The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
grep unix.com with google



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-09-2009
Registered User
 

Join Date: Oct 2009
Posts: 12
Averaging

Hello all,

I'm trying to perform an averaging procedure which selects a selection of rows, average the corresponding value, selects the next set of rows and average the corresponding values etc.

The data below illustrates what I want to do. Given two columns (day and value),
I want to perform an annual average. This means, average the first 365 rows, followed by the next 365 rows, and the next 365 rows.
i.e.
average line 1 to 365 (no. of lines = 365)
average line 366 to 730 (no. of lines = 365)
average line 731 to 1095 (no. of lines = 365)

But there is a problem. Every four years, the calendar has one additional day i.e. leap year. So instead of 365, we have 366. Eventually, the whole averaging pattern should look something like

average line 1 to 365 (no. of lines = 365)
average line 366 to 730 (no. of lines = 365)
average line 731 to 1095 (no. of lines = 365)
average line 1096 to 1461 (no. of lines = 366)
average line 1462 to 1827 (no. if lines = 365)
...

Any suggestions?

Thanks.

day value
1
2
3
...
365
1
2
3
...
365
1
2
3
...
366
1
2
3
365
  #2 (permalink)  
Old 11-11-2009
Registered User
 

Join Date: Apr 2009
Location: /usr/bin/vim
Posts: 618
ok, you are explanations are clear.

Do total/366 only at every 4th time... What suggestion you want ?! or What is the doubt you have here ?
  #3 (permalink)  
Old 11-12-2009
Registered User
 

Join Date: Jul 2009
Posts: 12
Hi i'm quite inexeperienced but my suggestion would be to use the modulus of 4 for your trigger to /366 instead of /365.

Hope this helps you out a bit
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Averaging multiple columns gisele_l Shell Programming and Scripting 4 10-18-2009 06:53 PM
Averaging all fields while counting repeated records nxp Shell Programming and Scripting 0 10-15-2009 07:15 PM
Averaging segments kylle345 Shell Programming and Scripting 11 09-16-2009 01:04 PM
averaging column values with awk johnmillsbro Shell Programming and Scripting 18 01-26-2009 01:20 PM
AWK - averaging $3 by info in $1 itisthus Shell Programming and Scripting 3 11-03-2008 06:12 AM



All times are GMT -4. The time now is 12:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0