Example usage for org.apache.commons.math.stat.descriptive SynchronizedDescriptiveStatistics addValue

List of usage examples for org.apache.commons.math.stat.descriptive SynchronizedDescriptiveStatistics addValue

Introduction

In this page you can find the example usage for org.apache.commons.math.stat.descriptive SynchronizedDescriptiveStatistics addValue.

Prototype

@Override
public synchronized void addValue(double v) 

Source Link

Usage

From source file:edu.umm.radonc.ca_dash.model.ActivityFacade.java

public SynchronizedDescriptiveStatistics getDailyStats(Date start, Date end, boolean imrtOnly,
        boolean includeWeekends) {
    SynchronizedDescriptiveStatistics stats = new SynchronizedDescriptiveStatistics();
    List<Object[]> counts = getDailyCounts(start, end, imrtOnly, includeWeekends);
    for (Object[] item : counts) {
        stats.addValue(((Long) item[1]).doubleValue());
    }//from  w w  w .  j  ava 2s  . com
    return stats;
}

From source file:edu.umm.radonc.ca_dash.model.ActivityFacade.java

public SynchronizedDescriptiveStatistics getDailyStats(Date start, Date end, Long hospitalser, boolean imrtOnly,
        boolean includeWeekends) {
    SynchronizedDescriptiveStatistics stats = new SynchronizedDescriptiveStatistics();
    List<Object[]> counts = getDailyCounts(start, end, hospitalser, imrtOnly, includeWeekends);
    for (Object[] item : counts) {
        stats.addValue(((Long) item[1]).doubleValue());
    }//  w  ww  .  j  a  v  a2s  . co  m
    return stats;
}

From source file:edu.umm.radonc.ca_dash.model.ActivityFacade.java

public SynchronizedDescriptiveStatistics getWeeklyStats(Date start, Date end, Long hospitalser,
        boolean imrtOnly, boolean includeWeekends) {
    SynchronizedDescriptiveStatistics stats = new SynchronizedDescriptiveStatistics();
    List<Object[]> counts = getWeeklyCounts(start, end, hospitalser, imrtOnly, includeWeekends);
    for (Object[] item : counts) {
        stats.addValue(((Long) item[2]).doubleValue());
    }//from   ww w . j  a v  a 2  s .  com
    return stats;
}

From source file:edu.umm.radonc.ca_dash.model.TxInstanceFacade.java

public TreeMap<String, SynchronizedDescriptiveStatistics> machineStats(Date startDate, Date endDate,
        Long hospital, String filter) {
    TreeMap<String, SynchronizedDescriptiveStatistics> retval = new TreeMap<>();
    String hospString = "";
    String filterString = "";
    if (hospital != null && hospital > 0) {
        hospString = " AND tf.hospitalser = ? ";
    }//from  w  w w .j  a v  a 2  s  . c  o m

    filterString = buildFilterString(filter);

    javax.persistence.Query q = getEntityManager()
            .createNativeQuery("select machine, COUNT(DISTINCT tf.activityinstanceser) " + "FROM tx_flat_v5 tf "
                    + "WHERE tf.completed IS NOT NULL AND tf.completed >= ? AND tf.completed <= ? "
                    + filterString + hospString + "GROUP BY tf.machine, completed;")
            .setParameter(1, startDate).setParameter(2, endDate);

    if (hospital != null && hospital > 0) {
        q.setParameter(3, hospital);
    }
    List<Object[]> results = q.getResultList();

    String currMachine = "";
    if (!(results.isEmpty())) {
        currMachine = (String) results.get(0)[0];
    }
    SynchronizedDescriptiveStatistics mStats = new SynchronizedDescriptiveStatistics();
    for (Object[] row : results) {
        String m = (String) row[0];
        if (!(m.equals(currMachine))) {
            retval.put(currMachine, mStats);
            mStats = new SynchronizedDescriptiveStatistics();
        }
        mStats.addValue((Long) row[1]);
        currMachine = m;
    }
    retval.put(currMachine, mStats);

    return retval;
}

From source file:edu.umm.radonc.ca_dash.model.TxInstanceFacade.java

public TreeMap<String, SynchronizedDescriptiveStatistics> doctorStats(Date startDate, Date endDate,
        Long hospital, String filter) {
    TreeMap<String, SynchronizedDescriptiveStatistics> retval = new TreeMap<>();
    String hospString = "";
    String filterString = "";
    if (hospital != null && hospital > 0) {
        hospString = " AND tf.hospitalser = ? ";
    }/*  w w w. jav a 2  s.  co  m*/

    filterString = buildFilterString(filter);

    javax.persistence.Query q = getEntityManager().createNativeQuery(
            "select (dr.lastname || ', ' || dr.firstname) AS doctor, completed, COUNT(DISTINCT tf.patientser) "
                    + "FROM tx_flat_v5 tf "
                    + "INNER JOIN patientdoctor ptdr ON tf.patientser = ptdr.patientser "
                    + "INNER JOIN doctor dr ON ptdr.resourceser = dr.resourceser "
                    + "WHERE tf.completed IS NOT NULL "
                    + "AND ptdr.primaryflag = 'TRUE' AND ptdr.oncologistflag = 'TRUE' "
                    + "AND tf.completed IS NOT NULL AND tf.completed >= ? AND tf.completed <= ? " + filterString
                    + hospString + "GROUP BY dr.lastname, dr.firstname, completed;")
            .setParameter(1, startDate).setParameter(2, endDate);

    if (hospital != null && hospital > 0) {
        q.setParameter(3, hospital);
    }
    List<Object[]> results = q.getResultList();

    String currDoc = "";
    if (!(results.isEmpty())) {
        currDoc = (String) results.get(0)[0];
    }
    SynchronizedDescriptiveStatistics drStats = new SynchronizedDescriptiveStatistics();
    for (Object[] row : results) {
        String dr = (String) row[0];
        if (!(dr.equals(currDoc))) {
            retval.put(currDoc, drStats);
            drStats = new SynchronizedDescriptiveStatistics();
        }
        drStats.addValue((Long) row[2]);
        currDoc = dr;
    }
    retval.put(currDoc, drStats);

    return retval;
}

From source file:edu.umm.radonc.ca_dash.model.TxInstanceFacade.java

public SynchronizedDescriptiveStatistics getDailyStats(Date startDate, Date endDate, Long hospital,
        String filter, boolean includeWeekends, boolean ptflag, boolean scheduledFlag) {
    SynchronizedDescriptiveStatistics stats = new SynchronizedDescriptiveStatistics();
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(endDate);/* ww w  . j a  v a2  s.com*/
    gc.add(Calendar.DATE, -1);
    List<Object[]> counts = getDailyCounts(startDate, gc.getTime(), hospital, filter, includeWeekends, ptflag,
            scheduledFlag);
    for (Object[] item : counts) {
        stats.addValue(((Long) item[1]).doubleValue());
    }
    return stats;
}

From source file:edu.umm.radonc.ca_dash.model.ActivityFacade.java

public TreeMap<String, SynchronizedDescriptiveStatistics> getMonthlySummaryStats(Date start, Date end,
        Long hospitalser, boolean imrtOnly, boolean includeWeekends) {
    Calendar cal = new GregorianCalendar();
    TreeMap<String, SynchronizedDescriptiveStatistics> retval = new TreeMap<>();

    List<Object[]> events;

    if (hospitalser < 0) {
        events = getDailyCounts(start, end, imrtOnly, includeWeekends);
    } else {/*from  w  w w .  j  a  v a 2  s. c om*/
        events = getDailyCounts(start, end, hospitalser, imrtOnly, includeWeekends);
    }
    cal.setTime(start);

    int mo = cal.get(Calendar.MONTH);
    int yr = cal.get(Calendar.YEAR);

    String currMoYr = yr + "-" + String.format("%02d", mo + 1);
    String prevMoYr = "";
    SynchronizedDescriptiveStatistics currStats = new SynchronizedDescriptiveStatistics();
    int i = 0;
    while (cal.getTime().before(end) && i < events.size()) {

        Object[] event = events.get(i);
        Date d = (Date) event[0];
        Long count = (Long) event[1];

        prevMoYr = currMoYr;
        cal.setTime(d);
        mo = cal.get(Calendar.MONTH);
        yr = cal.get(Calendar.YEAR);

        currMoYr = yr + "-" + String.format("%02d", mo + 1);

        if (!(prevMoYr.equals(currMoYr))) {
            retval.put(prevMoYr, currStats);
            currStats = new SynchronizedDescriptiveStatistics();
        }

        currStats.addValue(count);
        i++;
    }
    retval.put(prevMoYr, currStats);

    return retval;
}

From source file:edu.umm.radonc.ca_dash.model.TxInstanceFacade.java

public TreeMap<Date, SynchronizedDescriptiveStatistics> getWeeklySummaryStatsTr(Date startDate, Date endDate,
        Long hospitalser, String filter, boolean includeWeekends, boolean ptflag, boolean scheduledFlag) {
    Calendar cal = new GregorianCalendar();
    TreeMap<Date, SynchronizedDescriptiveStatistics> retval = new TreeMap<>();

    List<Object[]> events = getDailyCounts(startDate, endDate, hospitalser, filter, false, ptflag,
            scheduledFlag);/*from  w ww. j av  a2  s  . co m*/

    DateFormat df = new SimpleDateFormat("MM/dd/yy");
    cal.setTime(startDate);
    SynchronizedDescriptiveStatistics currStats = new SynchronizedDescriptiveStatistics();
    int i = 0;
    int dayCount = 0;
    while (cal.getTime().before(endDate) && i < events.size()) {

        Object[] event = events.get(i);
        Date d = (Date) event[0];
        Long count = (Long) event[1];

        //cal.setTime(d);
        if (dayCount == 6) {
            retval.put(cal.getTime(), currStats);
            currStats = new SynchronizedDescriptiveStatistics();
            dayCount = -1;
            cal.add(Calendar.DATE, 7);
        }

        currStats.addValue(count);
        dayCount++;
        i++;
    }
    retval.put(cal.getTime(), currStats);

    return retval;
}

