[SOLVED] AI5002-Assignment 5

24.99 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

Rate this product

In a game, a man wins a rupee for a six and loses a rupee for any other number when a fair die is thrown. The man decided to throw a die thrice but to quit as and when he gets a six. Find the expected value of the amount he wins / loses.

  1. Solution

Let X denote the random variable of winning/losing in the game.

P(X = 1)= P(win) = getting a 6 on rolling a fair die.

P(X = 0)= P(loss) = getting a 6 on rolling a fair die.

P(X = 1) = p = = 0.167

P(X = 0) = 1-p =  = 0.833

Let Y denote the random variable of winning the game in Nth trial, there can be 4 possible cases with the following probability: (i)Wins in first throw:

P(Y = 1) = p = 0.167                      (1)

(ii)Wins in the second throw :

P(Y = 2) = (1 −p) ×p = 0.139               (2)

(ii)Wins in the third throw :

P(Y = 3) = (1 −p) × (1 −p) ×p = 0.107           (3)

(ii)Does not wins in any throw :

P(Y = 3) = (1 −p) × (1 −p) × (1 −p) = 0.596

(4)

Net amount = P(Y=1)×1 + P(Y = 1) × (−1 + 1) +

P(Y = 1)×(−1−1+1)+P(Y = 1)×(−1−1−1) = −1.73

The probabilities were simulated using the python code.

Download python code from here

Figure 1: Simulation for tossing a fair coin

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.