https://github.com/lovasko/staf
Statistics for Foldable containers
https://github.com/lovasko/staf
Last synced: about 1 year ago
JSON representation
Statistics for Foldable containers
- Host: GitHub
- URL: https://github.com/lovasko/staf
- Owner: lovasko
- License: bsd-2-clause
- Created: 2016-12-15T14:22:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-28T02:23:28.000Z (over 9 years ago)
- Last Synced: 2025-05-01T00:40:07.612Z (about 1 year ago)
- Language: Haskell
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/lovasko/staf)
[](https://codeclimate.com/github/lovasko/staf)
# Stats.Foldable
A pure Haskell module that implements a safe interface to a set of statistical
computations for all `Foldable` containers. Folding (i.e. _reducing_ or
_crushing_) is a great fit for statistics, where a full data set has to be
reduced to a single object that represents the set in a meaningful way.
## Install
There are two standard ways of obtainig the module:
* by cloning the GitHub repository: `git clone https://github.com/lovasko/staf`
* by using the central Hackage server: `cabal install staf`
## API
All `staf` functions use the `Maybe` type to represent a failure (e.g. an empty
container provided as the input). All numerical arguments are limited to the
least-assuming typeclass. The module exports the following 7 functions:
#### Arithmetic mean
```haskell
amean :: (F.Foldable f, Floating a)
=> f a -- ^ population
-> Maybe a -- ^ arithmetic mean
```
#### Minimum
```haskell
min :: (F.Foldable f, Ord a)
=> f a -- ^ population
-> Maybe a -- ^ minimal value
```
#### Maximum
```haskell
max :: (F.Foldable f, Ord a)
=> f a -- ^ population
-> Maybe a -- ^ maximal value
```
#### Variance
```haskell
var :: (F.Foldable f, Floating a)
=> f a -- ^ population
-> Maybe a -- ^ variance
```
#### Standard deviation
```haskell
stddev :: (F.Foldable f, Floating a)
=> f a -- ^ population
-> Maybe a -- ^ standard deviation
```
#### Covariance
```haskell
covar :: (F.Foldable f, Floating a)
=> f a -- ^ first population
-> f a -- ^ second population
-> Maybe a -- ^ covariance
```
#### Pearson correlation
```haskell
correl :: (F.Foldable f, Floating a)
=> f a -- ^ first population
-> f a -- ^ second population
-> Maybe a -- ^ correlation
```
## Numerical stability
There is no current stability guarantee in any of the provided algorithms.
## License
The `staf` module is licensed under the [2-clause BSD license](LICENSE). In
case that any other licensing is needed, feel free to contact the author.
## Author
Daniel Lovasko