D.10 Miscellaneous Utilities

The KSL also provides a number of other useful class within the utilities package. The KSLMath class provides for working with finer levels of numerical precision and has some useful functions for computing factorials and binomial coefficients. In addition, there are functions for converting doubles to other numeric values.

  • double getDefaultNumericalPrecision() - returns the default numerical precision that can be expected on the machine
  • boolean equal(double a, double b) - returns true if the two doubles are equal with respect to the default numerical precision
  • boolean equal(double a, double b, double precision) - returns true if the two doubles are equal with respect to the specified precision
  • boolean within(double a, double b, double precision) - returns true if the absolute difference between the double is within the specified precision
  • double factorial(int n) - returns a numerically stable computed value of the factorial
  • double binomialCoefficient(int n, int k) - returns a numerically stable computed value of the binomial coefficient
  • double logFactorial(int n) - returns the natural logarithm of the factorial

The following list may be of interest and lead the reader to further exploration of the details.

  • GetValueIfc defines a general function and property to return a value
  • IdentityIfc a general interface to ensure that an implementer have an identity and a name.
  • Interval is useful to representing an inclusive real-valued interval such as a confidence interval.
  • PreviousValueIfc allows an implementer to remember and return the previous value.
  • KSLMaps hold utility functions for making maps from arrays, flattening maps of maps, unflattening maps, and converting maps to JSON.
  • utilities.rootfinding This package has an implementation for finding the root of a function via binary search
  • utilities.observers has base classes for implementing and using components that implement the observer pattern.