Skip to content

Improvements to degree of freedom parameter finders for noncentral F distribution #1495

Description

@dschmitz89

The check for the monotonicity of the noncentral F CDF as a function of the degrees of freedom parameters relies on asymptotic expressions for the right limit. For the left limits on the other hands, we still use an arbitrary smallValue and compute the CDF for it. Instead, we could also use simple asymptotic expressions.

For the v1 case we simply get F=exp(-nc/2) and for the v1 case F=0. This can be seen in the following plot. It can also be formally proven using the incomplete beta formulation of the CDF.

CC @NAThompson This is what I had in mind here.

Image
Python code

from scipy.special import ncfdtr, chndtr, chdtrc
import numpy as np
import matplotlib.pyplot as plt


v2 = 3
v1 = 2
nc = 1.
f = 1.5

fig, (top, bottom) = plt.subplots(2, 1)

v1_plot = np.logspace(-5, 5, 10000)
p = ncfdtr(v1_plot, v2, nc, f)
top.semilogx(v1_plot, p)

left_limit = np.exp(-0.5 * nc)
right_limit_chi_sq =chdtrc(v2, v2 / f)
top.set_xlabel('v1')
top.set_ylabel('p')
top.set_title(f'Noncentral F CDF(v1, {v2}, {nc}, {f})')
top.hlines(left_limit, v1_plot.min(), v1_plot.max(), colors='r', linestyles='--', label='left limit: exp(-0.5 * nc)')
top.hlines(right_limit_chi_sq, v1_plot.min(), v1_plot.max(), colors='b', linestyles='--', label='Right limit: 1 - Chi Sq.(v2 / f, v2)')

top.legend()

v2_plot = np.logspace(-5, 5, 10000)
p_v2 = ncfdtr(v1, v2_plot, nc, f)
bottom.semilogx(v2_plot, p_v2)
v2_right_limit = chndtr( f * v1, v1, nc)
bottom.set_xlabel('v2')
bottom.set_ylabel('p')
bottom.set_title(f'Noncentral F CDF({v1}, v2, {nc}, {f})')
bottom.hlines(0, v2_plot.min(), v2_plot.max(), colors='r', linestyles='--', label='left limit: 0')
bottom.hlines(v2_right_limit, v2_plot.min(), v2_plot.max(), colors='g', linestyles='--', label='right limit: Nonc. Chi Sq.(f * v1, v1, nc)')
bottom.legend()
fig.tight_layout()
plt.show()

Activity

  1. dschmitz89 commented on Sep 29, 2026

    @dschmitz89
    ContributorAuthor

    With nc=0 we get the limits for the regular F distribution, that we should also tackle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions