NumPy provides enhanced distutils functionality to make it easier to build and install sub-packages, auto-generate code, and extension modules that use Fortran-compiled libraries. To use features of NumPy distutils, use the setup command from numpy.distutils.core. A useful Configuration class is also provided in numpy.distutils.misc_util that can make it easier to construct keyword arguments to pass to the setup function (by passing the dictionary obtained from the todict() method of the class). More information is available in the NumPy Distutils - Users Guide.
The choice and location of linked libraries such as BLAS and LAPACK as well as include paths and other such build options can be specified in a site.cfg file located in the NumPy root repository or a .numpy-site.cfg file in your home directory. See the site.cfg.example example file included in the NumPy repository or sdist for documentation.
ccompiler
ccompiler_opt
Provides the CCompilerOpt class, used for handling the CPU/hardware optimization, starting from parsing the command arguments, to managing the relation between the CPU baseline and dispatch-able features, also generating the required C headers and ending with compiling the sources with proper compiler's flags.
cpuinfo.cpu
core.Extension(name, sources[, ...])
exec_command
exec_command
log.set_verbosity(v[, force])
system_info.get_info(name[, notfound_action])
notfound_action:
system_info.get_standard_file(fname)
Returns a list of files named 'fname' from 1) System-wide directory (directory-location of this module) 2) Users HOME directory (os.environ['HOME']) 3) Local directory
Construct a configuration instance for the given package name. If parent_name is not None, then construct the package as a sub-package of the parent_name package. If top_path and package_path are None then they are assumed equal to the path of the file this instance was created in. The setup.py files in the numpy distribution are good examples of how to use the Configuration instance.
Return a dictionary compatible with the keyword arguments of distutils setup function.
Return the distutils distribution object for self.
Return list of subpackage configurations.
Name of the subpackage to get the configuration. ‘*’ in subpackage_name is handled as a wildcard.
If None, then the path is assumed to be the local path plus the subpackage_name. If a setup.py file is not found in the subpackage_path, then a default configuration is used.
Parent name.
Add a sub-package to the current Configuration instance.
This is useful in a setup.py script for adding sub-packages to a package.
name of the subpackage
if given, the subpackage path such as the subpackage is in subpackage_path / subpackage_name. If None,the subpackage is assumed to be located in the local path / subpackage_name.
Add data files to configuration data_files.
Argument(s) can be either
The form of each element of the files sequence is very flexible allowing many combinations of where to get the files from the package and where they should ultimately be installed on the system. The most basic usage is for an element of the files argument sequence to be a simple filename. This will cause that file from the local path to be installed to the installation path of the self.name package (package path). The file argument can also be a relative path in which case the entire relative path will be installed into the package directory. Finally, the file can be an absolute path name in which case the file will be found at the absolute path name but installed to the package path.
This basic behavior can be augmented by passing a 2-tuple in as the file argument. The first element of the tuple should specify the relative path (under the package install directory) where the remaining sequence of files should be installed to (it has nothing to do with the file-names in the source distribution). The second element of the tuple is the sequence of files that should be installed. The files in this sequence can be filenames, relative paths, or absolute paths. For absolute paths the file will be installed in the top-level package installation directory (regardless of the first argument). Filenames and relative path names will be installed in the package install directory under the path name given as the first element of the tuple.
Rules for installation paths:
An additional feature is that the path to a data-file can actually be a function that takes no arguments and returns the actual path(s) to the data-files. This is useful when the data files are generated while building the package.
Add files to the list of data_files to be included with the package.
will install these data files to:
where <package install directory> is the package (or sub-package) directory such as ‘/usr/lib/python2.4/site-packages/mypackage’ (‘C: Python2.4 Lib site-packages mypackage’) or ‘/usr/lib/python2.4/site- packages/mypackage/mysubpackage’ (‘C: Python2.4 Lib site-packages mypackage mysubpackage’).
Recursively add files under data_path to data_files list.
Recursively add files under data_path to the list of data_files to be installed (and distributed). The data_path can be either a relative path-name, or an absolute path-name, or a 2-tuple where the first argument shows where in the install directory the data directory should be installed to.
Argument can be either
Rules for installation paths:
For example suppose the source directory contains fun/foo.dat and fun/bar/car.dat:
Will install data-files to the locations:
Add paths to configuration include directories.
Add the given sequence of paths to the beginning of the include_dirs list. This list will be visible to all extension modules of the current package.
Add installable headers to configuration.
Add the given sequence of files to the beginning of the headers list. By default, headers will be installed under <python- include>/<self.name.replace(‘.’,’/’)>/ directory. If an item of files is a tuple, then its first argument specifies the actual installation location relative to the <python-include> path.
Argument(s) can be either:
Add extension to configuration.
Create and add an Extension instance to the ext_modules list. This method also takes the following optional keyword arguments that are passed on to the Extension constructor.
name of the extension
list of the sources. The list of sources may contain functions (called source generators) which must take an extension instance and a build directory as inputs and return a source file or list of source files or None. If None is returned then no sources are generated. If the Extension instance has no sources after processing all source generators, then no extension module is built.
The depends list contains paths to files or directories that the sources of the extension module depend on. If any path in the depends list is newer than the extension module, then the module will be rebuilt.
dict or list of dict of keywords to be appended to keywords.
The self.paths(…) method is applied to all lists that may contain paths.
Add library to configuration.
Name of the extension.
List of the sources. The list of sources may contain functions (called source generators) which must take an extension instance and a build directory as inputs and return a source file or list of source files or None. If None is returned then no sources are generated. If the Extension instance has no sources after processing all source generators, then no extension module is built.
The following keys are allowed:
Add scripts to configuration.
Add the sequence of files to the beginning of the scripts list. Scripts will be installed under the <prefix>/bin/ directory.
Similar to add_library, but the specified library is installed.
Most C libraries used with distutils are only used to build python extensions, but libraries built through this method will be installed so that they can be reused by third-party packages.
Name of the installed library.
List of the library’s source files. See add_library for details.
Path to install the library, relative to the current sub-package.
The following keys are allowed:
See also
The best way to encode the options required to link against the specified C libraries is to use a “libname.ini” file, and use get_info to retrieve the required options (see add_npy_pkg_config for more information).
Generate and install a npy-pkg config file from a template.
The config file generated from template is installed in the given install directory, using subst_dict for variable substitution.
The path of the template, relatively to the current package path.
Where to install the npy-pkg config file, relatively to the current package path.
If given, any string of the form @key@ will be replaced by subst_dict[key] in the template file when installed. The install prefix is always available through the variable @prefix@, since the install prefix is not easy to get reliably from setup.py.
See also
This works for both standard installs and in-place builds, i.e. the @prefix@ refer to the source directory for in-place builds.
Assuming the foo.ini.in file has the following content:
The generated file will have the following content:
and will be installed as foo.ini in the ‘lib’ subpath.
When cross-compiling with numpy distutils, it might be necessary to use modified npy-pkg-config files. Using the default/generated files will link with the host libraries (i.e. libnpymath.a). For cross-compilation you of-course need to link with target libraries, while using the host Python installation.
You can copy out the numpy/core/lib/npy-pkg-config directory, add a pkgdir value to the .ini files and set NPY_PKG_CONFIG_PATH environment variable to point to the directory with the modified npy-pkg-config files.
Example npymath.ini modified for cross-compilation:
Apply glob to paths and prepend local_path if needed.
Applies glob.glob(…) to each path in the sequence (if needed) and pre-pends the local_path if needed. Because this is called on all source lists, this allows wildcard characters to be specified in lists of sources for extension modules and libraries and scripts and allows path-names be relative to the source directory.
Returns the numpy.distutils config command instance.
Return a path to a temporary directory where temporary files should be placed.
Check for availability of Fortran 77 compiler.
Use it inside source generating function to ensure that setup distribution instance has been initialized.
True if a Fortran 77 compiler is available (because a simple Fortran 77 code was able to be compiled successfully).
Check for availability of Fortran 90 compiler.
Use it inside source generating function to ensure that setup distribution instance has been initialized.
True if a Fortran 90 compiler is available (because a simple Fortran 90 code was able to be compiled successfully)
Try to get version string of a package.
Return a version string of the current package or None if the version information could not be detected.
This method scans files named __version__.py, <packagename>_version.py, version.py, and __svn_version__.py for string variables version, __version__, and <packagename>_version, until a version number is found.
Appends a data function to the data_files list that will generate __svn_version__.py file to the current package directory.
Generate package __svn_version__.py file from SVN revision number, it will be removed after python exits but will be available when sdist, etc commands are executed.
If __svn_version__.py existed before, nothing is done.
This is intended for working with source directories that are in an SVN repository.
Generate package __config__.py file containing system_info information used during building the package.
This file is installed to the package installation directory.
Get resources information.
Return information (from system_info.get_info) for all of the names in the argument list in a single dictionary.
Conventional C libraries (installed through add_library) are not installed, and are just used during the build (they are statically linked). An installable C library is a pure C library, which does not depend on the python C runtime, and is installed such that it may be used by third-party packages. To build and install the C library, you just use the method add_installed_library instead of add_library, which takes the same arguments except for an additional install_dir argument:
To make the necessary build options available to third parties, you could use the npy-pkg-config mechanism implemented in numpy.distutils. This mechanism is based on a .ini file which contains all the options. A .ini file is very similar to .pc files as used by the pkg-config unix utility:
Generally, the file needs to be generated during the build, since it needs some information known at build time only (e.g. prefix). This is mostly automatic if one uses the Configuration method add_npy_pkg_config. Assuming we have a template file foo.ini.in as follows:
and the following code in setup.py:
This will install the file foo.ini into the directory package_dir/lib, and the foo.ini file will be generated from foo.ini.in, where each @version@ will be replaced by subst_dict['version']. The dictionary has an additional prefix substitution rule automatically added, which contains the install prefix (since this is not easy to get from setup.py). npy-pkg-config files can also be installed at the same location as used for numpy, using the path returned from get_npy_pkg_dir function.
Info are easily retrieved from the get_info function in numpy.distutils.misc_util:
An additional list of paths to look for .ini files can be given to get_info.
NumPy distutils supports automatic conversion of source files named <somefile>.src. This facility can be used to maintain very similar code blocks requiring only simple changes between blocks. During the build phase of setup, if a template file named <somefile>.src is encountered, a new file named <somefile> is constructed from the template and placed in the build directory to be used instead. Two forms of template conversion are supported. The first form occurs for files named <file>.ext.src where ext is a recognized Fortran extension (f, f90, f95, f77, for, ftn, pyf). The second form is used for all other cases. See Conversion of .src files using Templates.


Apply glob to paths and prepend local_path if needed.
Applies glob.glob(…) to each path in the sequence (if needed) and pre-pends the local_path if needed. Because this is called on all source lists, this allows wildcard characters to be specified in lists of sources for extension modules and libraries and scripts and allows path-names be relative to the source directory.


The recommended generator for general use is PCG64 or its upgraded variant PCG64DXSM for heavily-parallel use cases. They are statistically high quality, full-featured, and fast on most platforms, but somewhat slow when compiled for 32-bit processes. See Upgrading PCG64 with PCG64DXSM for details on when heavy parallelism would indicate using PCG64DXSM.
Philox is fairly slow, but its statistical properties have very high quality, and it is easy to get an assuredly-independent stream by using unique keys. If that is the style you wish to use for parallel streams, or you are porting from another system that uses that style, then Philox is your choice.
SFC64 is statistically high quality and very fast. However, it lacks jumpability. If you are not using that capability and want lots of speed, even on 32-bit processes, this is your choice.
MT19937 fails some statistical tests and is not especially fast compared to modern PRNGs. For these reasons, we mostly do not recommend using it on its own, only through the legacy RandomState for reproducing old results. That said, it has a very long history as a default in many systems.
The timings below are the time in ns to produce 1 random value from a specific distribution. The original MT19937 generator is much slower since it requires 2 32-bit values to equal the output of the faster generators.
Integer performance has a similar ordering.
The pattern is similar for other, more complex generators. The normal performance of the legacy RandomState generator is much lower than the other since it uses the Box-Muller transform rather than the Ziggurat method. The performance gap for Exponentials is also large due to the cost of computing the log function to invert the CDF. The column labeled MT19973 uses the same 32-bit generator as RandomState but produces random variates using Generator.
MT19937
PCG64
PCG64DXSM
Philox
SFC64
RandomState
32-bit Unsigned Ints
3.3
1.9
2.0
3.3
1.8
3.1
64-bit Unsigned Ints
5.6
3.2
2.9
4.9
2.5
5.5
Uniforms
5.9
3.1
2.9
5.0
2.6
6.0
Normals
13.9
10.8
10.5
12.0
8.3
56.8
Exponentials
9.1
6.0
5.8
8.1
5.4
63.9
Gammas
37.2
30.8
28.9
34.0
27.5
77.0
Binomials
21.3
17.4
17.6
19.3
15.6
21.4
Laplaces
73.2
72.3
76.1
73.0
72.3
82.5
Poissons
111.7
103.4
100.5
109.4
90.7
115.2
The next table presents the performance in percentage relative to values generated by the legacy generator, RandomState(MT19937()). The overall performance was computed using a geometric mean.
MT19937
PCG64
PCG64DXSM
Philox
SFC64
32-bit Unsigned Ints
96
162
160
96
175
64-bit Unsigned Ints
97
171
188
113
218
Uniforms
102
192
206
121
233
Normals
409
526
541
471
684
Exponentials
701
1071
1101
784
1179
Gammas
207
250
266
227
281
Binomials
100
123
122
111
138
Laplaces
113
114
108
113
114
Poissons
103
111
115
105
127
Overall
159
219
225
174
251
Note
All timings were taken using Linux on an AMD Ryzen 9 3900X processor.
Performance differs across platforms due to compiler and hardware availability (e.g., register width) differences. The default bit generator has been chosen to perform well on 64-bit platforms. Performance on 32-bit operating systems is very different.
The values reported are normalized relative to the speed of MT19937 in each table. A value of 100 indicates that the performance matches the MT19937. Higher values indicate improved performance. These values cannot be compared across tables.
Distribution
MT19937
PCG64
PCG64DXSM
Philox
SFC64
32-bit Unsigned Ints
100
168
166
100
182
64-bit Unsigned Ints
100
176
193
116
224
Uniforms
100
188
202
118
228
Normals
100
128
132
115
167
Exponentials
100
152
157
111
168
Overall
100
161
168
112
192
The relative performance on 64-bit Linux and 64-bit Windows is broadly similar with the notable exception of the Philox generator.
Distribution
MT19937
PCG64
PCG64DXSM
Philox
SFC64
32-bit Unsigned Ints
100
155
131
29
150
64-bit Unsigned Ints
100
157
143
25
154
Uniforms
100
151
144
24
155
Normals
100
129
128
37
150
Exponentials
100
150
145
28
159
Overall
100
148
138
28
154
The performance of 64-bit generators on 32-bit Windows is much lower than on 64-bit operating systems due to register width. MT19937, the generator that has been in NumPy since 2005, operates on 32-bit integers.
Distribution
MT19937
PCG64
PCG64DXSM
Philox
SFC64
32-bit Unsigned Ints
100
24
34
14
57
64-bit Unsigned Ints
100
21
32
14
74
Uniforms
100
21
34
16
73
Normals
100
36
57
28
101
Exponentials
100
28
44
20
88
Overall
100
25
39
18
77
Note
Linux timings used Ubuntu 20.04 and GCC 9.3.0. Windows timings were made on Windows 10 using Microsoft C/C++ Optimizing Compiler Version 19 (Visual Studio 2019). All timings were produced on an AMD Ryzen 9 3900X processor.


poly1d(c_or_r[, r, variable])
A one-dimensional polynomial class.
polyval(p, x)
Evaluate a polynomial at specific values.
poly(seq_of_zeros)
Find the coefficients of a polynomial with the given sequence of roots.
roots(p)
Return the roots of a polynomial with coefficients given in p.
polyfit(x, y, deg[, rcond, full, w, cov])
Least squares polynomial fit.
polyder(p[, m])
Return the derivative of the specified order of a polynomial.
polyint(p[, m, k])
Return an antiderivative (indefinite integral) of a polynomial.
polyadd(a1, a2)
Find the sum of two polynomials.
polydiv(u, v)
Returns the quotient and remainder of polynomial division.
polymul(a1, a2)
Find the product of two polynomials.
polysub(a1, a2)
Difference (subtraction) of two polynomials.
RankWarning
Issued by polyfit when the Vandermonde matrix is rank deficient.


method
Return a derivative of this polynomial.
Refer to polyder for full documentation.
See also
equivalent function


method
Return an antiderivative (indefinite integral) of this polynomial.
Refer to polyint for full documentation.
See also
equivalent function


Convert a Chebyshev series to a polynomial.
Convert an array representing the coefficients of a Chebyshev series, ordered from lowest degree to highest, to an array of the coefficients of the equivalent polynomial (relative to the “standard” basis) ordered from lowest to highest degree.
1-D array containing the Chebyshev series coefficients, ordered from lowest order term to highest.
1-D array containing the coefficients of the equivalent polynomial (relative to the “standard” basis) ordered from lowest order term to highest.
See also
The easy way to do conversions between polynomial basis sets is to use the convert method of a class instance.


Add one Chebyshev series to another.
Returns the sum of two Chebyshev series c1 + c2. The arguments are sequences of coefficients ordered from lowest order term to highest, i.e., [1,2,3] represents the series T_0 + 2*T_1 + 3*T_2.
1-D arrays of Chebyshev series coefficients ordered from low to high.
Array representing the Chebyshev series of their sum.
See also
Unlike multiplication, division, etc., the sum of two Chebyshev series is a Chebyshev series (without having to “reproject” the result onto the basis set) so addition, just like that of “standard” polynomials, is simply “component-wise.”


Return the scaled companion matrix of c.
The basis polynomials are scaled so that the companion matrix is symmetric when c is a Chebyshev basis polynomial. This provides better eigenvalue estimates than the unscaled case and for basis polynomials the eigenvalues are guaranteed to be real if numpy.linalg.eigvalsh is used to obtain them.
1-D array of Chebyshev series coefficients ordered from low to high degree.
Scaled companion matrix of dimensions (deg, deg).
New in version 1.7.0.


Differentiate a Chebyshev series.
Returns the Chebyshev series coefficients c differentiated m times along axis. At each iteration the result is multiplied by scl (the scaling factor is for use in a linear change of variable). The argument c is an array of coefficients from low to high degree along each axis, e.g., [1,2,3] represents the series 1*T_0 + 2*T_1 + 3*T_2 while [[1,2],[1,2]] represents 1*T_0(x)*T_0(y) + 1*T_1(x)*T_0(y) +
2*T_0(x)*T_1(y) + 2*T_1(x)*T_1(y) if axis=0 is x and axis=1 is y.
Array of Chebyshev series coefficients. If c is multidimensional the different axis correspond to different variables with the degree in each axis given by the corresponding index.
Number of derivatives taken, must be non-negative. (Default: 1)
Each differentiation is multiplied by scl. The end result is multiplication by scl**m. This is for use in a linear change of variable. (Default: 1)
Axis over which the derivative is taken. (Default: 0).
New in version 1.7.0.
Chebyshev series of the derivative.
See also
In general, the result of differentiating a C-series needs to be “reprojected” onto the C-series basis set. Thus, typically, the result of this function is “unintuitive,” albeit correct; see Examples section below.


Divide one Chebyshev series by another.
Returns the quotient-with-remainder of two Chebyshev series c1 / c2. The arguments are sequences of coefficients from lowest order “term” to highest, e.g., [1,2,3] represents the series T_0 + 2*T_1 + 3*T_2.
1-D arrays of Chebyshev series coefficients ordered from low to high.
Of Chebyshev series coefficients representing the quotient and remainder.
See also
In general, the (polynomial) division of one C-series by another results in quotient and remainder terms that are not in the Chebyshev polynomial basis set. Thus, to express these results as C-series, it is typically necessary to “reproject” the results onto said basis set, which typically produces “unintuitive” (but correct) results; see Examples section below.


