density module
This module contains torch implementations of the density functions which can be used in combination with torch based models wanting to make use of the distributions in this package. Unlike the pdqr module which is based on numpy, this module can take care of the gradients for you.
Note that the Generalized Hyperbolic and Generalized Hyperbolic Skew Student’s Distributions will not work with autograd, since the modified bessel function of the second kind is not yet implemented in torch.
An example is available in the the tspydistributions gallery.
Density Functions
- density.dnorm(parameters: Float[Tensor, '...'], x: Float[Tensor, '...'], log: bool = False) Float[Tensor, '...'][source]
(Normal) Probability Density Function (dnorm)
This is a torch implementation of the probability density function of the Normal distribution useful for inclusion with PyTorch models.
- Parameters:
parameters – a tensor of parameters [mu, sigma].
x – a tensor of quantiles
log – whether to return the log density
- Return type:
a torch tensor
- density.dged(parameters: Float[Tensor, '...'], x: Float[Tensor, '...'], log: bool = False) Float[Tensor, '...'][source]
(GED) Probability Density Function (dged)
This is a torch implementation of the probability density function of the Generalized Error Distribution useful for inclusion with PyTorch models.
- Parameters:
parameters – a tensor of parameters [mu, sigma, shape].
x – a tensor of quantiles
log – whether to return the log density
- Return type:
a torch tensor
- density.dstd(parameters: Float[Tensor, '...'], x: Float[Tensor, '...'], log: bool = False) Float[Tensor, '...'][source]
(Student’s t) Probability Density Function (dstd)
This is a torch implementation of the probability density function of the Student’s t distribution useful for inclusion with PyTorch models.
- Parameters:
parameters – a tensor of parameters [mu, sigma, shape].
x – a tensor of quantiles
log – whether to return the log density
- Return type:
a torch tensor
- density.dsnorm(parameters: Float[Tensor, '...'], x: Float[Tensor, '...'], log: bool = False) Float[Tensor, '...'][source]
(Skew-Normal) Probability Density Function (dsnorm)
This is a torch implementation of the probability density function of the Skew-Normal distribution useful for inclusion with PyTorch models.
- Parameters:
parameters – a tensor of parameters [mu, sigma, skew].
x – a tensor of quantiles
log – whether to return the log density
- Return type:
a torch tensor
- density.dsged(parameters: Float[Tensor, '...'], x: Float[Tensor, '...'], log: bool = False) Float[Tensor, '...'][source]
- density.dsstd(parameters: Float[Tensor, '...'], x: Float[Tensor, '...'], log: bool = False) Float[Tensor, '...'][source]
(Skew-Student’s t) Probability Density Function (dsstd)
This is a torch implementation of the probability density function of the Skew-Student’s t distribution useful for inclusion with PyTorch models.
- Parameters:
parameters – a tensor of parameters [mu, sigma, skew, shape].
x – a tensor of quantiles
log – whether to return the log density
- Return type:
a torch tensor
- density.djsu(parameters: Float[Tensor, '...'], x: Float[Tensor, '...'], log: bool = False) Float[Tensor, '...'][source]
(Johnson’s SU) Probability Density Function (djsu)
This is a torch implementation of the probability density function of the Johnson’s SU distribution useful for inclusion with PyTorch models.
- Parameters:
parameters – a tensor of parameters [mu, sigma, skew, shape].
x – a tensor of quantiles
log – whether to return the log density
- Return type:
a torch tensor
- density.dsgh(parameters: Float[Tensor, '...'], x: Float[Tensor, '...'], log: bool = False) Float[Tensor, '...'][source]
(Standardized Generalized Hyperbolic) Probability Density Function (dsgh)
This is a torch implementation of the probability density function of the Standardized Generalized Hyperbolic distribution useful for inclusion with PyTorch models. Currently due to the absence of a torch implementation of the modified Bessel function of the second kind, the pdqr function should be used instead.
- Parameters:
parameters – a tensor of parameters [mu, sigma, skew, shape, lamda].
x – a tensor of quantiles
log – whether to return the log density
- Return type:
a torch tensor
- density.dsghst(parameters: Float[Tensor, '...'], x: Float[Tensor, '...'], log: bool = False) Float[Tensor, '...'][source]
(Standardized Generalized Hyperbolic Skew Student) Probability Density Function (dsghst)
This is a torch implementation of the probability density function of the Standardized Generalized Hyperbolic Skew Student distribution useful for inclusion with PyTorch models. Currently due to the absence of a torch implementation of the modified Bessel function of the second kind, the pdqr function should be used instead.
- Parameters:
parameters – a tensor of parameters [mu, sigma, skew, shape].
x – a tensor of quantiles
log – whether to return the log density
- Return type:
a torch tensor