Example usage for java.lang Double POSITIVE_INFINITY

List of usage examples for java.lang Double POSITIVE_INFINITY

Introduction

In this page you can find the example usage for java.lang Double POSITIVE_INFINITY.

Prototype

double POSITIVE_INFINITY

To view the source code for java.lang Double POSITIVE_INFINITY.

Click Source Link

Document

A constant holding the positive infinity of type double .

Usage

From source file:br.com.autonomiccs.autonomic.administration.algorithms.impl.VmsDispersionAlgorithmForHomogeneousEnvironment.java

/**
 * It calculates the host score based on its memory usage proportion (memory usage / total
 * memory)/*  www . j  a v  a2  s .c om*/
 */
@Override
protected double calculateHostScore(HostResources host) {
    if (host.getUsedMemoryInMegaBytes() != 0) {
        return (host.getTotalMemoryInBytes() / BYTES_TO_MEGA_BYTES) / host.getUsedMemoryInMegaBytes();
    }
    return Double.POSITIVE_INFINITY;
}

From source file:com.clust4j.algo.RadiusNeighbors.java

@Override
protected RadiusNeighbors fit() {
    synchronized (fitLock) {
        if (null != res)
            return this;

        final LogTimer timer = new LogTimer();
        Neighborhood initRes = new Neighborhood(tree.queryRadius(fit_X, radius, false));
        info("queried " + this.alg + " for radius neighbors in " + timer.toString());

        double[][] dists = initRes.getDistances();
        int[][] indices = initRes.getIndices();
        int[] tmp_ind_neigh, ind_neighbor;
        double[] tmp_dists, dist_row;

        for (int ind = 0; ind < indices.length; ind++) {
            ind_neighbor = indices[ind];
            dist_row = dists[ind];/*from  w  w w  .  java 2 s .  c o  m*/

            // Keep track for summary
            double v, sum = 0, minDist = Double.POSITIVE_INFINITY, maxDist = Double.NEGATIVE_INFINITY;

            int b_count = 0;
            boolean b_val;
            boolean[] mask = new boolean[ind_neighbor.length];
            for (int j = 0; j < ind_neighbor.length; j++) {
                b_val = ind_neighbor[j] != ind;
                mask[j] = b_val;
                v = dist_row[j];

                if (b_val) {
                    sum += v;
                    minDist = FastMath.min(minDist, v);
                    maxDist = FastMath.max(maxDist, v);
                    b_count++;
                }
            }

            tmp_ind_neigh = new int[b_count];
            tmp_dists = new double[b_count];

            for (int j = 0, k = 0; j < mask.length; j++) {
                if (mask[j]) {
                    tmp_ind_neigh[k] = ind_neighbor[j];
                    tmp_dists[k] = dist_row[j];
                    k++;
                }
            }

            indices[ind] = tmp_ind_neigh;
            dists[ind] = tmp_dists;

            fitSummary.add(new Object[] { ind, b_count, minDist, (double) sum / (double) b_count, maxDist,
                    timer.wallTime() });
        }

        res = new Neighborhood(dists, indices);

        sayBye(timer);
        return this;
    }
}

From source file:com.opengamma.analytics.financial.model.volatility.smile.fitting.interpolation.SmileInterpolator.java

public List<T> getFittedModelParameters(final double forward, final double[] strikes, final double expiry,
        final double[] impliedVols) {
    ArgumentChecker.notNull(strikes, "strikes");
    ArgumentChecker.notNull(impliedVols, "implied volatilities");
    final int n = strikes.length;
    ArgumentChecker.isTrue(n > 2, "cannot fit less than three points; have {}", n);
    ArgumentChecker.isTrue(impliedVols.length == n, "#strikes != # vols; have {} and {}", impliedVols.length,
            n);/*w w w.j a  v  a  2  s.c  om*/
    validateStrikes(strikes);

    final List<T> modelParameters = new ArrayList<>(n);

    final double[] errors = new double[n];
    Arrays.fill(errors, FIT_ERROR);

    final SmileModelFitter<T> globalFitter = getFitter(forward, strikes, expiry, impliedVols, errors);
    final BitSet gFixed = getGlobalFixedValues();
    LeastSquareResultsWithTransform gBest = null;
    double chiSqr = Double.POSITIVE_INFINITY;

    //TODO set these in sub classes
    int tries = 0;
    int count = 0;
    while (chiSqr > 100.0 * n && count < 5) { //10bps average error
        final DoubleMatrix1D gStart = getGlobalStart(forward, strikes, expiry, impliedVols);
        try {
            final LeastSquareResultsWithTransform glsRes = globalFitter.solve(gStart, gFixed);
            if (glsRes.getChiSq() < chiSqr) {
                gBest = glsRes;
                chiSqr = gBest.getChiSq();
            }
            count++;
        } catch (final Exception e) {
        }
        tries++;
        if (tries > 20) {
            throw new MathException("Cannot fit data");
        }
    }
    if (gBest == null) {
        throw new IllegalStateException("Global estimate was null; should never happen");
    }
    if (n == 3) {
        if (gBest.getChiSq() / n > 1.0) {
            s_logger.debug("chi^2 on fit to ", +n + " points is " + gBest.getChiSq());
        }
        modelParameters.add(toSmileModelData(gBest.getModelParameters()));
    } else {
        final BitSet lFixed = getLocalFixedValues();
        DoubleMatrix1D lStart = gBest.getModelParameters();
        for (int i = 0; i < n - 2; i++) {
            final double[][] temp = getStrikesVolsAndErrors(i, strikes, impliedVols, errors);
            final double[] tStrikes = temp[0];
            final double[] tVols = temp[1];
            final double[] tErrors = temp[2];
            final SmileModelFitter<T> localFitter = getFitter(forward, tStrikes, expiry, tVols, tErrors);
            LeastSquareResultsWithTransform lRes = localFitter.solve(lStart, lFixed);
            LeastSquareResultsWithTransform best = lRes;

            count = 0;
            while (lRes.getChiSq() > 3.0 && count < 10) {
                lStart = getGlobalStart(forward, strikes, expiry, impliedVols);
                lRes = localFitter.solve(lStart, lFixed);
                if (lRes.getChiSq() < best.getChiSq()) {
                    best = lRes;
                }
                count++;
            }

            if (best.getChiSq() > 3.0) {
                s_logger.debug("chi^2 on 3-point fit #" + i + " is " + best.getChiSq());
            }
            modelParameters.add(toSmileModelData(best.getModelParameters()));
        }
    }
    return modelParameters;
}

From source file:ffx.crystal.ReflectionList.java

/**
 * <p>// w w  w. j a v a2  s  . com
 * Constructor for ReflectionList.</p>
 *
 * @param crystal a {@link ffx.crystal.Crystal} object.
 * @param resolution a {@link ffx.crystal.Resolution} object.
 * @param properties a
 * {@link org.apache.commons.configuration.CompositeConfiguration} object.
 */
public ReflectionList(Crystal crystal, Resolution resolution, CompositeConfiguration properties) {
    this.crystal = crystal;
    spaceGroup = crystal.spaceGroup;
    crystalSystem = spaceGroup.crystalSystem;
    laueSystem = spaceGroup.laueSystem;
    this.resolution = resolution;

    int hmax = (int) (this.crystal.a / this.resolution.resolutionLimit());
    int kmax = (int) (this.crystal.b / this.resolution.resolutionLimit());
    int lmax = (int) (this.crystal.c / this.resolution.resolutionLimit());

    minres = Double.POSITIVE_INFINITY;
    maxres = Double.NEGATIVE_INFINITY;
    int n = 0;

    HKL hkl = new HKL();
    for (int h = -hmax; h <= hmax; h++) {
        hkl.h(h);
        for (int k = -kmax; k <= kmax; k++) {
            hkl.k(k);
            for (int l = -lmax; l <= lmax; l++) {
                hkl.l(l);

                double res = Crystal.invressq(this.crystal, hkl);
                getepsilon(hkl);
                if (SpaceGroup.checkLaueRestrictions(laueSystem, h, k, l) && resolution.inInverseResSqRange(res)
                        && !HKL.sys_abs(hkl)) {
                    minres = min(res, minres);
                    maxres = max(res, maxres);
                    String s = ("" + h + "_" + k + "_" + l).intern();
                    hklmap.put(s, new HKL(hkl.h(), hkl.k(), hkl.l(), hkl.epsilon(), hkl.allowed));
                    n++;
                }
            }
        }
    }

    n = 0;
    for (Map.Entry ei : hklmap.entrySet()) {
        Object key = ei.getKey();
        HKL ih = (HKL) ei.getValue();

        ih.index(n);
        hkllist.add(ih);
        n++;
    }

    /*
     * set up the resolution bins
     * first build a histogram
     */
    for (HKL ih : hkllist) {
        double r = (Crystal.invressq(this.crystal, ih) - minres) / (maxres - minres);
        int i = (int) (min(r, 0.999) * 1000.0);
        hist[i + 1] += 1.0;
    }

    // convert to cumulative histogram
    for (int i = 1; i < hist.length; i++) {
        hist[i] += hist[i - 1];
    }
    for (int i = 0; i < hist.length; i++) {
        hist[i] /= hist[hist.length - 1];
    }

    // assign each reflection to a bin in the range (0-nbins)
    setResolutionBins(properties);
}

