require 'distribution' require 'daru' require 'gnuplotrb' rng = Distribution::Normal.rng index = Daru::DateTimeIndex.date_range(:start => '2012-4-2', :periods => 1000, :freq => 'D') vector = Daru::Vector.new(1000.times.map {rng.call}, index: index) vector = vector.cumsum rolling = vector.rolling_mean 60 rolling.tail GnuplotRB::Plot.new([vector, with: 'lines', title: 'Vector'], [rolling, with: 'lines', title: 'Rolling Mean']) df = Daru::DataFrame.new({ a: 1000.times.map {rng.call}, b: 1000.times.map {rng.call}, c: 1000.times.map {rng.call} }, index: index) df = df.cumsum rs = df.rolling_sum(60) plots = [] rs.each_vector_with_index do |vec,n| plots << GnuplotRB::Plot.new([vec, with: 'lines', title: n]) end GnuplotRB::Multiplot.new(*plots, layout: [3,1], title: 'Rolling sums')