Determine what does that ratio look like

Assignment Help Python Programming
Reference no: EM132298954

Assignment: Your simulation has to do with a bottle of vitamin pills. The bottle of pills starts out with N pills. (More on N in a moment.) You need to take one half of a pill each day. Each day, you pull out a pill from the bottle. Assume that any pill is the bottle is equally likely to be selected. If you pull out a whole pill, then you break that pill in half, swallow one of the halves, and put the other half back in the bottle. If you pull out a half pill, then you swallow that half pill.

We are interested in tracking the ratio of half pills to all the pills left in the jar. When you start with a new jar of N whole pills, there are no half pills at all, so the ratio is 0/N. When you get down to the last half pill in the jar (and no whole pills), then the ratio is 1/1. In between, what does that ratio look like? You are going to use random simulation to find out.

Start with a full jar of all whole pills. (Perhaps you should use an array for this; each entry in the array would be able to record if a pill was a half or a whole pill.) Randomly pick one of the pills left in the jar. If that pill is a whole pill, change it to a half pill. If that pill is a half pill, then remove that pill from the jar. (Somehow that array entry should "disappear," and the array should become shorter; there are different ways to do this.)

After each pill is chosen, determine the ratio of half pills to all pills. For a jar holding N whole pills, your simulation will randomly choose a pill 2*N times before the jar is empty.

Assume at first that your jar holds 50 pills. Fill up the jar with 50 whole pills, and empty that jar, keeping track of the ratio each time a pill is chosen. You should finish with an empty jar after 100 simulated days. Now do the same experiment 3 more times, yielding 400 data points.

Now take the average of the 4 data points on day 1, day 2, and so one for all 100 days. Now you will have 500 data points in 5 series.

Finally, do exactly the same thing, but this time use 100 pills. Again, do 4 repetitions, and then average.

Reference no: EM132298954

Questions Cloud

Write a script that will take an optional argument : You will write a script (or, scripts) that will take an optional argument, the directory to process. If not argument is supplied, use the current directory.
Training promote organizational effectiveness : Discuss how team building and inter group training promote organizational effectiveness
Reporting illegal or unethical actions : If not, what is the motivation for not reporting illegal or unethical actions, or what are other explanatory causes?
Role of division of labor and hierarchy ay honest tea : 1. Describe the role of division of labor and hierarchy ay Honest Tea.
Determine what does that ratio look like : CSC 540 We are interested in tracking the ratio of half pills to all the pills left in the jar. When you start with a new jar of N whole pills.
What are the resources of potential conflict in situation : a. Define Joe's problem. b. What are the resources of potential conflict in this situation?
Win-win strategy and win-lose strategy : Define and briefly explain the terms 'win-win strategy' and 'win-lose strategy'.
Assess and analyse the factors in international cooperation : 6IB006 Debating Globalization Assignment, University of Wolverhampton, UK. Assess and analyse the factors in 'international cooperation
Operational risks can be split into internal and external : Operational risks can be split into internal and external rosks. How can managers mitigate external risks? How can managers mitigate internal risks?

Reviews

Write a Review

Python Programming Questions & Answers

  Write the pseudo code and then code it in python

Write the pseudo code and then code it in Python. Write a function that has number of tosses as an input parameter. As usual, screen copy your code and results.

  Write a function named digit_count that takes one parameter

Write a function named digit_count that takes one parameter that is a number (int or float) and returns a count of even digits, a count of odd digits.

  Implement the triangle classification algorithm

Create a function that implements the Triangle Classification Algorithm. The algorithm has a lot of steps in it, but each step is simple.

  Write a recursive function that takes in a list

For this part of the homework, you will write a recursive function that takes in a list of positive integers as a parameter, and prints out the maximum value in that list. Your recursive function should be called maxInt().

  Interaction between the customer and the machine

In Python:Simulate a cash register or ATM including the interaction between the customer and the machine (i.e. assume that you are automating the responses)

  Write a python program that draw as pie chart

Write a python program that draw as pie chart go n frequent lettering word.txt file. The program, will Use tkinter to build an interface to input n

  Write program that creates an object of productionwork class

Write a program that creates an object of the ProductionWorker class and prompts the user to enter data for each of the object's data attributes.

  Aussie best car abcdeclares that based on its yearly sales

aussie best car abcdeclares that based on its yearly sales it will award a bonus as follows. the bonus will be equally

  Create a dictionary from the boys txt file

Create a dictionary from the boys.txt file that uses the boys' names as the key and the number of boys that were named that name as the value.

  Write a python function that accepts the number of feet

Write a python function that accepts the number of feet and head as input as returns the number of rabbits and number of chickens.

  Implement a voting test

Implement a voting test. The user enters their age and then the program prints either, "You must be 18 to vote" or "You are of voting age"

  How many different devices can you identify

CS6263: Introduction to Cyber Physical System Security - Project: Reconnaissance and Attack on ICS Networks - How many different devices can you identify?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd