lib/gnuplotrb/fit.rb
##
# Parse Gnuplot's output to get coefficients and their deltas
# from it. Also replaces coefficients in given function with
# exact values.
Parse Gnuplot's output to get coefficients and their deltas
from it. Also replaces coefficients in given function with
exact values.
Parse Gnuplot ' s output to get coefficients and their deltas from it . Also replaces coefficients in given function with exact values .
def parse_output(variables, function, output)
      plottable_function = " #{function.clone} "
      coefficients = {}
      deltas = {}
      variables.each do |var|
        value, error = output.scan(%r{#{var} *= ([^ ]+) *\+/\- ([^ ]+)})[0]
        plottable_function.gsub!(/#{var}([^0-9a-zA-Z])/) { value + Regexp.last_match(1) }
        coefficients[var] = value.to_f
        deltas[var] = error.to_f
      end
      [coefficients, deltas, plottable_function]
    end
def parse_output ( variables , function , output ) plottable_function = " #{function.clone} " coefficients = { } deltas = { } variables . each do | var | value , error = output . scan ( %r{ #{ var }  *= ([^ ]+) * \+ / \-  ([^ ]+) } ) [ 0 ] plottable_function . gsub! ( / #{ var } ([^0-9a-zA-Z]) / ) { value + Regexp . last_match ( 1 ) } coefficients [ var ] = value . to_f deltas [ var ] = error . to_f end [ coefficients , deltas , plottable_function ] end
Parse Gnuplot's output to get coefficients and their deltas
from it.
Parse Gnuplot ' s output to get coefficients and their deltas from it .
variables
<not_specific>
function
<not_specific>
output
<not_specific>