[Scilab-users] Can you suggest a more efficient procedure for generating random variables?

Heinz Nabielek heinznabielek at me.com
Mon Mar 18 09:22:35 CET 2019


y is a previously defined table with values monotonically increasing from zero to one. 
h

> On 18.03.2019, at 06:43, Federico Miyara <fmiyara at fceia.unr.edu.ar> wrote:
> 
> 
> Heinz,
> 
> I don't find your example clear enough. What's y? Is it defined previously?
> 
> Perhaps an example would be useful.
> 
> Regards,
> 
> Federico Miyara
> 
> 
> On 17/03/2019 19:49, Heinz Nabielek wrote:
>> I need to generate random deviates x according to a given cumulative distribution y that is available only in tabular form.
>> 
>> Scilab coding was easy by table lookup:
>> 
>> length(y)=   360. // only for general information
>> N=1000;
>> z=grand(1,N,'def');
>> x=[];
>> for i=1:N;
>> x=[x find(y>z(i),1)];
>> end;
>> 
>> Problem is that execution times are exponentially increasing when I want one million deviates.
>> 
>> Can you suggest a significantly more efficient procedure?
>> Heinz




More information about the users mailing list