, Mathematica, , .. :
In[36]:= pdf = PiecewiseExpand[Rationalize[E^(-(x^2/2) - y^2/2)*
(-1 + E^(-1.*(x + 0.1*y)*UnitStep[x + 0.1*y]))^2],
Element[{x, y}, Reals]]
Out[36]= Piecewise[{{E^(-2*x - x^2/2 - y/5 - y^2/2)*(-1 +
E^(x + y/10))^2, 10*x + y >= 0}}, 0]
, :
In[56]:= cvr =
First[Solve[{10 x + y == u, (10 y - x)/101 == v}, {x, y}]]
Out[56]= {x -> (10 u)/101 - v, y -> u/101 + 10 v}
, , :
In[42]:= jac = Simplify[Det[Outer[D, {x, y} /. cvr, {u, v}]]]
Out[42]= 1
, :
In[45]:= npdf = FullSimplify[jac*pdf /. cvr]
Out[45]= Piecewise[{{E^(-(u/5) - u^2/202 - (101*v^2)/2)*(-1 +
E^(u/10))^2, u >= 0}}, 0]
'u' 'v' . 'v' NormalDistribution[0, 1/101], 'u' , ProbabilityDistribution.
In[53]:= updf =
Refine[npdf/nc, u >= 0]/PDF[NormalDistribution[0, 1/Sqrt[101]], v]
Out[53]= (E^(-(u/5) - u^2/202)*(-1 + E^(u/10))^2*Sqrt[2/(101*Pi)])/
(1 - 2*E^(101/200)*Erfc[Sqrt[101/2]/10] +
E^(101/50)*Erfc[Sqrt[101/2]/5])
So now you can define the joint distribution for the vector {u,v}:
dist = ProductDistribution[NormalDistribution[0, 1/101],
ProbabilityDistribution[updf, {u, 0, Infinity}]];
Since the connection between {u,v}and is {x,y}known, the generation of variations {x,y}is simple:
XYRandomVariates[len_] :=
RandomVariate[dist, len].{{-1, 10}, {10/101, 1/101}}
You can encapsulate accumulated knowledge using TransformedDistribution:
origdist =
TransformedDistribution[{(10 u)/101 - v,
u/101 + 10 v}, {Distributed[v, NormalDistribution[0, 1/101]],
Distributed[u, ProbabilityDistribution[updf, {u, 0, Infinity}]]}];
eg:.
In[68]:= Mean[RandomVariate[origdist, 10^4]]
Out[68]= {1.27198, 0.126733}