1
$\begingroup$

Suppose a function such as:

$\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) on $\phi$ where $x$ is drawn from a beta distribution with parameters (3,1) and $\alpha = 0.5$.

I don't know how to deal with $\phi$ in the random walk process, especially given its 3 conditions.

EDIT: $y$ is the mean of all the previous $x$. For instance, suppose we are at time $t=3$ and observations start at $t=0$. Then, $y_3 = \frac{x_0 + x_1 + x_2}{3}$.


ϕ[x_, y_] := Piecewise[{
  {α*x, x < y}, 
  {x, x == y}, 
  {α*x + (1 - α), x > y}}]
ϕ[x, y]

$\endgroup$
  • $\begingroup$ OP notes that $X\sim Beta$ ... which is a continuous random variable. It is not stated what $y$ is, but if $y$ is a constant, or $y$ is an independent random variable, then $P(X=y) = 0$. If so, you can ignore the case $X = y$, because it happens with zero probability. $\endgroup$ – wolfies Aug 7 '14 at 15:31
  • $\begingroup$ Thanks for your comments. $y$ is the mean of all the previous $x$. For instance, suppose we are at time $t=3$ and observations start at $t=0$. Then, $y_3=\frac{x_0+x_1+x_2}{3}$. $\endgroup$ – flo Aug 7 '14 at 18:05
2
$\begingroup$

With the function

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

you can define a new function, that will perform a single simulation

sim[a_Real, n_Integer] := 
 Module[{data = Partition[Riffle[#, Accumulate[#]/Range[n]], 2] &@ RandomVariate[BetaDistribution[3, 1], n]},
  f[a, #] & /@ data
 ]

where the first argument is the value of alpha and the second argument is length of the random walk.
Than 5 random walks of length 100 with alpha = 0.5 can be plotted using

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

5RandomWalksOfLengh100WithAlpha0.5

$\endgroup$
  • $\begingroup$ Thanks a lot @Karsten! It's starting to make a lot of sense. I just need to work on $y$, since we should observe a convergence towards the mean of x, $E(x) = 0.75$. $\endgroup$ – flo Aug 7 '14 at 18:51
0
$\begingroup$

Here is an approach using MovingMap and f from Karsten 7:

f[a_, {x_, y_}] := 
 Piecewise[{{a x, x < y}, {x, x == y}, {1 - a + a x, x > y}}, 0]
s[lst_] := MovingMap[f[0.5, {#[[4]], Mean[#[[1 ;; 3]]]}] &, lst, 3]

Visualizing:

ListPlot[s /@ RandomVariate[BetaDistribution[3, 1], {5, 100}], 
 Joined -> True, Frame -> True]

enter image description here

$\endgroup$

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.