** USING MATLAB TO PROGRAM
The main objective of this lab is to create a game that involves betting on the sum of two dice. The player will start out with some initial total amount of money. During each round, the player can bet some money that the sum of the two dice will be equal to a certain number. If the player wins the bet, that player adds the amount of the bet to his or her current total. If the player loses the bet, that player subtracts the amount of the bet from his or her current total. The game ends when the player decides to quit or when the player is out of money. After the game has finished, the main program should display a pie chart that shows the percentage of times that the sum of the dice equaled each of the possible sum values.
We can use this to calculate the probabilities of each sum.
P(sum=2) = 1/36 = 0.0278
P(sum=3) = 2/36 = 0.0556
P(sum=4) = 3/36 = 0.0833
P(sum=5) = 4/36 = 0.1111
P(sum=6) = 5/36 = 0.1389
P(sum=7) = 6/36 = 0.1667
P(sum=8) = 5/36 = 0.1389
P(sum=9) = 4/36 = 0.1111
P(sum=10) = 3/36 = 0.0833
P(sum=11) = 2/36 = 0.0556
P(sum=12) = 1/36 = 0.0278
We can use these theoretical probabilities as a basis of comparison when looking at the observed dice sum outcomes when playing the game.
Helpful Code
We can use a single while loop to continue to play the game until a certain condition is met. The code below shows a while loop that checks the value of a single variable called running. The code inside of the while loop will continue to execute as long as the running variable evaluates to true. In this case, when count is less than or equal to zero, we stop the main loop. We can use a similar approach to set up our main game loop.
count = 100;
running = true;
while(running)
count = count – 10;
if count <= 0
running = false;
end
end
Rolling dice can be done many ways, in this case, since we are looking for random rolls, we can use the randi() function. An example of this can be implemented with the following code:
my_roll = randi(6);
Implementation
Here's an approach that will work for implementing the game:
In: Computer Science
In: Statistics and Probability
Part B: Ballistic Pendulum
The questions n the very bottom is pertaining to a lab over projectile motion and its asking to use equations on the bottom to find velocity. Below are the procedures of the lab and the necessary data to find initial velocity.
Calculate the average value for the vertical distance h the pendulum-ball system has risen after the collision. This is the difference between the height of CM at its highest point and that at its lowest point.
1
Gain in Potential Energy = Loss in Kinetic Energy
Potential Energy at highest point =
Mass M of pendulum: 240 grams Mass m of ball: 64 g
| Trials | 1 | 2 | 3 | 4 | Avg |
| Angle of CM at its lowest point | 0o | 0o | 0o | 0o | |
| Angle of CM at its highest point | 33o | 35o | 40o | 40o | |
| Angle (highest - lowest) | 33o | 35o | 40o | 40o | |
| Distance L from pivot to CM of pendulum | .285 meters | .284 meters |
Kinetic Energy at lowest point =
Height h from angle and L= ?
Velocity V1 of pendulum as it starts to swing=?
Velocity Vo of ball=?
Calculate the average value for the vertical distance h the pendulum-ball system has risen after the collision. This is the difference between the height of CM at its highest point and that at its lowest point.
Using Energy balance and momentum conservation equations, calculate the initial velocity V0 of the projectile.
In: Physics
Problem 11-30 (Algorithmic)
A large insurance company maintains a central computing system that contains a variety of information about customer accounts. Insurance agents in a six-state area use telephone lines to access the customer information database. Currently, the company's central computer system allows three users to access the central computer simultaneously. Agents who attempt to use the system when it is full are denied access; no waiting is allowed. Management realizes that with its expanding business, more requests will be made to the central information system. Being denied access to the system is inefficient as well as annoying for agents. Access requests follow a Poisson probability distribution, with a mean of 30 calls per hour. The service rate per line is 8 calls per hour.
| j | Pj |
|---|---|
| 0 | |
| 1 | |
| 2 | |
| 3 |
In: Statistics and Probability
We are in casino playing roulette, American version. We decided to play only red/black, i.e. to bet on red only.
We will use the Martingale strategy. A game starts with the first bet of 1 chip. If you win the game is over. You won a game. If you loose, you double your bet. You proceed to double your bet till you finally win or if you loose 6 in a row. Either way that concludes one game. You start a new game by betting 1 chip again.
Fill up the following table
|
Game ended as we |
Bet (no. of chips) |
Casino pays |
Profit |
Probability of this happening |
|
Won in the 1st round |
||||
|
Won in the 2nd round |
||||
|
Won in the 3rd round |
||||
|
Won in the 4th round |
||||
|
Won in the 5th round |
||||
|
Won in the 6th round |
||||
|
Lost 6 in a row |
From the table compute the probability of winning in a game. A game has two outcomes therefore it is a
______________________ experiment.
We made a PDF table for the game. Include the gain function.
|
Sample Space |
Win |
Loose |
|
|
||
|
Gain |
Now we decide to play the game 12 times. Fill the table below.
|
Number of games won (out of 12) |
Probability |
Gain |
|
0 |
||
|
1 |
||
|
2 |
||
|
3 |
||
|
4 |
||
|
5 |
||
|
6 |
||
|
7 |
||
|
8 |
||
|
9 |
||
|
10 |
||
|
11 |
||
|
12 |
For this table we used __________________ distribution
What is the probability of winning(making a profit) after 12 games?
What is the expectation of the gain after 12 games?
Should we Gamble?
Yes or No
In: Statistics and Probability
Lottery
One state lottery game has contestants select 5 different numbers from 1 to 45. The prize if all numbers are matched is 2 million dollars. The tickets are $2 each.
1) How many different ticket possibilities are there?
2) If a person purchases one ticket, what is the probability of winning? What is the probability of losing?
3) Occasionally, you will hear of a group of people going in together to purchase a large amount of tickets. Suppose a group of 30 purchases 6,000 tickets.
a) How much would each person have to contribute?
b) What is the probability of the group winning? Losing?
4) How much would it cost to “buy the lottery”, that is, buy a ticket to cover every possibility? Is it worth it?
5) Create a probability distribution table for the random variable x = the amount won/lost when purchasing one ticket.
6) In fair games, the expected value will be $0. This means that if the game is played many…many times, then one is expected to break even eventually. This is never true for Casino and Lottery games. Find the expected value of x = the amount won/lost when purchasing one ticket.
7) Interpret the expected value. See section 4.2 in the textbook for an example on how to interpret the expected value.
8) Fill in the following table using the expected value.
|
Number of tickets purchases |
Expected net winnings for the lottery |
Expected netwinnings of a fair game (expected value = 0) |
|
100,000 |
$0 |
|
|
500,000 |
$0 |
|
|
1,000,000 |
$0 |
|
|
5,000,000 |
$0 |
In: Statistics and Probability
5. Six students are going on a road trip in which they will live closely together. Where they are going, there is a disease which spreads easily among people who live close together. The value of the trip to a student who does not get the disease is 6. The value of the trip to a student who gets the disease is 0. There is a vaccination against the disease. The vaccination costs different amounts for different students (they have different health plans). Let's call the students 1, 2, 3, 4, 5 and 6 respectively. The vaccination costs 1 for student 1; it costs 2 for student 2; etc.... If a student gets vaccinated, she will not get the disease. But, if she is not vaccinated then her probability of getting the disease depends on the total number in the group who are not vaccinated. If she is the only person not to get vaccinated then the probability that she gets the disease is 1/6. If there is one other person who is not vaccinated (i.e., two in all including her) then the probability that she gets the disease is 2/6. If there are two other people who are not vaccinated (i.e., three including her) then the probability that she gets the disease is 3/6, etc.. The students decide individually and simultaneously whether to get the vaccination and their goal is to maximise their payoffs. a) Explain with reasons whether or not it is a Nash Equilibrium for students 1,2,3 and 4 to get vaccinated and students 5 and 6 not to get vaccinated. [3 points] b) Which students have strictly or weakly dominated strategies? [3 points]
In: Economics
Problem 11-30 (Algorithmic)
A large insurance company maintains a central computing system that contains a variety of information about customer accounts. Insurance agents in a six-state area use telephone lines to access the customer information database. Currently, the company's central computer system allows three users to access the central computer simultaneously. Agents who attempt to use the system when it is full are denied access; no waiting is allowed. Management realizes that with its expanding business, more requests will be made to the central information system. Being denied access to the system is inefficient as well as annoying for agents. Access requests follow a Poisson probability distribution, with a mean of 57 calls per hour. The service rate per line is 35 calls per hour.
| j | Pj |
|---|---|
| 0 | |
| 1 | |
| 2 | |
| 3 |
In: Statistics and Probability
11) A student takes a true-false test that has 20 questions and guesses randomly at each answer. Let X be the number of questions answered correctly. Find P(19 or more)
A) 0.1719
B) 0.006
C) 0.00002
D) 0.07
12) It is estimated that 35% of households own a riding lawn mower. A sample of 10 households is studied. What is the probability that more than 7 of these own a riding lawn mower? (hint: you can use binomial or independent probability.)
15) A group of 10 male and 4 female students is talking about going out for pizza. If 50% of the male students actually go and 25% of the female students actually go, find the probability that a random student who goes out for pizza is female.
16) A lot of 1000 components contain 300 that are defective. Two components are drawn at random and tested. Let A be the event that the first component drawn is defective, and let B be the event that the second component drawn is defective. Find P(A and B).
17) A paint manufacturer discovers that the mean volume of paint in a gallon-sized
pail is 1 gallon with a standard deviation of 0.1 gallons. The paint volumes are
approximately bell-shaped (normally distributed). Estimate the percent of pails
with volumes between .70 gallons and 1.30 gallons.
21) The average length of crocodiles in a swamp is 10.5 feet. If the lengths are normally distributed with a standard deviation of 1.3 feet, find the probability that a crocodile is more than 10 feet long.
In: Statistics and Probability
One state lottery game has contestants select 5 different numbers from 1 to 45. The prize if all numbers are matched is 2 million dollars. The tickets are $2 each.
1) How many different ticket possibilities are there?
2) If a person purchases one ticket, what is the probability of winning? What is the probability of losing?
3) Occasionally, you will hear of a group of people going in together to purchase a large amount of tickets. Suppose a group of 30 purchases 6,000 tickets.
a) How much would each person have to contribute?
b) What is the probability of the group winning? Losing?
4) How much would it cost to “buy the lottery”, that is, buy a ticket to cover every possibility? Is it worth it?
5) Create a probability distribution table for the random variable x = the amount won/lost when purchasing one ticket.
6) In fair games, the expected value will be $0. This means that if the game is played many…many times, then one is expected to break even eventually. This is never true for Casino and Lottery games. Find the expected value of x = the amount won/lost when purchasing one ticket.
7) Interpret the expected value. See section 4.2 in the textbook for an example on how to interpret the expected value.
8) Fill in the following table using the expected value.
|
Number of tickets purchases |
Expected net winnings for the lottery |
Expected netwinnings of a fair game (expected value = 0) |
|
100,000 |
$0 |
|
|
500,000 |
$0 |
|
|
1,000,000 |
$0 |
|
|
5,000,000 |
$0 |
In: Statistics and Probability