package scipy

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
val get_py : string -> Py.Object.t

Get an attribute of this module as a Py.Object.t. This is useful to pass a Python function to another function.

val fft : ?n:int -> ?axis:int -> ?overwrite_x:bool -> x:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t * Py.Object.t

Return discrete Fourier transform of real or complex sequence.

The returned complex array contains ``y(0), y(1),..., y(n-1)`` where

``y(j) = (x * exp(-2*pi*sqrt(-1)*j*np.arange(n)/n)).sum()``.

Parameters ---------- x : array_like Array to Fourier transform. n : int, optional Length of the Fourier transform. If ``n < x.shapeaxis``, `x` is truncated. If ``n > x.shapeaxis``, `x` is zero-padded. The default results in ``n = x.shapeaxis``. axis : int, optional Axis along which the fft's are computed; the default is over the last axis (i.e., ``axis=-1``). overwrite_x : bool, optional If True, the contents of `x` can be destroyed; the default is False.

Returns ------- z : complex ndarray with the elements::

y(0),y(1),..,y(n/2),y(1-n/2),...,y(-1) if n is even y(0),y(1),..,y((n-1)/2),y(-(n-1)/2),...,y(-1) if n is odd

where::

y(j) = sumk=0..n-1 xk * exp(-sqrt(-1)*j*k* 2*pi/n), j = 0..n-1

See Also -------- ifft : Inverse FFT rfft : FFT of a real sequence

Notes ----- The packing of the result is 'standard': If ``A = fft(a, n)``, then ``A0`` contains the zero-frequency term, ``A1:n/2`` contains the positive-frequency terms, and ``An/2:`` contains the negative-frequency terms, in order of decreasingly negative frequency. So for an 8-point transform, the frequencies of the result are 0, 1, 2, 3, -4, -3, -2, -1. To rearrange the fft output so that the zero-frequency component is centered, like -4, -3, -2, -1, 0, 1, 2, 3, use `fftshift`.

Both single and double precision routines are implemented. Half precision inputs will be converted to single precision. Non floating-point inputs will be converted to double precision. Long-double precision inputs are not supported.

This function is most efficient when `n` is a power of two, and least efficient when `n` is prime.

Note that if ``x`` is real-valued then ``Aj == An-j.conjugate()``. If ``x`` is real-valued and ``n`` is even then ``An/2`` is real.

If the data type of `x` is real, a 'real FFT' algorithm is automatically used, which roughly halves the computation time. To increase efficiency a little further, use `rfft`, which does the same calculation, but only outputs half of the symmetrical spectrum. If the data is both real and symmetrical, the `dct` can again double the efficiency, by generating half of the spectrum from half of the signal.

Examples -------- >>> from scipy.fftpack import fft, ifft >>> x = np.arange(5) >>> np.allclose(fft(ifft(x)), x, atol=1e-15) # within numerical accuracy. True

val fft2 : ?shape:Py.Object.t -> ?axes:Py.Object.t -> ?overwrite_x:Py.Object.t -> x:Py.Object.t -> unit -> Py.Object.t

2-D discrete Fourier transform.

Return the two-dimensional discrete Fourier transform of the 2-D argument `x`.

See Also -------- fftn : for detailed information.

val fftn : ?shape:[ `I of int | `Array_like_of_ints of Py.Object.t ] -> ?axes:[ `I of int | `Array_like_of_ints of Py.Object.t ] -> ?overwrite_x:bool -> x:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Return multidimensional discrete Fourier transform.

The returned array contains::

yj_1,..,j_d = sumk_1=0..n_1-1, ..., k_d=0..n_d-1 xk_1,..,k_d * prodi=1..d exp(-sqrt(-1)*2*pi/n_i * j_i * k_i)

where d = len(x.shape) and n = x.shape.

