0

I have the following probability model:

$(X_k|\text{ PastHistory}_{k-1}, \theta_0, \theta_1, \theta_2) \sim (\pi\cdot N(\theta_1+\theta_0\cdot X_{k-1},1)+(1-\pi)\cdot N(\theta_2+\theta_0\cdot X_{k-1},1))$

and $X_k=0.5X_{k-1}+\epsilon_k$ with $\epsilon_k \sim N(0,1)$

I've tried something like:

Sample[n_] := 
 Module[{lst},
  lst = {RandomVariate[NormalDistribution[0, 1/(1 - 0.5^2)]]};
  element = 1;
  While[element <= n,
    AppendTo[lst, 
      RandomVariate[
        TransformedDistribution[
         p*X1 + (1 - p) X2, {
         X1 \[Distributed] 
         NormalDistribution[θ1 + θ0*lst[[element]], 1], 
         X2 \[Distributed] 
           NormalDistribution[θ2 + θ0*lst[[element]], 1]
      }]]];
   element = element + 1;
    ];
 lst
 ];

Is this correct?

Jacob Akkerboom
  • 12,215
  • 45
  • 79
An old man in the sea.
  • 2,527
  • 1
  • 18
  • 26

0 Answers0