[
https://issues.apache.org/jira/browse/NUMBERS-156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17344538#comment-17344538
]
Alex Herbert edited comment on NUMBERS-156 at 5/14/21, 12:26 PM:
-----------------------------------------------------------------
So... I made a mistake computing the std dev so all of those values are wrong.
(I used "=" instead of "+=".) Here are the actual results, including the
version with the Kahan summation. The std dev values are now pretty consistent
between runs.
||name||input type||error mean||error std dev||error min||error max||failed||
|direct|high|NaN|-0.00|Infinity|-Infinity|200000|
|enorm|high|0.0172|0.684|-2.00|3.00|0|
|enormMod|high|-0.00128|0.502|-2.00|2.00|0|
|enormModKahan|high|-0.000815|0.493|-2.00|2.00|0|
|direct|high-thresh|-0.00201|0.503|-2.00|2.00|0|
|enorm|high-thresh|0.0165|0.683|-2.00|2.00|0|
|enormMod|high-thresh|-0.00205|0.501|-2.00|2.00|0|
|enormModKahan|high-thresh|-0.00201|0.499|-2.00|2.00|0|
|direct|mid|-0.00177|0.506|-2.00|2.00|0|
|enorm|mid|-0.00177|0.506|-2.00|2.00|0|
|enormMod|mid|-0.00177|0.506|-2.00|2.00|0|
|enormModKahan|mid|-0.00131|0.496|-2.00|2.00|0|
|direct|low-thresh|1.00e-05|0.502|-2.00|2.00|0|
|enorm|low-thresh|0.0185|0.683|-2.00|2.00|0|
|enormMod|low-thresh|-3.00e-05|0.500|-2.00|2.00|0|
|enormModKahan|low-thresh|1.50e-05|0.498|-2.00|2.00|0|
|direct|low|6.84e+06|6.70e+08|-2.15e+09|2.15e+09|404|
|enorm|low|0.0191|0.682|-2.00|2.00|0|
|enormMod|low|0.000650|0.503|-2.00|2.00|0|
|enormModKahan|low|0.00112|0.494|-2.00|2.00|0|
|direct|full|-1.47e+04|4.43e+06|-1.33e+09|2.37e+06|20128|
|enorm|full|0.0118|0.180|-2.00|2.00|0|
|enormMod|full|0.000165|0.134|-2.00|1.00|0|
|enormModKahan|full|0.000160|0.134|-2.00|1.00|0|
{{enormModKahan}} consistently has the lowest std dev across all exponent
ranges, although the difference is slight. Here are the performance benchmarks.
||Benchmark||(type)||Mode||Cnt||Score||Error||Units||
|direct|low|avgt|5|15361280.529|± 292202.242|ns/op|
|direct|mid|avgt|5|520697.721|± 28644.444|ns/op|
|direct|high|avgt|5|517801.887|± 104893.641|ns/op|
|direct|full|avgt|5|951827.119|± 118513.195|ns/op|
|enorm|low|avgt|5|1986518.135|± 319268.787|ns/op|
|enorm|mid|avgt|5|1119078.784|± 37970.437|ns/op|
|enorm|high|avgt|5|1968502.909|± 62335.088|ns/op|
|enorm|full|avgt|5|3201915.597|± 77111.214|ns/op|
|enormMod|low|avgt|5|804732.957|± 6855.089|ns/op|
|enormMod|mid|avgt|5|814270.565|± 104127.054|ns/op|
|enormMod|high|avgt|5|837129.985|± 66755.395|ns/op|
|enormMod|full|avgt|5|1575207.552|± 37762.767|ns/op|
|enormModKahan|low|avgt|5|974512.192|± 25598.720|ns/op|
|enormModKahan|mid|avgt|5|1019614.135|± 163308.413|ns/op|
|enormModKahan|high|avgt|5|1075077.374|± 271268.724|ns/op|
|enormModKahan|full|avgt|5|1636619.080|± 86228.187|ns/op|
As you predicted, {{enormModKahan}} is only slightly slower than {{enormMod}}.
I'm undecided on whether the extra overhead is worth it. What do you think?
was (Author: mattjuntunen):
So... I made a mistake computing the std dev so all of those values are wrong.
(I used "=" instead of "+=".) Here are the actual results, including the
version with the Kahan summation. The std dev values are now pretty consistent
between runs.
||name||input||type||error mean||error std dev||error min||error max||failed||
|direct|high|NaN|-0.00|Infinity|-Infinity|200000|
|enorm|high|0.0172|0.684|-2.00|3.00|0|
|enormMod|high|-0.00128|0.502|-2.00|2.00|0|
|enormModKahan|high|-0.000815|0.493|-2.00|2.00|0|
|direct|high-thresh|-0.00201|0.503|-2.00|2.00|0|
|enorm|high-thresh|0.0165|0.683|-2.00|2.00|0|
|enormMod|high-thresh|-0.00205|0.501|-2.00|2.00|0|
|enormModKahan|high-thresh|-0.00201|0.499|-2.00|2.00|0|
|direct|mid|-0.00177|0.506|-2.00|2.00|0|
|enorm|mid|-0.00177|0.506|-2.00|2.00|0|
|enormMod|mid|-0.00177|0.506|-2.00|2.00|0|
|enormModKahan|mid|-0.00131|0.496|-2.00|2.00|0|
|direct|low-thresh|1.00e-05|0.502|-2.00|2.00|0|
|enorm|low-thresh|0.0185|0.683|-2.00|2.00|0|
|enormMod|low-thresh|-3.00e-05|0.500|-2.00|2.00|0|
|enormModKahan|low-thresh|1.50e-05|0.498|-2.00|2.00|0|
|direct|low|6.84e+06|6.70e+08|-2.15e+09|2.15e+09|404|
|enorm|low|0.0191|0.682|-2.00|2.00|0|
|enormMod|low|0.000650|0.503|-2.00|2.00|0|
|enormModKahan|low|0.00112|0.494|-2.00|2.00|0|
|direct|full|-1.47e+04|4.43e+06|-1.33e+09|2.37e+06|20128|
|enorm|full|0.0118|0.180|-2.00|2.00|0|
|enormMod|full|0.000165|0.134|-2.00|1.00|0|
|enormModKahan|full|0.000160|0.134|-2.00|1.00|0|
{{enormModKahan}} consistently has the lowest std dev across all exponent
ranges, although the difference is slight. Here are the performance benchmarks.
||Benchmark||(type)||Mode||Cnt||Score||Error||Units||
|direct|low|avgt|5|15361280.529|± 292202.242|ns/op|
|direct|mid|avgt|5|520697.721|± 28644.444|ns/op|
|direct|high|avgt|5|517801.887|± 104893.641|ns/op|
|direct|full|avgt|5|951827.119|± 118513.195|ns/op|
|enorm|low|avgt|5|1986518.135|± 319268.787|ns/op|
|enorm|mid|avgt|5|1119078.784|± 37970.437|ns/op|
|enorm|high|avgt|5|1968502.909|± 62335.088|ns/op|
|enorm|full|avgt|5|3201915.597|± 77111.214|ns/op|
|enormMod|low|avgt|5|804732.957|± 6855.089|ns/op|
|enormMod|mid|avgt|5|814270.565|± 104127.054|ns/op|
|enormMod|high|avgt|5|837129.985|± 66755.395|ns/op|
|enormMod|full|avgt|5|1575207.552|± 37762.767|ns/op|
|enormModKahan|low|avgt|5|974512.192|± 25598.720|ns/op|
|enormModKahan|mid|avgt|5|1019614.135|± 163308.413|ns/op|
|enormModKahan|high|avgt|5|1075077.374|± 271268.724|ns/op|
|enormModKahan|full|avgt|5|1636619.080|± 86228.187|ns/op|
As you predicted, {{enormModKahan}} is only slightly slower than {{enormMod}}.
I'm undecided on whether the extra overhead is worth it. What do you think?
> SafeNorm 3D overload
> --------------------
>
> Key: NUMBERS-156
> URL: https://issues.apache.org/jira/browse/NUMBERS-156
> Project: Commons Numbers
> Issue Type: Improvement
> Reporter: Matt Juntunen
> Priority: Major
>
> We should create an overload of {{SafeNorm.value}} that accepts 3 arguments
> to potentially improve performance for 3D vectors.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)