def gnuplot_fit(function, data, options, initials, term_options)
      variables = initials.keys
      term = Terminal.new
      term.set(term_options)
      initials.each { |var_name, value| term.stream_puts "#{var_name} = #{value}" }
      command = "fit #{function} #{data.to_s(term, without_options: true)} " \
                "#{options} via #{variables.join(',')}"
      term.stream_puts(command)
      output = wait_for_output(term, variables)
      begin
        term.close
      rescue GnuplotError
        # Nothing interesting here.
        # If we had an error, we never reach this line.
        # Error here may be only additional information
        # such as correlation matrix.
      end
      output
    end
def gnuplot_fit(function, data, options, initials, term_options)
      variables = initials.keys
      term = Terminal.new
      term.set(term_options)
      initials.each { |var_name, value| term.stream_puts "#{var_name} = #{value}" }
      command = "fit #{function} #{data.to_s(term, without_options: true)} " \
                "#{options} via #{variables.join(',')}"
      term.stream_puts(command)
      output = wait_for_output(term, variables)
      begin
        term.close
      rescue GnuplotError
        # Nothing interesting here.
        # If we had an error, we never reach this line.
        # Error here may be only additional information
        # such as correlation matrix.
      end
      output
    end
Make fit command and send it to gnuplot