Giter VIP home page Giter VIP logo

dsc-normal-distribution-lab's Introduction

The Normal Distribution - Lab

Introduction

In this lab, you'll learn how to generate random normal distributions in Python. You'll learn how to visualize a histogram and build a density function using the formula.

Objectives

You will be able to:

  • Use numpy to generate a random normal distribution
  • Calculate the density function for normal distributions with a Python function
  • Plot and interpret density plots and comment on the shape of the plot

A quick refresher!

Here's the formula for the normal distribution density function once more:

$$ \large N(x) = \dfrac{1}{\sigma \sqrt {2\pi }}e^{-\dfrac{(x-\mu)^2}{2\sigma^2}}$$

Here,

  • $\mu$ is the mean
  • $\sigma$ is the standard deviation
  • $\pi \approx 3.14159 $
  • $ e \approx 2.71828 $

First generate a normal distribution containing 5000 values with $\mu=14$ and $\sigma = 2.8$

# Generate a random normal variable with given parameters , n=5000

Calculate a normalized histogram for this distribution in matplotlib, with bin size = 20

Make sure to get the bin positions and counts for each of the obtained bins. You can use official documentation to view input and output options for plt.hist()

# Calculate a histogram for above data distribution

Use the formula to calculate the density function with $\mu$, $\sigma$ and bin information obtained before

# Calculate the normal Density function 
density = None

Plot the histogram and density function

# Plot histogram along with the density function

Visualize the distribution using seaborn and plot the KDE

# Use seaborn to plot the histogram with KDE

Summary

In this lab, you learned how to generate random normal distributions in Python using Numpy. You also calculated the density for normal distributions using the general formula as well as seaborn's KDE. Next, you'll move on to learn about the standard normal distribution and how normal distributions are used to answer analytical questions.

dsc-normal-distribution-lab's People

Contributors

cheffrey2000 avatar lmcm18 avatar loredirick avatar mas16 avatar peterbell avatar shakeelraja avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.