Examples of Histogram


Examples of gem.util.Histogram

    }
  }
 
  public Histogram getDistribution(boolean[] pos, double range)
  {
    Histogram h = new Histogram(range);
    for (int i = 0; i < value.length; i++)
    {
      if (pos == null || pos[i]) h.count(value[i]);
    }
    return h;
  }
View Full Code Here

Examples of gov.nist.microanalysis.Utility.Histogram

public class BSERadialDistributionListenerTest {

    @Test
    public void testRadialDistributionListenerEqualRadii() {
        BSERadialDistributionListener listener;
        Histogram h;

        listener = new BSERadialDistributionListener(Math2.ORIGIN_3D,
                Math2.Z_AXIS, 100.0, 10, false);
        h = listener.getDistribution();
        assertEquals(10, h.binCount());
        assertEquals(0.0, h.minValue(0), 1e-4);
        assertEquals(10.0, h.maxValue(0), 1e-4);
        assertEquals(10.0, h.minValue(1), 1e-4);
        assertEquals(20.0, h.maxValue(1), 1e-4);

        listener =
                new BSERadialDistributionListener(Math2.ORIGIN_3D,
                        Math2.Z_AXIS, 100.0, 10, true);
        h = listener.getDistribution();
        assertEquals(10, h.binCount());
        assertEquals(0.0, h.minValue(0), 1e-4);
        assertEquals(31.62278, h.maxValue(0), 1e-4);
        assertEquals(31.62278, h.minValue(1), 1e-4);
        assertEquals(44.72136, h.maxValue(1), 1e-4);
        assertEquals(Math.pow(h.maxValue(0), 2) - Math.pow(h.minValue(0), 2),
                Math.pow(h.maxValue(1), 2) - Math.pow(h.minValue(1), 2), 1e-4);
    }
View Full Code Here

Examples of io.druid.query.aggregation.Histogram

    final float[] breaks = new float[numBreaks];
    for (int i = 0; i < numBreaks; i++) {
      breaks[i] = min + stride * i;
    }

    Histogram h = new Histogram(breaks);
    for (float v : values) {
      h.offer(v);
    }
    double[] hcounts = h.asVisual().counts;

    ApproximateHistogram ah1 = new ApproximateHistogram(resolution);
    ApproximateHistogram ah2 = new ApproximateHistogram(combinedResolution);
    ApproximateHistogram tmp = new ApproximateHistogram(resolution);
    for (int i = 0; i < numValues; ++i) {
      tmp.offer(values[i]);
      if ((i + 1) % numPerHist == 0) {
        ah1.fold(tmp);
        ah2.foldRule(tmp, null, null);
        tmp = new ApproximateHistogram(resolution);
      }
    }
    double[] ahcounts1 = ah1.toHistogram(breaks).getCounts();
    double[] ahcounts2 = ah2.toHistogram(breaks).getCounts();

    float err1 = 0;
    float err2 = 0;
    for (int j = 0; j < hcounts.length; j++) {
      err1 += Math.abs((hcounts[j] - ahcounts1[j]) / numValues);
      err2 += Math.abs((hcounts[j] - ahcounts2[j]) / numValues);
    }

    if (debug) {
      float sum = 0;
      for (double v : hcounts) {
        sum += v;
      }
      System.out.println("Exact Histogram Sum:");
      System.out.println(sum);
      sum = 0;
      for (double v : ahcounts1) {
        sum += v;
      }
      System.out.println("Approximate Histogram Sum:");
      System.out.println(sum);
      sum = 0;
      for (double v : ahcounts2) {
        sum += v;
      }
      System.out.println("Approximate Histogram Rule Fold Sum:");
      System.out.println(sum);
      System.out.println("Exact Histogram:");
      System.out.println(h.asVisual());
      System.out.println("Approximate Histogram:");
      System.out.println(ah1.toHistogram(breaks));
      System.out.println("Approximate Histogram Rule Fold:");
      System.out.println(ah2.toHistogram(breaks));
      System.out.format("Error for approximate histogram: %s \n", err1);
View Full Code Here

Examples of javax.media.jai.Histogram

            final OperationJAI op = new OperationJAI("Histogram"); //$NON-NLS-1$
            ParameterValueGroup params = op.getParameters();
            params.parameter("Source").setValue(recoloredGridCoverage); //$NON-NLS-1$

            recoloredGridCoverage = (GridCoverage2D) op.doOperation(params, null);
            final Histogram h = (Histogram) recoloredGridCoverage.getProperty("histogram"); //$NON-NLS-1$

            Display.getDefault().asyncExec(new Runnable(){
                public void run() {
                    rgbViewer.updateHistograms(h.getBins());
                }
            });

            return Status.OK_STATUS;
        }
View Full Code Here

Examples of javax.media.jai.Histogram

