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


Java Precision.equalsIncludingNaN方法代码示例

本文整理汇总了Java中org.apache.commons.math3.util.Precision.equalsIncludingNaN方法的典型用法代码示例。如果您正苦于以下问题:Java Precision.equalsIncludingNaN方法的具体用法?Java Precision.equalsIncludingNaN怎么用?Java Precision.equalsIncludingNaN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.util.Precision的用法示例。


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

示例1: equals

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Returns true iff <code>object</code> is a
 * <code>StatisticalSummaryValues</code> instance and all statistics have
 *  the same values as this.
 *
 * @param object the object to test equality against.
 * @return true if object equals this
 */
@Override
public boolean equals(Object object) {
    if (object == this ) {
        return true;
    }
    if (object instanceof StatisticalSummaryValues == false) {
        return false;
    }
    StatisticalSummaryValues stat = (StatisticalSummaryValues) object;
    return Precision.equalsIncludingNaN(stat.getMax(),      getMax())  &&
           Precision.equalsIncludingNaN(stat.getMean(),     getMean()) &&
           Precision.equalsIncludingNaN(stat.getMin(),      getMin())  &&
           Precision.equalsIncludingNaN(stat.getN(),        getN())    &&
           Precision.equalsIncludingNaN(stat.getSum(),      getSum())  &&
           Precision.equalsIncludingNaN(stat.getVariance(), getVariance());
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:25,代码来源:StatisticalSummaryValues.java

示例2: equals

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Returns true iff <code>object</code> is a
 * <code>SummaryStatistics</code> instance and all statistics have the
 * same values as this.
 * @param object the object to test equality against.
 * @return true if object equals this
 */
@Override
public boolean equals(Object object) {
    if (object == this) {
        return true;
    }
    if (object instanceof SummaryStatistics == false) {
        return false;
    }
    SummaryStatistics stat = (SummaryStatistics)object;
    return Precision.equalsIncludingNaN(stat.getGeometricMean(), getGeometricMean()) &&
           Precision.equalsIncludingNaN(stat.getMax(),           getMax())           &&
           Precision.equalsIncludingNaN(stat.getMean(),          getMean())          &&
           Precision.equalsIncludingNaN(stat.getMin(),           getMin())           &&
           Precision.equalsIncludingNaN(stat.getN(),             getN())             &&
           Precision.equalsIncludingNaN(stat.getSum(),           getSum())           &&
           Precision.equalsIncludingNaN(stat.getSumsq(),         getSumsq())         &&
           Precision.equalsIncludingNaN(stat.getVariance(),      getVariance());
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:SummaryStatistics.java

示例3: equals

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Returns true iff <code>object</code> is a <code>MultivariateSummaryStatistics</code>
 * instance and all statistics have the same values as this.
 * @param object the object to test equality against.
 * @return true if object equals this
 */
@Override
public boolean equals(Object object) {
    if (object == this ) {
        return true;
    }
    if (object instanceof MultivariateSummaryStatistics == false) {
        return false;
    }
    MultivariateSummaryStatistics stat = (MultivariateSummaryStatistics) object;
    return MathArrays.equalsIncludingNaN(stat.getGeometricMean(), getGeometricMean()) &&
           MathArrays.equalsIncludingNaN(stat.getMax(),           getMax())           &&
           MathArrays.equalsIncludingNaN(stat.getMean(),          getMean())          &&
           MathArrays.equalsIncludingNaN(stat.getMin(),           getMin())           &&
           Precision.equalsIncludingNaN(stat.getN(),             getN())             &&
           MathArrays.equalsIncludingNaN(stat.getSum(),           getSum())           &&
           MathArrays.equalsIncludingNaN(stat.getSumSq(),         getSumSq())         &&
           MathArrays.equalsIncludingNaN(stat.getSumLog(),        getSumLog())        &&
           stat.getCovariance().equals( getCovariance());
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:MultivariateSummaryStatistics.java

示例4: replaceAndSlice

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Replace every occurrence of a given value with a replacement value in a
 * copied slice of array defined by array part from [begin, begin+length).
 * @param values the input array
 * @param begin start index of the array to include
 * @param length number of elements to include from begin
 * @param original the value to be replaced with
 * @param replacement the value to be used for replacement
 * @return the copy of sliced array with replaced values
 */
private static double[] replaceAndSlice(final double[] values,
                                        final int begin, final int length,
                                        final double original,
                                        final double replacement) {
    final double[] temp = copyOf(values, begin, length);
    for(int i = 0; i < length; i++) {
        temp[i] = Precision.equalsIncludingNaN(original, temp[i]) ?
                  replacement : temp[i];
    }
    return temp;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:22,代码来源:Percentile.java

示例5: removeAndSlice

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Remove the occurrence of a given value in a copied slice of array
 * defined by the array part from [begin, begin+length).
 * @param values the input array
 * @param begin start index of the array to include
 * @param length number of elements to include from begin
 * @param removedValue the value to be removed from the sliced array
 * @return the copy of the sliced array after removing the removedValue
 */
private static double[] removeAndSlice(final double[] values,
                                       final int begin, final int length,
                                       final double removedValue) {
    MathArrays.verifyValues(values, begin, length);
    final double[] temp;
    //BitSet(length) to indicate where the removedValue is located
    final BitSet bits = new BitSet(length);
    for (int i = begin; i < begin+length; i++) {
        if (Precision.equalsIncludingNaN(removedValue, values[i])) {
            bits.set(i - begin);
        }
    }
    //Check if empty then create a new copy
    if (bits.isEmpty()) {
        temp = copyOf(values, begin, length); // Nothing removed, just copy
    } else if(bits.cardinality() == length){
        temp = new double[0];                 // All removed, just empty
    }else {                                   // Some removable, so new
        temp = new double[length - bits.cardinality()];
        int start = begin;  //start index from source array (i.e values)
        int dest = 0;       //dest index in destination array(i.e temp)
        int nextOne = -1;   //nextOne is the index of bit set of next one
        int bitSetPtr = 0;  //bitSetPtr is start index pointer of bitset
        while ((nextOne = bits.nextSetBit(bitSetPtr)) != -1) {
            final int lengthToCopy = nextOne - bitSetPtr;
            System.arraycopy(values, start, temp, dest, lengthToCopy);
            dest += lengthToCopy;
            start = begin + (bitSetPtr = bits.nextClearBit(nextOne));
        }
        //Copy any residue past start index till begin+length
        if (start < begin + length) {
            System.arraycopy(values,start,temp,dest,begin + length - start);
        }
    }
    return temp;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:46,代码来源:Percentile.java

示例6: equals

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Returns true iff <code>object</code> is an
 * <code>AbstractStorelessUnivariateStatistic</code> returning the same
 * values as this for <code>getResult()</code> and <code>getN()</code>
 * @param object object to test equality against.
 * @return true if object returns the same value as this
 */
@Override
public boolean equals(Object object) {
    if (object == this ) {
        return true;
    }
   if (object instanceof AbstractStorelessUnivariateStatistic == false) {
        return false;
    }
    AbstractStorelessUnivariateStatistic stat = (AbstractStorelessUnivariateStatistic) object;
    return Precision.equalsIncludingNaN(stat.getResult(), this.getResult()) &&
           Precision.equalsIncludingNaN(stat.getN(), this.getN());
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:20,代码来源:AbstractStorelessUnivariateStatistic.java

示例7: assertEquals

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/** verifies that two arrays are close (sup norm) */
public static void assertEquals(String msg, double[] expected, double[] observed, double tolerance) {
    StringBuilder out = new StringBuilder(msg);
    if (expected.length != observed.length) {
        out.append("\n Arrays not same length. \n");
        out.append("expected has length ");
        out.append(expected.length);
        out.append(" observed length = ");
        out.append(observed.length);
        Assert.fail(out.toString());
    }
    boolean failure = false;
    for (int i=0; i < expected.length; i++) {
        if (!Precision.equalsIncludingNaN(expected[i], observed[i], tolerance)) {
            failure = true;
            out.append("\n Elements at index ");
            out.append(i);
            out.append(" differ. ");
            out.append(" expected = ");
            out.append(expected[i]);
            out.append(" observed = ");
            out.append(observed[i]);
        }
    }
    if (failure) {
        Assert.fail(out.toString());
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:29,代码来源:TestUtils.java

示例8: notifyGradebook

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
public void notifyGradebook(AssessmentGradingData data, PublishedAssessmentIfc pub) throws GradebookServiceException {
   // If the assessment is published to the gradebook, make sure to update the scores in the gradebook
   String toGradebook = pub.getEvaluationModel().getToGradeBook();

   GradebookExternalAssessmentService g = null;
   boolean integrated = IntegrationContextFactory.getInstance().isIntegrated();
   if (integrated)
   {
     g = (GradebookExternalAssessmentService) SpringBeanLocator.getInstance().
       getBean("org.sakaiproject.service.gradebook.GradebookExternalAssessmentService");
   }

   GradebookServiceHelper gbsHelper =
     IntegrationContextFactory.getInstance().getGradebookServiceHelper();

   PublishedAssessmentService publishedAssessmentService = new PublishedAssessmentService();
String currentSiteId = publishedAssessmentService.getPublishedAssessmentSiteId(pub.getPublishedAssessmentId().toString());
   if (gbsHelper.gradebookExists(GradebookFacade.getGradebookUId(currentSiteId), g)
       && toGradebook.equals(EvaluationModelIfc.TO_DEFAULT_GRADEBOOK.toString())){
       if(log.isDebugEnabled()) log.debug("Attempting to update a score in the gradebook");

   // add retry logic to resolve deadlock problem while sending grades to gradebook

   Double originalFinalScore = data.getFinalScore();
   int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount();
   while (retryCount > 0){
   	try {
   		// Send the average score if average was selected for multiple submissions
   		Integer scoringType = pub.getEvaluationModel().getScoringType();
   		if (scoringType.equals(EvaluationModelIfc.AVERAGE_SCORE)) {
   			// status = 5: there is no submission but grader update something in the score page
   			if(data.getStatus() ==5) {
   				data.setFinalScore(data.getFinalScore());
   			} else {
   				Double averageScore = PersistenceService.getInstance().getAssessmentGradingFacadeQueries().
   				getAverageSubmittedAssessmentGrading(pub.getPublishedAssessmentId(), data.getAgentId());
   				data.setFinalScore(averageScore);
   			}
   		}
   		gbsHelper.updateExternalAssessmentScore(data, g);
   		retryCount = 0;
   	}
     catch (org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException ante) {
   	  log.warn("problem sending grades to gradebook: {}", ante.getMessage());
         if (AssessmentIfc.RETRACT_FOR_EDIT_STATUS.equals(pub.getStatus())) {
       	  retryCount = retry(retryCount, ante, pub, true);
         }
         else {
       	  // Otherwise, do the same exeption handling as others
       	  retryCount = retry(retryCount, ante, pub, false);
         }
     }
     catch (Exception e) {
   	  retryCount = retry(retryCount, e, pub, false);
     }
   }

   // change the final score back to the original score since it may set to average score.
   // if we're deleting the last submission, the score might be null bugid 5440
   if(originalFinalScore != null && data.getFinalScore() != null && !(Precision.equalsIncludingNaN(data.getFinalScore(), originalFinalScore, 0.0001))) {
   	data.setFinalScore(originalFinalScore);
   }
   
   try {
       	Long publishedAssessmentId = data.getPublishedAssessmentId();
       	String agent = data.getAgentId();
       	String comment = data.getComments();
       	gbsHelper.updateExternalAssessmentComment(publishedAssessmentId, agent, comment, g);
   }
   catch (Exception ex) {
         log.warn("Error sending comments to gradebook: {}", ex.getMessage());
         }
   } else {
      log.debug("Not updating the gradebook.  toGradebook = {}", toGradebook);
   }
 }
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:77,代码来源:GradingService.java


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