cas/xcas implementation of Geometric PDF - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: cas/xcas implementation of Geometric PDF (/thread-16906.html) cas/xcas implementation of Geometric PDF - Wes Loewer - 05-09-2021 06:40 PM I've been wondering about the Geometric PDF/CDF/ICDF functions on the Prime. The syntax for the PDF is: GEOMETRIC(p,k) which gives the probability of the first success occurring on the kth trial, ie, (1-p)^(k-1) * p On other implementations that I have seen, the Geometric PDF is a discrete PDF, requiring k to be a natural number. While the xcas help screen indicates that k is an integer, both xcas and Prime cas allow k to have any positive decimal value. In essence, this makes Geometric a continuous distribution. My question is whether this was intentional? And if so, what would be an example application of using the Geometry PDF in such a continuous manner? Does a continuous Geometric PDF have a physical meaning? The CDF version likewise allows decimals for k, applied to the usual 1-(1-p)^k. One side-effect of this is that the behavior differs from other continuous pdf's in that the cdf is no longer the area under the pdf curve. chisquare_cdf(12,10) = ∫(chisquare(12,x),x,0,10) but GEOMETRIC_CDF(0.3,4) ≠ ∫(GEOMETRIC(0.3,x),x,0,4) From this it would seem that the Geometric CDF/PDF's are really intended to be discrete. Usually on discrete inverse functions, the returned value can only be a whole number, but no such rounding is done with GEOMETRIC_ICDF(), like a continuous function. So the implementation has characteristics of both discrete and continuous pdf's. Maybe someone can shed some light on this. RE: cas/xcas implementation of Geometric PDF - parisse - 05-10-2021 06:23 PM Code: ```   // geometric_cdf(p,k)=1-(1-p)^k ...   // k=geometric_icdf(p,P) if 1-(1-p)^k>=P hence    gen geometric_icdf(const gen & p,const gen & P,GIAC_CONTEXT){     return _ceil(ln(1-P,contextptr)/ln(1-p,contextptr),contextptr);   }``` There is no check on k being an integer for geometric_cdf since it's not necessary to compute the expression. RE: cas/xcas implementation of Geometric PDF - Wes Loewer - 05-12-2021 06:37 PM (05-10-2021 06:23 PM)parisse Wrote:  There is no check on k being an integer for geometric_cdf since it's not necessary to compute the expression. I take it that for the binomial and poisson cdf functions that this check is necessary, although I suppose at least the pdf versions could be calculated for non-integers using gamma functions for the factorials. Do your cdf implementations of binomial and poisson use a discrete summation, or something more sophisticated? Still, it seems like for consistency and to avoid user error, it would be better to restrict the values to integers. Same for the return value of GEOMETRIC_ICDF(). Are there ever any situations where a non-integer is useful here? In any case, the new Probability Wizard is treating the Geometric distribution as if it were continuous which produces some incorrect results. I'll file a report on that.