Browse Source

工具类,指标计算

ywx
王宁 2 weeks ago
parent
commit
7a3022fa15
1 changed files with 97 additions and 6 deletions
  1. 97
    6
      smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java

+ 97
- 6
smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java View File

20
 import java.util.concurrent.ConcurrentHashMap;
20
 import java.util.concurrent.ConcurrentHashMap;
21
 import java.util.regex.Matcher;
21
 import java.util.regex.Matcher;
22
 import java.util.regex.Pattern;
22
 import java.util.regex.Pattern;
23
+import java.util.stream.Collectors;
23
 
24
 
24
 /**
25
 /**
25
  * @author ywx
26
  * @author ywx
398
         return N_Utils.formatDouble(Math.sqrt(fc(x)), 2);
399
         return N_Utils.formatDouble(Math.sqrt(fc(x)), 2);
399
     }
400
     }
400
 
401
 
402
+    //中位数
403
+    public static double zws(List<Double> list){
404
+        if (N_Utils.isListEmpty(list)) return 0;
405
+        // 先对列表进行排序
406
+        List<Double> sorteList = list.stream().sorted().collect(Collectors.toList());
407
+
408
+        int size = sorteList.size();
409
+        if (size % 2 == 1) {
410
+            // 数据个数为奇数,取中间位置的元素
411
+            return sorteList.get(size / 2);
412
+        } else {
413
+            // 数据个数为偶数,取中间两个元素的平均值
414
+            int midIndex1 = size / 2 - 1;
415
+            int midIndex2 = size / 2;
416
+            return (sorteList.get(midIndex1) + sorteList.get(midIndex2)) / 2;
417
+        }
418
+    }
401
 
419
 
402
-    public static void main(String[] args) {
403
-        String str = "ADAC-D-(C)(AB)(CD)(ACB)BB";
420
+    //众数
421
+    public static List<Double> zs(List<Double> list){
422
+        List<Double> modes = new ArrayList<>();
423
+        if (N_Utils.isListEmpty(list)) return modes;
424
+
425
+        // 使用HashMap来统计每个元素出现的次数
426
+        Map<Double, Long> countMap = list.stream()
427
+                                            .collect(Collectors.groupingBy(e -> e, Collectors.counting()));
428
+
429
+        long maxCount = 0;
430
+        // 找出最大的出现次数
431
+        for (long count : countMap.values()) {
432
+            maxCount = Math.max(maxCount, count);
433
+        }
434
+
435
+        // 找出所有出现次数等于最大出现次数的元素,即为众数
436
+        for (Map.Entry<Double, Long> entry : countMap.entrySet()) {
437
+            if (entry.getValue() == maxCount) {
438
+                modes.add(entry.getKey());
439
+            }
440
+        }
441
+        return modes;
442
+    }
443
+
444
+    //超均率 =(个人单科得分-全校平均分)÷全校平均分
445
+    public static double cjl(Object v1,Object v2){
446
+        if(v2 == null || "0".equals(v2)) return 0;
447
+
448
+        BigDecimal b1 = new BigDecimal(v1.toString());
449
+        BigDecimal b2 = new BigDecimal(v2.toString());
450
+        return b1.subtract(b2).divide(b2, 2, BigDecimal.ROUND_DOWN).doubleValue();
451
+    }
452
+
453
+    //标准分 班级标准分 =(班级得分-全校平均分)÷年级标准差
454
+    public static double bzf(Double score, Double avgscore, Double bzc) {
455
+        double bzscore = div(sub(score, avgscore), bzc);
456
+        return N_Utils.formatDouble(bzscore, 2);
457
+    }
458
+
459
+    //综合率 固定计算=平均得分率*50%+优秀率*25%+及格率*25%
460
+    public static double zhl(Double v1, Double v2, Double v3) {
461
+        double s1 = mul(v1, 0.5);
462
+        double s2 = mul(v2, 0.25);
463
+        double s3 = mul(v3, 0.25);
464
+        return add(s1, add(s2, s3));
465
+    }
466
+
467
+    //学科上线贡献率  班级学科上线贡献率=(班级学科上线率-班级总分上线率)-(学校学科的上线率-学校总分上线率)
468
+    public static double sxgxl(Double v1,Double v2,Double v3,Double v4){
469
+        double s1 = sub(v1,v2);
470
+        double s2 = sub(v3,v4);
471
+        return sub(s1,s2);
472
+    }
404
 
473
 
405
-        List<String> result = extractCharacters(str);
474
+    //短板学生 学科短板学生:偏科指数=(单科分值-全科平均分)÷全科标准差 ,如果偏科指数>1,标识此科为短板学科
475
+    public static double dbxs(Double v1,Double v2,Double v3){
476
+        return div(sub(v1,v2),v3);
477
+    }
406
 
478
 
407
-        double pscore = 0;
479
+    //鉴别指数 试题鉴别指数 = 前27%的学生得分率-后27%的学生得分率
480
+    //将学生按总分排序(去掉缺考的学生),取前27%、后27%的学生,分别计算在该题上的得分率,两者之差即为鉴别指数
481
+    public static double jbzs(List<Double> list,Double qscore){
482
+        List<Double> sortList = list.stream().sorted().collect(Collectors.toList());
483
+        int size = sortList.size();
484
+        int count = (int)(size * 0.27);//27%学生数量
485
+
486
+        // 前27%的学生
487
+        List<Double> topGroup = sortList.subList(0, count);
488
+        double topScore = topGroup.stream().mapToDouble(Double::doubleValue).sum();
489
+        double topRate = div(topScore, mul(qscore, count));
490
+
491
+        // 后27%的学生
492
+        List<Double> bottomGroup = sortList.subList(size - count, size);
493
+        double bottomScore = bottomGroup.stream().mapToDouble(Double::doubleValue).sum();
494
+        double bottomRate = div(bottomScore, mul(qscore, count));
495
+
496
+        // 鉴别指数
497
+        return sub(topRate, bottomRate);
498
+    }
408
 
499
 
409
-        double psum = add(pscore,10.5);
410
-        System.out.println(psum);
500
+    public static void main(String[] args) {
501
+        System.out.println(cjl(50,40));
411
     }
502
     }
412
 
503
 
413
 
504
 

Loading…
Cancel
Save