Documentation ¶
Overview ¶
Package gopula implements common Archimedean Copulas. It aims both to infer a copula from observations and to sample data from a given model.
Index ¶
- Variables
- func BFGS(f ObjectiveFunction, args interface{}, x0 float64) (float64, float64, int, error)
- func Bisection(f ObjectiveFunction, args interface{}, x1, x2, tol float64) (float64, error)
- func BrentMinimizer(f ObjectiveFunction, args interface{}, a, b, t float64) (float64, float64, int, error)
- func BrentRootFinder(f ObjectiveFunction, args interface{}, x1, x2, tol float64) (float64, error)
- func Hist(values []float64, bins int, path string) error
- func LoadCSV(path string, sep rune, header bool) (*mat.Dense, error)
- func PrecomputeStirlingNumbers()
- func SaveCSV(M *mat.Dense, path string, sep rune) error
- func Secant(fun ObjectiveFunction, args interface{}, x1, x2, xacc float64) (float64, error)
- type AMH
- func (c *AMH) Cdf(vector []float64, theta float64) float64
- func (c *AMH) Family() string
- func (c *AMH) LogPdf(vector []float64, theta float64) float64
- func (c *AMH) Pdf(vector []float64, theta float64) float64
- func (c *AMH) Psi(t float64, theta float64) float64
- func (c *AMH) PsiD(dim int, t float64, theta float64) float64
- func (c *AMH) PsiInv(t float64, theta float64) float64
- func (c *AMH) ThetaBounds() (float64, float64)
- type ArchimedeanCopula
- func (arch *ArchimedeanCopula) Cdf(vector []float64) float64
- func (arch *ArchimedeanCopula) ConfidenceBounds(M *mat.Dense, level float64) (float64, float64)
- func (arch *ArchimedeanCopula) Family() string
- func (arch *ArchimedeanCopula) Fit(M *mat.Dense) *FitResult
- func (arch *ArchimedeanCopula) LogLikelihood(M *mat.Dense) float64
- func (arch *ArchimedeanCopula) LogPdf(vector []float64) float64
- func (arch *ArchimedeanCopula) Pdf(vector []float64) float64
- func (arch *ArchimedeanCopula) RadialCdf(x float64, dim int) float64
- func (arch *ArchimedeanCopula) RadialPpf(p float64, dim int) float64
- func (arch *ArchimedeanCopula) Sample(size int, dim int) *mat.Dense
- func (arch *ArchimedeanCopula) Theta() float64
- type ArchimedeanCopuler
- type Clayton
- func (c *Clayton) Cdf(vector []float64, theta float64) float64
- func (c *Clayton) Family() string
- func (c *Clayton) LogPdf(vector []float64, theta float64) float64
- func (c *Clayton) Pdf(vector []float64, theta float64) float64
- func (c *Clayton) Psi(t float64, theta float64) float64
- func (c *Clayton) PsiD(d int, t float64, theta float64) float64
- func (c *Clayton) PsiInv(t float64, theta float64) float64
- func (c *Clayton) ThetaBounds() (float64, float64)
- type FitResult
- type Frank
- func (c *Frank) Cdf(vector []float64, theta float64) float64
- func (c *Frank) Family() string
- func (c *Frank) LogPdf(vector []float64, theta float64) float64
- func (c *Frank) Pdf(vector []float64, theta float64) float64
- func (c *Frank) Psi(t float64, theta float64) float64
- func (c *Frank) PsiD(dim int, t float64, theta float64) float64
- func (c *Frank) PsiInv(t float64, theta float64) float64
- func (c *Frank) ThetaBounds() (float64, float64)
- type Gumbel
- func (c *Gumbel) Cdf(vector []float64, theta float64) float64
- func (c *Gumbel) Family() string
- func (c *Gumbel) LogPdf(vector []float64, theta float64) float64
- func (c *Gumbel) Pdf(vector []float64, theta float64) float64
- func (c *Gumbel) Psi(t float64, theta float64) float64
- func (c *Gumbel) PsiD(dim int, t float64, theta float64) float64
- func (c *Gumbel) PsiInv(t float64, theta float64) float64
- func (c *Gumbel) ThetaBounds() (float64, float64)
- type Joe
- func (c *Joe) Cdf(vector []float64, theta float64) float64
- func (c *Joe) Family() string
- func (c *Joe) LogPdf(vector []float64, theta float64) float64
- func (c *Joe) Pdf(vector []float64, theta float64) float64
- func (c *Joe) Psi(t float64, theta float64) float64
- func (c *Joe) PsiD(d int, t float64, theta float64) float64
- func (c *Joe) PsiInv(t float64, theta float64) float64
- func (c *Joe) ThetaBounds() (float64, float64)
- type ObjectiveFunction
Constants ¶
This section is empty.
Variables ¶
var ( // MaxDim is the maximum dimension for which // stirling number are pre-computed MaxDim = 12 // Inf is a 'big' value (for optimizing bound purpose) Inf = 15. )
var ( // Eps is the machine floating-point precision Eps = 3.e-8 // MaxFunEval is the maximum allowed number of iterations MaxFunEval = 500 )
Functions ¶
func BFGS ¶
BFGS uses the gonum implementation of the BFGS algorithm to find the minimum of a function without constraints
func Bisection ¶
func Bisection(f ObjectiveFunction, args interface{}, x1, x2, tol float64) (float64, error)
Bisection finds a root without derivatives
func BrentMinimizer ¶
func BrentMinimizer(f ObjectiveFunction, args interface{}, a, b, t float64) (float64, float64, int, error)
BrentMinimizer minimizes the function f according to the Brent's method
func BrentRootFinder ¶
func BrentRootFinder(f ObjectiveFunction, args interface{}, x1, x2, tol float64) (float64, error)
BrentRootFinder finds a root of the the function f: x->f(x, args) between x1 and x2 with the Van Wijngaarden–Dekker–Brent method. The implementation directly comes from the book 'Numerical Recipes in C' (p. 361, 362)
func PrecomputeStirlingNumbers ¶
func PrecomputeStirlingNumbers()
PrecomputeStirlingNumbers computes first and second kind stirling numbers until MaxDim
func Secant ¶
func Secant(fun ObjectiveFunction, args interface{}, x1, x2, xacc float64) (float64, error)
Secant finds the root of a function func thought to lie between x1 and x2. The root is refined until its accuracy is ±xacc. The implementation directly comes from the book 'Numerical Recipes in C' (p. 361, 362)
Types ¶
type AMH ¶
type AMH struct{}
AMH defines the AMH copula
func (*AMH) ThetaBounds ¶
ThetaBounds returns the range where the copula is well defined
type ArchimedeanCopula ¶
type ArchimedeanCopula struct {
// contains filtered or unexported fields
}
ArchimedeanCopula is a generic structure defining an archimedean copula
func NewCopula ¶
func NewCopula(family string, theta float64) *ArchimedeanCopula
NewCopula returns a new copula according to the desired family
func (*ArchimedeanCopula) Cdf ¶
func (arch *ArchimedeanCopula) Cdf(vector []float64) float64
Cdf computes the cumulative distribution function of the copula
func (*ArchimedeanCopula) ConfidenceBounds ¶
ConfidenceBounds compute the upper and lower confidence bounds at given level (level = 1-alpha = 0.95 in practice). The parameter theta must be the fitted value.
func (*ArchimedeanCopula) Family ¶
func (arch *ArchimedeanCopula) Family() string
Family returns the name of the copula family
func (*ArchimedeanCopula) Fit ¶
func (arch *ArchimedeanCopula) Fit(M *mat.Dense) *FitResult
Fit estimates the best theta parameter through maximum likelihood estimation according to the input observations
func (*ArchimedeanCopula) LogLikelihood ¶
func (arch *ArchimedeanCopula) LogLikelihood(M *mat.Dense) float64
LogLikelihood computes the log-likelihood of a batch of observations given the underlying archimedean copula
func (*ArchimedeanCopula) LogPdf ¶
func (arch *ArchimedeanCopula) LogPdf(vector []float64) float64
LogPdf computes the log density of the generated copula
func (*ArchimedeanCopula) Pdf ¶
func (arch *ArchimedeanCopula) Pdf(vector []float64) float64
Pdf computes the density of the generated copula
func (*ArchimedeanCopula) RadialCdf ¶
func (arch *ArchimedeanCopula) RadialCdf(x float64, dim int) float64
RadialCdf computes the cdf of the radial part of the ArchimeanCopula
func (*ArchimedeanCopula) RadialPpf ¶
func (arch *ArchimedeanCopula) RadialPpf(p float64, dim int) float64
RadialPpf computes the quantile zp verifying P(X<zp) = p
func (*ArchimedeanCopula) Sample ¶
func (arch *ArchimedeanCopula) Sample(size int, dim int) *mat.Dense
Sample generates random numbers according to the underlying copula
func (*ArchimedeanCopula) Theta ¶
func (arch *ArchimedeanCopula) Theta() float64
Theta returns the current value of 𝜃
type ArchimedeanCopuler ¶
type ArchimedeanCopuler interface { Family() string ThetaBounds() (float64, float64) Psi(t float64, theta float64) float64 PsiInv(t float64, theta float64) float64 PsiD(d int, t float64, theta float64) float64 Cdf(vector []float64, theta float64) float64 Pdf(vector []float64, theta float64) float64 LogPdf(vector []float64, theta float64) float64 }
ArchimedeanCopuler is an interface to implement an archimedean copula
type Clayton ¶
type Clayton struct{}
Clayton defines the clayton copula
func (*Clayton) ThetaBounds ¶
ThetaBounds returns the range where the copula is well defined
type FitResult ¶
type FitResult struct { // Theta is the estimated parameter Theta float64 // LogLikelihhod is the correspond log-likelihood (the maximum) LogLikelihood float64 // UpperBound is the 95% upper confidence bound UpperBound float64 // LowerBound is the 95% upper confidence bound LowerBound float64 // Evals is the number of function evaluations Evals int // Message describes whether the fit has suceeded Message string }
FitResult is a basic structure detailing the output of the fit
type Frank ¶
type Frank struct{}
Frank defines the Frank copula
func (*Frank) ThetaBounds ¶
ThetaBounds returns the range where the copula is well defined
type Gumbel ¶
type Gumbel struct{}
Gumbel defines the Gumbel copula
func (*Gumbel) ThetaBounds ¶
ThetaBounds returns the range where the copula is well defined
type Joe ¶
type Joe struct{}
Joe defines the Joe copula
func (*Joe) ThetaBounds ¶
ThetaBounds returns the range where the copula is well defined
type ObjectiveFunction ¶
ObjectiveFunction defines a function to minimize