openmc.stats.Discrete

class openmc.stats.Discrete(x, p)[source]

Distribution characterized by a probability mass function.

The Discrete distribution assigns probability values to discrete values of a random variable, rather than expressing the distribution as a continuous random variable.

Parameters
  • x (Iterable of float) – Values of the random variable

  • p (Iterable of float) – Discrete probability for each value

Variables
classmethod from_xml_element(elem)[source]

Generate discrete distribution from an XML element

Parameters

elem (xml.etree.ElementTree.Element) – XML element

Returns

Discrete distribution generated from XML element

Return type

openmc.stats.Discrete

integral()[source]

Return integral of distribution

New in version 0.13.1.

Returns

Integral of discrete distribution

Return type

float

classmethod merge(dists, probs)[source]

Merge multiple discrete distributions into a single distribution

New in version 0.13.1.

Parameters
  • dists (iterable of openmc.stats.Discrete) – Discrete distributions to combine

  • probs (iterable of float) – Probability of each distribution

Returns

Combined discrete distribution

Return type

openmc.stats.Discrete

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)[source]

Return XML representation of the discrete distribution

Parameters

element_name (str) – XML element name

Returns

element – XML element containing discrete distribution data

Return type

xml.etree.ElementTree.Element