シグモイド関数をグラフ表示
Ubuntu 16.04 で試した
% sudo apt-get install gnuplot % gem install gnuplot
require 'gnuplot' def sigmod( x ) 1.0 / (1.0 + Math.exp( -x ) ) end Gnuplot.open do |gp| Gnuplot::Plot.new(gp) do |plot| plot.title 'sample' plot.ylabel 'ylabel' plot.xlabel 'xlabel' x = (-100..100).collect{|v| v.to_f*0.1 } y = x.map {|f| sigmod(f) } plot.data << Gnuplot::DataSet.new( [x,y] ) do |ds| ds.with = "lines" ds.notitle end end end