I need to generate 625 different numbers between 1e-321 and 1e-200. However, when I use seq() function, it doesn't give me a good distribution.
seq(from = 1e-321, to = 1e-200, by = ((1e-200 - 1e-321)/624))
gives an output like this where only one value has -322 power (which is out of my range) and all others are in 1e-203, 1e-201, 1e-200 range.
I need an output, so all 625 numbers would be evenly distributed across the given range.
CodePudding user response:
It sounds, as @merv noted, that you want your numbers to be spaced evenly in log space, eg with a similar number in each order of magnitude. Here's one way. 1e-321
is the same as 10^-321
, so we could raise 10 to a series of exponents which themselves are evenly spaced.
10^seq(from = -321, to = -200, length.out = 625)
You'll note the output has 5 or 6 values for each order of magnitude, with each value about 1.563x the prior value. 1.563^624
(b/c there are 624 changes between 625 numbers) is approx. e 121
which is what we want -- 1e-200
is 121 orders of magnitude larger than 1e-321
.