Assignment No 1,2,3,4

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

Assignment No.

3
Qno.1: MCQ’s

1. a 2. b 3. a 4. a 5. b 6. c 7. a 8. b 9. a 10. b
11. b 12. d 13. a 14. b 15. c 16. c 17. b 18. a 19. a 20. a

Qno.2: MCQ’s

1. d 2. a 3. a 4. a 5. b 6. c 7. a 8. c 9. c 10. c
11. a 12. a 13. b 14. c 15. d 16. b 17. c 18. a 19. a 20. c

Qno.3: MCQ’s

1. a 2. a 3. a 4. b 5. b 6. d 7. b 8. c 9. a 10. a
11. a 12. a 13. c 14. a 15. c 16. a 17. b 18. c 19. d 20. c

Paper NO.1
Qno.1
The R commands are as follow:
# Create the vector of observations
observations =c(3, 9, 13, 10, 8, 10, 12, 8, 18, 14, 13, 11, 15, 12, 17, 19, 13, 17, 15, 16, 17, 18, 20, 22,
25, 23, 22, 25, 26, 29, 30, 31, 32, 33, 27, 26, 28, 29, 26, 24, 23, 22, 21, 20, 18)
length(observations)
sum(observations)
mean(observations)
median(observations)
quantile(observations, 0.9)
var(observations)
sd(observations)
prod(observations)
Qno.2
Y=c(227.2, 196, 278.7, 272.3, 267.4, 254.5, 224.7, 181.5, 227.5)
X1=c(694.85, 638.1, 774.55, 757.9, 753.35, 704.7, 666.8, 568.55, 653.1)
X2=c(37, 36.76, 34.62, 35.4, 35.96, 36.26, 36.34, 35.9, 31.84)
X3=c(15.83, 16.41, 13.1, 13.63, 14.51, 15.38, 16.1, 16.73, 10.58)
a) X=cbind(X1, X2, X3)
b) cov_X=cov(X)
c) cor_X=cor(X)
d) inv_cor_X=solve(cor_X)
e) det_cor_X=det(cor_X)
f) lm_Y_X=lm(Y ~ X1 + X2 + X3)

Qno.3(a)
#Suppose you have a vector named ‘values’
i. log_values =log(values)
ii. sqrt_values =sqrt(values)
iii. rounded_values =round(values, 2)
iv. integer_values=as.integer(values)
v. product_values=prod(values)

Qno.3(b)
# Assuming you have a vector named 'X' containing the sample values
alpha=0.05
t_test=t.test(X, mu = 35)
print(t_test)

Qno.4(a)
i. pbinom(3, size = 12, prob = 0.7)
ii. pbinom(4, size = 12, prob = 0.7)
iii. pbinom(8, size = 12, prob = 0.7)
iv. pbinom(7, size = 12, prob = 0.7) - pbinom(4, size = 12, prob = 0.7)

Qno.4(b)
range =function(vec) {
min_val=min(vec)
max_val=max(vec)
range_val=max_val - min_val
coefficient_of_range =range_val / (max_val + min_val)

result <- list(range = range_val, coefficient_of_range = coefficient_of_range)


return(result)
}

Qno.5(b)
geometric_mean=function(vector) {
product=prod(vector)
geometric_mean=product^(1/length(vector))
return(geometric_mean)
}
Qno.5(b)

outliers=function(vector) {
sd_limit=3
mean_val=mean(vector)
sd_val=sd(vector)
lower_limit=mean_val - sd_limit * sd_val
upper_limit=mean_val + sd_limit * sd_val

outliers =vec[vector < lower_limit | vector > upper_limit]


percentage_outliers=length(outliers) / length(vector) * 100

result=list(outliers = outliers, percentage_outliers = percentage_outliers)


return(result)
}

Paper No.2
Qno.1
Repeated Question
Qno.2
Repeated Question
Qno.3
x=c(34.46,34.6,35.38,35.85,35.68,35.35,35.04,34.07,32.2,34.32,31.08)
y=c(34.14,34.85,35.89,33.53,33.79,34.72,35.22,36.5,37.6,37.89,37.71)

i. var.test (x,y, alternative = “two.sided” , conf.level = 0.95, var.equal=F)


ii. t.test (x,y, alternative = “two.sided” , conf.level = 0.95)

Qno.4(a)
mean=50
sd=10
i. prob_between_55_100=pnorm (100, mean, sd) – pnorm (55, mean, sd)
ii. prob_greater_than_54= pnorm (54, mean, sd)
iii. prob_smaller_than_57=pnorm(57, mean, sd)
iv. value_with_77_percent_area <- qnorm (0.77, mean, sd)

Qno.4(b)
harmonic_mean=function(x) {
n=length(x)
harmonic=n / sum (1 / x)
return(harmonic)
}

Qno.5(a)
permutation <- function (n, r) {
result <- factorial(n) / factorial (n - r)
return(result)
}

Qno.5(b)
mean_deviation <- function(vector) {
mean_value <- mean(vector)
deviation <- abs (vector - mean_value)
mean_deviation <- mean(deviation)
return(mean_deviation)
}
Paper No.3
Qno.1(a)
y=c(40, 50, 60, 65, 76, 65, 66, 50, 45, 38, 60, 42, 53, 63, 58, 61)
x=c(“G1”, “G1”, “G1”, “G1”, “G2”, “G2”, “G2”, “G2”, “G3”, “G3”, “G3”, “G3”, “G4”, “G4”, “G4”,
“G4”)
a=aov(y~x)
summary(a)

