In [1]:
import numpy as np
from scipy import stats
In [2]:
array = np.array([1, 1, 5, 0, 1, 2, 2, 0, 1, 4])
In [9]:
frequency = stats.itemfreq(array)
print(frequency)
In [4]:
frequency.shape
Out[4]:
In [5]:
bins = frequency.shape[0]
In [7]:
cumulative_frequency = stats.cumfreq(array, bins)
print(cumulative_frequency)
In [8]:
%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[8]: