Package 'gaussratiovegind'

Title: Distribution of Gaussian Ratios
Description: It is well known that the distribution of a Gaussian ratio does not follow a Gaussian distribution. The lack of awareness among users of vegetation indices about this non-Gaussian nature could lead to incorrect statistical modeling and interpretation. This package provides tools to accurately handle and analyse such ratios: density function, parameter estimation, simulation. An example on the study of chlorophyll fluorescence can be found in A. El Ghaziri et al. (2023) <doi:10.3390/rs15020528>.
Authors: Pierre Santagostini [aut, cre], Angélina El Ghaziri [aut], Nizar Bouhlel [aut], David Rousseau [ctb]
Maintainer: Pierre Santagostini <[email protected]>
License: GPL (>= 3)
Version: 1.0.1
Built: 2025-02-11 19:22:21 UTC
Source: CRAN

Help Index


Ratio of two Gaussian distributions

Description

Density of the ratio of two Gaussian distributions.

Usage

dnormratio(z, bet, rho, delta)

Arguments

z

length pp numeric vector.

bet, rho, delta

numeric values. The parameters (β,ρ,δ)(\beta, \rho, \delta) of the distribution, see Details.

Details

Let two independant random variables XN(μx,σx)X \sim N(\mu_x, \sigma_x) and YN(μy,σy)Y \sim N(\mu_y, \sigma_y).

If we denote β=μxμy\beta = \frac{\mu_x}{\mu_y}, ρ=σyσx\rho = \frac{\sigma_y}{\sigma_x} and δy=σyμy\delta_y = \frac{\sigma_y}{\mu_y}, the probability distribution function of the ratio Z=XYZ = \frac{X}{Y} is given by:

fZ(z;β,ρ,δy)=ρπ(1+ρ2z2)[exp(ρ2β2+12δy2)+π2 q erf(q2)exp(ρ2(zβ)22δy2(1+ρ2z2))]\displaystyle{ f_Z(z; \beta, \rho, \delta_y) = \frac{\rho}{\pi (1 + \rho^2 z^2)} \left[ \exp{\left(-\frac{\rho^2 \beta^2 + 1}{2\delta_y^2}\right)} + \sqrt{\frac{\pi}{2}} \ q \ \text{erf}\left(\frac{q}{\sqrt{2}}\right) \exp\left(-\frac{\rho^2 (z-\beta)^2}{2 \delta_y^2 (1 + \rho^2 z^2)}\right) \right] }

with q=1+βρ2zδy1+ρ2z2\displaystyle{ q = \frac{1 + \beta \rho^2 z}{\delta_y \sqrt{1 + \rho^2 z^2}} } and erf(q2)=2π0q2exp(t2) dt\displaystyle{ \text{erf}\left(\frac{q}{\sqrt{2}}\right) = \frac{2}{\sqrt{\pi}} \int_0^{\frac{q}{\sqrt{2}}}{\exp{(-t^2)}\ dt} }

Value

Numeric: the value of density.

Author(s)

Pierre Santagostini, Angélina El Ghaziri, Nizar Bouhlel

References

El Ghaziri, A., Bouhlel, N., Sapoukhina, N., Rousseau, D., On the importance of non-Gaussianity in chlorophyll fluorescence imaging. Remote Sensing 15(2), 528 (2023). doi:10.3390/rs15020528

Díaz-Francés, E., Rubio, F.J., On the existence of a normal approximation to the distribution of the ratio of two independent normal random variables. Stat Papers 54, 309–323 (2013). doi:10.1007/s00362-012-0429-2

See Also

rnormratio(): sample simulation.

estparnormratio(): parameter estimation.

Examples

# First example
beta1 <- 0.15
rho1 <- 5.75
delta1 <- 0.22
dnormratio(0, bet = beta1, rho = rho1, delta = delta1)
dnormratio(0.5, bet = beta1, rho = rho1, delta = delta1)
curve(dnormratio(x, bet = beta1, rho = rho1, delta = delta1), from = -0.1, to = 0.7)

# Second example
beta2 <- 2
rho2 <- 2
delta2 <- 2
dnormratio(0, bet = beta2, rho = rho2, delta = delta2)
dnormratio(0.5, bet = beta2, rho = rho2, delta = delta2)
curve(dnormratio(x, bet = beta2, rho = rho2, delta = delta2), from = -0.1, to = 0.7)

Estimation of the Parameters of a Normal Ratio Distribution

Description

Estimation of the parameters of a ratio Z=XY\displaystyle{Z = \frac{X}{Y}}, XX and YY being two independant random variables distributed according to Gaussian distributions, using the EM (estimation-maximization) algorithm.

Usage

estparnormratio(z, eps = 1e-6)

Arguments

z

numeric matrix or data frame.

eps

numeric. Precision for the estimation of the parameters.

Details

Let a random variable: Z=XY\displaystyle{Z = \frac{X}{Y}},

XX and YY being normally distributed: XN(μx,σx)X \sim N(\mu_x, \sigma_x) and YN(μy,σy)Y \sim N(\mu_y, \sigma_y).

The density probability of ZZ is:

fZ(z;β,ρ,δy)=ρπ(1+ρ2z2) exp(ρ2β2+12δy2) 1F1(1,12;12δy2(1+βρ2z)21+ρ2z2)\displaystyle{ f_Z(z; \beta, \rho, \delta_y) = \frac{\rho}{\pi (1 + \rho^2 z^2)} \ \exp{\left(-\frac{\rho^2 \beta^2 + 1}{2\delta_y^2}\right)} \ {}_1 F_1\left( 1, \frac{1}{2}; \frac{1}{2 \delta_y^2} \frac{(1 + \beta \rho^2 z)^2}{1 + \rho^2 z^2} \right) }

with: β=μxμy\displaystyle{\beta = \frac{\mu_x}{\mu}_y}, ρ=σyσx\displaystyle{\rho = \frac{\sigma_y}{\sigma_x}}, δy=σyμy\displaystyle{\delta_y = \frac{\sigma_y}{\mu_y}}.

