STAT 362 Statistics R Language Questions


2 attachmentsSlide 1 of 2attachment_1attachment_1attachment_2attachment_2

Unformatted Attachment Preview

Stat 362: Chapter 3 Worksheet
Show all of your work / code. No credit will be given if there is no work / code.
For each of the below questions, report your code and results.
1. In a regional spelling bee, the 8 finalists consist of 3 boys and 5 girls. Find the number of
sample points in the sample space S for the number of possible orders at the conclusion of
the contest for
(a) all 8 finalists;
(b) the first 3 positions.
2. How many ways are there to select 3 candidates from 8 equally qualified recent graduates for
openings in an accounting firm?
3. A president and a treasurer are to be chosen from a student club consisting of 50 people. How
many different choices of officers are possible if
(a) there are no restrictions?
(b) Abe will serve only if he is president?
4. In testing a certain kind of truck tire over rugged terrain, it is found that 25% of the trucks fail
to complete the test run without a blowout. Of the next 15 trucks tested, find the probability
that (Hint: Binomial Distribution)
(a) less than 4 have blowouts;
(b) from 3 to 6 (inclusive) have blowouts.
5. An automobile manufacturer is concerned about a fault in the braking mechanism of a particular model. The fault can, on rare occasions, cause a catastrophe at high speed. The
distribution of the number of cars per year that will experience the catastrophe is a Poisson
random variable with λ = 5. What is the probability that greater than 1 car per year will
experience a catastrophe?
6. Suppose P(T > k) = 0.05, where T comes from the t-distribution with 10 degrees of freedom.
Find k. Hint: Use the function qt()
7. Generate a sample of size 30 from the Gamma Distribution with parameters α = 3 and β = 5
(scale parameter). We want to be able to replicate this sample, so use a seed of 15. Report
the sample mean and sample variance along with your code.
Probability and Distributions
Chapter 3
Stat 362
1 / 21
1 Random Sampling
2 Probability Calculations and Combinatorics
3 Discrete Distributions
4 Continuous Distributions
2 / 21
Random Sampling
3 / 21
Types of Sampling
Why random sample?
Types of random sampling:
Simple Random Sample (SRS)
Stratified Sampling (STSRS)
Cluster Sampling
Systematic Sampling
Multistage Sampling
4 / 21
Simple Random Sampling
Simple Random Sample:
sample(x, size, replace = FALSE, prob = NULL)
x: vector of numbers to select from
size: how many numbers you want to get
replace: sample with replacement (TRUE), sample without
replacement (FALSE)
prob: vector of probabilities. Default is uniform (each value has the
same probability of being selected)
5 / 21
How to generate a replicable series of random variables
Set a random number seed. Allows for replication to generate the
exact same dataset each time you run your code. Must be run right
before the random sample generation.
round(rnorm(n = 10, mean = 30, sd = 5),2)
## round() rounds values to a certain
## number of decimal places
32.38 29.37 35.48 22.78 35.74
27.66 24.97 30.32 35.12 32.87
See Additional R Code: Random Sampling
6 / 21
Probability Calculations and Combinatorics
7 / 21
Permutations, Combinations
Permutations can be written as a division of factorials.
factorial() returns the value of a factorial.
Example: factorial(4) = 4(3)(2)(1) = 24.
prod() gives the product of the values inside the function.
Example: prod(c(3,4)) = 3(4) = 12.
Combinations can be written with factorials, products, or the
binomial coefficient.
choose(n,k) returns the value of

See Additional R Code: Probability calculation and combinatorics
8 / 21
Discrete Distributions
9 / 21
Binomial Distribution
Let X represent the number of successes in n Bernoulli trials. Then
X ∼ Bin(n, p).

n x
P(X = x) =
p (1 − p)n−x , x = 0, 1, 2, . . . , n.
Expected Value:
E(X ) = np
V(X ) = σ 2 = np(1 − p)
Standard Deviation:
SD(X ) = σ =
np(1 − p)
10 / 21
Binomial Distribution: R Functions
PDF: dbinom(x, size = , prob = )
CDF: pbinom(x, size = , prob = )
Quantile: qbinom(q, size = , prob = )
The smallest value x such that F (x) ≥ p,
where F is the distribution function.
Generate Random Sample: rbinom(n, size = , prob = )
Suppose X ∼ Bin(20, 0.3)
P(X = 5): dbinom(5, size = 20, prob = 0.3)
P(X ≤ 5): pbinom(5, size = 20, prob = 0.3, lower.tail= TRUE)
50th percentile (median): qbinom(0.5, 20, 0.3, lower.tail = TRUE)
Generate a random sample of size 10:
rbinom(n = 10, size = 20, p = 0.3)
Note: lower.tail = TRUE is optional in the pbinom and qbinom functions
because it is the default setting.
11 / 21
Poisson Distribution
Let X represent the number of outcomes occurring in a given time
interval or specified region. Let λ represent the average number of
outcomes per unit time, distance, area, or volume. Then X ∼ Pois(λ).
P(X = x) =
e −λ λx
, x = 0, 1, 2, . . . .
Expected Value:
E(X ) = λ
V(X ) = σ 2 = λ
Standard Deviation:

SD(X ) = σ =
12 / 21
Poisson Distribution: R Functions
PDF: dpois(x,λ)
CDF: ppois(x,λ)
Quantile: qpois(q,λ)
It is the smallest integer x such that P(X ≤ x) ≥ p.
Generate Random Sample: rpois(n,λ)
Suppose X ∼ Pois(λ = 2.5).
P(X = 1): dpois(1,2.5)
P(X ≤ 5): ppois(5,2.5, lower.tail = TRUE)
50% percentile (median): qpois(0.5,2.5, lower.tail = TRUE)
Generate a random sample of size 10: rpois(10,2.5)
Note: lower.tail = TRUE is optional because it is the default setting.
13 / 21
Continuous Distributions
14 / 21
Normal (Gaussian) Distribution
Let X ∼ N(µ, σ 2 ).
f (x) =
1 − (X −µ)
2σ 2 ,

Purchase answer to see full

User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.

Looking for this assignment?

do my essay homework

Reviews, comments, and love from our customers and community

Article Writing

Great service so far. Keep doing what you do, I am really impressed by the work done.



PowerPoint Presentation

I am speechless…WoW! Thank you so much! Definitely, the writer is talented person. She provided me with an essay a day early before the due date!

Stacy V.

Part-time student

Dissertation & Thesis

This was a very well-written paper. Great work fast. I was in pretty desperate need for help to finish this paper before the due date, which was in nine hours.

M.H.H. Tony


Annotated Bibliography

I love working with this company. You always go above and beyond and exceed my expectations every time. Kate did a WONDERFUL job. I would highly recommend her.

Francisca N.


Book Report / Review

I received my order wayyyyyyy sooner than I expected. Couldn’t ask for more. Very good at communicating & fast at replying. And change & corrections she put in the effort to go back and change it!

Mary J.


Essay (Any Type)

On time, perfect paper. All concerns & matters I had Tom was able to answer them! I will definitely provide him with more orders!

Prof. Kate (Ph.D)


Case Study

Awesome! Great papers, and early! Thank you so much once again! Definitely recommend to trust James with your assignments! He won’t disappoint!

Kaylin Green


Proofreading & Editing

Thank you Dr. Rebecca for editing my essays! She completed my task literally in 3 hours. For sure will work with her again, she is great and follows all instructions

Rebecca L.


Critical Thinking / Review

Extremely thorough summary, understanding and examples found for social science readings, with edits made as needed and on time. It’s like having a tutoring service available (:

Arnold W.



Perfect!I only paid about $80, which i think was a good price considering what my paper entailed. My paper was done early and it was well written!

Joshua W.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>