0% found this document useful (0 votes)
6 views3 pages

Binomial and Hypergeometric Distributions

The document contains various calculations and plots related to probability distributions, specifically the negative binomial and hypergeometric distributions. It includes computations for probability mass functions (PMF), cumulative distribution functions (CDF), mean, variance, and expected values for different scenarios. Additionally, it provides visual representations of these distributions through plots.

Uploaded by

sl6316728
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Binomial and Hypergeometric Distributions

The document contains various calculations and plots related to probability distributions, specifically the negative binomial and hypergeometric distributions. It includes computations for probability mass functions (PMF), cumulative distribution functions (CDF), mean, variance, and expected values for different scenarios. Additionally, it provides visual representations of these distributions through plots.

Uploaded by

sl6316728
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd

> #1

> #a
> x=2
> r=4
> p=0.95
> q=0.05
> prob=dnbinom(x,r,p);prob
[1] 0.02036266
>
> #b
> x=2
> r=4
> p=0.95
> q=0.05
> prob=pnbinom(x,r,p);prob
[1] 0.9977702
>
> #c
> mean=r*q/p;mean
[1] 0.2105263
> var=r*q/p**2;var
[1] 0.2216066
>
> #d
> x=seq(0,10,1)
> pmf=dnbinom(x,4,0.95)
> plot(x,pmf,type="h")
> cdf=pnbinom(x,4,0.95)
> plot(x,cdf,type="h")
>
> #2
> #a
> r=2
> p=0.5
> q=0.5
> x=seq(0,12,1);x
[1] 0 1 2 3 4 5 6 7 8 9 10 11 12
> pmf=dnbinom(x,r,p);pmf
[1] 0.250000000 0.250000000 0.187500000 0.125000000 0.078125000
0.046875000
[7] 0.027343750 0.015625000 0.008789062 0.004882813 0.002685547
0.001464844
[13] 0.000793457
> plot(x,pmf,type="h")
>
> #b
> x=2
> r=2
> p=0.5
> dnbinom(x,r,p)
[1] 0.1875
>
> #c
> x=2
> r=2
> p=0.5
> pnbinom(x,r,p)
[1] 0.6875
>
> #d
> ex=r*q/p;ex
[1] 2
>
> #e
> ex_total=ex+2;ex_total
[1] 4
>
> #3
> N=300
> n=4
> k=270
> x=3
> prob=dhyper(x,n,N-n,k);prob
[1] 0.2942164
>
> #using binomial distribution
> p=k/N;p
[1] 0.9
> x=seq(0,4,1)
> prob_binomial=dbinom(x,n,p);prob_binomial
[1] 0.0001 0.0036 0.0486 0.2916 0.6561
> plot(x,prob_binomial,type="h",main="PMF",xlab="no of union members is
n",ylab="probability")
> cdf=pbinom(x,n,p)
> plot(x,cdf,type="s",main="CDF",xlab="no. of union members is
n",ylab="probability")
>
> #4
> N=18
> n=4
> k=11
>
> #i
> x=0
> prob_none=dhyper(x,n,N-n,k);prob_none
[1] 0.01143791
> #ii
> prob_atleast1=1-prob_none
>
> x=seq(0,4,1)
> pmf=dhyper(x,n,N-n,k);pmf
[1] 0.01143791 0.12581699 0.37745098 0.37745098 0.10784314
> plot(x,pmf,type="h",main="PMF")
> cdf=phyper(x,n,N-n,k);cdf
[1] 0.01143791 0.13725490 0.51470588 0.89215686 1.00000000
> plot(x,cdf,type="h",main="CDF")
>
> #5
> N=200
> n=4
> k=10
> x=0
> prob_none=dhyper(x,n,N-n,k)
>
> #a
> prob_atleast1=1-prob_none;prob_atleast1
[1] 0.1867944
>
> #b
> x=2
> prob=dhyper(x,n,N-n,k);prob
[1] 0.01249093
>
> #c
> x=seq(0,4,1)
> pmf=dhyper(x,n,N-n,k);pmf
[1] 8.132056e-01 1.739477e-01 1.249093e-02 3.524777e-04 3.246505e-06
> plot(x,pmf,type="h",main="PMF")
> cdf=phyper(x,n,N-n,k);cdf
[1] 0.8132056 0.9871533 0.9996443 0.9999968 1.0000000
> plot(x,cdf,type="h",main="cdf")

You might also like