I'd like to generate samples of real numbers respecting distributional constraints. I tried (here, for a sample of 17 reals):
NSolve[
Rationalize[
{
0 <= {m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14,
m15, m16, m17} <= 100,
Distributed[{m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12,
m13, m14, m15, m16, m17},
NormalDistribution[
21.2, (26.87 - 11.68)/(2*Sqrt[2] InverseErf[0.95])]]
}
],
{m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15,
m16, m17},
Reals,
WorkingPrecision -> 10]
Apparently, I'm not heading in the right direction, because the solver complains with:
NSolve: This system cannot be solved with the methods available to NSolve.
What is a better way of doing that? Thanks!
{m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16, m17} = RandomVariate[NormalDistribution[21.2, (26.87 - 11.68)/ (2*Sqrt[2] InverseErf[0.95])], 17]
While it is unlikely that these would not be in the interval{0, 100}
, you can guarantee that by using{m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16, m17} = RandomVariate[ TruncatedDistribution[{0, 100}, NormalDistribution[21.2, (26.87 - 11.68)/(2*Sqrt[2] InverseErf[0.95])]], 17]
$\endgroup$dist = NormalDistribution[21.2, (26.87 - 11.68)/(2*Sqrt[2] InverseErf[0.95])]; Join[RandomVariate[ TruncatedDistribution[{20, Infinity}, dist], 10], RandomVariate[TruncatedDistribution[{-Infinity, 20}, dist], 7]]
$\endgroup$