cf2PMF_FFT: Evaluates the PMF and CDF of a discrete random variable with...

View source: R/cf2PMF_FFT.R

cf2PMF_FFTR Documentation

Evaluates the PMF and CDF of a discrete random variable with lattice distribution

Description

The cf2PMF_FFT(cf, xMin, xMAX, xDelta, options) evaluates the distribution functions (PMF and CDF) of a DISCRETE random variable (DRV) with lattice distribution defined on the Support = seq(xMin,xMax,xDelta), and fully specified by its characteristic function (CF). PMF and CDF is evaluated at the specified support points x = seq(xMin,xMax,xDelta) by numerical inversion of CF, based on using the inverse FFT algorithm.. Algorithm considers only finite discrete support, so it should be specified carefully and correctly (i.e., it should include a probability mass equal to 1 - epsilon, where epsilon is an accepted truncation error). See Warr (2014) for more information on the method used.

Usage

cf2PMF_FFT(cf, xMin, xMax, xDelta, options)

Arguments

cf

function handle of the characteristic function of the discrete lattice distribution, defined on a subset of integers.

xMin

minimum value of the support of the (lattice) discrete RV X.

xMax

maximum value (finite number) of the support of the (lattice) DRV X.

xDelta

xDelta > 0 is the minimum difference of the support values of the discrete RV X with lattice distribution given as Supp = seq(xMin,xMax,xDelta). If empty, the default value is xDelta = 1.

options

structure with the following default parameters:

  • options$xMin = 0, minimum value of the support of X,

  • options$xMax = 100, maximum value of the support of X,

  • options$xDelta = 1, minimum difference of the support values of X,

  • options$isPlot = true, logical indicator for plotting PMF and CDF.

Value

  • result structure with all details,

  • pmf vector of the PMF values evaluated at x=seq(xMin, xMax),

  • cdf vector of the PMF values evaluated at x=seq(xMin, xMax).

References

[1] Warr, Richard L. Numerical approximation of probability mass functions via the inverse discrete Fourier transform. Methodology and Computing in Applied Probability 16, no. 4 2014: 1025-1038.

See Also

For more details see: https://arxiv.org/pdf/1701.08299.pdf

Other CF Inversion Algorithm: cf2DistFFT(), cf2DistGP()

Examples

## EXAMPLE 1
# PMF/CDF of the binomial RVV specified bz its CF
 n<-10
 p<-0.25
 cf<-function(t) cfN_Binomial(t,n,p)
  xMin<- 0
  xMax<-n
  xDelta<-1
  options$isPlot<-TRUE
  result<-cf2PMF_FFT(cf,xMin,xMax,xDelta,options)
  
  ## EXAMPLE 2   
  # PMF/CDF of the convolved discrete RV specified by its CF
  n<-10
  p<-0.25
  cf_Bino<-function(t) cfN_Binomial(t,n,p)
  N<-5
  cf<-function(t) cf_Bino(t)^N
  xMin<-0
  xMax<-N*n
  xDelta<-1
  options$isPlot=TRUE
  result<-cf2PMF_FFT(cf,xMin,xMax,xDelta,options)
  
  ## EXAMPLE 3
  # PMF/CDF of the mean of IID RV with Poisson distribution
  lambda<-5
  cf_Pois<-function(t) cfN_Poisson(t,lambda)
  N<-10
  cf<-function(t) cf_Pois(t/N)^N
  xMin<-0
  xMax<-10
  xDelta<-1/N
  options$isPlot=TRUE
  result<-cf2PMF_FFT(cf,xMin,xMax,xDelta,options)
  
  ## EXAMPLE 4
  # PMF/CDF of the convolved discrete RV specified by its CF
  # Here we consider convolutions of discrete RV defined on{0,1,2}
  # with probabilities p=[0.2,0.5,0.3]
  supp<-c(0,1,2)
  prob<-c(0.2,0.5,0.3)
  cf_X<-function(t) cfE_DiracMixture(t,supp,prob)
  N<-5
  cf<-function(t) cf_X(t)^N
  xMin<-0
  xMax<-max(supp)*N
  xDelta<-1
  options$isPlot<-TRUE
  result<-cf2PMF_FFT(cf,xMin,xMax,xDelta,options)
  
  ## EXAMPLE 5
  # PMF/CDF of the exact bootrap mean distribution specified by its CF
  data<-c(-2,0,0,0,0,0,0,0,1,4)
  N<-length(data)
  cf<- function(t) cfE_Empirical(t/N,data)^N
  xMin<-min(data)
  xMax<-max(data)
  xDelta<-1/N
  options$isPlot<-TRUE
  result<-cf2PMF_FFT(cf,xMin, xMax, xDelta, options)
  
  

gajdosandrej/CharFunToolR documentation built on June 3, 2024, 7:46 p.m.