Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6D66D200ACA for ; Thu, 9 Jun 2016 20:31:27 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6C296160A29; Thu, 9 Jun 2016 18:31:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8D34F160A58 for ; Thu, 9 Jun 2016 20:31:26 +0200 (CEST) Received: (qmail 71777 invoked by uid 500); 9 Jun 2016 18:31:25 -0000 Mailing-List: contact dev-help@apex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@apex.apache.org Delivered-To: mailing list dev@apex.apache.org Received: (qmail 71766 invoked by uid 99); 9 Jun 2016 18:31:25 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2016 18:31:25 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 5453A1A06DD for ; Thu, 9 Jun 2016 18:31:25 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -5.446 X-Spam-Level: X-Spam-Status: No, score=-5.446 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id oj-jqsitGcLJ for ; Thu, 9 Jun 2016 18:31:22 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id DED405F1D5 for ; Thu, 9 Jun 2016 18:31:21 +0000 (UTC) Received: (qmail 71243 invoked by uid 99); 9 Jun 2016 18:31:21 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2016 18:31:21 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 091EB2C0452 for ; Thu, 9 Jun 2016 18:31:21 +0000 (UTC) Date: Thu, 9 Jun 2016 18:31:21 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@apex.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (APEXMALHAR-2094) Quantiles sketch operator MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 09 Jun 2016 18:31:27 -0000 [ https://issues.apache.org/jira/browse/APEXMALHAR-2094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15323050#comment-15323050 ] ASF GitHub Bot commented on APEXMALHAR-2094: -------------------------------------------- Github user sandeep-n commented on a diff in the pull request: https://github.com/apache/apex-malhar/pull/301#discussion_r66496208 --- Diff: sketches/src/main/java/org/apache/apex/malhar/sketches/QuantilesEstimator.java --- @@ -0,0 +1,188 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.apex.malhar.sketches; + +import com.yahoo.sketches.quantiles.QuantilesSketch; + +import com.datatorrent.api.DefaultInputPort; +import com.datatorrent.api.DefaultOutputPort; +import com.datatorrent.api.annotation.OperatorAnnotation; +import com.datatorrent.common.util.BaseOperator; + +/** + * An implementation of BaseOperator that computes a "sketch" (a representation of the probability distribution using + * a low memory footprint) of the incoming numeric data, and evaluates/outputs the cumulative distribution function and + * quantiles of the probability distribution. Leverages the quantiles sketch implementation from the Yahoo Datasketches + * Library. + *

+ * Input Port(s) :
+ * data : Data values input port.
+ *
+ * Output Port(s) :
+ * cdfOutput : cumulative distribution function output port.
+ * quantilesOutput : quantiles output port.
+ *
+ * Partitions : No unifier. Merging these sketches is non-trivial.
+ *
+ + */ +@OperatorAnnotation(partitionable = false) +public class QuantilesEstimator extends BaseOperator +{ + /** + * Constructor that allows non-default initialization of the quantile sketch object + * + * @param k: Parameter that determines accuracy and memory usage of quantile sketch. See QuantilesSketch + * documentation for details + * @param seed: The quantile sketch algorithm is inherently random. Set seed to 0 for reproducibility in testing, but + * do not set otherwise. + */ + public QuantilesEstimator(int k, short seed) + { + quantilesSketch = QuantilesSketch.builder().setSeed(seed).build(k); + } + + private transient QuantilesSketch quantilesSketch = QuantilesSketch.builder().build(); + + /** + * This field determines the specific quantiles to be calculated. For a stream of numbers, the quantile at a value + * 0 <= p <= 1 is the number x such that a fraction p of the numbers in the sorted stream are less than x. E.g., the + * quantile at p = 0.5 is the median (half the numbers in the stream are less than the median). + * The default is set to compute the standard quartiles (4-quantiles). + */ + private double[] fractions = {0.0, 0.25, 0.50, 0.75, 1.00}; + /** + * This field determines the intervals on which the probability mass function is computed. + */ + private double[] pmfIntervals = {}; + + /** + * This operator computes three different quantities which are output on separate output ports. If not using any of + * these quantities, these variables can be set to avoid unnecessary computation. + */ + private boolean computeCdf = true; --- End diff -- That would be cleaner. Thanks for the suggestion. > Quantiles sketch operator > ------------------------- > > Key: APEXMALHAR-2094 > URL: https://issues.apache.org/jira/browse/APEXMALHAR-2094 > Project: Apache Apex Malhar > Issue Type: New Feature > Reporter: Sandeep Narayanaswami > Assignee: Sandeep Narayanaswami > Priority: Minor > > An operator that "sketches" in an online fashion the probability distribution of an input (numeric) data stream, enabling computation of quantiles and cumulative distribution functions. -- This message was sent by Atlassian JIRA (v6.3.4#6332)