Skip to content

Statistics

ocelot.util.stats.variable_bin_histogram(values, min, max, minimum_width, minimum_size=5) ¤

Computes a variably binned histogram.

ocelot.util.stats.calculate_bin_centers(bin_edges) ¤

Calculates the centers of a binned histogram.

ocelot.util.stats.vectorized_multivariate_normal_pdf(values, means, covariances) ¤

Calculate the PDF of n_queries different multivariate normal distributions at n_queries different points in a fast and vectorized way. Significantly faster than scipy.stats.multivariate_normal.pdf() when n_queries is large.

Parameters:

Name Type Description Default
values ndarray

Values to query the PDF at. Must have shape (n_queries, n_dims).

required
means ndarray

Means of the distributions. Must have shape (n_queries, n_dims).

required
covariances ndarray

Covariances of the distributions. Must have shape (n_queries, n_dims, n_dims).

required

Returns:

Type Description
ndarray

Array of shape (n_queries,) giving the PDF value of each distribution.

ocelot.util.stats.vectorized_multivariate_normal_rvs(means, covariances, n_samples=1, seed=None, method='svd') ¤

Sample n_samples samples from arrays of different multivariate normal distributions at n_samples different points in a fast and vectorized way. Significantly faster than scipy.stats.multivariate_normal.rvs() when n_queries is large.

Parameters:

Name Type Description Default
means ndarray

Means of the distributions. Must have shape (n_dists, n_dims).

required
covariances ndarray

Covariances of the distributions. Must have shape (n_dists, n_dims, n_dims).

required
n_samples int

Number of samples to draw from each distribution. Default: 1

1
method 'svd', 'eigh', 'cholesky'

Method to use for matrix decompositions. From the numpy docs: "The cov input is used to compute a factor matrix A such that A @ A.T = cov. This argument is used to select the method used to compute the factor matrix A. The default method 'svd' is the slowest, while 'cholesky' is the fastest but less robust than the slowest method. The method eigh uses eigen decomposition to compute A and is faster than svd but slower than cholesky." Default: 'svd'

'svd'

Returns:

Type Description
ndarray

Array of samples of shape (n_samples, n_dists, n_dims).