[Date Index]
[Thread Index]
[Author Index]
Re: A distribution problem using Mathematica
*To*: mathgroup at smc.vnet.net
*Subject*: [mg111494] Re: A distribution problem using Mathematica
*From*: Ray Koopman <koopman at sfu.ca>
*Date*: Tue, 3 Aug 2010 06:38:52 -0400 (EDT)
*References*: <i368np$r7k$1@smc.vnet.net>
On Aug 2, 4:04 am, "S. B. Gray" <stev... at ROADRUNNER.COM> wrote:
> I want 3 random variables v1,v2,v3 with uniform distribution from 0 to
> 1, but modified or normalized so that their sum is a uniform
> distribution from 0 to 1.
> These variables are for placing a point at a random place inside a
> tetrahedron defined by 4 vertex vectors p1,p2,p3,p4. The internal point
> is given by p=v1(p1-p4)+v2(p2-p4)+v3(p3-p4) (barycentric coordinates).
> The 0 to 1 constraints assure that the point p will be inside.
> The closest I have come is this function giving the triplet
> frs={v1,v2,v3}:
>
> mul = RandomReal[{0, 1}, {3}];
> mul = mul/Total[mul];
> frs = Sqrt[RandomReal[{0, 1}, {3}]]*Power[mul, (3)^-1];
>
> which I tested with the histogram nhist: (The +1 avoids trying to access
> the 0th element of the list nhist.)
>
> nhist = Table[0, {1000}];
> Do [ mul = RandomReal[{0, 1}, {3}];
> mul = mul/Total[mul];
> frs = Sqrt[RandomReal[{0, 1}, {3}]]*Power[mul, (3)^-1];
> ip = IntegerPart[1000 frs][[2]];
> nhist[[ip+1]]++, {10000}
> ];
> Print[frs];
> ListPlot[nhist]
>
> This ad-hoc method gives a distribution that covers the range 0-1 but is
> too heavy in the region 0.3 to 0.7. This would put too many points near
> the middle of the tetrahedron. Something tells me there must be a better
> and more elegant solution. Any ideas?
>
> Steve Gray
This will give n points uniformly distributed inside an m-dimensional
polytope whose vertices are given by the rows of a table p whose
dimensions are {m+1,m}:
Table[ #/Tr@# & @ RandomReal[ExponentialDistribution[1], m+1], {n}].p
Prev by Date:
**Re: Forcing Mathematica to use standard fonts**
Next by Date:
**Re: Bare Bones Backup Button**
Previous by thread:
**Re: A distribution problem using Mathematica**
Next by thread:
** Re: discretized Laplacian or linear inverse problem with extremely**
| |