Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python programming! Problem Statement A probability distribution can be represented in Python as a dictionary, where the keys are the possible outcomes and the values

Python programming!image text in transcribed

Problem Statement A probability distribution can be represented in Python as a dictionary, where the keys are the possible outcomes and the values are their probabilities. For example, the dictionary ("heads " : 0.5, "tails". .5) can be used to represent the probability distribution of a fair coin flip We want to do two things with this representation of a probability distribution. Calculating with disjoint additivity (10 points) Our second task is to calculate the probability of a set of outcomes. Write a function called set-prob. Your function should take two parameters: a dictionary of the form described above, and a Python set object. Your function should return the real number between 0 and 1 which is the probability of the event corresponding to the set You may assume that the dictionary passed as input will follow Kolmogorov's laws, and also that the elements of the set will be elements of the dictionary. Bonus: For 1 extra point, write a function that will take a dictionary and one or more sets, and return the probability of any of those events occurring. (Hint: which set-theoretic operation corresponds to the logical OR?) Simulating a random process (20 points) Our first task is to simulate the experience whose probability distribution is described by a dictionary. Write a function called simulate. Your function should take one parameter, which is a dictionary of the form described above. Your function should return a randomly chosen outcome (dictionary key) according to the probability distribution described by the dictionary. You may use random.random() to generate random numbers from [0,1), but no other source of randomness You may assume that the dictionary passed as input will follow Kolmogorov's laws: that is, the keys represent mutually exclusive outcomes and the values sum to 1 Bonus: For 1 extra point, write a function that wll handle, in a reasonable way, a dictionary whose values do not sum to 1 Problem Statement A probability distribution can be represented in Python as a dictionary, where the keys are the possible outcomes and the values are their probabilities. For example, the dictionary ("heads " : 0.5, "tails". .5) can be used to represent the probability distribution of a fair coin flip We want to do two things with this representation of a probability distribution. Calculating with disjoint additivity (10 points) Our second task is to calculate the probability of a set of outcomes. Write a function called set-prob. Your function should take two parameters: a dictionary of the form described above, and a Python set object. Your function should return the real number between 0 and 1 which is the probability of the event corresponding to the set You may assume that the dictionary passed as input will follow Kolmogorov's laws, and also that the elements of the set will be elements of the dictionary. Bonus: For 1 extra point, write a function that will take a dictionary and one or more sets, and return the probability of any of those events occurring. (Hint: which set-theoretic operation corresponds to the logical OR?) Simulating a random process (20 points) Our first task is to simulate the experience whose probability distribution is described by a dictionary. Write a function called simulate. Your function should take one parameter, which is a dictionary of the form described above. Your function should return a randomly chosen outcome (dictionary key) according to the probability distribution described by the dictionary. You may use random.random() to generate random numbers from [0,1), but no other source of randomness You may assume that the dictionary passed as input will follow Kolmogorov's laws: that is, the keys represent mutually exclusive outcomes and the values sum to 1 Bonus: For 1 extra point, write a function that wll handle, in a reasonable way, a dictionary whose values do not sum to 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

Explain the various collection policies in receivables management.

Answered: 1 week ago

Question

What are the main objectives of Inventory ?

Answered: 1 week ago

Question

Explain the various inventory management techniques in detail.

Answered: 1 week ago

Question

Be familiar with the five basic ways to manage demand.

Answered: 1 week ago