8
$\begingroup$

Let $X_t$ be IID random variables in $[0,1]$ and CDF $F(\cdot)$. Suppose there exists a variable $Y_t$ given by:

$Y_1 = X_1$ and $Y_t = \phi(X_t, \overline{Y}_{t-1}), \forall t >1$, where

$\overline{Y}_{t} = \frac{1}{t} \sum_{i=1}^{t} Y_i$

and

$\phi^{\alpha} (x,y) = \left\{ \begin{array}{l l} \alpha x & \quad \text{if $x < y$}\\ x & \quad \text{if $x = y$}\\ \alpha x + (1 -\alpha) & \quad \text{if $x > y$}\\ \end{array} \right.$

I wish to run a simulation for 5 random walks (each with length 100) of $\overline{Y}_{t}$ where $X$ is drawn from a beta distribution with parameters (3,1) and $\alpha = 0.5$.

Normally, we should observe a convergence to the mean of $X$, i.e. $\mathbb{E}[X]$.

I have for $\phi^{\alpha} (x,y)$:

f[a_, {x_, y_}] := Piecewise[{{a x, x < y}, {x, x == y}, {1 - a + a x, x > y}}, 0]

My Beta distribution (with 100 iterations) can be expressed as:

RandomVariate[BetaDistribution[3, 1], 100]

I have difficulties to form the aggregation of data, and plot the evolution of $\overline{Y}_{t}$. Any help would be highly appreciated.

ListPlot[Table[<%simulated_data%>], PlotRange -> All, Joined -> True, Frame -> True]
$\endgroup$
8
$\begingroup$

With

f[a_, {x_, y_}] := Piecewise[{{a x, x < y}, {x, x == y}, {1 - a + a x, x > y}}, 0]

one simulation can be defined by

sim[length_] := 
  Module[{rv = RandomVariate[BetaDistribution[3, 1], length], y, yBar},
    y[1] = First@rv;
    yBar[t_Integer] := yBar[t] = 1/t * Sum[y[i], {i, 1, t}];
    y[t_Integer] := y[t] = f[0.5, {rv[[t]], yBar[t - 1]}];
    yBar /@ Range[length]
  ]

and then 5 simulations with a length of 100 can be plotted with

ListPlot[Table[sim[100], {5}], PlotRange -> All, Joined -> True, Frame -> True]

randomBetaWalk

$\endgroup$
  • 1
    $\begingroup$ Thanks a lot @Karsten. Just edited your answer. y /@ Range[length] should be yBar /@ Range[length] in order to get the plot I wanted. $\endgroup$ – flo Aug 18 '14 at 12:46
  • 1
    $\begingroup$ @flo Thanks. Overlooked that bar. $\endgroup$ – Karsten 7. Aug 18 '14 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.