Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

19bcd7246 Lab4,5,6,7 Mat1011 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

APPLIED STAT (MAT1011)

LAB-4

SUBMITTED BY: SRIHARSHITHA DEEPALA


SLOT: L3
REG NO: 19BCD7246

CODE:
#Question-1
#(a)
M <- c(1:12)
dim(M) <-c(3,4)
M
#(b)
M<- matrix(c(1:12),nrow =3, ncol=4)
M
#(c)
m<- matrix(c(1:12),nrow =3, ncol=4 , dimnames=list(c("A","B","C")))
m
#(d)
t(M)
#(e)
rbind(A = c(1,4,7,10),B=c(2,5,8,11),C=c(3,6,9,12))
cbind(P = c(1,5,9), Q = c(2,6,10), R = c(3,7,11), S = c(4,8,12))
#(f)
rows = 4
cols = 3
r <- matrix(runif(n= rows*cols , min =1, max = 2),ncol = cols)
r
#(g)
M_mult <- M%*%r
M_mult

OUTPUT:
CODE:
#Question-2
#(a)
p <- c(1:40)
p
sample(p)
sample(p,5)
#(b)
sample(p,5,replace = TRUE, prob=NULL)
sample(p,5,replace = TRUE, prob=NULL)
sample(p,5,replace = TRUE, prob=NULL)
sample(p,5,replace = TRUE, prob=NULL)
sample(p,5,replace = TRUE, prob=NULL)
sample(p,5,replace = TRUE, prob=NULL)
sample(p,5,replace = TRUE, prob=NULL)
sample(p,5,replace = TRUE, prob=NULL)
sample(p,5,replace = TRUE, prob=NULL)
sample(p,5,replace = TRUE, prob=NULL)
#(c)
sample(c("H","T"),10,replace=TRUE)
sample(c("H","T"),10,replace=TRUE)
sample(c("H","T"),10,replace=TRUE)
sample(c("H","T"),10,replace=TRUE)
sample(c("H","T"),10,replace=TRUE)
sample(c("H","T"),10,replace=TRUE)
sample(c("H","T"),10,replace=TRUE)
sample(c("H","T"),10,replace=TRUE)
sample(c("H","T"),10,replace=TRUE)
sample(c("H","T"),10,replace=TRUE)
sample(c("H","T"),10,replace=TRUE)
sample(c("H","T"),10,replace=TRUE,prob=c(90,10))
#(d)
choose(40,5)
#(e)
factorial(5)
OUTPUT:
APPLIED STAT (MAT1011)
LAB-5

SUBMITTED BY: SRIHARSHITHA DEEPALA


SLOT: L3
REG NO: 19BCD7246

CODE:
#Question-1

#(a)

dbinom(3,5,0.95)

#(b)

dbinom(0:5,5,0.95)
OUTPUT:
CODE:
#Question-2
dbinom(x = 0:20,size = 20,prob = 0.2)

OUTPUT:

CODE:
#Question-3
dbinom(x = 0:100,size = 100,prob = 0.01)

OUTPUT:
CODE:
#Question - 4

par(mfrow = c(3,1))
plot(0:5, dbinom(0:5,5,0.95),
xlab ="No.of ready terminals",
ylab ="P(X = x)", type = "h",
main = "Ready Terminals, n = 5, p = 0.95")

plot(0:20, dbinom(0:20, 20, 0.2),


xlab = "No. of Defectives",
ylab = "P(X = x)", type = "h",
main = "Defectives, n = 20, p = 0.2")

plot(0:100, dbinom(0:100, 100, 0.01),


xlab = "No. of bits in error",
ylab = "P(X = x)", type = "h",
main = "Bits in error, n = 100, p = 0.01")

OUTPUT:
CODE:
#Question-5
#(Q.No-1 part)

dbinom(3,5,0.95)
1-pbinom(3,5,0.95)

#(Q.No-2 part)

dbinom(4,20,0.2)
1-pbinom(4,20,0.2)

