Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I asked the same question in the post: A special random subset of uniformly distributed numbers is still uniformly distributed?

Let me describe my question again. Assume that I have a value range [1,1000].

Goal: I want to have 10 numbers randomly sampled from [1,1000].


I sample 20 numbers, a1, ..., a20 from [1,1000].

Then I sample b1, ..., b10 from [a1, a2, ..., a20].

b1, ..., b10 are what I want.


I partition [1,1000] into 10 intervals, 

I1=[1,100], I2=[101,200], ... I10=[901,1000].

Then I sample one number bi from Ii. 

Eventually I still have 10 numbers b1, ..., b10.

Everyone said that the numbers in case2 are not uniformly distributed.

I also agree with that.

However, I used MATLAB to generate case1 and case2, and then I ran 2-sample kolmogorov smirnov test on case1 and case2.

Eventually, kolmogorov smirnov test told me that they are the same!! (always accept null hypothesis)

Can anyone explain this phenomenon?

My code is as follows for the reference.

clear all;


for in=1:10
    case2=[case2 randi( [((in-1)*100)+1 in*100]  ,1,1 ) ];

share|cite|improve this question
Typically, null hypothesis is rejected only when there is strong evidence it is false. Small samples seldom lead to rejection of null hypothesis. – André Nicolas May 19 '13 at 19:11
You're hiding the non-randomness under a layer of randomness; hence it takes a large sample to discover it. Sample Case 1 at random in [0,9] and make Case 2 cycle through [0,9]. This will strip away the extra layer, and KS will give you a better answer. – vadim123 May 19 '13 at 19:23
@vadim123 I don't get what you mean. Do you mean that for case 1, I sample just a number from [0,9]. And then, for case 2, how should I do? – user4478 May 19 '13 at 19:34
@user4478 Case 2 loops through 0,9 just as you have now (only without the extra 2 digits). – vadim123 May 19 '13 at 19:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.