            new String[]{"512", Integer.toString((512 - splitOffset) / 2),
                         Integer.toString(
                             512 - splitOffset - (512 - splitOffset) / 2),
                         Integer.toString(splitOffset)}
        };
        Histogram histogram[] = new Histogram[4];
        for (int i = 0; i < 4; i++) {
            InputStream stream = TestUtilities.
                doImageTranscodeTest(expectations,
                                     OutputImageRules.GRAYSCALEPNG8, "lena.tiff",
                                     new String[][]{
                                         {"v.width", params[1][i]},
                                         {"v.p", getProtectedArea(
                                             Integer.parseInt(params[1][i]),
                                             params[0][i])}},
                                     true);
            RenderedOp image = JAI.create("ImageRead", ImageIO.createImageInputStream(stream));
            // Create the parameter block.
            PlanarImage dst = null;
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);               // Specify the source image
            pb.add(null);                      // No ROI
            pb.add(1);                         // Sampling
            pb.add(1);                         // periods
            // Perform the histogram operation.
            dst = JAI.create("histogram", pb, null);
           
            // Retrieve the histogram data.
            Histogram hist = (Histogram) dst.getProperty("histogram");
            histogram[i] = hist;
        }
        for (int i = 0; i < 256; i++) {
            assertEquals(histogram[0].getBinSize(0, i),
                         histogram[1].getBinSize(0, i) +
View Full Code Here

Examples of kanakata.analytics.Histogram

            }

            @Override
            public void onAnswerIncorrect(Kana answer) {
                activateTabFor(kana);
                Histogram histogram = selectHistogramFor(kana);
                histogram.registerIncorrectResponse(kana);
                Response response = histogram.response(kana);
                Bin incorrect = incorrectBins.get(kana);
                incorrect.setLevel(response.getIncorrect());
            }

            @Override
            public void onAnswerCorrect() {
                activateTabFor(kana);
                Histogram histogram = selectHistogramFor(kana);
                histogram.registerCorrectResponse(kana);
                Response response = histogram.response(kana);
                Bin correct = correctBins.get(kana);
                correct.setLevel(response.getCorrect());
            }

            @Override
            public void onSkipped() {
                // TODO: paint skipped in yellow
                Histogram histogram = selectHistogramFor(kana);
                histogram.registerSkippedResponse(kana);
            }

            @Override
            public void onEnd() {
                completeHistogram();
View Full Code Here

Examples of org.HdrHistogram.Histogram

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(lastTime));

            Histogram accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            Histogram intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2000", 2000, accumulatedHistogram.getTotalCount());

            System.out.println("Pausing detector threads for 5 seconds:");
            pauseDetector.stallDetectorThreads(0x7, 5000 * MSEC);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 15 sec from start

            // Report without forcing interval measurement update:

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Post-pause, pre-observation Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause, pre-observation Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2000", 2000, accumulatedHistogram.getTotalCount());

            // Still @ 15 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Post-pause, post-observation Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause, post-observation Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2000", 2998, accumulatedHistogram.getTotalCount());

            pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (500 * MSEC));
            TimeServices.moveTimeForwardMsec(500);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 15.5 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Post-pause Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2000", 2998, accumulatedHistogram.getTotalCount());

            pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (500 * MSEC));
            TimeServices.moveTimeForwardMsec(500);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 16 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Post-pause Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2999", 2998, accumulatedHistogram.getTotalCount());

            pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (2000 * MSEC));
            TimeServices.moveTimeForwardMsec(2000);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 18 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Post-pause Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2999", 2998, accumulatedHistogram.getTotalCount());

            for (int i = 0 ; i < 100; i++) {
                pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (5 * MSEC));
                TimeServices.moveTimeForwardMsec(5);
                long now = TimeServices.nanoTime();
                latencyStats.recordLatency(now - lastTime);
                lastTime = now;
            }

            pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (500 * MSEC));
            TimeServices.moveTimeForwardMsec(500);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 19 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();


            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();
            System.out.println("Post-pause Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());


            pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (500 * MSEC));
            TimeServices.moveTimeForwardMsec(500);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 19.5 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();
            System.out.println("Post-pause Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2000", 3098, accumulatedHistogram.getTotalCount());
        } catch (InterruptedException ex) {

        }
View Full Code Here

Examples of org.HdrHistogram_voltpatches.Histogram

    /*
     * Get a that tracks from 1 microsecond to 10 seconds with
     * 2 significant value digits
     */
    public static Histogram constructHistogram() {
        return new Histogram( LOWEST_TRACKABLE, HIGHEST_TRACKABLE, SIGNIFICANT_VALUE_DIGITS);
    }
View Full Code Here

Examples of org.apache.kafka.common.metrics.stats.Histogram

    private static final double EPS = 0.0000001d;

    @Test
    public void testHistogram() {
        BinScheme scheme = new ConstantBinScheme(12, -5, 5);
        Histogram hist = new Histogram(scheme);
        for (int i = -5; i < 5; i++)
            hist.record(i);
        for (int i = 0; i < 10; i++)
            assertEquals(scheme.fromBin(i + 1), hist.value(i / 10.0 + EPS), EPS);
    }
View Full Code Here

Examples of org.graylog2.restclient.lib.metrics.Histogram

                case GAUGE:
                    return new Gauge(metric.get("value"));
                case HISTOGRAM:
                    Map<String, Object> histoTiming = (Map<String, Object>) metric.get("time");
                    double count = ((Number) metric.get("count")).doubleValue();
                    return new Histogram(histoTiming, count);
            }
        } catch(Exception e) {
            LOG.error("Could not parse metric: " + metric.toString(), e);
            throw new RuntimeException("Could not map metric to type. (more information in log) Type was: [" + this.type + "]", e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.