Skip to content

Commit

Permalink
Merge 0e61465 into d1f0913
Browse files Browse the repository at this point in the history
  • Loading branch information
PragTob committed Jul 5, 2019
2 parents d1f0913 + 0e61465 commit b0ff110
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.0 yyyy-mm-dd
## 1.0 2019-07-05

Import of the initial functionality from [benchee](github.com/bencheeorg/benchee).

Expand Down
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ iex> samples = [1, 3.0, 2.35, 11.0, 1.37, 35, 5.5, 10, 0, 2.35]
iex> Statistex.statistics(samples)
%Statistex{
average: 7.156999999999999,
frequency_distribution: %{
0 => 1,
1 => 1,
10 => 1,
35 => 1,
1.37 => 1,
2.35 => 2,
3.0 => 1,
5.5 => 1,
11.0 => 1
},
maximum: 35,
median: 2.675,
minimum: 0,
Expand All @@ -35,7 +46,8 @@ iex> Statistex.statistics(samples)
sample_size: 10,
standard_deviation: 10.47189577445799,
standard_deviation_ratio: 1.46316833512058,
total: 71.57
total: 71.57,
variance: 109.6606011111111
}
# or just calculate the value you need
iex> Statistex.average(samples)
Expand All @@ -51,11 +63,30 @@ iex> Statistex.statistics([])
** (ArgumentError) Passed an empty list ([]) to calculate statistics from, please pass a list containing at least on number.
```

## Supported Statistics

For an up to date overview with explanations please check out the documentation.

Statistics currently supported:

* average
* frequency_distribution
* maximum
* median
* minimum
* mode
* percentiles
* sample_size
* standard_deviation
* standard_deviation_ratio
* total
* variance

## Alternatives

In elixir there are 2 notable other libraries that I'm aware of: [statistics](https://github.com/msharp/elixir-statistics) and [Numerix](https://github.com/safwank/Numerix).

Both include more functions than just statistics functions as in general math functions and more. They also have more statistics related functions as of this writing. So if you'e looking for something, that Statistex doesn't provide these are some of the first places I'd look.
Both include more functions than just for statistics: general math and more (drawing of random values for instance). They also have more statistics related functions as of this writing. So if you'e looking for something, that Statistex doesn't provide (yet) these are some of the first places I'd look.

Why would you still want to use Statistex?

Expand Down
9 changes: 5 additions & 4 deletions lib/statistex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ defmodule Statistex do
A measurement how much samples vary (the higher the more the samples vary). This is the variance of a sample and is hence in its calculation divided by sample_size - 1 (Bessel's correction).
`Argumenterror` is raised if the given list is empty.
## Options
If already calculated, the `:average` and `:sample_size` options can be provided to avoid recalulating those values.
`Argumenterror` is raised if the given list is empty.
## Examples
iex> Statistex.variance([4, 9, 11, 12, 17, 5, 8, 12, 12])
Expand Down Expand Up @@ -454,6 +454,8 @@ defmodule Statistex do
Goes from a concrete occurence of the sample to the number of times it was observed in the samples.
`Argumenterror` is raised if the given list is empty.
## Examples
iex> Statistex.frequency_distribution([1, 2, 4.23, 7, 2, 99])
Expand Down Expand Up @@ -504,8 +506,7 @@ defmodule Statistex do
[1, 3, 5]
"""
@spec mode(samples, keyword) :: mode
defdelegate mode(samples), to: Mode
defdelegate mode(samples, opts), to: Mode
def mode(samples, opts \\ []), do: Mode.mode(samples, opts)

@doc """
Calculates the median of the given samples.
Expand Down

0 comments on commit b0ff110

Please sign in to comment.