def compstat(sdat, tstart=None, tend=None):
data = sdat.tseries_between(tstart, tend)<EOL>time = data['<STR_LIT:t>'].values<EOL>delta_time = time[-<NUM_LIT:1>] - time[<NUM_LIT:0>]<EOL>data = data.iloc[:, <NUM_LIT:1>:].values  <EOL>mean = np.trapz(data, x=time, axis=<NUM_LIT:0>) / delta_time<EOL>rms = np.sqrt(np.trapz((data - mean)**<NUM_LIT:2>, x=time, axis=<NUM_LIT:0>) / delta_time)<EOL>with open(misc.out_name('<STR_LIT>'), '<STR_LIT:w>') as out_file:<EOL><INDENT>mean.tofile(out_file, sep='<STR_LIT:U+0020>', format="<STR_LIT>")<EOL>out_file.write('<STR_LIT:\n>')<EOL>rms.tofile(out_file, sep='<STR_LIT:U+0020>', format="<STR_LIT>")<EOL>out_file.write('<STR_LIT:\n>')<EOL><DEDENT>
Compute statistics from series output by StagYY.

    Create a file 'statistics.dat' containing the mean and standard deviation
    of each series on the requested time span.

    Args:
        sdat (:class:`~stagpy.stagyydata.StagyyData`): a StagyyData instance.
        tstart (float): starting time. Set to None to start at the beginning of
            available data.
        tend (float): ending time. Set to None to stop at the end of available
            data.