Sponsored Content
Full Discussion: Averaging help in awk
Top Forums Shell Programming and Scripting Averaging help in awk Post 302547358 by yazu on Monday 15th of August 2011 10:34:29 AM
Old 08-15-2011
Quote:
Is there any way to do this?
Yes, of course. But why awk? It's very easy for scripting languages with big integers - just convert the third row to such integers and follow differences. It's 2083320 for 30 minutes. This numbers are not fit in 32 bits so big ints (and with float numbers results wouldn't be exact). It's a snap with Ruby or Python. (And maybe with awk but I think it may depends on awk version and it needs testing).
But even best programmers need to test their simplest programs and why somebody should want to write those tests for you? Give more rows (not every 5 seconds but with selection of different hours and maybe dates) and some columns with different and real data (what are they?) and you can get help.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK - averaging $3 by info in $1

Hello, I have three columns of data of the format below: <name> <volume> <size> a 2 1.2 a 2 1.1 b 3 1.7 c 0.7 1.9 c 0.7 1.9 c 0.7 1.8 What I... (3 Replies)
Discussion started by: itisthus
3 Replies

2. Shell Programming and Scripting

averaging column values with awk

Hello. Im just starting to learn awk so hang in there with me...I have a large text file formatted as such everything is in a single column ID001 value 1 value 2 value....n ID002 value 1 value 2 value... n I want to be able to calculate the average for values for each ID from the... (18 Replies)
Discussion started by: johnmillsbro
18 Replies

3. UNIX for Dummies Questions & Answers

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... (2 Replies)
Discussion started by: Muhammad Rahiz
2 Replies

4. UNIX for Dummies Questions & Answers

Averaging the rows using 'awk'

Dear all, I have the data in the following format. I want to do average of each NR= 5 (rows) for all the 3 ($1,$2, $3) columns and want to print average result in another file in the same format. I dont know how to write code for this in 'awk', can some one help me to write a code for this in... (1 Reply)
Discussion started by: arvindr
1 Replies

5. Shell Programming and Scripting

Averaging in increments using awk & head/tail

Hi, I only have a very limited understanding and experience with writing code and I was hoping I could get some help. I have a dataset of two columns (txt format, numbers in each row separated by a tab) Eg. 1 5 2 5 3 6 4 7 5 6 6 6 7 ... (5 Replies)
Discussion started by: Emred_Skye
5 Replies

6. Shell Programming and Scripting

Averaging data every 30 mins using AWK

A happy Monday to you all, I have a .csv file which contains data taken every 5 seconds. I want to average these 5 second data points into 30 minute averages! date co2 25/06/2011 08:04 8.31 25/06/2011 08:04 8.32 25/06/2011 08:04 8.33... (18 Replies)
Discussion started by: gd9629
18 Replies

7. Shell Programming and Scripting

Hourly averaging using Awk

Hey all, I have a set of 5-second data as shown below. I need to find an hourly average of this data. date co2 25/06/2011 08:04:00 8.30 25/06/2011 08:04:05 8.31 25/06/2011 08:04:10 8.32 25/06/2011 08:04:15 8.33 25/06/2011 08:04:20 ... (5 Replies)
Discussion started by: gd9629
5 Replies

8. Shell Programming and Scripting

Averaging 3 files

Hi, I am trying to average the values from 3 files with the same format. They are very large files so I will describe the file and show some it of. Basically the file has 83 columns (with nearly 7000 rows). The first three columns are the same for each file while the remaining 80 are values... (3 Replies)
Discussion started by: kylle345
3 Replies

9. Shell Programming and Scripting

Loop for row-wise averaging of multiple files using awk

Hello all, I need to compute a row-wise average of files with a single column based on the pattern of the filenames. I really appreciate any help on this. it would just be very difficult to do them manually as the rows are mounting to 100,000 lines. the filenames are as below with convention as... (2 Replies)
Discussion started by: ida1215
2 Replies

10. Shell Programming and Scripting

How to perform averaging of values for particular timestamp using awk or anythoing else??

I have a file of the form. 16:00:26,83.33 16:05:26,83.33 16:10:26,83.33 16:15:26,83.33 16:20:26,90.26 16:25:26,83.33 16:30:26,83.33 17:00:26,83.33 17:05:26,83.33 17:10:26,83.33 17:15:26,83.33 17:20:26,90.26 17:25:26,83.33 17:30:26,83.33 For the timestamp 16:00:00 to 16:55:00, I need to... (5 Replies)
Discussion started by: Saidul
5 Replies
Bigarray(3o)							   OCaml library						      Bigarray(3o)

NAME
Bigarray - Large, multi-dimensional, numerical arrays. Module Module Bigarray Documentation Module Bigarray : sig end Large, multi-dimensional, numerical arrays. This module implements multi-dimensional arrays of integers and floating-point numbers, thereafter referred to as ``big arrays''. The implementation allows efficient sharing of large numerical arrays between Caml code and C or Fortran numerical libraries. Concerning the naming conventions, users of this module are encouraged to do open Bigarray in their source, then refer to array types and operations via short dot notation, e.g. Array1.t or Array2.sub . Big arrays support all the Caml ad-hoc polymorphic operations: -comparisons ( = , <> , <= , etc, as well as Pervasives.compare ); -hashing (module Hash ); -and structured input-output ( Pervasives.output_value and Pervasives.input_value , as well as the functions from the Marshal module). === Element kinds === === Big arrays can contain elements of the following kinds: - IEEE single precision (32 bits) floating-point numbers (Bigar- ray.float32_elt), - IEEE double precision (64 bits) floating-point numbers (Bigarray.float64_elt), - IEEE single precision (2 * 32 bits) floating-point complex numbers (Bigarray.complex32_elt), - IEEE double precision (2 * 64 bits) floating-point complex numbers (Bigar- ray.complex64_elt), - 8-bit integers (signed or unsigned) (Bigarray.int8_signed_elt or Bigarray.int8_unsigned_elt), - 16-bit integers (signed or unsigned) (Bigarray.int16_signed_elt or Bigarray.int16_unsigned_elt), - Caml integers (signed, 31 bits on 32-bit architectures, 63 bits on 64-bit architectures) (Bigarray.int_elt), - 32-bit signed integer (Bigarray.int32_elt), - 64-bit signed integers (Bigar- ray.int64_elt), - platform-native signed integers (32 bits on 32-bit architectures, 64 bits on 64-bit architectures) (Bigar- ray.nativeint_elt). Each element kind is represented at the type level by one of the abstract types defined below. === type float32_elt type float64_elt type complex32_elt type complex64_elt type int8_signed_elt type int8_unsigned_elt type int16_signed_elt type int16_unsigned_elt type int_elt type int32_elt type int64_elt type nativeint_elt type ('a, 'b) kind To each element kind is associated a Caml type, which is the type of Caml values that can be stored in the big array or read back from it. This type is not necessarily the same as the type of the array elements proper: for instance, a big array whose elements are of kind float32_elt contains 32-bit single precision floats, but reading or writing one of its elements from Caml uses the Caml type float , which is 64-bit double precision floats. The abstract type ('a, 'b) kind captures this association of a Caml type 'a for values read or written in the big array, and of an element kind 'b which represents the actual contents of the big array. The following predefined values of type kind list all possible associations of Caml types with element kinds: val float32 : (float, float32_elt) kind See Bigarray.char . val float64 : (float, float64_elt) kind See Bigarray.char . val complex32 : (Complex.t, complex32_elt) kind See Bigarray.char . val complex64 : (Complex.t, complex64_elt) kind See Bigarray.char . val int8_signed : (int, int8_signed_elt) kind See Bigarray.char . val int8_unsigned : (int, int8_unsigned_elt) kind See Bigarray.char . val int16_signed : (int, int16_signed_elt) kind See Bigarray.char . val int16_unsigned : (int, int16_unsigned_elt) kind See Bigarray.char . val int : (int, int_elt) kind See Bigarray.char . val int32 : (int32, int32_elt) kind See Bigarray.char . val int64 : (int64, int64_elt) kind See Bigarray.char . val nativeint : (nativeint, nativeint_elt) kind See Bigarray.char . val char : (char, int8_unsigned_elt) kind As shown by the types of the values above, big arrays of kind float32_elt and float64_elt are accessed using the Caml type float . Big arrays of complex kinds complex32_elt , complex64_elt are accessed with the Caml type Complex.t . Big arrays of integer kinds are accessed using the smallest Caml integer type large enough to represent the array elements: int for 8- and 16-bit integer bigarrays, as well as Caml-integer bigarrays; int32 for 32-bit integer bigarrays; int64 for 64-bit integer bigarrays; and nativeint for platform-native integer bigarrays. Finally, big arrays of kind int8_unsigned_elt can also be accessed as arrays of characters instead of arrays of small integers, by using the kind value char instead of int8_unsigned . === Array layouts === type c_layout See Bigarray.fortran_layout . type fortran_layout To facilitate interoperability with existing C and Fortran code, this library supports two different memory layouts for big arrays, one compatible with the C conventions, the other compatible with the Fortran conventions. In the C-style layout, array indices start at 0, and multi-dimensional arrays are laid out in row-major format. That is, for a two-dimen- sional array, all elements of row 0 are contiguous in memory, followed by all elements of row 1, etc. In other terms, the array elements at (x,y) and (x, y+1) are adjacent in memory. In the Fortran-style layout, array indices start at 1, and multi-dimensional arrays are laid out in column-major format. That is, for a two-dimensional array, all elements of column 0 are contiguous in memory, followed by all elements of column 1, etc. In other terms, the array elements at (x,y) and (x+1, y) are adjacent in memory. Each layout style is identified at the type level by the abstract types Bigarray.c_layout and fortran_layout respectively. type 'a layout The type 'a layout represents one of the two supported memory layouts: C-style if 'a is Bigarray.c_layout , Fortran-style if 'a is Bigar- ray.fortran_layout . === Supported layouts The abstract values c_layout and fortran_layout represent the two supported layouts at the level of values. === val c_layout : c_layout layout val fortran_layout : fortran_layout layout === Generic arrays (of arbitrarily many dimensions) === module Genarray : sig end === One-dimensional arrays === module Array1 : sig end One-dimensional arrays. The Array1 structure provides operations similar to those of Bigarray.Genarray , but specialized to the case of one-dimensional arrays. (The Array2 and Array3 structures below provide operations specialized for two- and three-dimensional arrays.) Statically knowing the number of dimensions of the array allows faster operations, and more precise static type-checking. === Two-dimensional arrays === module Array2 : sig end Two-dimensional arrays. The Array2 structure provides operations similar to those of Bigarray.Genarray , but specialized to the case of two-dimensional arrays. === Three-dimensional arrays === module Array3 : sig end Three-dimensional arrays. The Array3 structure provides operations similar to those of Bigarray.Genarray , but specialized to the case of three-dimensional arrays. === Coercions between generic big arrays and fixed-dimension big arrays === val genarray_of_array1 : ('a, 'b, 'c) Array1.t -> ('a, 'b, 'c) Genarray.t Return the generic big array corresponding to the given one-dimensional big array. val genarray_of_array2 : ('a, 'b, 'c) Array2.t -> ('a, 'b, 'c) Genarray.t Return the generic big array corresponding to the given two-dimensional big array. val genarray_of_array3 : ('a, 'b, 'c) Array3.t -> ('a, 'b, 'c) Genarray.t Return the generic big array corresponding to the given three-dimensional big array. val array1_of_genarray : ('a, 'b, 'c) Genarray.t -> ('a, 'b, 'c) Array1.t Return the one-dimensional big array corresponding to the given generic big array. Raise Invalid_argument if the generic big array does not have exactly one dimension. val array2_of_genarray : ('a, 'b, 'c) Genarray.t -> ('a, 'b, 'c) Array2.t Return the two-dimensional big array corresponding to the given generic big array. Raise Invalid_argument if the generic big array does not have exactly two dimensions. val array3_of_genarray : ('a, 'b, 'c) Genarray.t -> ('a, 'b, 'c) Array3.t Return the three-dimensional big array corresponding to the given generic big array. Raise Invalid_argument if the generic big array does not have exactly three dimensions. === Re-shaping big arrays === val reshape : ('a, 'b, 'c) Genarray.t -> int array -> ('a, 'b, 'c) Genarray.t reshape b [|d1;...;dN|] converts the big array b to a N -dimensional array of dimensions d1 ... dN . The returned array and the original array b share their data and have the same layout. For instance, assuming that b is a one-dimensional array of dimension 12, reshape b [|3;4|] returns a two-dimensional array b' of dimensions 3 and 4. If b has C layout, the element (x,y) of b' corresponds to the element x * 3 + y of b . If b has Fortran layout, the element (x,y) of b' corresponds to the element x + (y - 1) * 4 of b . The returned big array must have exactly the same number of elements as the original big array b . That is, the product of the dimensions of b must be equal to i1 * ... * iN . Otherwise, Invalid_argument is raised. val reshape_1 : ('a, 'b, 'c) Genarray.t -> int -> ('a, 'b, 'c) Array1.t Specialized version of Bigarray.reshape for reshaping to one-dimensional arrays. val reshape_2 : ('a, 'b, 'c) Genarray.t -> int -> int -> ('a, 'b, 'c) Array2.t Specialized version of Bigarray.reshape for reshaping to two-dimensional arrays. val reshape_3 : ('a, 'b, 'c) Genarray.t -> int -> int -> int -> ('a, 'b, 'c) Array3.t Specialized version of Bigarray.reshape for reshaping to three-dimensional arrays. OCamldoc 2012-06-26 Bigarray(3o)
All times are GMT -4. The time now is 11:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy