Returns a tuple (min(list), Q1, Q2, Q3, max(list)) for the given list of values. Q1, Q2, Q3 are the quantiles at 0.25, 0.5, 0.75 respectively.
(list, **kwargs)
| 655 | #print quantile(range(10), p=0.5) == median(range(10)) |
| 656 | |
| 657 | def boxplot(list, **kwargs): |
| 658 | """ Returns a tuple (min(list), Q1, Q2, Q3, max(list)) for the given list of values. |
| 659 | Q1, Q2, Q3 are the quantiles at 0.25, 0.5, 0.75 respectively. |
| 660 | """ |
| 661 | # http://en.wikipedia.org/wiki/Box_plot |
| 662 | kwargs.pop("p", None) |
| 663 | kwargs.pop("sort", None) |
| 664 | s = sorted(list) |
| 665 | Q1 = quantile(s, p=0.25, sort=False, **kwargs) |
| 666 | Q2 = quantile(s, p=0.50, sort=False, **kwargs) |
| 667 | Q3 = quantile(s, p=0.75, sort=False, **kwargs) |
| 668 | return float(min(s)), Q1, Q2, Q3, float(max(s)) |
| 669 | |
| 670 | #--- FISHER'S EXACT TEST --------------------------------------------------------------------------- |
| 671 |