General Comments R Based Probability Distributions When a parameter name is ollowed by an equal sign, the value given is the deault. Consider a random variable that has the range, a x b. The parameter, lower.tail, when TRUE means that the cumulative distribution unction is to be interpreted as running rom a to some speciied value o x = x'. When the parameter is FALSE the cumulative distribution unction is to be interpreted as running rom x' to b. Probability density unctions all start with the letter d. Example, dbinom(). Cumulative distribution unctions all start with the letter p. Example, pnorm(). Inverse cumulative distribution unctions all start with the letter q (which is short or quantile). Example, qt(). Random number generators all start with the letter r. Example, runi(). Full examples o unction names are given under Binomial. Available Distributions Enter?Distributions to get a complete listing. Common distributions in chemical data processing are: binomial: binom(), occurs when an experiment has two outcomes, e.g. success or ailure. It deals with the distribution o successes out o a speciied number o trials. The random variable is discrete. An example is solvent extraction. Cauchy (Lorentzian): cauchy(), occurs when observing spectroscopic line shapes, or the Fourier transorm o a ree induction decay. exponential: exp(), results rom a irst order process. F statistic: (), occurs when comparing two experimental variances. normal (Gaussian): norm(), the bell shaped curve that represents the distribution o thermal noise. Poisson: pois(), the distribution o counting data. The random variable is discrete. t statistic: t(), occurs when comparing data normalized by the experimental standard deviation. uniorm: uni(), occurs when a random variable has a constant probability over its entire range, e.g. rolling a die. The random variable can be discrete or continuous.
Binomial This discrete density unction is given by, n! x x, n, p p p x! n x! where x is the number o successes, n is the number o trials (called size in R), and p is the probability o observing a success. The range o the random variable is 0 x n. In R the actorial term is given by the strangely named unction, choose(n,x). The mean is given by np and the variance by np( p). In the ollowing unction calls, the notation... signiies that there are less commonly used parameters. dbinom(x,size,probability,...), x is the number o successes, size is the number o trials, and probability is the probability o observing a success. As an example, dbinom(5,0,0.5) is the probability o observing 5 heads when tossing a coin 0 times. pbinom(q,size,probability), the probability o observing 0 to q successes out o size tries, where probability is the probability o observing a success. As an example, pbinom(5,0,0.5) is the probability o observing 0 through 5 heads when tossing a coin ten times. qbinom(p,size,probability), the value o q required so that observing 0 to q successes has a probability o p. Again, size is the number o tries and probability is the probability o observing a success. As an example, q <- qbinom(0.5,0,0.5) yields q = 5 where the range 0 to 5 successes is observed with a 0.5 probability, when tossing a coin 0 times. rbinom(n,size,probability), generates n random successes ranging rom 0 to size in value, when probability is the probability o a success. As an example, rbinom(8,0,0.5) yields, (6, 8, 5, 4, 4, 5, 5, 6) which is the number o heads observed or each o 8 replications o an experiment where a coin is tossed ten times. Cauchy This continuous density unction is given by, nx x,, x where x is the random variable, µ is the mean, Γ is the ull width at hal maximum (FWMH or peak width). The mean is µ. The distribution does not have a inite variance. dcauchy(x, location=0,scale=,...), x is the random variable, location is µ in the above equation, and scale is Γ/.
Exponential This continuous density unction has two common orms,, exp, exp x x t t where x or t are the random variable, /λ (or τ) is the mean and /λ (or τ ) is the variance. Chemists usually call λ the rate constant and τ the lietime, where λ = /τ. Note: 0 x,t. F Statistic dexp(x,rate=,...), x is the random variable and rate is λ. This continuous density has the orm, x,, x x where x is the random variable, φ is the numerator degrees o reedom, and φ is the denominator degrees o reedom. Γ () is the gamma unction (in R, gamma()). The mean and variance are o little importance. Note: since variances are positive, 0 x. d(x,d,d,...), x is the random variable, d is the numerator degrees o reedom, and d is the denominator degrees o reedom. Normal (Gaussian) This continuous density has the orm, x,, exp x where x is the continuous random variable, µ is the mean, and σ is the variance. dnorm(x,mean=0,sd=,...), x is the random variable, mean is the mean, and sd is the standard deviation. 3
Poisson This discrete Poisson or counting density has the orm, x x! x, exp where x is the random variable, µ is the mean and variance. Note: 0 x. t Statistic dpois(x,lambda,...), x is the random variable and lambda is the mean. This continuous density has the orm, x x, where x is the random variable and φ is the degrees o reedom. The mean and variance are o little importance. Γ is the gamma unction (not the gamma density!). Uniorm dt(x,d,...), x is the random variable and d is the degrees o reedom. The discrete and uniorm density unctions both have the orm, x, a, b b a where x is the random variable over the range, a < x b. For a discrete variable it is important that the lower bound, a, is not included. This distinction makes no dierence with a continuous random variable since < and are only o by the ininitely small amount, dx. The means are (b + a + )/ or discrete and (b + a)/ or continuous distributions. The variances are [(b a) ]/ or discrete and (b a) / or continuous. duni(x,min=0,max=,...), where x is the continuous random variable, min is a, and max is b. 4
Visualizing the Density Functions For continuous density unctions a quick and dirty way to visualize them is to use the curve() unction. For example, curve(dnorm,-4,4,lwd=3) grid(col='black') dnorm (x) 0.0 0. 0. 0.3 0.4-4 - 0 4 x 5
For discrete density unctions use the barplot() unction. For example, x <- 0:0 p <- dpois(x,5) barplot(p,names.arg=as.character(x)) abline(h=c(0.05,0.0,0.5),lty=3,col='black') 0.00 0.05 0.0 0.5 0 3 4 5 6 7 8 9 3 5 7 9 6