openmc.stats.Legendre

class openmc.stats.Legendre(coefficients: Sequence[float], bias: Univariate | None = None)[source]

Probability density given by a Legendre polynomial expansion \(\sum\limits_{\ell=0}^N \frac{2\ell + 1}{2} a_\ell P_\ell(\mu)\).

Parameters:
  • coefficients (Iterable of Real) – Expansion coefficients \(a_\ell\). Note that the \((2\ell + 1)/2\) factor should not be included.

  • bias (openmc.stats.Univariate or None, optional) – Distribution for biased sampling.

Variables:
  • coefficients (Iterable of Real) – Expansion coefficients \(a_\ell\). Note that the \((2\ell + 1)/2\) factor should not be included.

  • support (tuple of float) – A 2-tuple (lower, upper) defining the interval over which the distribution is nonzero-valued

  • bias (openmc.stats.Univariate or None) – Distribution for biased sampling

evaluate(x)[source]

Evaluate the probability density at the provided value.

Parameters:

x (float or sequence of float) – Location to evaluate p(x)

Returns:

Value of p(x)

Return type:

float or numpy.ndarray

sample(n_samples=1, seed=None)[source]

Sample the univariate distribution, handling biasing automatically.

Parameters:
  • n_samples (int) – Number of sampled values to generate

  • seed (int or None) – Initial random number seed.

Returns:

A tuple of (samples, weights)

Return type:

tuple of numpy.ndarray

property support

Return the support of the probability distribution.

Returns:

Returns the set of unique points assigned probability mass in a discrete distribution, the sampling interval for a continuous distribution, or a dictionary storing the discrete and continuous parts of the support of a mixed random variable

Return type:

set or tuple of float or dict