/** * Sets the {@link StochasticSupplier} that will be used to generate the * amplitude of the {@link IntensityFunction} that will be created by this * builder. Default value: 1. * @param a Must be positive. * @return This, as per the builder pattern. */ public SineIntensityBuilder amplitude(StochasticSupplier<Double> a) { amplitudeSup = checked(a, POSITIVE); return this; }
/** * Sets the {@link StochasticSupplier} that will be used to generate the * phaseShift of the {@link IntensityFunction} that will be created by this * builder. Default value: 1/2. * @param s The phase shift. * @return This, as per the builder pattern. */ public SineIntensityBuilder phaseShift(StochasticSupplier<Double> s) { phaseShiftSup = checked(s, FINITE); return this; }
/** * Sets the {@link StochasticSupplier} that will be used to generate the * frequency of the {@link IntensityFunction} that will be created by this * builder. Default value: 1. * @param f Must be positive. * @return This, as per the builder pattern. */ public SineIntensityBuilder frequency(StochasticSupplier<Double> f) { frequencySup = checked(f, POSITIVE); return this; }
/** * Sets the {@link StochasticSupplier} that will be used to generate the * height of the {@link IntensityFunction} that will be created by this * builder. Default value: 0. Typical values range between <code>-1</code> * and <code>1</code>. If the height is close to <code>-1</code> almost the * entire function will be negative. If the height is <code>1</code> or * higher the entire function will be positive. * @param h Must be <code> > -1</code>. * @return This, as per the builder pattern. */ public SineIntensityBuilder height(StochasticSupplier<Double> h) { heightSup = checked(h, GREATER_THAN_MINUS_ONE); return this; }
/** * Creates a {@link TimeSeriesGenerator} using a uniform distribution for the * inter arrival times of events. The spread of the uniform distribution is * defined by the <code>maxDeviation</code> {@link StochasticSupplier}, this * means that each time a time series is generated a different max deviation * settings is used. * @param length The length of the time series, all generated times will be in * the interval [0,length). * @param numEvents The total number of events in the time series (on * average). * @param maxDeviation A supplier that is used for max deviation values. * @return A {@link TimeSeriesGenerator} based on a uniform distribution, each * time series that is generated has a different max deviation drawn * from the supplier. */ public static TimeSeriesGenerator uniform(double length, int numEvents, StochasticSupplier<Double> maxDeviation) { checkArgument(length > 0d); checkArgument(numEvents > 0); final double average = length / numEvents; return new UniformTimeSeries(length, average, StochasticSuppliers.checked( maxDeviation, Range.atLeast(0d))); }
/** * Tests for * {@link StochasticSuppliers#checked(StochasticSupplier, Predicate)}. */ @Test public void testCheckedSupplier() { final Predicate<Double> positive = Range.closedOpen(0d, Double.POSITIVE_INFINITY); checked(constant(0d), positive).get(0); checked(constant(453453453.34), positive).get(0); checked(constant(Double.MAX_VALUE), positive).get(0); boolean fail = false; try { checked(constant(Double.POSITIVE_INFINITY), positive).get(0); } catch (final IllegalArgumentException e) { fail = true; } assertTrue(fail); fail = false; try { checked(constant(-0.0000000001), positive).get(0); } catch (final IllegalArgumentException e) { fail = true; } assertTrue(fail); }