This one is somewhat hard to explain, but I'll try my best to.
I'm trying to generate a list of numbers (containing only pi/10, 0, -pi/10). Numbers are randomly selected from these 3, where the probability of getting 0 is always 70%. But the probability of getting pi/10 and -pi/10 depend on the previous outcomes.
Here's I'm going to explain it how it depends:
Initially, the probability of getting pi/10 is 25%, and of getting -pi/10 is 5%.
But once I get -pi/10 as an outcome, probabilities will be switched. (i.e., the probability of getting pi/10 will be 5%, and of getting -pi/10 will be 25%.)
Similarly, when pi/10 comes next comes as an outcome, probabilities will again get switched and so on...
So, here's what I've tried, but didn't get the desired result.
rr := RandomReal[{0, 1}]
x1 = \[Piecewise]{{0, # < 0.7}, {-\[Pi]/10, 0.7 <= # < 0.75}, {\ [Pi]/10,True}} &@rr
x2 = \[Piecewise]{{0, # < 0.7}, {\[Pi]/10, 0.7 <= # < 0.75}, {-\[Pi]/10, True}} &@rr
And then I run a for-loop:
(Here, where I have used which function, my 3rd condition is when I get 0, and in that case, probabilites don't get switched, so it remains the previous "a". If you have a better way to that also, then that'll be great.)
list{}
For[i = 1 ; a = 1, i <= 100, i++;
If[a == 0, x = x1, x = x2];
a = Which[x == \[Pi]/10, 0, x == -\[Pi]/10, 1, True, a];
AppendTo[list, x]]
list
Your help will be really appreciated!!
P.S.: There might be some syntax errors, if you could point that out too, I'll be thankful to you (as I'm new to Mathematica).