0% found this document useful (0 votes)
33 views

Muskan Mini Project

Uploaded by

Abhishek kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Muskan Mini Project

Uploaded by

Abhishek kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

MINI PROJECT

Name:- Abhishek Kumar / Gorav Sharma


UID : 20BCS5576 / 20BCS7026
Subject :- STATISTICAL METHODS USING R
Section :- 12/ A

AIM:- Analyze a dataset related to student grades, calculating and comparing the arithmetic mean,
median, and mode.

Solution:-

we have the following dataset of student grades ( 85, 72, 90, 68, 78, 82, 95, 63, 77, 88, 70, 84,
92, 79, 73, 87, 91, 67, 81, 75, 89, 76, 86, 94 )

CODE:
# Define the dataset

grades_data <- data.frame(

Grade = c(85, 72, 90, 68, 78, 82, 95, 63, 77, 88, 70, 84, 92, 79, 73, 87, 91, 67, 81, 75, 89, 76, 86, 94)

# Create a histogram

hist(grades_data$Grade, breaks = 10, main = "Distribution of Student Grades", xlab = "Grade", ylab
= "Frequency", col = "skyblue")

# View the structure of the dataset

str(grades_data)

# Calculate the arithmetic mean of grades

mean_grade <- mean(grades_data$Grade)

# Calculate the median of grades

median_grade <- median(grades_data$Grade)

# Calculate the mode of grades

mode_grade <- as.numeric(names(table(grades_data$Grade))


[which.max(table(grades_data$Grade))])
# Print the results

cat("Arithmetic Mean:", mean_grade, "\n")

cat("Median:", median_grade, "\n")

cat("Mode:", mode_grade, "\n")

# Create a histogram

hist(grades_data$Grade, breaks = 10, main = "Distribution of Student Grades", xlab = "Grade", ylab
= "Frequency", col = "skyblue")

# Add lines for mean, median, and mode

abline(v = mean_grade, col = "red", lwd = 2, lty = 2) # Mean

abline(v = median_grade, col = "blue", lwd = 2, lty = 2) # Median

abline(v = mode_grade, col = "green", lwd = 2, lty = 2) # Mode

# Add legend

legend("topright", legend = c("Mean", "Median", "Mode"), col = c("red", "blue", "green"), lwd = 2,
lty = 2)

OUTPUT:
i) Arithmetic Mean (Average):
The arithmetic mean is calculated by adding up all the values in the dataset and
then dividing by the total number of values.

The mean, also known as the average, is calculated by adding up all the values in
a dataset and then dividing by the total number of values. It gives us a sense of
the central value around which the data points tend to cluster. The mean is
sensitive to outliers, meaning that extreme values can significantly influence its
value.

Arithmetic Mean = (Sum of all values) / (Number of values)


For our dataset: Arithmetic Mean = (85, 72, 90, 68, 78, 82, 95, 63, 77, 88, 70, 84,
92, 79, 73, 87, 91, 67, 81, 75, 89, 76, 86, 94 ) / 24
Arithmetic Mean ≈ 80.9967.

ii) Median:
The median is the middle value of a dataset when the values are arranged in
ascending order. If there is an even number of values, the median is the average
of the two middle values.

The median is the middle value of a dataset when the values are arranged in
ascending order. If there is an even number of values, the median is the average
of the two middle values. The median is less affected by extreme values (outliers)
compared to the mean, making it a robust measure of central tendency, especially
in skewed distributions.

First, we need to sort the dataset:


63,66,68,70,72,73,75,76,77,78,79,82,82,84,85,86,87,88,89,90,91,92,94,95
Since there are 24 values, the median will be the 12th value.
Median = 83.5

iii) Mode:
The mode is the value that appears most frequently in a dataset. Unlike the mean
and median, the mode is not affected by the actual values of the dataset; it only
reflects the frequency of occurrence of values. A dataset can have one mode,
more than one mode (multimodal), or no mode at all (if all values occur with
equal frequency).

In our dataset, the value 82 appears most frequently.


Mode = 82.
Comparing Between Mean, Median and mode:-

Sensitivity to
Measure Definition Outliers Calculation Method

Highly sensitive to
The average value of a dataset, outliers. Extreme
obtained by dividing the sum of values can
all values by the total number of significantly affect Mean = (Sum of all values) /
Mean values. its value. (Number of values)

The middle value of a dataset 1. Arrange values in ascending


when the values are arranged in order. 2. If the number of values is
ascending order. If the dataset odd, the median is the middle
has an even number of values, Less sensitive to value. If the number of values is
the median is the average of the outliers compared even, the median is the average of
Median two middle values. to the mean. the two middle values.

Not affected by
outliers. Reflects the
frequency of The mode is determined by
The value that appears most occurrence of identifying the value(s) with the
Mode frequently in a dataset. values. highest frequency of occurrence.

You might also like