Re: Option for continuous plot
- To: mathgroup at smc.vnet.net
- Subject: [mg72934] Re: [mg72890] Option for continuous plot
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 25 Jan 2007 07:51:38 -0500 (EST)
- Reply-to: hanlonr at cox.net
Needs["Utilities`FilterOptions`"];
poissonProcess[a_, n_] :=
FoldList[Plus, 0, Table[-1/a Log[1-Random[]],{n}]];
Options[showPoissonProcess] = {JoinLines->False};
showPoissonProcess[a_, n_, opts___] :=
Module[{pp=poissonProcess[a,n], lin},
lin = Table[Line[{{pp[[i]], i-1}, {pp[[i+1]], i-1}}], {i, 1, n}];
If[JoinLines /. {opts} /. Options[showPoissonProcess],
lin=(lin //. {s___, Line[x__], Line[y__], f___}:>
{s, Line[Join[x, y]], f}),];
Show[Graphics[{AbsoluteThickness[1.5], lin}],
Axes->True, FilterOptions[Plot, opts]]];
SeedRandom[1];
showPoissonProcess[4, 20, AspectRatio -> 0.3, ImageSize -> 500];
SeedRandom[1];
showPoissonProcess[4, 20, AspectRatio -> 0.3, ImageSize -> 500,
JoinLines -> True];
Bob Hanlon
---- Virgil Stokes <vs at it.uu.se> wrote:
> I have defined the following two functions:
>
> poissonProcess[�»_,n_] := FoldList[Plus,0,Table[-1/�» Log[1-Random[]],{n}]]
>
> showPoissonProcess[�»_,n_,opts___] := With[{pp = poissonProcess[�»,n]},
> Show[Graphics[{AbsoluteThickness[1.5],Table[Line[{{pp[[i]],i-1},{pp[[i+1]],i-1}}],{i,1,n}]}],
> Axes\[Rule]True,opts]];
>
> for plotting a Poisson process; i.e.,
>
> SeedRandom[1];
> showPoissonProcess[4, 20, AspectRatio -> 0.3];
>
> does indeed plot this process. However, I would like to have an option
> that would allow for these horizontal lines to be connected; i.e.,
> produce a continuous curve.
>
> Is there a easy way to do this?
>
> Thanks,
> V. Stokes
>
- Follow-Ups:
- Re: Re: Option for continuous plot
- From: Virgil Stokes <vs@it.uu.se>
- Re: Re: Option for continuous plot