From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1511 invoked by alias); 9 Aug 2014 16:55:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 1491 invoked by uid 89); 9 Aug 2014 16:55:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: vms173015pub.verizon.net Received: from vms173015pub.verizon.net (HELO vms173015pub.verizon.net) (206.46.173.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Aug 2014 16:55:27 +0000 Received: from [192.168.1.4] ([unknown] [173.69.187.216]) by vms173015.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0NA1008V0TO31H80@vms173015.mailsrvcs.net>; Sat, 09 Aug 2014 11:55:16 -0500 (CDT) Message-id: <53E65272.5050501@verizon.net> Date: Sat, 09 Aug 2014 16:55:00 -0000 From: Ed Smith-Rowland <3dw4rd@verizon.net> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-version: 1.0 To: libstdc++@gcc.gnu.org, Ulrich Drepper Cc: Jonathan Wakely , GCC Patches Subject: Re: [PATCH] libstdc++: add uniform on sphere distribution References: <87a98eow4m.fsf@x240.local.i-did-not-set--mail-host-address--so-tickle-me> <20140723102908.GM2361@redhat.com> <87d2catvi3.fsf@x240.local.i-did-not-set--mail-host-address--so-tickle-me> In-reply-to: Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit X-SW-Source: 2014-08/txt/msg00955.txt.bz2 On 08/09/2014 11:33 AM, Marc Glisse wrote: > On Sat, 9 Aug 2014, Ulrich Drepper wrote: > >>> If you are going to specialize for dim 2, I imagine you won't be >>> computing >>> normal distributions, you will only generate a point uniformy in a >>> square >>> and reject it if it is not in the ball? (interestingly enough this >>> is used >>> as a subroutine by the implementation of normal_distribution) >> >> We need to be *on* the circle, not inside. > > Yes, you still need the normalization step (divide by the norm). It > works whether you start from a uniform distribution in the disk or > from a Gaussian in the plane, but the first one is easier to generate > (generate points in a square until you get one in the disk). When the > dimension becomes higher, the probability that a point in the cube > actually belongs to the ball decreases, and it becomes cheaper to use > a Gaussian. > If we pull in the implementation of normal you will just be able to use the two values that normal computes on the first, (and third, ...) calls without doing two calls. That and hypot would be a real win.