[Date Index]
[Thread Index]
[Author Index]
Re: Random spherical troubles
*To*: mathgroup at smc.vnet.net
*Subject*: [mg25186] Re: Random spherical troubles
*From*: "John Doty" <jpd at yami.w-d.org>
*Date*: Tue, 12 Sep 2000 21:24:28 -0400 (EDT)
*References*: <8pkl8u$m80@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
In article <8pkl8u$m80 at smc.vnet.net>, Barbara DaVinci
<barbara_79_f at yahoo.it> wrote:
> Hi MathGrouppisti
>
> This time, my problem is to generate a set of
> directions randomly
> distributed over the whole solid angle.
>
> This simple approach is incorrect (spherical
> coordinates are assumed) :
>
> Table[{Pi Random[], 2 Pi Random[]} , {100}]
>
> because this way we obtain a set of point uniformly
> distributed
> over the [0 Pi] x [0 2Pi] rectangle NOT over a
> spherical surface :-(
>
> If you try doing so and plot the points {1,
> random_theta , random_phi}
> you will see them gathering around the poles because
> that simple
> transformation from rectangle to sphere isn't
> "area-preserving" .
>
> Such a set is involved in a simulation in statistical mechanics ...
> and I can't get out this trouble.
>
> May be mapping [0 Pi] x [0 2Pi] in itself , using an
> suitable
> "non-identity" transformation, can spread points in a
> way balancing
> the poles clustering effect.
>
>
> ====================================================================
>
> While I was brooding over that, an intuition flashed
> trought my mind :
> since spherical to cartesian transformation is
>
> x = rho Sin[ theta ] Cos[ phi ] y = rho Sin[ theta ] Sin[ phi ] z =
> rho Cos[ theta ]
>
> perhaps the right quantities to randomly spread
> around are Cos[ theta ] and
> Cos[ phi ] rather than theta and phi for itself. Give
> a glance at this :
>
> Table[{ ArcCos[ Random[] ], ArcCos[ Random[] Sign[ 0.5 - Random[] ]
> } , {100}]
>
> Do you think it is close to the right ? Do you see a
> better way ?
You're getting there. One good way to do it is to generate an isotropic
random 3 vector using the special properties of the Gaussian distribution.
<<Statistics`ContinuousDistributions`
rg1:=Random[NormalDistribution[0,1]]
r3v:={rg1,rg1,rg1}
Because standard deviations add in quadrature, the standard deviation of a
projection of this in any direction is the same. Because sums of Gaussian
variables are Gaussian, the projection of this in any direction is
Gaussian. r3v therefore generates isotropically distributed
random vectors.
Now just convert to polar coordinates. For numerical work, remember to use
the two argument ArcTan[] exclusively, as it avoids the numerical
misbehavior of the other inverse trig function near the coordinate
singularities.
--
| John Doty "You can't confuse me, that's my job."
| Home: jpd at w-d.org
| Work: jpd at space.mit.edu
Prev by Date:
**Re: When ploting a differential equation, sigularities cause big ugly vertical lines on the graph - how can I get rid of them? By some magic mathematica incantaion?**
Next by Date:
**Re: Random spherical troubles**
Previous by thread:
**Re:Random spherical troubles**
Next by thread:
**Re: Random spherical troubles**
| |