Learn R Programming

dpcR (version 0.1.2-1)

moments-methods: Calculate Moments of Poisson Distribution

Description

The function allows user to quickly calculate moments of a Poisson distributions. The calculations are based on values of positive and total partitions or the theoretical lambda value.

Usage

## S3 method for class 'adpcr':
moments(input)
## S3 method for class 'ddpcr':
moments(input)
## S3 method for class 'numeric':
moments(input)

Arguments

input
a single numeric object (lambda) or a two element vector (first element is treated as the number of positive partitions and the second as the number of total partitions) or an object of class adpcr or

Value

  • A named vector of four elements (mean, variance, skewness and kurtosis).

    In case of adpcr or ddpcr object containing total number of positive molecules, a n-by-4 matrix, where n is the number of experiments.

    In case of adpcr or ddpcr containing number of molecules per partition, a n*2-by-4 matrix, where n is the number of experiments. In this case empirical moments are calculated directly from a distribution of the data. Theoretical moments from a Poisson distribution with $\lambda$ parameter taken from the data.

Examples

Run this code
# moments for lambda = 2
moments(2)

# moments for 100 positive partitions of 765 total partitions
moments(c(100, 765))

# calculate moments for an array digital PCR, total number of positive partitions 
ddpcr1 <- sim_ddpcr(m = 10, n = 40, times = 50, pos_sums = TRUE, n_exp = 5)
moments(ddpcr1)

# calculate moments for an array digital PCR, detailed number of molecules in each partition 
ddpcr2 <- sim_ddpcr(m = 10, n = 40, times = 50, pos_sums = FALSE, n_exp = 5)
moments(ddpcr2)

Run the code above in your browser using DataLab