Functions from stat package (which is loaded by
default).
The probability mass at a point \(x\) can be evaluated using the syntax:
dpois(x=x,lambda=l).
The probability distribution \(P(X\leq
x)\) is calculated using the ppois() function.
Syntax is:
ppois(x,lambda=l)
The quantile for probability \(p\)
can be evaluated using the qpois() function. Syntax is:
qpois(prob,lambda=l)
Step 1: Assign the inputs for required distribution
Step 2: Calculate the required probabilities
Step 3: Report the results
Case: Given the data \(n=50\), mean, \(\lambda=25\), use appropriate function to find the mass function of a Poisson distribution. Also draw the graphs of the mass function and cumulative distribution function.
# create input parameters
n <-50; l <- 25
x=0:50
#calculating probability mass distribution and cumulative distribution
pmval=dpois(x,lambda=l)
pmval
## [1] 1.388794e-11 3.471986e-10 4.339982e-09 3.616652e-08 2.260408e-07
## [6] 1.130204e-06 4.709182e-06 1.681851e-05 5.255784e-05 1.459940e-04
## [11] 3.649850e-04 8.295113e-04 1.728149e-03 3.323363e-03 5.934576e-03
## [16] 9.890961e-03 1.545463e-02 2.272739e-02 3.156582e-02 4.153397e-02
## [21] 5.191747e-02 6.180651e-02 7.023467e-02 7.634203e-02 7.952295e-02
## [26] 7.952295e-02 7.646438e-02 7.080035e-02 6.321460e-02 5.449534e-02
## [31] 4.541279e-02 3.662321e-02 2.861189e-02 2.167567e-02 1.593799e-02
## [36] 1.138428e-02 7.905751e-03 5.341723e-03 3.514292e-03 2.252751e-03
## [41] 1.407969e-03 8.585180e-04 5.110226e-04 2.971062e-04 1.688103e-04
## [46] 9.378351e-05 5.096930e-05 2.711133e-05 1.412048e-05 7.204329e-06
## [51] 3.602164e-06
#calculating cumulative density
cdval=ppois(x,lambda = l)
cdval
## [1] 1.388794e-11 3.610865e-10 4.701069e-09 4.086759e-08 2.669083e-07
## [6] 1.397112e-06 6.106294e-06 2.292480e-05 7.548264e-05 2.214766e-04
## [11] 5.864616e-04 1.415973e-03 3.144122e-03 6.467484e-03 1.240206e-02
## [16] 2.229302e-02 3.774765e-02 6.047504e-02 9.204086e-02 1.335748e-01
## [21] 1.854923e-01 2.472988e-01 3.175335e-01 3.938755e-01 4.733985e-01
## [26] 5.529214e-01 6.293858e-01 7.001861e-01 7.634007e-01 8.178961e-01
## [31] 8.633089e-01 8.999321e-01 9.285440e-01 9.502196e-01 9.661576e-01
## [36] 9.775419e-01 9.854477e-01 9.907894e-01 9.943037e-01 9.965564e-01
## [41] 9.979644e-01 9.988229e-01 9.993339e-01 9.996310e-01 9.997999e-01
## [46] 9.998936e-01 9.999446e-01 9.999717e-01 9.999858e-01 9.999930e-01
## [51] 9.999966e-01
pmf and cdfpar(mfrow=c(1,2))
plot(x,pmval,xlab="x",ylab="P(X=x)", main="The Poisson Distribution")
plot(x,cdval,xlab="x",ylab=expression(P(X<=x)),main="Cumulative Distribution Function")
The pmf and cf of the Poisson distribution
for given input parameters are evaluated and create respective
plots.