Distributions

These distributions can be used in any place that Nengo distributions can be used.

nengo_extras.dists.Concatenate(distributions)

Concatenate distributions to form an independent multivariate

nengo_extras.dists.MultivariateCopula(…[, rho])

Generalized multivariate distribution.

nengo_extras.dists.MultivariateGaussian(…)

nengo_extras.dists.Mixture(distributions[, p])

nengo_extras.dists.Tile(values)

Choose values in order from an array

nengo_extras.dists.gaussian_icdf(mean, std)

nengo_extras.dists.loggaussian_icdf(…[, base])

nengo_extras.dists.uniform_icdf(low, high)

class nengo_extras.dists.Concatenate(distributions)[source]

Concatenate distributions to form an independent multivariate

sample(self, n, d=None, rng=numpy.random)[source]

Samples the distribution.

Parameters
nint

Number samples to take.

dint or None, optional

The number of dimensions to return. If this is an int, the return value will be of shape (n, d). If None, the return value will be of shape (n,).

rngnumpy.random.RandomState, optional

Random number generator state.

Returns
samples(n,) or (n, d) array_like

Samples as a 1d or 2d array depending on d. The second dimension enumerates the dimensions of the process.

class nengo_extras.dists.MultivariateCopula(marginal_icdfs, rho=None)[source]

Generalized multivariate distribution.

Uses the copula method to sample from a general multivariate distribution, given marginal distributions and copula covariances [1].

Parameters
marginal_icdfsiterable

List of functions, each one being the inverse CDF of the marginal distribution across that dimension.

rhoarray_like (optional)

Array of copula covariances [1] between parameters. Defaults to the identity matrix (independent parameters).

References

1(1,2)

Copula (probability theory). Wikipedia. https://en.wikipedia.org/wiki/Copula_(probability_theory%29

sample(self, n, d=None, rng=numpy.random)[source]

Samples the distribution.

Parameters
nint

Number samples to take.

dint or None, optional

The number of dimensions to return. If this is an int, the return value will be of shape (n, d). If None, the return value will be of shape (n,).

rngnumpy.random.RandomState, optional

Random number generator state.

Returns
samples(n,) or (n, d) array_like

Samples as a 1d or 2d array depending on d. The second dimension enumerates the dimensions of the process.

class nengo_extras.dists.MultivariateGaussian(mean, cov)[source]
sample(self, n, d=None, rng=numpy.random)[source]

Samples the distribution.

Parameters
nint

Number samples to take.

dint or None, optional

The number of dimensions to return. If this is an int, the return value will be of shape (n, d). If None, the return value will be of shape (n,).

rngnumpy.random.RandomState, optional

Random number generator state.

Returns
samples(n,) or (n, d) array_like

Samples as a 1d or 2d array depending on d. The second dimension enumerates the dimensions of the process.

class nengo_extras.dists.Mixture(distributions, p=None)[source]
sample(self, n, d=None, rng=numpy.random)[source]

Samples the distribution.

Parameters
nint

Number samples to take.

dint or None, optional

The number of dimensions to return. If this is an int, the return value will be of shape (n, d). If None, the return value will be of shape (n,).

rngnumpy.random.RandomState, optional

Random number generator state.

Returns
samples(n,) or (n, d) array_like

Samples as a 1d or 2d array depending on d. The second dimension enumerates the dimensions of the process.

class nengo_extras.dists.Tile(values)[source]

Choose values in order from an array

This distribution is not random, but rather tiles an array to be a particular size. This is useful for example if you want to pass an array for a neuron parameter, but are not sure how many neurons there will be.

Parameters
valuesarray_like

The values to tile.

sample(self, n, d=None, rng=numpy.random)[source]

Samples the distribution.

Parameters
nint

Number samples to take.

dint or None, optional

The number of dimensions to return. If this is an int, the return value will be of shape (n, d). If None, the return value will be of shape (n,).

rngnumpy.random.RandomState, optional

Random number generator state.

Returns
samples(n,) or (n, d) array_like

Samples as a 1d or 2d array depending on d. The second dimension enumerates the dimensions of the process.

nengo_extras.dists.gaussian_icdf(mean, std)[source]
nengo_extras.dists.loggaussian_icdf(log_mean, log_std, base=2.718281828459045)[source]
nengo_extras.dists.uniform_icdf(low, high)[source]