Module: StandardDeviation

Defined in:
lib/standard_deviation/version.rb,
ext/standard_deviation/standard_deviation.c

Constant Summary collapse

VERSION =
"1.0.3"

Instance Method Summary collapse

Instance Method Details

#population_varianceObject



54
55
56
57
58
59
60
61
# File 'ext/standard_deviation/standard_deviation.c', line 54

static VALUE population_variance(VALUE self) {
  long size = RARRAY_LEN(self);
  VALUE *array = RARRAY_PTR(self);

  if (size < 2) raise_not_enough_elements();

  return rb_float_new(compute_population_variance(array, size));
}

#sample_varianceObject Also known as: variance



45
46
47
48
49
50
51
52
# File 'ext/standard_deviation/standard_deviation.c', line 45

static VALUE sample_variance(VALUE self) {
  long size = RARRAY_LEN(self);
  VALUE *array = RARRAY_PTR(self);

  if (size < 2) raise_not_enough_elements();

  return rb_float_new(compute_sample_variance(array, size));
}

#stdevObject Also known as: standard_deviation



63
64
65
66
67
68
69
70
# File 'ext/standard_deviation/standard_deviation.c', line 63

static VALUE stdev(VALUE self) {
  long size = RARRAY_LEN(self);
  VALUE *array = RARRAY_PTR(self);

  if (size < 2) raise_not_enough_elements();

  return rb_float_new(sqrt(compute_sample_variance(array, size)));
}

#stdevpObject



72
73
74
75
76
77
78
79
# File 'ext/standard_deviation/standard_deviation.c', line 72

static VALUE stdevp(VALUE self) {
  long size = RARRAY_LEN(self);
  VALUE *array = RARRAY_PTR(self);

  if (size < 2) raise_not_enough_elements();

  return rb_float_new(sqrt(compute_population_variance(array, size)));
}