Questions
** USING MATLAB TO PROGRAM The main objective of this lab is to create a game...

** 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:

  1. Set up the following variables to keep track of the game state:
    • sum_count_array: an array to keep track of the number of times that each dice sum has occurred. There should be 11 elements in this array since there are 11 possible sum outcomes. The first element indicates the number of times a sum of 2 has occurred; the second element indicates the number of times a sum of 3 has occurred; and so on. Each of the elements in this array should be initialized to 0.
    • money: a variable to keep track of the amount of money the player currently has. This variable should be initialized to 100.
    • round: a variable to keep track of the game round. This variable should be initialized to 1.
    • keep_playing: a variable that keeps track of whether or not the player would like to continue playing. This variable should be initialized to true.
  2. Set up the main loop to run the game as long as the keep_playing variable is true. The rest of the game logic, which does not include the pie chart, will go inside this loop.
  3. Print out the round number and the amount of money the player currently has.
  4. Ask the player for an amount of money he or she would like to bet and store the result in a variable called current_bet.
  5. Ask the player what value he or she would like to bet on for the sum of the two dice and store the result in a variable called current_guess.
  6. Roll two dice and store the resulting number for each die. Store the sum of the two dice in a variable called current_sum. Add to the count for the sum in the appropriate index of sum_count_array. Display the result for each die and the sum of the two dice.
  7. Check to see if the player wins or loses his or her bet. Adjust the money variable accordingly, and tell the user whether or not they won the bet. Display the updated amount of money that the player has.
  8. If the player does not have any more money, print out a relevant message and set keep_playing to false.
  9. If the player does have more money, ask the player whether or not he or she would like to continue playing the game.
    • If the player enters ‘y’, increment the round number.
    • If the player enters ‘n’, set keep_playing to false.
  1. Once the main game loop has ended, display the percentage of times that each dice roll sum occurred in a pie chart. Give the chart an appropriate title.

In: Computer Science

1. (1 point) The range of probability is ​a. ​any value larger than zero ​b. ​any...

1. (1 point)
The range of probability is
​a. ​any value larger than zero
​b. ​any value between minus infinity to plus infinity
​c. ​zero to one
​d. ​any value between -1 to 1
2. (1 point)
Any process that generates well-defined outcomes is
​a. ​an event
​b. ​an experiment
​c. ​a sample point
​d. ​None of the other answers is correct.
3. (1 point)
The sample space refers to
​a. ​any particular experimental outcome
​b. ​the sample size minus one
​c. ​the set of all possible experimental outcomes
​d. ​both any particular experimental outcome and the set of all possible experimental outcomes are correct
4. (1 point)
An experiment consists of three steps. There are four possible results on the first step, three possible results on the second step, and two possible results on the third step. The total number of experimental outcomes is
​a. ​9
​b. ​14
​c. ​24
​d. ​36
5. (1 point)
When the assumption of equally likely outcomes is used to assign probability values, the method used to assign probabilities is referred to as the
​a. ​relative frequency method
​b. ​subjective method
​c. ​probability method
​d. ​classical method
6. (1 point)
Given that event E has a probability of 0.25, the probability of the complement of event E
​a. ​cannot be determined with the above information
​b. ​can have any value between zero and one
​c. ​must be 0.75
​d. ​is 0.25

If P(A) = 0.38, P(B) = 0.83, and P(A ∩ B) = 0.57; then P(A ∪ B) =
​a. ​1.21
​b. ​0.64
​c. ​0.78
​d. ​1.78
14. (1 point)
If P(A) = 0.62, P(B) = 0.47, and P(A ∪ B) = 0.88; then P(A ∩ B) =
​a. ​0.2914
​b. ​1.9700
​c. ​0.6700
​d. ​0.2100
15. (1 point)
Two events are mutually exclusive if
​a. ​the probability of their intersection is 1
​b. ​they have no sample points in common
​c. ​the probability of their intersection is 0.5
​d. ​the probability of their intersection is 1 and they have no sample points in common
16. (1 point)
If A and B are mutually exclusive events with P(A) = 0.3 and P(B) = 0.5, then P(A ∪ B) =
​a. ​0.00
​b. ​0.15
​c. ​0.8
​d. ​0.2
17. (1 point)
If P(A|B) = P(A) then
​a. ​A and B are mutually exclusive
​b. ​A and B are dependent
​c. ​A and B are both mutually exclusive and dependent
​d. ​A and B are independent.
18. (1 point)
On a December day, the probability of snow is .30. The probability of a "cold" day is .50. The probability of snow and a "cold" day is .15. Are snow and "cold" weather independent events (Hint: think about a joint probability table)?
​a. ​only if given that it snowed
​b. ​no
​c. ​yes
​d. ​only when they are also mutually exclusive
19. (1 point)
If A and B are independent events with P(A) = 0.4 and P(B) = 0.6, then P(A ∩ B) =
​a. ​0.76
​b. ​1.00
​c. ​0.24
​d. ​0.2
20. (1 point)
If A and B are independent events with P(A) = 0.2 and P(B) = 0.6, then P(A ∪ B) =
​a. ​0.62
​b. ​0.12
​c. ​0.60
​d. ​0.68

In: Statistics and Probability

Part B: Ballistic Pendulum The questions n the very bottom is pertaining to a lab over...

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.

  1. Place the ball in the launcher and cock the gun until the spring is locked in the same position as used for the previous part. Fire the gun. The ball will enter the catcher in the pendulum, which will swing up and return. A slider indicates the maximum angle by which it had moved. Repeat this procedure five times and obtain the average. Use the average angle and the length of the pendulum L (distance from pivot to its center of mass) to obtain the vertical distance ‘h’ moved by the center of mass of the pendulum+ball. (You will need to do some trigonometry to get ‘h’)
  2. In some instruments, as the pendulum swings up, it comes to rest on a curved rack. For this instrument, record the vertical distance between the base of the apparatus and the center of mass of the pendulum+ball before it swings and after it stops. The difference is the vertical height ‘h’.
  3. Use equations 1, 3 and 4 to obtain the initial speed of the ball. Compare this with the value obtained from part 1.

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

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.

  1. What is the probability that 0, 1, 2, and 3 access lines will be in use? Round your answers to 4 decimal places.
    j Pj
    0
    1
    2
    3

  2. What is the probability that an agent will be denied access to the system? Round your answers to 4 decimal places.

    ___
  3. What is the average number of access lines in use? Round your answers to 4 decimal places.

    L =
  4. In planning for the future, management wants to be able to handle λ = 38 calls per hour; in addition, the probability that an agent will be denied access to the system should be no greater than the value computed in part (b). How many access lines should this system have?

    ___ lines will be necessary.

In: Statistics and Probability

We are in casino playing roulette, American version. We decided to play only red/black, i.e. to...

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

PDF

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

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

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

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.

  1. What is the probability that 0, 1, 2, and 3 access lines will be in use? Round your answers to 4 decimal places.
    j Pj
    0
    1
    2
    3

  2. What is the probability that an agent will be denied access to the system? Round your answers to 4 decimal places.


  3. What is the average number of access lines in use? Round your answers to 4 decimal places.

    L =
  4. In planning for the future, management wants to be able to handle λ = 65 calls per hour; in addition, the probability that an agent will be denied access to the system should be no greater than the value computed in part (b). How many access lines should this system have?

    lines will be necessary.

In: Statistics and Probability

11) A student takes a true-false test that has 20 questions and guesses randomly at each...

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

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