How do I define a function from scratch that emulates DiscreteUniformDistribution
?
As shown below, attempting to use ProbabilityDistribution
does not preserve the condition that the distribution should be unique.
unif = DiscreteUniformDistribution[{0, 1}];
mine = ProbabilityDistribution[1/2, {x, 0, 1, 1}];
PDF[unif, 0.5]
PDF[mine, 0.5]
Out[65]= 0
Out[66]= 1/2
I suppose my real question is how do I enforce the condition that x should be discrete while using ProbabilityDistribution
?
By the way, I originally asked this on stackoverflow.
Update: After going back and forth between Wolfram support, this is their official response:
"I have consulted with our developers and this function is working as designed. There is no reason for evaluating a discrete distribution with non-integer values. The program recognizes the distribution as discrete and properly calculates such things as mean a variance. If you us the built-in functions rather than defining your own you will get the behavior you want. To fully implement the suggestions you have made would significantly impact the performance of the program both in memory usage and in speed. The function is working as designed and this case is closed."
EmpiricalDistribution@Range[0, 1]
$\endgroup$