exonio 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +2 -2
- data/README.md +18 -0
- data/lib/exonio.rb +4 -1
- data/lib/exonio/{helpers.rb → helpers/irr_helper.rb} +1 -1
- data/lib/exonio/statistical.rb +41 -0
- data/lib/exonio/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 089644ebee28aed7078f0c5ed6c0c28e8ef58e6c
|
4
|
+
data.tar.gz: 994f36751c19bb074d6b47fe10fbc4f477321b3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5c946611830bb1de45b3933f4a7e78e6e8ef253e2e204f3ce0969f6cd5f55d271833f80cf1e71c934c0b37d0b8722f8fabedc4ad511cdfd9b66115586c78048
|
7
|
+
data.tar.gz: c1ee25b9476757738c18e4c2e7220edd4b214bf9a803727385284b1a8ae3473c63fce51b3e1e2374d25b26fd6e01721d257639502f1976dc54c061fd9e6c4dbf
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
This gem brings some useful Excel formulas to Ruby. For now, it just has
|
4
4
|
financial formulas, but could have more (like statistical formulas) in the future.
|
5
5
|
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/exonio.svg)](https://badge.fury.io/rb/exonio)
|
7
|
+
[![Build Status](https://travis-ci.org/Noverde/exonio.svg?branch=master)](https://travis-ci.org/Noverde/exonio)
|
8
|
+
|
6
9
|
## Installation
|
7
10
|
|
8
11
|
Add this line to your application's Gemfile:
|
@@ -124,6 +127,20 @@ Exonio.rate(12 * 3, 2_500, -50_000) # ==> 0.036006853458478955
|
|
124
127
|
|
125
128
|
So, the rate applied is 3.60%.
|
126
129
|
|
130
|
+
## Statistical formulas
|
131
|
+
|
132
|
+
### Sum
|
133
|
+
```ruby
|
134
|
+
Exonio.sum([1, 2, 3, 4, 5]) # ==> 15
|
135
|
+
```
|
136
|
+
### Mean
|
137
|
+
```ruby
|
138
|
+
Exonio.mean([1, 2, 3, 4, 5]) # ==> 3.0
|
139
|
+
```
|
140
|
+
### Median
|
141
|
+
```ruby
|
142
|
+
Exonio.median([1, 2, 3, 6, 5, 4]) # ==> 3.5
|
143
|
+
```
|
127
144
|
## TODO
|
128
145
|
|
129
146
|
There's a lot of formulas to be implemented, including:
|
@@ -158,3 +175,4 @@ Exonio is released under the MIT License.
|
|
158
175
|
A special thanks goes to the python [NumPy project](http://www.numpy.org/), which was the source for most
|
159
176
|
of the formulas.
|
160
177
|
|
178
|
+
|
data/lib/exonio.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
require 'bigdecimal'
|
2
2
|
require 'bigdecimal/newton'
|
3
|
+
require "bigdecimal/util"
|
3
4
|
|
4
5
|
require 'exonio/version'
|
5
6
|
require 'exonio/financial'
|
6
|
-
require 'exonio/
|
7
|
+
require 'exonio/statistical'
|
8
|
+
require 'exonio/helpers/irr_helper'
|
7
9
|
|
8
10
|
module Exonio
|
9
11
|
extend Newton
|
10
12
|
extend Financial
|
13
|
+
extend Statistical
|
11
14
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Exonio
|
2
|
+
module Statistical
|
3
|
+
|
4
|
+
# Sum of all numbers
|
5
|
+
#
|
6
|
+
# @param numbers_ary [array] and array of numbers to sum all elements
|
7
|
+
#
|
8
|
+
# @return [float]
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# Exonio.sum([1,2,3,4,5]) # => 15
|
12
|
+
def sum(numbers_ary)
|
13
|
+
numbers_ary.inject(0, :+)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Simple mean formula: sum elements and / by length
|
17
|
+
#
|
18
|
+
# @param numbers_ary [array] an array of numbers to calculate the mean
|
19
|
+
#
|
20
|
+
# @return [float]
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# Exonio.mean([1,2,3,4,5]) # => 3.0
|
24
|
+
def mean(numbers_ary)
|
25
|
+
numbers_ary.inject(0) { |sum, i| sum + i }.to_f / numbers_ary.size
|
26
|
+
end
|
27
|
+
|
28
|
+
# Median formula
|
29
|
+
# @param numbers_ary [array] an array of numbers
|
30
|
+
#
|
31
|
+
# @return [float]
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# Exonio.median([1,2,3,4,5]) # => 3.0
|
35
|
+
def median(numbers_ary)
|
36
|
+
numbers_ary.sort!
|
37
|
+
len = numbers_ary.length
|
38
|
+
(numbers_ary[(len - 1) / 2] + numbers_ary[len / 2]) / 2.0
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/exonio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exonio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Izidoro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -88,7 +88,8 @@ files:
|
|
88
88
|
- exonio.gemspec
|
89
89
|
- lib/exonio.rb
|
90
90
|
- lib/exonio/financial.rb
|
91
|
-
- lib/exonio/helpers.rb
|
91
|
+
- lib/exonio/helpers/irr_helper.rb
|
92
|
+
- lib/exonio/statistical.rb
|
92
93
|
- lib/exonio/version.rb
|
93
94
|
homepage: http://github.com/noverde/exonio
|
94
95
|
licenses: []
|