Wednesday, August 10, 2016

Block Averaging: Matlab and Python

I'd written about block averaging to estimate error bars from correlated time-series in a couple of blog posts nearly three years ago. Here are the two posts, which explain the motivation and logic behind this technique (post1 and post2).

I wrote programs to carry out this operation in:


The required input is a data-stream or correlated "x" samples. There are optional flags for turning onscreen printing on or off, and to limit the size of the maximum block. The default choice for maximum block size ensures that the datastream is chopped into 4 blocks and more.

The output is a set of three arrays: the block size, the block variance, and the block mean.

The program prints out the mean and variance corresponding to the largest block sizes on screen. This may or may not be the "best choice". A quick look at the plot (by turning the isPlot flag on) will help ascertain this.

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi! I want to use your script for block-averaging but I don't know how to specify my input file, could you explain me that?
    Thanks!

    ReplyDelete
  3. Read the appropriate column of your input file into vector x (using load or numpy.loadtxt), and send it to blockAveraging function.

    ReplyDelete