asrandvar¶
-
probnum.random_variables.
asrandvar
(obj) → probnum.random_variables.RandomVariable¶ Return
obj
as aRandomVariable
.Converts scalars, (sparse) arrays or distribution classes to a
RandomVariable
.Parameters: obj (object) – Argument to be represented as a RandomVariable
.Returns: rv – The object obj as a RandomVariable
.Return type: RandomVariable See also
RandomVariable()
- Class representing random variables.
Examples
>>> from scipy.stats import bernoulli >>> from probnum import asrandvar >>> bern = bernoulli(p=0.5) >>> bern.random_state = 42 # Seed for reproducibility >>> b = asrandvar(bern) >>> b.sample(size=5) array([1, 1, 1, 0, 0])