[nzlug] Time Calculator
N Dempsey
NevilleD.AuckLug at sgr-a.net
Sat Jan 13 10:49:12 NZDT 2007
Hi Marvin,
Below is the classic unix/awk hack to generate a table of averages.
It uses regular expressions to detect which columns have data.
You will have to do a bit of fine tuning to correctly identify the
columns and automatically look "nice".
If you are doing a lot of statistics, the there is a choice of stats
tools you can use: Check out
http://en.wikipedia.org/wiki/Category:Statistical_programming_languages
In particular try:
http://en.wikipedia.org/wiki/R_%28programming_language%29 this has tools
for doing calculations of statistical errors etc. And "R" is open-
source.
I believe that "R" can handle HH:MM:SS.SS formats, after all that is
what statisticians do all the time. (My caveat is that I don't really
know R that well as I live in a shell/awk/C/python world, and would
normally use python for this [unless I needed C's 100x faster speed] )
BTW: to get a "rough" idea on the performance of python vs awk vs perl
vs "C" check out a script I have posted:
http://www.3ttechnology.com/gips/ ResultsDec06-05.txt
Open-source language interpretors:
a68g_gips.a68: 0.00045913 84 x slower then c
py_gips.py: 0.00039505 97 x slower then c
pl_gips.pl: 0.00029557 130 x slower then c
gawk_gips.awk: 0.00028388 136 x slower then c
ruby_gips.ruby: 0.00023380 165 x slower then c
Cheers
N
$ cat anova.awk
awk '{
print
for(col=1;col<=NF; col++){
if($col~"^[0-9][0-9]*:[0-9][0-9]"){
split($col,ms,":")
sum[col]+=ms[1]*60+ms[2]
max_col=col
}
}
if($2~"^[A-Z]")count++
}
END{
printf("| Av |")
for(col=1; col<=max_col; col++){
if(col in sum){
avg=sum[col]/count
m=(avg-avg%60)/60
s=avg-m*60
printf(" %d:%05.2f |",m,s)
}
}
print ""
print
}' << end_awk
-----------------------------------------------
| | Xa | Xb | Xc | Xd |
-----------------------------------------------
| T1 | 1:01.84 | 2:04.18 | 4:09.26 | 11:04.57 |
-----------------------------------------------
| T2 | 1:03.17 | 2:05.35 | 4:10.55 | 11:04.47 |
-----------------------------------------------
| T3 | 1:02.76 | 2:05.31 | 4:13.08 | 11:07.45 |
-----------------------------------------------
| T4 | 1:03.16 | 2:05.26 | 4:09.14 | 11:01.45 |
-----------------------------------------------
| T5 | 1:02.71 | 2:06.02 | 4:09.60 | 11:01.94 |
-----------------------------------------------
| T6 | 1:01.51 | 2:01.85 | 3:53.15 | 09:47.24 |
-----------------------------------------------
end_awk
$ ./anova.awk
-----------------------------------------------
| | Xa | Xb | Xc | Xd |
-----------------------------------------------
| T1 | 1:01.84 | 2:04.18 | 4:09.26 | 11:04.57 |
-----------------------------------------------
| T2 | 1:03.17 | 2:05.35 | 4:10.55 | 11:04.47 |
-----------------------------------------------
| T3 | 1:02.76 | 2:05.31 | 4:13.08 | 11:07.45 |
-----------------------------------------------
| T4 | 1:03.16 | 2:05.26 | 4:09.14 | 11:01.45 |
-----------------------------------------------
| T5 | 1:02.71 | 2:06.02 | 4:09.60 | 11:01.94 |
-----------------------------------------------
| T6 | 1:01.51 | 2:01.85 | 3:53.15 | 09:47.24 |
-----------------------------------------------
| Av | 1:02.52 | 2:04.66 | 4:07.46 | 10:51.19 |
-----------------------------------------------
On Fri, 2007-01-12 at 18:26 +0800, Marvin Pascual wrote:
> Hello all,
>
> On 1/12/07, yuri <yuridg at gmail.com> wrote:
> >
> > Does your situation lend itself to using a spreadsheet?
> > Spreadsheets do time calculations. I've used them for converting
> > timesheets into payslips.
>
> Thank you for all your suggestions. Actually, I'm about to compute
> the analysis of variance (ANOVA) of 6 different elapsed time. My data
> are listed below:
>
> -----------------------------------------------
> | | Xa | Xb | Xc | Xd |
> -----------------------------------------------
> | T1 | 1:01.84 | 2:04.18 | 4:09.26 | 11:04.57 |
> -----------------------------------------------
> | T2 | 1:03.17 | 2:05.35 | 4:10.55 | 11:04.47 |
> -----------------------------------------------
> | T3 | 1:02.76 | 2:05.31 | 4:13.08 | 11:07.45 |
> -----------------------------------------------
> | T4 | 1:03.16 | 2:05.26 | 4:09.14 | 11:01.45 |
> -----------------------------------------------
> | T5 | 1:02.71 | 2:06.02 | 4:09.60 | 11:01.94 |
> -----------------------------------------------
> | T6 | 1:01.51 | 2:01.85 | 3:53.15 | 09:47.24 |
> -----------------------------------------------
>
> Now, I want to compute its weighted mean and the analysis of variance
> automatically in order to identify its significant difference.
> Although the presentation of results and its computation will be
> written manually, I just want to get the basic calculations
> automatically.
>
> Thank you for all your help and suggestions.
>
> Marvin
>
> _______________________________________________
> NZLUG mailing list NZLUG at linux.net.nz
> http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
More information about the NZLUG
mailing list