bugGNU Octave - Bugs: bug #31671, betapdf fails for large parameter...

 
 

bug #31671: betapdf fails for large parameter values

Submitted by:  Christos Dimitrakakis <olethros>
Submitted on:  Tue 16 Nov 2010 12:06:23 PM UTC  
 
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Christos DimitrakakisOpen/Closed: Closed
Release: 3.2.3Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 18 Nov 2010 07:42:10 PM UTC, comment #1:

I checked in the changeset you submitted to the patch tracker.

John W. Eaton <jwe>
Project Administrator
Tue 16 Nov 2010 12:06:23 PM UTC, original submission:

Example failure:

octave-3.2.3:6> betapdf(0.5, 1000,1000)
warning: division by zero
ans = NaN

this is due to a naive implementation of this function and prohibits the use of betapdf for Bayesian statistics. Here is a version which works for all values:

function p=betapdf(x, alpha, beta)
z = lgamma(alpha + beta) - lgamma(alpha) - lgamma(beta);
ya = log(x) .* (alpha - 1);
ya(x==0) = 0;
yb = log(1 - x) .* (beta - 1);
p = exp(z + ya + yb);
p(x==0) = 0;
p(x==1) = 0;
endfunction

Example success:
octave-3.2.3:10> betapdf(0.5, 1000,1000)
ans = 35.678

Christos Dimitrakakis <olethros>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by olethros (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 18 Nov 2010 07:42:10 PM UTCjweStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1