Example usage for org.apache.commons.math.stat.descriptive SummaryStatistics SummaryStatistics

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

Introduction

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

Prototype

public SummaryStatistics() 

Source Link

Document

Construct a SummaryStatistics instance

Usage

From source file:org.modeshape.jcr.perftests.StatisticalData.java

public StatisticalData(Number... values) {
    if (values == null || values.length == 0) {
        throw new IllegalArgumentException(
                "The set of values for the statistical data cannot be empty or null");
    }//from  ww  w .  j  av  a2 s .com
    this.summaryStatistics = new SummaryStatistics();
    for (Number value : values) {
        this.summaryStatistics.addValue(value.doubleValue());
    }
    this.values = new double[values.length];
    for (int i = 0; i < values.length; i++) {
        this.values[i] = values[i].doubleValue();
    }
    // store the values in ascending order
    Arrays.sort(this.values);
}

From source file:org.openehealth.ipf.commons.test.performance.processingtime.ProcessingTimeStatistics.java

protected void initializeStatisticsIfNecessary(MeasurementHistory history) {
    // initialize summary statistics only for measurements with name
    for (Measurement measurement : history.getMeasurements()) {
        if (!measurement.isNameEmpty()) {
            String name = measurement.getName();
            if (!statisticsByMeasurementName.containsKey(name)) {
                statisticsByMeasurementName.put(name, new SummaryStatistics());
            }//from   w w  w.  j  a v  a 2 s .  c  o  m
        }
    }
}

From source file:org.ow2.clif.jenkins.parser.clif.ActionStatInfo.java

public ActionStatInfo(final ParsingContext context, final ChartConfiguration chartConfiguration) {
    this.context = new ParsingContext(context);
    this.onTheFlyStat = new SummaryStatistics();
    this.chartConfiguration = chartConfiguration;
}

From source file:rapture.stat.memory.ValueMemoryType.java

@Override
public boolean calculate() {
    if (System.currentTimeMillis() > nextRecord) {
        ValueStat v = new ValueStat();
        v.setKey(key);/*from ww w.  j a v  a 2  s.co m*/
        if (workingValues.isEmpty()) {
            v.setValue(0.0);
        } else {
            SummaryStatistics summary = new SummaryStatistics();
            synchronized (workingValues) {
                for (ValueStat vs : workingValues) {
                    summary.addValue(vs.getValue());
                }
            }
            switch (operation) {
            case AVERAGE:
                v.setValue(summary.getMean());
                break;
            case SUM:
                v.setValue(summary.getSum());
                break;
            }
        }
        history.add(v);
        nextRecord = nextExtractionTime();
        return true;
    }
    return false;
}

From source file:se.sics.gvod.common.GraphUtil.java

