NAME:CHITIMI SHIVA REDDY GARI MALLIKARJUN REDDY
SEN NUMBER:A866175125075
BRANCH:B-TECH CSE(AIML)
SUBJECT:STATISTICS AND PROBABILITY
SLOT:L29+30
Date:04.03.2026, Wednesday F1
L29+L30
Exercise-1
[Link] the values of the following by using the R
studio
25+15
15-18
12*4
100/5
2. 5.3^2
6.6^5
7.5^4
8.4^2
3. 17 divided by 5
15 divided by 3
25 divided by 6
4. Let:
x=20
y=10
x<-20
y<-10
x+y
x-y
x*y
x/y
[Link] marks of students
Raw data (marks out of 100)
Question:
45,55,60,70,80,50,65
Find the mean, median, standard deviation
marks<-c(45,55,60,70,80,50,65)
[Link](marks)
[Link](marks)
[Link](marks)
[Link] sales Data
Raw data (in through):
12,15,14,10,18,20,16
Question:
Find mean and variance
sales<-c(12,15,14,10,18,20,16)
mean(sales)
var(sales)
sd(sales)
Date:11.03.2026, Wednesday F1
L29+L30
[Link]<-c(10,20,20,30,40,50,20)
mean_value<-mean(data)
median_value<-median(data)
getmode<-function(v){
uniqv<-unique(v)
uniqv[[Link](tabulate(match(v,uniqv)))]
}
mode_value<-getmode(data)
print(paste("mean=",mean_value))
print(paste("median=",median_value))
print(paste("mode=",mode_value))
8. data<-c(12,15,18,18,20,22,25)
mean(data)
median(data)
getmode<-function(v){
uniqv<-unique(v)
uniqv[[Link](tabulate(match(v,uniqv)))]
}
getmode(data)
print(paste("mean=",mean_value))
print(paste("median=",median_value))
print(paste("mode=",mode_value))
9. marks<-c(45,50,55,60,60,65,70,75)
mean(marks)
median(marks)
getmode<-function(v){
uniqv<-unique(v)
uniqv[[Link](tabulate(match(v,uniqv)))]
}
getmode(marks)
print(paste("mean=",mean_value))
print(paste("median=",median_value))
print(paste("mode=",mode_value))
hist(data,main="histogram of data",col="blue")
10. marks<-c(45,50,55,60,60,65,70,75)
mean(marks)
median(marks)
getmode<-function(v){
uniqv<-unique(v)
uniqv[[Link](tabulate(match(v,uniqv)))]
}
getmode(marks)
print(paste("mean=",mean_value))
print(paste("median=",median_value))
print(paste("mode=",mode_value))
hist(data,main="histogram of data",col="blue")
boxplot(data,main="boxplot")
Date:18-03-2026
1-data<-c(2,3,3,4,2,5,3,4,2,3,4,3)
mean_value<-mean(data)
mean_value
median_value<-median(data)
median_value
get_mode<-function(v){
uniqv<-unique(v)
uniqv[[Link](tabulate(match(v,uniqv)))]
}
mode_value<-get_mode(data)
mode_value
cat("mean:",mean_value, "\n")
cat("median:",median_value, "\n")
cat("mode:",mode_value, "\n")
classes <- matrix(c(0,3, 3,6, 6,9, 9,12, 12,15),
ncol=2, byrow=TRUE)
freq <- c(10,18,25,15,12)
midpoints <- rowMeans(classes)
mean_grouped <- sum(midpoints * freq) /
sum(freq)
cum_freq <- cumsum(freq)
N <- sum(freq)
median_class_index <- which(cum_freq >= N/2)
[1]
L <- classes[median_class_index, 1]
F <- ifelse(median_class_index == 1, 0,
cum_freq[median_class_index - 1])
f <- freq[median_class_index]
h <- classes[median_class_index, 2] -
classes[median_class_index, 1]
median_grouped <- L + ((N/2 - F) / f) * h
mode_index <- [Link](freq)
f1 <- freq[mode_index]
f0 <- ifelse(mode_index == 1, 0,
freq[mode_index - 1])
f2 <- ifelse(mode_index == length(freq), 0,
freq[mode_index + 1])
L_mode <- classes[mode_index, 1]
h_mode <- classes[mode_index, 2] -
classes[mode_index, 1]
mode_grouped <- L_mode + ((f1 - f0) / ((f1 - f0)
+ (f1 - f2))) * h_mode
cat("Grouped data mean:", mean_grouped, "\n")
cat("Grouped data median:", median_grouped, "\
n")
cat("Grouped data mode:", mode_grouped, "\n")
Date:25-03-2026
1- x<-c(10,15,20,25,30,35,40)
range_x<-max(x)-min(x)
sd_x<-sd(x)
cv_x<-(sd_x/mean(x))*100
range_x
sd_x
cv_x
x <- c(10,20,30,40,50)
f <- c(3,5,2,4,1)
data <- rep(x, f)
range_d <- max(data) - min(data)
sd_d <- sd(data)
cv_d <- (sd_d / mean(data)) * 100
range_d
sd_d
cv_d
mid<-c(5,15,25,35,45)
f<-c(5,8,12,7,3)
data<-rep(mid,f)
range_c<-max(mid)-min(mid)
sd_c<-sd(data)
cv_c<-(sd_c/mean(data))*100
range_d
sd_d
cv_d
DATE:29-04-2026
1. x<-c(2,4,6,8,10)
y<-c(3,5,7,9,12)
correlation<-cor(x,y)
correlation
model<-lm(y~x)
summary(model)
coef(model)
intercept<-coef(model)[1]
slope<-coef(model)[2]
intercept
slope
y_pred<-predict(model)
y_pred
plot(x,y,main="scatter plot
with regression line",
xlab="xvalues",ylab="yvalues",pch=16,col="ora
nge")
abline(model,col="blue",lwd=2)
eq<-
paste("y=",round(intercept,2),"+",round(slope,2),
"*x")
text(6,10,eq,col="darkgreen")
res<-residuals(model)
plot(x,res,main="residual plot",
xlab="x",ylab="residuals",
pch=16)
abline(h=0,col="red")
par(mfrow=c(2,2))
plot(model0)
DATE:6-05-2026
[Link] study
A company wants to analysize
Wheather a new training method improves
employee performance
Wheather variability differs between two
departments Wheather customer
PROCEDURE:
group_a<-c(55,60,58,62,57,59,61)
group_b<-c(65,68,70,66,72,69,71)
[Link](group_a,group_b,[Link]=TRUE)
[Link] t test(before-after)
Before <-c(50,52,48,49,51)
After<-c(60,63,59,61,62)
[Link](before,after,paired=TRUE)
3.F-TEST(comparing Variances)
Check if variability in two departments differs
Dept_a<-c(10,12,11,13,12,11)
Dept_b<-c(8,9,7,10,6,9,)
[Link](dept_a,dept_b)
[Link]-SQUARE TEST(categorical Data)
Problem:Check if customer preference depends
on region
CODE:
Data<-matrix(c(30,20,25,20,30,25),
Nrow=2,byrow=TRUE)
Rownames(data)<-c(“urban”,”rural”)
Colnames(data)<-
c(“product_A”,”product_B”,”product_c”)
Data
[Link](data)
[Link]-WAY ANOYA
Problem: Compare scores under 3 teaching
methods
Code:
Socres<-c(70,75,78,72,80,82,85,88,65,68,70,72)
Method<-factor(rep(c(“a”,”b”,’c”),each=4))
Model1<-aov(scores~method)
Summary(model1)
[Link]-WAY ANOVA
Problem:Effect of teaching Method (A,B)
Study hours(Low,High)
Code:
Scores<-c(70,75,80,85,78,82,88,90)
Method<-factor(rep(c(“a”,”b”),each=4))
hours<-factor(rep(c(“Low”,”High”),times=4))
model2<-aov(scores~method*hours)
summary(model2)
[Link](IMPORTANT FOR
PRACTICAL)
Code:
scores <- c(70, 75, 80, 85,
78, 82, 88, 90)
method <- factor(rep(c("a", "b"), each = 4))
hours <- factor(rep(c("Low", "High"), times = 4))
model2 <- aov(scores ~ method * hours)
summary(model2)
boxplot(scores -method,main=”scores by
method”)
[Link](hours,method,scores)
Date:13.05.2026
8) Fitting binomial distribution to data
Problem statement:
A manufacturing company inspected 200 batches
of electronics components.
The number of defective items in each batch ic
recorded below.
Tasks:
1)estimate parameters n and p
2)fit the binomial distribution
3)compute expected value
4)compare observed and expected frequency
Code:
x <- 0:4
f <- c(18,42,66,48,26)
N <- sum(f)
N
mean_x <- sum(x*f)/N
mean_x
n <- 4
p <- mean_x/n
p
prob <- dbinom(x, size = n, prob = p)
prob
expected <- N * prob
expected
result <- [Link](
x = x,
observed_frequency = f,
probability = round(prob, 4),
expected_frequency = round(expected, 2)
)
print(result)
9)Fitting poisson distribution to data
Problem statement:
A hospital recorded the number of
emergency cases arriving per hour over 300
hours.
Assume the data follows as poisson
distribution.
Tasks:
1)Estimate lamda
2)Fit poissons distribution
3)compute expected frequencies
4)compare observed and expected
frequencies
Code:
x <- 0:6
f <- c(20,54,80,72,42,22,10)
N <- sum(f)
N
lambda <- sum(x * f) / N
lambda
prob <- dpois(x, lambda)
prob
expected <- N * prob
expected
result <- [Link](
x = x,
observed_frequency = f,
probability = round(prob, 4),
expected_frequency = round(expected, 2)
)
print(result)
barplot(
rbind(f,expected),
beside=TRUE,
[Link]=x,
col=c("light green","pink"),
main="observed vs expected frequencies",
xlab="number of emergency cases",
yalb="frequency"
)
legend(
"topright",
legend=c("observed","expected"),
fill=c("lightgreen","pink")
)
DATE:10-06-2026
[Link] a normal distribution to daily stock
returns (20,000 trading sessions )
Complete R programme with all plots
lower<-c(-5,-3,-1,1,3,5)
upper<-c(-3,-1,1,3,5,7)
freq<-c(420,2480,8760,5660,2040,640)
mid<-(lower+upper)/2
mid
N<-sum(freq)
N
mu<-sum(freq*mid)/N
mu
sigma<-sqrt(sum(freq*(mid-mu)^2)/N)
sigma
2.
lower_b <- c(-5, -3, -1, 1, 3, 5)
upper_b <- c(-3, -1, 1, 3, 5, 7)
prob <- pnorm(upper_b, mean = mu, sd = sigma)
-
pnorm(lower_b, mean = mu, sd = sigma)
expected <- N * prob
round(expected, 0)
result <- [Link](
class = c("-5:-3", "-3:-1", "-1:1", "1:3", "3:5",
"5:7"),
observed = freq,
expected = round(expected, 0)
)
result
mu <- sum(freq * mid) / N
mu
returns <- rep(mid, freq)
length(returns)
hist(
returns,
probability = TRUE, # corrected spelling
breaks = 30,
main = "Histogram of Daily Stock Returns",
xlab = "Return (%)"
)
curve(
dnorm(x, mean = mu, sd = sigma),
add = TRUE,
lwd = 3,
col = "red"
)