Overview
Probability DP doesn't just store `true` or `false` (can we reach state X?), it stores `float` values: "What is the mathematical probability we reach state X?"
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Calculate the expected value or probability of a specific outcome by transitioning fractional states over time or steps.
Probability DP doesn't just store `true` or `false` (can we reach state X?), it stores `float` values: "What is the mathematical probability we reach state X?"
Instead of "Pull DP" where a cell asks its neighbors for values, Probability DP often uses "Push DP". A cell takes its probability `P` and pushes `P / branches` to its valid next states.
Because the probabilities at step `K` only depend on step `K-1`, we only need to keep two 2D grids in memory: `dp` and `nextDp`.
If a move goes off the board, that fraction of the probability is lost forever. The final answer is just the sum of all probabilities remaining on the board.