From source file:mase.spec.SafeHybridExchanger.java

@Override
protected double[][] computeMetapopDistances(EvolutionState state) {
    double[][] distances = new double[metaPops.size()][metaPops.size()];
    for (int i = 0; i < metaPops.size(); i++) {
        MetaPopulation mp1 = metaPops.get(i);
        for (int j = i + 1; j < metaPops.size(); j++) {
            MetaPopulation mp2 = metaPops.get(j);
            if (mp1.age >= stabilityTime && mp2.age >= stabilityTime) {
                double diff1 = fitnessDifference(mp1, mp2, state);
                double diff2 = fitnessDifference(mp2, mp1, state);
                //distances[i][j] = distances[j][i] = (diff1 + diff2) / 2;
                distances[i][j] = distances[j][i] = Math.min(diff1, diff2);
            } else {
                distances[i][j] = distances[j][i] = Double.POSITIVE_INFINITY;
            }//from   w w w . ja  v  a2 s .  co m
        }
        distances[i][i] = 0;
    }

    return distances;
}

From source file:com.analog.lyric.dimple.factorfunctions.InverseGamma.java

@Override
public final double evalEnergy(Value[] arguments) {
    int index = 0;
    if (!_parametersConstant) {
        _alpha = arguments[index++].getDouble(); // First input is alpha parameter (must be non-negative)
        if (_alpha <= 0)
            return Double.POSITIVE_INFINITY;
        _beta = arguments[index++].getDouble(); // Second input is beta parameter (must be non-negative)
        if (_beta <= 0)
            return Double.POSITIVE_INFINITY;
        _alphaPlusOne = _alpha + 1;/*from ww w. j  a va  2 s. c om*/
        _logGammaAlphaMinusAlphaLogBeta = org.apache.commons.math3.special.Gamma.logGamma(_alpha)
                - _alpha * Math.log(_beta);
    }
    final int length = arguments.length;
    final int N = length - index; // Number of non-parameter variables
    double sum = 0;
    for (; index < length; index++) {
        final double x = arguments[index].getDouble(); // Remaining inputs are Inverse Gamma variables
        if (x <= 0)
            return Double.POSITIVE_INFINITY;
        else
            sum += _beta / x + _alphaPlusOne * Math.log(x);
    }
    return sum + N * _logGammaAlphaMinusAlphaLogBeta;
}

From source file:edu.umd.cs.psl.model.kernel.predicateconstraint.GroundPredicateConstraint.java

@Override
public double getIncompatibility() {
    double sum = 0.0;
    for (Atom atom : atoms) {
        sum += atom.getSoftValue(0);//from  w  ww .  ja  v a 2s . c o  m
    }
    if (template.getConstraintType().constraintHolds(sum)) {
        return 0.0;
    } else
        return Double.POSITIVE_INFINITY;
}

From source file:com.opengamma.analytics.financial.model.finitedifference.applications.TwoStateMarkovChainFitter.java

