def gauss(mu, sigma, n_obs=50, batch_size=1, random_state=None):
"""Sample the 1-D Gaussian distribution.
Parameters
----------
mu : float, array_like
sigma : float, array_like
n_obs : int, optional
batch_size : int, optional
random_state : np.random.RandomState, optional
Returns
-------
array_like
1-D observations.
"""
# Transforming the arrays' shape to be compatible with batching.
batches_mu = np.asanyarray(mu).reshape((-1, 1))
batches_sigma = np.asanyarray(sigma).reshape((-1, 1))
# Sampling observations.
y_obs = ss.norm.rvs(loc=batches_mu, scale=batches_sigma,
size=(batch_size, n_obs), random_state=random_state)
return y_obs
评论列表
文章目录