Module: Daru::Accessors::GSLStatistics

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

Instance Method Summary collapse

Instance Method Details

#kurtosisObject



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

def kurtosis
  @data.kurtosis
end

#medianObject



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

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

#sample_with_replacement(sample = 1) ⇒ Object



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

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



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

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

#skewObject



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

def skew
  @data.skew
end

#standard_deviation_population(m) ⇒ Object



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

def standard_deviation_population m
  @data.sd_with_fixed_mean(m)
end

#standard_deviation_sample(m) ⇒ Object



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

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

#variance_population(m) ⇒ Object



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

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

#variance_sample(m) ⇒ Object



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

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

#vector_centered_compute(m) ⇒ Object



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

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



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

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