Anda di halaman 1dari 4

Assignment 4

Question 1. Taking 100 observations of random variable X of a certain


distribution were taken and ordered startin 0 to 2. Calculate sample mean
and sample standard deviation. Group the data into 10 classes and create
a density histogram. Consider PDF = and superimpose it on the density
histogram.

Code
x=runif(100, min=0, max=2)
y=sort(x,decreasing = FALSE)
breaks=seq(0.0, 2.0, by=0.2)
breaks
x.cut = cut(x, breaks, right=FALSE)
x.freq = table(x.cut)
x.cut
x.freq
hist(x,xlab = "Weight",freq = FALSE,col = "yellow",border = "blue",ylim = c(0,1),xlim = c(0,2))
plot(y,type="o",col = "red")
x1<-c(0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.5,1.7,1.9)
y1<-c(11,12,10,5,10,11,13,14,6,8)
x2<-x1*y1
mean=sum(x2)/100
mean
var=(sum((x1^2)*y1/100))-mean
var
The mean calculated using the provided PDF is “0.976” whereas using the
discrete data it was found to be “0.2964”. A large difference between the
xnumbers is seen. Therefore, the function is not a good fit.
Ques 2
Question 2.

In a casino game roulette, if a player bids $1 on red , the


probability of winning $1=18/38, the probability of losing $1=20/38.

X is random variable which implies the no. of successive $1 bids that a


player makes before losing $5.
Simulate 100 observations of X. Generate a relative frequency histogram.
Calculate sample mean and variance s. Locate ,s,2s,3s and compare the
situation with normal distribution.

#1
mean=90 std deviation=10
pr=pnorm(100,90,10,lower.tail=F)
#pr=0.1586553
#2
mean=50 std deviation=10
pn=pnorm(70,50,10)
#pn=0.8023375
#She scored more than 80% of the students. Hence she would be admitted.
#3
mean=70 std deviation=10
#3a
ph=pnorm(80,70,10,lower.tail=F)
#ph=0.1586553
#3b
pp=pnorm(40,70,10,lower.tail=F)
#pp=0.9986501
#3c
pf=pnorm(40,70,10)
#pf=0.001349898
#4
p3=pnorm(3.5,4,0.09,lower.tail=F)
p3=1-p3
p4=pnorm(4.4,4,0.09)
p4=1-p4
#total probability of rejection is calculated
tp=p3+p4
#Rejected bolts=
b=500*tp
#b=0.0022099. Hence all 500 are selected.

Anda mungkin juga menyukai