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

 
 

bug #31671: betapdf fails for large parameter values

Submitter:  Christos Dimitrakakis <olethros>
Submitted:  Tue 16 Nov 2010 12:06:23 PM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Christos Dimitrakakis Open/Closed:  * Closed
Release:  * 3.2.3 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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 Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-11-18 jwe StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code