public LeastSquareResultsWithTransform fit(final ForwardCurve forward,
        final List<Pair<double[], Double>> marketVols, final DoubleMatrix1D initialGuess) {

    Validate.isTrue(initialGuess.getNumberOfElements() == TRANSFORMS.getNumberOfModelParameters());
    TRANSFORMS.transform(initialGuess);/*from   w  w  w.java 2  s .  c om*/

    final int nMarketValues = marketVols.size();
    double tminT = Double.POSITIVE_INFINITY;
    double tminK = Double.POSITIVE_INFINITY;
    double tmaxT = 0;
    double tmaxK = 0;

    for (int i = 0; i < nMarketValues; i++) {
        final double[] tk = marketVols.get(i).getFirst();

        if (tk[0] > tmaxT) {
            tmaxT = tk[0];
        }
        if (tk[0] < tminT) {
            tminT = tk[0];
        }
        if (tk[1] > tmaxK) {
            tmaxK = tk[1];
        }
        if (tk[1] < tminK) {
            tminK = tk[1];
        }
    }

    final double minT = 0.6 * tminT;
    final double minK = 0.9 * tminK;
    final double maxT = 1.0 * tmaxT;
    final double maxK = 1.1 * tmaxK;

    final int tNodes = 20;
    final int xNodes = 100;

    //TODO remove hard coded grid
    final MeshingFunction timeMesh = new ExponentialMeshing(0, tmaxT, tNodes, 5.0);
    final MeshingFunction spaceMesh = new HyperbolicMeshing(0, 10.0 * forward.getForward(maxT),
            forward.getSpot(), xNodes, 0.01);
    final PDEGrid1D grid = new PDEGrid1D(timeMesh, spaceMesh);

    final Function1D<DoubleMatrix1D, DoubleMatrix1D> funcAppox = new Function1D<DoubleMatrix1D, DoubleMatrix1D>() {

        @SuppressWarnings("synthetic-access")
        @Override
        public DoubleMatrix1D evaluate(final DoubleMatrix1D x) {
            final DoubleMatrix1D y = TRANSFORMS.inverseTransform(x);
            final double vol1 = y.getEntry(0);
            final double deltaVol = y.getEntry(1);
            final double lambda12 = y.getEntry(2);
            final double lambda21 = y.getEntry(3);
            final double p0 = y.getEntry(4);
            final double beta = y.getEntry(5);

            final double[] modVols = new double[nMarketValues];
            for (int i = 0; i < nMarketValues; i++) {
                final double[] temp = marketVols.get(i).getFirst();
                final double t = temp[0];
                final double k = temp[1];
                final EuropeanVanillaOption option = new EuropeanVanillaOption(k, t, true);
                final BlackFunctionData data = new BlackFunctionData(forward.getForward(t), 1.0, 0.0);
                final MarkovChainApprox mca = new MarkovChainApprox(vol1, vol1 + deltaVol, lambda12, lambda21,
                        p0, t);
                final double price = mca.priceCEV(data.getForward(), data.getDiscountFactor(), k, beta);
                try {
                    modVols[i] = BLACK_IMPLIED_VOL.getImpliedVolatility(data, option, price);
                } catch (final Exception e) {
                    modVols[i] = 0.0;
                    //System.out.println("arrrgggg");
                }
            }
            //debug(DataBundle);
            return new DoubleMatrix1D(modVols);
        }
    };

    final Function1D<DoubleMatrix1D, DoubleMatrix1D> func = new Function1D<DoubleMatrix1D, DoubleMatrix1D>() {

        @SuppressWarnings("synthetic-access")
        @Override
        public DoubleMatrix1D evaluate(final DoubleMatrix1D x) {
            //        long timer = System.nanoTime();
            final DoubleMatrix1D y = TRANSFORMS.inverseTransform(x);
            final double vol1 = y.getEntry(0);
            final double deltaVol = y.getEntry(1);
            final double lambda12 = y.getEntry(2);
            final double lambda21 = y.getEntry(3);
            final double p0 = y.getEntry(4);
            final double beta = y.getEntry(5);
            final TwoStateMarkovChainDataBundle chainData = new TwoStateMarkovChainDataBundle(vol1,
                    vol1 + deltaVol, lambda12, lambda21, p0, beta, beta);
            final TwoStateMarkovChainPricer mc = new TwoStateMarkovChainPricer(forward, chainData);
            //        long timer1 = System.nanoTime();
            final PDEFullResults1D res = mc.solve(grid, _theta);
            //        System.out.println("time1 " + ((System.nanoTime() - timer1)/1e6)+"ms");
            //        long timer2 = System.nanoTime();
            final Map<DoublesPair, Double> data = PDEUtilityTools.priceToImpliedVol(forward, res, minT, maxT,
                    minK, maxK, true);
            //        System.out.println("time2 " + ((System.nanoTime() - timer2)/1e6)+"ms");
            //        long timer3 = System.nanoTime();
            final Map<Double, Interpolator1DDataBundle> dataBundle = GRID_INTERPOLATOR2D.getDataBundle(data);
            final double[] modVols = new double[nMarketValues];
            for (int i = 0; i < nMarketValues; i++) {
                final double[] temp = marketVols.get(i).getFirst();
                final DoublesPair tk = new DoublesPair(temp[0], temp[1]);
                try {
                    modVols[i] = GRID_INTERPOLATOR2D.interpolate(dataBundle, tk);
                } catch (final Exception e) {
                    System.out.println("arrrgggg");
                }
            }
            //        System.out.println("time3 " + ((System.nanoTime() - timer3)/1e6)+"ms");
            //        System.out.println("time " + ((System.nanoTime() - timer)/1e6)+"ms");
            //debug(DataBundle);
            return new DoubleMatrix1D(modVols);
        }

    };

    final double[] mrkVols = new double[nMarketValues];
    final double[] sigma = new double[nMarketValues];
    for (int i = 0; i < nMarketValues; i++) {
        mrkVols[i] = marketVols.get(i).getSecond();
        sigma[i] = 0.01; //1% error
    }

    final NonLinearLeastSquare ls = new NonLinearLeastSquare();
    //solve approx first
    LeastSquareResults solverRes = ls.solve(new DoubleMatrix1D(mrkVols), new DoubleMatrix1D(sigma), funcAppox,
            TRANSFORMS.transform(initialGuess));
    // now solve pde model
    solverRes = ls.solve(new DoubleMatrix1D(mrkVols), new DoubleMatrix1D(sigma), func,
            solverRes.getFitParameters());
    return new LeastSquareResultsWithTransform(solverRes, TRANSFORMS);
    // return new LeastSquareResults(solverRes.getChiSq(), TRANSFORMS.inverseTransform(solverRes.getFitParameters()), solverRes.getCovariance());
}

From source file:MPC.ModelLP.java

public ModelLP(int D, double time, int N, double Delta, double Umax, List<Point2D[]> obstacles,
        Point2D... points) throws IloException {
    this.D = D;//from  w  ww. j av  a 2 s. c  o  m
    this.N = N;
    this.Delta = Delta;
    double delta = this.Delta / (N * obstacles.size());
    this.erfInverse = erfInv(1 - 2 * delta) / 10;
    sigmaMatrix(0.03, 0);

    // Create the enviroment
    cplex = new IloCplex();

    // Define the control variables
    u = new IloNumVar[N - 1][D];
    for (int n = 0; n < N - 1; n++) {
        for (int d = 0; d < D; d++) {
            u[n][d] = cplex.numVar(-Umax, +Umax, "u(" + n + "," + d + ")");
        }
    }

    // Define the state variables
    x = new IloNumVar[N][2 * D];
    for (int n = 0; n < N; n++) {
        for (int d = 0; d < 2 * D; d++) {
            x[n][d] = cplex.numVar(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
                    "x(" + n + "," + d + ")");
        }
    }

    pen = cplex.numVar(0, Double.POSITIVE_INFINITY, "penality");

    IloNumExpr obj = null;
    for (int n = 0; n < N - 1; n++) {
        for (int d = 0; d < D; d++) {
            if (obj == null) {
                obj = cplex.prod(u[n][d], u[n][d]);
            } else {
                obj = cplex.sum(obj, cplex.prod(u[n][d], u[n][d]));
            }
        }
    }
    obj = cplex.sum(obj, cplex.prod(1000, pen));
    cplex.addMinimize(obj);

    // Dynamic equations: x(n+1) = A x(n) + B u(n)
    final double dt = time / N;
    final double A[][] = A(D, dt);
    final double B[][] = B(D, dt);
    for (int n = 0; n < N - 1; n++) {
        for (int d = 0; d < 2 * D; d++) {
            IloNumExpr expr = null;
            //A x(n)
            for (int j = 0; j < 2 * D; j++) {
                if (expr == null) {
                    expr = cplex.prod(A[d][j], x[n][j]);
                } else {
                    expr = cplex.sum(expr, cplex.prod(A[d][j], x[n][j]));
                }
            }
            //B u(n)
            for (int j = 0; j < D; j++) {
                expr = cplex.sum(expr, cplex.prod(B[d][j], u[n][j]));
            }
            cplex.addEq(x[n + 1][d], expr, "dy(" + n + "," + d + ")");
        }
    }
    //spatial restrictions: H x(n) <= b
    Hyperplane h[] = Hyperplane.hyperplansFrom(D > 2, points);
    for (int n = 0; n < N; n++) {
        for (int i = 0; i < h.length; i++) {
            //h(i) x(n) <= b
            IloNumExpr expr = h[i].scalProd(cplex, x[n]);
            cplex.addLe(expr, cplex.sum(h[i].b, pen), "sr(" + n + "," + i + ")");
        }
    }
    z = new IloNumVar[obstacles.size()][N][];
    // obstacles constraints
    for (int r = 0; r < obstacles.size(); ++r) {
        Hyperplane obstacle[] = Hyperplane.hyperplansFrom(D > 2, obstacles.get(r));
        for (int n = 0; n < N; n++) {
            IloNumExpr z_sum = null;
            z[r][n] = new IloNumVar[obstacle.length];
            for (int i = 0; i < obstacle.length; ++i) {
                //h(i) x(n) >= b - M(1-z(n,r))
                z[r][n][i] = cplex.boolVar("z(" + r + "," + n + "," + i + ")");
                if (z_sum == null) {
                    z_sum = z[r][n][i];
                } else {
                    z_sum = cplex.sum(z_sum, z[r][n][i]);
                }
                IloNumExpr expr = obstacle[i].scalProd(cplex, x[n]);
                IloNumExpr m = cplex.prod(10000, cplex.sum(-1, z[r][n][i]));
                double c = c_in(n, zeroFill(obstacle[i].a));
                cplex.addGe(expr, cplex.sum(obstacle[i].b + c, m), "obc(" + r + "," + n + "," + i + ")");
            }
            cplex.addGe(z_sum, 1, "sum(" + r + "," + n + ")");
        }
    }

    // Corner cutting constraints
    for (int r = 0; r < z.length; ++r) {
        for (int n = 1; n < z[r].length - 1; n++) {
            IloNumExpr p_sum = null;
            for (int i = 0; i < z[r][n].length; ++i) {
                IloNumVar p = cplex.numVar(0, Double.POSITIVE_INFINITY, "p(" + r + "," + n + "," + i + ")");

                // p(r,n,i) >= z(r,n,i) + p(r,n-1,i) - 1
                IloNumExpr expr;
                expr = cplex.sum(z[r][n][i], z[r][n - 1][i]);
                expr = cplex.sum(expr, -1);
                cplex.addGe(p, expr, "corner1(" + r + "," + n + "," + i + ")");

                // p(r,n,i) <= z(r,n,i)
                cplex.addLe(p, z[r][n][i], "corner2(" + r + "," + n + "," + i + ")");

                // p(r,n,i) <= z(r,n-1,i)
                cplex.addLe(p, z[r][n - 1][i], "corner3(" + r + "," + n + "," + i + ")");

                // sum_i p(r,n,i) >= 1 \forall r,n
                if (p_sum == null) {
                    p_sum = p;
                } else {
                    p_sum = cplex.sum(p_sum, p);
                }
            }
            cplex.addGe(p_sum, 1, "sump(" + r + "," + n + ")");
        }
    }
    cplex.exportModel("./model.lp");
}

