rstoolbox.analysis.
cumulative
(values, bins=100, max_count=None, upper_limit=None, cumulative=1)¶Generates, for a given list of values, its cumulative distribution values.
This might be necessary in some cases when kernel estimates approximations do not accurately plot the data (specially when it alternates from very big to very small values).
Parameters: |
|
---|---|
Returns: | [ |
Example
In [1]: from rstoolbox.analysis import cumulative
...: import numpy as np
...: import matplotlib.pyplot as plt
...: np.random.seed(0)
...: data = np.random.rand(1000)
...: fig = plt.figure(figsize=(25, 25))
...: ax00 = plt.subplot2grid((2, 2), (0, 0), fig=fig)
...: ax01 = plt.subplot2grid((2, 2), (0, 1), fig=fig)
...: ax10 = plt.subplot2grid((2, 2), (1, 0), fig=fig)
...: ax11 = plt.subplot2grid((2, 2), (1, 1), fig=fig)
...: raw, y, x = cumulative(data)
...: ax00.plot(x, y)
...: ax00.set_title('cumulative')
...: raw, y, x = cumulative(data, cumulative=0)
...: ax01.plot(x, y)
...: ax01.set_title('non-cumulative')
...: raw, y, x = cumulative(data, cumulative=-1)
...: ax10.plot(x, y)
...: ax10.set_title('reverse-cumulative')
...: raw, y, x = cumulative(data)
...: ax11.plot(x, raw)
...: ax11.set_title('raw data')
...: plt.tight_layout()
...:
In [2]: fig.show()
In [3]: plt.close()