Sponsored Content
Top Forums Shell Programming and Scripting Calculating cumulative frequency Post 302480049 by sajal.bhatia on Tuesday 14th of December 2010 01:05:17 AM
Old 12-14-2010
Calculating cumulative frequency

Hi,

I have a file containing the frequency's of an element sorted in ascending order. The file looks something like this:

#Element Frequency
1 1
2 1
3 1
4 1
5 1
6 1
7 2
8 10
9 15
10 20

What I want is to calculate and print the cumulative frequency (adding the current frequency to the sum of the previous frequency's) with the existing data. So the
output file should look like this:

#Element Frequency Cumulative Frequency
1 1 1
2 1 2
3 1 3
4 1 4
5 1 5
6 1 6
7 2 8
8 10 18
9 15 33
10 20 53

Thanks !!
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with calculating frequency of specific word in a string

Input file: #read_1 AWEAWQQRZZZQWQQWZ #read_2 ZZAQWRQTWQQQWADSADZZZ #read_3 POGZZZZZZADWRR . . Desired output file: #read_1 3 #read_1 1 #read_2 2 #read_2 3 #read_3 6 . . (3 Replies)
Discussion started by: perl_beginner
3 Replies

2. Shell Programming and Scripting

Calculating frequency of values within bins

Hi, I am working with files containing 2 columns in which i need to come up with the frequency/count of values in col. 2 falling within specifics binned values of col. 1. the contents of a sample file is shown below: 15 12.5 15 11.2 16 0.2 16 1.4 17 1.6 18 4.5 17 5.6 12 8.6 11 7.2 9 ... (13 Replies)
Discussion started by: ida1215
13 Replies

3. Shell Programming and Scripting

Calculating the epoch time from standard time using awk and calculating the duration

Hi All, I have the following time stamp data in 2 columns Date TimeStamp(also with milliseconds) 05/23/2012 08:30:11.250 05/23/2012 08:30:15.500 05/23/2012 08:31.15.500 . . etc From this data I need the following output. 0.00( row1-row1 in seconds) 04.25( row2-row1 in... (5 Replies)
Discussion started by: ks_reddy
5 Replies

4. UNIX for Dummies Questions & Answers

Calculating cumulative frequency using awk

Hi, I wanted to calculate cumulative frequency distribution of my data that involves several arithmetic calls. I did things in excel but its taking me forever. this is what I want to do: var1.txt contains n observations which I have to compute for frequency which is given by 1/n and subsequently... (7 Replies)
Discussion started by: ida1215
7 Replies

5. Red Hat

Command for cumulative disk space

I wanted to know the Red Hat Linux command for cumulative disk space usage and the free space as df -h gives used and free space individually for the drives. Or, a command to check free space on the server would also be fine. I hope, my question is clear. Please revert with the reply to my... (2 Replies)
Discussion started by: RHCE
2 Replies

6. Shell Programming and Scripting

Calculatin cumulative elapsed time from mm:ss.ss data

Hello all, I got some time duration data like below and I want to compute the cumulative elapsed time. The data is in MM:SS.SS format. I got struck with logic on what to do when it changes from 59:59.ss to 00:00.ss. 59:59.4 59:59.6 59:59.9 00:00.1 00:00.4 00:00.6 00:00.9 I need the... (5 Replies)
Discussion started by: ks_reddy
5 Replies

7. Shell Programming and Scripting

awk or Bash: Cumulative average

For the data I would like to parse down and for each parsing I want a cumulative averaging, stored in an array that can be output. I.e. 546/NR = 546 (546+344)/NR=(546+344)/2 = etc. For N record input I want N values of the average (a block averaging effectively) Any... (3 Replies)
Discussion started by: chrisjorg
3 Replies

8. UNIX for Beginners Questions & Answers

How to find out the maximum cumulative value?

I have a file has thousands of rows and each row has a number and the number can be positive or negative. I want to do the cumulative sum from the first row. How can I find out the maximum cumulative value when I do the sum work row by row. Here is the example: 4 -3 2 -3 -1 1In this case, the... (5 Replies)
Discussion started by: yuejian
5 Replies
cpufreq-aperf(1)														  cpufreq-aperf(1)

NAME
cpufreq-aperf - Calculates the average frequency over a time period SYNTAX
cpufreq-aperf [options] DESCRIPTION
On latest processors exist two MSR registers refered to as: - MPERF increasing with maxium (P0) frequency in C0 - APERF increasing with current/actual frequency in C0 From this information the average frequency over a time period can be calculated and this is what this tool does. A nice falloff feature beside the average frequency is the time a processor core remained in C0 (working state) or any CX (sleep state) processor sleep state during the measured time period. This information can be determined from the fact that MPERF only increases in C0 state. OPTIONS
-c --cpu <CPU> The <CPU> core to measure - default all cores. -i --interval <seconds> Refresh rate - default 1 second. -o --once Exit after one interval. -h --help Prints the available options. REMARKS
The msr driver must be loaded for this command to work. AUTHORS
Thomas Renninger <trenn@suse.de> SEE ALSO
cpufreq-set(1), cpufreq-info(1) Mattia Dongili 0.1 cpufreq-aperf(1)
All times are GMT -4. The time now is 02:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy