/** Get the endpoints of the sub-line. * <p> * A subline may be any arbitrary number of disjoints segments, so the endpoints * are provided as a list of endpoint pairs. Each element of the list represents * one segment, and each segment contains a start point at index 0 and an end point * at index 1. If the sub-line is unbounded in the negative infinity direction, * the start point of the first segment will have infinite coordinates. If the * sub-line is unbounded in the positive infinity direction, the end point of the * last segment will have infinite coordinates. So a sub-line covering the whole * line will contain just one row and both elements of this row will have infinite * coordinates. If the sub-line is empty, the returned list will contain 0 segments. * </p> * @return list of segments endpoints */ public List<Segment> getSegments() { final List<Interval> list = remainingRegion.asList(); final List<Segment> segments = new ArrayList<Segment>(list.size()); for (final Interval interval : list) { final Vector3D start = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getInf())); final Vector3D end = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getSup())); segments.add(new Segment(start, end, line)); } return segments; }
/** Build an ordered list of intervals representing the instance. * <p>This method builds this intervals set as an ordered list of * {@link Interval Interval} elements. If the intervals set has no * lower limit, the first interval will have its low bound equal to * {@code Double.NEGATIVE_INFINITY}. If the intervals set has * no upper limit, the last interval will have its upper bound equal * to {@code Double.POSITIVE_INFINITY}. An empty tree will * build an empty list while a tree representing the whole real line * will build a one element list with both bounds being * infinite.</p> * @return a new ordered list containing {@link Interval Interval} * elements */ public List<Interval> asList() { final List<Interval> list = new ArrayList<Interval>(); for (final double[] a : this) { list.add(new Interval(a[0], a[1])); } return list; }
/** Get the midpoint of the interval. * @return midpoint of the interval * @deprecated as of 3.1, replaced by {@link #getBarycenter()} */ @Deprecated public double getMidPoint() { return getBarycenter(); }
/** Get the upper bound of the interval. * @return upper bound of the interval * @deprecated as of 3.1, replaced by {@link #getSup()} */ @Deprecated public double getUpper() { return getSup(); }
/** Get the lower bound of the interval. * @return lower bound of the interval * @deprecated as of 3.1, replaced by {@link #getInf()} */ @Deprecated public double getLower() { return getInf(); }
/** {@inheritDoc} */ @Override protected void computeGeometricalProperties() { if (getTree(false).getCut() == null) { setBarycenter((Point<Euclidean1D>) Vector1D.NaN); setSize(((Boolean) getTree(false).getAttribute()) ? Double.POSITIVE_INFINITY : 0); } else { double size = 0.0; double sum = 0.0; for (final Interval interval : asList()) { size += interval.getSize(); sum += interval.getSize() * interval.getBarycenter(); } setSize(size); if (Double.isInfinite(size)) { setBarycenter((Point<Euclidean1D>) Vector1D.NaN); } else if (size >= Precision.SAFE_MIN) { setBarycenter((Point<Euclidean1D>) new Vector1D(sum / size)); } else { setBarycenter((Point<Euclidean1D>) ((OrientedPoint) getTree(false).getCut().getHyperplane()).getLocation()); } } }
/** Get the length of the interval. * @return length of the interval * @deprecated as of 3.1, replaced by {@link #getSize()} */ @Deprecated public double getLength() { return getSize(); }
/** Get the upper bound of the interval. * @return upper bound of the interval * @deprecated as of 3.1, replaced by {@link #getSup()} */ @Deprecated public double getUpper() { return getSup(); }
/** Get the lower bound of the interval. * @return lower bound of the interval * @deprecated as of 3.1, replaced by {@link #getInf()} */ @Deprecated public double getLower() { return getInf(); }
/** {@inheritDoc} */ @Override protected void computeGeometricalProperties() { if (getTree(false).getCut() == null) { setBarycenter((Point<Euclidean1D>) Vector1D.NaN); setSize(((Boolean) getTree(false).getAttribute()) ? Double.POSITIVE_INFINITY : 0); } else { double size = 0.0; double sum = 0.0; for (final Interval interval : asList()) { size += interval.getSize(); sum += interval.getSize() * interval.getBarycenter(); } setSize(size); if (Double.isInfinite(size)) { setBarycenter((Point<Euclidean1D>) Vector1D.NaN); } else if (size >= Precision.SAFE_MIN) { setBarycenter((Point<Euclidean1D>) new Vector1D(sum / size)); } else { setBarycenter((Point<Euclidean1D>) ((OrientedPoint) getTree(false).getCut().getHyperplane()).getLocation()); } } }
/** Get the length of the interval. * @return length of the interval * @deprecated as of 3.1, replaced by {@link #getSize()} */ @Deprecated public double getLength() { return getSize(); }
/** Build an ordered list of intervals representing the instance. * <p>This method builds this intervals set as an ordered list of * {@link Interval Interval} elements. If the intervals set has no * lower limit, the first interval will have its low bound equal to * {@code Double.NEGATIVE_INFINITY}. If the intervals set has * no upper limit, the last interval will have its upper bound equal * to {@code Double.POSITIVE_INFINITY}. An empty tree will * build an empty list while a tree representing the whole real line * will build a one element list with both bounds being * infinite.</p> * @return a new ordered list containing {@link Interval Interval} * elements */ public List<Interval> asList() { final List<Interval> list = new ArrayList<Interval>(); for (final double[] a : this) { list.add(new Interval(a[0], a[1])); } return list; }
/** Get the midpoint of the interval. * @return midpoint of the interval * @deprecated as of 3.1, replaced by {@link #getBarycenter()} */ @Deprecated public double getMidPoint() { return getBarycenter(); }
/** Get the endpoints of the sub-line. * <p> * A subline may be any arbitrary number of disjoints segments, so the endpoints * are provided as a list of endpoint pairs. Each element of the list represents * one segment, and each segment contains a start point at index 0 and an end point * at index 1. If the sub-line is unbounded in the negative infinity direction, * the start point of the first segment will have infinite coordinates. If the * sub-line is unbounded in the positive infinity direction, the end point of the * last segment will have infinite coordinates. So a sub-line covering the whole * line will contain just one row and both elements of this row will have infinite * coordinates. If the sub-line is empty, the returned list will contain 0 segments. * </p> * @return list of segments endpoints */ public List<Segment> getSegments() { final Line line = (Line) getHyperplane(); final List<Interval> list = ((IntervalsSet) getRemainingRegion()).asList(); final List<Segment> segments = new ArrayList<Segment>(list.size()); for (final Interval interval : list) { final Vector2D start = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getInf())); final Vector2D end = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getSup())); segments.add(new Segment(start, end, line)); } return segments; }
likMax = likelihood; return new Interval(lowMax, Math.min(end, alphaMax + step));
/** Get the endpoints of the sub-line. * <p> * A subline may be any arbitrary number of disjoints segments, so the endpoints * are provided as a list of endpoint pairs. Each element of the list represents * one segment, and each segment contains a start point at index 0 and an end point * at index 1. If the sub-line is unbounded in the negative infinity direction, * the start point of the first segment will have infinite coordinates. If the * sub-line is unbounded in the positive infinity direction, the end point of the * last segment will have infinite coordinates. So a sub-line covering the whole * line will contain just one row and both elements of this row will have infinite * coordinates. If the sub-line is empty, the returned list will contain 0 segments. * </p> * @return list of segments endpoints */ public List<Segment> getSegments() { final List<Interval> list = remainingRegion.asList(); final List<Segment> segments = new ArrayList<Segment>(list.size()); for (final Interval interval : list) { final Vector3D start = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getInf())); final Vector3D end = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getSup())); segments.add(new Segment(start, end, line)); } return segments; }
likMax = likelihood; return new Interval(lowMax, Math.min(end, alphaMax + step));
/** Get the endpoints of the sub-line. * <p> * A subline may be any arbitrary number of disjoints segments, so the endpoints * are provided as a list of endpoint pairs. Each element of the list represents * one segment, and each segment contains a start point at index 0 and an end point * at index 1. If the sub-line is unbounded in the negative infinity direction, * the start point of the first segment will have infinite coordinates. If the * sub-line is unbounded in the positive infinity direction, the end point of the * last segment will have infinite coordinates. So a sub-line covering the whole * line will contain just one row and both elements of this row will have infinite * coordinates. If the sub-line is empty, the returned list will contain 0 segments. * </p> * @return list of segments endpoints */ public List<Segment> getSegments() { final Line line = (Line) getHyperplane(); final List<Interval> list = ((IntervalsSet) getRemainingRegion()).asList(); final List<Segment> segments = new ArrayList<Segment>(list.size()); for (final Interval interval : list) { final Vector2D start = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getInf())); final Vector2D end = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getSup())); segments.add(new Segment(start, end, line)); } return segments; }