An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data-type object describes the format of each element in the array (its byte-order, how many bytes it occupies in memory, whether it is an integer, a floating point number, or something else, etc.)
Arrays should be constructed using array, zeros or empty (refer to the See Also section below). The parameters given here refer to a low-level method (ndarray(…)) for instantiating an array.
For more information, refer to the numpy module and examine the methods and attributes of an array.
Shape of created array.
Any object that can be interpreted as a numpy data type.
Used to fill the array with data.
Offset of array data in buffer.
Strides of data in memory.
Row-major (C-style) or column-major (Fortran-style) order.
See also
Construct an array.
Create an array, each element of which is zero.
Create an array, but leave its allocated memory unchanged (i.e., it contains “garbage”).
Create a data-type.
An ndarray alias generic w.r.t. its dtype.type.
There are two modes of creating an array using __new__:
No __init__ method is needed because the array is fully initialized after the __new__ method.
These examples illustrate the low-level ndarray constructor. Refer to the See Also section above for easier ways of constructing an ndarray.
First mode, buffer is None:
Second mode:
Transpose of the array.
The array’s elements, in memory.
Describes the format of the elements in the array.
Dictionary containing information related to memory use, e.g., ‘C_CONTIGUOUS’, ‘OWNDATA’, ‘WRITEABLE’, etc.
Flattened version of the array as an iterator. The iterator allows assignments, e.g., x.flat = 3 (See ndarray.flat for assignment examples; TODO).
Imaginary part of the array.
Real part of the array.
Number of elements in the array.
The memory use of each array element in bytes.
The total number of bytes required to store the array data, i.e., itemsize * size.
The array’s number of dimensions.
Shape of the array.
The step-size required to move from one element to the next in memory. For example, a contiguous (3, 4) array of type int16 in C-order has strides (8, 2). This implies that to move from element to element in memory requires jumps of 2 bytes. To move from row-to-row, one needs to jump 8 bytes at a time (2 * 4).
Class containing properties of the array needed for interaction with ctypes.
If the array is a view into another array, that array is its base (unless that array is also a view). The base array is where the array data is actually stored.


Least squares fit of Chebyshev series to data.
Return the coefficients of a Chebyshev series of degree deg that is the least squares fit to the data values y given at points x. If y is 1-D the returned coefficients will also be 1-D. If y is 2-D multiple fits are done, one for each column of y, and the resulting coefficients are stored in the corresponding columns of a 2-D return. The fitted polynomial(s) are in the form
where n is deg.
x-coordinates of the M sample points (x[i], y[i]).
y-coordinates of the sample points. Several data sets of sample points sharing the same x-coordinates can be fitted at once by passing in a 2D-array that contains one dataset per column.
Degree(s) of the fitting polynomials. If deg is a single integer, all terms up to and including the deg’th term are included in the fit. For NumPy versions >= 1.11.0 a list of integers specifying the degrees of the terms to include may be used instead.
Relative condition number of the fit. Singular values smaller than this relative to the largest singular value will be ignored. The default value is len(x)*eps, where eps is the relative precision of the float type, about 2e-16 in most cases.
Switch determining nature of return value. When it is False (the default) just the coefficients are returned, when True diagnostic information from the singular value decomposition is also returned.
Weights. If not None, the weight w[i] applies to the unsquared residual y[i] - y_hat[i] at x[i]. Ideally the weights are chosen so that the errors of the products w[i]*y[i] all have the same variance. When using inverse-variance weighting, use w[i] = 1/sigma(y[i]). The default value is None.
New in version 1.5.0.
Chebyshev coefficients ordered from low to high. If y was 2-D, the coefficients for the data in column k of y are in column k.
These values are only returned if full == True
For more details, see numpy.linalg.lstsq.
The rank of the coefficient matrix in the least-squares fit is deficient. The warning is only raised if full == False. The warnings can be turned off by
See also
Evaluates a Chebyshev series.
Vandermonde matrix of Chebyshev series.
Chebyshev weight function.
Computes a least-squares fit from the matrix.
Computes spline fits.
The solution is the coefficients of the Chebyshev series p that minimizes the sum of the weighted squared errors
where \(w_j\) are the weights. This problem is solved by setting up as the (typically) overdetermined matrix equation
where V is the weighted pseudo Vandermonde matrix of x, c are the coefficients to be solved for, w are the weights, and y are the observed values. This equation is then solved using the singular value decomposition of V.
If some of the singular values of V are so small that they are neglected, then a RankWarning will be issued. This means that the coefficient values may be poorly determined. Using a lower order fit will usually get rid of the warning. The rcond parameter can also be set to a value smaller than its default, but the resulting fit may be spurious and have large contributions from roundoff error.
Fits using Chebyshev series are usually better conditioned than fits using power series, but much can depend on the distribution of the sample points and the smoothness of the data. If the quality of the fit is inadequate splines may be a good alternative.
Wikipedia, “Curve fitting”, https://en.wikipedia.org/wiki/Curve_fitting


Generate a Chebyshev series with given roots.
The function returns the coefficients of the polynomial
in Chebyshev form, where the r_n are the roots specified in roots. If a zero has multiplicity n, then it must appear in roots n times. For instance, if 2 is a root of multiplicity three and 3 is a root of multiplicity 2, then roots looks something like [2, 2, 2, 3, 3]. The roots can appear in any order.
If the returned coefficients are c, then
The coefficient of the last term is not generally 1 for monic polynomials in Chebyshev form.
Sequence containing the roots.
1-D array of coefficients. If all roots are real then out is a real array, if some of the roots are complex, then out is complex even if all the coefficients in the result are real (see Examples below).
See also


Gauss-Chebyshev quadrature.
Computes the sample points and weights for Gauss-Chebyshev quadrature. These sample points and weights will correctly integrate polynomials of degree \(2*deg - 1\) or less over the interval \([-1, 1]\) with the weight function \(f(x) = 1/\sqrt{1 - x^2}\).
Number of sample points and weights. It must be >= 1.
1-D ndarray containing the sample points.
1-D ndarray containing the weights.
New in version 1.7.0.
The results have only been tested up to degree 100, higher degrees may be problematic. For Gauss-Chebyshev there are closed form solutions for the sample points and weights. If n = deg, then


Evaluate a 2-D Chebyshev series on the Cartesian product of x and y.
This function returns the values:
where the points (a, b) consist of all pairs formed by taking a from x and b from y. The resulting points form a grid with x in the first dimension and y in the second.
The parameters x and y are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars. In either case, either x and y or their elements must support multiplication and addition both with themselves and with the elements of c.
If c has fewer than two dimensions, ones are implicitly appended to its shape to make it 2-D. The shape of the result will be c.shape[2:] + x.shape + y.shape.
The two dimensional series is evaluated at the points in the Cartesian product of x and y. If x or y is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and, if it isn’t an ndarray, it is treated as a scalar.
Array of coefficients ordered so that the coefficient of the term of multi-degree i,j is contained in c[i,j]. If c has dimension greater than two the remaining indices enumerate multiple sets of coefficients.
The values of the two dimensional Chebyshev series at points in the Cartesian product of x and y.
See also
New in version 1.7.0.


Evaluate a 3-D Chebyshev series on the Cartesian product of x, y, and z.
This function returns the values:
where the points (a, b, c) consist of all triples formed by taking a from x, b from y, and c from z. The resulting points form a grid with x in the first dimension, y in the second, and z in the third.
The parameters x, y, and z are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars. In either case, either x, y, and z or their elements must support multiplication and addition both with themselves and with the elements of c.
If c has fewer than three dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape + y.shape + z.shape.
The three dimensional series is evaluated at the points in the Cartesian product of x, y, and z. If x,`y`, or z is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and, if it isn’t an ndarray, it is treated as a scalar.
Array of coefficients ordered so that the coefficients for terms of degree i,j are contained in c[i,j]. If c has dimension greater than two the remaining indices enumerate multiple sets of coefficients.
The values of the two dimensional polynomial at points in the Cartesian product of x and y.
See also
New in version 1.7.0.


Integrate a Chebyshev series.
Returns the Chebyshev series coefficients c integrated m times from lbnd along axis. At each iteration the resulting series is multiplied by scl and an integration constant, k, is added. The scaling factor is for use in a linear change of variable. (“Buyer beware”: note that, depending on what one is doing, one may want scl to be the reciprocal of what one might expect; for more information, see the Notes section below.) The argument c is an array of coefficients from low to high degree along each axis, e.g., [1,2,3] represents the series T_0 + 2*T_1 + 3*T_2 while [[1,2],[1,2]] represents 1*T_0(x)*T_0(y) + 1*T_1(x)*T_0(y) + 2*T_0(x)*T_1(y) +
2*T_1(x)*T_1(y) if axis=0 is x and axis=1 is y.
Array of Chebyshev series coefficients. If c is multidimensional the different axis correspond to different variables with the degree in each axis given by the corresponding index.
Order of integration, must be positive. (Default: 1)
Integration constant(s). The value of the first integral at zero is the first value in the list, the value of the second integral at zero is the second value, etc. If k == [] (the default), all constants are set to zero. If m == 1, a single scalar can be given instead of a list.
The lower bound of the integral. (Default: 0)
Following each integration the result is multiplied by scl before the integration constant is added. (Default: 1)
Axis over which the integral is taken. (Default: 0).
New in version 1.7.0.
C-series coefficients of the integral.
If m < 1, len(k) > m, np.ndim(lbnd) != 0, or np.ndim(scl) != 0.
See also
Note that the result of each integration is multiplied by scl. Why is this important to note? Say one is making a linear change of variable \(u = ax + b\) in an integral relative to x. Then \(dx = du/a\), so one will need to set scl equal to \(1/a\)- perhaps not what one would have first thought.
Also note that, in general, the result of integrating a C-series needs to be “reprojected” onto the C-series basis set. Thus, typically, the result of this function is “unintuitive,” albeit correct; see Examples section below.


Interpolate a function at the Chebyshev points of the first kind.
Returns the Chebyshev series that interpolates func at the Chebyshev points of the first kind in the interval [-1, 1]. The interpolating series tends to a minmax approximation to func with increasing deg if the function is continuous in the interval.
New in version 1.14.0.
The function to be approximated. It must be a function of a single variable of the form f(x, a, b, c...), where a, b, c... are extra arguments passed in the args parameter.
Degree of the interpolating polynomial
Extra arguments to be used in the function call. Default is no extra arguments.
Chebyshev coefficients of the interpolating series ordered from low to high.
The Chebyshev polynomials used in the interpolation are orthogonal when sampled at the Chebyshev points of the first kind. If it is desired to constrain some of the coefficients they can simply be set to the desired value after the interpolation, no new interpolation or fit is needed. This is especially useful if it is known apriori that some of coefficients are zero. For instance, if the function is even then the coefficients of the terms of odd degree in the result can be set to zero.


Chebyshev series whose graph is a straight line.
The specified line is given by off + scl*x.
This module’s representation of the Chebyshev series for off + scl*x.
See also


Multiply one Chebyshev series by another.
Returns the product of two Chebyshev series c1 * c2. The arguments are sequences of coefficients, from lowest order “term” to highest, e.g., [1,2,3] represents the series T_0 + 2*T_1 + 3*T_2.
1-D arrays of Chebyshev series coefficients ordered from low to high.
Of Chebyshev series coefficients representing their product.
See also
In general, the (polynomial) product of two C-series results in terms that are not in the Chebyshev polynomial basis set. Thus, to express the product as a C-series, it is typically necessary to “reproject” the product onto said basis set, which typically produces “unintuitive live” (but correct) results; see Examples section below.


Multiply a Chebyshev series by x.
Multiply the polynomial c by x, where x is the independent variable.
1-D array of Chebyshev series coefficients ordered from low to high.
Array representing the result of the multiplication.
New in version 1.5.0.


Raise a Chebyshev series to a power.
Returns the Chebyshev series c raised to the power pow. The argument c is a sequence of coefficients ordered from low to high. i.e., [1,2,3] is the series T_0 + 2*T_1 + 3*T_2.
1-D array of Chebyshev series coefficients ordered from low to high.
Power to which the series will be raised
Maximum power allowed. This is mainly to limit growth of the series to unmanageable size. Default is 16
Chebyshev series of power.
See also


Chebyshev points of the first kind.
The Chebyshev points of the first kind are the points cos(x), where x = [pi*(k + .5)/npts for k in range(npts)].
Number of sample points desired.
The Chebyshev points of the first kind.
See also
New in version 1.5.0.


Chebyshev points of the second kind.
The Chebyshev points of the second kind are the points cos(x), where x = [pi*k/(npts - 1) for k in range(npts)].
Number of sample points desired.
The Chebyshev points of the second kind.
New in version 1.5.0.


Compute the roots of a Chebyshev series.
Return the roots (a.k.a. “zeros”) of the polynomial
1-D array of coefficients.
Array of the roots of the series. If all the roots are real, then out is also real, otherwise it is complex.
See also
The root estimates are obtained as the eigenvalues of the companion matrix, Roots far from the origin of the complex plane may have large errors due to the numerical instability of the series for such values. Roots with multiplicity greater than 1 will also show larger errors as the value of the series near such points is relatively insensitive to errors in the roots. Isolated roots near the origin can be improved by a few iterations of Newton’s method.
The Chebyshev series basis polynomials aren’t powers of x so the results of this function may seem unintuitive.


Subtract one Chebyshev series from another.
Returns the difference of two Chebyshev series c1 - c2. The sequences of coefficients are from lowest order term to highest, i.e., [1,2,3] represents the series T_0 + 2*T_1 + 3*T_2.
1-D arrays of Chebyshev series coefficients ordered from low to high.
Of Chebyshev series coefficients representing their difference.
See also
Unlike multiplication, division, etc., the difference of two Chebyshev series is a Chebyshev series (without having to “reproject” the result onto the basis set) so subtraction, just like that of “standard” polynomials, is simply “component-wise.”


Remove “small” “trailing” coefficients from a polynomial.
“Small” means “small in absolute value” and is controlled by the parameter tol; “trailing” means highest order coefficient(s), e.g., in [0, 1, 1, 0, 0] (which represents 0 + x + x**2 + 0*x**3 + 0*x**4) both the 3-rd and 4-th order coefficients would be “trimmed.”
1-d array of coefficients, ordered from lowest order to highest.
Trailing (i.e., highest order) elements with absolute value less than or equal to tol (default value is zero) are removed.
1-d array with trailing zeros removed. If the resulting series would be empty, a series containing a single zero is returned.
If tol < 0
See also


Evaluate a Chebyshev series at points x.
If c is of length n + 1, this function returns the value:
The parameter x is converted to an array only if it is a tuple or a list, otherwise it is treated as a scalar. In either case, either x or its elements must support multiplication and addition both with themselves and with the elements of c.
If c is a 1-D array, then p(x) will have the same shape as x. If c is multidimensional, then the shape of the result depends on the value of tensor. If tensor is true the shape will be c.shape[1:] + x.shape. If tensor is false the shape will be c.shape[1:]. Note that scalars have shape (,).
Trailing zeros in the coefficients will be used in the evaluation, so they should be avoided if efficiency is a concern.
If x is a list or tuple, it is converted to an ndarray, otherwise it is left unchanged and treated as a scalar. In either case, x or its elements must support addition and multiplication with with themselves and with the elements of c.
Array of coefficients ordered so that the coefficients for terms of degree n are contained in c[n]. If c is multidimensional the remaining indices enumerate multiple polynomials. In the two dimensional case the coefficients may be thought of as stored in the columns of c.
If True, the shape of the coefficient array is extended with ones on the right, one for each dimension of x. Scalars have dimension 0 for this action. The result is that every column of coefficients in c is evaluated for every element of x. If False, x is broadcast over the columns of c for the evaluation. This keyword is useful when c is multidimensional. The default value is True.
New in version 1.7.0.
The shape of the return value is described above.
See also
The evaluation uses Clenshaw recursion, aka synthetic division.


Evaluate a 2-D Chebyshev series at points (x, y).
This function returns the values:
The parameters x and y are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and they must have the same shape after conversion. In either case, either x and y or their elements must support multiplication and addition both with themselves and with the elements of c.
If c is a 1-D array a one is implicitly appended to its shape to make it 2-D. The shape of the result will be c.shape[2:] + x.shape.
The two dimensional series is evaluated at the points (x, y), where x and y must have the same shape. If x or y is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn’t an ndarray it is treated as a scalar.
Array of coefficients ordered so that the coefficient of the term of multi-degree i,j is contained in c[i,j]. If c has dimension greater than 2 the remaining indices enumerate multiple sets of coefficients.
The values of the two dimensional Chebyshev series at points formed from pairs of corresponding values from x and y.
See also
New in version 1.7.0.


Evaluate a 3-D Chebyshev series at points (x, y, z).
This function returns the values:
The parameters x, y, and z are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and they must have the same shape after conversion. In either case, either x, y, and z or their elements must support multiplication and addition both with themselves and with the elements of c.
If c has fewer than 3 dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape.
The three dimensional series is evaluated at the points (x, y, z), where x, y, and z must have the same shape. If any of x, y, or z is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn’t an ndarray it is treated as a scalar.
Array of coefficients ordered so that the coefficient of the term of multi-degree i,j,k is contained in c[i,j,k]. If c has dimension greater than 3 the remaining indices enumerate multiple sets of coefficients.
The values of the multidimensional polynomial on points formed with triples of corresponding values from x, y, and z.
See also
New in version 1.7.0.


Pseudo-Vandermonde matrix of given degree.
Returns the pseudo-Vandermonde matrix of degree deg and sample points x. The pseudo-Vandermonde matrix is defined by
where 0 <= i <= deg. The leading indices of V index the elements of x and the last index is the degree of the Chebyshev polynomial.
If c is a 1-D array of coefficients of length n + 1 and V is the matrix V = chebvander(x, n), then np.dot(V, c) and chebval(x, c) are the same up to roundoff. This equivalence is useful both for least squares fitting and for the evaluation of a large number of Chebyshev series of the same degree and sample points.
Array of points. The dtype is converted to float64 or complex128 depending on whether any of the elements are complex. If x is scalar it is converted to a 1-D array.
Degree of the resulting matrix.
The pseudo Vandermonde matrix. The shape of the returned matrix is x.shape + (deg + 1,), where The last index is the degree of the corresponding Chebyshev polynomial. The dtype will be the same as the converted x.


Pseudo-Vandermonde matrix of given degrees.
Returns the pseudo-Vandermonde matrix of degrees deg and sample points (x, y). The pseudo-Vandermonde matrix is defined by
where 0 <= i <= deg[0] and 0 <= j <= deg[1]. The leading indices of V index the points (x, y) and the last index encodes the degrees of the Chebyshev polynomials.
If V = chebvander2d(x, y, [xdeg, ydeg]), then the columns of V correspond to the elements of a 2-D coefficient array c of shape (xdeg + 1, ydeg + 1) in the order
and np.dot(V, c.flat) and chebval2d(x, y, c) will be the same up to roundoff. This equivalence is useful both for least squares fitting and for the evaluation of a large number of 2-D Chebyshev series of the same degrees and sample points.
Arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays.
List of maximum degrees of the form [x_deg, y_deg].
The shape of the returned matrix is x.shape + (order,), where \(order = (deg[0]+1)*(deg[1]+1)\). The dtype will be the same as the converted x and y.
See also
New in version 1.7.0.


Pseudo-Vandermonde matrix of given degrees.
Returns the pseudo-Vandermonde matrix of degrees deg and sample points (x, y, z). If l, m, n are the given degrees in x, y, z, then The pseudo-Vandermonde matrix is defined by
where 0 <= i <= l, 0 <= j <= m, and 0 <= j <= n. The leading indices of V index the points (x, y, z) and the last index encodes the degrees of the Chebyshev polynomials.
If V = chebvander3d(x, y, z, [xdeg, ydeg, zdeg]), then the columns of V correspond to the elements of a 3-D coefficient array c of shape (xdeg + 1, ydeg + 1, zdeg + 1) in the order
and np.dot(V, c.flat) and chebval3d(x, y, z, c) will be the same up to roundoff. This equivalence is useful both for least squares fitting and for the evaluation of a large number of 3-D Chebyshev series of the same degrees and sample points.
Arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays.
List of maximum degrees of the form [x_deg, y_deg, z_deg].
The shape of the returned matrix is x.shape + (order,), where \(order = (deg[0]+1)*(deg[1]+1)*(deg[2]+1)\). The dtype will be the same as the converted x, y, and z.
See also
New in version 1.7.0.


The weight function of the Chebyshev polynomials.
The weight function is \(1/\sqrt{1 - x^2}\) and the interval of integration is \([-1, 1]\). The Chebyshev polynomials are orthogonal, but not normalized, with respect to this weight function.
Values at which the weight function will be computed.
The weight function at x.
New in version 1.7.0.


An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data-type object describes the format of each element in the array (its byte-order, how many bytes it occupies in memory, whether it is an integer, a floating point number, or something else, etc.)
Arrays should be constructed using array, zeros or empty (refer to the See Also section below). The parameters given here refer to a low-level method (ndarray(…)) for instantiating an array.
For more information, refer to the numpy module and examine the methods and attributes of an array.
Shape of created array.
Any object that can be interpreted as a numpy data type.
Used to fill the array with data.
Offset of array data in buffer.
Strides of data in memory.
Row-major (C-style) or column-major (Fortran-style) order.
See also
Construct an array.
Create an array, each element of which is zero.
Create an array, but leave its allocated memory unchanged (i.e., it contains “garbage”).
Create a data-type.
An ndarray alias generic w.r.t. its dtype.type.
There are two modes of creating an array using __new__:
No __init__ method is needed because the array is fully initialized after the __new__ method.
These examples illustrate the low-level ndarray constructor. Refer to the See Also section above for easier ways of constructing an ndarray.
First mode, buffer is None:
Second mode:
Transpose of the array.
The array’s elements, in memory.
Describes the format of the elements in the array.
Dictionary containing information related to memory use, e.g., ‘C_CONTIGUOUS’, ‘OWNDATA’, ‘WRITEABLE’, etc.
Flattened version of the array as an iterator. The iterator allows assignments, e.g., x.flat = 3 (See ndarray.flat for assignment examples; TODO).
Imaginary part of the array.
Real part of the array.
Number of elements in the array.
The memory use of each array element in bytes.
The total number of bytes required to store the array data, i.e., itemsize * size.
The array’s number of dimensions.
Shape of the array.
The step-size required to move from one element to the next in memory. For example, a contiguous (3, 4) array of type int16 in C-order has strides (8, 2). This implies that to move from element to element in memory requires jumps of 2 bytes. To move from row-to-row, one needs to jump 8 bytes at a time (2 * 4).
Class containing properties of the array needed for interaction with ctypes.
If the array is a view into another array, that array is its base (unless that array is also a view). The base array is where the array data is actually stored.


method
Series basis polynomial of degree deg.
Returns the series representing the basis polynomial of degree deg.
New in version 1.7.0.
Degree of the basis polynomial for the series. Must be >= 0.
If given, the array must be of the form [beg, end], where beg and end are the endpoints of the domain. If None is given then the class domain is used. The default is None.
If given, the resulting array must be if the form [beg, end], where beg and end are the endpoints of the window. If None is given then the class window is used. The default is None.
A series with the coefficient of the deg term set to one and all others zero.


method
Convert series to series of this class.
The series is expected to be an instance of some polynomial series of one of the types supported by by the numpy.polynomial module, but could be some other class that supports the convert method.
New in version 1.7.0.
The series instance to be converted.
If given, the array must be of the form [beg, end], where beg and end are the endpoints of the domain. If None is given then the class domain is used. The default is None.
If given, the resulting array must be if the form [beg, end], where beg and end are the endpoints of the window. If None is given then the class window is used. The default is None.
A series of the same kind as the calling class and equal to series when evaluated.
See also
similar instance method


method
Convert series to a different kind and/or domain and/or window.
The domain of the converted series. If the value is None, the default domain of kind is used.
The polynomial series type class to which the current instance should be converted. If kind is None, then the class of the current instance is used.
The window of the converted series. If the value is None, the default window of kind is used.
The returned class can be of different type than the current instance and/or have a different domain and/or different window.
Conversion between domains and class types can result in numerically ill defined series.


method
Truncate series to the given degree.
Reduce the degree of the series to deg by discarding the high order terms. If deg is greater than the current degree a copy of the current series is returned. This can be useful in least squares where the coefficients of the high degree terms may be very small.
New in version 1.5.0.
The series is reduced to degree deg by discarding the high order terms. The value of deg must be a non-negative integer.
New instance of series with reduced degree.


method
The degree of the series.
New in version 1.5.0.
Degree of the series, one less than the number of coefficients.


method
Differentiate.
Return a series instance of that is the derivative of the current series.
Find the derivative of order m.
A new series representing the derivative. The domain is the same as the domain of the differentiated series.


method
Least squares fit to data.
Return a series instance that is the least squares fit to the data y sampled at x. The domain of the returned instance can be specified and this will often result in a superior fit with less chance of ill conditioning.
x-coordinates of the M sample points (x[i], y[i]).
y-coordinates of the M sample points (x[i], y[i]).
Degree(s) of the fitting polynomials. If deg is a single integer all terms up to and including the deg’th term are included in the fit. For NumPy versions >= 1.11.0 a list of integers specifying the degrees of the terms to include may be used instead.
Domain to use for the returned series. If None, then a minimal domain that covers the points x is chosen. If [] the class domain is used. The default value was the class domain in NumPy 1.4 and None in later versions. The [] option was added in numpy 1.5.0.
Relative condition number of the fit. Singular values smaller than this relative to the largest singular value will be ignored. The default value is len(x)*eps, where eps is the relative precision of the float type, about 2e-16 in most cases.
Switch determining nature of return value. When it is False (the default) just the coefficients are returned, when True diagnostic information from the singular value decomposition is also returned.
Weights. If not None, the weight w[i] applies to the unsquared residual y[i] - y_hat[i] at x[i]. Ideally the weights are chosen so that the errors of the products w[i]*y[i] all have the same variance. When using inverse-variance weighting, use w[i] = 1/sigma(y[i]). The default value is None.
New in version 1.5.0.
Window to use for the returned series. The default value is the default class domain
New in version 1.6.0.
A series that represents the least squares fit to the data and has the domain and window specified in the call. If the coefficients for the unscaled and unshifted basis polynomials are of interest, do new_series.convert().coef.
These values are only returned if full == True
For more details, see linalg.lstsq.


method
Return series instance that has the specified roots.
Returns a series representing the product (x - r[0])*(x - r[1])*...*(x - r[n-1]), where r is a list of roots.
List of roots.
Domain for the resulting series. If None the domain is the interval from the smallest root to the largest. If [] the domain is the class domain. The default is [].
Window for the returned series. If None the class window is used. The default is None.
Series with the specified roots.


method
Check if coefficients match.
New in version 1.6.0.
The other class must have the coef attribute.
True if the coefficients are the same, False otherwise.


method
Check if domains match.
New in version 1.6.0.
The other class must have the domain attribute.
True if the domains are the same, False otherwise.


method
Check if types match.
New in version 1.7.0.
Class instance.
True if other is same class as self


method
Check if windows match.
New in version 1.6.0.
The other class must have the window attribute.
True if the windows are the same, False otherwise.


method
Identity function.
If p is the returned series, then p(x) == x for all values of x.
If given, the array must be of the form [beg, end], where beg and end are the endpoints of the domain. If None is given then the class domain is used. The default is None.
If given, the resulting array must be if the form [beg, end], where beg and end are the endpoints of the window. If None is given then the class window is used. The default is None.
Series of representing the identity.


method
Integrate.
Return a series instance that is the definite integral of the current series.
The number of integrations to perform.
Integration constants. The first constant is applied to the first integration, the second to the second, and so on. The list of values must less than or equal to m in length and any missing values are set to zero.
The lower bound of the definite integral.
A new series representing the integral. The domain is the same as the domain of the integrated series.


method
Interpolate a function at the Chebyshev points of the first kind.
Returns the series that interpolates func at the Chebyshev points of the first kind scaled and shifted to the domain. The resulting series tends to a minmax approximation of func when the function is continuous in the domain.
New in version 1.14.0.
The function to be interpolated. It must be a function of a single variable of the form f(x, a, b, c...), where a, b, c... are extra arguments passed in the args parameter.
Degree of the interpolating polynomial.
Domain over which func is interpolated. The default is None, in which case the domain is [-1, 1].
Extra arguments to be used in the function call. Default is no extra arguments.
Interpolating Chebyshev instance.
See numpy.polynomial.chebfromfunction for more details.


method
Return x, y values at equally spaced points in domain.
Returns the x, y values at n linearly spaced points across the domain. Here y is the value of the polynomial at the points x. By default the domain is the same as that of the series instance. This method is intended mostly as a plotting aid.
New in version 1.5.0.
Number of point pairs to return. The default value is 100.
If not None, the specified domain is used instead of that of the calling instance. It should be of the form [beg,end]. The default is None which case the class domain is used.
x is equal to linspace(self.domain[0], self.domain[1], n) and y is the series evaluated at element of x.


method
Return the mapping parameters.
The returned values define a linear map off + scl*x that is applied to the input arguments before the series is evaluated. The map depends on the domain and window; if the current domain is equal to the window the resulting map is the identity. If the coefficients of the series instance are to be used by themselves outside this class, then the linear function must be substituted for the x in the standard representation of the base polynomials.
The mapping function is defined by off + scl*x.
If the current domain is the interval [l1, r1] and the window is [l2, r2], then the linear mapping function L is defined by the equations:


method
Return the roots of the series polynomial.
Compute the roots for the series. Note that the accuracy of the roots decrease the further outside the domain they lie.
Array containing the roots of the series.


method
Remove trailing coefficients
Remove trailing coefficients until a coefficient is reached whose absolute value greater than tol or the beginning of the series is reached. If all the coefficients would be removed the series is set to [0]. A new series instance is returned with the new coefficients. The current instance remains unchanged.
All trailing coefficients less than tol will be removed.
New instance of series with trimmed coefficients.


method
Truncate series to length size.
Reduce the series to length size by discarding the high degree terms. The value of size must be a positive integer. This can be useful in least squares where the coefficients of the high degree terms may be very small.
The series is reduced to length size by discarding the high degree terms. The value of size must be a positive integer.
New instance of series with truncated coefficients.


An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data-type object describes the format of each element in the array (its byte-order, how many bytes it occupies in memory, whether it is an integer, a floating point number, or something else, etc.)
Arrays should be constructed using array, zeros or empty (refer to the See Also section below). The parameters given here refer to a low-level method (ndarray(…)) for instantiating an array.
For more information, refer to the numpy module and examine the methods and attributes of an array.
Shape of created array.
Any object that can be interpreted as a numpy data type.
Used to fill the array with data.
Offset of array data in buffer.
Strides of data in memory.
Row-major (C-style) or column-major (Fortran-style) order.
See also
Construct an array.
Create an array, each element of which is zero.
Create an array, but leave its allocated memory unchanged (i.e., it contains “garbage”).
Create a data-type.
An ndarray alias generic w.r.t. its dtype.type.
There are two modes of creating an array using __new__:
No __init__ method is needed because the array is fully initialized after the __new__ method.
These examples illustrate the low-level ndarray constructor. Refer to the See Also section above for easier ways of constructing an ndarray.
First mode, buffer is None:
Second mode:
Transpose of the array.
The array’s elements, in memory.
Describes the format of the elements in the array.
Dictionary containing information related to memory use, e.g., ‘C_CONTIGUOUS’, ‘OWNDATA’, ‘WRITEABLE’, etc.
Flattened version of the array as an iterator. The iterator allows assignments, e.g., x.flat = 3 (See ndarray.flat for assignment examples; TODO).
Imaginary part of the array.
Real part of the array.
Number of elements in the array.
The memory use of each array element in bytes.
The total number of bytes required to store the array data, i.e., itemsize * size.
The array’s number of dimensions.
Shape of the array.
The step-size required to move from one element to the next in memory. For example, a contiguous (3, 4) array of type int16 in C-order has strides (8, 2). This implies that to move from element to element in memory requires jumps of 2 bytes. To move from row-to-row, one needs to jump 8 bytes at a time (2 * 4).
Class containing properties of the array needed for interaction with ctypes.
If the array is a view into another array, that array is its base (unless that array is also a view). The base array is where the array data is actually stored.


Convert a polynomial to a Chebyshev series.
Convert an array representing the coefficients of a polynomial (relative to the “standard” basis) ordered from lowest degree to highest, to an array of the coefficients of the equivalent Chebyshev series, ordered from lowest to highest degree.
1-D array containing the polynomial coefficients
1-D array containing the coefficients of the equivalent Chebyshev series.
See also
The easy way to do conversions between polynomial basis sets is to use the convert method of a class instance.


Convert a Hermite series to a polynomial.
Convert an array representing the coefficients of a Hermite series, ordered from lowest degree to highest, to an array of the coefficients of the equivalent polynomial (relative to the “standard” basis) ordered from lowest to highest degree.
1-D array containing the Hermite series coefficients, ordered from lowest order term to highest.
1-D array containing the coefficients of the equivalent polynomial (relative to the “standard” basis) ordered from lowest order term to highest.
See also
The easy way to do conversions between polynomial basis sets is to use the convert method of a class instance.


Add one Hermite series to another.
Returns the sum of two Hermite series c1 + c2. The arguments are sequences of coefficients ordered from lowest order term to highest, i.e., [1,2,3] represents the series P_0 + 2*P_1 + 3*P_2.
1-D arrays of Hermite series coefficients ordered from low to high.
Array representing the Hermite series of their sum.
See also
Unlike multiplication, division, etc., the sum of two Hermite series is a Hermite series (without having to “reproject” the result onto the basis set) so addition, just like that of “standard” polynomials, is simply “component-wise.”


Return the scaled companion matrix of c.
The basis polynomials are scaled so that the companion matrix is symmetric when c is an Hermite basis polynomial. This provides better eigenvalue estimates than the unscaled case and for basis polynomials the eigenvalues are guaranteed to be real if numpy.linalg.eigvalsh is used to obtain them.
1-D array of Hermite series coefficients ordered from low to high degree.
Scaled companion matrix of dimensions (deg, deg).
New in version 1.7.0.


Differentiate a Hermite series.
Returns the Hermite series coefficients c differentiated m times along axis. At each iteration the result is multiplied by scl (the scaling factor is for use in a linear change of variable). The argument c is an array of coefficients from low to high degree along each axis, e.g., [1,2,3] represents the series 1*H_0 + 2*H_1 + 3*H_2 while [[1,2],[1,2]] represents 1*H_0(x)*H_0(y) + 1*H_1(x)*H_0(y) +
2*H_0(x)*H_1(y) + 2*H_1(x)*H_1(y) if axis=0 is x and axis=1 is y.
Array of Hermite series coefficients. If c is multidimensional the different axis correspond to different variables with the degree in each axis given by the corresponding index.
Number of derivatives taken, must be non-negative. (Default: 1)
Each differentiation is multiplied by scl. The end result is multiplication by scl**m. This is for use in a linear change of variable. (Default: 1)
Axis over which the derivative is taken. (Default: 0).
New in version 1.7.0.
Hermite series of the derivative.
See also
In general, the result of differentiating a Hermite series does not resemble the same operation on a power series. Thus the result of this function may be “unintuitive,” albeit correct; see Examples section below.


Divide one Hermite series by another.
Returns the quotient-with-remainder of two Hermite series c1 / c2. The arguments are sequences of coefficients from lowest order “term” to highest, e.g., [1,2,3] represents the series P_0 + 2*P_1 + 3*P_2.
1-D arrays of Hermite series coefficients ordered from low to high.
Of Hermite series coefficients representing the quotient and remainder.
See also
In general, the (polynomial) division of one Hermite series by another results in quotient and remainder terms that are not in the Hermite polynomial basis set. Thus, to express these results as a Hermite series, it is necessary to “reproject” the results onto the Hermite basis set, which may produce “unintuitive” (but correct) results; see Examples section below.


Least squares fit of Hermite series to data.
Return the coefficients of a Hermite series of degree deg that is the least squares fit to the data values y given at points x. If y is 1-D the returned coefficients will also be 1-D. If y is 2-D multiple fits are done, one for each column of y, and the resulting coefficients are stored in the corresponding columns of a 2-D return. The fitted polynomial(s) are in the form
where n is deg.
x-coordinates of the M sample points (x[i], y[i]).
y-coordinates of the sample points. Several data sets of sample points sharing the same x-coordinates can be fitted at once by passing in a 2D-array that contains one dataset per column.
Degree(s) of the fitting polynomials. If deg is a single integer all terms up to and including the deg’th term are included in the fit. For NumPy versions >= 1.11.0 a list of integers specifying the degrees of the terms to include may be used instead.
Relative condition number of the fit. Singular values smaller than this relative to the largest singular value will be ignored. The default value is len(x)*eps, where eps is the relative precision of the float type, about 2e-16 in most cases.
Switch determining nature of return value. When it is False (the default) just the coefficients are returned, when True diagnostic information from the singular value decomposition is also returned.
Weights. If not None, the weight w[i] applies to the unsquared residual y[i] - y_hat[i] at x[i]. Ideally the weights are chosen so that the errors of the products w[i]*y[i] all have the same variance. When using inverse-variance weighting, use w[i] = 1/sigma(y[i]). The default value is None.
Hermite coefficients ordered from low to high. If y was 2-D, the coefficients for the data in column k of y are in column k.
These values are only returned if full == True
For more details, see numpy.linalg.lstsq.
The rank of the coefficient matrix in the least-squares fit is deficient. The warning is only raised if full == False. The warnings can be turned off by
See also
Evaluates a Hermite series.
Vandermonde matrix of Hermite series.
Hermite weight function
Computes a least-squares fit from the matrix.
Computes spline fits.
The solution is the coefficients of the Hermite series p that minimizes the sum of the weighted squared errors
where the \(w_j\) are the weights. This problem is solved by setting up the (typically) overdetermined matrix equation
where V is the weighted pseudo Vandermonde matrix of x, c are the coefficients to be solved for, w are the weights, y are the observed values. This equation is then solved using the singular value decomposition of V.
If some of the singular values of V are so small that they are neglected, then a RankWarning will be issued. This means that the coefficient values may be poorly determined. Using a lower order fit will usually get rid of the warning. The rcond parameter can also be set to a value smaller than its default, but the resulting fit may be spurious and have large contributions from roundoff error.
Fits using Hermite series are probably most useful when the data can be approximated by sqrt(w(x)) * p(x), where w(x) is the Hermite weight. In that case the weight sqrt(w(x[i])) should be used together with data values y[i]/sqrt(w(x[i])). The weight function is available as hermweight.
Wikipedia, “Curve fitting”, https://en.wikipedia.org/wiki/Curve_fitting


Generate a Hermite series with given roots.
The function returns the coefficients of the polynomial
in Hermite form, where the r_n are the roots specified in roots. If a zero has multiplicity n, then it must appear in roots n times. For instance, if 2 is a root of multiplicity three and 3 is a root of multiplicity 2, then roots looks something like [2, 2, 2, 3, 3]. The roots can appear in any order.
If the returned coefficients are c, then
The coefficient of the last term is not generally 1 for monic polynomials in Hermite form.
Sequence containing the roots.
1-D array of coefficients. If all roots are real then out is a real array, if some of the roots are complex, then out is complex even if all the coefficients in the result are real (see Examples below).
See also


Gauss-Hermite quadrature.
Computes the sample points and weights for Gauss-Hermite quadrature. These sample points and weights will correctly integrate polynomials of degree \(2*deg - 1\) or less over the interval \([-\inf, \inf]\) with the weight function \(f(x) = \exp(-x^2)\).
Number of sample points and weights. It must be >= 1.
1-D ndarray containing the sample points.
1-D ndarray containing the weights.
New in version 1.7.0.
The results have only been tested up to degree 100, higher degrees may be problematic. The weights are determined by using the fact that
where \(c\) is a constant independent of \(k\) and \(x_k\) is the k’th root of \(H_n\), and then scaling the results to get the right value when integrating 1.


Evaluate a 2-D Hermite series on the Cartesian product of x and y.
This function returns the values:
where the points (a, b) consist of all pairs formed by taking a from x and b from y. The resulting points form a grid with x in the first dimension and y in the second.
The parameters x and y are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars. In either case, either x and y or their elements must support multiplication and addition both with themselves and with the elements of c.
If c has fewer than two dimensions, ones are implicitly appended to its shape to make it 2-D. The shape of the result will be c.shape[2:] + x.shape.
The two dimensional series is evaluated at the points in the Cartesian product of x and y. If x or y is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and, if it isn’t an ndarray, it is treated as a scalar.
Array of coefficients ordered so that the coefficients for terms of degree i,j are contained in c[i,j]. If c has dimension greater than two the remaining indices enumerate multiple sets of coefficients.
The values of the two dimensional polynomial at points in the Cartesian product of x and y.
See also
New in version 1.7.0.


Evaluate a 3-D Hermite series on the Cartesian product of x, y, and z.
This function returns the values:
where the points (a, b, c) consist of all triples formed by taking a from x, b from y, and c from z. The resulting points form a grid with x in the first dimension, y in the second, and z in the third.
The parameters x, y, and z are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars. In either case, either x, y, and z or their elements must support multiplication and addition both with themselves and with the elements of c.
If c has fewer than three dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape + y.shape + z.shape.
The three dimensional series is evaluated at the points in the Cartesian product of x, y, and z. If x,`y`, or z is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and, if it isn’t an ndarray, it is treated as a scalar.
Array of coefficients ordered so that the coefficients for terms of degree i,j are contained in c[i,j]. If c has dimension greater than two the remaining indices enumerate multiple sets of coefficients.
The values of the two dimensional polynomial at points in the Cartesian product of x and y.
See also
New in version 1.7.0.


Integrate a Hermite series.
Returns the Hermite series coefficients c integrated m times from lbnd along axis. At each iteration the resulting series is multiplied by scl and an integration constant, k, is added. The scaling factor is for use in a linear change of variable. (“Buyer beware”: note that, depending on what one is doing, one may want scl to be the reciprocal of what one might expect; for more information, see the Notes section below.) The argument c is an array of coefficients from low to high degree along each axis, e.g., [1,2,3] represents the series H_0 + 2*H_1 + 3*H_2 while [[1,2],[1,2]] represents 1*H_0(x)*H_0(y) + 1*H_1(x)*H_0(y) + 2*H_0(x)*H_1(y) +
2*H_1(x)*H_1(y) if axis=0 is x and axis=1 is y.
Array of Hermite series coefficients. If c is multidimensional the different axis correspond to different variables with the degree in each axis given by the corresponding index.
Order of integration, must be positive. (Default: 1)
Integration constant(s). The value of the first integral at lbnd is the first value in the list, the value of the second integral at lbnd is the second value, etc. If k == [] (the default), all constants are set to zero. If m == 1, a single scalar can be given instead of a list.
The lower bound of the integral. (Default: 0)
Following each integration the result is multiplied by scl before the integration constant is added. (Default: 1)
Axis over which the integral is taken. (Default: 0).
New in version 1.7.0.
Hermite series coefficients of the integral.
If m < 0, len(k) > m, np.ndim(lbnd) != 0, or np.ndim(scl) != 0.
See also
Note that the result of each integration is multiplied by scl. Why is this important to note? Say one is making a linear change of variable \(u = ax + b\) in an integral relative to x. Then \(dx = du/a\), so one will need to set scl equal to \(1/a\) - perhaps not what one would have first thought.
Also note that, in general, the result of integrating a C-series needs to be “reprojected” onto the C-series basis set. Thus, typically, the result of this function is “unintuitive,” albeit correct; see Examples section below.


method
Series basis polynomial of degree deg.
Returns the series representing the basis polynomial of degree deg.
New in version 1.7.0.
Degree of the basis polynomial for the series. Must be >= 0.
If given, the array must be of the form [beg, end], where beg and end are the endpoints of the domain. If None is given then the class domain is used. The default is None.
If given, the resulting array must be if the form [beg, end], where beg and end are the endpoints of the window. If None is given then the class window is used. The default is None.
A series with the coefficient of the deg term set to one and all others zero.


method
Convert series to series of this class.
The series is expected to be an instance of some polynomial series of one of the types supported by by the numpy.polynomial module, but could be some other class that supports the convert method.
New in version 1.7.0.
The series instance to be converted.
If given, the array must be of the form [beg, end], where beg and end are the endpoints of the domain. If None is given then the class domain is used. The default is None.
If given, the resulting array must be if the form [beg, end], where beg and end are the endpoints of the window. If None is given then the class window is used. The default is None.
A series of the same kind as the calling class and equal to series when evaluated.
See also
similar instance method


method
Convert series to a different kind and/or domain and/or window.
The domain of the converted series. If the value is None, the default domain of kind is used.
The polynomial series type class to which the current instance should be converted. If kind is None, then the class of the current instance is used.
The window of the converted series. If the value is None, the default window of kind is used.
The returned class can be of different type than the current instance and/or have a different domain and/or different window.
Conversion between domains and class types can result in numerically ill defined series.


method
Truncate series to the given degree.
Reduce the degree of the series to deg by discarding the high order terms. If deg is greater than the current degree a copy of the current series is returned. This can be useful in least squares where the coefficients of the high degree terms may be very small.
New in version 1.5.0.
The series is reduced to degree deg by discarding the high order terms. The value of deg must be a non-negative integer.
New instance of series with reduced degree.


method
The degree of the series.
New in version 1.5.0.
Degree of the series, one less than the number of coefficients.


method
Differentiate.
Return a series instance of that is the derivative of the current series.
Find the derivative of order m.
A new series representing the derivative. The domain is the same as the domain of the differentiated series.


method
Least squares fit to data.
Return a series instance that is the least squares fit to the data y sampled at x. The domain of the returned instance can be specified and this will often result in a superior fit with less chance of ill conditioning.
x-coordinates of the M sample points (x[i], y[i]).
y-coordinates of the M sample points (x[i], y[i]).
Degree(s) of the fitting polynomials. If deg is a single integer all terms up to and including the deg’th term are included in the fit. For NumPy versions >= 1.11.0 a list of integers specifying the degrees of the terms to include may be used instead.
Domain to use for the returned series. If None, then a minimal domain that covers the points x is chosen. If [] the class domain is used. The default value was the class domain in NumPy 1.4 and None in later versions. The [] option was added in numpy 1.5.0.
Relative condition number of the fit. Singular values smaller than this relative to the largest singular value will be ignored. The default value is len(x)*eps, where eps is the relative precision of the float type, about 2e-16 in most cases.
Switch determining nature of return value. When it is False (the default) just the coefficients are returned, when True diagnostic information from the singular value decomposition is also returned.
Weights. If not None, the weight w[i] applies to the unsquared residual y[i] - y_hat[i] at x[i]. Ideally the weights are chosen so that the errors of the products w[i]*y[i] all have the same variance. When using inverse-variance weighting, use w[i] = 1/sigma(y[i]). The default value is None.
New in version 1.5.0.
Window to use for the returned series. The default value is the default class domain
New in version 1.6.0.
A series that represents the least squares fit to the data and has the domain and window specified in the call. If the coefficients for the unscaled and unshifted basis polynomials are of interest, do new_series.convert().coef.
These values are only returned if full == True
For more details, see linalg.lstsq.


method
Return series instance that has the specified roots.
Returns a series representing the product (x - r[0])*(x - r[1])*...*(x - r[n-1]), where r is a list of roots.
List of roots.
Domain for the resulting series. If None the domain is the interval from the smallest root to the largest. If [] the domain is the class domain. The default is [].
Window for the returned series. If None the class window is used. The default is None.
Series with the specified roots.


method
Check if coefficients match.
New in version 1.6.0.
The other class must have the coef attribute.
True if the coefficients are the same, False otherwise.


method
Check if domains match.
New in version 1.6.0.
The other class must have the domain attribute.
True if the domains are the same, False otherwise.


method
Check if types match.
New in version 1.7.0.
Class instance.
True if other is same class as self


method
Check if windows match.
New in version 1.6.0.
The other class must have the window attribute.
True if the windows are the same, False otherwise.


method
Identity function.
If p is the returned series, then p(x) == x for all values of x.
If given, the array must be of the form [beg, end], where beg and end are the endpoints of the domain. If None is given then the class domain is used. The default is None.
If given, the resulting array must be if the form [beg, end], where beg and end are the endpoints of the window. If None is given then the class window is used. The default is None.
Series of representing the identity.


method
Integrate.
Return a series instance that is the definite integral of the current series.
The number of integrations to perform.
Integration constants. The first constant is applied to the first integration, the second to the second, and so on. The list of values must less than or equal to m in length and any missing values are set to zero.
The lower bound of the definite integral.
A new series representing the integral. The domain is the same as the domain of the integrated series.


method
Return x, y values at equally spaced points in domain.
Returns the x, y values at n linearly spaced points across the domain. Here y is the value of the polynomial at the points x. By default the domain is the same as that of the series instance. This method is intended mostly as a plotting aid.
New in version 1.5.0.
Number of point pairs to return. The default value is 100.
If not None, the specified domain is used instead of that of the calling instance. It should be of the form [beg,end]. The default is None which case the class domain is used.
x is equal to linspace(self.domain[0], self.domain[1], n) and y is the series evaluated at element of x.


method
Return the mapping parameters.
The returned values define a linear map off + scl*x that is applied to the input arguments before the series is evaluated. The map depends on the domain and window; if the current domain is equal to the window the resulting map is the identity. If the coefficients of the series instance are to be used by themselves outside this class, then the linear function must be substituted for the x in the standard representation of the base polynomials.
The mapping function is defined by off + scl*x.
If the current domain is the interval [l1, r1] and the window is [l2, r2], then the linear mapping function L is defined by the equations:


