[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Simplet hack til glidende gennemsnit



Hej

Hans Schou wrote:
On Tue, 16 Mar 2004, Klaus Friis Østergaard wrote:
Er der en simple vej til at lave et glidene gennemsnit via f. eks
sed & awk
Med awk, det er der sikkert.

awk 'BEGIN { average=0.0 ; for (i=0 ; i<max ; i++) a[i]=0.0; j=0;k=1 } { average+=$2-a[j]; a[j]=$2; printf("Average = %.2f\n",average/k); j = (j+1)%max; if (k < max) k++; }' max=5

Praecision saettes vist nok med en environment-variable eller saadan noget.

Hvad med sh og dc?

Hvis dine data ser ud som ovenstående, så:
#!/bin/sh

Det er sjovt at se andres eksempel da man altid kan laere noget


--PMM



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *