The random number from
does not have uniform distribution. You should use
or
to get a uniform distribution.
Each number would then have a probability of 1/101 of being chosen.
In general, to get uniformly distributed integers in the range [m,n] (including the endpoints) use:
or
or you can use
ref : derkeiler
> > round(rand(1)*1000)
does not have uniform distribution. You should use
> > floor(101*rand)
or
> > ceil(101*rand-1)
to get a uniform distribution.
Each number would then have a probability of 1/101 of being chosen.
In general, to get uniformly distributed integers in the range [m,n] (including the endpoints) use:
> > floor((n-m+1)*rand+m)
or
> > ceil((n-m+1)*rand+m-1)
or you can use
> > temp=randperm(n);
> > random_integer=temp(1);
ref : derkeiler
ความคิดเห็น