samedi 25 juin 2016

Big random numbers on GNU Octave or matlab

I need to generate random numbers between 0 and 1e37. I've tried these codes:

numbers = [];
numbers= [numbers; unifrnd(0,1e37, numSamples, 1)];

_

numbers = [];
for i=1:numSamples 
numbers= [numbers;  0 + (9-0)*rand(1) * 10**(0 + (35 - 0)*rand(1))];
endfo

Both codes generate an array [numSamples,1] full of random numbers but when I plot the results, or see their values, I realize that most part of them are between 1e36 and 1e37. What I'm looking for is a normal or gaussian distribution, I mean, I want most part of those random numbers to be between 1e15 and 1e30 for example, but I don't know how I could achieve this.

I've tried this on GNU Octave but it doesn't matter if someone gives a solution on Matlab.

Forgot to say that I'm trying with 1e3 < numSamples < 1e7




Aucun commentaire:

Enregistrer un commentaire