DMM.discrete_rv#

module for common operations on discrete random variables (distributions)

class DiscreteRV(w, x)#

Bases: object

class for 1-d finite discrete RV

weights: probabilites masses atoms: atoms

dist_w1(another_rv)#

Compute the W1 distance from another_rv

moment(degree=1)#

Compute the moments of the input RV up to the given degree (start from first degree) Args: degree: int highest degree k

Returns: array of moments from the first degree to degree k

sample(num)#

draw n iid sample from U library: https://docs.scipy.org/doc/numpy/reference/routines.random.html alternative way: scipy.stats.rv_discrete(name=’custm’, values=(xk, pk))

sample_noisy(num, sigma=1)#

draw n iid samples from model U+sigma Z. Default sigma=1.

assert_shape_equal(x_var, y_var)#

Assert shape equal

wass(u_rv, v_rv)#

compute W1 distance between DiscreteRVs U and V