Fortune Telling Collection - Free divination - The probability of rolling dice and walking according to the number of steps in the nth grid
The probability of rolling dice and walking according to the number of steps in the nth grid
Like a monopoly, roll the dice and calculate the probability of going to the n-th grid according to the number of dice and steps.
For example, our function dp(n) calculates the probability of the nth grid, and then:
//The number of dice must be (1), which means 1 possibility.
P( 1)= 1 probability of grid = 1/6.
//The number of dice must be (2), (1, 1), two possibilities.
P(2)= probability of the second grid =1/6+(1/6) (1/6).
//Dice number (3), (1, 2), (2, 1), (1, 1)
P(3)= probability of the third grid =1/6+(1/6) (1/6) 2+(1/6) * (1/6).
There are too many permutations and combinations of the fourth one, so I won't continue to list them here.
Let's analyze how this p(n) is calculated. The probability of the nth lattice is actually calculated from the nth-6th lattice to the nth-1lattice.
If n
p( 1)= 1/6
p(2)=p( 1)/6+ 1/6
p(3)= p( 1)/6+p(2)/6+ 1/6
...
If n>6:
p(n)= p(n- 1)/6+p(n-2)/6+p(n-3)/6+p(n-4)/6+p(n-5)/6+p(n-6)/6
Then we just need to calculate the probability from 1
When calculating the probability of 1, the influence of the first lattice on the probability of 2-7 lattices must also be calculated.
p(n+ 1)+=p(n)/6
The specific algorithm is as follows:
- Previous article:Who is nmixx group?
- Next article:Introduction to the story of
- Related articles
- What does the spell mean?
- On the constellation of Gemini copywriting
- What is the ingredient of Zetian in gossip?
- Southwest University's most active couple at night.
- What is the loveliness index of the twelve constellations?
- One piece, Kidd pirate VS red-haired pirate, who gave courage?
- Technology: How to make transparent word cards?
- Ask an expert to calculate the fate.
- What do you mean? How did it come into being?
- Listening to Russian CCTV music 1, 2, 3