0
$\begingroup$

My question is :

Suppose that the PDF of a random variable X is as follows: \begin{equation*} f(x) = \begin{cases} ce^{-2x} & \text {$x > 0$}\\ 0 & \text {otherwise}\\ \end{cases} \end{equation*} (a) Find the value of the constant c and sketch the PDF.

I am able to calculate value of c = 2. But when I try to plot PDF on mathematica using below code, it throws me below error.

{xlow, xhigh} = {0, Infinity}; 
Clear[pdf, x, t]; 
pdf[x_] := 2 e^(-2x)
pdfplot = Plot[pdf[x], {x, xlow, xhigh}, 
  PlotStyle -> {{Thickness[0.01], Purple}}, 
  AxesLabel -> {"x", "pdf[x]"}, AspectRatio - > 1/GoldenRatio]

Error:

Plot::plln: Limiting value Infinity in {x, xlow, xhigh} is not a machine-sized real number.   Plot::plln: Limiting value Infinity in {x, xlow, xhigh} is not a machine-sized real number.   Plot::plln:Limiting value Infinity in {x, xlow, xhigh} is not a machine-sized real number.
$\endgroup$

closed as off-topic by Jens, bbgodfrey, Sjoerd C. de Vries, Dr. belisarius, m_goldberg Feb 4 '15 at 0:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Jens, bbgodfrey, Sjoerd C. de Vries, Dr. belisarius, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – bbgodfrey Feb 3 '15 at 16:07
  • 1
    $\begingroup$ Euler's number is written with a capital E in mathematica, or as esc-ee-esc. $\endgroup$ – Sjoerd C. de Vries Feb 3 '15 at 19:53
1
$\begingroup$

Use E rather than e

{xlow, xhigh} = {0, Infinity};
Clear[pdf, x, t];
pdf[x_] := 2 E^(-2 x)

You can use xhigh (i.e., Infinity) in a function like Integrate

Integrate[pdf[x], {x, xlow, xhigh}]

1

However, a Plot must be on a finite domain

Plot[pdf[x], {x, xlow, 6}, PlotStyle -> {{Thickness[0.01], Purple}}, 
 AxesLabel -> {"x", "pdf[x]"}, AspectRatio -> 1/GoldenRatio]

enter image description here

$\endgroup$
  • $\begingroup$ My graph is not touching on Y axis with your code. How do you mention the X/Y axis steps in between the plotted points of 0.5, 1.0, 1.5, 2.0 etc $\endgroup$ – mike99999 Feb 3 '15 at 16:47
  • $\begingroup$ See the documentation on Ticks to specify tick number, subdivisions, styling, and so on. $\endgroup$ – David G. Stork Feb 3 '15 at 17:19

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