Sponsored Content
Top Forums Shell Programming and Scripting Finding Max value from an array Post 302339769 by Scott on Friday 31st of July 2009 09:51:19 AM
Old 07-31-2009
Leading 0's will take care of that...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding max value

My code below is supposed to find which company had the most business and then print the appropriate fields from another file which are the companies ID number and name. I can loop through awk and display all the total amount of business for each company but I need help in only printing out the... (1 Reply)
Discussion started by: Enigma23
1 Replies

2. UNIX for Advanced & Expert Users

MAX SIZE ARRAY Can Hold it

Hi, Do anyone know what's the max size of array (in awk) can be store before hit any memory issue. Regards (3 Replies)
Discussion started by: epall
3 Replies

3. Shell Programming and Scripting

Help in finding the max and min position

Hi, I have this input file called ttbitnres (which is catenated and sorted):- 8 0.4444 213 10 0.5555 342 11 0.5555 321 12 0.5555 231 13 0.4444 400 My code is at :- #!/bin/bash echo -e Version "\t" Number of Pass "\t" Number of Fail "\t" Rank Position "\t"Min "\t" Max... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

4. Shell Programming and Scripting

Max amount of awk array indices

Does anyone know what the max amount of indices you can store in a awk array? (0 Replies)
Discussion started by: timj123
0 Replies

5. HP-UX

max limit in in setting array

hi, iam getting error when i assign a variable to an array of more that 315 character in length set -A array <variable> <variable> value is 000001 000002 and up to 000045 it is giving error as "The specified subscript cannot be greater than 1024." can any one help me to solve this (2 Replies)
Discussion started by: gomathi
2 Replies

6. Shell Programming and Scripting

finding max size

Hi I have a list of 2000 records with multiple entries and I want to get the max size for each entry ABC 1 ABC 2 ABC 3 ABC 4 DEF 1 DEF 2 DEF 2 DEF 2 DEF 2 ... (9 Replies)
Discussion started by: Diya123
9 Replies

7. Shell Programming and Scripting

Finding max number in filename and opening it

Hi, I have files named as energy.dat.1 energy.dat.2 energy.dat.3 ... energy.dat.2342 I would like to find the file with maximum number in the filename (ex. energy.dat.2342) and open it. Would you please share your expertize in writing the script? Thanks in advance. (8 Replies)
Discussion started by: rpd25
8 Replies

8. Shell Programming and Scripting

awk, max value, array, row

Hello: I want to print out the entire row with max value in column 3 based on column 2. Input file is millions rows. test.dat: Contig1 lcl|1DL 111 155 265 27 Contig2 lcl|1DS 100 73 172 100 Contig3 lcl|1DL 140 698 837 140 Contig3 lcl|6DS 107 1488 1594... (1 Reply)
Discussion started by: yifangt
1 Replies

9. Shell Programming and Scripting

Finding max of a column grouping by the time

Hi, I have the below text: 16:00 0.50 16:00 0.30 16:00 0.00 16:00 0.00 16:00 0.30 16:01 0.00 16:01 0.30 I want to find the max of the 2nd column grouping by the values in the 1st column using awk. So 16:00 0.50 16:01 0.30 I have tried (3 Replies)
Discussion started by: satishrao
3 Replies

10. Programming

Php number array from max, min, step size mysql data

I want to create a form with data values in a dropdown list. The values in the dropdown list need to be generated on the fly from max, min and increment values contained in a mysql database. Hopefully this makes sense, I really have no idea where to start :confused: Thanks (6 Replies)
Discussion started by: barrydocks
6 Replies
VecStat(3pm)						User Contributed Perl Documentation					      VecStat(3pm)

NAME
Math::VecStat - Some basic numeric stats on vectors SYNOPSIS
use Math::VecStat qw(max min maxabs minabs sum average); $max=max(@vector); $max=max(@vector); ($max,$imax)=max(@vector); ($max,$imax)=max(@vector); $min=min(@vector); $min=min(@vector); ($max,$imin)=min(@vector); ($max,$imin)=min(@vector); $max=maxabs(@vector); $max=maxabs(@vector); ($max,$imax)=maxabs(@vector); ($max,$imax)=maxabs(@vector); $min=minabs(@vector); $min=minabs(@vector); ($max,$imin)=minabs(@vector); ($max,$imin)=minabs(@vector); $sum=sum($v1,$v2,...); $sum=sum(@vector); $sum=sum(@vector); $average=average($v1,$v2,...); $av=average(@vector); $av=average(@vector); $ref=vecprod($scalar,@vector); $ok=ordered(@vector); $ok=ordered(@vector); $ref=sumbyelement(@vector1,@vector2); $ref=diffbyelement(@vector1,@vector2); $ok=allequal(@vector1,@vector2); $ref=convolute(@vector1,@vector2); DESCRIPTION
This package provides some basic statistics on numerical vectors. All the subroutines can take a reference to the vector to be operated on. In some cases a copy of the vector is acceptable, but is not recommended for efficiency. max(@vector), max(@vector) return the maximum value of given values or vector. In an array context returns the value and the index in the array where it occurs. min(@vector), min(@vector) return the minimum value of given values or vector, In an array context returns the value and the index in the array where it occurs. maxabs(@vector), maxabs(@vector) return the maximum value of absolute of the given values or vector. In an array context returns the value and the index in the array where it occurs. minabs(@vector), minabs(@vector) return the minimum value of the absolute of the given values or vector. In an array context returns the value and the index in the array where it occurs. sum($v1,$v2,...), sum(@vector), sum(@vector) return the sum of the given values or vector average($v1,$v2,..), average(@vector), average(@vector) return the average of the given values or vector vecprod($a,$v1,$v2,..), vecprod($a,@vector), vecprod( $a, @vector ) return a vector built by multiplying the scalar $a by each element of the @vector. ordered($v1,$v2,..), ordered(@vector), ordered(@vector) return nonzero iff the vector is nondecreasing with respect to its index. To be used like if( ordered( $lowBound, $value, $highBound ) ){ instead of the (slightly) more clumsy if( ($lowBound <= $value) && ($value <= $highBound) ) { sumbyelement( @array1, @array2 ), diffbyelement(@array1,@array2) return the element-by-element sum or difference of two identically-sized vectors. Given $s = sumbyelement( [10,20,30], [1,2,3] ); $d = diffbyelement( [10,20,30], [1,2,3] ); $s will be "[11,22,33]", $d will be "[9,18,27]". allequal( @array1, @array2 ) returns true if and only if the two arrays are numerically identical. convolute( @array1, @array2 ) return a reference to an array containing the element-by-element product of the two input arrays. I.e., $r = convolute( [1,2,3], [-1,2,1] ); returns a reference to [-1,4,3] median evaluates the median, i.e. an element which separates the population in two halves. It returns a reference to a list whose first element is the median value and the second element is the index of the median element in the original vector. $a = Math::VecStat::median( [9,8,7,6,5,4,3,2,1] ); returns the list reference [ 5, 4 ] i.e. the median value is 5 and it is found at position 4 of the original array. If there are several elements of the array having the median value, e.g. [1,3,3,3,5]. In this case we choose always the first element in the original vector which is a median. In the example, we return [3,1]. =back =head1 HISTORY $Log: VecStat.pm,v $ Revision 1.9 2003/04/20 00:49:00 spinellia@acm.org Perl 5.8 broke test 36, exposing inconsistency in C<median>. Fixed, thanks to david@jamesgang.com. Revision 1.8 2001/01/26 11:10:00 spinellia@acm.org Added function median. Fixed test, thanks to Andreas Marcel Riechert <riechert@pobox.com> Revision 1.7 2000/10/24 15:28:00 spinellia@acm.org Added functions allequal diffbyelement Created a reasonable test suite. Revision 1.6 2000/06/29 16:06:37 spinellia@acm.org Added functions vecprod, convolute, sumbyelement Revision 1.5 1997/02/26 17:20:37 willijar Added line before pod header so pod2man installs man page correctly Revision 1.4 1996/02/20 07:53:10 willijar Added ability to return index in array contex to max and min functions. Added minabs and maxabs functions. Thanks to Mark Borges <mdb@cdc.noaa.gov> for these suggestions. Revision 1.3 1996/01/06 11:03:30 willijar Fixed stupid bug that crept into looping in min and max functions Revision 1.2 1995/12/26 09:56:38 willijar Oops - removed xy data functions. Revision 1.1 1995/12/26 09:39:07 willijar Initial revision BUGS
Let me know. I welcome any appropriate additions for this package. AUTHORS
John A.R. Williams <J.A.R.Williams@aston.ac.uk> Andrea Spinelli <spinellia@acm.org> perl v5.12.4 2011-07-11 VecStat(3pm)
All times are GMT -4. The time now is 09:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy