Skip to content

Commit d12e5e8

Browse files
mkg33rgommers
authored andcommitted
updated tutorials
punctuation, minor stylistic issues
1 parent 5c6562a commit d12e5e8

File tree

4 files changed

+299
-300
lines changed

4 files changed

+299
-300
lines changed

doc/API.rst.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ section that the submodule in question is public.
8383
API definition
8484
--------------
8585

86-
Every submodule listed below is public. That means that these submodules are
86+
Every submodule listed below is public. That means that these submodules are
8787
unlikely to be renamed or changed in an incompatible way, and if that is
8888
necessary, a deprecation warning will be raised for one SciPy release before the
8989
change is made.
@@ -159,8 +159,8 @@ following, a *SciPy module* is defined as a Python package, say
159159

160160
* Ideally, each SciPy module should be as self-contained as possible.
161161
That is, it should have minimal dependencies on other packages or
162-
modules. Even dependencies on other SciPy modules should be kept to
163-
a minimum. A dependency on NumPy is of course assumed.
162+
modules. Even dependencies on other SciPy modules should be kept to
163+
a minimum. A dependency on NumPy is of course assumed.
164164

165165
* Directory ``yyy/`` contains:
166166

@@ -187,7 +187,7 @@ following, a *SciPy module* is defined as a Python package, say
187187
module.
188188

189189
Tutorial-style documentation with extensive examples should be
190-
separate, and put under ``doc/source/tutorial/``
190+
separate and put under ``doc/source/tutorial/``.
191191

192192
See the existing SciPy submodules for guidance.
193193

doc/source/tutorial/fft.rst

+42-42
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@ Fourier Transforms (:mod:`scipy.fft`)
99

1010

1111
Fourier analysis is a method for expressing a function as a sum of periodic
12-
components, and for recovering the signal from those components. When both
12+
components, and for recovering the signal from those components. When both
1313
the function and its Fourier transform are replaced with discretized
14-
counterparts, it is called the discrete Fourier transform (DFT). The DFT has
14+
counterparts, it is called the discrete Fourier transform (DFT). The DFT has
1515
become a mainstay of numerical computing in part because of a very fast
1616
algorithm for computing it, called the Fast Fourier Transform (FFT), which was
1717
known to Gauss (1805) and was brought to light in its current form by Cooley
18-
and Tukey [CT65]_. Press et al. [NR07]_ provide an accessible introduction to
18+
and Tukey [CT65]_. Press et al. [NR07]_ provide an accessible introduction to
1919
Fourier analysis and its applications.
2020

2121
.. note::
2222

2323
PyFFTW_ provides a way to replace a number of functions in `scipy.fft`
2424
with its own functions, which are usually significantly faster, via
25-
pyfftw.interfaces_. Because PyFFTW_ relies on the GPL-licensed FFTW_ it
26-
cannot be included in SciPy. Users for whom the speed of FFT routines is
25+
pyfftw.interfaces_. Because PyFFTW_ relies on the GPL-licensed FFTW_ it
26+
cannot be included in SciPy. Users for whom the speed of FFT routines is
2727
critical should consider installing PyFFTW_.
2828

2929

3030
Fast Fourier transforms
3131
-----------------------
3232

33-
One dimensional discrete Fourier transforms
33+
1-D discrete Fourier transforms
3434
___________________________________________
3535

3636
The FFT `y[k]` of length :math:`N` of the length-:math:`N` sequence `x[n]` is
@@ -47,7 +47,7 @@ and the inverse transform is defined as follows
4747
x[n] = \frac{1}{N} \sum_{k=0}^{N-1} e^{2 \pi j \frac{k n}{N} } y[k] \, .
4848
4949
These transforms can be calculated by means of :func:`fft` and :func:`ifft`,
50-
respectively as shown in the following example.
50+
respectively, as shown in the following example.
5151

5252
>>> from scipy.fft import fft, ifft
5353
>>> x = np.array([1.0, 2.0, 1.0, -1.0, 1.5])
@@ -76,8 +76,8 @@ which corresponds to :math:`y[0]`. For N even, the elements
7676
:math:`y[1]...y[N/2-1]` contain the positive-frequency terms, and the elements
7777
:math:`y[N/2]...y[N-1]` contain the negative-frequency terms, in order of
7878
decreasingly negative frequency. For N odd, the elements
79-
:math:`y[1]...y[(N-1)/2]` contain the positive- frequency terms, and the
80-
elements :math:`y[(N+1)/2]...y[N-1]` contain the negative- frequency terms, in
79+
:math:`y[1]...y[(N-1)/2]` contain the positive-frequency terms, and the
80+
elements :math:`y[(N+1)/2]...y[N-1]` contain the negative-frequency terms, in
8181
order of decreasingly negative frequency.
8282

8383
In case the sequence x is real-valued, the values of :math:`y[n]` for positive
@@ -104,7 +104,7 @@ The example plots the FFT of the sum of two sines.
104104
>>> plt.show()
105105

106106

107-
The FFT input signal is inherently truncated. This truncation can be modelled
107+
The FFT input signal is inherently truncated. This truncation can be modeled
108108
as multiplication of an infinite signal with a rectangular window function. In
109109
the spectral domain this multiplication becomes convolution of the signal
110110
spectrum with the window function spectrum, being of form :math:`\sin(x)/x`.
@@ -181,7 +181,7 @@ The function :func:`rfft` calculates the FFT of a real sequence and outputs the
181181
complex FFT coefficients :math:`y[n]` for only half of the frequency range. The
182182
remaining negative frequency components are implied by the Hermitian symmetry of
183183
the FFT for a real input (``y[n] = conj(y[-n])``). In case of N being even:
184-
:math:`[Re(y[0]) + 0j, y[1], ..., Re(y[N/2]) + 0j]`; in case N being odd
184+
:math:`[Re(y[0]) + 0j, y[1], ..., Re(y[N/2]) + 0j]`; in case of N being odd
185185
:math:`[Re(y[0]) + 0j, y[1], ..., y[N/2]`. The terms shown explicitly as
186186
:math:`Re(y[k]) + 0j` are restricted to be purely real since, by the hermitian
187187
property, they are their own complex conjugate.
@@ -210,34 +210,34 @@ array([ 4.5 +0.j , 2.08155948-1.65109876j,
210210
array([ 4.5 +0.j , 2.08155948-1.65109876j,
211211
-1.83155948+1.60822041j])
212212

213-
Notice that the :func:`rfft` of odd and even length signals are the same shape.
214-
By default, :func:`irfft` assumes the ouput signal should be of even length. And
215-
so for odd signals, will give the wrong result:
213+
Notice that the :func:`rfft` of odd and even length signals are of the same shape.
214+
By default, :func:`irfft` assumes the output signal should be of even length. And
215+
so, for odd signals, it will give the wrong result:
216216

217217
>>> irfft(yr)
218218
array([ 1.70788987, 2.40843925, -0.37366961, 0.75734049])
219219

220-
To recover the original odd length signal, we **must** pass the output shape by
220+
To recover the original odd-length signal, we **must** pass the output shape by
221221
the `n` parameter.
222222

223223
>>> irfft(yr, n=len(x))
224224
array([ 1. , 2. , 1. , -1. , 1.5])
225225

226226

227227

228-
Two and n-dimensional discrete Fourier transforms
228+
2- and N-D discrete Fourier transforms
229229
_________________________________________________
230230

231-
The functions :func:`fft2` and :func:`ifft2` provide 2-dimensional FFT, and
232-
IFFT, respectively. Similar, :func:`fftn` and :func:`ifftn` provide
233-
n-dimensional FFT, and IFFT, respectively.
231+
The functions :func:`fft2` and :func:`ifft2` provide 2-D FFT and
232+
IFFT, respectively. Similarly, :func:`fftn` and :func:`ifftn` provide
233+
N-D FFT, and IFFT, respectively.
234234

235-
For real input signals, similar to :func:`rfft`, we have the functions
236-
:func:`rfft2` and :func:`irfft2` for 2-dimensional real transforms;
237-
:func:`rfftn` and :func:`irfftn` for n-dimensional real transforms.
235+
For real-input signals, similarly to :func:`rfft`, we have the functions
236+
:func:`rfft2` and :func:`irfft2` for 2-D real transforms;
237+
:func:`rfftn` and :func:`irfftn` for N-D real transforms.
238238

239-
The example below demonstrates a 2-dimensional IFFT and plots the resulting
240-
(2-dimensional) time-domain signals.
239+
The example below demonstrates a 2-D IFFT and plots the resulting
240+
(2-D) time-domain signals.
241241

242242
.. plot::
243243

@@ -294,7 +294,7 @@ SciPy uses the following definition of the unnormalized DCT-I
294294
\cos\left(\frac{\pi nk}{N-1}\right),
295295
\qquad 0 \le k < N.
296296
297-
Note that the DCT-I is only supported for input size > 1
297+
Note that the DCT-I is only supported for input size > 1.
298298

299299
Type II DCT
300300
___________
@@ -320,7 +320,7 @@ In this case, the DCT "base functions" :math:`\phi_k[n] = 2 f \cos
320320

321321
.. math::
322322
323-
\sum_{n=0}^{N-1} \phi_k[n] \phi_l[n] = \delta_{lk}
323+
\sum_{n=0}^{N-1} \phi_k[n] \phi_l[n] = \delta_{lk}.
324324
325325
326326
Type III DCT
@@ -347,23 +347,23 @@ ____________
347347

348348

349349
The (unnormalized) DCT-III is the inverse of the (unnormalized) DCT-II, up to a
350-
factor `2N`. The orthonormalized DCT-III is exactly the inverse of the
350+
factor of `2N`. The orthonormalized DCT-III is exactly the inverse of the
351351
orthonormalized DCT- II. The function :func:`idct` performs the mappings between
352-
the DCT and IDCT types, as well as performing the correct normalization.
352+
the DCT and IDCT types, as well as the correct normalization.
353353

354354
The following example shows the relation between DCT and IDCT for different
355355
types and normalizations.
356356

357357
>>> from scipy.fft import dct, idct
358358
>>> x = np.array([1.0, 2.0, 1.0, -1.0, 1.5])
359359

360-
The DCT-II and DCT-III are each others inverses, so for an orthonormal transform
360+
The DCT-II and DCT-III are each other's inverses, so for an orthonormal transform
361361
we return back to the original signal.
362362

363363
>>> dct(dct(x, type=2, norm='ortho'), type=3, norm='ortho')
364364
array([ 1. , 2. , 1. , -1. , 1.5])
365365

366-
Doing the same under default normalization however, we pick up an extra scaling
366+
Doing the same under default normalization, however, we pick up an extra scaling
367367
factor of :math:`2N=10` since the forward transform is unnormalized.
368368

369369
>>> dct(dct(x, type=2), type=3)
@@ -376,8 +376,8 @@ giving a correctly normalized result.
376376
>>> idct(dct(x, type=2), type=2)
377377
array([ 1. , 2. , 1. , -1. , 1.5])
378378

379-
Analogous results can be seen for the DCT-I which is its own inverse up to a
380-
factor of :math:`2(N-1)`
379+
Analogous results can be seen for the DCT-I, which is its own inverse up to a
380+
factor of :math:`2(N-1)`.
381381

382382
>>> dct(dct(x, type=1, norm='ortho'), type=1, norm='ortho')
383383
array([ 1. , 2. , 1. , -1. , 1.5])
@@ -388,7 +388,7 @@ array([ 8. , 16., 8. , -8. , 12.])
388388
>>> idct(dct(x, type=1), type=1)
389389
array([ 1. , 2. , 1. , -1. , 1.5])
390390

391-
And for the DCT-IV which is also its own inverse up to a factor of :math:`2N`
391+
And for the DCT-IV, which is also its own inverse up to a factor of :math:`2N`.
392392

393393
>>> dct(dct(x, type=4, norm='ortho'), type=4, norm='ortho')
394394
array([ 1. , 2. , 1. , -1. , 1.5])
@@ -408,7 +408,7 @@ Zeroing out the other coefficients leads to a small reconstruction error, a
408408
fact which is exploited in lossy signal compression (e.g. JPEG compression).
409409

410410
The example below shows a signal x and two reconstructions (:math:`x_{20}` and
411-
:math:`x_{15}`)from the signal's DCT coefficients. The signal :math:`x_{20}`
411+
:math:`x_{15}`) from the signal's DCT coefficients. The signal :math:`x_{20}`
412412
is reconstructed from the first 20 DCT coefficients, :math:`x_{15}` is
413413
reconstructed from the first 15 DCT coefficients. It can be seen that the
414414
relative error of using 20 coefficients is still very small (~0.1%), but
@@ -446,7 +446,7 @@ Discrete Sine Transforms
446446
SciPy provides a DST [Mak]_ with the function :func:`dst` and a corresponding IDST
447447
with the function :func:`idst`.
448448

449-
There are theoretically 8 types of the DST for different combinations of
449+
There are, theoretically, 8 types of the DST for different combinations of
450450
even/odd boundary conditions and boundary off sets [WPS]_, only the first 3
451451
types are implemented in scipy.
452452

@@ -462,7 +462,7 @@ definition of the unnormalized DST-I (``norm=None``):
462462
\right), \qquad 0 \le k < N.
463463
464464
Note also that the DST-I is only supported for input size > 1. The
465-
(unnormalized) DST-I is its own inverse, up to a factor `2(N+1)`.
465+
(unnormalized) DST-I is its own inverse, up to a factor of `2(N+1)`.
466466

467467
Type II DST
468468
___________
@@ -491,19 +491,19 @@ DST and IDST
491491
____________
492492

493493

494-
The following example below shows the relation between DST and IDST for
494+
The following example shows the relation between DST and IDST for
495495
different types and normalizations.
496496

497497
>>> from scipy.fft import dst, idst
498498
>>> x = np.array([1.0, 2.0, 1.0, -1.0, 1.5])
499499

500-
The DST-II and DST-III are each others inverses, so for an orthonormal transform
500+
The DST-II and DST-III are each other's inverses, so for an orthonormal transform
501501
we return back to the original signal.
502502

503503
>>> dst(dst(x, type=2, norm='ortho'), type=3, norm='ortho')
504504
array([ 1. , 2. , 1. , -1. , 1.5])
505505

506-
Doing the same under default normalization however, we pick up an extra scaling
506+
Doing the same under default normalization, however, we pick up an extra scaling
507507
factor of :math:`2N=10` since the forward transform is unnormalized.
508508

509509
>>> dst(dst(x, type=2), type=3)
@@ -515,8 +515,8 @@ giving a correctly normalized result.
515515
>>> idst(dst(x, type=2), type=2)
516516
array([ 1. , 2. , 1. , -1. , 1.5])
517517

518-
Analogous results can be seen for the DST-I which is its own inverse up to a
519-
factor of :math:`2(N-1)`
518+
Analogous results can be seen for the DST-I, which is its own inverse up to a
519+
factor of :math:`2(N-1)`.
520520

521521
>>> dst(dst(x, type=1, norm='ortho'), type=1, norm='ortho')
522522
array([ 1. , 2. , 1. , -1. , 1.5])
@@ -527,7 +527,7 @@ array([ 12., 24., 12., -12., 18.])
527527
>>> idst(dst(x, type=1), type=1)
528528
array([ 1. , 2. , 1. , -1. , 1.5])
529529

530-
And for the DST-IV which is also its own inverse up to a factor of :math:`2N`
530+
And for the DST-IV, which is also its own inverse up to a factor of :math:`2N`.
531531

532532
>>> dst(dst(x, type=4, norm='ortho'), type=4, norm='ortho')
533533
array([ 1. , 2. , 1. , -1. , 1.5])

0 commit comments

Comments
 (0)