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

I want to plot the histogram and pdf of 2 X - 100 with X a binomial distribution, but I'm having trouble with the pdf -- I just get a line y = 0. I tried ploting a simple binomial distribution, but I don't get anything with that either and it takes so much time.

Li[n_] := 2*RandomVariate[BinomialDistribution[n, 1/2], n] - n;
Tb[n_, m_] := Table[Li[n], {i, 1, m}];
y = Tb[100, 1000];
 Histogram[y, 40, "PDF"], 
 Plot[PDF[2*BinomialDistribution[100, 1/2] - 100, x], {x, -10, 10}, 
   PlotStyle -> Thick]]
share|improve this question

closed as off-topic by Bob Hanlon, Kuba, MarcoB, blochwave, Öskå Oct 11 at 13:16

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." – Bob Hanlon, Kuba, MarcoB, blochwave, Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

That's (among other things) because giving ...2*BinomialDistribution[100, 1/2]-100... as the argument to PDF is nonsense. I suggest you avail yourself of the documentation to understand how to properly utilize the probability functions. – ciao Oct 9 at 8:15

1 Answer 1

up vote 3 down vote accepted

As commented, you're not using the functions properly. I think what you're after is:

DiscretePlot[PDF[TransformedDistribution[2*z - 100, 
                 z \[Distributed] BinomialDistribution[100, 1/2]], x], {x, -10, 10}]

enter image description here

Note the use of DiscretePlot - the binomial is a discrete distribution, so a discrete plot is appropriate. You can cajole things to use Plot, but that's goofy IMO...

share|improve this answer
@ciao...the quick or the dead...just deleting my response :) – ubpdqn Oct 9 at 8:21
@ubpdqn: Lol, once again, you cause me to spit-laugh my tea onto my netbook. Cleaning now.... – ciao Oct 9 at 8:23
"…but that's goofy…" - Hyuck! :) – J. M. Oct 9 at 9:31

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