From source file:com.rapidminer.operator.preprocessing.discretization.MinMaxBinDiscretization.java

@Override
public PreprocessingModel createPreprocessingModel(ExampleSet exampleSet) throws OperatorException {
    DiscretizationModel model = new DiscretizationModel(exampleSet);

    exampleSet.recalculateAllAttributeStatistics();
    int numberOfBins = getParameterAsInt(PARAMETER_NUMBER_OF_BINS);
    HashMap<Attribute, double[]> ranges = new HashMap<Attribute, double[]>();

    double min = getParameterAsDouble(PARAMETER_MIN_VALUE);
    double max = getParameterAsDouble(PARAMETER_MAX_VALUE);
    if (min > max) {
        throw new UserError(this, 116, PARAMETER_MIN_VALUE + " and " + PARAMETER_MAX_VALUE,
                "minimum must be less than maximum");
    }/*from w ww .ja  v  a 2 s  .c  o  m*/
    for (Attribute attribute : exampleSet.getAttributes()) {
        if (attribute.isNumerical()) { // skip nominal and date attributes
            double[] binRange = new double[numberOfBins + 2];
            binRange[0] = min;
            for (int b = 1; b < numberOfBins; b++) {
                binRange[b] = min + (((double) b / (double) numberOfBins) * (max - min));
            }
            binRange[numberOfBins] = max;
            binRange[numberOfBins + 1] = Double.POSITIVE_INFINITY;
            ranges.put(attribute, binRange);
        }
    }

    // determine number of digits
    int numberOfDigits = -1;
    if (getParameterAsBoolean(PARAMETER_AUTOMATIC_NUMBER_OF_DIGITS) == false) {
        numberOfDigits = getParameterAsInt(PARAMETER_NUMBER_OF_DIGITS);
    }

    model.setRanges(ranges, "range", getParameterAsInt(PARAMETER_RANGE_NAME_TYPE), numberOfDigits);
    return (model);
}