0

I have plotted and manipulated the Von Mises Distribution as follows:
enter image description here
Then I want to change the function of the distribution a bit
enter image description here
Because I want its function be as:
$$p_{\psi}(\psi|\mu,\kappa)=\frac{e^{\kappa\cos (2(\psi-\mu))}}{\pi I_0(\kappa)}$$
not as:
$$p_{\psi}(\psi|\mu,\kappa)=\frac{e^{\kappa\cos (\psi-\mu)}}{2\pi I_0(\kappa)}$$
And I plot and manipulate the new function. But there's nothing plotted.
enter image description here


In another attempt, I tried to plot the function $f(x)=x^2+2x+1$, but again there's nothing plotted.
enter image description here

What's the problem?

Sepideh Abadpour
  • 967
  • 1
  • 9
  • 18
  • @dionys yes I did. After I saw your comment, I closed mathematica and reopened it. But there's nothing changed – Sepideh Abadpour Sep 15 '15 at 13:41
  • @dionys yes, it does. What does the function Module do? – Sepideh Abadpour Sep 15 '15 at 13:45
  • Why can't we draw the function $f(x)$ just with the Plot function? – Sepideh Abadpour Sep 15 '15 at 13:51
  • Notice that your p[x] and f[x] are still colored blue. This means they have not been given any definition. They will turn black when the definition has been given. Did you remember to execute the definition before attempting to plot it? Mathematica is designed to be used interactively: it will not re-evaluate a notebook in order from the beginning whenever you evaluate something within it. – Oleksandr R. Sep 15 '15 at 13:51
  • @OleksandrR. this picture shows that I have executed the definition before plotting. but about $f(x)=x^2+2x+1$ yes, you are right. I had forgotten to run the definition before plotting – Sepideh Abadpour Sep 15 '15 at 14:03
  • @dionys something said about my problem in one of its posts. But that's not totally about my problem. If you continue this way, I'll be blocked of asking questions. Remember when there's an answer added to my question, I'm not able to delete it any more and avoid being blocked of asking. Take it easy alittle. – Sepideh Abadpour Sep 15 '15 at 14:22
  • 1
    @sepideh Try not to take it personally. Most everyone here is genuinely trying to help. It shouldn't be a big deal if your question is marked as a duplicate. If the issue is really different, try to communicate that clearly by editing your question. Also, you will get more help if you learn to format your questions and code according to the conventions of this forum and diligently read through the WRI documentation before posting a question. – dionys Sep 15 '15 at 14:29
  • @dionys No not personally. I really like the dicipline of stackexchange. It is really a good way to avoid spam questions. But the problem is that mathematica is alarming me that you soon will be blocked of questioning – Sepideh Abadpour Sep 15 '15 at 14:33
  • 1
    @sepideh If the site warned you about being blocked, don't take it too seriously. (The post that link goes to explains why.) – C. E. Sep 15 '15 at 15:59

1 Answers1

3

It is a scoping issue. Include parameters as arguments to p so that the Manipulate controls are linked to the arguments.

p[x_, mu_, k_] = 2*PDF[VonMisesDistribution[2 mu, k], 2 x] // Simplify;

Manipulate[Plot[p[x, mu, k],
  {x, -Pi + mu, Pi + mu},
  PlotRange -> {{-3, 3}, {0, 2.5}}],
 {{mu, 0, μ}, -Pi/2, Pi/2, Appearance -> "Labeled"},
 {{k, 5, κ}, 0, 10, Appearance -> "Labeled"}]

enter image description here

EDIT: Your distribution can also be expressed as a transformed distribution of the VonMisesDistribution

dist = TransformedDistribution[x/2,
   x \[Distributed] VonMisesDistribution[2 mu, k]];

p[x, mu, k] == PDF[dist, x] // Simplify

(*  True  *)

Mean[dist]

(*  mu  *)
LCarvalho
  • 9,233
  • 4
  • 40
  • 96
Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • Thanks Problem is solved. But a question rises. Before your post I thought that my problem might be this. Not because of plotting but because after several lines of code, I have to integrate $p(x)$ for certain $\mu$ and $\kappa$ and so there should be a way to pass the value of these parameter to $P$ and then let $P$ pass them to PDF but I thought that way I will create a 3D function not 1D? – Sepideh Abadpour Sep 15 '15 at 14:11
  • In the first line of code , $=$ should be written as $:=$, right? Or am I wrong? – Sepideh Abadpour Sep 15 '15 at 21:20
  • @sepideh - Either will work in this application. I prefer = over := when either will work since it is more efficient (e.g., Simplify is only done once rather than for each call). – Bob Hanlon Sep 15 '15 at 23:29