Libraryless. Click here for Pure Java version (9154L/50K).
static double ratioToProbability(double ratio) { if (ratio < 0) fail("No negative values allowed"); if (ratio > 1) ratio = 1/ratio; ret ratio; } static double ratioToProbability(double a, double b) { if (a < 0 || b < 0) fail("No negative values allowed"); ret b == 0 ? (a == 0 ? 1 : 0) : ratioToProbability(a/b); }
Began life as a copy of #1031994
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035513 |
Snippet name: | ratioToProbability - 1 is highest probability, any other ratio is lower |
Eternal ID of this version: | #1035513/1 |
Text MD5: | d376402528eeca62de55702d148ab417 |
Transpilation MD5: | ba02bd6d25aa43ca3e55c64680bc280d |
Author: | stefan |
Category: | javax / maths |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-06-01 17:55:06 |
Source code size: | 334 bytes / 10 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 115 / 152 |
Referenced in: | [show references] |