You are on page 1of 13

WINTER SEMESTER 2022-2023

NAME: Chethan N V

REG.NO: 21BCE0427

Course Title: Probability and Statistics

Course Code: BMAT202P

Slot: L5+L6

EXPERIMENT NO : LAB ASSIGNMENT – 4

FACULTY NAME: Padigepati Naveen


Problem - 1
In a city 250 men out of 750 were found to be smokers does this
information support the conclusion that the majority of men in this
city are smokers.

Aim: To find single mean test


Code:
> #Name: Chethan N V
> #Reg No: 21BCE0427
>

> #Question 1
> #In a city 250 men out of 750 were found to be smokers does
this information support the conclusion that the majority of
men in this city are smokers.
>
> P=1/2 #Which re presents an equal number of smokers and
nonsmokers(No majority)
> n=250
> N=750
> p=n/N
> if(p>P)
+ {
+ print("Majority of men in this city are smokers")
+ }
> if(p<P)
+ {
+ print("Majority of men in this city are not smokers")
+ }
[1] "Majority of men in this city are not smokers"
>
> #Here H0:Majority of men in this city are smokers >
#H1: Majority of men in this city are not smokers
>
> #Since p<P we accept H0.

Screenshot:
Problem 2:
A random sample of 36 values from a normal population showed a mean of 41.5
inches and the sum of the squares of deviation from mean is 13.5 inches.

(a) Find the maximum error with 99% confidence.

(b) A sample of size 40 was taken from a population whose S.D is 2.03 and the
mean 40 is Construct 95% confidence interval for the mean.

(c) It is claimed that a random sample of 100tyres with a mean life of 15269 is
drawn from a population of tyres which has a mean life of 15200 km. and a
standard deviation of 1248 km. Test the validity of the claim.

Code:
> #Name: Chethan N V >
#Reg No: 21BCE0427
>
> #Question 2
> #A random sample of 16 values from a normal population showed
a mean of 41.5 inches and the sum of the squares of deviation
from mean is 13.5 inches.
>
> #a) Find the maximum error with 99% confidence.
>
cv=qt(0.995,35)
> sm=41.5
> sos=13.5
> sz=36
> sample_sd=sqrt(sos/(sz-1))
> maxerror=cv*(sample_sd/sqrt(sz))
> maxerror
[1] 0.2819407
>
> #b) A sample of size10was taken from a population whose S.D
is .03 and the mean is Construct 95% confidence interval for
the mean.
>
> sz=40
> sm=40
> sample_sd=2.03
> cv=qt(0.95,sz-1)
> margin_error=cv*(sample_sd/sqrt(sz))
>
> lb=sm-margin_error >
ub=sm+margin_error
>
> c(lb,ub)

[1] 39.4592 40.5408


>
> #(c) To test the validity of the claim in R programming:
>
> sz=100
> sm=15269
> p_mean=15200
> p_sd=1248
>
> # Null hypothesis: the sample is drawn from a population with
mean = pop_mean
> # Alternative hypothesis: the sample is not drawn from a
population with mean = pop_mean > # Level of significance:
0.05
>
> test=(sm-p_mean)/(p_sd/sqrt(sz))
> cv=qt(0.025,sz-1,lower.tail=FALSE)
> pv=2*pt(abs(test),sz-1,lower.tail=FALSE)
>
> if(abs(test)>cv|pv<0.05) {
+ cat("Reject null hypothesis. The sample is not drawn from a
population with mean =", p_mean)
+ }else{
+ cat("Fail to reject null hypothesis. The sample is drawn from
a population with mean =", p_mean)
+ }
Fail to reject null hypothesis. The sample is drawn from a
population with mean = 15200
Screenshots:
Problem 3:
Random samples of 600 men and 900 women in a locality were asked
whether they would like to have a bus stop near their residence 350
men and 475 women were in favor of the proposal. Test the
significance between the difference of two proportions at 5% level

Aim: To find difference of proportions.

Code:
> #Name: Chethan N V >
#Reg No: 21BCE0427
>
> #Question 3
> #Random samples of 600 men and 900 women in a locality were
asked whether they would like to have a bus stop near their
residence 350 men and 475 women were in favor of the proposal.
Test the significance between the difference of two proportions
at 5% level.
>
>
> n1=600
> n2=900
> N1=350
> N2=475
>
> p1=N1/n1
> p2=N2/n2
>
> p=(N1+N2)/(n1+n2) > se=sqrt(p*(1-
p)*((1/n1)+(1/n2)))
> z=(p1-p2)/se
>
> p_value=2*pnorm(-abs(z))
>
> a=0.05
>
> if(p_value<a){
+ cat("The difference in proportions is significant at the",
a*100, "% level.\n")
+ }else{
+ cat("The difference in proportions is not significant at
the", a*100, "% level.\n")
+ }
The difference in proportions is significant at the 5 % level.
>
> #Here H0: The difference in proportions is significant
> #H1: The difference in proportions is not significant
> #as pvalue<a we accept H0 se=sqrt(p*(1-p)*((1/n1)+(1/n2)))
Screenshots:
Problem 4:
lady stenographer claims that she can take dictation at the rate of 118
words per minute can we reject her claim on the basis of 100 trials in
which she demonstrates a mean of 116 words and a S.D of 15 words.

Aim: To find T-statistic and p-statistic.

Code:
> #Name: Chethan N V >
#Reg No; 21BCE0427
>
> #Question 4
> #A lady stenographer claims that she can take dictation at
the rate of 118 words per minute can we reject her claim on the
basis of 100 trials in which she demonstrates a mean of 116
words and a S.D of 15 words.
> xbar=116
> s=15
> n=100
> mu0=118
>
> t_stat=(xbar-mu0)/(s/sqrt(n))
> p_val=2*pt(-abs(t_stat),df=n-1)
>
> cat("t-statistic =",round(t_stat,2),"\n") t-statistic
= -1.33
> cat("p-value =", p_val, "\n") p-value
= 0.1854824
>
> #Since the p-value is less than 0.05, we can reject the null
hypothesis and conclude that there is evidence to suggest that
the lady stenographer's claim of dictating at 118 words per
minute is not true, based on the 100 trials with a mean of 116
words and a standard deviation of 15 words.
>

Screenshot:

You might also like