Giter Site home page Giter Site logo

dsc-skewness-and-kurtosis-lab's Introduction

Skewness and Kurtosis - Lab

Introduction

In this lab, you'll calculate skewness and kurtosis for a given dataset in SciPy using Python.

Objectives

You will be able to:

  • Calculate and interpret values of skewness and kurtosis

Bring in SciPy

In the previous lesson, you have seen formulas to calculate skewness and kurtosis for your data. SciPy comes packaged with these functions and provides an easy way to calculate these two quantities, see scipy.stats.kurtosis and scipy.stats.skew. Check out the official SciPy documentation to dig deeper into this. Otherwise, simply pull up the documentation within the Jupyter notebook using shift+tab within the function call or pull up the full documentation with kurtosis? or skew?, once you have imported these methods from the SciPy package.

You'll generate two datasets and measure/visualize and compare their skew and kurtosis in this lab.

# Import required libraries
import numpy as np
import matplotlib.pyplot as plt

from scipy.stats import kurtosis, skew

Take 1

  • Generate a random normal variable x_random in NumPy with 10,000 values. Set the mean value to 0 and the standard deviation to 2.
  • Plot a histogram of the data, set bins to auto (default).
  • Calculate the skewness and kurtosis for this data distribution using the SciPy functions.
  • Record your observations about the calculated values and the shape of the data.
x_random = None

# Skewness = -0.0025781248189666343
# kurtosis = 0.03976806960642154
Skewness = -0.01442829768952485
kurtosis = 0.016922288438713018

png

# Your observations here 


#
#
#

Take 2

Let's generate another distribution

x = np.linspace( -5, 5, 10000 )
y = 1./(np.sqrt(2.*np.pi)) * np.exp( -.5*(x)**2  )  # normal distribution
  • Plot a histogram for data $y$, and set bins to auto (default).
  • Calculate the skewness and kurtosis for this data distribution using the SciPy functions.
  • Record your observations about the calculated values and the shape of the data.
# Skewness = 1.109511549276228
# kurtosis = -0.31039027765889804
Skewness = 1.109511549276228
kurtosis = -0.31039027765889804

png

# Your observations here 

#
#
#

Summary

In this lesson we learned how to calculate, visualize, and analyze the skewness and kurtosis for any given distribution. We worked with synthetic datasets at this stage to get the concepts cleared up. Later we will try these techniques on real datasets to see if they are fit for analysis (or not).

dsc-skewness-and-kurtosis-lab's People

Contributors

shakeelraja avatar loredirick avatar mas16 avatar fpolchow avatar lmcm18 avatar mathymitchell avatar

Watchers

James Cloos 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.