Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a function that looks like this:

likelihood[x_] = -Log[1/24*E^(-8*x)*x^11]

However, when plotting this using

Plot[likelihood[x],{x,0,8}]

Mathematica returns a weird-fuzzy plot. On the other hand, when I use this command

Plot[-Log[1/24*Exp[-8*x]*x^(11)], {x, 0, 8}]

Everythings works out fine. I'm using Mathematica 8 on Ubuntu 12.04. Where's the problem?

fuzzy plot in Mathematica

share|improve this question
Copying and pasting your updated code as it is now with the underscore works fine for me. v8 on Windows xP. No fuzziness, just a nice smooth curve identical to the explicit function. Try quitting your kernel and trying it again. You might have an old definition of likelihood still in memory. In particular look for an older version with a := definition – fizzics Dec 19 '12 at 10:45
same applies to macosx and v8 or 9 – chris Dec 19 '12 at 10:52
Okay I found the error by myself: I used a list to generate the likelihood-function. List elements have been chosen by RandomInteger. – Vincent Dec 19 '12 at 11:28
3  
Seems to me that this should be closed. – David Skulsky Dec 19 '12 at 12:59

closed as too localized by István Zachar, Yves Klett, chris, rm -rf Dec 19 '12 at 15:10

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

You forgot to use pattern matching on the LHS. This...

likelihood[x_] = -Log[1/24*E^(-8*x)*x^11]; (* use x_ in the LHS not x *)
Plot[likelihood[x], {x, 0, 8}]

works fine. I leaved the explicit * you put, although they are not necessary either: use white space for implicit multiplication (as in normal mathematical writing.)

share|improve this answer
whoups I'm sorry, I forgot the underscore for pattern matching, but it's actually in my notebook. Nevertheless, the problem remains… – Vincent Dec 19 '12 at 10:41
what do you mean "the problem remains"? with a proper pattern in the LHS it works for me... I also use version 8, although on Mac. – caya Dec 19 '12 at 10:47
I still get the fuzzy plot as displayed above… – Vincent Dec 19 '12 at 11:03
Maybe you should do ?likelihood and see what Mathematica currently has for it. But even with the two x and x_ definitions in there, Plot works. – caya Dec 19 '12 at 11:09
nice hint, thanks, but actually the notebook is for demonstration purposes… – Vincent Dec 19 '12 at 11:10
show 2 more comments

Not the answer you're looking for? Browse other questions tagged or ask your own question.