Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46045

Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'correct.': 0.07; "subject:' ": 0.07; 'variables': 0.07; 'subject:help': 0.08; 'funny,': 0.09; 'integers': 0.09; 'lost.': 0.09; 'subject:using': 0.09; 'variables.': 0.09; 'random': 0.14; 'add,': 0.16; 'ah!': 0.16; 'dice': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'sense:': 0.16; 'shifts': 0.16; 'spurious': 0.16; 'stable.': 0.16; 'subject: \n ': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'variable': 0.18; 'cheap': 0.19; 'normally': 0.19; 'result.': 0.19; 'shape': 0.19; 'saying': 0.22; 'adds': 0.24; 'instance,': 0.24; 'values': 0.27; 'header:In-Reply- To:1': 0.27; 'chris': 0.29; 'possibility': 0.29; "doesn't": 0.30; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'gives': 0.31; 'you?': 0.31; 'constant': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'know.': 0.32; 'quite': 0.32; 'implemented': 0.33; 'received:209.85': 0.35; 'common': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'possible': 0.36; 'similar': 0.36; 'so,': 0.37; 'two': 0.37; 'received:209': 0.37; 'being': 0.38; 'to:addr:python- list': 0.38; 'fact': 0.38; 'pm,': 0.38; 'does': 0.39; 'extremely': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'numbers': 0.61; "you're": 0.61; 'real': 0.63; 'more': 0.64; 'close': 0.67; '26,': 0.68; 'results': 0.69; 'fact,': 0.69; 'computers': 0.72; 'around,': 0.84; 'multiplying': 0.84; 'take,': 0.84; '2013': 0.98
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 :content-type; bh=CjEjnHu9V8fil0SFujLwoPP2OTVRtWxkpMd3H1PeN7k=; b=qL5d04TUzumK7phvuhRUf4rZh2H/csYNg8ET+JkKOcTuIzoqOnQYuV/9pgHdjWOkBS pe8WBdlrsCOW7sK+4qICmZQbKVBMp/rxFcIYirVK7tpU1kqtV5cxqzlqUgi3ynHgI9B2 Ct51NKjuMvpUj7BKFAKQSDvlO1/tqCRENV/ph/+PRoXSPn32EdCF3D3P1auj1CAhtHJY ssqneNFrJvXxiZaTTu4ZXmgEaR2vXolXDQb9J66EkSGRMSUvHeA/lzEZGeJkoVzmh/KP Tqy7nkah9075tsvTjNTCfojyHimdoRTUzKMQQygKrN/i6StnupET4w/cF0hXcdiaOO3V ajbg==
MIME-Version 1.0
X-Received by 10.52.65.238 with SMTP id a14mr10227517vdt.24.1369542517324; Sat, 25 May 2013 21:28:37 -0700 (PDT)
In-Reply-To <51a183a4$0$30002$c3e8da3$5496439d@news.astraweb.com>
References <e31fbc7c-1bc0-4f9a-9f1d-68f963a9ec39@googlegroups.com> <mailman.2109.1369459444.3114.python-list@python.org> <39ac7437-857e-483f-998c-8162c1039933@googlegroups.com> <51a052d1$0$6599$c3e8da3$5496439d@news.astraweb.com> <74e33270-a79a-4878-a400-8a6cda6637b2@googlegroups.com> <BLU176-W22ACF37B4898379CD64258D7940@phx.gbl> <CAPTjJmrTma=7xx2q37Ak8XoEc8UziKVEL77YLxkVac0+yrfhqA@mail.gmail.com> <BLU176-W1833A5275DD72D3BBC43F7D7940@phx.gbl> <CAPTjJmofQJ03a47C=LsnZKYv-37=qpYU-Asd5bRd+NopH5JdCA@mail.gmail.com> <BLU176-W34BB46913B9DB79761CAE0D7940@phx.gbl> <CAPTjJmrNodc7S5eOCeQEZdvz+3r06o4XnSgFx1ht7Ne1qDYpmw@mail.gmail.com> <BLU176-W31B6CDED0C7EBB19C87FFCD7940@phx.gbl> <mailman.2127.1369473306.3114.python-list@python.org> <51a0ca91$0$30002$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmpWeG3xRqKSXuH1+SwLTJhi-S=USU8cmXaQHFmgib=iyw@mail.gmail.com> <BLU176-W420C2B916435EE6F327BF6D7940@phx.gbl> <mailman.2142.1369502632.3114.python-list@python.org> <51a183a4$0$30002$c3e8da3$5496439d@news.astraweb.com>
Date Sun, 26 May 2013 14:28:37 +1000
Subject Re: help how to sort a list in order of 'n' in python without using inbuilt functions??
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2163.1369542526.3114.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369542526 news.xs4all.nl 15876 [2001:888:2000:d::a6]:43986
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:46045

