0% found this document useful (0 votes)
3 views2 pages

Ids Exp13

Uploaded by

palakarora10107
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Ids Exp13

Uploaded by

palakarora10107
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

EXP-13

AIM- Using a dataset of student marks in a class, create a histogram to


visualize the distribution of scores. Adjust bin sizes and analyze the
distribution.
CODE:

import numpy as np

import matplotlib.pyplot as plt

import seaborn as sns

# Simulate student marks

np.random.seed(123)

marks = np.random.normal(loc=65, scale=15, size=100)

marks = np.clip(np.round(marks), 0, 100) # Clamp between 0 and 100

# Plot settings

plt.figure(figsize=(15, 12))

# Basic Histogram

plt.subplot(3, 1, 1)

plt.hist(marks, bins=10, color='skyblue', edgecolor='white')

plt.title('Histogram of Student Marks (10 Bins)')

plt.xlabel('Marks')

plt.ylabel('Frequency')

# Histogram with more bins (20)

plt.subplot(3, 1, 2)

plt.hist(marks, bins=20, color='lightgreen', edgecolor='white')

plt.title('Histogram with 20 Bins')

plt.xlabel('Marks')

plt.ylabel('Frequency')
# Histogram with fewer bins (5)

plt.subplot(3, 1, 3)

plt.hist(marks, bins=5, color='salmon', edgecolor='white')

plt.title('Histogram with 5 Bins')

plt.xlabel('Marks')

plt.ylabel('Frequency')

plt.tight_layout()

plt.show()

# Summary statistics

print("Summary Statistics:")

print(f"Mean: {np.mean(marks):.2f}")

print(f"Standard Deviation: {np.std(marks):.2f}")

print(f"Min: {np.min(marks)}, Max: {np.max(marks)}")

print(f"Quartiles: {np.percentile(marks, [25, 50, 75])}")

OUTPUT:

You might also like