Hi All, I recently discovered an interesting issue with the punif() function. Let X~Uiform[a,b] then the CDF is defined by F(x)=(x-a)/(b-a) for (a<= x<= b). The important fact here is the domain of the random variable X. Having said that, R returns CDF for any value in the real domain. I understand that one can justify this by extending the domain of X and assigning zero probabilities to the values outside the domain. However, theoretically, it is not true to return a value for the CDF outside the domain. Then I propose a patch to R function punif() to return an error in this situations. Example:> punif(10^10)[1] 1 Regards, Hamed. [[alternative HTML version deleted]]
Hi Hamed,
I disagree with your criticism.
For a random variable X
X: D - - - > R
its CDF F is defined by
F: R - - - > [0,1]
F(z) = Prob(X <= z)
The fact that you wrote a convenient formula for the CDF
F(z) = (z-a)/(b-a) a <= z <= b
in a particular range for z is your decision, and as you noted this formula
will give the wrong value for z outside the interval [a,b].
But the problem lies in your formula, not the definition of the CDF which
would be, in your case:
F(z) = 0 if z <= a
= (z-a)/(b-a) if a <= z <= b
= 1 if 1 <= z
HTH,
Eric
On Tue, Oct 23, 2018 at 12:05 PM Hamed Ha <hamedhaseli at gmail.com>
wrote:
> Hi All,
>
> I recently discovered an interesting issue with the punif() function. Let
> X~Uiform[a,b] then the CDF is defined by F(x)=(x-a)/(b-a) for (a<=
x<= b).
> The important fact here is the domain of the random variable X. Having said
> that, R returns CDF for any value in the real domain.
>
> I understand that one can justify this by extending the domain of X and
> assigning zero probabilities to the values outside the domain. However,
> theoretically, it is not true to return a value for the CDF outside the
> domain. Then I propose a patch to R function punif() to return an error in
> this situations.
>
> Example:
> > punif(10^10)
> [1] 1
>
>
> Regards,
> Hamed.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
Hi Eric, Thank you for your reply. I should say that your justification makes sense to me. However, I am in doubt that CDF defines by the Pr(x <= X) for all X? that is the domain of RV is totally ignored in the definition. It makes a conflict between the formula and the theoretical definition. Please see page 115 in https://books.google.co.uk/books?id=FEE8D1tRl30C&printsec=frontcover&dq=statistical+distribution&hl=en&sa=X&ved=0ahUKEwjp3PGZmJzeAhUQqxoKHV7OBJgQ6AEIKTAA#v=onepage&q=uniform&f=false The Thanks. Hamed. On Tue, 23 Oct 2018 at 10:21, Eric Berger <ericjberger at gmail.com> wrote:> Hi Hamed, > I disagree with your criticism. > For a random variable X > X: D - - - > R > its CDF F is defined by > F: R - - - > [0,1] > F(z) = Prob(X <= z) > > The fact that you wrote a convenient formula for the CDF > F(z) = (z-a)/(b-a) a <= z <= b > in a particular range for z is your decision, and as you noted this > formula will give the wrong value for z outside the interval [a,b]. > But the problem lies in your formula, not the definition of the CDF which > would be, in your case: > > F(z) = 0 if z <= a > = (z-a)/(b-a) if a <= z <= b > = 1 if 1 <= z > > HTH, > Eric > > > > > On Tue, Oct 23, 2018 at 12:05 PM Hamed Ha <hamedhaseli at gmail.com> wrote: > >> Hi All, >> >> I recently discovered an interesting issue with the punif() function. Let >> X~Uiform[a,b] then the CDF is defined by F(x)=(x-a)/(b-a) for (a<= x<= b). >> The important fact here is the domain of the random variable X. Having >> said >> that, R returns CDF for any value in the real domain. >> >> I understand that one can justify this by extending the domain of X and >> assigning zero probabilities to the values outside the domain. However, >> theoretically, it is not true to return a value for the CDF outside the >> domain. Then I propose a patch to R function punif() to return an error in >> this situations. >> >> Example: >> > punif(10^10) >> [1] 1 >> >> >> Regards, >> Hamed. >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >[[alternative HTML version deleted]]