Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: now, while loops construct errors

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44303] Re: now, while loops construct errors
  • From: koopman at sfu.ca (Ray Koopman)
  • Date: Wed, 5 Nov 2003 10:00:27 -0500 (EST)
  • References: <bo5sfg$m9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

sean kim <sean_incali at yahoo.com> wrote in message 
news:<bo5sfg$m9$1 at smc.vnet.net>...

> part 1. 
> [...]
> I'm trying to pick randome numbers for a pair such
> that the ratio of the two random numbers picked are
> between a range given. 
> 
> So with v1 and d1, the ratio has to be between 10^-8
> and 10^-4. I have implemented this as follows. 
> 
> In[395]:=
> dv:= Module[{v1n, d1n}, 
> While[
> (v1n=10^ Random[Real,{-12,-7}]); 
> (d1n=10^ Random[Real,{-6,-4}]); 
> 10^-8<= (v1n/d1n)<= 10^-4 ];
> {v1 -> v1n, d1 -> d1n, v1n/d1n//ScientificForm}]

Complement the "While" condition: change it to
  Not[10^-8<= (v1n/d1n)<= 10^-4]
or something equivalent, so that you loop UNTIL
v1n/d1n is within the acceptable range.

> [...]
> part2. 
> 
> what exactly is the difference between the following
> three repesentation of a range? (Peter suggested that
> i use the first represntation, and i'm starting to see
> why but i don't understand it) 

> In[90]:=
> {10^ Random[Real,{-12,-6}],
> Random[Real,10^{-12,-6}],
> Random[Real,{10^-12,10^-6}]}
> 
> upon repeat evaluating, it's easy to see that the
> first representation gives number over wider range
> while the other two stays within very short range.( in
> the order of 10^-7)

As ranges, the three representations are equivalent. However,
if a random variable U is uniformly distributed over {a,b}
then 10^U will not be uniformly distributed over {10^a,10^b}
but will be concentrated toward the bottom end of the range,
which your comments suggest that you want.


  • Prev by Date: Re: Function-type arguments in function definition
  • Next by Date: Re: simple equation system -- crashing M5?
  • Previous by thread: Re: now, while loops construct errors
  • Next by thread: Line and Polygon