Skip to content

too large alpha or beta in dbeta ? (PR#643)

4 messages · Martin Maechler, Duncan Murdoch

#

        
TL> On Thu, 24 Aug 2000, Troels Ring wrote:
>> Dear friends.
    >> 
    >> Is this as expected ? Is alpha and beta too large simply ?
    >> 
    >> > dbeta(.1,534,646)
    >> [1] NaN
    >> Warning message:
    >> NaNs produced in: dbeta(x, shape1, shape2, log)

    TL> well, it should work, but the correct answer is effectively zero.
    TL> pbeta(.1,534,646) gives 3.6e-213

    TL> Perhaps more worrying is 
    >> dbeta(.25,534,646)
    TL> [1] Inf
yes.
and I see that it is one case where the log-density seems to be alright:
[1] -109.939612

and also for the NaN case :
[1] -480.725168

A workaround is  using   exp( log-density  ), i.e.

  exp(dbeta(x,a,b, log = TRUE)) :

Look at
or
--
I'll have a look.

Martin


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Fri, 25 Aug 2000 15:20:10 +0200 (MET DST), Martin Maechler wrote in
message <200008251320.PAA05152@pubhealth.ku.dk>:
I never knew that plot could take a function!  

Could I make some suggestions?

1.  It should be mentioned more prominently in the documentation.
Since functions aren't a class, I scanned over the list of plot
methods without ever noticing that functions were mentioned there.
I'd suggest modifying the description of parameter x to read:

 x: the coordinates of points in the plot. Alternatively, a
single plotting structure, function or R object with a `plot' method
can be provided.


2.  If xlim is specified and from and to aren't, the from and to
values should default to xlim[1] and xlim[2], not 0 and 1.  

3.  The help for plot.function says:

"This used to be a quick hack which seems to serve a useful
purpose, but can give bad results for functions which are not
smooth."

That doesn't read right:  it makes me ask, "If it used to be a quick
hack, what is it now?"  I'd suggest:

"This function was a quick hack which seems to serve a useful
purpose, but it can give bad results for functions which are not
smooth."


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Duncan> On Fri, 25 Aug 2000 15:20:10 +0200 (MET DST), Martin Maechler wrote in
    Duncan> message <200008251320.PAA05152@pubhealth.ku.dk>:

    >> Look at
    >> 
    >>> plot(function(x)    dbeta(x, 534,646, log = TRUE), n = 1001)

    Duncan> I never knew that plot could take a function!  
well..

    Duncan> Could I make some suggestions?
sure... no promisses though ;-)

    Duncan> 1.  It should be mentioned more prominently in the documentation.
    Duncan> Since functions aren't a class, I scanned over the list of plot
    Duncan> methods without ever noticing that functions were mentioned there.
    Duncan> I'd suggest modifying the description of parameter x to read:

    Duncan> x: the coordinates of points in the plot. Alternatively, a
    Duncan> single plotting structure, function or R object with a `plot' method
    Duncan> can be provided.

ok, done, thank you.
    Duncan> 2.  If xlim is specified and from and to aren't, the from and to
    Duncan> values should default to xlim[1] and xlim[2], not 0 and 1.  

good idea,
and easy to implement...  
I would have it as

  \item{xlim}{numeric of length 2; if specified, it replaces \code{from}
              and \code{to}.}

(and not give a warning if someone uses  xlim  *and* e.g. `from').

    Duncan> 3.  The help for plot.function says:

    Duncan> "This used to be a quick hack which seems to serve a useful
    Duncan> purpose, but can give bad results for functions which are not
    Duncan> smooth."

    Duncan> That doesn't read right:  it makes me ask, "If it used to be a quick
    Duncan> hack, what is it now?"  I'd suggest:
yes..
    Duncan> "This function was a quick hack which seems to serve a useful
    Duncan> purpose, but it can give bad results for functions which are not
    Duncan> smooth."

"This" was now really implying  both  curve()  and plot.function()  ...

Could I just add one word, "now", to make it
--
Thank you,
Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Fri, 25 Aug 2000 18:57:50 +0200 (CEST), you wrote in message
<14758.42382.735308.898057@gargle.gargle.HOWL>:
Hmmm, I can see that someone might want both, and have them take
inconsistent values.  Then from and to should control the range of
values graphed, and xlim should control the plotting box.

For example,

  plot(function(x) x^2, xlim=c(-1,1), from=0, to=1)

should do what it does now, i.e. have the x-axis run from -1 to 1, but
only positive x values are graphed.

Duncan Murdoch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._