https://github.com/winterland1989/means
calculate varieties of mean/average using semigroup.
https://github.com/winterland1989/means
Last synced: about 2 months ago
JSON representation
calculate varieties of mean/average using semigroup.
- Host: GitHub
- URL: https://github.com/winterland1989/means
- Owner: winterland1989
- License: mit
- Created: 2016-06-13T04:07:28.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-13T04:46:48.000Z (almost 9 years ago)
- Last Synced: 2025-02-08T06:31:00.727Z (4 months ago)
- Language: Haskell
- Size: 4.88 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
means
=====[](http://hackage.haskell.org/package/means)
[](https://travis-ci.org/winterland1989/means)This package provide following mean calculations using semigroup:
+ Arithmetic/ Weighted Arithmetic mean:

+ Geometric mean:

+ Harmonic mean:

+ Quadratic mean(RMS):

+ Cubic mean:

+ Midrange mean:

Check [wikipedia](https://en.wikipedia.org/wiki/Average) for details.
Example
-------```haskell
*Data.Semigroup.Means> getAM . foldr1 (<>) . map am $ [4, 36, 45, 50, 75]
42.0
*Data.Semigroup.Means> getGM . foldr1 (<>) . map gm $ [4, 36, 45, 50, 75]
30.000000000000007
*Data.Semigroup.Means> getHM . foldr1 (<>) . map hm $ [4, 36, 45, 50, 75]
15.0
*Data.Semigroup.Means> :m + Data.Ratio
*Data.Semigroup.Means Data.Ratio> getMM . foldr1 (<>) . map mm $ [4, 36, 45, 50, 75] :: Ratio Int
79 % 2
*Data.Semigroup.Means Data.Ratio> getAM . foldr1 (<>) . map am $ [4, 36, 45, 50, 75] :: Ratio Int
42 % 1
```