Package csb :: Package numeric |
[frames] | no frames]

# Package numeric

source code

Low level numeric / math utility functions.

Submodules
csb.numeric.integrators: provides various integration schemes and an abstract gradient class.

Classes
| InvertibleMatrix Matrix object which is intended to save time in MCMC sampling algorithms involving repeated integration of Hamiltonian equations of motion and frequent draws from multivariate normal distributions involving mass matrices as covariance matrices.
| MatrixInitError

Functions
approx_psi(x) | source code
tuple |
axis_and_angle(r) Calculate axis and angle of rotation from a three dimensional rotation matrix. | source code
convolve(x, f) | source code
correlate(x, y) | source code
d_approx_psi(x) | source code
degree2radian(x) Convert randian angles to torsion angles. | source code
dihedral_angle(a, b, c, d) Calculate the dihedral angle between 4 vectors, representing 4 connected points. | source code
euler(a, b, c) Calculate a three dimensional rotation matrix from the euler angles. | source code
euler_angles(r) Calculate the euler angles from a three dimensional rotation matrix. | source code
exp(x, x_min=-308, x_max=709) Safe version of exp, clips argument such that overflow does not occur. | source code
from_polar(x) Reconstruct d-dimensional vector from polar coordinates. | source code
from_polar3d(x) Reconstruct 3-dimensional vector from polar coordinates. | source code
(n,n) numpy.array |
gower_matrix(X) Gower, J.C. | source code
inv_psi(y, tol=1e-10, n_iter=100, psi=<function psi at 0x033D6FB0>) Inverse digamma function | source code
isreal(x, tol=1e-14) Check if input array has no imaginary part. | source code
log(x, x_min=1e-308, x_max=1e+308) Safe version of log, clips argument such that overflow does not occur. | source code
log_midpoint_rule_2d(log_f, x, y) | source code
log_sum_exp(x, axis=0) Return the logarithm of the sum of exponentials. | source code
log_sum_exp_accumulate(x, axis=0) Return the logarithm of the accumulated sums of exponentials. | source code
log_trapezoidal(log_y, x=None) Compute the logarithm of the 1D integral of x, using trepezoidal approximation. | source code
log_trapezoidal_2d(log_f, x=None, y=None) Compute the logarithm of the 1D integral of x, using trepezoidal approximation. | source code
norm(x) Calculate the Eucledian norm of a d-dimensional vector. | source code
pad(x, s) Add layers of zeros around grid. | source code
polar(x) Polar coordinate representation of a d-dimensional vector. | source code
polar3d(x) Polar coordinate representation of a three-dimensional vector. | source code
psi(x) Digamma function | source code
radian2degree(x) Convert radians angles to torsion angles. | source code
reverse(array, axis=0) Reverse the order of elements in an array. | source code
(3,3) numpy.array |
rotation_matrix(axis, angle) Calculate a three dimensional rotation matrix for a rotation around the given angle and axis. | source code
sign(x) Return the sign of the input. | source code
simpson_2d(f) Approximate the integral of f from a to b in two dimensions, using Composite Simpson's rule. | source code
trapezoidal(x, y) | source code
trapezoidal_2d(f) Approximate the integral of f from a to b in two dimensions, using trepezoidal approximation. | source code
trim(x, s) Remove additional layers. | source code
zerofill(x, s) | source code

Variables
| EULER_MASCHERONI = `0.577215664902`
| EXP_MAX = `709`
| EXP_MIN = `-308`
| LOG_MAX = `1e+308`
| LOG_MIN = `1e-308`

Function Details

### axis_and_angle(r) | source code
Calculate axis and angle of rotation from a three dimensional rotation matrix. Parameters: `r` - 3x3 Rotation matrix Returns: tuple axis unit vector as (3,) numpy.array and angle in radians as float

### degree2radian(x) | source code
Convert randian angles to torsion angles. Parameters: `x` - torsion angle Returns: radian angle of x

