[Scipy-svn] r6407 - in trunk/doc/source: . tutorial

scipy-svn at scipy.org scipy-svn at scipy.org
Mon May 24 09:11:26 EDT 2010


Author: rgommers
Date: 2010-05-24 08:11:26 -0500 (Mon, 24 May 2010)
New Revision: 6407

Modified:
   trunk/doc/source/fftpack.rst
   trunk/doc/source/maxentropy.rst
   trunk/doc/source/special.rst
   trunk/doc/source/tutorial/interpolate.rst
   trunk/doc/source/tutorial/signal.rst
   trunk/doc/source/weave.rst
Log:
DOC: merge wiki edits - scipy-docs.

Modified: trunk/doc/source/fftpack.rst
===================================================================
--- trunk/doc/source/fftpack.rst	2010-05-24 13:11:07 UTC (rev 6406)
+++ trunk/doc/source/fftpack.rst	2010-05-24 13:11:26 UTC (rev 6407)
@@ -1,4 +1,149 @@
 =========================================
+Fourier Transforms (:mod:`scipy.fftpack`)
+=========================================
+
+.. sectionauthor:: Scipy Developers
+
+.. currentmodule:: scipy.fftpack
+
+.. warning::
+
+   This is currently a stub page
+
+
+.. contents::
+
+
+Fourier analysis is fundamentally a method for expressing a function as a
+sum of periodic components, and for recovering the signal from those
+components.  When both the function and its Fourier transform are
+replaced with discretized counterparts, it is called the discrete Fourier
+transform (DFT).  The DFT has become a mainstay of numerical computing in
+part because of a very fast algorithm for computing it, called the Fast
+Fourier Transform (FFT), which was known to Gauss (1805) and was brought
+to light in its current form by Cooley and Tukey [CT]_.  Press et al. [NR]_
+provide an accessible introduction to Fourier analysis and its
+applications.
+
+
+Fast Fourier transforms
+-----------------------
+
+One dimensional discrete Fourier transforms
+-------------------------------------------
+
+fft, ifft, rfft, irfft
+
+
+Two and n dimensional discrete Fourier transforms
+-------------------------------------------------
+
+fft in more than one dimension
+
+
+Discrete Cosine Transforms
+--------------------------
+
+
+Return the Discrete Cosine Transform [Mak]_ of arbitrary type sequence ``x``.
+
+For a single dimension array ``x``, ``dct(x, norm='ortho')`` is equal to
+matlab ``dct(x)``.
+
+There are theoretically 8 types of the DCT [WP]_, only the first 3 types are
+implemented in scipy. 'The' DCT generally refers to DCT type 2, and 'the'
+Inverse DCT generally refers to DCT type 3.
+
+type I
+~~~~~~
+
+There are several definitions of the DCT-I; we use the following
+(for ``norm=None``):
+
+.. math::
+   :nowrap:
+
+    \[ y_k = x_0 + (-1)^k x_{N-1} + 2\sum_{n=1}^{N-2} x_n
+    \cos\left({\pi nk\over N-1}\right),
+    \qquad 0 \le k < N. \]
+
+Only None is supported as normalization mode for DCT-I. Note also that the
+DCT-I is only supported for input size > 1
+
+type II
+~~~~~~~
+
+There are several definitions of the DCT-II; we use the following
+(for ``norm=None``):
+
+.. math::
+   :nowrap:
+
+    \[ y_k = 2 \sum_{n=0}^{N-1} x_n
+    \cos \left({\pi(2n+1)k \over 2N} \right)
+    \qquad 0 \le k < N.\]
+
+If ``norm='ortho'``, :math:`y_k` is multiplied by a scaling factor `f`:
+
+.. math::
+   :nowrap:
+
+    \[f = \begin{cases} \sqrt{1/(4N)}, & \text{if $k = 0$} \\
+       \sqrt{1/(2N)}, & \text{otherwise} \end{cases} \]
+
+
+Which makes the corresponding matrix of coefficients orthonormal
+(`OO' = Id`).
+
+type III
+~~~~~~~~
+
+There are several definitions, we use the following
+(for ``norm=None``):
+
+.. math::
+   :nowrap:
+
+    \[ y_k = x_0 + 2 \sum_{n=1}^{N-1} x_n
+    \cos\left({\pi n(2k+1) \over 2N}\right)
+    \qquad 0 \le k < N,\]
+
+or, for ``norm='ortho'``:
+
+.. math::
+   :nowrap:
+
+    \[ y_k = {x_0\over\sqrt{N}} + {1\over\sqrt{N}} \sum_{n=1}^{N-1}
+    x_n \cos\left({\pi n(2k+1) \over 2N}\right)
+    \qquad 0 \le k < N.\]
+
+The (unnormalized) DCT-III is the inverse of the (unnormalized) DCT-II, up
+to a factor `2N`. The orthonormalized DCT-III is exactly the inverse of the
+orthonormalized DCT-II.
+
+References
+~~~~~~~~~~
+
+.. [CT] Cooley, James W., and John W. Tukey, 1965, "An algorithm for the
+        machine calculation of complex Fourier series," *Math. Comput.*
+        19: 297-301.
+
+.. [NR] Press, W., Teukolsky, S., Vetterline, W.T., and Flannery, B.P.,
+        2007, *Numerical Recipes: The Art of Scientific Computing*, ch.
+        12-13.  Cambridge Univ. Press, Cambridge, UK.
+
+.. [Mak] J. Makhoul, 1980, 'A Fast Cosine Transform in One and Two Dimensions',
+       `IEEE Transactions on acoustics, speech and signal processing`
+       vol. 28(1), pp. 27-34, http://dx.doi.org/10.1109/TASSP.1980.1163351
+
+.. [WP] http://en.wikipedia.org/wiki/Discrete_cosine_transform
+
+
+FFT convolution
+---------------
+
+scipy.fftpack.convolve performs a convolution of two one-dimensional
+arrays in frequency domain.
 Fourier transforms (:mod:`scipy.fftpack`)
 =========================================
 

