Does using the randperm function affect the probability?

조회 수: 4 (최근 30일)
Jaime Wu
Jaime Wu 2018년 8월 28일
댓글: Jaime Wu 2018년 8월 28일
I am trying to select random points from an array with equal probability. If i use the randperm function would that affect the probability of selecting any points from the array since there is no replacement? For example, if the array is 5x5, each point has 1/25 probability being selected. After selecting 1 point (without replacement) would that mean the probability for the remaining points increase to 1/24?
I am a bit confused if that is how this function work, would love if someone could explain this in a bit of a simpler way. Thanks!

답변 (2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 8월 28일
편집: KALYAN ACHARJYA 2018년 8월 28일
No
p=randperm(n) returns a row vector containing a random permutation of the integers from 1 to n inclusive. depending on the state of the random number generator. if random number generation the probability of selection is always the same.
  댓글 수: 1
Jaime Wu
Jaime Wu 2018년 8월 28일
Hi, even if i do something like this, the probability will always be equal?
a = randperm(256*256,5)
I was thinking that if i chose more than 1 value the probability will be affected? Kind of like drawing out coloured balls out of a bag and not replacing it

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


Walter Roberson
Walter Roberson 2018년 8월 28일
The code for randperm used to be approximately
[~, random_permutation] = sort( rand(1, N) );
The random values are chosen completely independently of each other, and then the ordering of those random values is found, and that is the random permutation. Determining the ordering obviously does not change the numeric values.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by