Package 'gamblers.ruin.gameplay'

Title: One-Dimensional Random Walks Through Simulation of the Gambler's Ruin Problem
Description: Simulates a gambling game under the gambler's ruin setup, after asking for the money you have and the money you want to win, along with your win probability in each round of the game.
Authors: Somjit Roy
Maintainer: Somjit Roy <[email protected]>
License: MIT + file LICENSE
Version: 4.0.5
Built: 2024-10-30 04:45:49 UTC
Source: https://github.com/cran/gamblers.ruin.gameplay

Help Index


A function to simulate a game of gambling (chance) under the gambler's ruin setup.

Description

The gambler's ruin problem is a classic example, which illustrates the application of one-dimensional Random Walks - a Stochastic Process. Simulation of a gambling game under the gambler's ruin setup concerns to a gambler starting the game with an initial capital, where the probability of winning a particular round is 'p'. If the gambler wins the round, then 1 unit of money is added to the gambler's existing capital and if the gambler loses a round, then 1 unit of money is deducted from the gambler's existing capital. The game stops when the gambler reaches his desired amount of money or gets totally bankrupted (ruined), these two points are known as the absorbed states of the game, or equivalently absorbed states in the one-dimensional random walk.

The function 'grp.gameplay()' simulates the above described game, where the simulation runs until one of the absorbed states are reached, i.e., simulating the game until the gambler reaches to 0 money, getting ruined or wins the desired or targeted amount, eventually winning the game. User inputs are accepted, which includes the initial amount of money with which the gambler enters the game, the probability 'p' of winning each round of the game and lastly the amount of money, which the gambler wishes to earn from this game being played.The function facilitates majorly in visualizing the game trajectory of the gambler, along with the overall probability of the gambler winning the entire game.

Usage

grp.gameplay(ini.stake, p, win.amt)

Arguments

ini.stake

The initial capital (money) with which the gambler enters the game.

p

The probability with which the gambler wins each round of the game, 0<p<1.

win.amt

The amount of money which the gambler desires to win from the game.

Value

A Graphical Plot - graphical representation of the entire trajectory of the money/capital with the gambler during the course of the game being played, along with the long run probability of winning the entire game, stated in the graph as "Overall Probability of winning this entire game".

Author(s)

Somjit Roy

References

Frederick Mosteller, Fifty Challenging Problems in Probability with Solutions, 1965, Dover Publications.

See Also

The simulation of the gambler's ruin problem helps to demonstrate the idea of one-dimensional random walks, consequently facilitating the readers to have an example of a stochastic process. The gambler's ruin problem is a very famous problem, often visited in the course of probability, aimed at explaining stochastic processes, and two of its major offshoots - Random Walks and Markov Chains.

The game can be simulated under both biased as well as unbiased situations, depending on the value of 'p' chosen by the user, thereby giving examples of both biased as well as unbiased random walks.

NOTE :: Here the wagered amount is 1 unit of money for each round, as dictated by the setup of the gambler's ruin problem.

Examples

# Suppose a gambler enters a game of gambling under the gambler's ruin setup with an initial
# amount (capital) of 100 and wants to reach an amount of 200, where the probability
# of winning each round of the game for the gambler is 0.5, i.e., a fair game, then
# the gambler's ruin problem under this framework is simulated as follows:

grp.gameplay(5,0.5,10)