当前位置: 首页>>代码示例>>Java>>正文


Java Evaluator类代码示例

本文整理汇总了Java中beast.core.util.Evaluator的典型用法代码示例。如果您正苦于以下问题:Java Evaluator类的具体用法?Java Evaluator怎么用?Java Evaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Evaluator类属于beast.core.util包,在下文中一共展示了Evaluator类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: search_interval

import beast.core.util.Evaluator; //导入依赖的package包/类
double search_interval(Evaluator E, double x0, RealParameter X, Double L, Double R, double logy) {
    //	assert evaluate(E,x0) > evaluate(E,L) && evaluate(E,x0) > evaluate(E,R);

    assert evaluate(E, X, x0) >= logy;
    assert L < R;
    assert L <= x0 && x0 <= R;

    double L0 = L, R0 = R;

    double gx0 = evaluate(E, X, x0);
    assert logy < gx0;

    double x1 = x0;
    for (int i = 0; i < 200; i++) {
        x1 = L + Randomizer.nextDouble() * (R - L);
        double gx1 = evaluate(E, X, x1);

        //	    System.err.println("    L0 = " + L0 + "   x0 = " + x0 + "   R0 = " + R0 + "   gx0 = " + gx0);
        //	    System.err.println("    L  = " + L  + "   x1 = " + x1 + "   R  = " + R0 + "   gx1 = " + gx1);
        //	    System.err.println("    logy  = " + logy);

        if (gx1 >= logy) return x1;

        if (x1 > x0)
            R = x1;
        else
            L = x1;
    }
    Log.warning.println("Warning!  Is size of the interval really ZERO?");
    //	double logy_x0 = evaluate(E,X,x0);
    Log.warning.println("    L0 = " + L0 + "   x0 = " + x0 + "   R0 = " + R0 + "   gx0 = " + gx0);
    Log.warning.println("    L  = " + L + "   x1 = " + x1 + "   R  = " + R0 + "   gx1 = " + evaluate(E));

    return x0;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:36,代码来源:SliceOperator.java

示例2: evaluate

import beast.core.util.Evaluator; //导入依赖的package包/类
Double evaluate(Evaluator E) {
    return E.evaluate();
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:4,代码来源:SliceOperator.java

示例3: find_slice_boundaries_stepping_out

import beast.core.util.Evaluator; //导入依赖的package包/类
Double[] find_slice_boundaries_stepping_out(Evaluator E, RealParameter X, double logy, double w, int m) {
    double x0 = X.getValue(0);

    assert in_range(X, x0);

    double u = Randomizer.nextDouble() * w;
    Double L = x0 - u;
    Double R = x0 + (w - u);

    // Expand the interval until its ends are outside the slice, or until
    // the limit on steps is reached.

    if (m > 1) {
        int J = (int) Math.floor(Randomizer.nextDouble() * m);
        int K = (m - 1) - J;

        while (J > 0 && (!below_lower_bound(X, L)) && evaluate(E, X, L) > logy) {
            L -= w;
            J--;
        }

        while (K > 0 && (!above_upper_bound(X, R)) && evaluate(E, X, R) > logy) {
            R += w;
            K--;
        }
    } else {
        while ((!below_lower_bound(X, L)) && evaluate(E, X, L) > logy)
            L -= w;

        while ((!above_upper_bound(X, R)) && evaluate(E, X, R) > logy)
            R += w;
    }

    // Shrink interval to lower and upper bounds.

    if (below_lower_bound(X, L))
        L = X.getLower();
    if (above_upper_bound(X, R))
        R = X.getUpper();

    assert L < R;

    Double[] range = {L, R};
    return range;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:46,代码来源:SliceOperator.java

示例4: proposal

import beast.core.util.Evaluator; //导入依赖的package包/类
/**
 * override this for proposals,
 * returns log of hastingRatio, or Double.NEGATIVE_INFINITY if proposal should not be accepted *
 */
@Override
public double proposal(Evaluator E) {

    int m = 100;

    RealParameter X = parameterInput.get();

    // Find the density at the current point
    Double gx0 = evaluate(E);

    //	System.err.println("gx0 = " + gx0);
    // Get the 1st element
    Double x0 = X.getValue(0);
    //	System.err.println("x0 = " + x0);

    // Determine the slice level, in log terms.
    double logy = gx0 - Randomizer.nextExponential(1);

    // Find the initial interval to sample from.
    Double[] range = find_slice_boundaries_stepping_out(E, X, logy, windowSize, m);
    Double L = range[0];
    Double R = range[1];

    // Sample from the interval, shrinking it on each rejection
    double x_new = search_interval(E, x0, X, L, R, logy);
    X.setValue(x_new);

    if (n_learning_iterations > 0) {
        n_learning_iterations--;

        totalDelta += Math.abs(x_new - x0);
        totalNumber++;

        double W_predicted = totalDelta / totalNumber * 4.0;
        if (totalNumber > 3) {
            W = 0.95 * W + 0.05 * W_predicted;
            windowSize = W;
        }
        //	    System.err.println("W = " + W);
    }

    return Double.POSITIVE_INFINITY;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:48,代码来源:SliceOperator.java

示例5: proposal

import beast.core.util.Evaluator; //导入依赖的package包/类
/**
 * Implement this for proposing a new State.
 * The proposal is responsible for keeping the State valid,
 * and if the State becomes invalid (e.g. a parameter goes out
 * of its range) Double.NEGATIVE_INFINITY should be returned.
 * <p>
 * If the operator is a Gibbs operator, hence the proposal should
 * always be accepted, the method should return Double.POSITIVE_INFINITY.
 *
 * @param evaluator An evaluator object that can be use to repetitively
 *                  used to evaluate the distribution returned by getEvaluatorDistribution().
 * @return log of Hastings Ratio, or Double.NEGATIVE_INFINITY if proposal
 * should not be accepted (because the proposal is invalid) or
 * Double.POSITIVE_INFINITY if the proposal should always be accepted
 * (for Gibbs operators).
 */
public double proposal(final Evaluator evaluator) {
    return proposal();
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:20,代码来源:Operator.java


注:本文中的beast.core.util.Evaluator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。