 # GammaFunction in core is not good enough for proximity

## Details

• Type: Bug
• Status: Resolved
• Priority: Major
• Resolution: Fixed
• Affects Version/s: 3.0
• Fix Version/s:
• Component/s: None
• Labels:
None

## Description

After TREC-131, we are using the WikipediaGammaFunction. This is insufficient (IIRC, it doesnt handle non-integer input). We need to find a better one before releasing 3.1.

## Activity

I verified that DFR proximity now behaves properly. Well done Rodrygo for reworking the Wikipedia implementation.

Show Craig Macdonald added a comment - I verified that DFR proximity now behaves properly. Well done Rodrygo for reworking the Wikipedia implementation.

Here is a class I used while debugging the Gamma Function

```    static class DebuggingGammaFunction extends GammaFunction
{
GammaFunction parent;
DebuggingGammaFunction(GammaFunction p)
{
parent = p;
}

@Override
public double compute(double number) {
double rtr = parent.compute(number);
System.err.println("compute("+number +")="+rtr);
return rtr;
}

@Override
public double compute_log(double number) {
double rtr = parent.compute_log(number);
System.err.println("compute_log("+number +")="+rtr);
return rtr;
}

}
```
Show Craig Macdonald added a comment - Here is a class I used while debugging the Gamma Function static class DebuggingGammaFunction extends GammaFunction { GammaFunction parent; DebuggingGammaFunction(GammaFunction p) { parent = p; } @Override public double compute( double number) { double rtr = parent.compute(number); System .err.println( "compute(" +number + ")=" +rtr); return rtr; } @Override public double compute_log( double number) { double rtr = parent.compute_log(number); System .err.println( "compute_log(" +number + ")=" +rtr); return rtr; } }

Current implementation overflows for large input values. I have fixed it by replacing raw computations with log-based computations. Test cases for large input values have been added. The documentation was updated to reflect that all GammaFunction implementations assume a positive input value, so as to avoid the issue of logarithms of negative values.

Show Rodrygo L. T. Santos added a comment - Current implementation overflows for large input values. I have fixed it by replacing raw computations with log-based computations. Test cases for large input values have been added. The documentation was updated to reflect that all GammaFunction implementations assume a positive input value, so as to avoid the issue of logarithms of negative values.

## People

• Assignee: Rodrygo L. T. Santos
Reporter: Craig Macdonald
• Watchers:
0 Start watching this issue

## Dates

• Created:
Updated:
Resolved: