Suppose that we have a red coin and a blue coin. The red coinhas probability pR = 0.1 of landing heads, and the blue coin hasprobability pB = 0.2 of landing heads.
(a) Write R code to generate a sequence of coin tosses, startingwith the red coin, and switching coins every time a coin landsheads.
(b) Generate 1000 such sequences, each consisting of 1000 cointosses, and use them to construct a plot of the 2.5%, 50% and 97.5%quantiles of the proportion of red coins tossed as the number oftosses increases. (c) What is the stationary distribution ofcolours for this process? Comment on how this experiment relates toBirkhoff’s ergodic theorem