Sponsored Content
Top Forums Shell Programming and Scripting awk or Bash: Cumulative average Post 302900697 by rbatte1 on Thursday 8th of May 2014 08:05:46 AM
Old 05-08-2014
So what's your logic here? Might I suggest:-
  • Zero total and rows read
  • Read a row
  • Increment row counter
  • Add row value to total
  • Get cumulative mean average by dividing total by rows read
  • Store it in an array based on the rows read
  • Repeat the loop until there is no data left
There are other averages, but I assume that this is the one you want.

So that leaves a few questions?
  • What have you tried so far?
  • What output/errors/messages do you get?
  • What OS & version are you using?
  • What are your preferred tools?
  • How big an input file have you got (array limits)
Most important, what have you tried so far?



Robin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to average in awk

Hi, I have the data like this $1 $2 1 12 2 13 3 14 4 12 5 12 6 12 7 13 8 14 9 12 10 12 i want to compute average of $1 and $2 every 5th line (1-5 and 6-10) Please help me with awk Thank you (4 Replies)
Discussion started by: saint2006
4 Replies

2. Shell Programming and Scripting

Average in awk

Hi I am looking for an awk script which can compute average of all the fields every 5th line. The file looks: A B C D E F G H I J K L M 1 18 13 14 12 14 13 11 12 12 15 15 15 2 17 17 13 13 13 12 12 11 12 14 15 14 3 16 16 12 12 12 11 11 12 11 16 14 13 4 15 15 11 11 11 12 11 12 11... (6 Replies)
Discussion started by: saint2006
6 Replies

3. UNIX for Dummies Questions & Answers

Average in awk based on time

Hi I am looking for an awk script which can compute the average of the last column based on the date and time. The file looks: site1,"2000-01-01 00:00:00", "2000-01-01 00:59:00",0.013 site2,"2000-02-01 01:00:00", "2000-02-01 01:59:00",0.035 site1,"2000-02-01 02:00:00", "2000-02-01... (15 Replies)
Discussion started by: kathy wang
15 Replies

4. Shell Programming and Scripting

BASH. Need to extract some numbers and take the average

Hey all, I ran some simulations, of which the output is 100s of files. I've used grep to extract the vital information needed from the files. This has made my task somewhat easier. But I still need to perform some mathematical calculations (average and geometrical average) on the results of the... (9 Replies)
Discussion started by: slackjack
9 Replies

5. Shell Programming and Scripting

Calculate Average AWK

I want to calculate the average line by line of some files with several lines on them, the files are identical, just want to average the 3rd columns of those files.:wall: Example file: File 1 001 0.046 0.667267 001 0.047 0.672028 001 0.048 0.656025 001 0.049 ... (2 Replies)
Discussion started by: AriasFco
2 Replies

6. Shell Programming and Scripting

Calculating average with awk

I need to find the average from a file like: data => BW:123 M:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0' data => BW:123 N:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0' data => BW:123 N:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0' data => BW:123 N:30 RTD:0 1 0 1 0 0 1 1 1 1 0 0 1 1 0' data => BW:123 N:30 RTD:0 1... (4 Replies)
Discussion started by: Slagle
4 Replies

7. UNIX for Dummies Questions & Answers

Calculating cumulative frequency using awk

Hi, I wanted to calculate cumulative frequency distribution of my data that involves several arithmetic calls. I did things in excel but its taking me forever. this is what I want to do: var1.txt contains n observations which I have to compute for frequency which is given by 1/n and subsequently... (7 Replies)
Discussion started by: ida1215
7 Replies

8. Shell Programming and Scripting

Bash script affect load average

Hello I have created next scritpt to do the next: chekp if host is alive. When the host down, launch telnet other equip to do checks. When execute the script the load average of the machines increase. For example: Before launch script top - 11:14:56 up 14 days, 18:06, 3 users, load... (3 Replies)
Discussion started by: capilla
3 Replies

9. Shell Programming and Scripting

Bash to calculate average of all files in directory and output by part of filename

I am trying to use awk to calculate the average of all lines in $2 for every file in a directory. The below bash seems to do that, but I cannot figure out how to capture the string before the _ as the output file name and have it be tab-delimeted. Thank you :). Filenames in... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. Shell Programming and Scripting

awk Moving Average

Hi, I'm using awk to try and get a moving average for the second column of numbers ($2) in the below example broken out by unique identifier in column 1 ($1) : H1,1.2 H1,2.3 H1,5.5 H1,6.6 H1,8.7 H1,4.1 H1,6.4 H1,7.8 H1,9.6 H1,3.2 H5,50.1 H5,54.2 H5,58.8 H5,60.9 H5,54.3 H5,52.7... (8 Replies)
Discussion started by: theflamingmoe
8 Replies
RASTERIZER(1)							   User Commands						     RASTERIZER(1)