Modified: trunk/doc/source/maxentropy.rst
===================================================================
--- trunk/doc/source/maxentropy.rst	2010-05-24 13:11:07 UTC (rev 6406)
+++ trunk/doc/source/maxentropy.rst	2010-05-24 13:11:26 UTC (rev 6407)
@@ -4,36 +4,40 @@
 
 .. automodule:: scipy.maxentropy
 
-
 Models
 ======
+.. autoclass:: scipy.maxentropy.basemodel
 
-.. autoclass:: model
+.. autosummary::
+   :toctree: generated/
 
+   basemodel.beginlogging
+   basemodel.endlogging
+   basemodel.clearcache
+   basemodel.crossentropy
+   basemodel.dual
+   basemodel.fit
+   basemodel.grad
+   basemodel.log
+   basemodel.logparams
+   basemodel.normconst
+   basemodel.reset
+   basemodel.setcallback
+   basemodel.setparams
+   basemodel.setsmooth
+
+.. autoclass:: scipy.maxentropy.model
+
 .. autosummary::
    :toctree: generated/
 
-   model.beginlogging
-   model.endlogging
-   model.clearcache
-   model.crossentropy
-   model.dual
-   model.fit
-   model.grad
-   model.log
-   model.logparams
-   model.normconst
-   model.reset
-   model.setcallback
-   model.setparams
-   model.setsmooth
    model.expectations
    model.lognormconst
    model.logpmf
    model.pmf_function
    model.setfeaturesandsamplespace
 
-.. autoclass:: bigmodel
+.. autoclass:: scipy.maxentropy.bigmodel
 
 .. autosummary::
    :toctree: generated/
@@ -48,7 +52,7 @@
    bigmodel.stochapprox
    bigmodel.test
 
-.. autoclass:: conditionalmodel
+.. autoclass:: scipy.maxentropy.conditionalmodel
 
 .. autosummary::
    :toctree: generated/

Modified: trunk/doc/source/special.rst
===================================================================
--- trunk/doc/source/special.rst	2010-05-24 13:11:07 UTC (rev 6406)
+++ trunk/doc/source/special.rst	2010-05-24 13:11:26 UTC (rev 6407)
@@ -160,7 +160,7 @@
    sph_kn
    sph_inkn
 
-Ricatti-Bessel Functions
+Riccati-Bessel Functions
 ^^^^^^^^^^^^^^^^^^^^^^^^
 
 These are not universal functions:

Modified: trunk/doc/source/tutorial/interpolate.rst
===================================================================
--- trunk/doc/source/tutorial/interpolate.rst	2010-05-24 13:11:07 UTC (rev 6406)
+++ trunk/doc/source/tutorial/interpolate.rst	2010-05-24 13:11:26 UTC (rev 6407)
@@ -11,7 +11,8 @@
 first facility is an interpolation class which performs linear
 1-dimensional interpolation. The second facility is based on the
 FORTRAN library FITPACK and provides functions for 1- and
-2-dimensional (smoothed) cubic-spline interpolation.
+2-dimensional (smoothed) cubic-spline interpolation. There are both
+procedural and object-oriented interfaces for the FITPACK library.
 
 
 Linear 1-d interpolation (:class:`interp1d`)
@@ -22,11 +23,11 @@
 anywhere within the domain defined by the given data using linear
 interpolation. An instance of this class is created by passing the 1-d
 vectors comprising the data. The instance of this class defines a
-:meth:`__call__ <interp1d.__call__>` method and can therefore by
-treated like a function which interpolates between known data values
-to obtain unknown values (it also has a docstring for help). Behavior
-at the boundary can be specified at instantiation time. The following
-example demonstrates it's use.
+__call__ method and can therefore by treated like a function which
+interpolates between known data values to obtain unknown values (it
+also has a docstring for help). Behavior at the boundary can be
+specified at instantiation time. The following example demonstrates
+it's use.
 
 .. plot::
 
@@ -45,13 +46,13 @@
 ..             class :obj:`interpolate.interp1d`
 
 
-Spline interpolation in 1-d (interpolate.splXXX)
-------------------------------------------------
+Spline interpolation in 1-d: Procedural (interpolate.splXXX)
+------------------------------------------------------------
 
 Spline interpolation requires two essential steps: (1) a spline
 representation of the curve is computed, and (2) the spline is
 evaluated at the desired points. In order to find the spline
-representation, there are two different was to represent a curve and
+representation, there are two different ways to represent a curve and
 obtain (smoothing) spline coefficients: directly and parametrically.
 The direct method finds the spline representation of a curve in a two-
 dimensional plane using the function :obj:`splrep`. The
@@ -84,7 +85,7 @@
 Once the spline representation of the data has been determined,
 functions are available for evaluating the spline
 (:func:`splev`) and its derivatives
-(:func:`splev`, :func:`splade`) at any point
+(:func:`splev`, :func:`spalde`) at any point
 and the integral of the spline between any two points (
 :func:`splint`). In addition, for cubic splines ( :math:`k=3`
 ) with 8 or more knots, the roots of the spline can be estimated (
@@ -160,10 +161,81 @@
    >>> plt.title('Spline of parametrically-defined curve')
    >>> plt.show()
 
+Spline interpolation in 1-d: Object-oriented (:class:`UnivariateSpline`)
+-----------------------------------------------------------------------------
 
-Two-dimensional spline representation (:func:`bisplrep`)
---------------------------------------------------------
+The spline-fitting capabilities described above are also available via
+an objected-oriented interface.  The one dimensional splines are
+objects of the `UnivariateSpline` class, and are created with the
+:math:`x` and :math:`y` components of the curve provided as arguments
+to the constructor.  The class defines __call__, allowing the object
+to be called with the x-axis values at which the spline should be
+evaluated, returning the interpolated y-values.  This is shown in
+the example below for the subclass `InterpolatedUnivariateSpline`.
+The methods :meth:`integral <UnivariateSpline.integral>`,
+:meth:`derivatives <UnivariateSpline.derivatives>`, and
+:meth:`roots <UnivariateSpline.roots>` methods are also available
+on `UnivariateSpline` objects, allowing definite integrals,
+derivatives, and roots to be computed for the spline.
 
+The UnivariateSpline class can also be used to smooth data by
+providing a non-zero value of the smoothing parameter `s`, with the
+same meaning as the `s` keyword of the :obj:`splrep` function
+described above.  This results in a spline that has fewer knots
+than the number of data points, and hence is no longer strictly
+an interpolating spline, but rather a smoothing spline.  If this
+is not desired, the `InterpolatedUnivariateSpline` class is available.
+It is a subclass of `UnivariateSpline` that always passes  through all
+points (equivalent to forcing the smoothing parameter to 0).  This
+class is demonstrated in the example below.
+
+The `LSQUnivarateSpline` is the other subclass of `UnivarateSpline`.
+It allows the user to specify the number and location of internal
+knots as explicitly with the parameter `t`.  This allows creation
+of customized splines with non-linear spacing, to interpolate in
+some domains and smooth in others, or change the character of the
+spline.
+
+
+.. plot::
+
+   >>> import numpy as np
+   >>> import matplotlib.pyplot as plt
+   >>> from scipy import interpolate
+
+   InterpolatedUnivariateSpline
+
+   >>> x = np.arange(0,2*np.pi+np.pi/4,2*np.pi/8)
+   >>> y = np.sin(x)
+   >>> s = interpolate.InterpolatedUnivariateSpline(x,y)
+   >>> xnew = np.arange(0,2*np.pi,np.pi/50)
+   >>> ynew = s(xnew)
+
+   >>> plt.figure()
+   >>> plt.plot(x,y,'x',xnew,ynew,xnew,np.sin(xnew),x,y,'b')
+   >>> plt.legend(['Linear','InterpolatedUnivariateSpline', 'True'])
+   >>> plt.axis([-0.05,6.33,-1.05,1.05])
+   >>> plt.title('InterpolatedUnivariateSpline')
+   >>> plt.show()
+
+   LSQUnivarateSpline with non-uniform knots
+
+   >>> t = [np.pi/2-.1,np.pi/2-.1,3*np.pi/2-.1,3*np.pi/2+.1]
+   >>> s = interpolate.LSQUnivariateSpline(x,y,t)
+   >>> ynew = s(xnew)
+
+   >>> plt.figure()
+   >>> plt.plot(x,y,'x',xnew,ynew,xnew,np.sin(xnew),x,y,'b')
+   >>> plt.legend(['Linear','LSQUnivariateSpline', 'True'])
+   >>> plt.axis([-0.05,6.33,-1.05,1.05])
+   >>> plt.title('Spline with Specified Interior Knots')
+   >>> plt.show()
+
+
+
+Two-dimensional spline representation: Procedural (:func:`bisplrep`)
+--------------------------------------------------------------------
+
 For (smooth) spline-fitting to a two dimensional surface, the function
 :func:`bisplrep` is available. This function takes as required inputs
 the **1-D** arrays *x*, *y*, and *z* which represent points on the
@@ -234,6 +306,18 @@
 
 ..   :caption: Example of two-dimensional spline interpolation.
 
+
+Two-dimensional spline representation: Object-oriented (:class:`BivariateSpline`)
+---------------------------------------------------------------------------------
+
+The :class:`BivariateSpline` class is the 2-dimensional analog of the
+:class:`UnivariateSpline` class.  It and its subclasses implement
+the FITPACK functions described above in an object oriented fashion,
+allowing objects to be instantiated that can be called to compute
+the spline value by passing in the two coordinates as the two
+arguments.
+
+
 Using radial basis functions for smoothing/interpolation
 ---------------------------------------------------------
 
@@ -274,7 +358,7 @@
 
     >>> plt.subplot(2, 1, 2)
     >>> plt.plot(x, y, 'bo')
-    >>> plt.plot(xi, yi, 'g')
+    >>> plt.plot(xi, fi, 'g')
     >>> plt.plot(xi, np.sin(xi), 'r')
     >>> plt.title('Interpolation using RBF - multiquadrics')
     >>> plt.show()
@@ -313,4 +397,3 @@
     >>> plt.xlim(-2, 2)
     >>> plt.ylim(-2, 2)
     >>> plt.colorbar()
-

Modified: trunk/doc/source/tutorial/signal.rst
===================================================================
--- trunk/doc/source/tutorial/signal.rst	2010-05-24 13:11:07 UTC (rev 6406)
+++ trunk/doc/source/tutorial/signal.rst	2010-05-24 13:11:26 UTC (rev 6407)
@@ -159,10 +159,10 @@
 of the flattened Numpy array by an appropriate matrix resulting in
 another flattened Numpy array. Of course, this is not usually the best
 way to compute the filter as the matrices and vectors involved may be
-huge. For example filtering a :math:`512\times512` image with this
-method would require multiplication of a :math:`512^{2}x512^{2}`
-matrix with a :math:`512^{2}` vector. Just trying to store the
-:math:`512^{2}\times512^{2}` matrix using a standard Numpy array would
+huge. For example filtering a :math:`512 \times 512` image with this
+method would require multiplication of a :math:`512^2 \times 512^2`
+matrix with a :math:`512^2` vector. Just trying to store the
+:math:`512^2 \times 512^2` matrix using a standard Numpy array would
 require :math:`68,719,476,736` elements. At 4 bytes per element this
 would require :math:`256\textrm{GB}` of memory. In most applications
 most of the elements of this matrix are zero and a different method
@@ -439,106 +439,106 @@
 ..
 .. Detrend
 .. """""""
-.. 
+..
 .. Filter design
 .. -------------
-.. 
-.. 
+..
+..
 .. Finite-impulse response design
 .. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Inifinite-impulse response design
 .. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Analog filter frequency response
 .. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Digital filter frequency response
 .. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Linear Time-Invariant Systems
 .. -----------------------------
-.. 
-.. 
+..
+..
 .. LTI Object
 .. ^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Continuous-Time Simulation
 .. ^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Step response
 .. ^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Impulse response
 .. ^^^^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Input/Output
 .. ============
-.. 
-.. 
+..
+..
 .. Binary
 .. ------
-.. 
-.. 
+..
+..
 .. Arbitrary binary input and output (fopen)
 .. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Read and write Matlab .mat files
 .. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Saving workspace
 .. ^^^^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Text-file
 .. ---------
-.. 
-.. 
+..
+..
 .. Read text-files (read_array)
 .. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Write a text-file (write_array)
 .. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. 
-.. 
+..
+..
 .. Fourier Transforms
 .. ==================
-.. 
-.. 
+..
+..
 .. One-dimensional
 .. ---------------
-.. 
-.. 
+..
+..
 .. Two-dimensional
 .. ---------------
-.. 
-.. 
+..
+..
 .. N-dimensional
 .. -------------
-.. 
-.. 
+..
+..
 .. Shifting
 .. --------
-.. 
-.. 
+..
+..
 .. Sample frequencies
 .. ------------------
-.. 
-.. 
+..
+..
 .. Hilbert transform
 .. -----------------
-.. 
-.. 
+..
+..
 .. Tilbert transform
 .. -----------------

Modified: trunk/doc/source/weave.rst
===================================================================
--- trunk/doc/source/weave.rst	2010-05-24 13:11:07 UTC (rev 6406)
+++ trunk/doc/source/weave.rst	2010-05-24 13:11:26 UTC (rev 6407)
@@ -8,3 +8,12 @@
 
 .. automodule:: scipy.weave
    :members:
+
+
+.. autosummary::
+   :toctree: generated/
+
+   inline
+   blitz
+   ext_tools
+   accelerate




More information about the Scipy-svn mailing list