Changeset 7007
- Timestamp:
- 05/20/09 16:50:09 (9 months ago)
- Location:
- trunk/numpy
- Files:
-
- 2 modified
-
lib/function_base.py (modified) (16 diffs)
-
random/mtrand/mtrand.pyx (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/numpy/lib/function_base.py
r6858 r7007 2071 2071 Plot the window and the frequency response: 2072 2072 2073 >>> from numpy import clip, log10, array, bartlett 2073 >>> from numpy import clip, log10, array, bartlett, linspace 2074 2074 >>> from scipy.fftpack import fft, fftshift 2075 2075 >>> import matplotlib.pyplot as plt … … 2081 2081 >>> plt.xlabel("Sample") 2082 2082 >>> plt.show() 2083 2083 2084 >>> plt.figure() 2084 2085 >>> A = fft(window, 2048) / 25.5 2085 2086 >>> mag = abs(fftshift(A)) … … 2088 2089 >>> response = clip(response,-100,100) 2089 2090 >>> plt.plot(freq, response) 2090 >>> plt.title("Frequency response of B artlettwindow")2091 >>> plt.title("Frequency response of Blackman window") 2091 2092 >>> plt.ylabel("Magnitude [dB]") 2092 2093 >>> plt.xlabel("Normalized frequency [cycles per sample]") 2093 >>> plt.axis('tight'); plt.show() 2094 >>> plt.axis('tight') 2095 >>> plt.show() 2094 2096 2095 2097 """ … … 2168 2170 Plot the window and its frequency response (requires SciPy and matplotlib): 2169 2171 2170 >>> from numpy import clip, log10, array, bartlett 2171 >>> from numpy.fft import fft 2172 >>> from numpy import clip, log10, array, bartlett, linspace 2173 >>> from numpy.fft import fft, fftshift 2172 2174 >>> import matplotlib.pyplot as plt 2173 2175 … … 2178 2180 >>> plt.xlabel("Sample") 2179 2181 >>> plt.show() 2180 2182 2183 >>> plt.figure() 2181 2184 >>> A = fft(window, 2048) / 25.5 2182 2185 >>> mag = abs(fftshift(A)) … … 2188 2191 >>> plt.ylabel("Magnitude [dB]") 2189 2192 >>> plt.xlabel("Normalized frequency [cycles per sample]") 2190 >>> plt.axis('tight'); plt.show() 2193 >>> plt.axis('tight') 2194 >>> plt.show() 2191 2195 2192 2196 """ … … 2262 2266 2263 2267 >>> window = np.hanning(51) 2264 >>> plt.subplot(121)2265 2268 >>> plt.plot(window) 2266 2269 >>> plt.title("Hann window") 2267 2270 >>> plt.ylabel("Amplitude") 2268 2271 >>> plt.xlabel("Sample") 2269 2272 >>> plt.show() 2273 2274 >>> plt.figure() 2270 2275 >>> A = fft(window, 2048) / 25.5 2271 2276 >>> mag = abs(fftshift(A)) … … 2273 2278 >>> response = 20*np.log10(mag) 2274 2279 >>> response = np.clip(response,-100,100) 2275 >>> plt.subplot(122)2276 2280 >>> plt.plot(freq, response) 2277 2281 >>> plt.title("Frequency response of the Hann window") 2278 2282 >>> plt.ylabel("Magnitude [dB]") 2279 2283 >>> plt.xlabel("Normalized frequency [cycles per sample]") 2280 >>> plt.axis('tight'); plt.show() 2284 >>> plt.axis('tight') 2285 >>> plt.show() 2281 2286 2282 2287 """ … … 2347 2352 Plot the window and the frequency response: 2348 2353 2349 >>> from numpy import clip, log10, array, hamming 2354 >>> from numpy import clip, log10, array, hamming, linspace 2350 2355 >>> from scipy.fftpack import fft, fftshift 2351 2356 >>> import matplotlib.pyplot as plt … … 2358 2363 >>> plt.show() 2359 2364 2365 >>> plt.figure() 2360 2366 >>> A = fft(window, 2048) / 25.5 2361 2367 >>> mag = abs(fftshift(A)) … … 2367 2373 >>> plt.ylabel("Magnitude [dB]") 2368 2374 >>> plt.xlabel("Normalized frequency [cycles per sample]") 2369 >>> plt.axis('tight'); plt.show() 2375 >>> plt.axis('tight') 2376 >>> plt.show() 2370 2377 2371 2378 """ … … 2592 2599 Plot the window and the frequency response: 2593 2600 2594 >>> from numpy import clip, log10, array, kaiser 2601 >>> from numpy import clip, log10, array, kaiser, linspace 2595 2602 >>> from scipy.fftpack import fft, fftshift 2596 2603 >>> import matplotlib.pyplot as plt … … 2603 2610 >>> plt.show() 2604 2611 2612 >>> plt.figure() 2605 2613 >>> A = fft(window, 2048) / 25.5 2606 2614 >>> mag = abs(fftshift(A)) … … 2612 2620 >>> plt.ylabel("Magnitude [dB]") 2613 2621 >>> plt.xlabel("Normalized frequency [cycles per sample]") 2614 >>> plt.axis('tight'); plt.show() 2622 >>> plt.axis('tight') 2623 >>> plt.show() 2615 2624 2616 2625 """ … … 2677 2686 2678 2687 >>> import matplotlib.pyplot as plt 2679 >>> plt.plot(x, sinc(x))2688 >>> plt.plot(x, np.sinc(x)) 2680 2689 >>> plt.title("Sinc Function") 2681 2690 >>> plt.ylabel("Amplitude") … … 2687 2696 >>> x = np.arange(-200., 201.)/50. 2688 2697 >>> xx = np.outer(x, x) 2689 >>> plt.imshow( sinc(xx))2698 >>> plt.imshow(np.sinc(xx)) 2690 2699 2691 2700 """ -
trunk/numpy/random/mtrand/mtrand.pyx
r6725 r7007 1280 1280 >>> import scipy.special as sps 1281 1281 >>> count, bins, ignored = plt.hist(s, 50, normed=True) 1282 >>> y = bins**(shape-1)*( (exp(-bins/scale))/\\1283 (sps.gamma(shape)*scale**shape))1282 >>> y = bins**(shape-1)*(exp(-bins/scale) / 1283 ... (sps.gamma(shape)*scale**shape)) 1284 1284 >>> plt.plot(bins, y, linewidth=2, color='r') 1285 1285 >>> plt.show() … … 1673 1673 >>> import scipy.special as sps 1674 1674 >>> count, bins, ignored = plt.hist(s, 50, normed=True) 1675 >>> x = arange(-pi, pi, 2*pi/50.)1676 >>> y = -np.exp(kappa*np.cos(x-mu))/(2* pi*sps.jn(0,kappa))1675 >>> x = np.arange(-np.pi, np.pi, 2*np.pi/50.) 1676 >>> y = -np.exp(kappa*np.cos(x-mu))/(2*np.pi*sps.jn(0,kappa)) 1677 1677 >>> plt.plot(x, y/max(y), linewidth=2, color='r') 1678 1678 >>> plt.show() … … 1859 1859 1860 1860 >>> import matplotlib.pyplot as plt 1861 >>> x = np.arange(1,100.)/50. 1861 1862 >>> def weib(x,n,a): 1862 1863 ... return (a / n) * (x / n)**(a - 1) * np.exp(-(x / n)**a) … … 2620 2621 Truncate s values at 50 so plot is interesting 2621 2622 >>> count, bins, ignored = plt.hist(s[s<50], 50, normed=True) 2622 >>> x = arange(1., 50.)2623 >>> x = np.arange(1., 50.) 2623 2624 >>> y = x**(-a)/sps.zetac(a) 2624 2625 >>> plt.plot(x, y/max(y), linewidth=2, color='r')
