I have a function $$F(X_{t+1},Y_{t}^{med})= \alpha X_{t+1} + (1-\alpha) Y_{t}^{med},$$ where $$Y_{t}^{med} = Median(Y_1, Y_2,... Y_t).$$ Moreover, $Y_1 = X_1$ and $Y_t = F(X_{t},Y_{t-1}^{med})$ $\forall t>1$.
Suppose $X_t \sim X$ is a IID random variable following a Beta distribution, $X \sim Beta(2,1)$.
I wish to plot the evolution of $Y_{t}^{med}$ over time.
Currently, I have:
1) The function:
f[a_, {x_, y_}] := a x + (1 - a) y
2) Generate data. Here, I don't know how to generate the running median, that is $Y_{t}^{med}$ in Mathematica.
sim[length_] :=
Module[{rv = RandomVariate[BetaDistribution[2, 1], length], y, yMed},
y[1] = First@rv;
yMed[t_Integer] := yMed[t] = MovingMedian[rv, t];
y[t_Integer] := y[t] = f[0.5, {rv[[t]], yMed[t - 1]}];
yMed /@ Range[length]]
3) Create the plot/graph for 100 iterations, 5 random walks:
ListPlot[Table[sim[100], {5}], PlotRange -> All, Joined -> True,
Frame -> False, AxesOrigin -> {0, 0}, AxesLabel -> {t, Y},
GridLines -> {{}, {2/3}}, GridLinesStyle -> Directive[Gray, Dashed]]