Class/Module Index [+]

Quicksearch

Statsample::Vector::GSL_

Public Instance Methods

clear_gsl() click to toggle source
# File lib/statsample/vector/gsl.rb, line 4
def clear_gsl
  @gsl=nil
end
gsl() click to toggle source
# File lib/statsample/vector/gsl.rb, line 20
def gsl
  @gsl||=GSL::Vector.alloc(@scale_data) if @scale_data.size>0
end
Also aliased as: to_gsl
mean() click to toggle source
# File lib/statsample/vector/gsl.rb, line 70
def mean
  check_type :scale
  gsl.nil? ? nil : gsl.mean
end
median() click to toggle source
# File lib/statsample/vector/gsl.rb, line 57
def median
  if @type!=:scale
    median_ruby
  else
    sorted=GSL::Vector.alloc(@scale_data.sort)
    GSL::Stats::median_from_sorted_data(sorted)
  end
end
push(v) click to toggle source
# File lib/statsample/vector/gsl.rb, line 12
def push(v)
  # If data is GSL::Vector, should be converted first to an Array
  if @data.is_a? GSL::Vector
    @data=@data.to_a
  end
  push_ruby(v)
end
sample_with_replacement(sample=1) click to toggle source
# File lib/statsample/vector/gsl.rb, line 40
def sample_with_replacement(sample=1)
  if(@type!=:scale)
    sample_with_replacement_ruby(sample)
  else
    r = GSL::Rng.alloc(GSL::Rng::MT19937,rand(10000))
    Statsample::Vector.new(r.sample(gsl, sample).to_a,:scale)
  end
end
sample_without_replacement(sample=1) click to toggle source
# File lib/statsample/vector/gsl.rb, line 49
def sample_without_replacement(sample=1)
  if(@type!=:scale)
    sample_without_replacement_ruby(sample)
  else
    r = GSL::Rng.alloc(GSL::Rng::MT19937,rand(10000))
    r.choose(gsl, sample).to_a
  end
end
set_valid_data() click to toggle source
# File lib/statsample/vector/gsl.rb, line 8
def set_valid_data
  clear_gsl
  set_valid_data_ruby
end
standard_deviation_sample(m=nil) click to toggle source
# File lib/statsample/vector/gsl.rb, line 80
def standard_deviation_sample(m=nil)
  check_type :scale
  m||=mean
  gsl.nil? ? nil : gsl.sd(m)
end
sum() click to toggle source
# File lib/statsample/vector/gsl.rb, line 66
def sum 
  check_type :scale
  gsl.nil? ? nil : gsl.sum
end
to_gsl() click to toggle source
Alias for: gsl
variance_sample(m=nil) click to toggle source
# File lib/statsample/vector/gsl.rb, line 74
def variance_sample(m=nil)
  check_type :scale
  m||=mean
  gsl.nil? ? nil : gsl.variance_m
end
vector_centered_compute(m) click to toggle source
# File lib/statsample/vector/gsl.rb, line 33
def vector_centered_compute(m)
  if flawed?
    vector_centered_compute_ruby(m)
  else
    gsl.collect {|x| (x.to_f - m)}.to_scale
  end
end
vector_standarized_compute(m,sd) click to toggle source
# File lib/statsample/vector/gsl.rb, line 25
def vector_standarized_compute(m,sd)
  if flawed?
    vector_standarized_compute_ruby(m,sd)
  else
    gsl.collect {|x| (x.to_f - m).quo(sd)}.to_scale
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.