MathGroup Archive 2004

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

Search the Archive

significant digits in random numbers in scientificform

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46278] significant digits in random numbers in scientificform
  • From: sean_incali at yahoo.com (sean kim)
  • Date: Fri, 13 Feb 2004 02:28:47 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

hello group. 

few more questions. 

how do I pick random numbers such that, when displayed in
ScientificForm, the coefficients only vary to designated number of
digits?

Example: 1.2345x 10^1 has significant digits of 5 (1.2345), where as
1.2*10^3 has signficant digits of 2.(1.2)

consider the following.

In[601]:=
rule1 = {k1 ->10^Random[Real,{1,3}, 2]//ScientificForm,
    k2 ->10^Random[Real,{1,3}, 5]//ScientificForm}

k1 + k2/.rule1

but above gives following errors.

ReplaceAll::reps :(k1 -> 1.4×10^2, k2 -> 7.875×10^1) is neither a list
of replacement rules nor a valid dispatch table, and so cannot be used
for replacing. "More?"

What I wanted Mathematica to  pick was something like...

(random real number to given digits) *10^ (random integer chosen from
range)

So the question is two fold. How do I tell mathematica to pick random
numbers only in designated number of digits? and use that in
downstream calculations?

if I use..

Random[Real, {1,10},5]* 10 ^ Random[Integer, {1, 3}] 

above does what I want but I hate the idea of using two Random, and
I'm worried that it will cause problems. and i would liek to see how
you guys would do it.

will the routine be too slow If i have to use it many many times? and
if so why and how do i fix it?

thank you all very much in advance as always. 

sean


  • Prev by Date: Re: how to plot with logarithmic scale on X-axis ?
  • Next by Date: Re: FindRoot in Version 5
  • Previous by thread: Re: Estimating parameters p and q in y'' + p y' + q y = Tide(t)
  • Next by thread: Re: significant digits in random numbers in scientificform