This site and this site provide some background as to what I am trying to achieve, but with some variations in what is required. First I want three random variables with a normal distribution, however they are correlated as in $d_i= c a_i +(1-c) b_i$, where $c$ is the correlation factor, and $(a_i, b_i, d_i)$ are the variables. The constraint $b_i < d_i < a_i$ is a requirement.
Here I have a Monte Carlo based simulation that yields all three variables which satisfies the criteria mentioned above:
RaN[m_, s_, co_] :=
Module[{me = m, sd = s, c = co},
q1 = RandomVariate[NormalDistribution[me, sd]];
q2 = RandomVariate[NormalDistribution[me, sd]];
p = c*q1 + (1 - c)*q2;
If[TrueQ[q2 < p < q1], {q1, q2, p}, RaN[m, s, co]]]
Manipulate[
ListPointPlot3D[Table[RaN[0, 1, cr], {i, 1000}]], {cr, 0.005, 0.995}]
However this is not an optimized code. It can be expensive time-wise, and also there is the possibility of running into recursion depth problems if total runs is increased.
My question is: Are there better ways of seeking, not just 3 correlated variables, but a sequence of $N$ variables such that the variables $a_i$ is the highest and $b_i$ is the lowest numbers. The site mentioned earlier points to a technique that involves matrices. Any suggestions?
RaN[m_, s_, c_] := Append[#, c*#[[1]] + (1 - c)*#[[2]]] &@ Sort@RandomVariate[NormalDistribution[m, s], {2}];
$\endgroup$RaN[m_, s_, c_, n_] := Append[#, c*#[[1]] + (1 - c)*#[[2]]] & /@ (Sort /@ RandomVariate[NormalDistribution[m, s], {n, 2}]); Manipulate[ListPointPlot3D[RaN[0, 1, cr, 1000]], {cr, 0.005, 0.995}]
$\endgroup$