standard_deviation 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,12 @@
|
|
1
1
|
#include <ruby.h>
|
2
2
|
#include <math.h>
|
3
3
|
|
4
|
-
static double sum(
|
4
|
+
static double sum(double array[], long size) {
|
5
5
|
int i;
|
6
6
|
double total = 0;
|
7
7
|
|
8
8
|
for (i = 0; i < size; i++) {
|
9
|
-
total +=
|
9
|
+
total += array[i];
|
10
10
|
}
|
11
11
|
|
12
12
|
return total;
|
@@ -15,11 +15,16 @@ static double sum(VALUE *array, long size) {
|
|
15
15
|
static double distance_from_mean(VALUE *array, long size) {
|
16
16
|
int i;
|
17
17
|
double mean, distance;
|
18
|
+
double values[size];
|
18
19
|
|
19
|
-
|
20
|
+
for (i = 0; i < size; i++) {
|
21
|
+
values[i] = NUM2DBL(array[i]);
|
22
|
+
}
|
23
|
+
|
24
|
+
mean = sum(values, size) / size;
|
20
25
|
|
21
26
|
for (i = 0, distance = 0; i < size; i++) {
|
22
|
-
distance += pow(
|
27
|
+
distance += pow(values[i] - mean, 2);
|
23
28
|
}
|
24
29
|
|
25
30
|
return distance;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: standard_deviation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-17 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153819300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153819300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153818820 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153818820
|
36
36
|
description: ! "An implementation of the standard deviation calculation in C,\n with
|
37
37
|
much better performance (50x-100x) than using pure ruby."
|
38
38
|
email:
|
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
segments:
|
75
75
|
- 0
|
76
|
-
hash: -
|
76
|
+
hash: -1911497483402748616
|
77
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
78
|
none: false
|
79
79
|
requirements:
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
segments:
|
84
84
|
- 0
|
85
|
-
hash: -
|
85
|
+
hash: -1911497483402748616
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
88
|
rubygems_version: 1.8.10
|