10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
HI
I need to get the function "kick" to get executed in any way the parameters are passed in to the function. The parameters are first stored in a dictionary
self.otherlist = {}
print self.otherlist
self.populateTestList(self.system_type)
print... (1 Reply)
Discussion started by: Priya Amaresh
1 Replies
2. Shell Programming and Scripting
Hi,
I want to be able to sort/print a hash based on the string length of the values.
For example
%hash = (
key1 => 'jeri',
key2 => 'corona',
key3 => 'una,
);
I want to be able to print in the following order (smallest to largest)
una,jeri,corona
OR... (1 Reply)
Discussion started by: jdilts
1 Replies
3. Shell Programming and Scripting
I want to sort values of a hash in ascending order.
my %records;
for my $value (sort values %records){print $value,"\n";}
When I use the above code I get values in this order: 1,10,11,2,3,4,5,6,7,8,9. But, I need values in my output in this order: 1,2,3,4,5,6,7,8,9,10,11.
Can Someone... (1 Reply)
Discussion started by: koneru_18
1 Replies
4. Shell Programming and Scripting
Hi All,
Thanks all for the continued support so far.
Today, I need to find the most occurring string/number(also called mode in statistics terminology) for each column in a data file (.csv type).
For one column of data(1.txt) like below
Sample
1
2
2
3
4
1
1
1
2
I can find the mode... (6 Replies)
Discussion started by: ks_reddy
6 Replies
5. Shell Programming and Scripting
Dear Forum
I'm Trying to use split function to split a string, but the output is not as the same order as of the string, please see simple example
echo " " | nawk -v var="First;Second;Third;Fourth" '
BEGIN {split(var, arr,";") for(i in arr){print arr }}'
The output is
Second
Third... (6 Replies)
Discussion started by: yahyaaa
6 Replies
6. Shell Programming and Scripting
Can Someone explain me why even using Tie::IxHash I can not get the output data in the same order that it was inserted? See code below.
#!/usr/bin/perl
use warnings;
use Tie::IxHash;
use strict;
tie (my %programs, "Tie::IxHash");
while (my $line = <DATA>) {
chomp $line;
my(... (1 Reply)
Discussion started by: jgfcoimbra
1 Replies
7. Programming
Hi,
I want build 10 processus with fork and that each processus write a value betwen 0 and 9 , but each processus send the same value .
So my code ,you can compile and try .
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h> ... (7 Replies)
Discussion started by: carton99
7 Replies
8. Programming
I have created my own hash table class, but am looking to speed it up. My current hash function is:
int HashTable::hashFunc(const string &key) const
{
int tableSize = theLists.size();
int hashVal = 0;
for(int i = 0; i<key.length(); i++)
hashVal =... (7 Replies)
Discussion started by: killerqb
7 Replies
9. Shell Programming and Scripting
I have a file with a format of
A,2
B,2
G,3
A,2
A,3
A,2
D,7
A,2
E,2
A,2
I need to create a sum of each alphabet with the numbers assigned to it using awk. (2 Replies)
Discussion started by: dinjo_jo
2 Replies
10. Programming
Hi all,
Is the rand() function in C uniform or normal distribution. If it is unform, is there a random function that is normal.
Thanks and Regards (2 Replies)
Discussion started by: omran
2 Replies
Statistics::Basic::Mean(3pm) User Contributed Perl Documentation Statistics::Basic::Mean(3pm)
NAME
Statistics::Basic::Mean - find the mean of a list
SYNOPSIS
Invoke it this way:
my $avg = mean(1,2,3);
Or this way:
my $v1 = vector(1,2,3);
my $avg = avg($v1);
And then either query the values or print them like so:
print "The mean of $v1: $avg
";
my $mq = $avg->query;
my $m0 = 0+$avg;
Create a 20 point moving average like so:
use Statistics::Basic qw(:all nofill);
my $sth = $dbh->prepare("select col1 from data where something");
my $len = 20;
my $avg = mean()->set_size($len);
$sth->execute or die $dbh->errstr;
$sth->bind_columns( my $val ) or die $dbh->errstr;
while( $sth->fetch ) {
$avg->insert( $val );
if( defined( my $m = $avg->query ) ) {
print "Mean: $m
";
}
# This would also work:
# print "Mean: $avg
" if $avg->query_filled;
}
METHODS
new()
The constructor takes a single array ref or a single Statistics::Basic::Vector as arguments. It returns a Statistics::Basic::Mean
object.
Note: normally you'd use the mean() constructor, rather than building these by hand using "new()".
_OVB::import()
This module also inherits all the overloads and methods from Statistics::Basic::_OneVectorBase.
OVERLOADS
This object is overloaded. It tries to return an appropriate string for the calculation or the value of the computation in numeric
context.
In boolean context, this object is always true (even when empty).
AUTHOR
Paul Miller "<jettero@cpan.org>"
COPYRIGHT
Copyright 2012 Paul Miller -- Licensed under the LGPL
SEE ALSO
perl(1), Statistics::Basic, Statistics::Basic::_OneVectorBase, Statistics::Basic::Vector
perl v5.14.2 2012-01-23 Statistics::Basic::Mean(3pm)