help random numbers generator
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Daniele1
le 23 Mai 2020
Réponse apportée : Jeff Miller
le 25 Mai 2020
Hi everyone, I'd like to know how to generate a set of random numbers with normal distribution (randn) belonging to a range defined by me.
To make it easier:
I want to generate 10 random numbers between [-0.5 0.5] using randn.
Thanks for your attention
0 commentaires
Réponse acceptée
Jeff Miller
le 25 Mai 2020
Good. Here it is as an 'official' answer:
pd = makedist('Normal');
t = truncate(pd,-0.5,0.5);
r = random(t,10,1);
0 commentaires
Plus de réponses (1)
KSSV
le 23 Mai 2020
a = -0.5 ;
b = 0.5 ;
N = 10 ;
r = (b-a).*randn(N,1) + a;
7 commentaires
Jeff Miller
le 25 Mai 2020
If that would work, then I guess this is what you are after:
pd = makedist('Normal');
t = truncate(pd,-0.5,0.5);
r = random(t,10,1);
Voir également
Catégories
En savoir plus sur Random Number Generation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!