-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix TensorExtensions.StdDev #110392
Fix TensorExtensions.StdDev #110392
Conversation
{ | ||
return T.CreateChecked(Math.Sqrt(double.CreateChecked(variance))); | ||
} | ||
return T.Pow(variance, T.CreateChecked(0.5)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should indeed be updated to use IRootFunctions
instead; not Pow
which isn't guaranteed to behave the same in many important edge cases
For floating point numbers |
Fixes #110381
I use
IPowerFunctions<T>.Pow(x, 0.5)
to replicate sqrt, but special casedouble
andfloat
to useMath.Sqrt
andMathF.Sqrt
respectively.Would prefer to add
IRootFunctions
to method constraints to useT.Sqrt
but I don't know if it is possible to add new constraints.N.b.
TensorExtensions
is still marked as experimental