and 1F1(a,b;x)_1 F_1\left(a, b; x\right) is the confluent hypergeometric function (Kummer's function):

1F1(a,b;x)=n=0+(a)n(b)nxnn!\displaystyle{ _1 F_1\left(a, b; x\right) = \sum_{n = 0}^{+\infty}{ \frac{ (a)_n }{ (b)_n } \frac{x^n}{n!} } }

The parameters β\beta, ρ\rho, δy\delta_y of the ZZ distribution are estimated with the EM algorithm, as presented in El Ghaziri et al. The computation uses the kummerM function.

This uses an iterative algorithm.

The precision for the estimation of the parameters is given by the eps parameter.

Value

A list of 3 elements beta, rho, delta: the estimated parameters of the ZZ distribution β^\hat{\beta}, ρ^\hat{\rho}, δ^y\hat{\delta}_y, with two attributes attr(, "epsilon") (precision of the result) and attr(, "k") (number of iterations).

Author(s)

Pierre Santagostini, Angélina El Ghaziri, Nizar Bouhlel

References

El Ghaziri, A., Bouhlel, N., Sapoukhina, N., Rousseau, D., On the importance of non-Gaussianity in chlorophyll fluorescence imaging. Remote Sensing 15(2), 528 (2023). doi:10.3390/rs15020528

See Also

dnormratio(): probability density of a normal ratio.

rnormratio(): sample simulation.

Examples

# First example
beta1 <- 0.15
rho1 <- 5.75
delta1 <- 0.22

set.seed(1234)
z1 <- rnormratio(800, bet = beta1, rho = rho1, delta = delta1)

estparnormratio(z1)

# Second example
beta2 <- 0.24
rho2 <- 4.21
delta2 <- 0.25

set.seed(1234)
z2 <- rnormratio(800, bet = beta2, rho = rho2, delta = delta2)

estparnormratio(z2)

Confluent DD-Hypergeometric Function

Description

Computes the Kummer's function, or confluent hypergeometric function.

Usage

kummerM(a, b, z, eps = 1e-06)

Arguments

a

numeric.

b

numeric

z

numeric vector.

eps

numeric. Precision for the sum (default 1e-06).

Details

The Kummer's confluent hypergeometric function is given by:

1F1(a,b;z)=n=0+(a)n(b)nznn!\displaystyle{_1 F_1\left(a, b; z\right) = \sum_{n = 0}^{+\infty}{ \frac{ (a)_n }{ (b)_n } \frac{z^n}{n!} }}

where (z)p(z)_p is the Pochhammer symbol (see pochhammer).

The eps argument gives the required precision for its computation. It is the attr(, "epsilon") attribute of the returned value.

Value

A numeric value: the value of the Kummer's function, with two attributes attr(, "epsilon") (precision of the result) and attr(, "k") (number of iterations).

Author(s)

Pierre Santagostini, Angélina El Ghaziri, Nizar Bouhlel

References

El Ghaziri, A., Bouhlel, N., Sapoukhina, N., Rousseau, D., On the importance of non-Gaussianity in chlorophyll fluorescence imaging. Remote Sensing 15(2), 528 (2023). doi:10.3390/rs15020528


Logarithm of the Pochhammer Symbol

Description

Computes the logarithm of the Pochhammer symbol.

Usage

lnpochhammer(x, n)

Arguments

x

numeric.

n

positive integer.

Details

The Pochhammer symbol is given by:

(x)n=Γ(x+n)Γ(x)=x(x+1)...(x+n1)\displaystyle{ (x)_n = \frac{\Gamma(x+n)}{\Gamma(x)} = x (x+1) ... (x+n-1) }

So, if n>0n > 0:

log((x)n)=log(x)+log(x+1)+...+log(x+n1)\displaystyle{ log\left((x)_n\right) = log(x) + log(x+1) + ... + log(x+n-1) }

If n=0n = 0, log((x)n)=log(1)=0\displaystyle{ log\left((x)_n\right) = log(1) = 0}

Value

Numeric value. The logarithm of the Pochhammer symbol.

Author(s)

Pierre Santagostini, Nizar Bouhlel

See Also

pochhammer, kummerM

Examples

lnpochhammer(2, 0)
lnpochhammer(2, 1)
lnpochhammer(2, 3)

Pochhammer Symbol

Description

Computes the Pochhammer symbol.

Usage

pochhammer(x, n)

Arguments

x

numeric.

n

positive integer.

Details

The Pochhammer symbol is given by:

(x)n=Γ(x+n)Γ(x)=x(x+1)...(x+n1)\displaystyle{ (x)_n = \frac{\Gamma(x+n)}{\Gamma(x)} = x (x+1) ... (x+n-1) }

Value

Numeric value. The value of the Pochhammer symbol.

Author(s)

Pierre Santagostini, Nizar Bouhlel

See Also

lnpochhammer, kummerM

Examples

pochhammer(2, 0)
pochhammer(2, 1)
pochhammer(2, 3)

Ratio of two Gaussian distributions

Description

Simulate data from a ratio of two Gaussian distributions.

Usage

rnormratio(n, bet, rho, delta)

Arguments

n

integer. Number of observations. If length(n) > 1, the length is taken to be the nmber required.

bet, rho, delta

numeric values. The parameters (β,ρ,δ)(\beta, \rho, \delta) of the distribution, see Details.

Details

Let two random variables XN(μx,σx)X \sim N(\mu_x, \sigma_x) and YN(μy,σy)Y \sim N(\mu_y, \sigma_y)

with probability densities fXf_X and fYf_Y.

The parameters of the distribution of the ratio Z=XYZ = \frac{X}{Y} are: β=μxμy\displaystyle{\beta = \frac{\mu_x}{\mu_y}}, ρ=σyσx\displaystyle{\rho = \frac{\sigma_y}{\sigma_x}}, δy=σyμy\displaystyle{\delta_y = \frac{\sigma_y}{\mu_y}}.

μx\mu_x, σx\sigma_x, μy\mu_y and σy\sigma_y are computed from β\beta, ρ\rho and δy\delta_y (by fixing arbitrarily μx=1\mu_x = 1) and two random samples (x1,,xn)\left( x_1, \dots, x_n \right) and (y1,,yn)\left( y_1, \dots, y_n \right) are simulated.

Then (x1y1,,xnyn)\displaystyle{\left( \frac{x_1}{y_1}, \dots, \frac{x_n}{y_n} \right)} is returned.

Value

A numeric vector: the produced sample.

Author(s)

Pierre Santagostini, Angélina El Ghaziri, Nizar Bouhlel

References

El Ghaziri, A., Bouhlel, N., Sapoukhina, N., Rousseau, D., On the importance of non-Gaussianity in chlorophyll fluorescence imaging. Remote Sensing 15(2), 528 (2023). doi:10.3390/rs15020528

See Also

dnormratio(): probability density of a normal ratio.

estparnormratio(): parameter estimation.

Examples

# First example
beta1 <- 0.15
rho1 <- 5.75
delta1 <- 0.22
rnormratio(20, bet = beta1, rho = rho1, delta = delta1)

# Second example
beta2 <- 0.24
rho2 <- 4.21
delta2 <- 0.25
rnormratio(20, bet = beta2, rho = rho2, delta = delta2)