openmc.stats.Univariate

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

Probability distribution of a single random variable.

The Univariate class is an abstract class that can be derived to implement a specific probability distribution.

Parameters:

bias (Iterable of float, optional) – Distribution or discrete probabilities for biased sampling or discrete probabilities for biased sampling.

abstractmethod evaluate(x: float | Sequence[float])[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

integral()[source]

Return integral of distribution

Added in version 0.13.1.

Returns:

Integral of distribution

Return type:

float

sample(n_samples: int = 1, seed: int | None = 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

abstract 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