Qno.1(b)
i. Y=c(227.2, 196, 278.7, 272.3, 267.4, 254.5, 224.7, 181.5, 227.5)
X1=c(694.85, 638.1, 774.55, 757.9, 753.35, 704.7, 666.8, 568.55, 653.1)
X2=c(37, 36.76, 34.62, 35.4, 35.96, 36.26, 36.34, 35.9, 31.84)
X3=c(15.83, 16.41, 13.1, 13.63, 14.51, 15.38, 16.1, 16.73, 10.58)
lm_Y_X=lm(Y ~ X1 + X2 + X3)

ii. summary(lm_Y_X)

Call:
lm(formula = Y ~ X1 + X2 + X3)

Residuals:
1 2 3 4 5 6 7 8 9
-1.7044 -8.5085 -7.3664 3.4470 0.2619 12.3425 -1.1071 2.0229 0.6121

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 230.3065 187.0910 1.231 0.2731
X1 0.6246 0.1094 5.712 0.0023 **
X2 -16.9235 10.8532 -1.559 0.1797
X3 12.0503 9.3415 1.290 0.2535
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 7.74 on 5 degrees of freedom
Multiple R-squared: 0.9678, Adjusted R-squared: 0.9485
F-statistic: 50.15 on 3 and 5 DF, p-value: 0.000373

Qno.2
Repeated Question
Qno.3
Repeated Question
Qno.4(a)
Repeated Question
Qno.5(a)
Repeated Question
Qno.5(b)
Repeated Question
Qno.5(c)
range_and_coefficient_of_range <- function(vector) {
range_value <- max(vector) - min(vector)
coefficient_of_range <- (range_value / mean(vector)) * 100
return(list(range = range_value, coefficient_of_range = coefficient_of_range))
}
Assignment No.4
QNO.1
t.test (Argan_tree_heights,alternative= "two.sided", Conf.level= 0.95, mu=2.1)

One Sample t-test

data: Argan_tree_heights
t = -8.1871, df = 34, p-value = 1.499e-09
alternative hypothesis: true mean is not equal to 2.1
95 percent confidence interval:
1.723356 1.873157
sample estimates:
mean of x
1.798256

>

QNO.2
Time=c(3.4,3.6,3.4,3.6,3.2,3.6,3.8,3.8,3.4,3.5,3.4,3.6,3.6,4.1,3.5,3.4,3.7,3.6,3.6,3.8,3
.8,3.7,3.6,3.3,3.4,3.7,3.5,3.8,3.8,3.6,3.4,3.7,3.7,3.7,3.6,3.5,3.7,3.9,3.2,3.7,6.1,6.8,5
.9,5.3,6,5.8,6.9,5.9,4.8,6.3,5.6,4.5,6.7,6.1,6.7,5.3,5.3,6.1,7.5,5.7,7.8,6.8,6.3,4.4,5.3
,6.3,5.9,5.8,4.9,5.2,4.6,5.4,4.7,6.7,5.7,4.8,6.7,6.7,4.8,5.8,6,5.9,5.4,6,3.8,5.2,4.5,3.8
,4.9,4.8,5.3,4.3,5.7,3.9,4.5,4.1,3.9,6,3.7,4.3,5.4,5.4,4.5,3.7,5.3,5.8,4.8,4.4,4.3,6.2,5
,5.8,5.4,4.5,4.6,5.2,6.1,4.9,5,5.8)
> data=(Time)
> Times=factor(rep(c("A", "B", "C"), each = 40))
> Times
[1] A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A B
B B B
[45] B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B C C C C C
C C C
[89] C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C
Levels: A B C
> model=aov(data ~ Times)
> model
Call:
aov(formula = data ~ Times)

Terms:
Times Residuals
Sum of Squares 102.66067 50.48925
Deg. of Freedom 2 117

Residual standard error: 0.656911


Estimated effects may be unbalanced
> summary(model)
Df Sum Sq Mean Sq F value Pr(>F)
Times 2 102.66 51.33 118.9 <2e-16 ***
Residuals 117 50.49 0.43
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

>

QNO.5
data=(buttercup_growth_forms)
> t.test(Aggregation ~ Soil, data = data)

Welch Two Sample t-test

data: Aggregation by Soil


t = -4.0132, df = 34.937, p-value = 0.0003011
alternative hypothesis: true difference in means between group Normal and group
Sandy is not equal to 0
95 percent confidence interval:
-15.702365 -5.152304
sample estimates:
mean in group Normal mean in group Sandy
47.67905 58.10639

>

QNO.6
> data=(blow_fly_flight)
> t.test(Time ~ Wind, data = data)

Welch Two Sample t-test

data: Time by Wind


t = -8.0323, df = 63.066, p-value = 3.111e-11
alternative hypothesis: true difference in means between group
Strong and group Weak is not equal to 0
95 percent confidence interval:
-8.167940 -4.913506
sample estimates:
mean in group Strong mean in group Weak
9.051862 15.592586

>

QNO.7

You might also like