SciPy 0.6.0 API Documentation Generated by Endo, 2007-10-17
maxentutils.py: Utility routines for the maximum entropy module. Most of them are either Python replacements for the corresponding Fortran routines or wrappers around matrices to allow the maxent module to manipulate ndarrays, scipy sparse matrices, and PySparse matrices a common interface.
Perhaps the logsumexp() function belongs under the utils/ branch where other modules can access it more easily.
Copyright: Ed Schofield, 2003-2006 License: BSD-style (see LICENSE.txt in main source directory)
Returns the elementwise antilog of the real array x. We try to exponentiate with numpy.exp() and, if that fails, with python's math.exp(). numpy.exp() is about 10 times faster but throws an OverflowError exception for numerical underflow (e.g. exp(-800), whereas python's math.exp() just returns zero, which is much more helpful.
Returns the elementwise antilog of the vector x. We try to exponentiate with numpy.exp() and, if that fails, with python's math.exp(). numpy.exp() is about 10 times faster but throws an OverflowError exception for numerical underflow (e.g. exp(-800), whereas python's math.exp() just returns zero, which is much more helpful.
This is a wrapper for general dense or sparse dot products. It is only necessary as a common interface for supporting ndarray, scipy spmatrix, and PySparse arrays.
Returns a dense (1 x n) vector with the column averages of A, which can be an (m x n) sparse or dense matrix.
>>> a = numpy.array([[1,2],[3,4]],'d') >>> columnmeans(a) array([ 2., 3.])
This is a wrapper for general dense or sparse dot products. It is not necessary except as a common interface for supporting ndarray, scipy spmatrix, and PySparse arrays.
Returns a dense (1 x n) vector with unbiased estimators for the column variances for each column of the (m x n) sparse or dense matrix A. (The normalization is by (m - 1).)
>>> a = numpy.array([[1,2], [3,4]], 'd') >>> columnvariances(a) array([ 2., 2.])
Returns an (m x n) dense array of non-zero evaluations of the scalar functions fi in the list f at the points x_1,...,x_n in the list sample.
Returns a dense array of non-zero evaluations of the functions fi in the list f at the point x.
This is a wrapper around general dense or sparse dot products. It is not necessary except as a common interface for supporting ndarray, scipy spmatrix, and PySparse arrays.
Returns the dot product of the (1 x m) sparse array u with the (m x 1) (dense) numpy array v.
Flattens the sparse matrix or dense array/matrix 'a' into a 1-dimensional array
This is a wrapper around general dense or sparse dot products. It is not necessary except as a common interface for supporting ndarray, scipy spmatrix, and PySparse arrays.
Returns the inner product of the (m x n) dense or sparse matrix A with the n-element dense array v. This is a wrapper for A.dot(v) for dense arrays and spmatrix objects, and for A.matvec(v, result) for PySparse matrices.
This is a wrapper around general dense or sparse dot products. It is not necessary except as a common interface for supporting ndarray, scipy spmatrix, and PySparse arrays.
Computes A^T V, where A is a dense or sparse matrix and V is a numpy array. If A is sparse, V must be a rank-1 array, not a matrix. This function is efficient for large matrices A. This is a wrapper for u.T.dot(v) for dense arrays and spmatrix objects, and for u.matvec_transp(v, result) for pysparse matrices.
Compute the log of the sum of exponentials log(e^{a_1}+...e^{a_n}) of the components of the array a, avoiding numerical overflow.
For testing logsumexp(). Subject to numerical overflow for large values (e.g. 720).
Returns log(x) if x > 0, the complex log cmath.log(x) if x < 0, or float('-inf') if x == 0.
This is a wrapper for general dense or sparse dot products. It is only necessary as a common interface for supporting ndarray, scipy spmatrix, and PySparse arrays.
Returns a dense (m x 1) vector representing the mean of the rows of A, which be an (m x n) sparse or dense matrix.
>>> a = numpy.array([[1,2],[3,4]], float) >>> rowmeans(a) array([ 1.5, 3.5])
Chooses k random elements (with replacement) from a population. (From the Python Cookbook).
Returns an (m x n) sparse matrix of non-zero evaluations of the scalar or vector functions f_1,...,f_m in the list f at the points x_1,...,x_n in the sequence 'sample'.
If format='ll_mat', the PySparse module (or a symlink to it) must be available in the Python site-packages/ directory. A trimmed-down version, patched for NumPy compatibility, is available in the SciPy sandbox/pysparse directory.
Returns an Mx1 sparse matrix of non-zero evaluations of the scalar functions f_1,...,f_m in the list f at the point x.
If format='ll_mat', the PySparse module (or a symlink to it) must be available in the Python site-packages/ directory. A trimmed-down version, patched for NumPy compatibility, is available in the SciPy sandbox/pysparse directory.
| Local name | Refers to |
|---|---|
| asarray | numpy.asarray |
| bisect | bisect |
| cmath | cmath |
| division | __future__.division |
| exp | numpy.exp |
| log | numpy.log |
| math | math |
| ndarray | numpy.ndarray |
| numpy | numpy |
| random | random |
| sparse | scipy.sparse |