public GraphUtil(TreeMap<VodAddress, VodNeighbors> alivePeers) {
    super();//from  w ww.j av  a  2s .c o  m
    n = alivePeers.size();
    m = new byte[n][n];
    dist = new int[n][n];
    inDegree = new double[n];
    outDegree = new int[n];
    clustering = new double[n];
    a = new VodAddress[n];
    map = new HashMap<VodAddress, Integer>();
    neighbors = new int[n][];
    inStats = new SummaryStatistics();
    outStats = new SummaryStatistics();

    // map all alive nodes to a contiguous sequence of integers
    {
        int p = 0;
        for (VodAddress address : alivePeers.keySet()) {
            VodAddress src = (VodAddress) address;
            utilitySetNbChange += (alivePeers.get(src).getUtilitySetNbChange()
                    / alivePeers.get(src).getNbCycles());
            upperSetNbChange += (alivePeers.get(src).getUpperSetNbChange() / alivePeers.get(src).getNbCycles());
            nbCycles += alivePeers.get(src).getNbCycles();
            a[p] = src;
            map.put(src, p);
            p++;
        }
    }

    // build adjacency matrix
    int d = -1;
    {
        try {
            for (int s = 0; s < a.length; s++) {
                VodAddress src = a[s];
                VodNeighbors neigh = alivePeers.get(src);
                int nn = 0;
                for (VodDescriptor desc : neigh.getRandomSetDescriptors()) {
                    VodAddress dst = desc.getVodAddress();
                    if (!map.containsKey(dst)) {
                        continue;
                    }
                    d = map.get(dst);
                    m[s][d] = 1;
                    inDegree[d]++;
                    outDegree[s]++;
                    nn++;
                }
                neighbors[s] = new int[nn];
                nn = 0;
                for (VodDescriptor desc : neigh.getRandomSetDescriptors()) {
                    VodAddress dst = desc.getVodAddress();
                    if (map.containsKey(dst)) {
                        neighbors[s][nn++] = map.get(dst);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
    // build distance matrix, clustering coefficient, average path length
    // diameter and average degrees
    {
        for (int i = 0; i < n; i++) {
            bfs(i, dist[i]);

            // we compute the clustering coefficient here
            int neigh[] = neighbors[i];
            if (neigh.length <= 1) {
                clustering[i] = 1.0;
                continue;
            }
            int edges = 0;

            for (int j = 0; j < neigh.length; j++) {
                for (int k = j + 1; k < neigh.length; k++) {
                    if (m[neigh[j]][neigh[k]] > 0 || m[neigh[k]][neigh[j]] > 0) {
                        ++edges;
                    }
                }
            }
            clustering[i] = ((edges * 2.0) / neigh.length) / (neigh.length - 1);
        }
        int k = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j)
                    continue;
                if (dist[i][j] == n) {
                    infinitePathCount++;
                    continue;
                }
                if (dist[i][j] > diameter) {
                    diameter = dist[i][j];
                }
                avgPathLength = (avgPathLength * k + dist[i][j]) / (k + 1);
                k++;
            }
            inStats.addValue(inDegree[i]);
            outStats.addValue(outDegree[i]);
            // avgIn = (avgIn * i + inDegree[i]) / (i + 1);
            // minIn = minIn > inDegree[i] ? inDegree[i] : minIn;
            // maxIn = maxIn < inDegree[i] ? inDegree[i] : maxIn;
            // avgOut = (avgOut * i + outDegree[i]) / (i + 1);
            avgClustering = (avgClustering * i + clustering[i]) / (i + 1);
        }
    }
}

From source file:se.sics.gvod.simulator.vod.VodSimulator.java

private void logStatistics() {
    //        snapshot.generateGraphVizReport();
    SummaryStatistics downloadTimeNotFree = new SummaryStatistics();
    SummaryStatistics downloadTime99NotFree = new SummaryStatistics();
    SummaryStatistics nbBufferingNotFree = new SummaryStatistics();
    SummaryStatistics nbNBufferingNotFree = new SummaryStatistics();
    SummaryStatistics statsWaitingNotFree = new SummaryStatistics();
    SummaryStatistics downloadTimeFree = new SummaryStatistics();
    SummaryStatistics downloadTime99Free = new SummaryStatistics();
    SummaryStatistics nbBufferingFree = new SummaryStatistics();
    SummaryStatistics nbNBufferingFree = new SummaryStatistics();
    SummaryStatistics statsWaitingFree = new SummaryStatistics();
    SummaryStatistics nbWaiting = new SummaryStatistics();
    SummaryStatistics nbMisConnect = new SummaryStatistics();

    Map<Long, SummaryStatistics> downloadNotFree = new HashMap<Long, SummaryStatistics>();
    Map<Long, SummaryStatistics> download99NotFree = new HashMap<Long, SummaryStatistics>();
    Map<Long, ArrayList<Long>> list99NotFree = new HashMap<Long, ArrayList<Long>>();
    Map<Long, SummaryStatistics> totalUploadUse = new HashMap<Long, SummaryStatistics>();
    Map<Long, SummaryStatistics> waitingNotFree = new HashMap<Long, SummaryStatistics>();
    Map<Long, SummaryStatistics> bufferingNotFree = new HashMap<Long, SummaryStatistics>();
    Map<Long, SummaryStatistics> notBufferingNotFree = new HashMap<Long, SummaryStatistics>();
    Map<Long, SummaryStatistics> downloadFree = new HashMap<Long, SummaryStatistics>();
    Map<Long, SummaryStatistics> download99Free = new HashMap<Long, SummaryStatistics>();
    Map<Long, ArrayList<Long>> list99Free = new HashMap<Long, ArrayList<Long>>();
    Map<Long, SummaryStatistics> waitingFree = new HashMap<Long, SummaryStatistics>();
    Map<Long, SummaryStatistics> bufferingFree = new HashMap<Long, SummaryStatistics>();
    Map<Long, SummaryStatistics> notBufferingFree = new HashMap<Long, SummaryStatistics>();

    ArrayList<Long> temp = new ArrayList<Long>();
    long totalDownload = 0;
    long totalUpload = 0;
    for (Integer node : nodeDownloadTimeNotFree.keySet()) {
        downloadTimeNotFree.addValue(nodeDownloadTimeNotFree.get(node));
        temp.add(nodeDownloadTimeNotFree.get(node));
        if (!downloadNotFree.containsKey(downloadLink.get(node).getCapacity())) {
            downloadNotFree.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
            download99NotFree.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
            list99NotFree.put(downloadLink.get(node).getCapacity(), new ArrayList<Long>());
            totalUploadUse.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
            waitingNotFree.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
            bufferingNotFree.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
            notBufferingNotFree.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
        }/*from   ww w.j av  a 2s  .  co m*/
        downloadNotFree.get(downloadLink.get(node).getCapacity()).addValue(nodeDownloadTimeNotFree.get(node));
        list99NotFree.get(downloadLink.get(node).getCapacity()).add(nodeDownloadTimeNotFree.get(node));
        totalUploadUse.get(downloadLink.get(node).getCapacity())
                .addValue(uploadLink.get(node).getBwUsePs() / 1024);
        waitingNotFree.get(downloadLink.get(node).getCapacity()).addValue(nodeWaitingTimeNotFree.get(node));
        bufferingNotFree.get(downloadLink.get(node).getCapacity()).addValue(nodeNbBufferingNotFree.get(node));
        if (nodeNbBufferingNotFree.get(node) == 0) {
            notBufferingNotFree.get(downloadLink.get(node).getCapacity()).addValue(1);
        } else {
            notBufferingNotFree.get(downloadLink.get(node).getCapacity()).addValue(0);
        }
        totalDownload += downloadLink.get(node).getBwUse();
        totalUpload += uploadLink.get(node).getBwUse();
    }

    Collections.sort(temp);
    int i = temp.size() * 5 / 100;
    while (i > 0) {
        temp.remove(temp.size() - 1);
        i--;
    }
    for (Long val : temp) {
        downloadTime99NotFree.addValue(val);
    }

    for (Long key : list99NotFree.keySet()) {
        Collections.sort(list99NotFree.get(key));
        i = list99NotFree.get(key).size() / 100;
        while (i > 0) {
            long toRemove = list99NotFree.get(key).size() - 1;
            list99NotFree.get(key).remove(toRemove);
            i--;
        }
        for (Long val : list99NotFree.get(key)) {
            download99NotFree.get(key).addValue(val);
        }
    }

    if (downloadLink.get(seedId) != null) {
        totalDownload += downloadLink.get(seedId).getBwUse();
        totalUpload += uploadLink.get(seedId).getBwUse();

        if (totalUploadUse.get(downloadLink.get(seedId).getCapacity()) == null) {
            totalUploadUse.put(downloadLink.get(seedId).getCapacity(), new SummaryStatistics());
        }
        totalUploadUse.get(downloadLink.get(seedId).getCapacity())
                .addValue(uploadLink.get(seedId).getBwUsePs() / 1280);
    }
    for (int bufferingNb : nodeNbBufferingNotFree.values()) {
        nbBufferingNotFree.addValue(bufferingNb);
        if (bufferingNb == 0) {
            nbNBufferingNotFree.addValue(1);
        } else {
            nbNBufferingNotFree.addValue(0);
        }
    }
    for (int waitingTime : nodeNbWaiting.values()) {
        nbWaiting.addValue(waitingTime);
    }

    for (int misConnect : nodeNbMisConnect.values()) {
        nbMisConnect.addValue(misConnect);
    }

    for (long waitingTime : nodeWaitingTimeNotFree.values()) {
        statsWaitingNotFree.addValue(waitingTime);
    }
    int messages = 0;
    long traffic = 0;
    for (ReceivedMessage rm : messageHistogram.values()) {
        messages += rm.getTotalCount();
        traffic += rm.getTotalSize();
    }

    temp = new ArrayList<Long>();
    for (Integer node : nodeDownloadTimeFree.keySet()) {
        downloadTimeFree.addValue(nodeDownloadTimeFree.get(node));
        temp.add(nodeDownloadTimeFree.get(node));
        if (!downloadFree.containsKey(downloadLink.get(node).getCapacity())) {
            downloadFree.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
            download99Free.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
            list99Free.put(downloadLink.get(node).getCapacity(), new ArrayList<Long>());
            totalUploadUse.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
            waitingFree.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
            bufferingFree.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
            notBufferingFree.put(downloadLink.get(node).getCapacity(), new SummaryStatistics());
        }
        downloadFree.get(downloadLink.get(node).getCapacity()).addValue(nodeDownloadTimeFree.get(node));
        list99Free.get(downloadLink.get(node).getCapacity()).add(nodeDownloadTimeFree.get(node));
        totalUploadUse.get(downloadLink.get(node).getCapacity())
                .addValue(uploadLink.get(node).getBwUsePs() / 1024);
        waitingFree.get(downloadLink.get(node).getCapacity()).addValue(nodeWaitingTimeFree.get(node));
        bufferingFree.get(downloadLink.get(node).getCapacity()).addValue(nodeNbBufferingFree.get(node));
        if (nodeNbBufferingFree.get(node) == 0) {
            notBufferingFree.get(downloadLink.get(node).getCapacity()).addValue(1);
        } else {
            notBufferingFree.get(downloadLink.get(node).getCapacity()).addValue(0);
        }
        totalDownload += downloadLink.get(node).getBwUse();
        totalUpload += uploadLink.get(node).getBwUse();
    }

    Collections.sort(temp);
    i = temp.size() * 5 / 100;
    while (i > 0) {
        temp.remove(temp.size() - 1);
        i--;
    }
    for (Long val : temp) {
        downloadTime99Free.addValue(val);
    }

    for (Long key : list99Free.keySet()) {
        Collections.sort(list99Free.get(key));
        i = list99Free.get(key).size() / 100;
        while (i > 0) {
            long toRemove = list99Free.get(key).size() - 1;
            list99Free.get(key).remove(toRemove);
            i--;
        }
        for (Long val : list99Free.get(key)) {
            download99Free.get(key).addValue(val);
        }
    }

    for (int bufferingNb : nodeNbBufferingFree.values()) {
        nbBufferingFree.addValue(bufferingNb);
        if (bufferingNb == 0) {
            nbNBufferingFree.addValue(1);
        } else {
            nbNBufferingFree.addValue(0);
        }
    }

    for (long waitingTime : nodeWaitingTimeFree.values()) {
        statsWaitingFree.addValue(waitingTime);
    }

    logger.info("=================================================");
    logger.info("Total Upload : {}", totalUpload);
    logger.info("Total Download : {}", totalDownload);
    logger.info("diff : {}", Math.abs(totalUpload - totalDownload));
    logger.info("=================================================");
    logger.info("NOT FREE");
    logger.info("Number of nodes: {}", downloadTimeNotFree.getN());
    logger.info("Min download time:  {} ms ({})", downloadTimeNotFree.getMin(),
            durationToString(Math.round(downloadTimeNotFree.getMin())));
    logger.info("Max download time:  {} ms ({})", downloadTimeNotFree.getMax(),
            durationToString(Math.round(downloadTimeNotFree.getMax())));
    logger.info("Avg download time:  {} ms ({})", downloadTimeNotFree.getMean(),
            durationToString(Math.round(downloadTimeNotFree.getMean())));
    logger.info("Std download time:  {} ms ({})", downloadTimeNotFree.getStandardDeviation(),
            durationToString(Math.round(downloadTimeNotFree.getStandardDeviation())));
    logger.info("=================================================");
    logger.info("FREE");
    logger.info("Number of nodes: {}", downloadTimeFree.getN());
    logger.info("Min download time:  {} ms ({})", downloadTimeFree.getMin(),
            durationToString(Math.round(downloadTimeFree.getMin())));
    logger.info("Max download time:  {} ms ({})", downloadTimeFree.getMax(),
            durationToString(Math.round(downloadTimeFree.getMax())));
    logger.info("Avg download time:  {} ms ({})", downloadTimeFree.getMean(),
            durationToString(Math.round(downloadTimeFree.getMean())));
    logger.info("Std download time:  {} ms ({})", downloadTimeFree.getStandardDeviation(),
            durationToString(Math.round(downloadTimeFree.getStandardDeviation())));

    int nbNodes = nodeDownloadTimeNotFree.size() + nodeDownloadTimeFree.size();
    try {
        FileWriter writer = new FileWriter("gvod" + VodConfig.PERCENTAGE_FREERIDERS // arg
                + "NotFree_superseed.out", true);
        String text = seed + "\t" + nbNodes + "\t" + downloadTimeNotFree.getMean() + "\t"
                + downloadTimeNotFree.getMax() + "\t" + downloadTimeNotFree.getMin() + "\t"
                + downloadTime99NotFree.getMax() + "\t" + statsWaitingNotFree.getMean() + "\t"
                + nbBufferingNotFree.getMean() + "\t" + nbNBufferingNotFree.getMean() + "\n";
        writer.write(text, 0, text.length());
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        FileWriter writer = new FileWriter("gvod" + VodConfig.PERCENTAGE_FREERIDERS + "Free_superseed.out",
                true);
        String text = seed + "\t" + nbNodes + "\t" + downloadTimeFree.getMean() + "\t"
                + downloadTimeFree.getMax() + "\t" + downloadTimeFree.getMin() + "\t"
                + downloadTime99Free.getMax() + "\t" + statsWaitingFree.getMean() + "\t"
                + nbBufferingFree.getMean() + "\t" + nbNBufferingFree.getMean() + "\n";
        writer.write(text, 0, text.length());
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    for (long bW : downloadNotFree.keySet()) {
        logger.info("=================================================");

        SummaryStatistics stats = downloadNotFree.get(bW);
        SummaryStatistics stats99 = download99NotFree.get(bW);
        SummaryStatistics statsUpTotal = totalUploadUse.get(bW);
        SummaryStatistics statsDown = downloadUse.get(bW);
        SummaryStatistics statsUp = uploadUse.get(bW);
        SummaryStatistics statsWait = waitingNotFree.get(bW);
        SummaryStatistics statsBuf = bufferingNotFree.get(bW);
        SummaryStatistics statsNBuf = notBufferingNotFree.get(bW);

        try {
            FileWriter writer = new FileWriter(
                    bW + "gvod" + VodConfig.PERCENTAGE_FREERIDERS + "NotFree_superseed.out", true);
            String text = nbNodes + "\t" + stats.getMean() + "\t" + stats.getMax() + "\t" + stats.getMin()
                    + "\t" + stats99.getMax() + "\t" + statsWait.getMean() + "\t" + statsBuf.getMean() + "\t"
                    + statsNBuf.getMean() + "\n";
            writer.write(text, 0, text.length());
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        Map<Integer, SummaryStatistics> map = utilitySetSize.get(bW);

        logger.info(
                "BandWith down {}KB/S, nb of nodes {} ("
                        + ((float) stats.getN() / downloadTimeNotFree.getN()) * 100 + "%)",
                bW / 1024, stats.getN());
        logger.info("Number of nodes: {}", stats.getN());
        logger.info("Min download time:  {} ms ({})", stats.getMin(),
                durationToString(Math.round(stats.getMin())));
        logger.info("Max download time:  {} ms ({})", stats.getMax(),
                durationToString(Math.round(stats.getMax())));
        logger.info("Avg download time:  {} ms ({})", stats.getMean(),
                durationToString(Math.round(stats.getMean())));
        logger.info("Std download time:  {} ms ({})", stats.getStandardDeviation(),
                durationToString(Math.round(stats.getStandardDeviation())));
        logger.info("Avg upload Use Total: {} KBytes/s", statsUpTotal.getMean());
        logger.info("Avg upload Use during download: {} KBytes/s", statsUp.getMean());
        logger.info("Max upload Use during download: {} KBytes/s", statsUp.getMax());
        logger.info("Avg download Use Total during downloag: {} KBytes/s", statsDown.getMean());
        logger.info("Min download Use Total during downloag: {} KBytes/s", statsDown.getMin());
        logger.info("-----------------------------------------------");
        logger.info("Avg buffering Time: {} ms ({})", statsWait.getMean(),
                durationToString(Math.round(statsWait.getMean())));
        logger.info("Avg number of buffering : {}", statsBuf.getMean());
    }

    for (long bW : downloadFree.keySet()) {
        logger.info("=================================================");

        SummaryStatistics stats = downloadFree.get(bW);
        SummaryStatistics stats99 = download99Free.get(bW);
        SummaryStatistics statsUpTotal = totalUploadUse.get(bW);
        SummaryStatistics statsDown = downloadUse.get(bW);
        SummaryStatistics statsUp = uploadUse.get(bW);
        SummaryStatistics statsWait = waitingFree.get(bW);
        SummaryStatistics statsBuf = bufferingFree.get(bW);
        SummaryStatistics statsNBuf = notBufferingFree.get(bW);

        try {
            FileWriter writer = new FileWriter(bW + "gvod" //                        + arg + "Free_superseed.out"
                    , true);
            String text = nbNodes
                    //                        + "\t" + gvodConfiguration.getArg()
                    + "\t" + stats.getMean() + "\t" + stats.getMax() + "\t" + stats.getMin() + "\t"
                    + stats99.getMax() + "\t" + statsWait.getMean() + "\t" + statsBuf.getMean() + "\t"
                    + statsNBuf.getMean() + "\n";
            writer.write(text, 0, text.length());
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        Map<Integer, SummaryStatistics> map = utilitySetSize.get(bW);

        //            logger.info("BandWith down {}KB/S, nb of nodes {} (" +
        //                    ((float) stats.getN() / downloadTimeNotFree.getN()) * 100 + "%)", bW / 1024, stats.getN());
        //            logger.info("Number of nodes: {}", stats.getN());
        //            logger.info("Min download time:  {} ms ({})", stats.getMin(),
        //                    durationToString(Math.round(stats.getMin())));
        //            logger.info("Max download time:  {} ms ({})", stats.getMax(),
        //                    durationToString(Math.round(stats.getMax())));
        //            logger.info("Avg download time:  {} ms ({})", stats.getMean(),
        //                    durationToString(Math.round(stats.getMean())));
        //            logger.info("Std download time:  {} ms ({})",
        //                    stats.getStandardDeviation(),
        //                    durationToString(Math.round(stats.getStandardDeviation())));
        //            logger.info("Avg upload Use Total: {} KBytes/s", statsUpTotal.getMean());
        //            logger.info("Avg upload Use during download: {} KBytes/s", statsUp.getMean());
        //            logger.info("Max upload Use during download: {} KBytes/s", statsUp.getMax());
        //            logger.info("Avg download Use Total during downloag: {} KBytes/s", statsDown.getMean());
        //            logger.info("Min download Use Total during downloag: {} KBytes/s", statsDown.getMin());
        //            logger.info("-----------------------------------------------");
        //            logger.info("Avg buffering Time: {} ms ({})", statsWait.getMean(),
        //                    durationToString(Math.round(statsWait.getMean())));
        //            logger.info("Avg number of buffering : {}", statsBuf.getMean());
        //            logger.info("do not buffer : {}%", donotbuffer * 100);
        //            for (int size : map.keySet()) {
        //                logger.info("UtilitySet of Size " + size + " during {}ms ({})", map.get(size).getMean(),
        //                        durationToString(Math.round(map.get(size).getMean())));
        //            }
    }

    logger.info("=================================================");
    logger.info("Min nb of buffering: {}", nbBufferingNotFree.getMin());
    logger.info("Max nb of buffering: {}", nbBufferingNotFree.getMax());
    logger.info("Avg nb of buffering:  {}", nbBufferingNotFree.getMean());
    logger.info("percent of nonbuffering:  {}", nbNBufferingNotFree.getMean());
    logger.info("Std nb of buffering:  {}", nbBufferingNotFree.getStandardDeviation());
    logger.info("=================================================");
    logger.info("Min waiting: {} ms ({})", statsWaitingNotFree.getMin(),
            durationToString(Math.round(statsWaitingNotFree.getMin())));
    logger.info("Max waiting: {} ms ({})", statsWaitingNotFree.getMax(),
            durationToString(Math.round(statsWaitingNotFree.getMax())));
    logger.info("Avg waiting:  {} ms ({})", statsWaitingNotFree.getMean(),
            durationToString(Math.round(statsWaitingNotFree.getMean())));
    logger.info("Avg waiting (free):  {} ms ({})", statsWaitingFree.getMean(),
            durationToString(Math.round(statsWaitingFree.getMean())));
    logger.info("Std of waiting:  {} ms ({})", statsWaitingNotFree.getStandardDeviation(),
            durationToString(Math.round(statsWaitingNotFree.getStandardDeviation())));
    logger.info("=================================================");
    logger.info("Min jumpTime : {} ms ({})", jumpForwardStats.getMin(),
            durationToString(Math.round(jumpForwardStats.getMin())));
    logger.info("Max jumpTime : {} ms ({})", jumpForwardStats.getMax(),
            durationToString(Math.round(jumpForwardStats.getMax())));
    logger.info("Avg jumpTime : {} ms ({})", jumpForwardStats.getMean(),
            durationToString(Math.round(jumpForwardStats.getMean())));
    //        logger.info("=================================================");
    //        logger.info("Min nb of waiting: {}", nbWaiting.getMin());
    //        logger.info("Max nb of waiting: {}", nbWaiting.getMax());
    //        logger.info("Avg nb of waiting:  {}", nbWaiting.getMean());
    //        logger.info("Std nb of waiting:  {}",
    //                nbWaiting.getStandardDeviation());
    //        logger.info("=================================================");
    //        logger.info("Min nb of MisConnect: {}", nbMisConnect.getMin());
    //        logger.info("Max nb of MisConnect: {}", nbMisConnect.getMax());
    //        logger.info("Avg nb of MisConnect:  {}", nbMisConnect.getMean());
    //        logger.info("Std nb of MisConnect:  {}",
    //                nbMisConnect.getStandardDeviation());
    //        logger.info("Total nb of MisConnect:  {}",
    //                nbMisConnect.getN());
    logger.info("=================================================");
    logger.info("Total number of messages: {}", messages);
    logger.info("Total amount of traffic:  {} bytes", traffic);
    for (Map.Entry<Class<? extends RewriteableMsg>, ReceivedMessage> entry : messageHistogram.entrySet()) {
        logger.info("{}: #={}  \t bytes={}", new Object[] { String.format("%22s", entry.getKey().getName()),
                entry.getValue().getTotalCount(), entry.getValue().getTotalSize() });
    }
    logger.info("=================================================");

}

From source file:se.sics.gvod.web.server.VodMonitorServer.java

public VodMonitorServer() {
    this.view = new HashMap<VodAddress, OverlayViewEntry>();
    this.alivePeers = new TreeMap<VodAddress, VodNeighbors>();
    this.deadPeers = new TreeMap<VodAddress, VodNeighbors>();
    this.outstandingTimeouts = new HashSet<TimeoutId>();
    this.downloadTime = new SummaryStatistics();

    subscribe(handleInit, control);/*from   w  ww. j a v a 2s .c om*/

    subscribe(handleWebRequest, web);
    subscribe(handlePeerNotification, network);
    subscribe(handleDownloadCompleted, network);
    subscribe(handleViewEvictPeer, timer);
}

From source file:se.sics.kompics.p2p.experiment.bittorrent.BitTorrentSimulator.java

private void logStatistics() {
    SummaryStatistics downloadTime = new SummaryStatistics();
    for (long time : leecherDownloadTime.values()) {
        downloadTime.addValue(time);//  www  . j  a  v  a 2  s  .c o m
    }

    int messages = 0;
    long traffic = 0;
    for (ReceivedMessage rm : messageHistogram.values()) {
        messages += rm.getTotalCount();
        traffic += rm.getTotalSize();
    }

    long torrentSize = torrent.getPieceCount() * torrent.getPieceSize();

    logger.info("=================================================");
    logger.info("Content size: {} bytes", torrentSize);
    logger.info("Piece size:   {} bytes", torrent.getPieceSize());
    logger.info("Piece count:  {}", torrent.getPieceCount());
    logger.info("=================================================");
    logger.info("Number of leechers: {}", downloadTime.getN());
    logger.info("Min download time:  {} ms ({})", downloadTime.getMin(),
            durationToString(Math.round(downloadTime.getMin())));
    logger.info("Max download time:  {} ms ({})", downloadTime.getMax(),
            durationToString(Math.round(downloadTime.getMax())));
    logger.info("Avg download time:  {} ms ({})", downloadTime.getMean(),
            durationToString(Math.round(downloadTime.getMean())));
    logger.info("Std download time:  {} ms ({})", downloadTime.getStandardDeviation(),
            durationToString(Math.round(downloadTime.getStandardDeviation())));
    logger.info("Min download rate:  {} Bps", torrentSize / downloadTime.getMax() * 1000);
    logger.info("Max download rate:  {} Bps", torrentSize / downloadTime.getMin() * 1000);
    logger.info("Avg download rate:  {} Bps", torrentSize / downloadTime.getMean() * 1000);
    logger.info("=================================================");
    logger.info("Total number of messages: {}", messages);
    logger.info("Total amount of traffic:  {} bytes", traffic);
    for (Map.Entry<Class<? extends Message>, ReceivedMessage> entry : messageHistogram.entrySet()) {
        logger.info("{}: #={}  \t bytes={}",
                new Object[] { String.format("%22s", entry.getKey().getSimpleName()),
                        entry.getValue().getTotalCount(), entry.getValue().getTotalSize() });
    }
    logger.info("=================================================");
}

From source file:se.sics.kompics.p2p.overlay.cyclon.GraphUtil.java

public GraphUtil(TreeMap<OverlayAddress, CyclonNeighbors> alivePeers) {
    super();/*  w ww . j  av a2s .  com*/
    n = alivePeers.size();
    m = new byte[n][n];
    dist = new int[n][n];
    inDegree = new double[n];
    outDegree = new int[n];
    clustering = new double[n];
    a = new CyclonAddress[n];
    map = new HashMap<CyclonAddress, Integer>();
    neighbors = new int[n][];
    inStats = new SummaryStatistics();
    outStats = new SummaryStatistics();

    // map all alive nodes to a contiguous sequence of integers
    {
        int p = 0;
        for (OverlayAddress address : alivePeers.keySet()) {
            CyclonAddress src = (CyclonAddress) address;
            a[p] = src;
            map.put(src, p);
            p++;
        }
    }

    // build adjacency matrix
    int d = -1;
    {
        try {
            for (int s = 0; s < a.length; s++) {
                CyclonAddress src = a[s];
                CyclonNeighbors neigh = alivePeers.get(src);
                int nn = 0;
                for (CyclonNodeDescriptor desc : neigh.getDescriptors()) {
                    CyclonAddress dst = desc.getCyclonAddress();
                    if (!map.containsKey(dst)) {
                        continue;
                    }
                    d = map.get(dst);
                    m[s][d] = 1;
                    inDegree[d]++;
                    outDegree[s]++;
                    nn++;
                }
                neighbors[s] = new int[nn];
                nn = 0;
                for (CyclonNodeDescriptor desc : neigh.getDescriptors()) {
                    CyclonAddress dst = desc.getCyclonAddress();
                    if (map.containsKey(dst)) {
                        neighbors[s][nn++] = map.get(dst);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
    // build distance matrix, clustering coefficient, average path length
    // diameter and average degrees
    {
        for (int i = 0; i < n; i++) {
            bfs(i, dist[i]);

            // we compute the clustering coefficient here
            int neigh[] = neighbors[i];
            if (neigh.length <= 1) {
                clustering[i] = 1.0;
                continue;
            }
            int edges = 0;

            for (int j = 0; j < neigh.length; j++) {
                for (int k = j + 1; k < neigh.length; k++) {
                    if (m[neigh[j]][neigh[k]] > 0 || m[neigh[k]][neigh[j]] > 0) {
                        ++edges;
                    }
                }
            }
            clustering[i] = ((edges * 2.0) / neigh.length) / (neigh.length - 1);
        }
        int k = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j)
                    continue;
                if (dist[i][j] == n) {
                    infinitePathCount++;
                    continue;
                }
                if (dist[i][j] > diameter) {
                    diameter = dist[i][j];
                }
                avgPathLength = (avgPathLength * k + dist[i][j]) / (k + 1);
                k++;
            }
            inStats.addValue(inDegree[i]);
            outStats.addValue(outDegree[i]);
            // avgIn = (avgIn * i + inDegree[i]) / (i + 1);
            // minIn = minIn > inDegree[i] ? inDegree[i] : minIn;
            // maxIn = maxIn < inDegree[i] ? inDegree[i] : maxIn;
            // avgOut = (avgOut * i + outDegree[i]) / (i + 1);
            avgClustering = (avgClustering * i + clustering[i]) / (i + 1);
        }
    }
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.AbstractCompoundDataset.java

@Override
protected void calculateSummaryStats() {
    IndexIterator iter = getIterator();// w  w  w  .ja  v a2s. c  o  m
    SummaryStatistics[] stats = new SummaryStatistics[isize];
    for (int i = 0; i < isize; i++)
        stats[i] = new SummaryStatistics();

    double[] vals = new double[isize];
    while (iter.hasNext()) {
        boolean okay = true;
        for (int i = 0; i < isize; i++) {
            final double val = getElementDoubleAbs(iter.index + i);
            if (Double.isInfinite(val) || Double.isNaN(val)) {
                okay = false;
                break;
            }
            vals[i] = val;
        }
        if (!okay)
            continue;
        for (int i = 0; i < isize; i++)
            stats[i].addValue(vals[i]);
    }

    // now all the calculations are done, add the values into store
    storedValues = new HashMap<String, Object>();
    for (int i = 0; i < isize; i++)
        storedValues.put("stats-" + i, stats[i]);
}