stochastic programsprobabilityand statistics import random def rolldie()"""returns random int between and ""return random choice([ , , , , , ]def rolln( )result 'for in range( )result result str(rolldie()print result figure roll die nowimagine running rolln( would you be more surprised to see it print or orto put it another waywhich of these two sequences is more randomit' trick question each of these sequences is equally likelybecause the value of each roll is independent of the values of earlier rolls in stochastic process two events are independent if the outcome of one event has no influence on the outcome of the other this is bit easier to see if we simplify the situation by thinking about twosided die (also known as coinwith the values and this allows us to think of the output of call of rolln as binary number (see when we use binary diethere are possible sequences that testn might return each of these is equally likelytherefore each has probability of occurring of ( / ) let' go back to our six-sided die how many different sequences are there of length sothe probability of rolling ten consecutive ' is / less than one out of sixty million pretty lowbut no lower than the probability of any other particular sequencee of ten rolls in generalwhen we talk about the probability of result having some property ( all 'swe are asking what fraction of all possible results has that property this is why probabilities range from to suppose we want to know the probability of getting any sequence other than all ' when rolling the dieit is simply ( / )because the probability of something happening and the probability of the same thing not happening must add up to suppose we want to know the probability of rolling the die ten times without getting single one way to answer this question is to transform it into the question of how many of the possible sequences don' contain