neurotools.stats.distributions module

Functions for computing the log-PDF of common distributions.

Some of these yield a more digits of precision than their counterparts in scipy.stats by computing log-probability values using np.longdouble.

neurotools.stats.distributions.poisson_logpdf(k, l)[source]

Evaluate the log-pdf for a poisson distribution with rate l evaluated at points k.

Parameters:
  • k (np.int32) – Counts at whih to evaluate the log-pdf

  • l (positive float) – Poisson rate

Returns:

result – Log-probability of each k for a Poisson distribution with rate l.

Return type:

np.longdouble

neurotools.stats.distributions.poisson_pdf(k, l)[source]

Evaluate the pdf for a poisson distribution with rate l evaluated at points k.

Parameters:
  • k (np.int32) – Counts at whih to evaluate the log-pdf

  • l (positive float) – Poisson rate

Returns:

result – Probability of each k for a Poisson distribution with rate l.

Return type:

np.longdouble

neurotools.stats.distributions.gaussian_logpdf(mu, sigma, x)[source]

Evaluate the log-pdf of a (mu,sigma) normal distribution at points x.

Parameters:
  • mu (float) – Distribution mean

  • sigma (positive float) – Distribution standard deviation

  • x (np.float32) – Points at which to evaluate.

Returns:

result – log-PDF evaluated ast x.

Return type:

np.longdouble

neurotools.stats.distributions.gaussian_pdf(mu, sigma, x)[source]

Evaluate the pdf of a (mu,sigma) normal distribution at points x.

Parameters:
  • mu (float) – Distribution mean

  • sigma (positive float) – Distribution standard deviation

  • x (np.float32) – Points at which to evaluate.

Returns:

result – PDF evaluated ast x.

Return type:

np.longdouble

neurotools.stats.distributions.explogpdf(x, dx=1)[source]

Convert log-pdf to normalized pdf, integrating to get normalization constant

neurotools.stats.distributions.sample_categorical(pobabilities)[source]

Pick a state according to probabilities

Parameters:

probabilities (vector) – Vector of probabilities, must sum to 1.

Returns:

i – integer between 0 and len(probabilities)-1

Return type:

int