P <- pbinom(0:5,5,0.95)
round(P,digits =4)
Q <- pbinom(0:20,20,0.2)
round(Q,digits =4)
OUTPUT:

CODE:
#Question-6
#(a)

P <- 1-pbinom(9,15,0.4)
P
#(b)
P <- pbinom(8,15,0.4)-pbinom(2,15,0.4)
P

#(c)
dbinom(5,15,0.4)

OUTPUT:
APPLIED STAT (MAT1011)
LAB-6

SUBMITTED BY: SRIHARSHITHA DEEPALA


SLOT: L3
REG NO: 19BCD7246

CODE:
#Question - 1

dpois(6,lambda=4)

OUTPUT:
CODE:
#Question - 2
#(a)
n <- 400
p <- 0.005
lambda <- n*p
dpois(1,lambda)

#(b)
ppois(3,lambda)

OUTPUT:

CODE:
#Question - 3
n <- 8000
p <- 0.001
lambda <- n*p
ppois(6,lambda)

OUTPUT:

CODE:
#Question - 4
#(a)
dpois(5,lambda = 3)

#(b)
ppois(2,lambda = 3)

#(c)
1-ppois(1,lambda = 3)
OUTPUT:

CODE:
#Question - 5
#(a)
dbinom(10,10,0.99)

#(b)
#first two attempts will fail and next 10 attempts will succeed
P <-(1-0.99)^2*dbinom(10,10,0.99)
P
OUTPUT:

CODE:
#Question - 6
#(a)
pgeom(75,prob=0.001,FALSE)

#(b)
dgeom(20,prob = 0.001,FALSE)

#(c)
pgeom(10,prob = 0.001,TRUE)
OUTPUT:

CODE:
#Question - 7

#Q2 graph
par(mfcol = c(2,2))
plot(0:400, dpois(0:400, 0.005*400),
xlab = "Random Variables",
ylab = "P(X = x)", type = "p",
main = "Random Variables vs Probability Distribution Function (Q-2)")

#Q4 graph
plot(0:5, dpois(0:5,3),
xlab = "Random Variables",
ylab = "P(X = x)", type = "p",
main = "Random Variables vs Probability Distribution Function (Q-4)")
#Q5 graph
plot(0:10, dbinom(0:10,10,0.990),
xlab = "Random Variables",
ylab = "P(X = x)", type = "p",
main = "Random Variables vs Probability Distribution Function (Q-5)")

#Q6 graph
plot(0:75, dgeom(0:75,0.001,FALSE),
xlab = "Random Variables",
ylab = "P(X = x)", type = "p",
main = "Random Variables vs Probability Distribution Function (Q-6)")

OUTPUT:
APPLIED STAT (MAT1011)
LAB-7

SUBMITTED BY: SRIHARSHITHA DEEPALA


SLOT: L3
REG NO: 19BCD7246

CODE:
# Question - 1
#(a)
a <- pnorm(125,100,15,lower.tail=TRUE)
a

#(b)
b <-pnorm(110,100,15,lower.tail=FALSE)
b

#(c)
pnorm(125,100,15,lower.tail = TRUE)-pnorm(110,100,15,lower.tail=TRUE)
#(d)
qnorm(0.25)

#(e)
qnorm(0.25,2,3)

#(f)
qnorm(0.25,100,15,TRUE)

#(g)
qnorm(0.25,100,15,FALSE)

#(h)
percentile <- qnorm(0.25)*15+100
percentile
OUTPUT:
CODE:
p <-rnorm(20,572,51)
p
mean(p)
sd(p)

OUTPUT:

CODE:
p <-rnorm(20,572,51)
p
mean(p)
sd(p)
std_dev <-sd(p)
M <- mean(p)
windows()
hist(p,xlab = "Data from normal distribution", freq = FALSE, main="Histogrm
with normal curve and smooth curve.")
curve(dnorm(x,mean =M,sd=std_dev),col = 'green',lwd = 2,add = TRUE)
lines(density(p,adjust = 1),col = 'red',lwd = 2)

OUTPUT:

You might also like