• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ResizableDoubleArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XMLStringBuffer类代码示例发布时间:2022-05-23
下一篇:
Java DecisionService类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap