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 146502009C6 for ; Tue, 17 May 2016 01:42:24 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1300D160A19; Mon, 16 May 2016 23:42:24 +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 5C691160A16 for ; Tue, 17 May 2016 01:42:23 +0200 (CEST) Received: (qmail 84012 invoked by uid 500); 16 May 2016 23:42:17 -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 84000 invoked by uid 99); 16 May 2016 23:42:17 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 May 2016 23:42:17 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id C33BEC6CB4 for ; Mon, 16 May 2016 23:42:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.491 X-Spam-Level: ** X-Spam-Status: No, score=2.491 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, GAPPY_SUBJECT=1.312, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id ddeBqdkBGHf4 for ; Mon, 16 May 2016 23:42:14 +0000 (UTC) Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 2FD6B5F19B for ; Mon, 16 May 2016 23:42:14 +0000 (UTC) Received: by mail-wm0-f51.google.com with SMTP id g17so3151130wme.1 for ; Mon, 16 May 2016 16:42:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=+AHWHdA+HcoVQbcbzluXBAqIbpgQGWJmBU8uUxDzTpk=; b=HSjSU6jSUApycaLi+J256KtJqQvxfc8wY+bJBTosS9ihyeuyEwvqTAwN5VmMsLEM/h ZRHCcZyk0cXZoOp3sjYD2lrQWDePS9AqEL2JDes2MWocRB7Xv3ocXCX1sFSV37Wcy/HB Gs1ytuP09GxNNBR4CfXkX37y/817pBilDSTKJLoSNgLRTKbHuoRELuY8QL+fvgPFrK2i Mr+wQUuZ8v2PZQGfSij1r71nFqrqCewc/mJckD7AjvG2IkfpYe5JPxBy9rSEl78lwbCC NLwUzQUGLAzgTGK7+w2YaBYYXHZDd9bmuBDqtkT/6uMyYKSBeYF9E+lSoH+blNuC8tQU TYUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=+AHWHdA+HcoVQbcbzluXBAqIbpgQGWJmBU8uUxDzTpk=; b=LMv43w0bxGLbCwy7JfQ/X3JHEOEUGlvTkclFNI0T7CkUfvqRTI7/NNI/Y0H1VsUPW9 jkjD4MN8UBvlf1YoPSQtw8YPP5I1hCH9fAXF8RX7kSfJGZqYjr8zFnWYUJPXzcWhR4WB viLb/uFBU3BtYeNHJZORdlMCiNsNmYhorgVrto290SkTCwMvVrbrxWcqTUU7oBNXU4Kx zBZ9NGtaOZb56lt8fCsPQhC6L6nzsj+bA7cBGtmduOFujqqOzrWZiFwZSg41eg47DTIF hSF8WoB6Co0UJO38ps17JVJ7o5CZqxXQbUnSXl36jeTKJdvPt4Tx8yoK8LFPA9KfnxwT IzTw== X-Gm-Message-State: AOPr4FWHgtTryxI+wqj+upHs2dZadUB9woInO5+dAq9AVXVMTi1GwMXsQrioVdacPVrAYtE0ykd7w9POfqw0jA== MIME-Version: 1.0 X-Received: by 10.194.108.197 with SMTP id hm5mr32190962wjb.167.1463442132856; Mon, 16 May 2016 16:42:12 -0700 (PDT) Received: by 10.28.52.14 with HTTP; Mon, 16 May 2016 16:42:12 -0700 (PDT) In-Reply-To: References: Date: Mon, 16 May 2016 16:42:12 -0700 Message-ID: Subject: Re: [Math] Design of "o.a.c.m.stat.descriptive.moment" From: "michael.brzustowicz@gmail.com" To: Commons Developers List Content-Type: multipart/alternative; boundary=047d7bf10a707a78a10532fe2cc3 archived-at: Mon, 16 May 2016 23:42:24 -0000 --047d7bf10a707a78a10532fe2cc3 Content-Type: text/plain; charset=UTF-8 Hi Giles, I ran into the same problem. Many months ago I asked about higher order moments in Multivariate Stats. I pulled the code and implemented third and fourth order moments in MVStats. I had to "unprotect" some methods and mostly got everything working. The problem arose (I think) in one of the unit tests for AggregateBlahBlah where the code actually uses stat quantities (like std dev) to go backwards to get 2nd moment. I gave up when I saw that :) I think it could be reimplemented easier. Why not compose a class called StatisticalMoments which contains 1st, 2nd, 3rd, 4th moments as hard coded variables, with hard coded methods for updating those moments and merging them. Higher order moments (than fourth) could be contained in array and the requisite update methods could be the generic expressions for n-order update / merge. In this way, all other stat classes could inherit the StatisticalMoments class. Maybe you have all thought of doing it this way already, and it failed spectacularly for some reason :) Thanx, Mike Brzustowicz On Sat, May 7, 2016 at 10:11 AM, Gilles wrote: > Hi. > > Looking at some way out for MATH-1228, I uncovered what looks to me > as an abuse of inheritance: "ThirdMoment" extends "SecondMoment". > > "Skewness" contains a "ThirdMoment" instance variable but, in order > to compute its value, "m3" (cf. "getResult()"), it also must read > the result of that variable's parent type ("SecondMoment"), i.e. "m2". > > IMO, this makes no sense at the conceptual level: a third moment is > _not_ a second moment. > > And the problem is compounded as: > * "FourthMoment" inherits from "ThirdMoment", and > * "SecondMoment" extends "FirstMoment". > > In this strange hierarchy, the fields are all "protected" in order > to be accessed from subclasses, making the whole thing fragile and > inefficient (as pointed out by the OP of MATH-1228). > > From a programming POV, the design is flawed because "getResult()" > is, rightfully, intended to be overridden in subclasses. > However, "protected" access is used to work around that very purpose > of inheritance. > And thus, good practice (cf. MATH-758) cannot be implemented. > > Did I miss the point of this package's design? > Or am I right that it should be completely redesigned? > > > Regards, > Gilles > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > --047d7bf10a707a78a10532fe2cc3--