Created
April 23, 2019 04:04
-
-
Save silicontrip/0fa0987a4d69517d05b2f9200b57c971 to your computer and use it in GitHub Desktop.
Uniform Distribution refine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Performs an intersection with another Uniform Distribution and updates this one in place | |
| * The idea is that improves the accuracy of the current UD | |
| * | |
| * @param a the UniformDistribution to refine this one with | |
| * | |
| * @return boolean indicating if this UD was improved | |
| * | |
| * @throws ArithmeticException if there was no overlap between the two UD | |
| */ | |
| public boolean refine (UniformDistribution a) throws ArithmeticException { | |
| // sanity check | |
| boolean changed = false; | |
| if ((upper > a.getUpper() || upper > a.getLower()) && ( lower < a.getLower() || lower < a.getUpper())) | |
| { | |
| if (lower < a.getLower()) | |
| { | |
| double d = a.getLower() - lower; | |
| //System.err.println("lower diff: " + d + "/" + lower); | |
| lower=a.getLower(); | |
| changed=true; | |
| } | |
| if (upper > a.getUpper()) | |
| { | |
| double d = upper - a.getUpper(); | |
| //System.err.println("upper diff: " + d + "/" + upper + " : " + lower); | |
| upper=a.getUpper(); | |
| changed=true; | |
| } | |
| } else { | |
| throw new ArithmeticException( "REFINE Sanity check Exception : " + toString() + " x " + a); | |
| } | |
| return changed; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment