0% found this document useful (0 votes)
33 views1 page

Lab05 Normal Distribution - Ipynb

This document explores the normal distribution and how to plot it with different means and standard deviations in Python. Random samples are generated from normal distributions and plotted. The mean and standard deviation are varied to show their effects on the distribution. Examples are given to calculate probabilities and cut-off scores for normally distributed data like exam scores.

Uploaded by

joumana.r.daher
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views1 page

Lab05 Normal Distribution - Ipynb

This document explores the normal distribution and how to plot it with different means and standard deviations in Python. Random samples are generated from normal distributions and plotted. The mean and standard deviation are varied to show their effects on the distribution. Examples are given to calculate probabilities and cut-off scores for normally distributed data like exam scores.

Uploaded by

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

{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":

[],"collapsed_sections":[]},"kernelspec":{"name":"python3","display_name":"Python
3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","source":
["**Objective:**\n","\n","In this Notebook we will explore the normal distribution,
how to plot its related figure with different mean and standard deviation.
"],"metadata":{"id":"lXljJbjX0Lf4"}},{"cell_type":"markdown","source":["# Importing
Librairies"],"metadata":{"id":"a6Cdu7OYZ-te"}},{"cell_type":"code","source":
["import numpy as np\n","import matplotlib.pyplot as plt\n","from scipy.stats
import norm\n","import scipy.stats"],"metadata":
{"id":"pkIs8vJDaGTf"},"execution_count":null,"outputs":[]},
{"cell_type":"markdown","source":["# Normal Distribution"],"metadata":
{"id":"My9jKzdFc4F1"}},{"cell_type":"code","source":["np.random.normal(100, 2)
#Random sample from a Normal Distribution with Mean = 100 and sd = 2"],"metadata":
{"id":"zx7EAb6l8TxL"},"execution_count":null,"outputs":[]},
{"cell_type":"code","source":["np.random.normal(100, 2, 10) # Get 10
samples"],"metadata":{"id":"KzCZoU5k8Veo"},"execution_count":null,"outputs":[]},
{"cell_type":"code","source":["np.round(np.random.normal(100, 2, 10),
2)"],"metadata":{"id":"lzX4EQCg8ZXY"},"execution_count":null,"outputs":[]},
{"cell_type":"code","source":["# Plot between -10 and 10 with .001 steps.\
n","x_axis = np.arange(-20, 20, 0.01)\n"," \n","# Calculating mean and standard
deviation\n","mean = np.mean(x_axis)\n","sd = np.std(x_axis)\n"," \n","# Ploting
the figure \n","plt.plot(x_axis, norm.pdf(x_axis, mean, sd))\
n","plt.show()"],"metadata":{"id":"nueUhtjFctv9"},"execution_count":null,"outputs":
[]},{"cell_type":"markdown","source":["## Changing the meand and std"],"metadata":
{"id":"O6UHbqW5lTtg"}},{"cell_type":"code","source":["# Trying different mean and
sd\n","mean=0\n","sd=2\n","plt.plot(x_axis, norm.pdf(x_axis, mean, sd))\n","\
n","plt.show()"],"metadata":{"id":"wcvCc96fdPsX"},"execution_count":null,"outputs":
[]},{"cell_type":"markdown","source":["## Examples"],"metadata":
{"id":"DVgzKvxHc9Qm"}},{"cell_type":"markdown","source":["**Example
1**"],"metadata":{"id":"YVIVIdC20HGv"}},{"cell_type":"markdown","source":["The tips
left by customers at a local restaurant are \n","normally distributed with a mean
equal to 12.00 dollars and \n","a standard deviation equal to 3.00 dollars. \n","\
n","What is the \n","probability that a customer will leave a tip of less than \
n","$8.00?"],"metadata":{"id":"LwwpRL1AeQwu"}},{"cell_type":"code","source":["#1st
method\n","norm(loc = 12 , scale = 3).cdf(8) # mean = loc, scale =
std"],"metadata":{"id":"48UQ8B77ydUD"},"execution_count":null,"outputs":[]},
{"cell_type":"code","source":["#2nd method\n","scipy.stats.norm.cdf(8, loc=12,
scale=3)"],"metadata":{"id":"91UT2ONTe_1Y"},"execution_count":null,"outputs":[]},
{"cell_type":"markdown","source":["**Example 2**"],"metadata":
{"id":"ZkmVcg7d0JBU"}},{"cell_type":"markdown","source":["An entrance exam for a
graduate program at a major \n","university produces scores that are normally \
n","distributed with a mean of 800 with a standard \n","deviation equal to 50. If
the school only wants to \n","admit the top 10 percent of students, what should the
\n","cut-off score for admittance be?"],"metadata":{"id":"IOsDGW-DjYQA"}},
{"cell_type":"code","source":[],"metadata":
{"id":"8sYVhgMZjRUB"},"execution_count":null,"outputs":[]}]}

You might also like