"set samples" with two lines

View: New views
3 Messages — Rating Filter:   Alert me  

"set samples" with two lines

by Allin Cottrell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: "set samples" with two lines

by Lutz Maibaum-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Nov 1, 2009 at 8:42 AM, Allin Cottrell <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

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: "set samples" with two lines

by Allin Cottrell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sun, 1 Nov 2009, Lutz Maibaum wrote:

> On Sun, Nov 1, 2009 at 8:42 AM, Allin Cottrell <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

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta