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


Java Precision.round方法代码示例

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


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

示例1: getRoundedValue

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Rounds a value. If the given parameters has skip rounding, the value is
 * returned unchanged. If the given number of decimals is specified, the
 * value is rounded to the given decimals. If skip rounding is specified
 * in the given data query parameters, 10 decimals is used. Otherwise,
 * default rounding is used.
 * 
 * @param params the query parameters.
 * @param decimals the number of decimals.
 * @param value the value.
 * @return a double.
 */
public static Double getRoundedValue( DataQueryParams params, Integer decimals, Double value )
{
    if ( value == null )
    {
        return value;
    }
    else if ( params.isSkipRounding() )
    {
        return Precision.round( value, DECIMALS_NO_ROUNDING );
    }
    else if ( decimals != null && decimals > 0 )
    {
        return Precision.round( value, decimals );
    }
    else
    {
        return MathUtils.getRounded( value );
    }
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:32,代码来源:AnalyticsUtils.java

示例2: printResults

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
private void printResults(Map<String, Map<String, Sig>> sampleSigs, Map<String, Integer> geneSigs) {
    int j = 0;
    for (Map.Entry<String, Map<String, Sig>> entry : sampleSigs.entrySet()) {
        String sample = entry.getKey();
        int samplesNumber = sampleSigs.size();
        for (Map.Entry<String, Sig> sigs : entry.getValue().entrySet()) {
            String gene = sigs.getKey();
            Sig sig = sigs.getValue();
            Locus locus = genes.get(gene);
            StringBuilder locStr = new StringBuilder();

            locStr.append(sample).append("\t").append(gene).append("\t").append(locus.getName()).append("\t").append(Precision.round(sig.getLrMed(), 3)).append("\t");
            if (sig.getSig() != -1) {
                double bpPercent = 0.0;
                int bpNumber = 0;
                if (sig.getBp().equals("BP")) {
                    String key = (gene + " " + sig.getSigseg()).intern();
                    bpNumber = geneSigs.get(key);
                    bpPercent = Precision.round(bpNumber/(double)samplesNumber, 3);
                }
                if (Double.compare(bpPercent, 0.0) != 0 && Double.compare(bpPercent, MAXRATE) > 0
                        && bpNumber > MAXCNT) {
                    locStr.append("\t\t\t\t\t").append(sig.getTotal());
                } else {
                    locStr.append(sig.getName().append("\t").append(bpNumber).append("\t").append(bpPercent));
                }
            } else {
                locStr.append("\t\t\t\t").append(sig.getTotal());
            }
            if (j == 0)
                System.out.println("Sample\tGene\tChr\tStart\tEnd\tLength\tLog2ratio\tSig\tBP_Whole\tAmp_Del\tAb_Seg\tTotal_Seg\tAb_log2ratio\tLog2r_Diff\tAb_Seg_Loc\tAb_Samples\tAb_Samples_Pcnt");
            j++;


            System.out.println(locStr);
        }
    }
}
 
开发者ID:AstraZeneca-NGS,项目名称:Seq2CJava,代码行数:39,代码来源:Lr2gene.java

示例3: readCoverageAndGetMedDepth

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Read samples from coverage file, put them in map, calculates median depth and fill in map {@link Cov2lr#geneStatistics}
 * @param samp set of sample names from coverage file; empty
 * @return median depth
 */
//perl version: 63 str
double readCoverageAndGetMedDepth(Set<String> samp) {
    List<Double> depth = new ArrayList<>();
    CloseableIterator<Sample> iterator = getFileDataIterator();
    while (iterator.hasNext()) {
        Sample sample = iterator.next();
        double norm1 = Precision.round((sample.getCov() * factor.get(sample.getSample())), 2);
        depth.add(norm1);
        samp.add(sample.getSample());
        putInMap(sample, norm1); //perl version: 68 str
    }
    iterator.close();
    return median.evaluate(toDoubleArray(depth));
}
 
开发者ID:AstraZeneca-NGS,项目名称:Seq2CJava,代码行数:20,代码来源:Cov2lr.java

示例4: getRoundedValueObject

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Rounds a value. If the given parameters has skip rounding, the value is
 * returned unchanged. If the given number is null or not of class Double,
 * the value is returned unchanged. If skip rounding is specified in the
 * given data query parameters, 10 decimals is used. Otherwise, default
 * rounding is used.
 *
 * @param params the query parameters.
 * @param value the value.
 * @return a value.
 */
public static Object getRoundedValueObject( DataQueryParams params, Object value )
{
    if ( value == null || !Double.class.equals( value.getClass() ) )
    {
        return value;
    }
    else if ( params.isSkipRounding() )
    {
        return Precision.round( (Double) value, DECIMALS_NO_ROUNDING );
    }
    
    return MathUtils.getRounded( (Double) value );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:25,代码来源:AnalyticsUtils.java

示例5: roundSignificant

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Rounds a number, keeping at least 3 significant digits.
 * <p>
 * <ul>
 * <li>If value is >= 10 or <= -10 it will have 1 decimal.</li>
 * <li>If value is between -10 and 10 it will have three significant digits.</li>
 * </ul>
 *
 * @param value the value to round off.
 * @return a rounded off number.
 */
public static double roundSignificant( double value )
{
    if ( value >= 10.0 || value <= -10.0 )
    {
        return Precision.round( value, 1 );
    }
    else
    {
        return roundToSignificantDigits( value, 3 );
    }
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:23,代码来源:MathUtils.java

示例6: getNextRandomValue

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
@Override
public Double getNextRandomValue() {
    double range = max - min;
    double scaled = rand.nextDouble() * range;
    double shifted = scaled + min;

    return Precision.round(shifted, decimalPlaces);

}
 
开发者ID:acesinc,项目名称:json-data-generator,代码行数:10,代码来源:DoubleType.java

示例7: getRoundedGrade

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
public static String getRoundedGrade(Double theGrade, Double points) throws Exception {
	if ( theGrade < 0.0 || theGrade > 1.0 ) {
		throw new Exception("Grade out of range");
	}
	theGrade = theGrade * points;
	theGrade = Precision.round(theGrade,2);
	return String.valueOf(theGrade);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:9,代码来源:SakaiBLTIUtil.java

示例8: getPointsDisplayString

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * If we display the score, return it, followed by a slash.
 * 
 * @return either, a) the score followed by a slash, or, b) "" (empty
 *         string)
 */
public String getPointsDisplayString() {
	String pointsDisplayString = "";
	if (showStudentQuestionScore) {
		pointsDisplayString = Precision.round(points, 2) + "/";
	}
	return pointsDisplayString;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:14,代码来源:ItemContentsBean.java

示例9: getPointsDisplayString

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * If we display the score, return it, followed by a slash.
 * @return either, a) the score followed by a slash, or, b) "" (empty string)
 */
public String getPointsDisplayString()
{
  String pointsDisplayString = "";
  if (showStudentQuestionScore)
  {
    pointsDisplayString = Precision.round(points, 2) + "/";
  }
  return pointsDisplayString;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:14,代码来源:SectionContentsBean.java

示例10: getPointsDisplayString

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * If we display the current score, return it, otherwise an empty string.
 * Not currently used, provided if we need it later.
 * @return either, a) the current score, otherwise, b) "" (empty string)
 */
public String getPointsDisplayString()
{
 String pointsDisplayString = "";
 if (showStudentScore)
 {
  pointsDisplayString = "" + Precision.round(currentScore, 2);
 }
 return pointsDisplayString;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:15,代码来源:ContentsDeliveryBean.java

示例11: fromNanoTime

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
private static String fromNanoTime(double nanoTime)
{
  if (nanoTime > 1000000d) {
    return Precision.round(nanoTime/1000000d, PRECISION) + " millis";
  } else if (nanoTime > 1000d) {
    return Precision.round(nanoTime/1000d, PRECISION) + " micros";
  } else {
    return Precision.round(nanoTime, PRECISION) + " nanos";
  }
}
 
开发者ID:DataTorrent,项目名称:Netlet,代码行数:11,代码来源:BenchmarkResults.java

示例12: getHistory

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
@Override
public DataElementHistory getHistory( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
		DataElementCategoryOptionCombo attributeOptionCombo, OrganisationUnit organisationUnit, Period lastPeriod, int historyLength )
{
    if ( !dataElement.getValueType().isNumeric() )
    {
        return null; // TODO
    }

    // ---------------------------------------------------------------------
    // Initialise history
    // ---------------------------------------------------------------------

    DataElementHistory history = new DataElementHistory();
    history.setDataElement( dataElement );
    history.setOptionCombo( optionCombo );
    history.setAttributeOptionComboOptionCombo( attributeOptionCombo );
    history.setOrganisationUnit( organisationUnit );
    history.setHistoryLength( historyLength );
    addMinMaxLimits( organisationUnit, dataElement, optionCombo, history );

    // ---------------------------------------------------------------------
    // Create history points
    // ---------------------------------------------------------------------

    List<Period> periods = periodService.getPeriods( lastPeriod, historyLength );

    double max = 1;
    double average = 0;
    double total = 0;
    int count = 0;

    if ( history.getMaxLimit() != null )
    {
        max = Math.max( max, history.getMaxLimit() );
    }

    for ( Period period : periods )
    {
        DataElementHistoryPoint historyPoint = new DataElementHistoryPoint();
        historyPoint.setPeriod( period );

        Double value = getValue( dataElement, optionCombo, attributeOptionCombo, organisationUnit, period );

        if ( value != null )
        {
            historyPoint.setValue( value );
        }

        if ( historyPoint.getValue() != null )
        {
            max = Math.max( max, historyPoint.getValue() );
            total += historyPoint.getValue();
            average = total / ++count;
            average = Precision.round( average, 1 );
        }

        historyPoint.setAverage( average );

        history.getHistoryPoints().add( historyPoint );
    }

    history.setMaxHistoryValue( max );

    double maxValue = getMaxValue( history );

    if ( !MathUtils.equals( maxValue, Double.NEGATIVE_INFINITY ) )
    {
        history.setMaxValue( maxValue );

        double minValue = getMinValue( history );
        history.setMinValue( minValue );
    }

    return history;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:77,代码来源:DefaultHistoryRetriever.java

示例13: getHistory

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
@Override
public DataElementHistory getHistory( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
    OrganisationUnit organisationUnit, Period lastPeriod, int historyLength )
{
    if ( !dataElement.getValueType().isNumeric() )
    {
        return null; // TODO
    }

    // ---------------------------------------------------------------------
    // Initialise history
    // ---------------------------------------------------------------------

    DataElementHistory history = new DataElementHistory();
    history.setDataElement( dataElement );
    history.setOptionCombo( optionCombo );
    history.setOrganisationUnit( organisationUnit );
    history.setHistoryLength( historyLength );
    addMinMaxLimits( organisationUnit, dataElement, optionCombo, history );

    // ---------------------------------------------------------------------
    // Create history points
    // ---------------------------------------------------------------------

    List<Period> periods = periodService.getPeriods( lastPeriod, historyLength );

    double max = 1;
    double average = 0;
    double total = 0;
    int count = 0;

    if ( history.getMaxLimit() != null )
    {
        max = Math.max( max, history.getMaxLimit() );
    }

    for ( Period period : periods )
    {
        DataElementHistoryPoint historyPoint = new DataElementHistoryPoint();
        historyPoint.setPeriod( period );

        Double value = getValue( dataElement, optionCombo, organisationUnit, period );

        if ( value != null )
        {
            historyPoint.setValue( value );
        }

        if ( historyPoint.getValue() != null )
        {
            max = Math.max( max, historyPoint.getValue() );
            total += historyPoint.getValue();
            average = total / ++count;
            average = Precision.round( average, 1 );
        }

        historyPoint.setAverage( average );

        history.getHistoryPoints().add( historyPoint );
    }

    history.setMaxHistoryValue( max );

    double maxValue = getMaxValue( history );

    if ( !MathUtils.equals( maxValue, Double.NEGATIVE_INFINITY ) )
    {
        history.setMaxValue( maxValue );

        double minValue = getMinValue( history );
        history.setMinValue( minValue );
    }

    return history;
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:76,代码来源:DefaultHistoryRetriever.java

示例14: updateExternalAssessmentScore

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
 * Update the grading of the assessment.
 * @param ag the assessment grading.
 * @param g  the Gradebook Service
 * @throws java.lang.Exception
 */
public void updateExternalAssessmentScore(AssessmentGradingData ag,
  GradebookExternalAssessmentService g) throws
  Exception
{
  boolean testErrorHandling=false;
  PublishedAssessmentService pubService = new PublishedAssessmentService();
  GradingService gradingService = new GradingService();

  //Following line seems just for the need of getting publishedAssessmentId
  //use ag.getPublishedAssessmentId() instead of pub.getPublishedAssessmentId() to
  //get publishedAssessmentId 
  //comment out following 3 lines since it returns null for not submitted students which we 
  //need not save to assessmentgrading table but will need to notify gradebook only  
  
 /* PublishedAssessmentIfc pub = (PublishedAssessmentIfc) gradingService.getPublishedAssessmentByAssessmentGradingId(ag.getAssessmentGradingId().toString());

  String gradebookUId = pubService.getPublishedAssessmentOwner(
         pub.getPublishedAssessmentId());*/
  String gradebookUId = pubService.getPublishedAssessmentOwner(
          ag.getPublishedAssessmentId());
  if (gradebookUId == null)
  {
    return;
  }
  
  //Will pass to null value when last submission is deleted
  String points = null;
  if(ag.getFinalScore() != null) {
      //SAM-1562 We need to round the double score and covert to a double -DH
      double fScore = Precision.round(ag.getFinalScore(), 2);
      Double score = Double.valueOf(fScore).doubleValue();
      points = score.toString();
      log.info("rounded:  " + ag.getFinalScore() + " to: " + score.toString() );
  }
  g.updateExternalAssessmentScore(gradebookUId,
    ag.getPublishedAssessmentId().toString(),
    ag.getAgentId(),  points);
  if (testErrorHandling){
    throw new Exception("Encountered an error in update ExternalAssessmentScore.");
  }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:48,代码来源:GradebookServiceHelperImpl.java

示例15: getUpdatedScore

import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
public Double getUpdatedScore () {
    if (itemData.getScore() == null)
 return 0.0;
    else
 return Precision.round(itemData.getScore(), 2);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:7,代码来源:ItemContentsBean.java


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