Module: Daru::Accessors::GSLStatistics

Included in:
GSLWrapper
Defined in:
lib/daru/accessors/gsl_wrapper.rb

Instance Method Summary collapse

Instance Method Details

#kurtosisObject



50
51
52
# File 'lib/daru/accessors/gsl_wrapper.rb', line 50

def kurtosis
  @data.kurtosis
end

#medianObject



26
27
28
# File 'lib/daru/accessors/gsl_wrapper.rb', line 26

def median
  GSL::Stats.median_from_sorted_data(@data.sort)
end

#sample_with_replacement(sample = 1) ⇒ Object



15
16
17
18
19
# File 'lib/daru/accessors/gsl_wrapper.rb', line 15

def sample_with_replacement(sample=1)
  r = GSL::Rng.alloc(GSL::Rng::MT19937,rand(10_000))
  Daru::Vector.new(r.sample(@data, sample).to_a, dtype: :gsl,
                                                 index: @context.index, name: @context.name)
end

#sample_without_replacement(sample = 1) ⇒ Object



21
22
23
24
# File 'lib/daru/accessors/gsl_wrapper.rb', line 21

def sample_without_replacement(sample=1)
  r = GSL::Rng.alloc(GSL::Rng::MT19937,rand(10_000))
  r.choose(@data, sample).to_a
end

#skewObject



46
47
48
# File 'lib/daru/accessors/gsl_wrapper.rb', line 46

def skew
  @data.skew
end

#standard_deviation_population(m) ⇒ Object



42
43
44
# File 'lib/daru/accessors/gsl_wrapper.rb', line 42

def standard_deviation_population m
  @data.sd_with_fixed_mean(m)
end

#standard_deviation_sample(m) ⇒ Object



34
35
36
# File 'lib/daru/accessors/gsl_wrapper.rb', line 34

def standard_deviation_sample(m)
  @data.sd(m)
end

#variance_population(m) ⇒ Object



38
39
40
# File 'lib/daru/accessors/gsl_wrapper.rb', line 38

def variance_population(m)
  @data.variance_with_fixed_mean(m)
end

#variance_sample(m) ⇒ Object



30
31
32
# File 'lib/daru/accessors/gsl_wrapper.rb', line 30

def variance_sample(m)
  @data.variance(m)
end

#vector_centered_compute(m) ⇒ Object



10
11
12
13
# File 'lib/daru/accessors/gsl_wrapper.rb', line 10

def vector_centered_compute(m)
  Daru::Vector.new @data.collect { |x| (x.to_f - m) }, dtype: :gsl,
                                                       index: @context.index, name: @context.name
end

#vector_standardized_compute(m, sd) ⇒ Object



5
6
7
8
# File 'lib/daru/accessors/gsl_wrapper.rb', line 5

def vector_standardized_compute(m,sd)
  Daru::Vector.new @data.collect { |x| (x.to_f - m).quo(sd) }, dtype: :gsl,
                                                               index: @context.index, name: @context.name
end