归一化list里面的数据

java中,归一化list里面的数据

 

复制代码
/**
 * 归一化
 * @param listInt
 * @return
 */
public static List<Double> normalListInteger(List<Integer> listInt){
    List<Double> list_d = new ArrayList<Double>();
    int maxValue = listInt.get(0);
    int minValue = listInt.get(0);
    for(int k = 0;k<listInt.size();k++) {
        int indexValue = listInt.get(k);
        
        if(indexValue<minValue) {
            minValue = indexValue;
        }
        
        if(indexValue>maxValue) {
            maxValue = indexValue;
        }
    }
    
    for(int k = 0;k<listInt.size();k++) {
        int indexValue = listInt.get(k);
        
        //x = (x - Min) / (Max - Min);
        
        double indexDValue = (double)(indexValue-minValue)/(double)(maxValue-minValue);
        list_d.add(indexDValue);
    }
    
    
    return list_d;
}
复制代码

 

 

########################

posted @   西北逍遥  阅读(319)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Ollama——大语言模型本地部署的极速利器
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· Windows编程----内核对象竟然如此简单?
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
历史上的今天:
2021-02-22 IfcProductRepresentationSelect
2020-02-22 IfcBuilding
点击右上角即可分享
微信分享提示