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)
In [12]:
frequency.shape
Out[12]:
In [15]:
bins = frequency.shape[0]
In [18]:
cumulative_frequency = stats.cumfreq(array, bins)
print(cumulative_frequency)b
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]: