Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 675E9DA59 for ; Mon, 12 Nov 2012 19:48:13 +0000 (UTC) Received: (qmail 1924 invoked by uid 500); 12 Nov 2012 19:48:13 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 1742 invoked by uid 500); 12 Nov 2012 19:48:12 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 1731 invoked by uid 99); 12 Nov 2012 19:48:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Nov 2012 19:48:12 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of phil.steitz@gmail.com designates 209.85.160.43 as permitted sender) Received: from [209.85.160.43] (HELO mail-pb0-f43.google.com) (209.85.160.43) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Nov 2012 19:48:04 +0000 Received: by mail-pb0-f43.google.com with SMTP id um15so1148484pbc.30 for ; Mon, 12 Nov 2012 11:47:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=jKe3bEkUje9xtfsaqKlUvr3Ck0Yh9LZlZJbXRnoJmkM=; b=thL6oj20hKKdFJ+4lVcNAJfI5o0TX6yFKscB/nGmqwR6eLBjdMA1/qVxTipJOC8kMK aMcATyhSXxOF516F62Qe7x3VjNME45RIoTHJkPKjWML+3H3Yh75gZIOov/PDHSAjDuq3 60PeeSJHEGsDBdUqDCuJP/RxHz2OSlTAJeEc375SHLXCRI/bk5Zo3fSU7FeVlObfPYIS olnHcbKNsh/qkD6D6V/NSkrr6HXAX9ctCqyAOYGe8pA86YipGcGPb0N5YvA2LNnNKUWU /QKXge53aLIQipr6HX3rqiOJdChipd8WgoRhGtsz+HvKsM0jABXtux6whpZINrvwvUy0 Lp2g== Received: by 10.68.251.197 with SMTP id zm5mr53283206pbc.30.1352749664504; Mon, 12 Nov 2012 11:47:44 -0800 (PST) Received: from [10.4.70.30] ([107.0.25.2]) by mx.google.com with ESMTPS id bd2sm4747370pab.36.2012.11.12.11.47.42 (version=SSLv3 cipher=OTHER); Mon, 12 Nov 2012 11:47:43 -0800 (PST) Message-ID: <50A1525D.3050002@gmail.com> Date: Mon, 12 Nov 2012 11:47:41 -0800 From: Phil Steitz User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: Commons Developers List Subject: Re: [Math] MATH-894 References: <20121112140517.GI3397@dusk.harfang.homelinux.org> <50A13E81.3020905@gmail.com> <008501cdc10d$3dec62d0$b9c52870$@gmail.com> In-Reply-To: <008501cdc10d$3dec62d0$b9c52870$@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 11/12/12 11:38 AM, Patrick Meyer wrote: > Please keep ResizeableDoubleArray as its own class. I find it very useful > for more than descriptive statistics. I do like the idea of adding an apply > method to it. Thanks for speaking up :) I think Gilles is right though on the broken encapsulation, so maybe its best to add the apply or "applyStatistic" method as described below. Phil > > Patrick > > -----Original Message----- > From: Phil Steitz [mailto:phil.steitz@gmail.com] > Sent: Monday, November 12, 2012 1:23 PM > To: Commons Developers List > Subject: Re: [Math] MATH-894 > > On 11/12/12 6:05 AM, Gilles Sadowski wrote: >> Hi. >> >> What do you think about deprecating "getInternalValues"? >> Its only use is in "DescriptiveStatistics". I guess that the current >> usage could save some time (by avoiding the creation of an array and >> copying the elements), so that acces to the internal representation should > be retained. > > That is why it is there. ResizeableDoubleArray was created to be the > backing store for DescriptiveStatistics. We don't actually use it anywhere > else, so I am wondering if it might in fact be better to deprecate the > entire class and aim to make it a private inner class of > DescriptiveStatistics. That way, the broken encapsulation that you point > out will be less of an issue. The idea behind the class is to support a > "rolling window" of data from a stream that statistics can be applied to. > If we want to keep it separate (or even not, actually), it might be better > for it to expose an apply method that takes a UnivariateStatistic as an > argument and applies the statistic to the currently defined window. So the > following method from DescriptiveStatistics public double > apply(UnivariateStatistic stat) { > return stat.evaluate(eDA.getInternalValues(), eDA.start(), > eDA.getNumElements()); } would be implemented in ResizeableDoubleArray > (just removing the eDA. everywhere). Then in DescriptiveStatistics you > would have > > public double apply(UnivariateStatistic stat) { > return eDA.apply(stat); > } > possibly renaming the version in RDA. But given all of the fuss over this > class that really is just there to serve DescriptiveStatistics, I think it > may be best to just make it a private inner class of DescriptiveStatistics. > > Phil > > >> If so, I think that the name "getInternalValues" should be changed in >> order to make it explicit that we are exposing an instance's field >> (whose modification will be reflected in the object's state). The >> suffix "...Values" is misleading; I suggest "getInternalArray" since >> current API (and current usage) anyways forbids that another data > structure be used. >> [The alternative would be to enhance encapsulation by hiding the >> internal representation altogether, thus removing the methods > "getInternalValues()" >> and "start()".] >> >> I also notice that the "clear()" method reallocates the internal array. >> IMO, it is unnecessarily inefficient. If one wanted to get this >> behaviour, one could just create a new object. However, when reusing >> the same object, users could legitimately expect that no allocation >> occurs and that it is only the _contents_ that is discarded. >> >> >> Regards, >> Gilles >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >> For additional commands, e-mail: dev-help@commons.apache.org >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org