LinearFitter.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:java-monitoring-client-library 作者:
/**
 * Create a new {@link LinearFitter}.
 *
 * @param numFiniteIntervals the number of intervals, excluding the underflow and overflow
 *     intervals
 * @param width the width of each interval
 * @param offset the start value of the first interval
 * @throws IllegalArgumentException if {@code numFiniteIntervals <= 0} or {@code width <= 0}
 */
public static LinearFitter create(int numFiniteIntervals, double width, double offset) {
  checkArgument(numFiniteIntervals > 0, "numFiniteIntervals must be greater than 0");
  checkArgument(width > 0, "width must be greater than 0");
  checkDouble(offset);

  ImmutableSortedSet.Builder<Double> boundaries = ImmutableSortedSet.naturalOrder();

  for (int i = 0; i < numFiniteIntervals + 1; i++) {
    boundaries.add(width * i + offset);
  }

  return new AutoValue_LinearFitter(width, offset, boundaries.build());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号