Show key headers only | View raw


On Sun, May 26, 2013 at 1:38 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Sun, 26 May 2013 03:23:44 +1000, Chris Angelico wrote:
>
>> Does adding 1 to a random
>> number make it less random? It adds determinism to the number; can a
>> number be more deterministic while still no less random?
>>
>> Ah! I know. The answer comes from common sense:
> [snip spurious answer]
>
> I know you're being funny, but in fact adding a constant to a random
> variable still leaves it equally random. Adding, multiplying, dividing or
> subtracting a constant from a random variable X just shifts the possible
> values X can take, it doesn't change the shape of the distribution.

In real numbers, that's correct. However, computers don't work with
real numbers, so there's the very, uhh, REAL possibility that some of
the entropy will be lost. For instance, multiplying and dividing when
working with integers results in truncation, and adding huge numbers
to small floats results in precision loss.

I was deliberately playing around, but unfortunately there have been
many people who've genuinely thought things similar to what I was
saying - and then implemented into code.

> However, adding two random variables X and Y does change the
> distribution. In fact, a very cheap way of simulating an almost normally
> distributed random variable is to add up a whole lot of uniformly
> distributed random variables. Adding up 12 calls to random.random(), and
> subtracting 6, gives you a close approximation to a Gaussian random
> variable with mean 0 and standard deviation 1.

Yep. The more dice you roll, the more normal the distribution. Which
means that d100 is extremely swingy, but 11d10-10 is much less so, and
99d2-98 quite stable. The more randomness you add, the more
predictable the result.

<quote source="Jubal Early">Does that seem right to you?</quote>

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 01:04 -0700
  Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-24 18:12 +1000
  Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Dave Angel <davea@davea.name> - 2013-05-24 08:33 -0400
  RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-24 16:06 +0300
  Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 22:15 -0700
    Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 15:24 +1000
      Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 22:39 -0700
        Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 15:43 +1000
        Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-25 05:57 +0000
          Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 23:05 -0700
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 16:12 +1000
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 10:53 +0300
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 18:28 +1000
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 11:43 +0300
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 18:47 +1000
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 11:54 +0300
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 19:01 +1000
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 12:10 +0300
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 19:14 +1000
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-25 14:28 +0000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Fábio Santos <fabiosantosart@gmail.com> - 2013-05-25 15:46 +0100
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-25 16:03 +0100
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 01:41 +1000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-26 03:09 +0000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 14:02 +1000
                RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:12 +0300
                RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:17 +0300
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 03:23 +1000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-26 03:38 +0000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Dan Sommers <dan@tombstonezero.net> - 2013-05-26 04:06 +0000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 14:28 +1000
                RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:34 +0300
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 12:30 +0300
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-25 13:01 +0100
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Roy Smith <roy@panix.com> - 2013-05-25 10:03 -0400
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Dave Angel <davea@davea.name> - 2013-05-25 10:27 -0400
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-25 14:30 +0000
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:07 +0300
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:45 +0300
    Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? rusi <rustompmody@gmail.com> - 2013-05-24 22:43 -0700
    Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Roy Smith <roy@panix.com> - 2013-05-25 09:29 -0400
      Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-05-25 17:59 +0300

csiph-web