Message Boards Message Boards

Is there any command for doing an ensemble average of overplotting curves?

Dear All,

May I ask you something? I have over-plotting result of 61 curves (please refer to below image). x axis refers to time in hour, and y axis refers to rainfall (mm/h).

enter image description here

Thus, is that possible to take the ensemble average including the standard deviation of those curves as function of time? If yes, then may I know the command for doing so? Thanks in advance for your help.

Best Regards, Intan.

2 Replies

Dear Marco,

Thanks a lot for your explanations! Yes, it works. Thanks again for your help. Btw, may I ask you another thing? I have a PDF of normal distribution of a certain variable, like in this case, the value of a (please refer to below figure):

enter image description here

The mean value is 117, and the value of a varies from 100 to 130. May I know if there is a command to extract all of the values of a under the curve by following the Gaussian rule? I meant, I am expecting that many values of a will be located near the mean value then gradually decrease near to the tail. So I want to obtain all of values of a with an expectation that when later I plot those values, it will behave like Gaussian. Please kindly let me know if you know how to do so. Thanks in advance for your help!

Best Regards, Intan.


Dear Intan,

I guess that it depends a bit in which form your data is, and whether you want to code it "by foot" or use built in functionality. Here is one example. I first generate the data:

data = Transpose[Table[4.*Sin[0.01*n] + RandomVariate[NormalDistribution[0, 1]], {n,1, 700}, {m, 1, 50}]];

representing 50 time series with 700 points each.

enter image description here

You can draw the ensemble average +/- the standard deviation like so

ListLinePlot[{Mean[data], Mean[data] - StandardDeviation[data], Mean[data] + StandardDeviation[data]}]

or equivalently like so

ListLinePlot[{Mean@ data, Mean@data + StandardDeviation@ data, Mean@ data - StandardDeviation@ data}]

Both give

enter image description here

You can also use the built in ErrorListPlot function:

ErrorListPlot[Transpose[{Mean[data], StandardDeviation[data]}], PlotRange -> All]

There are other methods, and if your data comes in the format of a Mathematica time series, or you want to use DateList, you would again have lightly different commands. Also, for rainfall data, because of its distribution, you might want not to just plot the standard deviation around it.

Hope this helps,


POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract