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.