From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7962 invoked by alias); 9 Aug 2014 15:33:54 -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 7930 invoked by uid 89); 9 Aug 2014 15:33:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail3-relais-sop.national.inria.fr Received: from mail3-relais-sop.national.inria.fr (HELO mail3-relais-sop.national.inria.fr) (192.134.164.104) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Sat, 09 Aug 2014 15:33:47 +0000 Received: from stedding.saclay.inria.fr (HELO stedding) ([193.55.250.194]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/AES128-SHA; 09 Aug 2014 17:33:44 +0200 Received: from glisse (helo=localhost) by stedding with local-esmtp (Exim 4.84_RC1) (envelope-from ) id 1XG8eN-0000eg-PN; Sat, 09 Aug 2014 17:33:43 +0200 Date: Sat, 09 Aug 2014 15:33:00 -0000 From: Marc Glisse Reply-To: libstdc++@gcc.gnu.org To: Ulrich Drepper cc: "libstdc++@gcc.gnu.org" , Jonathan Wakely , GCC Patches Subject: Re: [PATCH] libstdc++: add uniform on sphere distribution In-Reply-To: Message-ID: 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> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-SW-Source: 2014-08/txt/msg00953.txt.bz2 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. -- Marc Glisse