.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "VecStat 3pm" .TH VecStat 3pm "2011-07-11" "perl v5.12.4" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" .Vb 1 \& Math::VecStat \- Some basic numeric stats on vectors .Ve .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 10 \& use Math::VecStat qw(max min maxabs minabs sum average); \& $max=max(@vector); \& $max=max(\e@vector); \& ($max,$imax)=max(@vector); \& ($max,$imax)=max(\e@vector); \& $min=min(@vector); \& $min=min(\e@vector); \& ($max,$imin)=min(@vector); \& ($max,$imin)=min(\e@vector); \& $max=maxabs(@vector); \& $max=maxabs(\e@vector); \& ($max,$imax)=maxabs(@vector); \& ($max,$imax)=maxabs(\e@vector); \& $min=minabs(@vector); \& $min=minabs(\e@vector); \& ($max,$imin)=minabs(@vector); \& ($max,$imin)=minabs(\e@vector); \& $sum=sum($v1,$v2,...); \& $sum=sum(@vector); \& $sum=sum(\e@vector); \& $average=average($v1,$v2,...); \& $av=average(@vector); \& $av=average(\e@vector); \& $ref=vecprod($scalar,\e@vector); \& $ok=ordered(@vector); \& $ok=ordered(\e@vector); \& $ref=sumbyelement(\e@vector1,\e@vector2); \& $ref=diffbyelement(\e@vector1,\e@vector2); \& $ok=allequal(\e@vector1,\e@vector2); \& $ref=convolute(\e@vector1,\e@vector2); .Ve .SH "DESCRIPTION" .IX Header "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. .IP "max(@vector), max(\e@vector)" 5 .IX Item "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. .IP "min(@vector), min(\e@vector)" 5 .IX Item "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. .IP "maxabs(@vector), maxabs(\e@vector)" 5 .IX Item "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. .IP "minabs(@vector), minabs(\e@vector)" 5 .IX Item "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. .IP "sum($v1,$v2,...), sum(@vector), sum(\e@vector)" 5 .IX Item "sum($v1,$v2,...), sum(@vector), sum(@vector)" return the sum of the given values or vector .IP "average($v1,$v2,..), average(@vector), average(\e@vector)" 5 .IX Item "average($v1,$v2,..), average(@vector), average(@vector)" return the average of the given values or vector .ie n .IP "vecprod($a,$v1,$v2,..), vecprod($a,@vector), vecprod( $a, \e@vector )" 5 .el .IP "vecprod($a,$v1,$v2,..), vecprod($a,@vector), vecprod( \f(CW$a\fR, \e@vector )" 5 .IX Item "vecprod($a,$v1,$v2,..), vecprod($a,@vector), vecprod( $a, @vector )" return a vector built by multiplying the scalar \f(CW$a\fR by each element of the \&\f(CW@vector\fR. .IP "ordered($v1,$v2,..), ordered(@vector), ordered(\e@vector)" 5 .IX Item "ordered($v1,$v2,..), ordered(@vector), ordered(@vector)" return nonzero iff the vector is nondecreasing with respect to its index. To be used like .Sp .Vb 1 \& if( ordered( $lowBound, $value, $highBound ) ){ .Ve .Sp instead of the (slightly) more clumsy .Sp .Vb 1 \& if( ($lowBound <= $value) && ($value <= $highBound) ) { .Ve .IP "sumbyelement( \e@array1, \e@array2 ), diffbyelement(\e@array1,\e@array2)" 5 .IX Item "sumbyelement( @array1, @array2 ), diffbyelement(@array1,@array2)" return the element-by-element sum or difference of two identically-sized vectors. Given .Sp .Vb 2 \& $s = sumbyelement( [10,20,30], [1,2,3] ); \& $d = diffbyelement( [10,20,30], [1,2,3] ); .Ve .Sp \&\f(CW$s\fR will be \f(CW\*(C`[11,22,33]\*(C'\fR, \f(CW$d\fR will be \f(CW\*(C`[9,18,27]\*(C'\fR. .IP "allequal( \e@array1, \e@array2 )" 5 .IX Item "allequal( @array1, @array2 )" returns true if and only if the two arrays are numerically identical. .IP "convolute( \e@array1, \e@array2 )" 5 .IX Item "convolute( @array1, @array2 )" return a reference to an array containing the element-by-element product of the two input arrays. I.e., .Sp .Vb 1 \& $r = convolute( [1,2,3], [\-1,2,1] ); .Ve .Sp returns a reference to .Sp .Vb 1 \& [\-1,4,3] .Ve .IP "median" 5 .IX Item "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. .Sp .Vb 1 \& $a = Math::VecStat::median( [9,8,7,6,5,4,3,2,1] ); .Ve .Sp returns the list reference .Sp .Vb 1 \& [ 5, 4 ] .Ve .Sp i.e. the median value is 5 and it is found at position 4 of the original array. .Sp 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 \s-1HISTORY\s0 .Sp .Vb 3 \& $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. 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 \& \& 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 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 .Ve .SH "BUGS" .IX Header "BUGS" Let me know. I welcome any appropriate additions for this package. .SH "AUTHORS" .IX Header "AUTHORS" John A.R. Williams Andrea Spinelli