normale_distribution 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 394e4ec0ea40117b42c097903d253d590ea380ea
4
+ data.tar.gz: a6beebab07d01cd3b7c27f41d0eeac37e194d598
5
+ SHA512:
6
+ metadata.gz: 4423bd75b8939437288ad11562e0745995898a96fc15b788a98ecce6374798e0f57e9bf4e73431002d934a29e8fd4fa74b9fc00ab2159c3e8d93a1c38dc57ee5
7
+ data.tar.gz: d8f0fd53b27bb9d55b9ba1768791de00c079258113088b6ac2f3a8d595a3c22ec6f2782975ba323af808db7f47c97c35407329b79b1ef4f3ba3f3d2a76875885
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ n�:�Y�l)�9��Z(�'�2�n1����Dc��^�5��M��/�H�\5��/�j�v�_���Wo�0��8�!:����[�}!�-��,"�@��vإ���g��ƥ��������!zl],X(AX+l�/��)��Y[ڤ��5߰T���;a��\�N�t
2
+ ����@��EDQ�M3�HB*Mq��ǘ�>F~?ɘ!��Ԣ;������0����.iKNq/�v��rG-��� [��p�{�5�>̇�
data.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+ Y���lY�YaZ{i\� ����F�פ�N'�>k5��2Bw����"�K���b�i�;�0��6��(���I(h�r��y�e���u�������6���f�7'�Dh��M,2��{�(L�z��T���fܦE�+ګr[=V���c���ZH������5�kѕ�k���۝M�] ̉ER�*w�p���g���l�2@� mD�~J���0uE��1�Z>�aU�__T�ZCb�ً���6H�g�+H�;�VŔk.%
data/CHANGELOG ADDED
@@ -0,0 +1,4 @@
1
+ v0.1
2
+ * Initialize project
3
+ * Gemfile and dependancies
4
+ * Create unitary test (cover 100%)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'nomorebeer' # action against drunk driving
4
+
data/Gemfile.lock ADDED
@@ -0,0 +1,13 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ nomorebeer (1.1)
5
+
6
+ PLATFORMS
7
+ ruby
8
+
9
+ DEPENDENCIES
10
+ nomorebeer
11
+
12
+ BUNDLED WITH
13
+ 1.11.2
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Normale
2
+
3
+
4
+ ## Installation
5
+
6
+ ```sh
7
+ gem install normale_distribution
8
+ ```
9
+
10
+ or in the ``Gemfile``
11
+
12
+ ```ruby
13
+ gem 'normale_distribution'
14
+ ```
15
+
16
+
17
+ ## Usage in Ruby
18
+
19
+ ```ruby
20
+ require 'normale_distribution'
21
+
22
+ NormaleDistribution::between standard_deviation: 15, esperance: 100, a: 85, b: 115 # => 0.6826894921370859
23
+ NormaleDistribution::less_than standard_deviation: 15, esperance: 100, a: 85 # => 0.15865525393145707
24
+ NormaleDistribution::greater_than standard_deviation: 15, esperance: 100, a: 115 # => 0.15865525393145707
25
+ ```
26
+
27
+
28
+ ## Unitary tests
29
+
30
+ ```sh
31
+ rake test
32
+ ```
33
+
34
+
35
+ ## Contributes !
36
+
37
+ Find a bug ? Want a new feature ?
38
+ Create a clear pull request and we'll see :)
39
+
40
+ - Nephos (poulet_a)
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ #encoding: utf-8
2
+
3
+ task :default => [:test]
4
+
5
+ task :test do
6
+ ruby "test/unit_test.rb"
7
+ end
8
+
9
+ namespace :test do
10
+
11
+ desc "Unitary tests."
12
+ task :test do
13
+ ruby "test/unit_test.rb"
14
+ end
15
+
16
+ end
data/certs/nephos.pem ADDED
@@ -0,0 +1,22 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRYwFAYDVQQDDA1hcnRo
3
+ dXIucG91bGV0MRkwFwYKCZImiZPyLGQBGRYJY3J5cHRvbGFiMRMwEQYKCZImiZPy
4
+ LGQBGRYDbmV0MB4XDTE1MTAwMzIxNTQyMFoXDTE2MTAwMjIxNTQyMF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Jx1RvWZpIyH5uJhRUYK3+vU9nMOxez5WbIlC1TtpByKAPMX+sht
21
+ gib3AoIT8jh/2w==
22
+ -----END CERTIFICATE-----
@@ -0,0 +1,13 @@
1
+ require_relative 'normale_distribution/persistant'
2
+
3
+ module NormaleDistribution
4
+ def self.between standard_deviation: nil, esperance: nil, sd: 1.0, e: 0.0, a: nil, b: nil
5
+ NormaleDistribution::Persistant.new(standard_deviation: standard_deviation||sd, esperance: esperance||e).between a, b
6
+ end
7
+ def self.greater_than standard_deviation: nil, esperance: nil, sd: 1.0, e: 0.0, a: nil
8
+ NormaleDistribution::Persistant.new(standard_deviation: standard_deviation||sd, esperance: esperance||e).greater_than a
9
+ end
10
+ def self.less_than standard_deviation: nil, esperance: nil, sd: 1.0, e: 0.0, a: nil, b: nil
11
+ NormaleDistribution::Persistant.new(standard_deviation: standard_deviation||sd, esperance: esperance||e).less_than a
12
+ end
13
+ end
@@ -0,0 +1,32 @@
1
+ module NormaleDistribution
2
+ class Persistant
3
+ attr_accessor :standard_deviation, :esperance
4
+ def initialize standard_deviation: 1.0, esperance: 0.0
5
+ @standard_deviation = Float(standard_deviation)
6
+ @esperance = Float(esperance)
7
+ raise ArgumentError, "standard_deviation must be > 0" unless @standard_deviation > 0.0
8
+ end
9
+
10
+ def greater_than a
11
+ 1 - repartition(a)
12
+ end
13
+
14
+ def less_than a
15
+ repartition a
16
+ end
17
+
18
+ def between a, b
19
+ repartition(b) - repartition(a)
20
+ end
21
+
22
+ private
23
+ def density t
24
+ #1.0 / (standard_deviation * (2 * Math::PI) ** 0.5) * Math::exp((t - esperance) / (2 * standard_deviation)))
25
+ end
26
+
27
+ def repartition t
28
+ erf = (Float(t) - esperance) / (standard_deviation * 2.0**0.5)
29
+ 0.5 * (1.0 + Math.erf(erf))
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,38 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'normale_distribution'
3
+ s.version = File.read("version")
4
+ s.date = Time.now.getgm.to_s.split.first
5
+ s.summary = File.read("CHANGELOG").match(/^v[^\n]+\n((\t[^\n]+\n)+)/m)[1].split("\t").join
6
+ s.description = 'A ruby implementation of the Normal Distribution'
7
+ s.authors = ['Nephos (poulet_a)']
8
+ s.email = ['arthur.poulet@mailoo.org']
9
+ s.files = %w(
10
+ lib/normale_distribution.rb
11
+ lib/normale_distribution/persistant.rb
12
+
13
+ README.md
14
+ CHANGELOG
15
+
16
+ Rakefile
17
+ Gemfile
18
+ Gemfile.lock
19
+ normale_distribution.gemspec
20
+ version
21
+
22
+ test/unit_test.rb
23
+ test/normale_distribution.rb
24
+
25
+ certs/nephos.pem
26
+ )
27
+ s.executables = %w(
28
+ )
29
+ s.homepage = 'https://github.com/Nephos/NormaleDistribution'
30
+ s.license = 'WTFPL'
31
+
32
+ s.cert_chain = ['certs/nephos.pem']
33
+ s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $0 =~ /gem\z/
34
+
35
+ # s.add_dependency 'nephos', '~> 1.0'
36
+ s.add_dependency 'nomorebeer', '~> 1.1'
37
+
38
+ end
@@ -0,0 +1,33 @@
1
+ class TestNormale < Test::Unit::TestCase
2
+
3
+ def test_simple
4
+ NormaleDistribution::Persistant.new
5
+ NormaleDistribution::Persistant.new standard_deviation: 1
6
+ NormaleDistribution::Persistant.new esperance: 1
7
+ end
8
+
9
+ def test_qi
10
+ rule = NormaleDistribution::Persistant.new standard_deviation: 15, esperance: 100
11
+ assert_equal 0.68, rule.between(85, 115).round(2)
12
+ end
13
+
14
+ def test_centroid
15
+ [0.1, 1, 2, 4.1324].each do |space|
16
+ [0, 1, -1, 12, 41, 0.2, 0.233].each do |center|
17
+ rule = NormaleDistribution::Persistant.new standard_deviation: space, esperance: center
18
+ [0.2, 0.4, 0.45, 0.55, 0.94, 1.1].each do |diff|
19
+ assert_equal -rule.between(diff, center), rule.between(center, diff)
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ def test_error
26
+ assert_raise { NormaleDistribution::Persistant.new 1, 2 }
27
+ assert_raise { NormaleDistribution::Persistant.new 1 }
28
+ assert_raise { NormaleDistribution::Persistant.new standard_deviation: "ok" }
29
+ assert_raise { NormaleDistribution::Persistant.new standard_deviation: -1 }
30
+ assert_raise { NormaleDistribution::Persistant.new standard_deviation: 0 }
31
+ end
32
+
33
+ end
data/test/unit_test.rb ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "test/unit"
4
+
5
+ require_relative '../lib/normale_distribution'
6
+
7
+ require_relative 'normale_distribution'
data/version ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: normale_distribution
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nephos (poulet_a)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRYwFAYDVQQDDA1hcnRo
14
+ dXIucG91bGV0MRkwFwYKCZImiZPyLGQBGRYJY3J5cHRvbGFiMRMwEQYKCZImiZPy
15
+ LGQBGRYDbmV0MB4XDTE1MTAwMzIxNTQyMFoXDTE2MTAwMjIxNTQyMFowSDEWMBQG
16
+ A1UEAwwNYXJ0aHVyLnBvdWxldDEZMBcGCgmSJomT8ixkARkWCWNyeXB0b2xhYjET
17
+ MBEGCgmSJomT8ixkARkWA25ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBANnLB9vH7/O0aUWi0f9VtC7F73zMC1OvxDaJq+qIcmGBFiKPOngDCRyKffWf
19
+ A6gyf7VsJAlDVFYoyNw7bzLFjBT9gkb5xmED3Uaxvt8Ax131YvKv0sTsQeiTVHHW
20
+ 1crq7266hW1McrFU2A1uQRV8FHuruUJBuP7UUYK7fZi0barbkdAIb4VvQFZxXByI
21
+ lKdQSuhu8k0RcG1vTACEsQXJIUImc8CWMi8/TG3HidJdASMvIWtV2rNQXlQ+UgIc
22
+ UeHC0p+SNTrc09H6q+5eH8NRYhJ91xKuLXv7NNy8M3quAMHcQ1GM6DWljc+Jc4cm
23
+ uAPQMYJf7Vy6OzWLoEiv2QU6sE0CAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQU08cDEZOTZNjP/0+E2unJWyw4NzQwJgYDVR0RBB8w
25
+ HYEbYXJ0aHVyLnBvdWxldEBjcnlwdG9sYWIubmV0MCYGA1UdEgQfMB2BG2FydGh1
26
+ ci5wb3VsZXRAY3J5cHRvbGFiLm5ldDANBgkqhkiG9w0BAQUFAAOCAQEAo60BuRZM
27
+ 5Vtn0H0kHHTPiXz09lwxx4cFpTqrTTM0T6qM3gKsR5eLyR1Rt5hGmYLPgY4ZW4zI
28
+ XcuDbgRJrczZs7AZNy5NXyVWpxCwkZzklpbGTuYQdFz7mKfVyALjLjrilOIktXcz
29
+ PvB7EoLlqYvq9cnwV3WE1MkRcBd07xpofcp0kxae2dCOZPUq24TcNaRe7Utw6jjA
30
+ iL0bcH7zZkzMsNoNpPAgsd3ovU4Mf9M+A3M8COmd7KzKyZ0k7P12u5InPWUsNQS2
31
+ tcYkgfqUJPitIJx1RvWZpIyH5uJhRUYK3+vU9nMOxez5WbIlC1TtpByKAPMX+sht
32
+ gib3AoIT8jh/2w==
33
+ -----END CERTIFICATE-----
34
+ date: 2016-05-03 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: nomorebeer
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.1'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.1'
50
+ description: A ruby implementation of the Normal Distribution
51
+ email:
52
+ - arthur.poulet@mailoo.org
53
+ executables: []
54
+ extensions: []
55
+ extra_rdoc_files: []
56
+ files:
57
+ - CHANGELOG
58
+ - Gemfile
59
+ - Gemfile.lock
60
+ - README.md
61
+ - Rakefile
62
+ - certs/nephos.pem
63
+ - lib/normale_distribution.rb
64
+ - lib/normale_distribution/persistant.rb
65
+ - normale_distribution.gemspec
66
+ - test/normale_distribution.rb
67
+ - test/unit_test.rb
68
+ - version
69
+ homepage: https://github.com/Nephos/NormaleDistribution
70
+ licenses:
71
+ - WTFPL
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.5.1
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: "* Initialize project"
93
+ test_files: []
94
+ has_rdoc:
metadata.gz.sig ADDED
@@ -0,0 +1 @@
1
+ k�����N���'#�О�dz�}k��N�^�"g�>�xA Df��<c�!�j��,���lHt�&Uݗi]P��C�'*ՁL\�߇�@��d�dCמQN\.i� ���tl�%���B���#�X���v�Y���j�,%�6���E��Ak����jҕ����I���:SV�o[ �}����%�׍D/�A|M�I��