// Path: src/main/java/cz/paulrz/montecarlo/parallel/CpuPool.java
// public final class CpuPool {
//     public static final int numOfCpu = Runtime.getRuntime().availableProcessors();
//     public static final ExecutorService executorService = Executors.newFixedThreadPool(numOfCpu);
// 
// 
// }


import cz.paulrz.montecarlo.parallel.CpuPool;
import org.apache.commons.math3.exception.MathInternalError;
import org.apache.commons.math3.exception.NullArgumentException;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.stat.descriptive.AbstractUnivariateStatistic;
import org.apache.commons.math3.util.FastMath;
import java.io.Serializable;
import java.util.Arrays;
import java.util.concurrent.*;
        }
        if (length == 1) {
            return values[begin]; // always return single value for n = 1
        }
        double pos = p * (length + 1) / 100;
        double fpos = FastMath.floor(pos);
        int intPos = (int) fpos;
        double dif = pos - fpos;
        double[] work;
        int[] pivotsHeap;
        if (values == getDataRef()) {
            work = getDataRef();
            pivotsHeap = cachedPivots;
        } else {
            work = new double[length];
            System.arraycopy(values, begin, work, 0, length);
            pivotsHeap = new int[(0x1 << MAX_CACHED_LEVELS) - 1];
            Arrays.fill(pivotsHeap, -1);
        }

        if (pos < 1) {
            return select(work, pivotsHeap, 0);
        }
        if (pos >= length) {
            return select(work, pivotsHeap, length - 1);
        }

        Future<Double> lowerFuture =
                CpuPool.executorService.submit(new SelectWorker(work, pivotsHeap, intPos - 1));
        Future<Double> upperFuture =
// Path: src/main/java/cz/paulrz/montecarlo/parallel/CpuPool.java
// public final class CpuPool {
//     public static final int numOfCpu = Runtime.getRuntime().availableProcessors();
//     public static final ExecutorService executorService = Executors.newFixedThreadPool(numOfCpu);
// 
// 
// }


// Path: src/main/java/cz/paulrz/montecarlo/random/ParallelPercentile.java
import cz.paulrz.montecarlo.parallel.CpuPool;
import org.apache.commons.math3.exception.MathInternalError;
import org.apache.commons.math3.exception.NullArgumentException;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.stat.descriptive.AbstractUnivariateStatistic;
import org.apache.commons.math3.util.FastMath;
import java.io.Serializable;
import java.util.Arrays;
import java.util.concurrent.*;

        }
        if (length == 1) {
            return values[begin]; // always return single value for n = 1
        }
        double pos = p * (length + 1) / 100;
        double fpos = FastMath.floor(pos);
        int intPos = (int) fpos;
        double dif = pos - fpos;
        double[] work;
        int[] pivotsHeap;
        if (values == getDataRef()) {
            work = getDataRef();
            pivotsHeap = cachedPivots;
        } else {
            work = new double[length];
            System.arraycopy(values, begin, work, 0, length);
            pivotsHeap = new int[(0x1 << MAX_CACHED_LEVELS) - 1];
            Arrays.fill(pivotsHeap, -1);
        }

        if (pos < 1) {
            return select(work, pivotsHeap, 0);
        }
        if (pos >= length) {
            return select(work, pivotsHeap, length - 1);
        }

        Future<Double> lowerFuture =
                CpuPool.executorService.submit(new SelectWorker(work, pivotsHeap, intPos - 1));
        Future<Double> upperFuture =
                CpuPool.executorService.submit(new SelectWorker(work, pivotsHeap, intPos));