當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。