Sha256: b670946d8341234001ea3b45b74379b785270555ca3fe31c7d9612201d1d2475

Contents?: true

Size: 375 Bytes

Versions: 22

Compression:

Stored size: 375 Bytes

Contents

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

N = 100

y0 = 1
A = 1.5
fc = 0.7
phi = 0.2

r = GSL::Rng.alloc()
x = GSL::Vector.linspace(0, 12, N)
y =  y0 + A*GSL::Sf::sin(fc*x+phi) + 0.1*r.gaussian(1, N)

coef, err, chi2, dof = GSL::MultiFit::FdfSolver.fit(x, y, "sin")
y0 = coef[0]
amp = coef[1]
fc = coef[2]
phi = coef[3]
p coef
p err
GSL::graph(x, y, y0+amp*GSL::Sf::sin(fc*x+phi))

Version data entries

22 entries across 22 versions & 4 rubygems

Version Path
gsl-2.1.0.3 examples/fit/sinfit.rb
gsl-2.1.0.2 examples/fit/sinfit.rb
gsl-2.1.0.1 examples/fit/sinfit.rb
gsl-2.1.0 examples/fit/sinfit.rb
gsl-1.16.0.6 examples/fit/sinfit.rb
rb-gsl-1.16.0.5 examples/fit/sinfit.rb
rb-gsl-1.16.0.4 examples/fit/sinfit.rb
rb-gsl-1.16.0.3 examples/fit/sinfit.rb
rb-gsl-1.16.0.3.rc1 examples/fit/sinfit.rb
gsl-nmatrix-1.15.3.2 examples/fit/sinfit.rb
gsl-nmatrix-1.15.3.1 examples/fit/sinfit.rb
rb-gsl-1.16.0.2 examples/fit/sinfit.rb
rb-gsl-1.16.0.1 examples/fit/sinfit.rb
rb-gsl-1.16.0 examples/fit/sinfit.rb
rb-gsl-1.15.3.2 examples/fit/sinfit.rb
rb-gsl-1.15.3.1 examples/fit/sinfit.rb
blackwinter-gsl-1.15.3.2 examples/fit/sinfit.rb
gsl-nmatrix-1.15.3.0 examples/fit/sinfit.rb
gsl-1.15.3 examples/fit/sinfit.rb
gsl-1.14.7 examples/fit/sinfit.rb