NormalDist#

class pygam.distributions.NormalDist(scale=None)[source]#

Bases: Distribution

Normal Distribution

Parameters:
scalefloat or None, default: None

scale/standard deviation of the distribution

Methods

V(mu)

Glm Variance function.

deviance(y, mu[, scaled])

Model deviance.

get_params([deep])

Returns a dict of all of the object's user-facing parameters.

log_pdf(y, mu[, weights])

Computes the log of the pdf or pmf of the values under the current distribution.

phi(y, mu, edof, weights)

Related to GLM scale parameter.

sample(mu)

Return random samples from this Normal distribution.

set_params([deep, force])

Sets an object's parameters.

V(mu)[source]#

Glm Variance function.

if

Y ~ ExpFam(theta, scale=phi)

such that

E[Y] = mu = b’(theta)

and

Var[Y] = b’’(theta) * phi / w

then we seek V(mu) such that we can represent Var[y] as a fn of mu:

Var[Y] = V(mu) * phi

ie

V(mu) = b’’(theta) / w

Parameters:
muarray-like of length n

expected values

Returns:
V(mu)np.array of length n
deviance(y, mu, scaled=True)[source]#

Model deviance.

for a gaussian linear model, this is equal to the SSE

Parameters:
yarray-like of length n

target values

muarray-like of length n

expected values

scaledboolean, default: True

whether to divide the deviance by the distribution scale

Returns:
deviancesnp.array of length n
get_params(deep=False)[source]#

Returns a dict of all of the object’s user-facing parameters.

Parameters:
deepboolean, default: False

when True, also gets non-user-facing parameters

Returns:
dict
log_pdf(y, mu, weights=None)[source]#

Computes the log of the pdf or pmf of the values under the current distribution.

Parameters:
yarray-like of length n

target values

muarray-like of length n

expected values

weightsarray-like shape (n,) or None, default: None

sample weights if None, defaults to array of ones

Returns:
pdf/pmfnp.array of length n
phi(y, mu, edof, weights)[source]#

Related to GLM scale parameter. for Binomial and Poisson families this is unity for Normal family this is variance.

Parameters:
yarray-like of length n

target values

muarray-like of length n

expected values

edoffloat

estimated degrees of freedom

weightsarray-like shape (n,) or None, default: None

sample weights if None, defaults to array of ones

Returns:
scaleestimated model scale
sample(mu)[source]#

Return random samples from this Normal distribution.

Samples are drawn independently from univariate normal distributions with means given by the values in mu and with standard deviations equal to the scale attribute if it exists otherwise 1.0.

Parameters:
muarray-like of shape n_samples or shape (n_simulations, n_samples)

expected values

Returns:
random_samplesnp.array of same shape as mu
set_params(deep=False, force=False, **parameters)[source]#

Sets an object’s parameters.

Parameters:
deepboolean, default: False

when True, also sets non-user-facing parameters

forceboolean, default: False

when True, also sets parameters that the object does not already have

**parametersparameters to set
Returns:
self