MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

A distribution problem using Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111459] A distribution problem using Mathematica
  • From: "S. B. Gray" <stevebg at ROADRUNNER.COM>
  • Date: Mon, 2 Aug 2010 07:04:37 -0400 (EDT)
  • Reply-to: stevebg at ROADRUNNER.COM

	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


  • Prev by Date: Re: Mathematica- Use a previous equation into the function Function
  • Next by Date: Re: Cannot load example data
  • Previous by thread: Re: different results for Standard vs Prefix forms
  • Next by thread: Re: A distribution problem using Mathematica