Libraryless. Click here for Pure Java version (50L/1K).
1 | // properties: |
2 | // -yields a proper probability (0 < p <= 1) |
3 | // -distance 0 has probability 1 |
4 | // -function is monotonically decreasing |
5 | // (greater distance = lower probability) |
6 | // -negative distances are interpreted as positive |
7 | static double genericDistanceToProbability(double distance) { |
8 | ret 1/(1+abs(distance)); |
9 | } |
10 | |
11 | static double genericDistanceToProbability(double a, double b) { |
12 | ret genericDistanceToProbability(a-b); |
13 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1031994 |
Snippet name: | genericDistanceToProbability - is 1/(1+x) better or 1/(1+x^2)? |
Eternal ID of this version: | #1031994/5 |
Text MD5: | 37eb012b41d8aac628e3169357018057 |
Transpilation MD5: | a9ac49ad5ba524293c07a1fe952772f2 |
Author: | stefan |
Category: | javax / maths |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-04-30 17:07:10 |
Source code size: | 441 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 179 / 276 |
Version history: | 4 change(s) |
Referenced in: | [show references] |