DS4 1
DS4 1
: 210430116083
Experiment No: 4
Date:
Materials Used:
- Python environment (Anaconda, Jupyter Notebook, etc.)
- NumPy library
Procedure:
1. Introduction to Probability Distributions:
2. Probability theory is the branch of mathematics that deals with the study of random
events or phenomena. In probability theory, a probability distribution is a function that
describes the likelihood of different outcomes in a random process. Probability
distributions can be categorized into two types: discrete and continuous.
3. Discrete probability distributions are used when the possible outcomes of a random
process are countable and can be listed. The most commonly used discrete probability
distributions are Bernoulli, Binomial, and Poisson distributions.
4. Continuous probability distributions are used when the possible outcomes of a random
process are not countable and can take any value within a certain range. The most
commonly used continuous probability distributions are Normal and Exponential
distributions.
5. Each probability distribution has its own set of properties, such as mean, variance,
skewness, and kurtosis. Mean represents the average value of the random variable,
variance represents how much the values vary around the mean, skewness represents
the degree of asymmetry of the distribution, and kurtosis represents the degree of
peakedness or flatness of the distribution.
6. Probability distributions are widely used in fields such as finance, engineering, physics,
and social sciences to model real-world phenomena and make predictions about future
events. Understanding different probability distributions and their properties is an
important tool for analyzing data and making informed decisions.
#python
import numpy as np
import matplotlib.pyplot as plt
# Generate 1000 random numbers following a normal distribution with mean 0 and standard
deviation 1
normal_dist = np.random.normal(0, 1, 1000)
Information Technology 23
Enrolment No.: 210430116083
In this example, we generate 1000 random numbers following a normal distribution with mean
0 and standard deviation 1 using the `np.random.normal()` function. We then calculate the
mean and standard deviation of the distribution using the `np.mean()` and `np.std()` functions.
We also generate 1000 random numbers following a Poisson distribution with lambda 5 using
the `np.random.poisson()` function. We calculate the mean and variance of the Poisson
distribution using the `np.mean()` and `np.var()` functions.
We then plot the probability density function (PDF) and cumulative distribution function
(CDF) of both distributions using the `plt.hist()` and `plt.plot()` functions from the Matplotlib
library.
3. Exercise:
- Generate a dataset of your choice or given by faculty with a given probability distribution
using NumPy random library functions
- Plot the probability density function and cumulative distribution function for the generated
data
- Calculate the descriptive statistics of the generated data
Interpretation/Program/code:
import numpy as np
import matplotlib.pyplot as plt
Information Technology 24
Enrolment No.: 210430116083
mean = np.mean(normal_dist)
std_dev = np.std(normal_dist)
sorted_dist = np.sort(normal_dist)
cdf = np.arange(1, len(sorted_dist) + 1) / len(sorted_dist)
descriptive_stats = {
'Mean': np.mean(normal_dist),
'Standard Deviation': np.std(normal_dist),
'Minimum': np.min(normal_dist),
'Maximum': np.max(normal_dist),
'Median': np.median(normal_dist),
'25th Percentile': np.percentile(normal_dist, 25),
'75th Percentile': np.percentile(normal_dist, 75)
}
print(descriptive_stats)
Output:
Information Technology 25
Enrolment No.: 210430116083
Conclusion:
This lab practical provided an opportunity to explore and implement various probability
distributions using NumPy random library functions. By understanding and applying different
probability distributions, one can model real-world phenomena and make predictions about
future events. With the knowledge gained in this lab practical, student will be equipped to work
with probability distributions and analyze data in a wide range of fields, including finance,
engineering, and social sciences.
Quiz:
1. Which NumPy function can be used to generate random numbers from a normal
distribution?
a) numpy.random.uniform
b) numpy.random.poisson
c) numpy.random.normal
d) numpy.random.exponential
Information Technology 26
Enrolment No.: 210430116083
Suggested References:-
1. Dinesh Kumar, Business Analytics, Wiley India Business alytics: The Science
2. V.K. Jain, Data Science & Analytics, Khanna Book Publishing, New Delhi of Dat
3. Data Science For Dummies by Lillian Pierson , Jake Porway
Rubrics wise marks obtained
02 02 05 01 10
Information Technology 27