MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Weird Plot problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59842] Re: [mg59789] Re: Weird Plot problem
  • From: "Owen, HL \(Hywel\)" <h.l.owen at dl.ac.uk>
  • Date: Tue, 23 Aug 2005 05:17:07 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com
  • Thread-index: AcWmMKNifSBlBe8kSnerpJF7ylDQegBkaYbQ

> -----Original Message-----
> From: Bill Rowe [mailto:readnewsciv at earthlink.net] 
To: mathgroup at smc.vnet.net
> Sent: 21 August 2005 08:52
> Subject: [mg59842] [mg59789] Re: Weird Plot problem
> 
> On 8/20/05 at 3:13 AM, h.l.owen at dl.ac.uk (Owen, HL (Hywel)) wrote:
> 
> >I'm seeing a weird plot problem. For reference, I'm using 
> Mathematica 
> >5.2 on Windows XP.
> 
> >First, using the package
> 
> ><< Statistics`ContinuousDistributions`
> 
> >I define a Gaussian function modulated with a Sin[] as:
> 
> >ModulatedGaussian[x_, ��_, ��_, modamp_, mod�Ž_] := 
> >PDF[NormalDistribution[��, ��],x](1 + modamp Sin[2  x/mod�Ž])
> 
> I was able to figure out what you are trying to do here, but 
> it would have been much easier had you posted this in Input form.

Yes, sorry! I forgot I left in the Greek symbols.... :(

> >I then Plot it using:
> 
> >Plot[ModulatedGaussian[x, 0.0, 1.0, 0.3, 0.2], {x, -5, 5}]
> 
> >Instead of seeing the modulation properly, I see the plot available
> >at: http://www.astec.ac.uk/staff/owen/pictures/graph.png
> 
> >Plot[ModulatedGaussian[x, 0.0, 1.0, 0.31, 0.2], {x, -5, 5}] and 
> >Plot[ModulatedGaussian[x, 0.0, 1.0, 0.29, 0.2], {x, -5, 5}] 
> (changing 
> >the modulation amplitude) both work fine. Generating the data also 
> >works:
> 
> >ListPlot[Table[{x,ModulatedGaussian[x, 0, 1, 0.3, 0.2]}, {x, -5, 5, 
> >0.01}], PlotJoined -> True]
> 
> >Anyone else get the same behaviour? Is it a bug?
> 
> It isn't a bug per se. The issue is the adaptive sampling 
> algorithm Mathematica uses. For any rapidly oscillating 
...
> 
> The simplest solution is to increase the number of points 
> where Mathematica samples the function to be plotted, i.e., 
> using PlotPoints->n where n is something larger than the 
> default. But this is not the only solution. Any change in the 
> plot parameters that causes Mathematica to sample at 
> different points can potentially solve the problem. And if 
> the function is time consuming to evaluate, it *may* be 
> preferable to do something other than simply increase the 
> value for PlotPoints. For example, changing {x,-5, 5} to {x, 
> -5.01, 5.01} will cause Mathematica to sample the function at 
> different points and likely will resolve the issue.
...

Yes, that was my fix too. The thing that confused me was that part of the plot looked fine whilst only one section had gone haywire. I think I'll stick to ListPlot!

Cheers,

Hywel
 


  • Prev by Date: Manipulating the results of Maximize
  • Next by Date: Re: How to free memory?
  • Previous by thread: Re: Weird Plot problem
  • Next by thread: Re: Weird Plot problem