Giter Site home page Giter Site logo

dsc-exponential-distribution-lab-nyc-ds-career-042219's Introduction

Exponential Distributions - Lab

Introduction

In this lesson, we'll make use of our newfound knowledge of the Exponential Distribution to answer some real-world questions!

Objectives

You will be able to:

  • Identify use cases for the exponential distribution
  • Calculate the probability of events that follow an exponential distribution

Getting Started

Before we can begin answering questions, it will probably be helpful to write some Python functions to quickly calculate the PDF and CDF for us.

For reference, here are the functions we'll want to implement.

Probability Density Function

$$PDF(x) = \lambda e^{- \lambda x}$$

Cumulative Density Function

$$CDF(x) = 1 - e^{- \lambda x}$$

In the cell below, complete the following functions.

import numpy as np

def exp_pdf(mu, x):
    pass
    
def exp_cdf(mu, x):
    pass

Great! Now, lets answer some questions.

Question 1

Steven is picking up a friend at the airport and their plane is late. The late flight is 22 minutes behind schedule. What is the probability that Steven will wait 30 minutes or less for his friend's flight to land?

# Expected Output: 0.7442708400868994

Question 2

The average student takes 44 minutes to complete a test. What is the probability that the fastest student in the class will take more than 38 minutes to complete the test?

# Expected Output: 0.4216261054870035

Question 3

The first customer of the day walks into a store 6 minutes after the store opens, on average. What is the probability that a customer shows up within 8 minutes of opening tomorrow?

# Expected Output: 0.7364028618842733

Question 4

The average interval that calls come in at a call center is 8 seconds. Plot the probability density function for a call happening at each second between 0 and 30 seconds (you can look at intervals of 0.5 seconds only.

What is the probability that the next call will happen in 7 seconds?

# Create a list to contain the pdf-values

    
# Create the plot

Question 5

The average earthquake in a given region happens every 7 weeks. What is probability that the next earthquake happens between 5 and 8 weeks from now?

Hint: This has both an upper and lower bound. You'll need to do some arithmetic to solve this one.

lower_bound = None
upper_bound  = None

print("Probability of earthquake before 5 weeks: {}%".format(lower_bound * 100))
print("Probability of earthquake before 8 weeks: {}%".format(upper_bound * 100))
print("Probability of earthquake between 5 - 8 weeks: {}%".format((upper_bound - lower_bound) * 100))

# Expected Output: 
# 
# Probability of earthquake before 5 weeks: 51.045834044304684%
# Probability of earthquake before 8 weeks: 68.10934426760295%
# Probability of earthquake between 5 - 8 weeks: 17.063510223298273%

Summary

In this lesson, you solved some real-world problems using the PDF and CDF for the Exponential Distribution!

dsc-exponential-distribution-lab-nyc-ds-career-042219's People

Contributors

fpolchow avatar lmcm18 avatar loredirick avatar mas16 avatar mathymitchell avatar mike-kane avatar

Watchers

 avatar  avatar  avatar  avatar  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.