However, when drawing the function in a histogram it has its maximum at around (x,y) = (20, 140), which is clearly wrong, as it should precisely be at (20, 892.83). I suspect that it has something to do with the fact that binomial is only defined for discrete values (which I did not know how to express in the function definition) and root does some sort of interpolation?!

How do I fix the plot?

EDIT: When I plot binomial individually (not together with a histogram using binomial->Draw(“same”) I get yet another peek value which is approximately off by a factor of 10. (see Image) binomial.pdf (14 KB)

Ok, that seems to fix some issues and makes sense! However it still does not look pretty and rather hackish (there is still some interpolation going and the graph goes through some intermediate point in the middle of nowhere for which it is not defined).

It would probably make sense to only plot the function at discrete values and then connect them with straight lines or display them as bars.

Is there root support to
a.) declare a function to be defined only at discrete values
b.) have special plotting commands for discrete functions?

Thanks for your help! But being fairly new with root I would appreciate it if you could take the time to respond to my questions and not only drop a line of code without any further explanation. This would certainly also make things easier for other persons having the same problem.

Hi,
Since the binomial is a discrete function, you want actually to be evaluate at the integer values.
It is important then that each bin has a bin width of 1, so in your case with a range [0,100], you need to have 100 points. But you need to fix the function definition for the other terms which are not in the binomial, as following

TF1 *binomial = new TF1("binomial", "[0]*TMath::Binomial([1], x) * ([2])^(int(x)) * (1-[2])^([1]-int(x))", 0., 100.);
binomial->SetParameter(0, 10000);
binomial->SetParameter(1, 2000);
binomial->SetParameter(2, 0.01);
binomial->SetNpx(100);
binomial->Draw("HIST"); // to draw it as an histogram

Or otherwise you make the function having been center corresponding to exact integers. This can be achieved for example by setting the range to [0.5,100.5]