1
$\begingroup$

I need to obtain a random distribution of some parameters {t1,t2,t3} subject to a set of conditions. For example,

{(t1,t2,t3)| p1(t1,t2,t3)>0, p2(t1,t2,t3)==0}

So far, my only idea has been to use FindInstance in the following way:

tpoints = {t1,t2,t3}/.FindInstance[p1(t1,t2,t3)>0&&p2(t1,t2,t3)==0,{t1,t2,t3},numpoints

where numpoints is the size of the sample that I want. However, It's unclear to me how FindInstance works and whether constructing a data set this way is truly a "good" (random) data set.

Update: I should also mention that until the conditions are imposed, the parameters (t1, t2, t3) can be any real numbers. Additionally, the conditions p1, p2, etc. are linear and quadratic polynomial constraints.

$\endgroup$
3
  • 1
    $\begingroup$ You could try something like RandomPoint @ ImplicitRegion[conditions, parameters]. $\endgroup$
    – Carl Woll
    Commented Aug 26, 2020 at 16:04
  • $\begingroup$ Until you specify the (unconditional) joint distribution of $(t_1,t_2,t_3)$ (which includes the range of values the parameters can take: integers? non-negative reals?) and the definitions of p1 and p2, I don't think there's much specific advice one can give. The general advice should help but might not capitalize on efficiencies knowing more information. $\endgroup$
    – JimB
    Commented Aug 26, 2020 at 16:45
  • 1
    $\begingroup$ @JimB thanks, just updated the post with additional information. $\endgroup$
    – naomig
    Commented Aug 26, 2020 at 17:59

1 Answer 1

1
$\begingroup$

I don't believe the term "fairly sampled data set" is well defined.

Given the two types of constraints (an inequality and an equality), you'll likely need to solve explicitly for the equality (p2), generate samples from a known multivariate distribution, and then Select the subset that satisfies the inequality (p1).

Suppose p2 = t1^2 + t2^2 - t3^2 is the equality. Then we can solve for t3 as follows:

p2 = t1^2 + t2^2 - t3^2;
Solve[p2 == 0, t3]
(* {{t3 -> -Sqrt[t1^2 + t2^2]}, {t3 -> Sqrt[t1^2 + t2^2]}} *)

We'll assume that t3 could take either value equally likely. Also let

p1 = Total[{t1, t2, t3}]

Now generate the restricted samples:

n = 10000;  (* Maximum sample size *)

(* Generate random sample of (t1, t2) from a bivariate normal \
distribution *)
ρ = 0;
t12 = RandomVariate[BinormalDistribution[{0, 0}, {1, 1}, ρ], n];

(* Add in the value of t3 determined by the equality *)
t3 = (Sqrt[#[[1]]^2 + #[[2]]^2] & /@ 
     t12)*(2*RandomVariate[BernoulliDistribution[1/2], n] - 1);
t123 = Join[t12, Transpose[{t3}], 2];

(* Select the samples that satisfy p1 (the inequality constraint) *)
sample = Select[t123, Total[#] > 0 &];

(* Show the results *)
GraphicsGrid[{{Graphics[Text[Style["ρ = 0", Bold, Italic, 36]]],
   ListPlot[sample[[All, {1, 2}]], AxesLabel -> {"t1", "t2"}, 
    PlotRange -> {{-4, 4}, {-4, 4}}, AspectRatio -> 1]},
  {ListPlot[sample[[All, {1, 3}]], AxesLabel -> {"t1", "t3"}, 
    PlotRange -> {{-4, 4}, {-4, 4}}, AspectRatio -> 1],
   ListPlot[sample[[All, {2, 3}]], AxesLabel -> {"t2", "t3"}, 
    PlotRange -> {{-4, 4}, {-4, 4}}, AspectRatio -> 1]}}]

Restricted sampling of t1, t2, and t3 with rho = 0

But now use $\rho=0.9$:

Restricted sampling of t1, t2, and t3 with rho = 0.9

Different values of ρ result in wildly different samples as does the choice of the joint distribution.

So setting the restrictions is just part of what needs to be specified. You also need to specify the joint distribution of t1, t2, and t3. (With the example I used you just need to specify the joint distribution of t1 and t2 because one can solve for t3 in terms of t1 and t2.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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