Skip to content

Commit 3f6b1f9

Browse files
authored
Merge pull request #12 from bencheeorg/bumping
Prep 1.1.0
2 parents 7d8f1b5 + 7d9eb6d commit 3f6b1f9

4 files changed

Lines changed: 55 additions & 13 deletions

File tree

README.md

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ iex> samples = [1, 3.0, 2.35, 11.0, 1.37, 35, 5.5, 10, 0, 2.35]
2828
# calculate all available statistics at once, efficiently reusing already calculated values
2929
iex> Statistex.statistics(samples)
3030
%Statistex{
31+
total: 71.57,
3132
average: 7.156999999999999,
33+
variance: 109.66060111111112,
34+
standard_deviation: 10.471895774457991,
35+
standard_deviation_ratio: 1.4631683351205802,
36+
median: 2.675,
37+
percentiles: %{25 => 1.2775, 50 => 2.675, 75 => 10.25},
3238
frequency_distribution: %{
3339
0 => 1,
3440
1 => 1,
@@ -40,16 +46,13 @@ iex> Statistex.statistics(samples)
4046
5.5 => 1,
4147
11.0 => 1
4248
},
43-
maximum: 35,
44-
median: 2.675,
45-
minimum: 0,
4649
mode: 2.35,
47-
percentiles: %{50 => 2.675},
48-
sample_size: 10,
49-
standard_deviation: 10.47189577445799,
50-
standard_deviation_ratio: 1.46316833512058,
51-
total: 71.57,
52-
variance: 109.6606011111111
50+
minimum: 0,
51+
maximum: 35,
52+
lower_outlier_bound: -12.18125,
53+
upper_outlier_bound: 23.708750000000002,
54+
outliers: [35],
55+
sample_size: 10
5356
}
5457
# or just calculate the value you need
5558
iex> Statistex.average(samples)
@@ -63,6 +66,34 @@ iex> Statistex.average(samples, sample_size: 10)
6366
# output is likely also very different from when you have statistics.
6467
iex> Statistex.statistics([])
6568
** (ArgumentError) Passed an empty list ([]) to calculate statistics from, please pass a list containing at least one number.
69+
# You can exclude outliers from the calculation of statistics
70+
iex> Statistex.statistics(samples, exclude_outliers: true)
71+
%Statistex{
72+
total: 36.57,
73+
average: 4.0633333333333335,
74+
variance: 15.696975,
75+
standard_deviation: 3.96194081227875,
76+
standard_deviation_ratio: 0.9750469595435808,
77+
median: 2.35,
78+
percentiles: %{25 => 1.185, 50 => 2.35, 75 => 7.75},
79+
frequency_distribution: %{
80+
0 => 1,
81+
1 => 1,
82+
10 => 1,
83+
1.37 => 1,
84+
2.35 => 2,
85+
3.0 => 1,
86+
5.5 => 1,
87+
11.0 => 1
88+
},
89+
mode: 2.35,
90+
minimum: 0,
91+
maximum: 11.0,
92+
lower_outlier_bound: -12.18125,
93+
upper_outlier_bound: 23.708750000000002,
94+
outliers: [35],
95+
sample_size: 9
96+
}
6697
```
6798

6899
## Supported Statistics
@@ -83,6 +114,8 @@ Statistics currently supported:
83114
* standard_deviation_ratio
84115
* total
85116
* variance
117+
* outliers (determining outliers)
118+
* outlier bounds (lower and upper bound of when samples start being considered outliers)
86119

87120
## Alternatives
88121

lib/statistex.ex

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ defmodule Statistex do
462462
Calculates the value at the `percentile_rank`-th percentile.
463463
464464
Think of this as the value below which `percentile_rank` percent of the samples lie.
465-
For example, if `Statistex.percentile(samples, 99) == 123.45`,
465+
For example, if `Statistex.percentiles(samples, 99) == 123.45`,
466466
99% of samples are less than 123.45.
467467
468468
Passing a number for `percentile_rank` calculates a single percentile.
@@ -513,6 +513,10 @@ defmodule Statistex do
513513
@spec percentiles(samples, number | [number(), ...]) ::
514514
percentiles()
515515
defdelegate percentiles(samples, percentiles, options), to: Percentile
516+
517+
@doc """
518+
See `percentiles/3`.
519+
"""
516520
defdelegate percentiles(samples, percentiles), to: Percentile
517521

518522
@doc """
@@ -703,6 +707,8 @@ defmodule Statistex do
703707
704708
Returns: `{outliers, remaining_samples`} where `remaining_samples` has the outliers removed.
705709
710+
`Argumenterror` is raised if the given list is empty.
711+
706712
## Options
707713
* `:outlier_bounds` - if you already have calculated the outlier bounds.
708714
* `:percentiles` - you can pass it a map of calculated percentiles (25th and 75th are needed).
@@ -723,6 +729,9 @@ defmodule Statistex do
723729
724730
iex> Statistex.outliers([50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 99, 99, 99])
725731
{[99, 99, 99], [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]}
732+
733+
iex> Statistex.outliers([])
734+
** (ArgumentError) Passed an empty list ([]) to calculate statistics from, please pass a list containing at least one number.
726735
"""
727736
@spec outliers(samples, keyword) :: {samples | [], samples}
728737
def outliers(samples, options \\ []) do

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Statistex.MixProject do
22
use Mix.Project
33

4-
@version "1.0.0"
4+
@version "1.1.0"
55
def project do
66
[
77
app: :statistex,

mix.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
33
"credo": {:hex, :credo, "1.7.12", "9e3c20463de4b5f3f23721527fcaf16722ec815e70ff6c60b86412c695d426c1", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8493d45c656c5427d9c729235b99d498bd133421f3e0a683e5c1b561471291e5"},
44
"dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"},
5-
"earmark": {:hex, :earmark, "1.4.47", "7e7596b84fe4ebeb8751e14cbaeaf4d7a0237708f2ce43630cfd9065551f94ca", [:mix], [], "hexpm", "3e96bebea2c2d95f3b346a7ff22285bc68a99fbabdad9b655aa9c6be06c698f8"},
5+
"earmark": {:hex, :earmark, "1.4.48", "5f41e579d85ef812351211842b6e005f6e0cef111216dea7d4b9d58af4608434", [:mix], [], "hexpm", "a461a0ddfdc5432381c876af1c86c411fd78a25790c75023c7a4c035fdc858f9"},
66
"earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"},
77
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
8-
"ex_doc": {:hex, :ex_doc, "0.37.3", "f7816881a443cd77872b7d6118e8a55f547f49903aef8747dbcb345a75b462f9", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "e6aebca7156e7c29b5da4daa17f6361205b2ae5f26e5c7d8ca0d3f7e18972233"},
8+
"ex_doc": {:hex, :ex_doc, "0.38.2", "504d25eef296b4dec3b8e33e810bc8b5344d565998cd83914ffe1b8503737c02", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "732f2d972e42c116a70802f9898c51b54916e542cc50968ac6980512ec90f42b"},
99
"excoveralls": {:hex, :excoveralls, "0.18.5", "e229d0a65982613332ec30f07940038fe451a2e5b29bce2a5022165f0c9b157e", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "523fe8a15603f86d64852aab2abe8ddbd78e68579c8525ae765facc5eae01562"},
1010
"file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"},
1111
"inch_ex": {:hex, :inch_ex, "2.0.0", "24268a9284a1751f2ceda569cd978e1fa394c977c45c331bb52a405de544f4de", [:mix], [{:bunt, "~> 0.2", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "96d0ec5ecac8cf63142d02f16b7ab7152cf0f0f1a185a80161b758383c9399a8"},

0 commit comments

Comments
 (0)