docs/examples/IrregularlySampledData.java
/**
     * Create sample data
     *
     * @param duration duration
     * @param interval interval
     * @return generated values
     */
Create sample data
@param duration duration
@param interval interval
@return generated values
Create sample data @param duration duration @param interval interval @return generated values
private static Data createData(double duration, double interval) {
        double[] times = new double[(int) (1.5 * duration / interval)];
        times = Arrays.stream(times).map(x -> getPoisson(interval * 1000) / 1000.0).toArray();
        for (int i = 1; i < times.length; i++) {
            times[i] += times[i - 1];
        }
        double round = 1000.0;
        times = Arrays.stream(times).map(x -> (Math.round(x * round) / round)).toArray();
        times = Arrays.stream(times).filter(x -> x <= duration).toArray();
        double stepsize = 0.001;
        double frequency = 5;
        int size = (int) Math.ceil(times[times.length - 1] * 2 * Math.PI / stepsize);
        double[] y = new double[size];
        for (int i = 0; i < size; i++) {
            double x = i * stepsize;
            y[i] = Math.sin(frequency * x);
        }
        double[] ind = Arrays.stream(times).map(x -> x / 0.001 * 2 * Math.PI).toArray();
        double[] yData = new double[ind.length];
        for (int i = 0; i < yData.length; i++) {
            yData[i] = y[(int) ind[i]];
        }
        return new Data(times, yData);
    }
private static Data createData ( double duration , double interval ) { double [ ] times = new double [ ( int ) ( 1.5 * duration / interval ) ] ; times = Arrays . stream ( times ) . map ( x -> getPoisson ( interval * 1000 ) / 1000.0 ) . toArray ( ) ; for ( int i = 1 ; i < times . length ; i ++ ) { times [ i ] += times [ i - 1 ] ; } double round = 1000.0 ; times = Arrays . stream ( times ) . map ( x -> ( Math . round ( x * round ) / round ) ) . toArray ( ) ; times = Arrays . stream ( times ) . filter ( x -> x <= duration ) . toArray ( ) ; double stepsize = 0.001 ; double frequency = 5 ; int size = ( int ) Math . ceil ( times [ times . length - 1 ] * 2 * Math . PI / stepsize ) ; double [ ] y = new double [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { double x = i * stepsize ; y [ i ] = Math . sin ( frequency * x ) ; } double [ ] ind = Arrays . stream ( times ) . map ( x -> x / 0.001 * 2 * Math . PI ) . toArray ( ) ; double [ ] yData = new double [ ind . length ] ; for ( int i = 0 ; i < yData . length ; i ++ ) { yData [ i ] = y [ ( int ) ind [ i ] ] ; } return new Data ( times , yData ) ; }
Create sample data
 @param duration duration
 @param interval interval
 @return generated values
Create sample data @param duration duration @param interval interval @return generated values