Libraryless. Click here for Pure Java version (2571L/16K).
1 | // returns 0 for identical, 1 for completely different |
2 | static <A> double chiSquared_histogramsWithSum1(Map<A, Double> map1, Map<A, Double> map2) { |
3 | if (empty(map1) || empty(map2)) ret Double.NaN; |
4 | double sum = 0; |
5 | for (A key : joinSets(keys(map1), keys(map2))) { |
6 | double mi = or0(map1.get(key)); |
7 | double ni = or0(map2.get(key)); |
8 | double item = sqr(ni-mi)/(mi+ni); |
9 | ifdef chiSquared_histogramsWithSum1_debug |
10 | printVars_str(+key, +mi, +ni, +item); |
11 | endifdef |
12 | sum += item; |
13 | } |
14 | ret sum/2; |
15 | } |
Began life as a copy of #1030107
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030110 |
Snippet name: | chiSquared_histogramsWithSum1 |
Eternal ID of this version: | #1030110/6 |
Text MD5: | 1e062e0920d5e60bb79834991cbad836 |
Transpilation MD5: | 62a2cbdfed8f2c67eb4f49517f51b4ec |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-11-09 12:56:05 |
Source code size: | 530 bytes / 15 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 218 / 293 |
Version history: | 5 change(s) |
Referenced in: | [show references] |