Skip to content

Commit

Permalink
Fix fisher_f mode (#976)
Browse files Browse the repository at this point in the history
* Fix fisher_f mode 

The mode for F-distribution is defined when `df1 > 2` according to https://en.wikipedia.org/wiki/F-distribution. It is also reasonable since `df2 * (df1 - 2) / (df1 * (df2 + 2))` becomes zero or negative when `df1 <= 2`

Co-authored-by: Matt Borland <matt@mattborland.com>
  • Loading branch information
maitbayev and mborland authored Apr 14, 2023
1 parent 93448ac commit 109a814
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/boost/math/distributions/fisher_f.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ inline RealType mode(const fisher_f_distribution<RealType, Policy>& dist)
&& detail::check_df(
function, df2, &error_result, Policy()))
return error_result;
if(df2 <= 2)
if(df1 <= 2)
{
return policies::raise_domain_error<RealType>(
function, "Second degree of freedom was %1% but must be > 2 in order for the distribution to have a mode.", df2, Policy());
function, "First degree of freedom was %1% but must be > 2 in order for the distribution to have a mode.", df1, Policy());
}
return df2 * (df1 - 2) / (df1 * (df2 + 2));
}
Expand Down

0 comments on commit 109a814

Please sign in to comment.