Skip to content

[tests] Add unit tests for ProbabilityFunctions (Erfinv, Erf, Erfc)#53

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
copilot/copy-changes-from-pr-7569-719442c54010b02d
Draft

[tests] Add unit tests for ProbabilityFunctions (Erfinv, Erf, Erfc)#53
github-actions[bot] wants to merge 1 commit intomainfrom
copilot/copy-changes-from-pr-7569-719442c54010b02d

Conversation

@github-actions
Copy link
Copy Markdown

@github-actions github-actions bot commented Apr 7, 2026

Adds tests for the changes introduced in PR #51.

What's covered

New test file: test/Microsoft.ML.CpuMath.UnitTests/ProbabilityFunctionsTests.cs

Tests for ProbabilityFunctions (Erfinv, Erf, Erfc):

Test Description
ErfinvOutOfRangeAboveOneReturnsNaN x > 1 → NaN
ErfinvOutOfRangeBelowNegativeOneReturnsNaN x < -1 → NaN
ErfinvAtOneReturnsPositiveInfinity x = 1 → +∞
ErfinvAtNegativeOneReturnsNegativeInfinity x = -1 → -∞
ErfinvAtZeroReturnsZero x = 0 → 0
ErfinvIsInverseOfErf Round-trip: Erfinv(Erf(x)) ≈ x for several values
ErfinvIsOddFunction Erfinv(-x) == -Erfinv(x)
ErfinvRepeatedCallsReturnConsistentResults Coefficients shared; repeated calls are stable
ErfAtPositiveInfinityReturnsOne
ErfAtNegativeInfinityReturnsNegativeOne
ErfAtZeroReturnsZero
ErfcAtPositiveInfinityReturnsZero
ErfcAtNegativeInfinityReturnsTwo
ErfAndErfcSumToOne Erf(x) + Erfc(x) == 1 for several values

Notes

  • The ErfinvRepeatedCallsReturnConsistentResults test verifies the key behavioural guarantee of the PR — that the refactored static coefficient caching doesn't introduce per-call divergence.
  • Tests follow the existing Microsoft.ML.CpuMath.UnitTests conventions: xUnit [Fact]/[Theory], BaseTestClass base, MIT license header.

Generated by Add Tests for PR Changes · ● 1.3M ·

Adds tests for the refactored ProbabilityFunctions.Erfinv that now uses
the ErfInvSeriesCoefficients struct for lazy one-time coefficient
initialization. Tests cover edge cases (out-of-range, boundary values),
round-trip correctness (Erfinv(Erf(x)) ≈ x), odd-function symmetry,
consistency of repeated calls, and Erf/Erfc complementary sum.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JanKrivanek
Copy link
Copy Markdown
Owner

Try some comment

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant