-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix TensorExtensions.StdDev #110392
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
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 casedoubleandfloatto useMath.SqrtandMathF.Sqrtrespectively.Would prefer to add
IRootFunctionsto method constraints to useT.Sqrtbut I don't know if it is possible to add new constraints.N.b.
TensorExtensionsis still marked as experimental