# Strange Plot result

When I plot this function

collisionProb[distA_, velA_, radA_, velP_, radP_] :=
With[{\[Sigma] = (velA * distA)/(2 * velP), l = radA + radP},
Probability[-l <= x <= l, x \[Distributed] NormalDistribution[0, \[Sigma]]]]


with the command

Plot[collisionProb[10, x, 0.2, 10, 0.1], {x, 0, 11}]


I get this...

which seems strange to me. For example,

collisionProb[10, 1, 0.2, 10, 0.1]


evaluates to 0.451494.

What's wrong with that plot command?

You have a collision of variables in that x is used two ways (as the variable in the probability function and as the iterator in the Plot). Variables in Mathematica are global. Plot using:
Plot[collisionProb[10, z, 0.2, 10, 0.1], {z, 0, 11}]

• The reason for this variable collision is the fact (stated under Details and Options in the documentation), that Plot treats x as a local variable, effectively using Block. Therefore the global x inside Probability becomes the same local x as the second argument of collisionProb. Commented Aug 7, 2015 at 23:01