## gnuplot-beta

 "set samples" with two lines From: Allin Cottrell - 2009-11-01 16:42:48 ```I'd be much obliged if anyone has a clever suggestion for solving this problem: I'd like to plot two probability distribution curves together (in a 2D graph), one a continuous pdf (e.g. Gaussian) and the other discrete (e.g. Poisson or binomial). I can get a nice plot of each, separately, by setting a high "samples" value for the continuous distribution and an appropriate low value, corresponding to the number of integer values in the x- or t-range, for the discrete one. But in a 2D plot there's only one "samples" setting available. I realize that instead of using a formula (as in the continuous case), I could pre-compute a set of "data points" for the discrete distribution and treat it as one would empirical data, but that's not very convenient in context. (I'd like to be able to do this programmatically, for many sets of distributions with various parameters, so a formula-based solution is desirable.) It would be nice if one could attach a "samples" parameter to a line style specification, as in set style line 1 samples 200 ... set style line 2 samples 16 ... but maybe I'm missing something that makes that unnecessary? -- Allin Cottrell Department of Economics Wake Forest University ```
 Re: "set samples" with two lines From: Lutz Maibaum - 2009-11-01 17:07:59 ```On Sun, Nov 1, 2009 at 8:42 AM, Allin Cottrell wrote: > I'd like to plot two probability distribution curves together (in > a 2D graph), one a continuous pdf (e.g. Gaussian) and the other > discrete (e.g. Poisson or binomial). > > I can get a nice plot of each, separately, by setting a high > "samples" value for the continuous distribution and an appropriate > low value, corresponding to the number of integer values in the x- > or t-range, for the discrete one. But in a 2D plot there's only > one "samples" setting available. Maybe you could downsample inside the evaluation of the discrete function, something like this: rnd(x)=int(x+0.5) f(x)=exp(-x) g(x)=f(rnd(x)) plot [0:5] f(x), g(x) Hope this helps, Lutz ```
 Re: "set samples" with two lines From: Allin Cottrell - 2009-11-01 17:27:38 ```On Sun, 1 Nov 2009, Lutz Maibaum wrote: > On Sun, Nov 1, 2009 at 8:42 AM, Allin Cottrell wrote: > > I'd like to plot two probability distribution curves together (in > > a 2D graph), one a continuous pdf (e.g. Gaussian) and the other > > discrete (e.g. Poisson or binomial). > > > > I can get a nice plot of each, separately, by setting a high > > "samples" value for the continuous distribution and an appropriate > > low value, corresponding to the number of integer values in the x- > > or t-range, for the discrete one. But in a 2D plot there's only > > one "samples" setting available. > > Maybe you could downsample inside the evaluation of the discrete > function, something like this: > > rnd(x)=int(x+0.5) > f(x)=exp(-x) > g(x)=f(rnd(x)) > plot [0:5] f(x), g(x) > > Hope this helps, Indeed, that's the solution. Thanks! Allin Cottrell ```