Parameters ---------- x : array_like The (n-dimensional) array to transform. shape : int or array_like of ints or None, optional The shape of the result. If both `shape` and `axes` (see below) are None, `shape` is ``x.shape``; if `shape` is None but `axes` is not None, then `shape` is ``scipy.take(x.shape, axes, axis=0)``. If ``shapei > x.shapei``, the i-th dimension is padded with zeros. If ``shapei < x.shapei``, the i-th dimension is truncated to length ``shapei``. If any element of `shape` is -1, the size of the corresponding dimension of `x` is used. axes : int or array_like of ints or None, optional The axes of `x` (`y` if `shape` is not None) along which the transform is applied. The default is over all axes. overwrite_x : bool, optional If True, the contents of `x` can be destroyed. Default is False.

Returns ------- y : complex-valued n-dimensional numpy array The (n-dimensional) DFT of the input array.

See Also -------- ifftn

Notes ----- If ``x`` is real-valued, then ``y..., j_i, ... == y..., n_i-j_i, ....conjugate()``.

Both single and double precision routines are implemented. Half precision inputs will be converted to single precision. Non floating-point inputs will be converted to double precision. Long-double precision inputs are not supported.

Examples -------- >>> from scipy.fftpack import fftn, ifftn >>> y = (-np.arange(16), 8 - np.arange(16), np.arange(16)) >>> np.allclose(y, fftn(ifftn(y))) True

val ifft : ?n:int -> ?axis:int -> ?overwrite_x:bool -> x:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Return discrete inverse Fourier transform of real or complex sequence.

The returned complex array contains ``y(0), y(1),..., y(n-1)`` where

``y(j) = (x * exp(2*pi*sqrt(-1)*j*np.arange(n)/n)).mean()``.

Parameters ---------- x : array_like Transformed data to invert. n : int, optional Length of the inverse Fourier transform. If ``n < x.shapeaxis``, `x` is truncated. If ``n > x.shapeaxis``, `x` is zero-padded. The default results in ``n = x.shapeaxis``. axis : int, optional Axis along which the ifft's are computed; the default is over the last axis (i.e., ``axis=-1``). overwrite_x : bool, optional If True, the contents of `x` can be destroyed; the default is False.

Returns ------- ifft : ndarray of floats The inverse discrete Fourier transform.

See Also -------- fft : Forward FFT

Notes ----- Both single and double precision routines are implemented. Half precision inputs will be converted to single precision. Non floating-point inputs will be converted to double precision. Long-double precision inputs are not supported.

This function is most efficient when `n` is a power of two, and least efficient when `n` is prime.

If the data type of `x` is real, a 'real IFFT' algorithm is automatically used, which roughly halves the computation time.

Examples -------- >>> from scipy.fftpack import fft, ifft >>> import numpy as np >>> x = np.arange(5) >>> np.allclose(ifft(fft(x)), x, atol=1e-15) # within numerical accuracy. True

val ifft2 : ?shape:Py.Object.t -> ?axes:Py.Object.t -> ?overwrite_x:Py.Object.t -> x:Py.Object.t -> unit -> Py.Object.t

2-D discrete inverse Fourier transform of real or complex sequence.

Return inverse two-dimensional discrete Fourier transform of arbitrary type sequence x.

See `ifft` for more information.

See also -------- fft2, ifft

val ifftn : ?shape:Py.Object.t -> ?axes:Py.Object.t -> ?overwrite_x:Py.Object.t -> x:Py.Object.t -> unit -> Py.Object.t

Return inverse multi-dimensional discrete Fourier transform.

The sequence can be of an arbitrary type.

The returned array contains::

yj_1,..,j_d = 1/p * sumk_1=0..n_1-1, ..., k_d=0..n_d-1 xk_1,..,k_d * prodi=1..d exp(sqrt(-1)*2*pi/n_i * j_i * k_i)

where ``d = len(x.shape)``, ``n = x.shape``, and ``p = prodi=1..d n_i``.

For description of parameters see `fftn`.

