Code Monkey home page Code Monkey logo

dsc-poisson-distribution-lab's Introduction

Poisson Distribution - Lab

Introduction

In this lab, you will put your knowledge of the Poisson Distribution to use to solve some sample real-world problems!

Objectives

You will be able to:

  • Calculate the probabilities of certain events that follow a Poisson distribution

Instructions

Solve the following sample problems by using Python and your knowledge of the Poisson Distribution.

Getting Started

Good Data Scientists plan ahead! Since you're going to be solving Poisson Distribution problems in this lab, it's probably a good idea to write a function that calculates Poisson Probabilities for us first.

Recall that the Poisson Probability Formula is:

$$p(x) = \frac{\lambda^xe^{-\lambda}}{x!}$$

Write a generalized function that takes in the appropriate parameters and returns the Poisson Probability.

NOTE: You can use np.exp() to quickly calculate $e$, and math.factorial (from the math library, not numpy) to calculate factorials.

HINT: It's up to you whether or not you have your function calculate the value for lambda given $\mu$ and the interval, or whether you calculate lambda yourself beforehand and just pass it into the function.

import numpy as np
from math import factorial
def poisson_probability(lambd, x):
    pass

Question 1

A fireman fights, on average, 4 fires per month. What is the probability that a fireman is called to two different fires this week?

lambd_q1 = None
prob_q1 = None
print(prob_q1)  # Expected Output:  0.18393972058572117

Question 2

A car salesman sells an average of 4 cars per week. What is the probability they sell a car today?

lambd_q2 = None
prob_q2 = None
print(prob_q2)  # Expected Output: 0.32269606971871956

Question 3

A website makes an average of 50 sales per day. What is the probability that they make 3 sales in an hour?

lambd_q3 = None
prob_q3 = None
print(prob_q3)  # Expected Output: 0.18764840049328912

Question 4

A factory produces 250 cars per week (assume that the factory runs day and night all week with no down time). What is the probability that they produce 3 cars in the next hour?

lambd_q4 = None
prob_q4 = None
print(prob_q4)   # Expected Output: 0.1240136186052091

Question 5

The following table shows the number of houses sold by a realtor each week for the month of May. What is the probability that they sell 3 houses next week?

Week Houses Sold
1 6
2 2
3 5
4 4
mean_weekly_sales = None
lambd_q5 = None 
prob_q5 = None
print(prob_q5)  # Expected Output: 0.18250047186175347

Summary

In this lab, we got some practice making use of our knowledge of the Poisson Distribution to answer some real-world questions!

dsc-poisson-distribution-lab's People

Contributors

fpolchow avatar lmcm18 avatar loredirick avatar mas16 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

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.