Code Monkey home page Code Monkey logo

dsc-1-09-13-normal-gaussian-distributions-lab's Introduction

Gaussian/Normal Distribution - Lab

Introduction

In this lab we shall learn how to generate random normal distributions in python. We shall look into visualising a histogram and building a density function using the formula as well as seaborn's built in functions.

Objectives

You will be able to:

  • Generate random normal distributions in Python with given parameters
  • Calculate the density function for normal distributions
  • Use seaborn to visualize distributions with histograms and density functions

A quick refresher!

Here's the formula for calculating normal distribution density function.

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 - use bin size = 20.

Get the bin positions and count for each bin

Refer to official documentation to view input and output options for plt.hist()

# Calculate a histogram for above data distribution

png

Calculate the density function (using above formula) with mu, sigma and bin information calculated above .

# Calculate the normal Density function 
density = None

Plot the histogram and density function

# Plot histogram along with the density function

png

Visualize the distribution using seaborn and plot the KDE

<matplotlib.axes._subplots.AxesSubplot at 0x1a19d4cda0>

png

Summary

In this lab we saw how to generate random normal distributions in python using numpy. We also looked into calculating the density for gaussian distributions using the general formula as well as seaborn's kde. We shall now move on to see how we can analyze such variables for answering analytical questions.

dsc-1-09-13-normal-gaussian-distributions-lab's People

Contributors

loredirick avatar peterbell avatar shakeelraja avatar

Watchers

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

dsc-1-09-13-normal-gaussian-distributions-lab's Issues

normed no longer supported?

Current documentation for pyplot.hist() seems to my novice eye that normed is unsupported. Says we're supposed to use the density argument instead. Sure enough, normed=True raises an error whereas density=True does not. Both plot a histogram that I can plot density on top of.

Loading Issues

When ever I am trying to load this lesson a red banner appears at the top and says that I don't have access to this lab. This has happened before and usually I just refresh the page and it's back to normal. Unfortunately, that isn't working this time. Can someone resolve this issue?

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.