/usr/share/doc/ruby-gsl/examples/fit/lognormal.rb is in ruby-gsl 2.1.0.3+dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #!/usr/bin/env ruby
require("gsl")
N = 100
y0 = 1.0
A = 2.0
x0 = 3.0
w = 0.5
r = GSL::Rng.alloc()
x = GSL::Vector.linspace(0.01, 10, N)
sig = 1
y = y0 + A*GSL::Sf::exp(-GSL::pow_2(GSL::Sf::log(x/x0)/w)) + 0.1*GSL::Ran::gaussian(r, sig, N)
coef, err, chi2, dof = GSL::MultiFit::FdfSolver.fit(x, y, "lognormal", [0, 3, 2, 1])
y0 = coef[0]
amp = coef[1]
x0 = coef[2]
w = coef[3]
p coef
p err
GSL::graph(x, y, y0+amp*GSL::Sf::exp(-GSL::pow_2(GSL::Sf::log(x/x0)/w)))
|