NAME
rasterizer - SVG conversion SYNOPSIS
rasterizer [options] files DESCRIPTION
Rasterizer is a program to convert SVG files to various formats, namely PNG, JPEG and PDF. OPTIONS
-d <dir|file> output directory. If there is a single input file, this can be a file. -m <mimeType> output mime type. Should be one of image/jpg, image/jpeg, image/jpe, image/png, image/tiff or application/pdf. -w <width> output width. This is a floating point value. -h <height> output height. This is a floating point value. -maxw <width> Maximum output width. This is a floating point value. -maxh <height> Maximum output height. This is a floating point value. -a <area> output area. The format for <area> is x,y,w,h, where x, y, w and h are floating point values. -bg <color> output color. The format for <color> is a.r.g.b, where a, r, g and b are integer values. -cssMedia <media> CSS media type for which the source SVG files should be converted. -cssAlternate <alternate> CSS alternate stylesheet to use when converting the source SVG files. -cssUser <userStylesheet> CSS user stylesheet URI to apply to converted SVG documents in addition to any other referened or embeded stylesheets. -font-family <defaultFontFamily> Value used as a default when no font-family value is specified. -lang <userLanguage> User language to use when converting SVG documents. -q <quality> Quality for the output image. This is only relevant for the image/jpeg mime type. -indexed (1|2|4|8) Reduces the image to given number of bits per pixel using an adaptive pallete, resulting in an Indexed image. This is currently only supported for PNG conversion. -dpi <resolution> Resolution for the ouptut image. -validate Controls whether the source SVG files should be validated. -onload Controls if the source SVG files must be rasterize after dispatching the 'onload' event. -scriptSecurityOff removes any security check on the scripts running as a result of dispatching the onload event. -anyScriptOrigin controls whether scripts can be loaded from any location. By default, scripts can only be loaded from the same location as the document referencing them. -scripts <listOfAllowedScripts> List of script types (i.e., values for the type attribute in the <script> tag) which should be loaded. -d <dir|file> output directory. If there is a single input file, this can be a file. -m <mimeType> output mime type. -w <width> output width. This is a floating point value. -h <height> output height. This is a floating point value. -maxw <width> Maximum output width. This is a floating point value. -maxh <height> Maximum output height. This is a floating point value. -a <area> output area. The format for <area> is x,y,w,h, where x, y, w and h are floating point values. -bg <color> output color. The format for <color> is a.r.g.b, where a, r, g and b are integer values. -cssMedia <media> CSS media type for which the source SVG files should be converted. -cssAlternate <alternate> CSS alternate stylesheet to use when converting the source SVG files. -cssUser <userStylesheet> CSS user stylesheet URI to apply to converted SVG documents in addition to any other referened or embeded stylesheets. -font-family <defaultFontFamily> Value used as a default when no font-family value is specified. -lang <userLanguage> User language to use when converting SVG documents. -q <quality> Quality for the output image. This is only relevant for the image/jpeg mime type. -indexed (1|2|4|8) Reduces the image to given number of bits per pixel using an adaptive pallete, resulting in an Indexed image. This is currently only supported for PNG conversion. -dpi <resolution> Resolution for the ouptut image. -validate Controls whether the source SVG files should be validated. -onload Controls if the source SVG files must be rasterize after dispatching the 'onload' event. -scriptSecurityOff removes any security check on the scripts running as a result of dispatching the onload event. Always enabled, as in most cases, rasterizer just fails to run without this option. See -scriptSecurityOn -scriptSecurityOn If this is the first argument on the command-line, turn security back on. You'll most likely be hit by the possible bug mentioned below. -anyScriptOrigin controls whether scripts can be loaded from any location. By default, scripts can only be loaded from the same location as the docu- ment referencing them. -scripts <listOfAllowedScripts> List of script types (i.e., values for the type attribute in the <script> tag) which should be loaded. BUGS
If rasterizer fails with an error in the spirit of: Exception in thread "main" java.security.AccessControlException: access denied (java.util.PropertyPermission java.security.policy write) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323) at java.security.AccessController.checkPermission(AccessController.java:546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.System.setProperty(System.java:727) Run it with the -scriptSecurityOff option on. It seems in some cases the security design is slighlty too strong. This might become the default some day. JAVA-WRAPPERS NOTE This program is a shell script wrapper based on java-wrappers(7). You therefore benefit from several features; please see the java-wrap- pers(7) manual page for more information about them. AUTHORS
rasterizer is part of batik, written by the Apache Software Foundation. This manual page was written by Vincent Fourmond <fourmond@debian.org> for the Debian Project, but may be used by others. SEE ALSO
The web page of batik, http://xml.apache.org/batik java-wrappers(7) SVG conversion January 2008 RASTERIZER(1)
All times are GMT -4. The time now is 07:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy