Untitled
unknown
plain_text
4 years ago
2.7 kB
28
Indexable
setwd("C:/Users/jains/Desktop/Vit Pune/Sem 2/Labs/Data Science/Lab 2")
travel = read.csv("travelled_abroad_data.csv")
attach(travel)
#1. Find out the % of Indians in the sample
# who have traveled abroad using the data source
yesTravel = sum(Travelledabroad == "Y")
per1 = ((yesTravel / length(Sr..No.)) * 100)
per1
notTravel = sum(Travelledabroad == "N")
per2 = ((notTravel / length(Sr..No.)) * 100)
per2
#2. Treating this value as "p" , calculate the following probabilities
# a. What is the probability that in a
# randomly chosen sample of 10 persons, no one has traveled abroad.
1 - pnorm(66, mean=1, sd=10, lower.tail =TRUE, log.p = F)
# b. What is the probability that in a randomly chosen sample of
# 10 persons, exactly one has traveled abroad.
1 - pnorm(84, mean=9, sd=10, lower.tail =TRUE, log.p = F)
#c. What is the probability that in a randomly chosen sample of 10 persons,
# exactly two persons have traveled abroad.
1 - pnorm(84, mean=8, sd=10, lower.tail =TRUE, log.p = F)
#d. What is the probability that in a randomly chosen sample of 10 persons,
# exactly three persons have travelled abroad.
1 - pnorm(84, mean=7, sd=10, lower.tail =TRUE, log.p = F)
#e. What is the probability that in a randomly chosen sample of 10 persons,
# exactly four persons have travelled abroad.
1 - pnorm(84, mean=6, sd=10, lower.tail =TRUE, log.p = F)
#f. What is the probability that in a randomly chosen sample of 10 persons,
# exactly five persons have travelled abroad.
1 - pnorm(84, mean=5, sd=10, lower.tail =TRUE, log.p = F)
#g. What is the probability that in a randomly chosen sample of 10 persons,
# exactly six persons have travelled abroad.
1 - pnorm(84, mean=4, sd=10, lower.tail =TRUE, log.p = F)
#h. What is the probability that in a randomly chosen sample of 10 persons,
# exactly seven persons have travelled abroad.
1 - pnorm(84, mean=3, sd=10, lower.tail =TRUE, log.p = F)
#i. What is the probability that in a randomly chosen sample of 10 persons,
# exactly eight persons have travelled abroad.
1 - pnorm(84, mean=2, sd=10, lower.tail =TRUE, log.p = F)
#j. What is the probability that in a randomly chosen sample of 10 persons,
# all 10 persons have travelled abroad.
1 - pnorm(84, mean=1, sd=10, lower.tail =TRUE, log.p = F)
# 3. Plot the probability values as a Table / Bar graph and interpret
table(travel$Travelledabroad == "Y", travel$Travelledabroad == "N")
# 4. What is the probability that in the randomly chosen sample of 100 persons
# at least 59 have travelled abroad?
pnorm(84, mean=59, sd=100, lower.tail =TRUE, log.p = F)
Editor is loading...