for (StatisticsResult statisticsResult : statisticsResults) { standardDeviationS1 += statisticsResult.getCount() * Math.pow(statisticsResult.getStandardDeviation(), 2.0); standardDeviationS2 += statisticsResult.getCount() * Math.pow(statisticsResult.getAverage() - average, 2.0);
for (StatisticsResult statisticsResult : statisticsResults) { standardDeviationS1 += statisticsResult.getCount() * Math.pow(statisticsResult.getStandardDeviation(), 2.0); standardDeviationS2 += statisticsResult.getCount() * Math.pow(statisticsResult.getAverage() - average, 2.0);
public JSONObject getAverages(int minutes, Graph graph, Authorizations authorizations) { Date minutesAgo = new Date(System.currentTimeMillis() - minutes * 60 * 1000); Query q = graph.query(authorizations) .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), PingOntology.IRI_CONCEPT_PING) .has(PingOntology.CREATE_DATE.getPropertyName(), Compare.GREATER_THAN, minutesAgo) .limit(0); q.addAggregation(new StatisticsAggregation(PingOntology.SEARCH_TIME_MS.getPropertyName(), PingOntology.SEARCH_TIME_MS.getPropertyName())); q.addAggregation(new StatisticsAggregation(PingOntology.RETRIEVAL_TIME_MS.getPropertyName(), PingOntology.RETRIEVAL_TIME_MS.getPropertyName())); q.addAggregation(new StatisticsAggregation(PingOntology.GRAPH_PROPERTY_WORKER_WAIT_TIME_MS.getPropertyName(), PingOntology.GRAPH_PROPERTY_WORKER_WAIT_TIME_MS.getPropertyName())); q.addAggregation(new StatisticsAggregation(PingOntology.LONG_RUNNING_PROCESS_WAIT_TIME_MS.getPropertyName(), PingOntology.LONG_RUNNING_PROCESS_WAIT_TIME_MS.getPropertyName())); QueryResultsIterable<Vertex> vertices = q.vertices(); StatisticsResult searchTimeAgg = vertices.getAggregationResult(PingOntology.SEARCH_TIME_MS.getPropertyName(), StatisticsResult.class); StatisticsResult retrievalTimeAgg = vertices.getAggregationResult(PingOntology.RETRIEVAL_TIME_MS.getPropertyName(), StatisticsResult.class); StatisticsResult gpwWaitTimeAgg = vertices.getAggregationResult(PingOntology.GRAPH_PROPERTY_WORKER_WAIT_TIME_MS.getPropertyName(), StatisticsResult.class); StatisticsResult lrpWaitTimeAgg = vertices.getAggregationResult(PingOntology.LONG_RUNNING_PROCESS_WAIT_TIME_MS.getPropertyName(), StatisticsResult.class); JSONObject json = new JSONObject(); json.put("pingCount", searchTimeAgg.getCount()); json.put("averageSearchTime", searchTimeAgg.getAverage()); json.put("averageRetrievalTime", retrievalTimeAgg.getAverage()); json.put("graphPropertyWorkerCount", gpwWaitTimeAgg.getCount()); json.put("averageGraphPropertyWorkerWaitTime", gpwWaitTimeAgg.getAverage()); json.put("longRunningProcessCount", lrpWaitTimeAgg.getCount()); json.put("averageLongRunningProcessWaitTime", lrpWaitTimeAgg.getAverage()); return json; }
private ClientApiSearchResponse.AggregateResult toClientApiStatisticsResult(StatisticsResult agg) { ClientApiSearchResponse.StatisticsAggregateResult result = new ClientApiSearchResponse.StatisticsAggregateResult(); result.setCount(agg.getCount()); result.setAverage(agg.getAverage()); result.setMin(agg.getMin()); result.setMax(agg.getMax()); result.setStandardDeviation(agg.getStandardDeviation()); result.setSum(agg.getSum()); return result; }
assertEquals(25.0, stats.getMax(), 0.1); assertEquals(2.35702, stats.getStandardDeviation(), 0.1); assertEquals(21.666666, stats.getAverage(), 0.1); assertEquals(0.0, stats.getMin(), 0.1); assertEquals(0.0, stats.getMax(), 0.1); assertEquals(0.0, stats.getAverage(), 0.1); assertEquals(0.0, stats.getStandardDeviation(), 0.1); assertEquals(20.0, stats.getMin(), 0.1); assertEquals(30.0, stats.getMax(), 0.1); assertEquals(23.75, stats.getAverage(), 0.1); assertEquals(4.14578, stats.getStandardDeviation(), 0.1);
assertEquals(25.0, stats.getMax(), 0.1); assertEquals(2.35702, stats.getStandardDeviation(), 0.1); assertEquals(21.666666, stats.getAverage(), 0.1); assertEquals(0.0, stats.getMin(), 0.1); assertEquals(0.0, stats.getMax(), 0.1); assertEquals(0.0, stats.getAverage(), 0.1); assertEquals(0.0, stats.getStandardDeviation(), 0.1); assertEquals(20.0, stats.getMin(), 0.1); assertEquals(30.0, stats.getMax(), 0.1); assertEquals(23.75, stats.getAverage(), 0.1); assertEquals(4.14578, stats.getStandardDeviation(), 0.1);