From source file:edu.umm.radonc.ca_dash.model.ActivityFacade.java

public TreeMap<String, SynchronizedDescriptiveStatistics> getWeeklySummaryStats(Date start, Date end,
        Long hospitalser, boolean imrtOnly, boolean includeWeekends) {
    Calendar cal = new GregorianCalendar();
    TreeMap<String, SynchronizedDescriptiveStatistics> retval = new TreeMap<>();

    List<Object[]> events;

    if (hospitalser < 0) {
        events = getDailyCounts(start, end, imrtOnly, includeWeekends);
    } else {/*from  w w w . ja v a2s. c  om*/
        events = getDailyCounts(start, end, hospitalser, imrtOnly, includeWeekends);
    }
    cal.setTime(start);
    int wk = cal.get(Calendar.WEEK_OF_YEAR);
    int mo = cal.get(Calendar.MONTH);
    int yr = cal.get(Calendar.YEAR);
    if (mo == Calendar.DECEMBER && wk == 1) {
        yr = yr + 1;
    } else if (mo == Calendar.JANUARY && wk == 52) {
        yr = yr - 1;
    }
    String currYrWk = yr + "-" + String.format("%02d", wk);
    String prevYrWk = "";
    SynchronizedDescriptiveStatistics currStats = new SynchronizedDescriptiveStatistics();
    int i = 0;
    while (cal.getTime().before(end) && i < events.size()) {

        Object[] event = events.get(i);
        Date d = (Date) event[0];
        Long count = (Long) event[1];

        prevYrWk = currYrWk;
        cal.setTime(d);
        wk = cal.get(Calendar.WEEK_OF_YEAR);
        mo = cal.get(Calendar.MONTH);
        yr = cal.get(Calendar.YEAR);
        if (mo == Calendar.DECEMBER && wk == 1) {
            yr = yr + 1;
        } else if (mo == Calendar.JANUARY && wk == 52) {
            yr = yr - 1;
        }
        currYrWk = yr + "-" + String.format("%02d", wk);

        if (!(prevYrWk.equals(currYrWk))) {
            retval.put(prevYrWk, currStats);
            currStats = new SynchronizedDescriptiveStatistics();
        }

        currStats.addValue(count);
        i++;
    }
    retval.put(prevYrWk, currStats);

    return retval;
}

From source file:edu.umm.radonc.ca_dash.model.TxInstanceFacade.java

public TreeMap<Date, SynchronizedDescriptiveStatistics> getMonthlySummaryStats(Date startDate, Date endDate,
        Long hospitalser, String filter, boolean includeWeekends, boolean ptflag, boolean scheduledFlag) {
    Calendar cal = new GregorianCalendar();
    TreeMap<Date, SynchronizedDescriptiveStatistics> retval = new TreeMap<>();
    GregorianCalendar oc = new GregorianCalendar();
    List<Object[]> events;

    events = getDailyCounts(startDate, endDate, hospitalser, filter, false, ptflag, scheduledFlag);

    cal.setTime(startDate);/*from w  ww  .ja  v a2 s . co  m*/

    int mo = cal.get(Calendar.MONTH);
    int yr = cal.get(Calendar.YEAR);

    int currYr = yr;
    int currMo = mo;
    int prevMo = -1;
    int prevYr = -1;
    SynchronizedDescriptiveStatistics currStats = new SynchronizedDescriptiveStatistics();
    int i = 0;
    while (cal.getTime().before(endDate) && i < events.size()) {

        Object[] event = events.get(i);
        Date d = (Date) event[0];
        Long count = (Long) event[1];

        prevMo = currMo;
        prevYr = currYr;
        cal.setTime(d);
        mo = cal.get(Calendar.MONTH);
        yr = cal.get(Calendar.YEAR);

        currMo = mo;
        currYr = yr;

        if (prevMo != currMo || prevYr != currYr) {
            oc.set(Calendar.MONTH, prevMo);
            oc.set(Calendar.YEAR, prevYr);
            oc.set(Calendar.DAY_OF_MONTH, 1);
            retval.put(oc.getTime(), currStats);
            currStats = new SynchronizedDescriptiveStatistics();
        }

        currStats.addValue(count);
        i++;
    }
    oc.set(Calendar.MONTH, currMo);
    oc.set(Calendar.YEAR, currYr);
    oc.set(Calendar.DAY_OF_MONTH, 1);
    retval.put(oc.getTime(), currStats);

    return retval;
}