In [2]:
import numpy as np
from scipy import stats

In [3]:
array = np.array([1, 1, 5, 0, 1, 2, 2, 0, 1, 4])

In [10]:
frequency = stats.itemfreq(array)
print(frequency)


[[0 2]
 [1 4]
 [2 2]
 [4 1]
 [5 1]]

In [12]:
frequency.shape


Out[12]:
(5, 2)

In [15]:
bins = frequency.shape[0]

In [18]:
cumulative_frequency = stats.cumfreq(array, bins)
print(cumulative_frequency)b


CumfreqResult(cumcount=array([  2.,   6.,   8.,   9.,  10.]), lowerlimit=-0.625, binsize=1.25, extrapoints=0)

In [69]:
%matplotlib notebook
import matplotlib.pyplot as plt

x = np.arange(bins)
fig = plt.figure(1)
plt.bar(x, cumulative_frequency.cumcount, width=cumulative_frequency.binsize)
plt.xlim([0, bins+1])
plt.ylim([0, cumulative_frequency.cumcount.max()+1])


Out[69]:
(0, 11.0)