SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
PRACTICAL NO.1
AIM: Program to execute the basic commands, array, list and frames in R programming
language.
Q1. Take any two variables a and b. Write a R-code to perform arithmetic operations on them.
R-CODE:
> a = 10
>b=5
> a+b
15
> a-b
> a*b
50
> a/b
> a%%b (a mod b) // Gives
remainder of first value with
second
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
> a^3
1000
> exp(a)
22026.47
> a = 25 ; sqrt(a)
> b = - 9 ; abs(b)
Q.2 Create two vectors p and q. Write a R code to perform Arithmetic
operations. p = c(1, 3, 4, 7, 5, 0, 11) and q = c(4, 11, 0, 8, 1, 2, 6)
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q.3 Create two vectors p and q. Write a R code to perform Relational
operations.
p = c(4, 2.2, 8, 6) and q = c(5, 10, 8, 6.6)
Q.4 Create two vectors p and q. Write a R code to perform Logical operations.
p = c(4, 2.2, 8, 6) and q = c(5, 10, 8, 6.6)
Q5. Write a R code to combine following data structures:
Name Age Vote
John 18 FALSE
Alex 19 TRUE
Jay 20 TRUE
Name Age Vote
Monisha 18 TRUE
Sam 21 TRUE
Rhea 19 TRUE
If we want to combine two data frames vertically, the column name of the two
data frames must be the same.
Result = rbind(df1, df2)
Q6. Write a R code to combine following data structures:
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Name Age Vote
Monisha 18 TRUE
Sam 21 TRUE
Rhea 19 TRUE
City Country
Mumbai India
Bengluru India
Toronto Canada
The cbind() function combines two or more data frames horizontally.
Result = cbind(df1, df2)
PRACTICAL NO.2
AIM: Program to create a Matrix and to perform the matrix operations.
Q.1. Create two matrices A and B. Write a R-code to perform mathematical operations.
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
3 4 5
6 7 8
9 10 11
3 6 9
4 7 10
5 8 11
R-code:
> A = matrix ( c(3:11),nrow=3,byrow="true" )
>A
[,1] [,2] [,3]
[1,] 3 4 5
[2,] 6 7 8
[3,] 9 10 11
> B = matrix ( c(3:11),nrow=3,byrow="false" )
>B
[,1] [,2] [,3]
[1,] 3 6 9
[2,] 4 7 10
[3,] 5 8 11
> A+B
[,1] [,2] [,3]
[1,] 6 10 14
[2,] 10 14 18
[3,] 14 18 22
> A-B
[,1] [,2] [,3]
[1,] 0 -2 -4
[2,] 2 0 -2
[3,] 4 2 0
> A%*%B
[,1] [,2] [,3]
[1,] 50 86 122
[2,] 86 149 212
[3,] 122 212 302
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
> A/B
[,1] [,2] [,3]
[1,] 1.0 0.6666667 0.5555556
[2,] 1.5 1.0000000 0.8000000
[3,] 1.8 1.2500000 1.0000000
>t(A)
[,1] [,2] [,3]
[1,] 3 6 9
[2,] 4 7 10
[3,] 5 8 11
> t(B)
[,1] [,2] [,3]
[1,] 3 4 5
[2,] 6 7 8
[3,] 9 10 11
Q.2. Write a R-Code to verify the following expressions for given matrices:
i) 2 2
( A+ B) = A + AB+BA +B
2
ii) ( AB )' =B ' A'
iii) (A2 )’ = (A’)2
Q.3. Write a R-Code to verify whether a given matrix is orthogonal?
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
PRACTICAL NO. 3
AIM: Program to execute the Statistical functions on the ungrouped / Raw data.
A): Measures of Central Tendency in R.
Q.1 Write a R code to calculate measures of central tendency of given data:
20, 30, 10 ,10, 25, 12
R-CODE:
> x = c(20, 30, 10 ,10, 25, 12)
> result1 = mean(x)
> print(result1)
[1] 17.83333
> result2 = median(x)
> print(result2)
[1] 16
> getmode = function(v)
{m = unique(v)
m[which.max(tabulate(match(x, m)))]
> result = getmode(x)
> print(result)
[1] 10
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Result: Mean = 17.83333, Median = 16, Mode = 10
Q.2 Write a R code to calculate measures of central tendency of given
marks obtained by 10 students: 97, 78, 57, 78, 97, 66, 87, 64, 87, 78
B) : Study of measures of Dispersion.
Q.1. write a R-Code to find the Range, IQR, Coefficient of range of Rainfall
measured during 9 days in millimeters: 29,19, 26,12, 24, 21, 36, 35, 33
R-Code:
> Rainfall = c(29,19,26,12,24,21,36,35,33)
> r = max(Rainfall) - min(Rainfall)
>r
[1] 24
> IQR(Rainfall)
[1] 12
> cr = ( max(Rainfall) - min(Rainfall) ) / ( max(Rainfall) + min(Rainfall) )
> cr
[1] 0.5
Result: Range=24, IQR=12, Coefficient of range=0.5
Q2. Write a R-Code to calculate Quartile deviation and Coefficient of QD for
given data: 12, 18, 35, 42, 50, 45, 20, 8
R-Code:
> x = c(12, 18, 35, 42, 50, 45, 20, 8)
> Q = quantile(x, probs = c(0.25,0.50,0.75) )
>Q
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
25% 50% 75%
16.50 27.50 42.75
> QD = ( Q[3] - Q[1]) / 2
> QD
75%
13.125
> CQ = ( Q[3] - Q[1] ) / ( Q[3] + Q[1] )
> CQ
75%
0.443038
Result: Quartile deviati on = 13.125, Coefficient of QD= 0.443038
Q3. Write a R-Code to calculate the Standard deviation, Variance of Rainfall
measured during 9 days: 29, 19, 26, 12, 24, 21, 36, 35, 33
R-Code:
> Rainfall = c (29,19,26,12,24,21,36,35,33)
> sd(Rainfall)
[1] 8.006941
> var(Rainfall)
[1] 64.11111
Result: Standard deviation = 8.006941, Variance of Rainfall = 64.11111
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
PRACTICAL NO. 4
AIM: To import the data from Excel / .CSV file and to perform the measures of central
tendency.
Q1. Import the given data from the .csv file. Write a R-code to calculate measures
of central tendency of marks for each subject.
Name Marks Marks (Maths)
(English)
Jay 30 40
Alex 25.5 50
Caroline 35 45.5
Esmita 45.5 25.5
Nick 45 33
Nimit 42.5 35
R-Code:
>dir()
> d = read.csv("Data.csv")
>d
Name Marks..English. Marks..Maths.
1 Jay 30.0 40.0
2 Alex 25.5 50.0
3 Caroline 35.0 45.5
4 Esmita 45.5 25.5
5 Nick 45.0 33.0
6 Nimit 42.5 35.0
> Mean = mean (d$Marks..English)
> Mean
37.25
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
> Median = median (d$Marks..English)
> Median
38.75
> Mode = mode(d$Marks..English)
> Mode
"numeric"
> getmode = function(v)
{m = unique(v)
m[which.max(tabulate(match(d$Marks..English, m)))]
> result = getmode(x)
> print(result)
> Mean = mean (d$Marks..Maths)
> Mean
38.16667
> Median = median (d$Marks..Maths)
> Median
37.5
> Mode = mode (d$Marks..Maths)
> Mode
"numeric"
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q2.
id name salary start_date dept
1 A 6000 2012-01-01 IT
2 B 5000 2013-09-23
Operations
3 C 6500 2014-11-15 IT
4 D 7300 2014-05-11 HR
5 E 8000 2015-03-27 Finance
6 F 5500 2013-05-21 IT
7 G 6500 2013-07-30 Operations
8 H 7900 2014-06-17 Finance
Read the given data and calculate:
Q1. Get the number of rows and columns.
Q2. Get the persons having maximum salary and minimum salary.
Q3. Get the people who joined on or after 2014.
Q4. Get the mean, median and mode of salary.
R-code:
>dir()
> data = read.csv("input.csv")
> print(data)
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
id name salary start_date dept
1 1 A 6000 2012-01-01 IT
2 2 B 5000 2013-09-23 Operations
3 3 C 6500 2014-11-15 IT
4 4 D 7300 2014-05-11 HR
5 5 E 8000 2015-03-27 Finance
6 6 F 5500 2013-05-21 IT
7 7 G 6500 2013-07-30 Operations
8 8 H 7900 2014-06-17 Finance
Q1.
print(ncol(data))
print(nrow(data))
[1] 5
[1] 8
Q2.
> Max = subset(data, salary == max(salary))
> print(Max)
id name salary start_date dept
5 5 E 8000 2015-03-27 Finance
> Min = subset(data, salary == min(salary))
> print(Min)
id name salary start_date dept
2 2 B 5000 2013-09-23 Operations
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q3.
> result = subset(data, as.Date(start_date) > as.Date("2014-01-01"))
> print(result)
id name salary start_date dept
3 3 C 6500 2014-11-15 IT
4 4 D 7300 2014-05-11 HR
5 5 E 8000 2015-03-27 Finance
8 8 H 7900 2014-06-17 Finance
Q4.
> Mean = mean(data$salary)
> Median = median(data$salary)
> Mode = mode(data$salary)
> print(Mean)
[1] 6587.5
> print(Median)
[1] 6500
> print(Mode)
[1] "numeric"
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
PRACTICAL NO. 5
AIM: To import the data from Excel / .CSV file and to perform the measures of
dispersion.
Q1. Import the given data from the .csv file. Write a R-code to calculate measures of
dispersion of marks for each subject.
Name Marks Marks (Maths)
(English)
Jay 30 40
Alex 25.5 50
Caroline 35 45.5
Esmita 45.5 25.5
Nick 45 33
Nimit 42.5 35
R-Code:
>dir()
> d = read.csv("Data.csv")
>d
Name Marks..English. Marks..Maths.
1 Jay 30.0 40.0
2 Alex 25.5 50.0
3 Caroline 35.0 45.5
4 Esmita 45.5 25.5
5 Nick 45.0 33.0
6 Nimit 42.5 35.0
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
> SD = sd(d$Marks..English)
> SD
8.383019
> Variance = var(d$Marks..English)
> Variance
70.275
> r = max(d$Marks..English) - min(d$Marks..English)
>r
20
> IQR(d$Marks..English)
13.125
> cr = ( max(d$Marks..English) - min(d$Marks..English) ) /
( max(d$Marks..English) + min(d$Marks..English) )
> cr
0.2816901
> SD = sd(d$Marks..Maths)
> SD
8.880691
> Variance = var(d$Marks..Maths)
> Variance
78.86667
> r = max(d$Marks..Maths) - min(d$Marks..Maths)
>r
24.5
> IQR(d$Marks..Maths)
10.625
> cr = ( max(d$Marks..Maths) - min(d$Marks..Maths) ) /
( max(d$Marks..Maths) + min(d$Marks..Maths) )
> cr
0.3245033
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
> cov(d$Marks..English, d$Marks..Maths) // indicates the relationship of
two variables
[1] -66
There exists a negative relationship between two subjects.
Q2. Import the given data from the .csv file.
i) Write a R-code to calculate measures of dispersion of salary of each employee.
ii) What is the relation between current salary and expected salary.
iii) Plot the relation between current salary and expected salary.
id name salary start_date dept exp_salary
1 A 6000 2012-01-01 IT 6000
2 B 5000 2013-09-23 Operations 8000
3 C 6500 2014-11-15 IT 7000
4 D 7300 2014-05-11 HR 10000
5 E 8000 2015-03-27 Finance 15000
6 F 5500 2013-05-21 IT 12000
7 G 6500 30-07-2013 Operations 9000
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
8 H 7900 2014-06-17 Finance 9500
i)
> SD = sd(d$salary)
> SD
1088.167
> Variance = var(d$salary)
> Variance
1184107
> r = max(d$salary) - min(d$salary)
>r
3000
> IQR(d$salary)
1575
> cr = ( max(d$salary) - min(d$salary) ) / ( max(d$salary) + min(d$salary) )
> cr
0.2307692
ii)
>cov(d$salary, d$exp_salary)
>cov
1443750
There exists a positive correlation
iii)
plot(col1 , col2)
There exists a positive correlation among current salary and
expected salary.
PRACTICAL NO. 6
AIM: To import the data from .CSV file and to calculate Skewness.
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q1. Import the given data from the .csv file. Write an R-code to
calculate the Skewness and Kurtosis of scores obtained by 9
candidates. Also plot the skewness.
Candidates Alex John Steve Nimita James Caroline Vansh David Sumati
Score 10 45.5 80 65 57.5 39.5 35 25 15
R-Code:
> dir()
"Pract 6 Data.csv"
> d = read.csv( "Pract 6 Data.csv")
>d
Candidates Score
1 Alex 10.0
2 John 45.5
3 Steve 80.0
4 Nimit 65.0
5 James 57.5
6 Caroline 39.5
7 Vansh 35.0
8 David 25.0
9 Sumati 15.0
> Mean = mean(d$Score)
> Median = median (d$Score)
> SD = sd(d$Score )
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
> Sk = ( 3 * ( Mean - Median ) ) / SD
> Sk
[1] 0.2438718
To Plot Skewness:
> x = c(10, 45.5, 80, 65, 57.5, 39.5, 35, 25, 15)
> plot(x, type="o", main = "Skewness")
> plot(x, ylab = "score", type="o", main = "Skewness")
> kurtosis(d$Score)
1.992505
Interpretation:
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
The value of Sk > 0, hence the score obtained by candidates is Positively
Skewed (Skewed to right side).
The coefficient of kurtosis < 3, hence distribution of score of candidates is
Platykurtic (Flat distribution).
Q2. Import the given data from the .csv file. Write an R-code to
calculate the Skewness and kurtosis of scores obtained by 7
candidates. Also plot the skewness.
Candidates Alex John Steve Nimita James Carolin Vansh
e
Score 10 20 30 50 40 30 20
> kurtosis(d$Score)
2.123961
Practical No- 07
AIM: Study of Hypothetical testing (Upper tailed & Lower tailed tests) in R.
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
qnorm: To get percentiles from a normal distribution with mean µ and standard
deviation σ. It is inverse of pnorm i.e. CDF (Cumulative Distribution Function).
(Note: No need to write theory in Journal, this is just for
understanding)
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q.1. Suppose the food label on a cookie bag states that there is at most 2 grams of
saturated fat in a single cookie. In a sample of 35 cookies, it is found that the mean
amount of saturated fat per cookie is 2.1 grams. Assume that the population standard
deviation is 0.25 grams. At a 0.05 significance level, can we reject the claim on the food
label?
Hypothesis:
The null hypothesis is H0 : μ 2
The Alternative hypothesis is H1 : μ = 2
R-Code:
xbar = 2.1 # sample mean
mu = 2 # hypothesized value
sigma = 0.25 # population standard deviation
n = 35 # sample size
z
[1] 2.3664
We then compute the critical value at 0.05 significance level.
# critical value (table value)
[1] 1.6449
z cal > z.alpha
Result:
The z-value 2.3664 is greater than the critical value of 1.6449
Hence at 0.05 significance level, we reject (null hypothesis) the claim that there is at
most 2 grams of saturated fat in a cookie.
So we accept H1
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q.2. Suppose the food label on a cookie bag states that there is at most 2 grams of
saturated fat in a single cookie. In a sample of 35 cookies, it is found that the mean
amount of saturated fat per cookie is 2.1 grams. Assume that the sample standard
deviation is 0.3 gram. At a 0.05 significance level, can we reject the claim on the food
label?
Hypothesis:
The null hypothesis is H0 : μ 2
The alternative hypothesis is H1 : μ = 2
R-Code:
xbar = 2.1 # sample mean
mu = 2 # hypothesized value
s = 0.3 # sample standard deviation
n = 35 # sample size
t=(xbarmu) / ( s/sqrt(n) )
t
[1] 1.9720
We then compute the critical value at 0.05 significance level.
alpha = 0.05
t.alpha=qnorm(1alpha)
t.alpha # critical value (table value)
[1] 1.6991
tcal > t.alpha
Result:
The t-value 1.9720 is greater than the critical value of 1.6991.
Hence at 0.05 significance level, we can reject (null hypothesis) the claim that there is
at most 2 grams of saturated fat in a cookie.
So we accept H1
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Practical No- 8
AIM: A. Study of R - Binomial distributions.
Functions for Binomial Distribution
Functions Description
dbinom(x, n, p) This function is used to find probability at a particular
value & generates pdf i.e. it finds: P(X = x)
x is the value at which the probability has to be found
out, n is the total number of trials and p is the
probability of success.
The function pbinom() is used to find the
pbinom(x, n, p) cumulative probability (cdf) of a data i.e. P(X <=
x)
qbinom(k, n, p) This function is used to find the nth quantile, that is if
P(X <= x) = k is given, it finds x.
Where k is the probability, n is the total number of
trials and p is the probability of success.
This function generates N random samples of a
particular probability.
rbinom(N, n, p)
Where N is numbers of samples (sample size), n is the
total number of trials, p is the probability of success.
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q.1 A fair coin is tossed 10 times. What is the probability of getting heads exactly 8
times? Generate pdf function for Binomial distribution in R.
R-Code:
> x = 1 : 10
> n = 8; p = 0.5
> y = dbinom(x, n, p)
> data.frame(y)
1 0.03125000
2 0.10937500
3 0.21875000
4 0.27343750
5 0.21875000
6 0.10937500
7 0.03125000
8 0.00390625
9 0.00000000
10 0.00000000
> plot(x, y, xlab='Success', ylab='Probability', type='h', col='Purple')
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q.2 A fair coin is tossed 10 times. What is the probability of getting heads at most 8
times (8 or less than)? Generate cdf function for Binomial distribution in R.
R-code:
> x = 1 : 10
> n = 8; p = 0.5
> y = pbinom(x, n, p)
> data.frame(y)
1 0.03515625
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
2 0.14453125
3 0.36328125
4 0.63671875
5 0.85546875
6 0.96484375
7 0.99609375
8 1.00000000
9 1.00000000
10 1.00000000
> plot(x,y,xlab='Success', ylab='Probability', type='h', col='Green')
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q3. Write a R-code to calculate the 19th quantile of a Binomial distribution with 30
trials with the prob of success to 0.5.
R-code:
> k=19; n=30; p = 0.5
> y=qbinom(0.19, 30, 0.5)
>y
[1] 13
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q.4 Write a R-code to calculate the 6 random samples from 10 samples with
probability 0.5
R-code:
> N= 6; n=10; p=0.5
> x = rbinom(N, n, p)
>x
[1] 4 3 6 4 6 4
> plot(x,xlab='Samples',ylab='Probability',type='h',col='Purple')
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
AIM: B. Study of R - Normal distribution
Functions Description
dnorm (x, mean, sd) Normal density
(Probability Density Function)
pnorm (x, mean, sd) Normal distribution
(Cumulative Distribution Function)
qnorm (p1, mean, sd) Quantile function of the Normal distribution. Quantile
function gives value of x such that P(X <= x)=p1.
Hence, the qnorm function is the inverse of the pnorm
function.)
rnorm (N, mean, sd) Generates random sample of size N
· x is a vector of numbers.
· p is a vector of probabilities.
· N is the number of samples (sample size).
· Here, mean is the mean value of the sample data. Also, its default value is zero.
· sd is the standard deviation. Its default value is 1.
(Note: No need to write theory in Journal)
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q.1 Obtain the PDF for x, where x∈
(4,4), with mean 1 and standard deviation of 3.
R Code:
x = -4:4
mean = 1
sd = 3
y=dnorm(x, mean, sd)
plot(x, y)
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q.2 Obtain the CDF for x, where x∈
(4,4), with mean 1 and standard deviation of 1.
R-Code:
x = - 4:4
mean = 1
sd = 1
y=pnorm(x, mean, sd)
plot(x,y)
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
Q.3. Generate a sample of 8 observations of a standard Normal distribution with 0
mean and SD of 3.
R-Code:
N=6
mean = 40
sd = 2
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No
SYBSc (IT) - Sem IV Computer Oriented Statistical Techniques
y = rnorm(N, mean, sd)
Output:
40.85860 38.49336 42.20388 36.85891 37.73531 41.91403
R.K.Talreja College > plot(y,xlab='Probability',
ylab='Quantiles', type='h',col='Purple')
Page No