# Graphing probability distribution using R and checking other solutions

I am trying to solve questions in my statistics book. There is a question a want you check me and help for the part iv :

Consider a population of 100 computer, 45 of whom are broken, and the rest are nonbroken.

i) If you select 10 computer at random but with replacement, find the probability that 4 are broken.

ii) Now assume you select ten people without replacement, find the same probability.

iii) What is the probability distribution that gives probabilities in i) and what is it in ii)

iv) Using cumulative probability distribution(s) and graph(s) try to show that probabilities >converge between the cases with replacement and without the replacement as the population size increases relative to size of selection, i.e. sample size.

iv-) I cannot do this part

I stuck in part iv , i am beginner in R language so i could not write codes for part iv.Can you help me for it , i need to show it using cumulative probability distribution(s) and graph(s) in R.Moreover , are i ,ii,iii correct ? Thanks in advance

• Please add the self-study tag & read its wiki. Then tell us what you understand thus far, what you've tried & where you're stuck. We'll provide hints to help you get unstuck. Please make these changes as just posting your homework & hoping someone will do it for you is grounds for closing. Dec 15, 2021 at 17:23
• @kjetilbhalvorsen i wrote my answers for i,ii,iii. what should i do ? Dec 15, 2021 at 17:31
• @kjetilbhalvorsen i need r code for part iv Dec 15, 2021 at 17:31
• R code: (i) dbinom(4, 10, .45) returns $0.2383666,$ as does choose(10,4)*.45^4*.55^6, so that part is correct. (ii) dhyper(4, 45,55, 10) returns $0.2495228$ as does choose(45,4)*choose(55,6)/choose(100,10) so your formula is correct, but the distribution is hypergeometric, not binomial, in this part. // Part (iv) is not clearly stated. Selecting only 10 observations will not give much of a clue as to convergence. What is the exact statement of (iv)? Dec 15, 2021 at 20:25

Graphical comment:

For whatever help it may provide, the CDFs of the binomial distribution in (i) and the hypergeometric distribution in (ii) are almost the same, because only 10 of 100 people have been sampled.

A plot of the two CDFs from R is shown below. (The vertical resolution of such a graph is about two decimal places.)

R code for the figure (using base R graphics).

x = 0:10
Bino.CDF = pbinom(x, 10, .45)
Hypr.CDF = phyper(x, 45,55, 10)
hdr = "Binomial (solid blue) and Hypergeometric (dotted) CDFs"
plot(x, Bino.CDF, type="s", col="blue", ylab="CDF", main=hdr)
points(x, Bino.CDF, pch=20, col="blue")
lines(x, Hypr.CDF, type="s", lwd=3, lty="dotted", col="brown")
points(x, Hypr.CDF, col="brown")