Libraryless. Click here for Pure Java version (50L/1K).
// properties: // -yields a proper probability (0 < p <= 1) // -distance 0 has probability 1 // -function is monotonically decreasing // (greater distance = lower probability) // -negative distances are interpreted as positive static double genericDistanceToProbability(double distance) { ret 1/(1+abs(distance)); } static double genericDistanceToProbability(double a, double b) { ret genericDistanceToProbability(a-b); }
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: | 177 / 272 |
Version history: | 4 change(s) |
Referenced in: | [show references] |