Azzera filtri
Azzera filtri

How to generate Zero mean and unit variance

30 visualizzazioni (ultimi 30 giorni)
I'm not sure how to generate 1024 samples of pseudo random numbers with zero mean and unit variance using rand and to verify the results with mean, std, and hist.
  2 Commenti
the cyclist
the cyclist il 18 Set 2014
What distribution do you want? Uniform? Normal? Something else?
Dick Rusell
Dick Rusell il 18 Set 2014
I think it is supposed to be uniform.

Accedi per commentare.

Risposta accettata

Roger Stafford
Roger Stafford il 18 Set 2014
Modificato: Roger Stafford il 18 Set 2014
If you want a uniform distribution do this:
n = 1024;
x = sqrt(3)*(2*rand(n,1)-1);
The random variable x will have a statistical mean of 0 and variance of 1. Of course any given n-element sample will deviate from these. These are only the statistically expected values.
  2 Commenti
senthil vel
senthil vel il 8 Gen 2019
why sqrt(3)*(2*rand(1024,1)-1)
Marius Hernes Brateng
Marius Hernes Brateng il 20 Ott 2020
this comes from the definition of variance. Solve this equation for a, get a = sqrt(3).

Accedi per commentare.

Più risposte (2)

the cyclist
the cyclist il 18 Set 2014
Modificato: the cyclist il 18 Set 2014
randn(1024,1)
will generate 1,024 normally distributed values from a population with zero mean and unit variance.
  3 Commenti
soumya dwibedy
soumya dwibedy il 16 Feb 2021
how to generate 1000 normally distributed values with (2 7 )mean and unit variance
the cyclist
the cyclist il 19 Feb 2021
It's usually better to post a new question, than a comment on a 6-year-old one (even though this is related). People won't typically see a comment buried in an old post. It was just lucky that I did.
I don't understand what you mean by "(2 7)mean". Did you you mean just "27"?

Accedi per commentare.


majid
majid il 19 Set 2014
Modificato: majid il 31 Mag 2015
it helped me so much...thank you انجام پروژه متلب

Categorie

Scopri di più su Random Number Generation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by