how to generate random data (dichotomous 0-1) with normal distrubition

조회 수: 6 (최근 30일)
Selin Soguksu
Selin Soguksu 2012년 3월 27일
Hello, I am a measurement and evaluation student and I want to generate [10000,10] random data with matlab. But these data includes only 0 and 1 and has a normal distrubition. First I used binornd function, but the data I generated did not have normal distrubition. Then I used normrnd function, but the datas I created has decimal points and some of them are negative. Please help me... Beril
  댓글 수: 1
RNTL
RNTL 2012년 3월 27일
If your set contain only two values, namely [0,1] how can it has normal distribution?
Your set should be defined by a probability function that is nonzero only for those two values, hence it cannot be derived from normal distribution.

댓글을 달려면 로그인하십시오.

답변 (3개)

RNTL
RNTL 2012년 3월 27일
If your set contain only two values, namely [0,1] how can it has normal distribution? Your set should be defined by a probability function that is nonzero only for those two values, hence it cannot be derived from normal distribution

Image Analyst
Image Analyst 2012년 3월 27일
Maybe you want randi
zerosAndOnes = randi(2, [1 1000]) - 1
but it's not going to be a normal distribution. That's impossible with only two values.
  댓글 수: 3
Jonathan Sullivan
Jonathan Sullivan 2012년 3월 27일
I think when he says "normally" distributed, I think he means *uniformly* distributed. That's my guess.
Image Analyst
Image Analyst 2012년 3월 27일
andrei: yep. Jonathan: maybe he wants a random distribution where there are equal numbers of 1's and 0's??? Maybe if those numbers are equal he's calling *that* normal or uniform. Or maybe he just doesn't care anymore and went away. I don't know why Beril is not clearing this up.

댓글을 달려면 로그인하십시오.


Selin Soguksu
Selin Soguksu 2012년 3월 28일
Hello, Thank you for the answers. I am studying simulation in Matlab. I want to explain my trouble a little more. I have a test which contains 30 items and 10000 sample. When a sample has a success in an item he has 1 point or has failure in an item he has 0 point. Then for every sample, I calculate their total scores. Now I have a one column and 10000 rows [10000,1] which includes total scores of the samples. Now I want these scores normally distributed. So I have to make a simulation including [10000,30] matrix which has only zeros and ones. And the total scores has a normal distrubition. Thank you.
  댓글 수: 1
Daniel Shub
Daniel Shub 2012년 3월 28일
This cannot be a normal distribution. If I create a 1e4x30 matrix of 0 or 1, the total will always be an integer between 0 and 30. Are you sure you do not want a binomial distribution? Is the score on item i independent from the score on item j?

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by