PSU STAT 401 - Probability Sampling and Basic Plotting

Unformatted text preview:

OutlineReview of Probability SamplingA Special PMFCombinations in RThe Binomial Theorem and PMFSampling from the Binomial PMFBasic Plotting in RThe Lab Assignment # 2OutlineReview of Probability SamplingA Special PMFBasic Plotting in RThe Lab Assignment # 2Lab2: Probability Samplingand Basic PlottingM. George AkritasM. George Akritas Lab2: Probability Sampling and Basic PlottingOutlineReview of Probability SamplingA Special PMFBasic Plotting in RThe Lab Assignment # 2OutlineReview of Probability SamplingA Special PMFCombinations in RThe Binomial Theorem and PMFSampling from the Binomial PMFBasic Plotting in RThe Lab Assignment # 2M. George Akritas Lab2: Probability Sampling and Basic PlottingOutlineReview of Probability SamplingA Special PMFBasic Plotting in RThe Lab Assignment # 2DefinitionThe type of random sampling where different outcomes havedifferent probability of occurring is referred to as probabilitysampling. Probability sampling is always sampling withreplacement.ExampleConsider rolling a die twice and record the number of times 6occurs. Describe an equivalent probability sampling experiment.Solution. The experiment that records the number of 6s can bethought of as a probability sampling experiment from thesample space population S = {0, 1, 2}, with probabilitiesP(0) = 25/36, P(1) = 10/36 and P(2) = 1/36.M. George Akritas Lab2: Probability Sampling and Basic PlottingOutlineReview of Probability SamplingA Special PMFBasic Plotting in RThe Lab Assignment # 2DefinitionA list of the numerical outcomes in the sample space populationand their associated probabilities is be called a probability massfunction, or pmf for short.The pmf of the previous example isx 0 1 2prob. 25/36 10/36 1/36.Probability sampling is also called sampling from a pmf.M. George Akritas Lab2: Probability Sampling and Basic PlottingOutlineReview of Probability SamplingA Special PMFBasic Plotting in RThe Lab Assignment # 2Combinations in RThe Binomial Theorem and PMFSampling from the Binomial PMFIFactorials in R:Ix! can be given by ”factorial(x)” or ”gamma(x+1)”ITry ”factorial(3)” and ”gamma(4)”. Also ”factorial(4)” and”gamma(5)”.ITry also ”factorial(3.5)” and ”gamma(3.5)”.ICombinations in R:IFor the number of combinationsnktry”factorial(5)/(factorial(3)*factorial(5-3))” for53, or”factorial(10)/(factorial(3)*factorial(10-3))” for103IFor the actual combinations (though this is not needed asoften) try ”combn(1:5,3)” or ”combn(1:10,3)”Note: ”1:5” gives the same result as ”seq(1:5)”, or ”seq(1,5)”or ”seq(1,5,1)”ICan also do ”length(combn(1:5,3))/3” for53.M. George Akritas Lab2: Probability Sampling and Basic PlottingOutlineReview of Probability SamplingA Special PMFBasic Plotting in RThe Lab Assignment # 2Combinations in RThe Binomial Theorem and PMFSampling from the Binomial PMFTheorem (The Binomial Theorem)(p + q)n=n0pnq0+n1pn−1q1+ · · · +nnp0qn=nXk=0nkpn−kqk=nXk=0nkpkqn−kIIf p + q = 1, and p, q > 0, we get a p.m.f. onS = {0, 1, . . . , n} with P(k) =nkpkqn−k. This is called theBinomial p.m.f.IIf p = q = 0.5, P(k) =nk0.5nis the probability of having kheads in n flips of a fair coin.M. George Akritas Lab2: Probability Sampling and Basic PlottingOutlineReview of Probability SamplingA Special PMFBasic Plotting in RThe Lab Assignment # 2Combinations in RThe Binomial Theorem and PMFSampling from the Binomial PMFIThe Binomial p.m.f.ITry ”dbinom(0:10, 10, 0.5)” for all probabilities P(k),k = 0, . . . 10. Try also ”dbinom(4, 10, 0.5)” for P(4).IVerify that P(4) obtained above can also be obtained from:”factorial(10)/(factorial(4)*factorial(10-4))*0.5**10”IProbability sampling using the Binomial p.m.f.ITry ”sample(0:10,1000,TRUE,dbinom(0:10, 10, 0.5))” or”p=dbinom(0:10, 10, 0.5), sample(0:10,1000,TRUE,p)”. Tryit again using object x to store the sample:”x=sample(0:10,1000,TRUE,dbinom(0:10, 10, 0.5))”IFor a summary of the sample do: ”table(x)”, or”table(x)/1000”ICompare with ”dbinom(0:10, 10, 0.5)”M. George Akritas Lab2: Probability Sampling and Basic PlottingOutlineReview of Probability SamplingA Special PMFBasic Plotting in RThe Lab Assignment # 2IPlotting a p.m.f.ITry ”plot(0:10,dbinom(0:10, 10, 0.5))” (which is the same as”plot(0:10,dbinom(0:10, 10, 0.5), pch=1)”, or”plot(0:10,dbinom(0:10, 10, 0.5), pch=4)”.IAdd color: Try plot(0:10,dbinom(0:10, 10, 0.5), pch=4,col=2)ICustomize labels: plot(0:10,dbinom(0:10, 10, 0.5),pch=1,col=2, xlab=”Sample Space”, ylab=”BinomialProbabilities”)IConnecting the dots: Try ”lines(0:10,dbinom(0:10, 10, 0.5))”and also ”lines(0:10,dbinom(0:10, 10, 0.5), col=3)”IBar graph of a p.m.f.:ITry ”p=dbinom(0:10, 10, 0.5), barplot(p)”ICustomize the axes: barplot(p,xlim=c(0,12),ylim=c(0,0.25))IAdd color:barplot(p,xlim=c(0,12),ylim=c(0,0.25),col=”green”)M. George Akritas Lab2: Probability Sampling and Basic PlottingOutlineReview of Probability SamplingA Special PMFBasic Plotting in RThe Lab Assignment # 2IHistogram of Empirical Probabilities:ITry ”hist(x,seq(-0.5,10.5,1))”IAdd color ”hist(x,seq(-0.5,10.5,1),col=5)”ICheck out the site: http://www.harding.edu/fmccown/r/for additional (still basic) plotting examples.M. George Akritas Lab2: Probability Sampling and Basic PlottingOutlineReview of Probability SamplingA Special PMFBasic Plotting in RThe Lab Assignment # 2Do computer activities 1,2,3 in Section 2.8. Email your results,together with the plots (you can save them as pdf’s for example),to the TA by Friday, 16th of September.M. George Akritas Lab2: Probability Sampling and Basic PlottingOutlineReview of Probability SamplingA Special PMFBasic Plotting in RThe Lab Assignment # 2IGo to previous lab http://www.stat.psu.edu/~mga/401/course.info/b.lab-Ch1.pdfIGo to next lab http://www.stat.psu.edu/~mga/401/course.info/b.lab-Ch3.pdfIGo to the Stat 401 home pagehttp://www.stat.psu.edu/~mga/401/course.info/Ihttp://www.stat.psu.edu/~mgaIhttp://www.google.comM. George Akritas Lab2: Probability Sampling and Basic


View Full Document

PSU STAT 401 - Probability Sampling and Basic Plotting

Download Probability Sampling and Basic Plotting
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Probability Sampling and Basic Plotting and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Probability Sampling and Basic Plotting 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?