Method: GnuplotRB::Fit#fit
- Defined in:
- lib/gnuplotrb/fit.rb
#fit(data, function: 'a2*x*x+a1*x+a0', initials: { a2: 1, a1: 1, a0: 1 }, term_options: {}, **options) ⇒ Hash
Fit given data with function.
Fit waits for output from gnuplot Settings.max_fit_delay and throw exception if gets nothing. One can change this value in order to wait longer (if huge datasets is fitted).
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gnuplotrb/fit.rb', line 36 def fit(data, function: 'a2*x*x+a1*x+a0', initials: { a2: 1, a1: 1, a0: 1 }, term_options: {}, **) dataset = data.is_a?(Dataset) ? Dataset.new(data.data) : Dataset.new(data) opts_str = OptionHandling.ruby_class_to_gnuplot() output = gnuplot_fit(function, dataset, opts_str, initials, ) res = parse_output(initials.keys, function, output) { formula_ds: Dataset.new(res[2], title: 'Fit formula'), coefficients: res[0], deltas: res[1], data: dataset } end |