|
From: <pl...@pi...> - 2008-01-23 11:28:11
|
On Wed, 23 Jan 2008 02:57:31 +0100, Philipp K. Janert <ja...@ie...> wrote: > > 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. > Well that is getting into the realm of data processing that some feel is= beyond the scope of a plotting tool and indeed the line has to be drawn somewhere. This sort of thing can already be done using the new assignment syntax b= ut requires two passes. ie a first plot command that calls some function on= each point as it is plotted , then a new plot command that uses some stored result and plots what you want to see. > 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. > mean_sd(x)=3D (....... , mean=3D..., sdddev=3D...); plot "data" u 1:(mean_sd($2)) plot "data" u 1:( ($2-mean)/stddev ) I currently do something like this to plot an arrow representing the mea= n y value. The arrow has to be defined before the plot so I have to do one= run just to get the mean with a trivial function then replot with my arr= ow. > 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... > That would be an never ending list of desired functions that someone wou= ld always want extending. There exists now two mechanisms , one internal and of course the traditional ablility to call any outside prog or script to do more compl= ex analysis. Maybe someone with a good grounding in these stats could provide a set o= f gnuplot functions as a .gnu that could be added to any users .gnu with o= ne line of load "basic-stats.gnu" like Ethan suggested. If something is to be added here like your stat suggestion it could be a= dont_plot option that mimics the way plot goes through the data without spending time creating the output. This would allow a prepass for simple= d.p. functions as outlines above without much of the redundancy. I expect it would be pretty simple to add this as an plot option or null= line type that simple avoids calling the output routine. I'd have to dig= into the code. The above example could become: plot "data" u 1:(mean_sd($2)) noplot plot "data" u 1:( ($2-mean)/stddev ) This could substancially improve the efficiency of the dual pass appraoc= h. regards, Peter. > 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 gnuplo= t. >> > > > These functions include: >> > > > min() >> > > > max() >> > > > std() >> > > > mean() >> > > > etc. >> > > >> > > Could you explain why you need to have these as built-in function= s? >> > > What is wrong with just defining them yourself: >> > > >> > > min(A,B) =3D 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 i= f >> 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. > > ----------------------------------------------------------------------= --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > gnuplot-beta mailing list > gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-beta > |