dfmx: Density, Distribution and Quantile of Finite Mixture...

View source: R/dpqr.R

dfmxR Documentation

Density, Distribution and Quantile of Finite Mixture Distribution

Description

Density function, distribution function, quantile function and random generation for a finite mixture distribution with normal or Tukey g-&-h components.

Usage

dfmx(
  x,
  dist,
  distname = dist@distname,
  K = dim(pars)[1L],
  pars = dist@pars,
  w = dist@w,
  ...,
  log = FALSE
)

pfmx(
  q,
  dist,
  distname = dist@distname,
  K = dim(pars)[1L],
  pars = dist@pars,
  w = dist@w,
  ...,
  lower.tail = TRUE,
  log.p = FALSE
)

qfmx(
  p,
  dist,
  distname = dist@distname,
  K = dim(pars)[1L],
  pars = dist@pars,
  w = dist@w,
  interval = qfmx_interval(dist = dist),
  ...,
  lower.tail = TRUE,
  log.p = FALSE
)

rfmx(
  n,
  dist,
  distname = dist@distname,
  K = dim(pars)[1L],
  pars = dist@pars,
  w = dist@w
)

Arguments

x, q

numeric vector, quantiles, 'NA_real_' value(s) allowed.

dist

fmx object, a finite mixture distribution

distname, K, pars, w

auxiliary parameters, whose default values are determined by argument 'dist'. The user-specified vector of 'w' does not need to sum up to 1; 'w/sum(w)' will be used internally.

...

additional parameters

log, log.p

logical scalar. If 'TRUE', probabilities are given as \log(p).

lower.tail

logical scalar. If 'TRUE' (default), probabilities are Pr(X\le x), otherwise, Pr(X>x).

p

numeric vector, probabilities.

interval

length-2 numeric vector, interval for root finding, see vuniroot

n

integer scalar, number of observations.

Details

A computational challenge in function [dfmx()] is when mixture density is very close to 0, which happens when the per-component log densities are negative with big absolute values. In such case, we cannot compute the log densities (i.e., '-Inf').

The function [qfmx()] gives the quantile function, by numerically solving [pfmx]. One major challenge when dealing with the finite mixture of Tukey g-&-h family distribution is that Brent–Dekker's method needs to be performed in both pGH and [qfmx] functions, i.e. *two layers* of root-finding algorithm.

Value

The function [dfmx()] returns a numeric vector of probability density values of an fmx object at specified quantiles 'x'.

The function [pfmx()] returns a numeric vector of cumulative probability values of an fmx object at specified quantiles 'q'.

The function [qfmx()] returns an unnamed numeric vector of quantiles of an fmx object, based on specified cumulative probabilities 'p'.

The function [rfmx()] generates random deviates of an fmx object.

Note

The function qnorm returns an unnamed vector of quantiles, although quantile returns a named vector of quantiles.


fmx documentation built on July 17, 2026, 1:07 a.m.