Scenario
A gambler starts with fortune \kandrepeatedlywagers$1onsuccessiveindependentrounds,winning$1withprobabilitypandlosing$1withprobabilityq = 1 - p.Thegamblingprocesshaltswhentheplayereitherreaches$0(ruin)orattainstargetwealth$N(N > k > 0$).
Your Task
- Formulate the second-order linear recurrence relation for the probability of reaching target N (Pk).
- Derive the closed-form analytical formula for Pk for both fair (p=0.5) and biased (p=0.5) regimes.
- Derive the expected duration (hitting time) Ek of the game.
- Compute Pk and Ek for k=20,N=50,p=0.48.
Constraints
- Boundary conditions: P0=0,PN=1 and E0=0,EN=0.
Examples
For p=0.5, Pk=k/N and Ek=k(N−k).