Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

PROBABILITY AND STATISTICS

LAB

Lab Assessment - 4

NAME :- HARSH

AGARWAL REG NO :-

21BCI0110 COURSE

CODE :- BCSE202P LAB

SLOT :- L11+L12

Question 1:

The nicotine contents in milligrams in two samples of tobacco were found to be as


follows:

Can it be said that two samples come from same normal population? ( Do both t-test and Ftest)

AIM:
To check if the samples are from the same population.

MATHEMATICAL FORMULA:
CODE AND OUTPUT FOR t test:
> a = c(24,27,26,21,25)
> b = c(27,30,28,31,22,36)
> t.test(a,b,var.equal=FALSE,paired = FALSE)

CODE AND OUTPUT FOR f test:


> a = c(24,27,26,21,25)
> b = c(27,30,28,31,22,36)
> var.test(a,b)

CONCLUSION:
P-value is greater than 0.05.
Hence we conclude that Sample A and B are from the same population.
Question 2:

AIM:
To check if the training is effective or not.

MATHEMATICAL FORMULA:

CODE AND OUTPUT:


> prior = c(84,48,36,37,54,69,83,96,90,65)
> after = c(90,58,56,49,62,81,84,86,84,75)
> t.test(prior,after,paired = TRUE)
CONCLUSION:
The p-value is greater than 0.05, then we do not reject the hypothesis H0 of
equality of the averages and conclude that the new training has not made any
significant improvement to the team of athletes.
Question 3:

AIM:
Test whether there is any change in IQ after the training Programme.

MATHEMATICAL FORMULA:

CODE AND OUTPUT:


> before = c(110,120,123,132,125)
> after = c(120,118,125,136,121)
> t.test(before,after,paired = TRUE,alt = "greater")
CONCLUSION:
We can accept the null hypothesis and support the claim because the
P-value(0.77) is greater than 0.05. Hence there is no change in IQ after the
training.
QUESTIONS OF CHI SQUARE TEST AND ANOVA:
Question 1:

AIM:
Check if there is any association between gender and preference for
ice cream flavor.

MATHEMATICAL FORMULA:

CODE AND OUTPUT:


> data<-matrix(c(100,120,60,350,320,150),ncol= 3,byrow=T)
> data
[,1] [,2] [,3]
[1,] 100 120 60
[2,] 350 320 150
> chisq.test(data)

CONCLUSION:
As p value is greater than 0.05 we do not reject the null hypothesis. Hence
there is no relationship between gender and ice cream choice.
Question 2:

AIM:
Check if binomial distribution is a good fit.

MATHEMATICAL FORMULA:

CODE AND OUTPUT:


> x = c(0,1,2,3,4)
> fx = c(5,20,45,20,10)
>n=4
> N = sum(fx)
>N
[1] 100
> # # We take null hypothesis as 4 addresses need to be changed in order to follow binomial
distribution
> p = (sum(fx*x)/sum(fx*4))
>p
[1] 0.525
> Obs_freq = fx
> Obs_freq
[1] 5 20 45 20 10
> Exp_freq = dbinom(x,n,p)*N
> Exp_freq
[1] 5.090664 22.506094 37.312734 27.493594 7.596914
> chisq = sum((Observed_frequency-Expected_frequency)^2/Expected_frequency)
Error: object 'Observed_frequency' not found
> chisq = sum((Obs_freq-Expected_frequencExp_freqy)^2/Expected_frequency)
> chisq = sum((Obs_freq-Exp_freq)^2/Exp_freq)
> chisq
[1] 4.667014
> qchisq(0.95,5)
[1] 11.0705
> qchisq(0.95,4)
[1] 9.487729
> # Hence table calculated value is lesser than table value. Hence the null hypothesis is not rejected.
And binomial is a good fit.

CONCLUSION:
The calculated value is greater than the table value at 5% significance at 4
degrees of freedom. Hence null hypothesis is accepted and binomial
distribution is a good fit for the given data.

You might also like