|
From: Philipp K. J. <ja...@ie...> - 2008-01-23 01:57:36
|
I am also not sure that having min(), max(), etc for some fixed number of args would be all that useful. What would be AWESOME, however (at least in my opinion) is to have those kinds of functions to operate on input data. Why? Here is an example. Often I would like to do this: plot "data" u 1:($2 - mean($2)) or plot "data" u 1:( ($2-mean($2))/stddev($2) ) etc. Given how data file input is currently handled, something like the above would be difficult to implement, I think (would require multiple passes). A very useful alternative might be to have a "stat" command, so that I could say: stat "data" u 1 and it prints a brief report to the terminal, including all the usual suspects (mean, stddev, min, max, median...) That would be tremendously useful when working with data... Best, Ph. On Tuesday 22 January 2008 14:41, Ethan Merritt wrote: > On Tuesday 22 January 2008 14:30, Mojca Miklavec wrote: > > On Jan 22, 2008 11:20 PM, Ethan Merritt wrote: > > > On Tuesday 22 January 2008 05:54, Daniel Heiserer wrote: > > > > I would like to add some functions to the CVS version of gnuplot. > > > > These functions include: > > > > min() > > > > max() > > > > std() > > > > mean() > > > > etc. > > > > > > Could you explain why you need to have these as built-in functions? > > > What is wrong with just defining them yourself: > > > > > > min(A,B) = A < B ? A : B > > > > > > You can put that definition in your customization file ~/.gnuplot > > > if you always like to have it. > > > > I agree that min, max, mean and others might be handy to have. I > > always "hack them" with ($1+$2+$3+$4)/4 or the way you have just > > shown, but these are really basic functions that are often used and > > easy to implement. > > The two argument case is trivial, as shown above. > The general case of N arguments would be less trivial, particularly if > you are looking for a way to make the calculation over an arbitrary > number of data points read from a data file. > > Before jumping in with both feet, I think it would be useful to > block out what exactly is the goal. > > I can understand wanting MIN and MAX for simple bookkeeping, > for example choosing which of two column values to use. > > But the need for a command line std(a,b,c,...) or mean(a,b,c,...) > function is not obvious to me. This seems more like something one > would track automatically during the course of data input than > something one would type in manually at the command line. > > > Instead of asking "why one would want to add them", I would rather ask > > "why not". > > The reason to ask "why" is that there may be a better way to achieve > the actual goal. |