ruby-statistics 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e37b06e60f8045e0517cb48260ad5d70edab41d
4
- data.tar.gz: f5152b5bdbb02c8bc3dd423a52d4dfd9f267e16f
3
+ metadata.gz: 298bc7d8dff1aeabc7db9c11fe9d7987f16bde40
4
+ data.tar.gz: 1d796e62c18052f87fc2616b4c1a5f777080c1ab
5
5
  SHA512:
6
- metadata.gz: e81155507b0c78cb1211faa7b7d0b3fab0dd9db8e1f8b5449e20211ed9d6cbc5fa6735649a24136a7013740fad19e39b772fb44ecfc5b2acfafafd576b738797
7
- data.tar.gz: f5e693b125d372ee7af3e2f2a84c180608b7141087da6c5cf6bce6db4f5d46843ff01383dda27878ebd3b9ea30251ff1c650d0fbccfd5738cddd98c0f298e6ed
6
+ metadata.gz: 98e8c58f34668e839be9689c74debd75bd7a6869372536d7e9927a63f77fca59ab05e06b413705f0d286094292cb566c01e6fe71145cdd7d2152fc930829910e
7
+ data.tar.gz: 37b78191adb8d659f21134346a8a415c5bd7bd8a7dd99b2c1f8d7793a2ea741c43e60d8235a7d5fcc2bc0284b24e8e58e8404e0b4b4401ee3bc60f7e1afc8b8b
@@ -39,9 +39,16 @@ module Statistics
39
39
  (sample_left_mean - sample_right_mean).abs/standard_error.to_f
40
40
  end
41
41
 
42
- probability = Distribution::TStudent.new(degrees_of_freedom).cumulative_function(t_score)
43
- p_value = 1 - probability
44
- p_value *= 2 if tails == :two_tail
42
+ t_distribution = Distribution::TStudent.new(degrees_of_freedom)
43
+ probability = t_distribution.cumulative_function(t_score)
44
+
45
+ # Steps grabbed from https://support.minitab.com/en-us/minitab/18/help-and-how-to/statistics/basic-statistics/supporting-topics/basics/manually-calculate-a-p-value/
46
+ # See https://github.com/estebanz01/ruby-statistics/issues/23
47
+ p_value = if tails == :two_tail
48
+ 2 * (1 - t_distribution.cumulative_function(t_score.abs))
49
+ else
50
+ 1 - probability
51
+ end
45
52
 
46
53
  { t_score: t_score,
47
54
  probability: probability,
@@ -1,3 +1,3 @@
1
1
  module Statistics
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-statistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - esteban zapata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-17 00:00:00.000000000 Z
11
+ date: 2018-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler