openmc.stats.Mixture

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

Probability distribution characterized by a mixture of random variables.

Parameters:
  • probability (Iterable of Real) – Probability of selecting a particular distribution

  • distribution (Iterable of Univariate) – List of distributions with corresponding probabilities

  • bias (Iterable of Real, optional) – Probability of selecting a particular distribution under biased sampling

Variables:
  • probability (Iterable of Real) – Probability of selecting a particular distribution

  • distribution (Iterable of Univariate) – List of distributions with corresponding probabilities

  • support (dict) – Dictionary containing discrete and continuous parts of the support

  • bias (numpy.ndarray or None) – Probability of selecting each distribution under biased sampling

clip(tolerance: float = 1e-06, inplace: bool = False) Mixture[source]

Remove low-importance points / distributions

Like Discrete.clip(), this method will remove low-importance points from discrete distributions contained within the mixture but it will also clip any distributions that have negligible contributions to the overall intensity.

Added in version 0.14.0.

Parameters:
  • tolerance (float) – Maximum fraction of intensities that will be discarded.

  • inplace (bool) – Whether to modify the current object in-place or return a new one.

Return type:

Distribution with low-importance points / distributions removed

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

classmethod from_xml_element(elem: Element)[source]

Generate mixture distribution from an XML element

Added in version 0.13.0.

Parameters:

elem (lxml.etree._Element) – XML element

Returns:

Mixture distribution generated from XML element

Return type:

openmc.stats.Mixture

integral()[source]

Return integral of the distribution

Added in version 0.13.1.

Returns:

Integral of the distribution

Return type:

float

mean() float[source]

Return mean of the mixture distribution

The mean is the weighted average of the means of the component distributions, weighted by probability * integral.

Added in version 0.15.3.

Returns:

Mean of the mixture distribution

Return type:

float

normalize()[source]

Normalize the probabilities stored on the distribution

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

to_xml_element(element_name: str)[source]

Return XML representation of the mixture distribution

Added in version 0.13.0.

Parameters:

element_name (str) – XML element name

Returns:

element – XML element containing mixture distribution data

Return type:

lxml.etree._Element