See Also -------- fftn : for detailed information.

Examples -------- >>> from scipy.fftpack import fftn, ifftn >>> import numpy as np >>> y = (-np.arange(16), 8 - np.arange(16), np.arange(16)) >>> np.allclose(y, ifftn(fftn(y))) True

val irfft : ?n:int -> ?axis:int -> ?overwrite_x:bool -> x:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Return inverse discrete Fourier transform of real sequence x.

The contents of `x` are interpreted as the output of the `rfft` function.

Parameters ---------- x : array_like Transformed data to invert. n : int, optional Length of the inverse Fourier transform. If n < x.shapeaxis, x is truncated. If n > x.shapeaxis, x is zero-padded. The default results in n = x.shapeaxis. axis : int, optional Axis along which the ifft's are computed; the default is over the last axis (i.e., axis=-1). overwrite_x : bool, optional If True, the contents of `x` can be destroyed; the default is False.

Returns ------- irfft : ndarray of floats The inverse discrete Fourier transform.

See Also -------- rfft, ifft, scipy.fft.irfft

Notes ----- The returned real array contains::

y(0),y(1),...,y(n-1)

where for n is even::

y(j) = 1/n (sumk=1..n/2-1 (x2*k-1+sqrt(-1)*x2*k) * exp(sqrt(-1)*j*k* 2*pi/n)

  1. c.c. + x0 + (-1)**(j) xn-1)

and for n is odd::

y(j) = 1/n (sumk=1..(n-1)/2 (x2*k-1+sqrt(-1)*x2*k) * exp(sqrt(-1)*j*k* 2*pi/n)

  1. c.c. + x0)

c.c. denotes complex conjugate of preceding expression.

For details on input parameters, see `rfft`.

To process (conjugate-symmetric) frequency-domain data with a complex datatype, consider using the newer function `scipy.fft.irfft`.

Examples -------- >>> from scipy.fftpack import rfft, irfft >>> a = 1.0, 2.0, 3.0, 4.0, 5.0 >>> irfft(a) array( 2.6 , -3.16405192, 1.24398433, -1.14955713, 1.46962473) >>> irfft(rfft(a)) array(1., 2., 3., 4., 5.)

val rfft : ?n:int -> ?axis:int -> ?overwrite_x:bool -> x:[ `Ndarray of [> `Ndarray ] Np.Obj.t | `Real_valued of Py.Object.t ] -> unit -> Py.Object.t * Py.Object.t

Discrete Fourier transform of a real sequence.

Parameters ---------- x : array_like, real-valued The data to transform. n : int, optional Defines the length of the Fourier transform. If `n` is not specified (the default) then ``n = x.shapeaxis``. If ``n < x.shapeaxis``, `x` is truncated, if ``n > x.shapeaxis``, `x` is zero-padded. axis : int, optional The axis along which the transform is applied. The default is the last axis. overwrite_x : bool, optional If set to true, the contents of `x` can be overwritten. Default is False.

Returns ------- z : real ndarray The returned real array contains::

y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2)) if n is even y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2)),Im(y(n/2)) if n is odd

where::

y(j) = sumk=0..n-1 xk * exp(-sqrt(-1)*j*k*2*pi/n) j = 0..n-1

See Also -------- fft, irfft, scipy.fft.rfft

Notes ----- Within numerical accuracy, ``y == rfft(irfft(y))``.

Both single and double precision routines are implemented. Half precision inputs will be converted to single precision. Non floating-point inputs will be converted to double precision. Long-double precision inputs are not supported.

To get an output with a complex datatype, consider using the newer function `scipy.fft.rfft`.

Examples -------- >>> from scipy.fftpack import fft, rfft >>> a = 9, -9, 1, 3 >>> fft(a) array( 4. +0.j, 8.+12.j, 16. +0.j, 8.-12.j) >>> rfft(a) array( 4., 8., 12., 16.)

OCaml

Innovation. Community. Security.