Ejemplo n.º 1
0
  public void psaTest() {

    PSAdata p = new PSAdata();

    AnalyteStat psa = ComputeAnalyteStats.computeMonth(p.getMonth(7), "psa", 7);

    // Values from Excel

    int total = 2346;
    // numeric excluding <0.03 = 2277
    // numeric including 0.029 = 2339
    int totalValid = 2339;
    // other "U" = 7
    Integer countU = 7;

    // Min 0.029
    // 2.5 0.029
    // 25 0.71
    // 50 1.35
    // 75 3.16
    // 97.5 20.31
    // Max 10106

    // 65th 2.127

    // Mean: 9.458323215

    // TODO These test figures are wrong becuase we're now filtering out weekends!

    //		assertEquals(total, psa.getInputCount());
    //		assertEquals(totalValid, psa.getValidCount());
    //		assertEquals(countU, psa.getOtherData().get("U"));
    //
    //		assertEquals(0.029, psa.getMin(), 0.001);
    //
    //		assertEquals(0.029, psa.getPercentile(0.025), 0.001);
    //		assertEquals(0.71, psa.getPercentile(0.25), 0.001);
    //		assertEquals(1.35, psa.getPercentile(0.5), 0.001);
    //		assertEquals(3.16, psa.getPercentile(0.75), 0.001);
    //		assertEquals(20.31, psa.getPercentile(0.975), 0.001);
    //
    //		assertEquals(2.127, psa.getPercentile(0.65), 0.001);
    //
    //		assertEquals(10106, psa.getMax(), 0.001);
    //
    //		assertEquals(9.458, psa.getMean(), 0.001);

    // TODO lots more tests
  }
Ejemplo n.º 2
0
  @Ignore
  @Test
  public void sorting() {
    PSAdata pd = new PSAdata();
    HashMap<LocalDate, AnalyteStat> allDailyAnalyteStats = new HashMap<LocalDate, AnalyteStat>();

    List<AnalyteResult> analyteResultsList;
    List<AnalyteDate> allVaildAnalyteDates = new ArrayList<AnalyteDate>();
    List<AnalyteDate> allInVaildAnalyteDates = new ArrayList<AnalyteDate>();

    // the RAW data are here
    analyteResultsList = pd.getResults();

    // hm contains the results divided by day.
    // The analytes are still mixed up though.
    HashMap<LocalDate, List<String>> hm = new HashMap<LocalDate, List<String>>();

    for (AnalyteResult r : analyteResultsList) {
      if (hm.get(r.getDate()) == null) hm.put(r.getDate(), new ArrayList<String>());
      hm.get(r.getDate()).add(r.getResult());
    }

    for (LocalDate day : hm.keySet()) {
      AnalyteDate d = new AnalyteDate("psa", day.toDate(), hm.get(day));
      AnalyteStat s = ComputeAnalyteStats.computeDay(d, "psa");
      if (s.getIsValid()) {
        allDailyAnalyteStats.put(day, s);
        allVaildAnalyteDates.add(d);
      } else allInVaildAnalyteDates.add(d);
    }

    ComputeAnalyteStats.getMovingMeanOfMedian(allDailyAnalyteStats, 50);
    ComputeAnalyteStats.getMovingMeanOfMedian(allDailyAnalyteStats, 7);
    ComputeAnalyteStats.getMovingMeanOfMedian(allDailyAnalyteStats, 20);

    ComputeAnalyteStats.getMovingMean(allDailyAnalyteStats, 50);
    ComputeAnalyteStats.getMovingMean(allDailyAnalyteStats, 7);
    ComputeAnalyteStats.getMovingMean(allDailyAnalyteStats, 20);

    List<AnalyteStat> stats = new ArrayList<AnalyteStat>();

    for (AnalyteStat as : allDailyAnalyteStats.values()) stats.add(as);

    Collections.sort(stats);

    for (AnalyteStat a : stats) System.out.println(a.getIncludedDates().get(0).toString());
  }