2

I'm computing the statistics of a file where the 2nd column is my X-value and the 15th column is my Y-value. This works fine as long as the x-range covers the whole data in the file.

stats '$LOGFILE' using 15 name 'rate_Y_'
print rate_Y_max

outputs this:

* FILE: 
  Records:      74
  Out of range:  0
  Invalid:       0
  Blank:         0
  Data Blocks:   1

* COLUMN: 
  Mean:      26391.9815
  Std Dev:   37555.9366
  Sum:      1.95301e+06
  Sum Sq.:  1.55917e+11

  Minimum:    2793.2603 [ 1]
  Maximum:  142755.0813 [73]
  Quartile:   4586.2274 
  Median:    10359.6168 
  Quartile:  27017.6600

142755.081306

But when I want to limit the x-range, I have to define my X-column

set xrange [40:400]
stats '$LOGFILE' using 2:15 name 'rate_Y_'

and get a two-dimensional statistic and my variable rate_Y_max is not accessible any more:

* FILE: 
  Records:      7
  Out of range: 67
  Invalid:      0
  Blank:        0
  Data Blocks:  1

* COLUMNS:
  Mean:        182.1429       111416.6321
  Std Dev:     118.5585        14491.4560
  Sum:        1275.0000       779916.4248
  Sum Sq.:  330625.0000       8.83657e+10

  Minimum:      50.0000 [6]    83292.6937 [0]
  Maximum:     400.0000 [0]   124953.1493 [5]
  Quartile:     75.0000        99960.3747
  Median:      150.0000       111045.6078
  Quartile:    300.0000       124912.0550

  Linear Model: y = -120 x + 1.333e+05
  Correlation:  r = -0.9817
  Sum xy:       1.302e+08

           line 0: undefined variable: rate_Y_max

Question: How do I access two-dimensional statistic variables?

2 Answers 2

3

Use show variables rate_ to see all variables that were generated by you call to stats ... name 'rate'.

set xrange [0:100]
stats '+' using 1:($1**2) name 'rate'

Now call show variables rate_ which prints

Variables beginning with rate_:
...
rate_min_x = 0.0
rate_max_x = 100.0
...
rate_min_y = 0.0
rate_max_y = 10000.0
...
Sign up to request clarification or add additional context in comments.

Comments

1

From the doc :

If two columns are analysed jointly by a single stats command, the suffix "_x" or "_y" is appended to each variable name. I.e. STATS_min_x is the minimum value found in the first column, while STATS_min_y is the minimum value found in the second column.

So

rate_Y_max_y

Is what you're looking for.

You probably should use :

stats '$LOGFILE' using 2:15 name 'rate'
print rate_max_y

1 Comment

LOL. 3 years later, I come back to this post and want to upvote it, before realizing I'm the one who also had this problem and wrote an answer for it already.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.