### dihedral_angle(a, b, c, d) | source code
Calculate the dihedral angle between 4 vectors, representing 4 connected points. The angle is in range [-180, 180]. Parameters: `a` (array) - the four points that define the dihedral angle Returns: angle in [-180, 180]

### euler(a, b, c) | source code
Calculate a three dimensional rotation matrix from the euler angles. Parameters: `a` - alpha, angle between the x-axis and the line of nodes `b` - beta, angle between the z axis of the different coordinate systems `c` - gamma, angle between the line of nodes and the X-axis

### euler_angles(r) | source code
Calculate the euler angles from a three dimensional rotation matrix. Parameters: `r` - 3x3 Rotation matrix

### exp(x, x_min=-308, x_max=709) | source code
Safe version of exp, clips argument such that overflow does not occur. Parameters: `x` (numpy array or float or int) - input `x_min` (float) - lower value for clipping `x_max` (float) - upper value for clipping

### from_polar(x) | source code
Reconstruct d-dimensional vector from polar coordinates. Parameters: `x` - vector (i.e. rank one array) Returns: position in d-dimensional space

### from_polar3d(x) | source code
Reconstruct 3-dimensional vector from polar coordinates. Parameters: `x` - vector (i.e. rank one array) Returns: position in 3-dimensional space

### gower_matrix(X) | source code
Gower, J.C. (1966). Some distance properties of latent root and vector methods used in multivariate analysis. Biometrika 53: 325-338 Parameters: `X` ((m,n,k) numpy.array) - ensemble coordinates Returns: (n,n) numpy.array symmetric dissimilarity matrix

### isreal(x, tol=1e-14) | source code
Check if input array has no imaginary part. Parameters: `x` (numpy array) - input array `tol` (float) - tolerance to check for equality zero

### log(x, x_min=1e-308, x_max=1e+308) | source code
Safe version of log, clips argument such that overflow does not occur. Parameters: `x` (numpy array or float or int) - input `x_min` (float) - lower value for clipping `x_max` (float) - upper value for clipping

### log_sum_exp(x, axis=0) | source code
Return the logarithm of the sum of exponentials. Parameters: `x` (Numpy array)

### log_sum_exp_accumulate(x, axis=0) | source code
Return the logarithm of the accumulated sums of exponentials. Parameters: `x` (Numpy array)

### log_trapezoidal(log_y, x=None) | source code
Compute the logarithm of the 1D integral of x, using trepezoidal approximation. Assumes x is monotonically increasing.

### log_trapezoidal_2d(log_f, x=None, y=None) | source code
Compute the logarithm of the 1D integral of x, using trepezoidal approximation. Assumes x and y is monotonically increasing.

### norm(x) | source code
Calculate the Eucledian norm of a d-dimensional vector. Parameters: `x` - vector (i.e. rank one array) Returns: length of vector

### polar(x) | source code
Polar coordinate representation of a d-dimensional vector. Parameters: `x` - vector (i.e. rank one array) Returns: polar coordinates (radius and polar angles)

### polar3d(x) | source code
Polar coordinate representation of a three-dimensional vector. Parameters: `x` - vector (i.e. rank one array) Returns: polar coordinates (radius and polar angles)

### radian2degree(x) | source code
Convert radians angles to torsion angles. Parameters: `x` - radian angle Returns: torsion angle of x

### rotation_matrix(axis, angle) | source code
Calculate a three dimensional rotation matrix for a rotation around the given angle and axis. Parameters: `angle` (float) - angle in radians `axis` ((3,) numpy array) Returns: (3,3) numpy.array

### simpson_2d(f) | source code
Approximate the integral of f from a to b in two dimensions, using Composite Simpson's rule. Parameters: `f` - 2D numpy array of function values Returns: approximation of the definit integral

### trapezoidal_2d(f) | source code
Approximate the integral of f from a to b in two dimensions, using trepezoidal approximation. Parameters: `f` - 2D numpy array of function values at equally spaces positions Returns: approximation of the definit integral