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


Java ResizableDoubleArray类代码示例

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


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

示例1: aggregateSubjects

import org.apache.commons.math3.util.ResizableDoubleArray; //导入依赖的package包/类
private Double aggregateSubjects(MathArrays.Function aggregator, List<Subject> aggregationSubjects) throws IncomputableFieldException {
    ResizableDoubleArray doubles = new ResizableDoubleArray();

    for (Subject subject : aggregationSubjects) {
        try {
            doubles.addElement(Double.parseDouble(singleValueField.valueForSubject(subject, true)));
        } catch (IncomputableFieldException e) {
            log.warn("Incomputable field not included in aggregation for subject {} ({})",
                    subject.getName(),
                    subject.getId());
        }
    }

    Double retVal = doubles.compute(aggregator);

    if (retVal.isNaN()) {
        throw new IncomputableFieldException(String.format("Aggregation function %s returned NaN (possible division by zero?)", function));
    } else if (retVal.isInfinite()) {
        throw new IncomputableFieldException(String.format("Aggregation function %s returned Infinity (possible division by zero?)", function));
    }

    return retVal;
}
 
开发者ID:FutureCitiesCatapult,项目名称:TomboloDigitalConnector,代码行数:24,代码来源:GeographicAggregationField.java

示例2: getDoubleValueForSubject

import org.apache.commons.math3.util.ResizableDoubleArray; //导入依赖的package包/类
private Double getDoubleValueForSubject(Subject subject) throws IncomputableFieldException {
    // Check for cached value
    String cachedValue = getCachedValue(subject);
    if (cachedValue != null)
        return Double.parseDouble(cachedValue);

    // Initialise
    if (null == singleValueFields)
        initialize();

    // Calculate statistic
    ResizableDoubleArray doubles = new ResizableDoubleArray();

    for (Field field : singleValueFields){
        try {
            doubles.addElement(Double.parseDouble(((SingleValueField) field).valueForSubject(subject, null)));
        }catch (IncomputableFieldException e){
            log.warn("Incomputable field not included in statistics for subject {} ({})",
                    subject.getName(),
                    subject.getId());
        }
    }

    Double descriptiveStaistic = doubles.compute(statistic.getStatistic());

    if (descriptiveStaistic.isNaN()) {
        throw new IncomputableFieldException(String.format(
                "Descriptive statistics function %s returned NaN",
                statistic.getStatistic().getClass().getSimpleName()));
    } else if (descriptiveStaistic.isInfinite()) {
        throw new IncomputableFieldException(String.format(
                "Descriptive statistics function {} returned Infinity",
                statistic.getStatistic().getClass().getSimpleName()));
    }

    return descriptiveStaistic;
}
 
开发者ID:FutureCitiesCatapult,项目名称:TomboloDigitalConnector,代码行数:38,代码来源:DescriptiveStatisticsField.java

示例3: getData

import org.apache.commons.math3.util.ResizableDoubleArray; //导入依赖的package包/类
private ResizableDoubleArray getData()throws SQLException{
    Statement stmt = null;
    ResultSet rs = null;
    ResizableDoubleArray data = new ResizableDoubleArray((int)(maxProgress/2.0));

    try{
        //connect to table to create data set to be ranked
        Table sqlTable = new Table(tableName.getNameForDatabase());
        SelectQuery select = new SelectQuery();
        select.addColumn(sqlTable, variable.getName().nameForDatabase());
        stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        rs=stmt.executeQuery(select.toString());

        String vNameDb = variable.getName().nameForDatabase();

        double x = Double.NaN;
        int dbIndex = 0;//row position index for all records in db
        while(rs.next()){
            x = rs.getDouble(vNameDb);
            if(!rs.wasNull()){
                if(ascending){
                    data.addElement(x);//ascending order
                }else{
                    data.addElement(-x);//descending order
                }

            }else{
                missingIndex.add(dbIndex);
            }
            dbIndex++;
            updateProgress();
        }
        return data;
    }catch(SQLException ex){
        throw ex;
    }finally{
        if(rs!=null) rs.close();
        if(stmt!=null) stmt.close();

    }
}
 
开发者ID:meyerjp3,项目名称:jmetrik,代码行数:42,代码来源:RankingAnalysis.java

示例4: compute

import org.apache.commons.math3.util.ResizableDoubleArray; //导入依赖的package包/类
public String compute()throws SQLException{
    Statement stmt = null;
    ResultSet rs = null;

    try{
        //get data
        ResizableDoubleArray data = getData();

        //create columns - dao uses its own transaction
        int numberOfColumns = dao.getColumnCount(conn, tableName);
        int columnNumber = numberOfColumns+1;
        String newVariableLabel = "Rank";
        if(blom) newVariableLabel = "Blom Normal Score";
        if(tukey) newVariableLabel = "Tukey Normal Score";
        if(vdw) newVariableLabel = "van der Waerden Normal Score";
        if(ntiles) newVariableLabel = "Quantiles: " + numGroups + " groups";
        newVariable = new VariableAttributes(newVariableName, newVariableLabel, ItemType.NOT_ITEM, DataType.DOUBLE, columnNumber++, "");

        dao.addColumnToDb(conn, tableName, newVariable);

        //compute ranks
        NaturalRanking ranking = new NaturalRanking(NaNStrategy.REMOVED, tiesStrategy);
        double[] ranks = ranking.rank(data.getElements());

        //begin transaction
        conn.setAutoCommit(false);

        //connect to table and update values
        SelectQuery select = new SelectQuery();
        Table sqlTable = new Table(tableName.getNameForDatabase());
        select.addColumn(sqlTable, newVariable.getName().nameForDatabase());
        stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
        rs=stmt.executeQuery(select.toString());

        int nRanks = ranks.length;
        int rankIndex = 0;//array index for ranks (missing values not included)
        int dbIndex = 0;//db row position for case (missing values included)
        double r = Double.NaN;
        boolean missing = false;
        String tempName = "";
        while(rs.next()){
            missing = missingIndex.contains(dbIndex);
            if(missing){
                rs.updateNull(newVariable.getName().nameForDatabase());
            }else{
                r = ranks[rankIndex];
                if(blom){
                    rs.updateDouble(newVariable.getName().nameForDatabase(), normScore.blom(r, (double)nRanks));
                }else if (tukey){
                    rs.updateDouble(newVariable.getName().nameForDatabase(), normScore.tukey(r, (double)nRanks));
                }else if(vdw){
                    rs.updateDouble(newVariable.getName().nameForDatabase(), normScore.vanderWaerden(r, (double)nRanks));
                }else if(ntiles){
                    rs.updateDouble(newVariable.getName().nameForDatabase(), getGroup(r, (double)nRanks, (double)numGroups));
                }else{
                    rs.updateDouble(newVariable.getName().nameForDatabase(), r);
                }
                rankIndex++;
            }
            rs.updateRow();
            updateProgress();
            dbIndex++;
        }
        conn.commit();
        return "Ranks computed";
    }catch(SQLException ex){
        conn.rollback();
        throw ex;
    }finally{
        if(rs!=null) rs.close();
        if(stmt!=null) stmt.close();
        conn.setAutoCommit(true);
    }

}
 
开发者ID:meyerjp3,项目名称:jmetrik,代码行数:76,代码来源:RankingAnalysis.java

示例5: DescriptiveStatistics

import org.apache.commons.math3.util.ResizableDoubleArray; //导入依赖的package包/类
/**
 * Construct a DescriptiveStatistics instance with an infinite window
 * and the initial data values in double[] initialDoubleArray.
 * If initialDoubleArray is null, then this constructor corresponds to
 * DescriptiveStatistics()
 *
 * @param initialDoubleArray the initial double[].
 */
public DescriptiveStatistics(double[] initialDoubleArray) {
    if (initialDoubleArray != null) {
        eDA = new ResizableDoubleArray(initialDoubleArray);
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:14,代码来源:DescriptiveStatistics.java


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