openmc.stats.Mixture

class openmc.stats.Mixture(probability: Sequence[float], distribution: Sequence[Univariate])[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

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

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

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

Remove low-importance points from contained discrete distributions.

Given a probability mass function \(p(x)\) with \(\{x_1, x_2, x_3, \dots\}\) the possible values of the random variable with corresponding probabilities \(\{p_1, p_2, p_3, \dots\}\), this function will remove any low-importance points such that \(\sum_i x_i p_i\) is preserved to within some threshold.

New in version 0.14.0.

Parameters
  • tolerance (float) – Maximum fraction of \(\sum_i x_i p_i\) that will be discarded for any discrete distributions within the mixture distribution.

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

Return type

Discrete distribution with low-importance points removed

classmethod from_xml_element(elem: Element)[source]

Generate mixture distribution from an XML element

New 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

New in version 0.13.1.

Returns

Integral of the distribution

Return type

float

normalize()[source]

Normalize the probabilities stored on the distribution

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

Sample the univariate distribution

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

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

Returns

A 1-D array of sampled values

Return type

numpy.ndarray

to_xml_element(element_name: str)[source]

Return XML representation of the mixture distribution

New 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