Utility Functions¶
Function Reference¶
-
qinfer.utils.
binomial_pdf
(N, n, p)[source]¶ Returns the PDF of the binomial distribution Bin(N,p) evaluated at n.
-
qinfer.utils.
particle_meanfn
(weights, locations, fn=None)[source]¶ Returns the mean of a function f over model parameters.
Parameters: - weights (numpy.ndarray) – Weights of each particle.
- locations (numpy.ndarray) – Locations of each particle.
- fn (callable) – Function of model parameters to
take the mean of. If
None
, the identity function is assumed.
-
qinfer.utils.
particle_covariance_mtx
(weights, locations)[source]¶ Returns an estimate of the covariance of a distribution represented by a given set of SMC particle.
Parameters: - weights – An array containing the weights of each particle.
- location – An array containing the locations of each particle.
Return type: numpy.ndarray
, shape(n_modelparams, n_modelparams)
.Returns: An array containing the estimated covariance matrix.
-
qinfer.utils.
in_ellipsoid
(x, A, c)[source]¶ Determines which of the points
x
are in the closed ellipsoid with shape matrixA
centered atc
. For a single pointx
, this is computed as(c−x)T⋅A−1⋅(c−x)≤1Parameters: - x (np.ndarray) – Shape
(n_points, dim)
orn_points
. - A (np.ndarray) – Shape
(dim, dim)
, positive definite - c (np.ndarray) – Shape
(dim)
Returns: bool
or array of bools of lengthn_points
- x (np.ndarray) – Shape
-
qinfer.utils.
ellipsoid_volume
(A=None, invA=None)[source]¶ Returns the volume of an ellipsoid given either its matrix or the inverse of its matrix.