Sha256: 20c515f01c0505aefcca6999c8ad8241cab6dc5549567bd0280b45842ceae951

Contents?: true

Size: 699 Bytes

Versions: 16

Compression:

Stored size: 699 Bytes

Contents

#!/usr/bin/env ruby
require("gsl")

N = 40

amp0 = 5.0
b0 = 0.1
y0 = 1.0

r = GSL::Rng.alloc()
x = GSL::Vector[0...N]
sigma = GSL::Vector[N]
sigma.set_all(0.1)
y = y0 + amp0*GSL::Sf::exp(-b0*x) + 0.1*r.gaussian(1, N)

coef, err, chi2, dof = GSL::MultiFit::FdfSolver.fit(x, sigma, y, "exponential")
y0 = coef[0]
amp = coef[1]
b = coef[2]
p coef
p err
GSL::graph(x, y, y0+amp*GSL::Sf::exp(-b*x))

# This will result in
# [ 1.019e+00 5.045e+00 1.040e-01 ] 
# [ 3.385e-02 5.395e-02 2.826e-03 ]

# GNUPLOT results:
# y0              = 1.01925          +/- 0.03383      (3.319%)
# A               = 5.04536          +/- 0.05396      (1.069%)
# b               = 0.104049         +/- 0.002826     (2.716%)

Version data entries

16 entries across 16 versions & 4 rubygems

Version Path
rb-gsl-1.16.0.4 examples/fit/expfit.rb
rb-gsl-1.16.0.3 examples/fit/expfit.rb
rb-gsl-1.16.0.3.rc1 examples/fit/expfit.rb
gsl-nmatrix-1.15.3.2 examples/fit/expfit.rb
gsl-nmatrix-1.15.3.1 examples/fit/expfit.rb
rb-gsl-1.16.0.2 examples/fit/expfit.rb
rb-gsl-1.16.0.1 examples/fit/expfit.rb
rb-gsl-1.16.0 examples/fit/expfit.rb
rb-gsl-1.15.3.2 examples/fit/expfit.rb
rb-gsl-1.15.3.1 examples/fit/expfit.rb
blackwinter-gsl-1.15.3.2 examples/fit/expfit.rb
gsl-nmatrix-1.15.3.0 examples/fit/expfit.rb
gsl-1.15.3 examples/fit/expfit.rb
gsl-1.14.7 examples/fit/expfit.rb
gsl-1.14.6 examples/fit/expfit.rb
gsl-1.14.5 examples/fit/expfit.rb