Exponential
Data Type: float
The exponential distribution is can be used to model arrival times between events. The distribution has support on the positive real line. The probability density function is given by
The above is the scale parametarization of the exponential distribution. For more info see Exponential Distribution.
ExponentialDistribution
- class pysp.stats.exponential.ExponentialDistribution(beta, name=None, keys=None)
Exponential distribution with scale parameter beta.
- beta
Positive real number defining the scale of the exponential distribution.
- Type:
float
- log_beta
Logarithm of the beta parameter.
- Type:
float
- name
Name for the ExponentialDistribution object.
- Type:
Optional[str]
- keys
Key for parameters.
- Type:
Optional[str]
- __init__(beta, name=None, keys=None)
Initialize ExponentialDistribution.
- Parameters:
beta (float) – Positive real number defining the scale of the exponential distribution.
name (Optional[str], optional) – Name for the ExponentialDistribution object.
keys (Optional[str], optional) – Key for parameters.
- density(x)
Evaluate the density of the exponential distribution at x.
- Parameters:
x (float) – Positive real-valued number.
- Returns:
Density evaluated at x.
- Return type:
float
- dist_to_encoder()
Return an ExponentialDataEncoder for this distribution.
- Returns:
Encoder object.
- Return type:
ExponentialDataEncoder
- estimator(pseudo_count=None)
Return an ExponentialEstimator 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 exponential distribution at x.
- Parameters:
x (float) – Positive real-valued number.
- Returns:
Log-density evaluated at x.
- Return type:
float
- sampler(seed=None)
Return an ExponentialSampler for this distribution.
- Parameters:
seed (Optional[int], optional) – Seed for random number generator.
- Returns:
Sampler object.
- Return type:
- seq_log_density(x)
Vectorized log-density for encoded data.
- Parameters:
x (ExponentialEncodedDataSequence) – Encoded data sequence.
- Returns:
Log-density values.
- Return type:
np.ndarray
ExponentialEstimator
- class pysp.stats.exponential.ExponentialEstimator(pseudo_count=None, suff_stat=None, name=None, keys=None)
Estimator for the exponential distribution from aggregated sufficient statistics.
- pseudo_count
Used to weight sufficient statistics.
- Type:
Optional[float]
- suff_stat
Positive float value for scale of exponential distribution.
- Type:
Optional[float]
- name
Name for the estimator.
- Type:
Optional[str]
- keys
Key for combining sufficient statistics.
- Type:
Optional[str]
- __init__(pseudo_count=None, suff_stat=None, name=None, keys=None)
Initialize ExponentialEstimator.
- Parameters:
pseudo_count (Optional[float], optional) – Used to weight sufficient statistics.
suff_stat (Optional[float], optional) – Positive float value for scale of exponential distribution.
name (Optional[str], optional) – Name for the estimator.
keys (Optional[str], optional) – Key for combining sufficient statistics.
- Raises:
TypeError – If keys is not a string or None.
- accumulator_factory()
Return an ExponentialAccumulatorFactory for this estimator.
- Returns:
Factory object.
- Return type:
ExponentialAccumulatorFactory
- estimate(nobs, suff_stat)
Estimate an ExponentialDistribution from sufficient statistics.
- Parameters:
nobs (Optional[float]) – Number of observations (not used).
suff_stat (Tuple[float, float]) – (count, sum) sufficient statistics.
- Returns:
Estimated distribution.
- Return type:
ExponentialSampler
- class pysp.stats.exponential.ExponentialSampler(dist, seed=None)
Sampler for the exponential distribution.
- dist
ExponentialDistribution instance to sample from.
- Type:
- rng
Random number generator.
- Type:
RandomState
- sample(size=None)
Draw iid samples from the exponential 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]