method
Return the roots of the series polynomial.
Compute the roots for the series. Note that the accuracy of the roots decrease the further outside the domain they lie.
Array containing the roots of the series.


method
Remove trailing coefficients
Remove trailing coefficients until a coefficient is reached whose absolute value greater than tol or the beginning of the series is reached. If all the coefficients would be removed the series is set to [0]. A new series instance is returned with the new coefficients. The current instance remains unchanged.
All trailing coefficients less than tol will be removed.
New instance of series with trimmed coefficients.


method
Truncate series to length size.
Reduce the series to length size by discarding the high degree terms. The value of size must be a positive integer. This can be useful in least squares where the coefficients of the high degree terms may be very small.
The series is reduced to length size by discarding the high degree terms. The value of size must be a positive integer.
New instance of series with truncated coefficients.


Hermite series whose graph is a straight line.
The specified line is given by off + scl*x.
This module’s representation of the Hermite series for off + scl*x.
See also


Multiply one Hermite series by another.
Returns the product of two Hermite series c1 * c2. The arguments are sequences of coefficients, from lowest order “term” to highest, e.g., [1,2,3] represents the series P_0 + 2*P_1 + 3*P_2.
1-D arrays of Hermite series coefficients ordered from low to high.
Of Hermite series coefficients representing their product.
See also
In general, the (polynomial) product of two C-series results in terms that are not in the Hermite polynomial basis set. Thus, to express the product as a Hermite series, it is necessary to “reproject” the product onto said basis set, which may produce “unintuitive” (but correct) results; see Examples section below.


Multiply a Hermite series by x.
Multiply the Hermite series c by x, where x is the independent variable.
1-D array of Hermite series coefficients ordered from low to high.
Array representing the result of the multiplication.
See also
The multiplication uses the recursion relationship for Hermite polynomials in the form


An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data-type object describes the format of each element in the array (its byte-order, how many bytes it occupies in memory, whether it is an integer, a floating point number, or something else, etc.)
Arrays should be constructed using array, zeros or empty (refer to the See Also section below). The parameters given here refer to a low-level method (ndarray(…)) for instantiating an array.
For more information, refer to the numpy module and examine the methods and attributes of an array.
Shape of created array.
Any object that can be interpreted as a numpy data type.
Used to fill the array with data.
Offset of array data in buffer.
Strides of data in memory.
Row-major (C-style) or column-major (Fortran-style) order.
See also
Construct an array.
Create an array, each element of which is zero.
Create an array, but leave its allocated memory unchanged (i.e., it contains “garbage”).
Create a data-type.
An ndarray alias generic w.r.t. its dtype.type.
There are two modes of creating an array using __new__:
No __init__ method is needed because the array is fully initialized after the __new__ method.
These examples illustrate the low-level ndarray constructor. Refer to the See Also section above for easier ways of constructing an ndarray.
First mode, buffer is None:
Second mode:
Transpose of the array.
The array’s elements, in memory.
Describes the format of the elements in the array.
Dictionary containing information related to memory use, e.g., ‘C_CONTIGUOUS’, ‘OWNDATA’, ‘WRITEABLE’, etc.
Flattened version of the array as an iterator. The iterator allows assignments, e.g., x.flat = 3 (See ndarray.flat for assignment examples; TODO).
Imaginary part of the array.
Real part of the array.
Number of elements in the array.
The memory use of each array element in bytes.
The total number of bytes required to store the array data, i.e., itemsize * size.
The array’s number of dimensions.
Shape of the array.
The step-size required to move from one element to the next in memory. For example, a contiguous (3, 4) array of type int16 in C-order has strides (8, 2). This implies that to move from element to element in memory requires jumps of 2 bytes. To move from row-to-row, one needs to jump 8 bytes at a time (2 * 4).
Class containing properties of the array needed for interaction with ctypes.
If the array is a view into another array, that array is its base (unless that array is also a view). The base array is where the array data is actually stored.


Raise a Hermite series to a power.
Returns the Hermite series c raised to the power pow. The argument c is a sequence of coefficients ordered from low to high. i.e., [1,2,3] is the series P_0 + 2*P_1 + 3*P_2.
1-D array of Hermite series coefficients ordered from low to high.
Power to which the series will be raised
Maximum power allowed. This is mainly to limit growth of the series to unmanageable size. Default is 16
Hermite series of power.
See also


Compute the roots of a Hermite series.
Return the roots (a.k.a. “zeros”) of the polynomial
1-D array of coefficients.
Array of the roots of the series. If all the roots are real, then out is also real, otherwise it is complex.
See also
The root estimates are obtained as the eigenvalues of the companion matrix, Roots far from the origin of the complex plane may have large errors due to the numerical instability of the series for such values. Roots with multiplicity greater than 1 will also show larger errors as the value of the series near such points is relatively insensitive to errors in the roots. Isolated roots near the origin can be improved by a few iterations of Newton’s method.
The Hermite series basis polynomials aren’t powers of x so the results of this function may seem unintuitive.


Subtract one Hermite series from another.
Returns the difference of two Hermite series c1 - c2. The sequences of coefficients are from lowest order term to highest, i.e., [1,2,3] represents the series P_0 + 2*P_1 + 3*P_2.
1-D arrays of Hermite series coefficients ordered from low to high.
Of Hermite series coefficients representing their difference.
See also
Unlike multiplication, division, etc., the difference of two Hermite series is a Hermite series (without having to “reproject” the result onto the basis set) so subtraction, just like that of “standard” polynomials, is simply “component-wise.”


Remove “small” “trailing” coefficients from a polynomial.
“Small” means “small in absolute value” and is controlled by the parameter tol; “trailing” means highest order coefficient(s), e.g., in [0, 1, 1, 0, 0] (which represents 0 + x + x**2 + 0*x**3 + 0*x**4) both the 3-rd and 4-th order coefficients would be “trimmed.”
1-d array of coefficients, ordered from lowest order to highest.
Trailing (i.e., highest order) elements with absolute value less than or equal to tol (default value is zero) are removed.
1-d array with trailing zeros removed. If the resulting series would be empty, a series containing a single zero is returned.
If tol < 0
See also


Evaluate an Hermite series at points x.
If c is of length n + 1, this function returns the value:
The parameter x is converted to an array only if it is a tuple or a list, otherwise it is treated as a scalar. In either case, either x or its elements must support multiplication and addition both with themselves and with the elements of c.
If c is a 1-D array, then p(x) will have the same shape as x. If c is multidimensional, then the shape of the result depends on the value of tensor. If tensor is true the shape will be c.shape[1:] + x.shape. If tensor is false the shape will be c.shape[1:]. Note that scalars have shape (,).
Trailing zeros in the coefficients will be used in the evaluation, so they should be avoided if efficiency is a concern.
If x is a list or tuple, it is converted to an ndarray, otherwise it is left unchanged and treated as a scalar. In either case, x or its elements must support addition and multiplication with with themselves and with the elements of c.
Array of coefficients ordered so that the coefficients for terms of degree n are contained in c[n]. If c is multidimensional the remaining indices enumerate multiple polynomials. In the two dimensional case the coefficients may be thought of as stored in the columns of c.
If True, the shape of the coefficient array is extended with ones on the right, one for each dimension of x. Scalars have dimension 0 for this action. The result is that every column of coefficients in c is evaluated for every element of x. If False, x is broadcast over the columns of c for the evaluation. This keyword is useful when c is multidimensional. The default value is True.
New in version 1.7.0.
The shape of the return value is described above.
See also
The evaluation uses Clenshaw recursion, aka synthetic division.


Evaluate a 2-D Hermite series at points (x, y).
This function returns the values:
The parameters x and y are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and they must have the same shape after conversion. In either case, either x and y or their elements must support multiplication and addition both with themselves and with the elements of c.
If c is a 1-D array a one is implicitly appended to its shape to make it 2-D. The shape of the result will be c.shape[2:] + x.shape.
The two dimensional series is evaluated at the points (x, y), where x and y must have the same shape. If x or y is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn’t an ndarray it is treated as a scalar.
Array of coefficients ordered so that the coefficient of the term of multi-degree i,j is contained in c[i,j]. If c has dimension greater than two the remaining indices enumerate multiple sets of coefficients.
The values of the two dimensional polynomial at points formed with pairs of corresponding values from x and y.
See also
New in version 1.7.0.


Evaluate a 3-D Hermite series at points (x, y, z).
This function returns the values:
The parameters x, y, and z are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and they must have the same shape after conversion. In either case, either x, y, and z or their elements must support multiplication and addition both with themselves and with the elements of c.
If c has fewer than 3 dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape.
The three dimensional series is evaluated at the points (x, y, z), where x, y, and z must have the same shape. If any of x, y, or z is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn’t an ndarray it is treated as a scalar.
Array of coefficients ordered so that the coefficient of the term of multi-degree i,j,k is contained in c[i,j,k]. If c has dimension greater than 3 the remaining indices enumerate multiple sets of coefficients.
The values of the multidimensional polynomial on points formed with triples of corresponding values from x, y, and z.
See also
New in version 1.7.0.


Pseudo-Vandermonde matrix of given degree.
Returns the pseudo-Vandermonde matrix of degree deg and sample points x. The pseudo-Vandermonde matrix is defined by
where 0 <= i <= deg. The leading indices of V index the elements of x and the last index is the degree of the Hermite polynomial.
If c is a 1-D array of coefficients of length n + 1 and V is the array V = hermvander(x, n), then np.dot(V, c) and hermval(x, c) are the same up to roundoff. This equivalence is useful both for least squares fitting and for the evaluation of a large number of Hermite series of the same degree and sample points.
Array of points. The dtype is converted to float64 or complex128 depending on whether any of the elements are complex. If x is scalar it is converted to a 1-D array.
Degree of the resulting matrix.
The pseudo-Vandermonde matrix. The shape of the returned matrix is x.shape + (deg + 1,), where The last index is the degree of the corresponding Hermite polynomial. The dtype will be the same as the converted x.