SIES College of Arts, Science and Commerce (Autonomous)
Sion (W), Mumbai – 400 022.
Department of Computer Science
CERTIFICATE
This is to certify that Mr/Ms Esai Seshan S Thanga Perumal of FYBSc [Computer Science],
Semester I , Seat No FCS2425025 has successfully completed the practicals and submitted
it online in Microsoft Teams for the subject of FMS (Fundamental Mathematics and
Statistics) as a partial fulfilment of the degree BSc(CS) during the academic year 2024-
2025.
________________ _______________
Faculty-in-charge Internal Examiner
Rajesh Yadav Rajesh Yadav
Date: College Seal
________________________________________________________
Practical 1
________________________________________________________________
1] DATA INPUT
- Arithmetic Operators
Explanation :
a = 23; b = 92
Two variables a and b are assigned the values 23 and 92, .
v=a+b
The variable v stores the result of adding a and b. This is simple addition:
v=23+92=115
w=a-b
The variable w stores the result of subtracting b from a. This is subtraction:
w=23−92=−69
x=a*b
The variable x stores the result of multiplying a and b. This is multiplication:
x=23×92=2116.
y=a/b
The variable y stores the result of dividing a by b. This is division:
y=23/92=0.25.
z=a^b
The variable z stores the result of raising a to the power of b. This is exponentiation:
z=2392≈1.900907×10125
v; w; x; y; z
Finally, the values of v, w, x, y, and z are printed to the console, showing the results of
each operation in the following order:
v = 115
w = -69
x = 2116
y = 0.25
z = 1.900907e+125
- Mathematical Functions
Explanation:
log(25)
This computes the natural logarithm (base e) of 25:
loge(25)=3.218876.
sqrt(625)
This calculates the square root of 625:
625=25
exp(50)
This computes the exponential function, which is e raised to the power of 50:
e50=5.184706×1021e^{50}
round(3.184628425)
This rounds the number 3.184628425 to the nearest integer:
round(3.184628425)=3
-Trigonometric Functions
Explanation :
sin(0)
This calculates the sine of 0 degrees:
sin(0∘)=0
cos(270)
This calculates the cosine of 270 degrees:
cos(270∘)=0.984382.
- Combinatiorial Function
Explanation ;
Choose(8,2) computes the number of ways to choose 5 items from 10 without regards bto
order , which is 28
2] Vector Operation
Explanation :
j <- c(25, 3, 61, 4, 52, 63): This creates a vector j with the values 25, 3, 61, 4,
52, 63. The c() function is used to combine these elements into a vector.
sort(j): This sorts the elements of the vector j in ascending order
rank(j): This calculates the ranks of the elements in the original vector j. The rank is based on the
element's position in the sorted vector, where the smallest value is ranked 1
log(j): This calculates the natural logarithm (log base e) of each element in the vector j
Explanation :
N = scan() allows the user to input values directly from the console. The user has input 14
values, and they are read into the variable N
After the scan() function reads the inputs, the output shows the list stored in N as:After the
scan() function reads the inputs, the output shows the list stored in N as: 3 4 2 1 3 4 5 2 1 6 7
94
3] Data Frames, Built in Function
Explanation :
A data frame named data_frame is created using the data.frame() function
The data frame includes three columns:training: A vector of character strings representing
different types of training ("strength", "stamina", and "other").pulse: A numeric vector
indicating the pulse rate associated with each training type (10, 15, and 20).duration: A
numeric vector indicating the duration (in minutes) for each type of training (60, 30, and 45).
The command data_frame prints out the created data frame, which consists of the following
rows and columns
Explanation :
s <- c(3, 4, 2, 1, 3, 4, 5, 2, 1, 6, 7, 4, 9, 9, 4):
This creates a vector s with the given numbers.u = table(s):
This line uses the table() function to count the frequency of each unique value in s and stores
it in u.u:
When u is called, it prints the frequency table of s. In this case, the numbers 1, 2, 3, 4, 5, 6, 7,
and 9 appear in the vector, with their respective counts shown.transform(u):
This line transforms the table into a data frame with two columns:s: The unique values in the
vector.Freq: The frequency of each value
Explanation :
abs(j) returns the absolute values.
cumsum(j) gives the cumulative sum of the vector
exp(j) computes the exponential function for each elements
log(j) returns the natural logarithm of each elements based on their in j
length(j) provides the number of elements in j
rank(j) assigns ranks to the elements based on their magnitude , handling ties by assigning
ranks
max(x) finds the maximum value.
min(x) finds the minimum value.
mean(x) calculates the average.
sort(x) sorts in ascending order.
sort(x, decreasing = TRUE) sorts in descending order
. var(x) computes the variance.
which(x == value )findsindices where the condition is met.
prod(y) computes the product of elements.
round() rounds numbers to the nearest integer.
Explanation :
byrow ="false" creates a matrix filled by columns.
byrow ="true" creates a matrix filled by rows.
t(A) transposes the matrix, swapping rows and columns.
diag(A) extracts the diagonal elements.
A[,3] extracts the 3rd column of the matrix
A[1,1] Accesses the element in the 1st row and 1st column of the new matrix A, which is 2
x <- c(1, 3, 5, 9, 10) creates a vector x with the elements 1, 3, 5, 9, and 10.
The function c() is used to combine or concatenate these values into a vector.
x on its own displays the contents of the vector
__________________________________________________
Practical 2
__________________________________________________
- Mean = Mean is the average of the given numbers and is
calculated by dividing the sum of given numbers by the total number
of numbers
The following data shows the weekly income of 10 families.
Calculate arithmetic mean
Family A B C D E F G H I J
Income 850 700 100 750 5000 80 420 2500 400 360
Formula : Mean=∑xi /n (Sum of all the observations / Total number
of observations)
Explanation :
1. x <- c(850, 700, 100, 750, 5000, 80, 420, 2500, 400, 360) creates a vector x containing the values:
850, 700, 100, 750, 5000, 80, 420, 2500, 400, and 360.
2. When you run mean(x), R calculates the mean (average) of the values in the vector x.
Find the arithmetic mean for the given values :- 9,8,6,4,7,5,3,7
Formula: Mean=∑xi /n (Sum of all the observations / Total number of
observations)
Explanation :
1.y <-c(9,8,6,4,7,5,3,7) creates a vector y containing the values: 9,8,6,4,7,5,3 and 7.
2. When you run mean(y), R calculates the mean(average) of the values in the vector y. Thus,
the mean (average) of the values in y is 6.125
Find the arithmetic mean of the following numbers
9,8,6,4,7,5,3,7
Formula : Mean=∑xi /n (Sum of all the observations / Total
number of observations)
Explanation :
1.x <- c(9, 8, 6, 4, 7, 5, 3, 7) creates a vector x containing the values: 9, 8, 6, 4, 7, 5, 3,
and 7.
2.When you run mean(x),R calculates the mean (average) of the values in the vector
x .Thus, the mean (average) of the values in x is 6.125.
Find the arithmetic mean for the given number using scan
function to create a vector for the following values
16,19,27,10,5,7,12,15,NA
Formula : Mean=∑xi /n (Sum of all the observations / Total
number of observations)
Explanation :
X = scan()prompts you to input a series of numbers.
In this case, you entered the values 16,19,27,10,5,7,12,15 and NA . After pressing enter on
the blank line, R stops reading inputs. When you run a ,it displays the vector x containing the
values: 16,19,27,10,5,7,12,15 and NA. Running mean(b,na.rm=T) calculates the mean
(average) of the values in the vector x Thus, the mean (average) of the values in b is 7.575.
- Median = The median is a measure of central tendency that
represents the middle value in a data set when the values are
arranged in order, either from lowest to highest or highest to lowest.
It is a way to describe the "middle" of a distribution.
Calculate the median for the following data
1100,1150,1080,1120,1200,1160,1400
Formula :
For odd:- Median=x(n+1/2 )
For even:- Median=[x(n/2 ) +x(n /2+1)]/2
Explanation :
1. x <- c(1100, 1150, 1080, 1120, 1200, 1160, 1400) creates a vector x with the values: 1100,
1150, 1080, 1120, 1200, 1160, and 1400.
2. y =sort(x) sorts the vector b in ascending order, resulting in the vector a: 1080, 1100,
1120, 1150, 1160, 1200, 1400.
3. When you run median (y), R calculates the median of the sorted vector y
Find the median of number 3,4,4,6,8,8,5,8,10.
Formula :
For odd:- Median=x(n+1/2 )
For even:- Median=[x(n/2 ) +x(n /2+1)]/2
Explanation :
1. x <- c(3, 4, 4, 6, 8, 8, 5, 8, 10)creates a vector x with the values: 3, 4, 4, 6, 8, 8, 5, 8, and
10.
2. y = sort(d)sorts the vector x in ascending order, resulting in the vector e: 3, 4, 4, 5, 6, 8, 8,
8, 10.
3. Running median(y) calculates the median of the sorted vector ‘ y’
Find the median for the given number with missing value
7,9,11,12,15,18,55
Formula :
For odd:- Median=x(n+1/2 )
For even:- Median=[x(n/2 ) +x(n /2+1)]/2
Explanation :
1. x <- c(7, 9, 11, 12, 15, 5, 5, 18, NA)creates a vector x containing the values
7,9,11,12,15,18,55 (which represents a missing value).
2. y = sort(x)sorts the vector x, excluding the NA value, resulting in the sorted vector y:
7,9,11,12,15,18,55
3. Running median(y), na.rm = TRUE)calculates the median of the sorted vector y, removing
the NA with na.rm = TRUE
- Mode = The mode is a measure of central tendency that represents the
most frequently occurring value in a dataset. It is the value or values that
appear most often. Unlike the mean and median, the mode can be used with
both numerical and categorical data.
Calculate the mode for the given values 2,7,10,15,10,7,8,10,2
Formula : mode = L+Δ1/Δ1+Δ2 x
Explanation :
1. a <- c(2, 7, 10, 15, 10, 7, 8, 10, 2)creates a vector x containing the values: 2, 7, 10, 15,
10, 7, 8, 10, and 2.
2. b = table(x)creates a frequency table of the elements in a. This table shows how many
times each value appears in a. The output of table(a) would look like this: names by b)[b
== max(b)]extracts the names (i.e., values) from the frequency table b where the
frequency is equal to the maximum frequency (i.e., the most frequent value).
max(b)returns the highest frequency in the table (which is 3, for the value 10).
b == max(y)creates a logical condition to find which values have the highest frequency.
names(b)[b == max(b)]returns the name(value)corresponding to the highest frequency.
Find the mode of 10.5,6.5,2.3,6.5,8.9,4,4
Formula : mode = L+Δ1/Δ1+Δ2 x
Explanation :
1. a <- c(10.5, 6.5, 2.3, 6.5, 8.9, 4, 4)creates a vector a with the values: 10.5, 6.5, 2.3, 6.5, 8.9, 4,
and 4.
2. b = table(b)creates a frequency table for the values in a. This table shows how many times
each value appears in a. The output of table(a) would look like this:
3. names(b)[b == max(b)]extracts the names(i.e., values) from the frequency table b where the
frequency is equal to the maximum frequency (i.e., the most frequent values)
Find the mode of following data with missing value:
20,30,31,25,30,31,30,32,NA.
Formula : mode = L+Δ1/Δ1+Δ2 x
Explanation :
1. a <- c(20, 30, 31, 25, 30, 31, 30, 32, NA)creates a vector a with the values: 20, 30, 31,
25, 30, 31, 30, 32, and NA (which represents a missing value).
2. b = table(a)creates frequency table for the values in a, excluding the NA value. The
table would count how many times each value appears in a.
3. names(b)[b == max(b)]extracts the names(i.e., values) from the frequency table b
where the frequency is equal to the maximum frequency (i.e., the most frequent value).
- Quartiles = Quartiles are values that divide a dataset into four
equal parts, each containing 25%of the data. They provide a way
to understand the spread and distribution of data by breaking it
into segments
Find the Q1,Q2&Q3 for given values:- [4,7,1,3,5,8,23]
Formula : Q1=(n+1)/4 Q3= 3(n+1)/4
Explanation :
1. p <- c(4, 7, 1, 3, 5, 8, 23)creates a vector p with the values: 4, 7, 1, 3, 5, 8, and 23
. 2. Q1 = quartile(x, 0.25)calculates the first quartile (Q1), which is the value below which
25% of the data falls. The result is 3.5. This means 25%of the data values are less than or
equal to 3.5.
3. Q2 = quartile(x, 0.50)calculates the second quartile (Q2), which is the median. The result
is 5. This means 50% of the data values are less than or equal to 5.
4. Q3 = quartile(x, 0.75)calculates the third quartile (Q3), which is the value below which
75% of the data falls. The result is 7.5. This means 75%of the data values are less than or
equal to 7.5
Find the quartile Q1,Q2&Q3 from following data.
(4,6,5,9,8,10,3)
Formula : Q1=(n+1)/4 Q3= 3(n+1)/4
Explanation :
1. p <- c(4,6,5,9,8,10,3)creates a vector p with the values4,6,5,9,8,10 and 3
. 2. Q1 = quartile(x, 0.25)calculates the first quartile (Q1), which is the value below which
25% of the data falls. The result is 3.5. This means 25%of the data values are less than or
equal to 10.
3. Q2 = quartile(x, 0.50)calculates the second quartile (Q2), which is the median. The result
is 5. This means 50% of the data values are less than or equal to 12.
4. Q3 = quartile(x, 0.75)calculates the third quartile (Q3), which is the value below which
75% of the data falls. The result is 16.5. This means 75%of the data values are less than or
equal to 16.5
_____________________________________________
Practical 3 :- Measure of dispersion
_____________________________________________
{The range in statistics for a given data set is the difference between
the highest and lowest values. The coefficient of range is a
normalized measure that shows the relative spread of the data. It is
calculated by dividing the difference between the maximum and
minimum values by their sum}
1] Create a vector with the following values 8,9,8,10,11 . Find the
range and coefficient of range
Formula:-
Range=Maximum Value−Minimum Value
Coefficient of Range=Maximum Value + Minimum Value/Maximum
Value−Minimum Value
Explanation :
a <-c(8, 9, 8, 10, 11) creates a vector a with the values: 8, 9, 8, 10,
and 11
l = max(a) calculates the maximum value in a, which is 11.
s = min(a) calculates the minimum value in a, which is 8.
r = l-s calculates the range, which is 11- 8 = 3.
cora = (l- s) / (l + s) calculates the coefficient of range: 0.1578947
2] Following distribution gives the number of houses and the
number of persons per hour. Find the range and coefficient of range
from following data.
NO.of 1 2 3 4 5 6 7 8 9 10
Person
NO.of 26 113 120 95 60 42 21 14 5 4
House
Formula:-
Range=Maximum Value−Minimum Value
Coefficient of Range=Maximum Value + Minimum Value/Maximum
Value−Minimum Value
Explanation :
a <-c(26,113,120,95,60,42,21,14,5,4) creates a vector a with the
values: 26,113,120,95,60,42,21,14,5 and 4
l = max(a) calculates the maximum value in a, which is 120.
s = min(a) calculates the minimum value in a, which is 4.
r = l-s calculates the range, which is 120-4 = 116.
cora = (l- s) / (l + s) calculates the coefficient of range : 0.9354839
3] Calculate the range and coefficient of range
Weight (kg) Class Mid-Values No. of
Boundaries student
60-62 59.5-62.5 61 5
63-65 62.5-65.5 64 18
66-68 66.5-68.5 67 42
69-71 68.5-71.5 70 27
72-74 71.5-74.5 73 8
Formula:-
Range=Maximum Value−Minimum Value
Coefficient of Range=Maximum Value + Minimum Value/Maximum
Value−Minimum Value
Explanation :
a <-c(59.5,62.5,66.5,68.5,74.5) creates a vector a with the values:
59.5,62.5,66.5,68.5 and 74.5
l = max(a) calculates the maximum value in a, which is 74.5.
s = min(a) calculates the minimum value in a, which is 59.5.
r = l-s calculates the range, which is 74.5-59.5=15.
cora = (l- s) / (l + s) calculates the coefficient of range : 0.1119403
{Quamtiles are values that divide a dataset into four equal parts.
They help to describe the spread and distribution of data by
providing insight into the data’s central tendency and variability. The
quantile deviation, also known as the semi-interquartile range,
measures the dispersion of the middle 50% of the data. It tells us
how spread out the data is around the median .The coefficient of
quartile deviation is a relative measure of dispersion, indicating the
spread of the middle 50% of data relative to the size of the quartiles}
4] The wheat production (in kg) of 20 acres is given as
1120,1240,1320,1080,1200,1440,1360,1680,1730,1785,1342,1960,
1880,1755,1720,1600,1470,1750,1885. Find the quartile deviation
and the coefficient of quartile deviation
Formula:-
Q1=[(n+1) /4] −th value Q3=3[(n+1) /4]−th value
Quartile Deviation=(Q3−Q1)/2
Coefficient of Quartile Deviation=(Q3+Q1)/(Q3−Q1)
Explanation:-
First Quartile (Q1): 1331 (25% of the data falls below this value).
Third Quartile (Q3): 1752.5 (75% of the data falls below this value).
Quartile Deviation (QD): 210.75, indicating the spread of the middle
50%ofthedata.
Coefficient of Quartile Deviation (coQD): 0.1367, reflecting that the
middle 50%ofthedatais spread out by approximately 13.67% of the
sum of Q1 and Q3
5] Find the quartile deviation and coefficient of quartile deviation.
X 5 15 20 50 70 82
F 8 12 20 10 7 3
Formula :-
Q1=[(n+1) /4] −th value Q3=3[(n+1) /4]−th value
Quartile Deviation=(Q3−Q1)/2
Coefficient of Quartile Deviation=(Q3+Q1)/(Q3−Q1)
Explanation :
First Quartile (Q1): 7.25. This means 25% of the data falls below 7.25
Third Quartile (Q3): 11.5. This means 75% of the data falls below
11.5.
Quartile Deviation (QD): 2.125. This measures the spread of the
middle 50%ofthedata.
It’s calculated as Q3−Q12\frac{Q3 Q1}{2}2Q3−Q1 .
Coefficient of Quartile Deviation (coQD): 0.2267. This relative
measure of dispersion indicates that the spread of the middle 50%of
the data is approximately 22.67% of the sum of Q1 and Q3.
{The standard deviation is the square root of the variance, which is
the average of the squared differences between each data point and
the mean.
Variance provides a measure of the variability or spread in a dataset,
with higher variance indicating more dispersion and lower variance
indicating less dispersion.
The coefficient of variation is the ratio of the standard deviation to
the mean, multiplied by 100 to express it as a percentage. It provides
a relative measure of variability compared to the mean of the
dataset}
6] Find the standard deviation, variance & the coefficient of variance
of following frequency distribution
Class 0-10 10-20 20-30 30-40 40-50
interval
Frequencies 14 23 27 21 15
Formula :
σ=1/N [ i=1∑N (xi −μ)2]
σ2=N1 i=1∑N (xi −μ)2
Coefficient of Variation (CV)=μ/σ ×100%
Explanation :
Dataset: x = {14, 23, 27, 21, 15}
Standard Deviation: Measures the spread of data points around the
mean
Variance: The square of the standard deviation, indicating the spread
of data.
Mean :The average value of the dataset.
Coefficient of Variation (CV): The standard deviation expressed as a
percentage of the mean, showing relative dispersion