LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Simple Stats question (https://www.linuxquestions.org/questions/linux-newbie-8/simple-stats-question-226855/)

lugnut 09-05-2004 03:00 AM

Simple Stats question
 
Hello,

I'm sure this is an easy one for someone.

I have a network device log file that has the number of concurrently logged on users at the end of some of the log file lines. Using AWK, grep, and sort, I'm able extract just the numeric information I want and redirect it to a text file. What I'd like to do is to determine the mean, median, and mode from the set of numbers in the text file. The data in the text file is sorted by number and consists of one number per line (and there is nothing but a number on each line). What would be an easy way to do this (I'm only looking for how to read data from a textfile and then work with it using math functions, and not how to find the mean, median, and mode from a set of numbers :D )

Thanks in advance

Tinkster 09-05-2004 04:04 PM

I'd stick with awk, in that case ...
does it well, maths and all... you can find out
the number of records with awk, you can add
things up quite easily, ...
{ count += $1}; END{ print count/NR}


Cheers,
Tink

lugnut 09-05-2004 04:59 PM

Thanks for the reply Tinkster. I'll have to check out what I can do that way. I was thinking of a shell script to read in the values from the text file, but I wasn't sure how to do that.

Thanks again.


All times are GMT -5. The time now is 08:35 PM.