|
From: Jon <dev...@gm...> - 2011-02-14 18:22:53
|
Dear Thomas, Nunzio Losacco wrote a short script to get each number divided by the smallest number in a specific column, as min=10**10 grab(x)=x<min?min=x:min=min plot 'disy.100' u 1:($3/grab($3)) I don't quite understand the logic behind although I checked that it works fine. If I were to do this, I would write something like set term dumb min=10**10 plot 'disy.100' u ($3<min?min=$3:min=min,$1):3 set term x11 plot 'disy.100' u 1:($3/min) and you easily see the idea I wrote it this way. I think this reflects a big problem for me to understand deeply how gnuplot deals with datafile and how it plots, which is obviously different from the standard programming languages. Thanks for your in-depth explanation or references, Sincerely, Jon |
|
From: Thomas S. <t.s...@fz...> - 2011-02-15 08:31:34
|
strictly speaking, nunzio's script only works if the smallest number is in the 1st data line. an example: #ts.dat: 1 10 2 9 3 8 4 7 5 6 6 5 7 4 8 3 9 2 10 1 #script: min=10**10 grab(x)=x<min?min=x:min=min plot 'ts.dat' using 1:($2/grab($2)) gives a horizontal line and a warning about the empty y-range. this means that gnuplot behaves like other programming languages and there is no magic behind it. a 2nd plot gives the correct result, as you have pointed out, because then 'min' already contains the smallest value. #script: min=10**10 grab(x)=x<min?min=x:min=min plot "ts.dat" using 1:($2/grab($2)), "" using 1:($2/grab($2)) ... , "" using 1:($2/grab($2)) is equivalent to ... , "" using 1:($2/min) bsmile wrote: > > Dear Thomas, > > Nunzio Losacco wrote a short script to get each number divided by the > smallest number in a specific column, as > min=10**10 > grab(x)=x<min?min=x:min=min > plot 'disy.100' u 1:($3/grab($3)) > > I don't quite understand the logic behind although I checked that it works > fine. If I were to do this, I would write something like > > set term dumb > min=10**10 > plot 'disy.100' u ($3<min?min=$3:min=min,$1):3 > > set term x11 > plot 'disy.100' u 1:($3/min) > > and you easily see the idea I wrote it this way. I think this reflects a > big > problem for me to understand deeply how gnuplot deals with datafile and > how > it plots, which is obviously different from the standard programming > languages. Thanks for your in-depth explanation or references, > > Sincerely, > Jon > ------------------------------------------------------------------------------ > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > Pinpoint memory and threading errors before they happen. > Find and fix more than 250 security defects in the development cycle. > Locate bottlenecks in serial and parallel code that limit performance. > http://p.sf.net/sfu/intel-dev2devfeb > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > -- View this message in context: http://old.nabble.com/explanation-to-a-short-script-tp30924408p30928896.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
|
From: Jon <dev...@gm...> - 2011-02-15 16:51:11
|
Dear Thomas, I actually specifically checked whether the first script could capture a minimum hidden in the data except for the first line. The sample data I used is 1 0.9 2 0.45 3 0.1 4 0.94 5 0.44 6 0.12 7 0.36 and it seems a single pass corrected identified 0.1 as the minimum. As to your sample data, the missing of y range is a 2nd mysterious to me as if I change the data to float, it works fine, and even if I interpret the data to be integer, it should still give the right answer instead of giving constant 1 for each dataline. Sincerely, Jon On Tue, Feb 15, 2011 at 2:31 AM, Thomas Sefzick <t.s...@fz...>wrote: > > strictly speaking, nunzio's script only works if the smallest number is in > the > 1st data line. > > an example: > > #ts.dat: > 1 10 > 2 9 > 3 8 > 4 7 > 5 6 > 6 5 > 7 4 > 8 3 > 9 2 > 10 1 > > #script: > min=10**10 > grab(x)=x<min?min=x:min=min > plot 'ts.dat' using 1:($2/grab($2)) > > gives a horizontal line and a warning about the empty y-range. > this means that gnuplot behaves like other programming languages > and there is no magic behind it. > > a 2nd plot gives the correct result, as you have pointed out, > because then 'min' already contains the smallest value. > > #script: > min=10**10 > grab(x)=x<min?min=x:min=min > plot "ts.dat" using 1:($2/grab($2)), "" using 1:($2/grab($2)) > > ... , "" using 1:($2/grab($2)) > is equivalent to > ... , "" using 1:($2/min) > > > bsmile wrote: > > > > Dear Thomas, > > > > Nunzio Losacco wrote a short script to get each number divided by the > > smallest number in a specific column, as > > min=10**10 > > grab(x)=x<min?min=x:min=min > > plot 'disy.100' u 1:($3/grab($3)) > > > > I don't quite understand the logic behind although I checked that it > works > > fine. If I were to do this, I would write something like > > > > set term dumb > > min=10**10 > > plot 'disy.100' u ($3<min?min=$3:min=min,$1):3 > > > > set term x11 > > plot 'disy.100' u 1:($3/min) > > > > and you easily see the idea I wrote it this way. I think this reflects a > > big > > problem for me to understand deeply how gnuplot deals with datafile and > > how > > it plots, which is obviously different from the standard programming > > languages. Thanks for your in-depth explanation or references, > > > > Sincerely, > > Jon > > > ------------------------------------------------------------------------------ > > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > > Pinpoint memory and threading errors before they happen. > > Find and fix more than 250 security defects in the development cycle. > > Locate bottlenecks in serial and parallel code that limit performance. > > http://p.sf.net/sfu/intel-dev2devfeb > > _______________________________________________ > > gnuplot-info mailing list > > gnu...@li... > > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > > > > > -- > View this message in context: > http://old.nabble.com/explanation-to-a-short-script-tp30924408p30928896.html > Sent from the Gnuplot - User mailing list archive at Nabble.com. > > > > ------------------------------------------------------------------------------ > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > Pinpoint memory and threading errors before they happen. > Find and fix more than 250 security defects in the development cycle. > Locate bottlenecks in serial and parallel code that limit performance. > http://p.sf.net/sfu/intel-dev2devfeb > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > |
|
From: Thomas S. <t.s...@fz...> - 2011-02-15 19:06:15
|
the script correctly identifies 0.1 as the minimum, yes, but not for all data points. you may have noticed that the 1st three y-values in the plot are '1', but should be '0.09', '0.045', and '1'. the script searches for the minimum by storing the actual y-value if it's smaller than a previous one. as long as the absolute minimum isn't found, i.e. the data line with the minumum y-value hasn't been yet read, y-values are divided by the intermediate minimum. that's the reason why the y-values are always '1' when reading my data set. bsmile wrote: > > Dear Thomas, > > I actually specifically checked whether the first script could capture a > minimum hidden in the data except for the first line. The sample data I > used > is > > 1 0.9 > 2 0.45 > 3 0.1 > 4 0.94 > 5 0.44 > 6 0.12 > 7 0.36 > > and it seems a single pass corrected identified 0.1 as the minimum. As to > your sample data, the missing of y range is a 2nd mysterious to me as if I > change the data to float, it works fine, and even if I interpret the data > to > be integer, it should still give the right answer instead of giving > constant > 1 for each dataline. > > Sincerely, > Jon > > > On Tue, Feb 15, 2011 at 2:31 AM, Thomas Sefzick > <t.s...@fz...>wrote: > >> >> strictly speaking, nunzio's script only works if the smallest number is >> in >> the >> 1st data line. >> >> an example: >> >> #ts.dat: >> 1 10 >> 2 9 >> 3 8 >> 4 7 >> 5 6 >> 6 5 >> 7 4 >> 8 3 >> 9 2 >> 10 1 >> >> #script: >> min=10**10 >> grab(x)=x<min?min=x:min=min >> plot 'ts.dat' using 1:($2/grab($2)) >> >> gives a horizontal line and a warning about the empty y-range. >> this means that gnuplot behaves like other programming languages >> and there is no magic behind it. >> >> a 2nd plot gives the correct result, as you have pointed out, >> because then 'min' already contains the smallest value. >> >> #script: >> min=10**10 >> grab(x)=x<min?min=x:min=min >> plot "ts.dat" using 1:($2/grab($2)), "" using 1:($2/grab($2)) >> >> ... , "" using 1:($2/grab($2)) >> is equivalent to >> ... , "" using 1:($2/min) >> >> >> bsmile wrote: >> > >> > Dear Thomas, >> > >> > Nunzio Losacco wrote a short script to get each number divided by the >> > smallest number in a specific column, as >> > min=10**10 >> > grab(x)=x<min?min=x:min=min >> > plot 'disy.100' u 1:($3/grab($3)) >> > >> > I don't quite understand the logic behind although I checked that it >> works >> > fine. If I were to do this, I would write something like >> > >> > set term dumb >> > min=10**10 >> > plot 'disy.100' u ($3<min?min=$3:min=min,$1):3 >> > >> > set term x11 >> > plot 'disy.100' u 1:($3/min) >> > >> > and you easily see the idea I wrote it this way. I think this reflects >> a >> > big >> > problem for me to understand deeply how gnuplot deals with datafile and >> > how >> > it plots, which is obviously different from the standard programming >> > languages. Thanks for your in-depth explanation or references, >> > >> > Sincerely, >> > Jon >> > >> ------------------------------------------------------------------------------ >> > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio >> XE: >> > Pinpoint memory and threading errors before they happen. >> > Find and fix more than 250 security defects in the development cycle. >> > Locate bottlenecks in serial and parallel code that limit performance. >> > http://p.sf.net/sfu/intel-dev2devfeb >> > _______________________________________________ >> > gnuplot-info mailing list >> > gnu...@li... >> > https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> > >> > >> >> -- >> View this message in context: >> http://old.nabble.com/explanation-to-a-short-script-tp30924408p30928896.html >> Sent from the Gnuplot - User mailing list archive at Nabble.com. >> >> >> >> ------------------------------------------------------------------------------ >> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: >> Pinpoint memory and threading errors before they happen. >> Find and fix more than 250 security defects in the development cycle. >> Locate bottlenecks in serial and parallel code that limit performance. >> http://p.sf.net/sfu/intel-dev2devfeb >> _______________________________________________ >> gnuplot-info mailing list >> gnu...@li... >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> > ------------------------------------------------------------------------------ > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > Pinpoint memory and threading errors before they happen. > Find and fix more than 250 security defects in the development cycle. > Locate bottlenecks in serial and parallel code that limit performance. > http://p.sf.net/sfu/intel-dev2devfeb > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > -- View this message in context: http://old.nabble.com/explanation-to-a-short-script-tp30924408p30934168.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
|
From: Jon <dev...@gm...> - 2011-02-15 22:08:27
|
Dear Thomas, I attach the plot here for both cases using the dataset I listed in the previous email. You can see that the rescaled data really uses 0.1 as the minimum. By the way, I cannot understand what you mean by saying "but should be '0.09', '0.045', and '1'"? Shouldn't the first three be "9,4.5,1", as correctly shown in the plot I attach in this email? Thanks, Sincerely, Jon On Tue, Feb 15, 2011 at 1:06 PM, Thomas Sefzick <t.s...@fz...>wrote: > > the script correctly identifies 0.1 as the minimum, yes, > but not for all data points. > you may have noticed that the 1st three y-values in the plot are '1', > but should be '0.09', '0.045', and '1'. > > the script searches for the minimum by storing the actual y-value if > it's smaller than a previous one. as long as the absolute minimum > isn't found, i.e. the data line with the minumum y-value hasn't been > yet read, y-values are divided by the intermediate minimum. > that's the reason why the y-values are always '1' when reading > my data set. > > > bsmile wrote: > > > > Dear Thomas, > > > > I actually specifically checked whether the first script could capture a > > minimum hidden in the data except for the first line. The sample data I > > used > > is > > > > 1 0.9 > > 2 0.45 > > 3 0.1 > > 4 0.94 > > 5 0.44 > > 6 0.12 > > 7 0.36 > > > > and it seems a single pass corrected identified 0.1 as the minimum. As to > > your sample data, the missing of y range is a 2nd mysterious to me as if > I > > change the data to float, it works fine, and even if I interpret the data > > to > > be integer, it should still give the right answer instead of giving > > constant > > 1 for each dataline. > > > > Sincerely, > > Jon > > > > > > On Tue, Feb 15, 2011 at 2:31 AM, Thomas Sefzick > > <t.s...@fz...>wrote: > > > >> > >> strictly speaking, nunzio's script only works if the smallest number is > >> in > >> the > >> 1st data line. > >> > >> an example: > >> > >> #ts.dat: > >> 1 10 > >> 2 9 > >> 3 8 > >> 4 7 > >> 5 6 > >> 6 5 > >> 7 4 > >> 8 3 > >> 9 2 > >> 10 1 > >> > >> #script: > >> min=10**10 > >> grab(x)=x<min?min=x:min=min > >> plot 'ts.dat' using 1:($2/grab($2)) > >> > >> gives a horizontal line and a warning about the empty y-range. > >> this means that gnuplot behaves like other programming languages > >> and there is no magic behind it. > >> > >> a 2nd plot gives the correct result, as you have pointed out, > >> because then 'min' already contains the smallest value. > >> > >> #script: > >> min=10**10 > >> grab(x)=x<min?min=x:min=min > >> plot "ts.dat" using 1:($2/grab($2)), "" using 1:($2/grab($2)) > >> > >> ... , "" using 1:($2/grab($2)) > >> is equivalent to > >> ... , "" using 1:($2/min) > >> > >> > >> bsmile wrote: > >> > > >> > Dear Thomas, > >> > > >> > Nunzio Losacco wrote a short script to get each number divided by the > >> > smallest number in a specific column, as > >> > min=10**10 > >> > grab(x)=x<min?min=x:min=min > >> > plot 'disy.100' u 1:($3/grab($3)) > >> > > >> > I don't quite understand the logic behind although I checked that it > >> works > >> > fine. If I were to do this, I would write something like > >> > > >> > set term dumb > >> > min=10**10 > >> > plot 'disy.100' u ($3<min?min=$3:min=min,$1):3 > >> > > >> > set term x11 > >> > plot 'disy.100' u 1:($3/min) > >> > > >> > and you easily see the idea I wrote it this way. I think this reflects > >> a > >> > big > >> > problem for me to understand deeply how gnuplot deals with datafile > and > >> > how > >> > it plots, which is obviously different from the standard programming > >> > languages. Thanks for your in-depth explanation or references, > >> > > >> > Sincerely, > >> > Jon > >> > > >> > ------------------------------------------------------------------------------ > >> > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio > >> XE: > >> > Pinpoint memory and threading errors before they happen. > >> > Find and fix more than 250 security defects in the development cycle. > >> > Locate bottlenecks in serial and parallel code that limit performance. > >> > http://p.sf.net/sfu/intel-dev2devfeb > >> > _______________________________________________ > >> > gnuplot-info mailing list > >> > gnu...@li... > >> > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> > > >> > > >> > >> -- > >> View this message in context: > >> > http://old.nabble.com/explanation-to-a-short-script-tp30924408p30928896.html > >> Sent from the Gnuplot - User mailing list archive at Nabble.com. > >> > >> > >> > >> > ------------------------------------------------------------------------------ > >> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio > XE: > >> Pinpoint memory and threading errors before they happen. > >> Find and fix more than 250 security defects in the development cycle. > >> Locate bottlenecks in serial and parallel code that limit performance. > >> http://p.sf.net/sfu/intel-dev2devfeb > >> _______________________________________________ > >> gnuplot-info mailing list > >> gnu...@li... > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> > > > ------------------------------------------------------------------------------ > > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > > Pinpoint memory and threading errors before they happen. > > Find and fix more than 250 security defects in the development cycle. > > Locate bottlenecks in serial and parallel code that limit performance. > > http://p.sf.net/sfu/intel-dev2devfeb > > _______________________________________________ > > gnuplot-info mailing list > > gnu...@li... > > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > > > > > -- > View this message in context: > http://old.nabble.com/explanation-to-a-short-script-tp30924408p30934168.html > Sent from the Gnuplot - User mailing list archive at Nabble.com. > > > > ------------------------------------------------------------------------------ > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > Pinpoint memory and threading errors before they happen. > Find and fix more than 250 security defects in the development cycle. > Locate bottlenecks in serial and parallel code that limit performance. > http://p.sf.net/sfu/intel-dev2devfeb > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > |
|
From: Tait <gnu...@t4...> - 2011-02-15 23:29:38
|
(Sorry this was delayed; I accidentally sent from the wrong address and it was rejected by the moderator. But having already written it, it seemed a shame not to send it.) > set term dumb > min=10**10 > plot 'disy.100' u ($3<min?min=$3:min=min,$1):3 > > set term x11 > plot 'disy.100' u 1:($3/min) > > and you easily see the idea I wrote it this way. I think this reflects a big > problem for me to understand deeply how gnuplot deals with datafile and how > it plots, which is obviously different from the standard programming > languages. Thanks for your in-depth explanation or references, First, are you familiar with C? The syntax is similar, and it is described in "help ternary". The ternary operator: (condition) ? true-expr : false-expr is a single-line if/then/else construct. If condition is true, then true-expr is evaluated. Otherwise, false-expr is evaluated instead. So consider: $3<min ? min=$3 : min=min If the third column is less than the value of the variable min, then assign this new value to min. Otherwise do a non-operation (of setting min equal to itself). The "plot... using ($3<min?min=$3:min=min,$1):3" means plot the third column as the y-coordinate, against the stuff in parenthesis as the x-coordinate. In recent gnuplot versions, multiple expressions can be evaluated for each line of the input file, by separating them with a comma. The stuff in parenthesis finds the minimum value of column 3 (and saves in it variable min), then evaluates $1, which just means the value of column 1. The first plot is output as text in the console, so you might not have seen it. It doesn't matter, because it's just a throwaway plot used to find the minimum value of column 3 anyway. The second plot is the one that matters. It plots your data file using 1:($3/min) which means plot column 3 divided* by min versus column 1. Another approach to this problem would be to use an external program/script to find the minimum value of column three. I often use Perl for these tasks. Others use sed/awk/shell scripts. We should probably develop some C programs for contrib to do common tasks like this. For example: filename="disy.100" c3min = `min_value_by_col.pl filename 3` set term X11 plot filename using 1:(($3+0.0)/c3min) * The division here is possibly integer division, depending on the values from column 3 of 'disy.100'. If you want to assure floating-point results from the division, you should instead: plot 'disy.100' using 1:((0.0+$3)/min) or something similar. Adding 0.0 will force promotion of $3 to a float type, which will in turn force the division to be a floating-point operation. |
|
From: Jon <dev...@gm...> - 2011-02-16 00:41:42
|
Dear Tait, I guess the script you analyzed is what I wrote, but not by Nunzio Losacco. His code is a bit complex than mine. What I am asking is basically the concept of one pass or two passes possibly used by gnuplot, similar concept relevant to SAS or database languages. Sincerely, Jon On Tue, Feb 15, 2011 at 5:29 PM, Tait <gnu...@t4...> wrote: > > (Sorry this was delayed; I accidentally sent from the wrong address > and it was rejected by the moderator. But having already written it, > it seemed a shame not to send it.) > > > set term dumb > > min=10**10 > > plot 'disy.100' u ($3<min?min=$3:min=min,$1):3 > > > > set term x11 > > plot 'disy.100' u 1:($3/min) > > > > and you easily see the idea I wrote it this way. I think this reflects a > big > > problem for me to understand deeply how gnuplot deals with datafile and > how > > it plots, which is obviously different from the standard programming > > languages. Thanks for your in-depth explanation or references, > > > First, are you familiar with C? The syntax is similar, and it is described > in "help ternary". The ternary operator: > (condition) ? true-expr : false-expr > is a single-line if/then/else construct. If condition is true, then > true-expr is evaluated. Otherwise, false-expr is evaluated instead. So > consider: > $3<min ? min=$3 : min=min > If the third column is less than the value of the variable min, then > assign this new value to min. Otherwise do a non-operation (of setting > min equal to itself). > > The "plot... using ($3<min?min=$3:min=min,$1):3" means plot the third > column as the y-coordinate, against the stuff in parenthesis as the > x-coordinate. In recent gnuplot versions, multiple expressions can > be evaluated for each line of the input file, by separating them with > a comma. The stuff in parenthesis finds the minimum value of column 3 > (and saves in it variable min), then evaluates $1, which just means the > value of column 1. > > The first plot is output as text in the console, so you might not have > seen it. It doesn't matter, because it's just a throwaway plot used to > find the minimum value of column 3 anyway. > > The second plot is the one that matters. It plots your data file using > 1:($3/min) which means plot column 3 divided* by min versus column 1. > > Another approach to this problem would be to use an external program/script > to find the minimum value of column three. I often use Perl for these > tasks. Others use sed/awk/shell scripts. We should probably develop some > C programs for contrib to do common tasks like this. For example: > filename="disy.100" > c3min = `min_value_by_col.pl filename 3` > set term X11 > plot filename using 1:(($3+0.0)/c3min) > > > > > * The division here is possibly integer division, depending on the values > from column 3 of 'disy.100'. If you want to assure floating-point results > from the division, you should instead: > plot 'disy.100' using 1:((0.0+$3)/min) > or something similar. Adding 0.0 will force promotion of $3 to a float > type, which will in turn force the division to be a floating-point > operation. > > > > ------------------------------------------------------------------------------ > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > Pinpoint memory and threading errors before they happen. > Find and fix more than 250 security defects in the development cycle. > Locate bottlenecks in serial and parallel code that limit performance. > http://p.sf.net/sfu/intel-dev2devfeb > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > |