Number generator for 0.00006 to 30 range

1 次查看(过去 30 天)
I am attempting to run monte carlo simulations and wanted a random number between the end members of 0.000069 and 30 to populate this equation through each pass of a for loop. After looking at my model's output, I noticed that the Kd is heavily skewed toward larger numbers. I then came across this thread which led me to read about creating one's own random number stream. Is there a number generator out there that gives equal weight to each order of magnitude...ie I'd like the number generator to be equally likely to draw .0005, .05, 5, etc. Originally I didn't realize that unifrnd was not appropriate for 0 to 1 range. Thank you in advance for any guidance.
Kd=unifrnd(0.000069,30);

回答(2 个)

weikang zhao
weikang zhao 2022-9-14
It looks like you don't want these random numbers to follow a uniform distribution, you want their logarithms to follow a uniform distribution.
try this way:
a=log10(0.000069);
b=log10(30);
Kd=10^(unifrnd(a,b));

Chunru
Chunru 2022-9-14
% Kd=unifrnd(0.000069,30);
logminmax = log10([0.000069,30]);
for i=1:20
kdlog = unifrnd(logminmax(1), logminmax(2));
kd = 10^kdlog
end
kd = 0.0017
kd = 2.5985e-04
kd = 0.0066
kd = 0.0038
kd = 1.3455e-04
kd = 9.1956e-05
kd = 0.0160
kd = 0.0231
kd = 0.0272
kd = 3.1372e-04
kd = 0.0571
kd = 2.5811
kd = 0.1905
kd = 0.0177
kd = 0.1814
kd = 1.7050
kd = 0.1131
kd = 0.2859
kd = 0.8698
kd = 3.1837e-04

标签

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by