Gaussian (Normal)
Data Type: float
The Gaussian distribution is a symmetric bell-shaped distribution on the real line. The probability density function is given by
For more info see Gaussian Distribution.
GaussianDistribution
- class pysp.stats.gaussian.GaussianDistribution(mu, sigma2, name=None, keys=None)
Gaussian distribution with mean mu and variance sigma2.
- mu
Mean of the Gaussian distribution.
- Type:
float
- sigma2
Variance of the Gaussian distribution.
- Type:
float
- name
Name of the object.
- Type:
Optional[str]
- const
Normalizing constant of the Gaussian (depends on sigma2).
- Type:
float
- log_const
Log of the normalizing constant.
- Type:
float
- keys
Key for the distribution.
- Type:
Optional[str]
- __init__(mu, sigma2, name=None, keys=None)
Initialize GaussianDistribution.
- Parameters:
mu (float) – Mean of the Gaussian distribution.
sigma2 (float) – Variance of the Gaussian distribution (must be positive).
name (Optional[str], optional) – Name for the object.
keys (Optional[str], optional) – Key for the distribution.
- density(x)
Evaluate the density of the Gaussian distribution at x.
- Parameters:
x (float) – Observation.
- Returns:
Density at x.
- Return type:
float
- dist_to_encoder()
Return a GaussianDataEncoder for this distribution.
- Returns:
Encoder object.
- Return type:
GaussianDataEncoder
- estimator(pseudo_count=None)
Return a GaussianEstimator for this distribution.
- Parameters:
pseudo_count (Optional[float], optional) – Pseudo-count for regularization.
- Returns:
Estimator object.
- Return type:
- log_density(x)
Evaluate the log-density of the Gaussian distribution at x.
- Parameters:
x (float) – Observation.
- Returns:
Log-density at x.
- Return type:
float
- sampler(seed=None)
Return a GaussianSampler for this distribution.
- Parameters:
seed (Optional[int], optional) – Seed for random number generator.
- Returns:
Sampler object.
- Return type:
- seq_ld_lambda()
Return a list containing the seq_log_density method.
- Return type:
List[Callable]
- seq_log_density(x)
Vectorized log-density for encoded data.
- Parameters:
x (GaussianEncodedDataSequence) – Encoded data sequence.
- Returns:
Log-density values.
- Return type:
np.ndarray
GaussianEstimator
- class pysp.stats.gaussian.GaussianEstimator(pseudo_count=(None, None), suff_stat=(None, None), name=None, keys=None)
Estimator for the Gaussian distribution from aggregated sufficient statistics.
- pseudo_count
Weights for sufficient statistics.
- Type:
Tuple[Optional[float], Optional[float]]
- suff_stat
Tuple of mean (mu) and variance (sigma2).
- Type:
Tuple[Optional[float], Optional[float]]
- name
Name of the estimator.
- Type:
Optional[str]
- keys
Key for mean and variance.
- Type:
Optional[str]
- __init__(pseudo_count=(None, None), suff_stat=(None, None), name=None, keys=None)
Initialize GaussianEstimator.
- Parameters:
pseudo_count (Tuple[Optional[float], Optional[float]]) – Tuple of two positive floats.
suff_stat (Tuple[Optional[float], Optional[float]]) – Tuple of mean and variance.
name (Optional[str], optional) – Name for the estimator.
keys (Optional[str], optional) – Key for mean and variance.
- Raises:
TypeError – If keys is not a string or None.
- accumulator_factory()
Return a GaussianAccumulatorFactory for this estimator.
- Returns:
Factory object.
- Return type:
GaussianAccumulatorFactory
- estimate(nobs, suff_stat)
Estimate a GaussianDistribution from sufficient statistics.
- Parameters:
nobs (Optional[float]) – Number of observations (not used).
suff_stat (Tuple[float, float, float, float]) – (sum, sum2, count, count2) sufficient statistics.
- Returns:
Estimated distribution.
- Return type:
GaussianSampler
- class pysp.stats.gaussian.GaussianSampler(dist, seed=None)
Sampler for drawing samples from a GaussianDistribution instance.
- dist
GaussianDistribution instance to sample from.
- Type:
- rng
Random number generator.
- Type:
RandomState
- sample(size=None)
Draw iid samples from the Gaussian distribution.
- Parameters:
size (Optional[int], optional) – Number of samples to draw. If None, returns a single sample.
- Returns:
Single sample or array of samples.
- Return type:
Union[float, np.ndarray]