# L-10.5 MCS 260 Wed 9 Jul 2014 : q08.py
"""
To whether random.uniform(0,1) generates numbers uniformly distributed
in [0, 1], we generate 1000 samples and build a histogram,
counting how many numbers are in the four equal subintervals of [0, 1].
Write Python code to perform this test.
"""
from random import uniform as u
L = [u(0, 1) for k in range(1000)]
H = [0 for k in range(4)]
for r in L:
    if r < 0.25:
        H[0] = H[0] + 1
    elif r < 0.50:
        H[1] = H[1] + 1
    elif r < 0.75:
        H[2] = H[2] + 1
    else:
        H[3] = H[3] + 1
print 'histogram :', H
