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


Groups > comp.lang.python > #41141

Re: How can i create a random array of floats from 0 to 5 in python

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <maarten.sneep@knmi.nl>
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; 'float': 0.05; 'subject:How': 0.09; '[0,': 0.09; 'subject:create': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'subject:python': 0.11; '100,': 0.16; 'numpy': 0.16; 'subject:array': 0.16; 'subject:random': 0.16; 'wrote:': 0.17; 'import': 0.21; 'work.': 0.23; 'random': 0.24; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'values': 0.26; 'cc:addr:gmail.com': 0.27; 'array': 0.29; 'received:google.com': 0.34; 'received:209.85': 0.35; 'but': 0.36; '12,': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; '2013': 0.84; 'maarten': 0.91; 'ranging': 0.91
X-Received by 10.49.24.13 with SMTP id q13mr1288145qef.33.1363110445338; Tue, 12 Mar 2013 10:47:25 -0700 (PDT)
Newsgroups comp.lang.python
Date Tue, 12 Mar 2013 10:47:25 -0700 (PDT)
In-Reply-To <mailman.3237.1363108626.2939.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=145.23.254.101; posting-account=iJTQsAoAAABApfTuFpnnNwqdJKQ-QQBs
References <mailman.3237.1363108626.2939.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 145.23.254.101
MIME-Version 1.0
Subject Re: How can i create a random array of floats from 0 to 5 in python
From Maarten <maarten.sneep@knmi.nl>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.org
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>
Message-ID <mailman.3242.1363110453.2939.python-list@python.org> (permalink)
Lines 11
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363110453 news.xs4all.nl 6863 [2001:888:2000:d::a6]:39281
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41141

Show key headers only | View raw


On Tuesday, March 12, 2013 6:11:10 PM UTC+1, Norah Jones wrote:
> I want to create a random float array of size 100, with the values in the array ranging from 0 to 5. I have tried random.sample(range(5),100) but that does not work. How can i get what i want to achieve?

Use numpy

import numpy as np
np.random.uniform(0, 5, 100)

# note that the values are from the interval [0, 5)

Maarten

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


Thread

How can i create a random array of floats from 0 to 5 in python Norah Jones <nh.jones01@gmail.com> - 2013-03-12 17:11 +0000
  Re: How can i create a random array of floats from 0 to 5 in python Maarten <maarten.sneep@knmi.nl> - 2013-03-12 10:47 -0700
    Re: How can i create a random array of floats from 0 to 5 in python llanitedave <llanitedave@veawb.coop> - 2013-03-12 13:21 -0700
      Re: How can i create a random array of floats from 0 to 5 in python Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-03-12 21:59 +0000
        Re: How can i create a random array of floats from 0 to 5 in python llanitedave <llanitedave@veawb.coop> - 2013-03-12 22:35 -0700
        Re: How can i create a random array of floats from 0 to 5 in python llanitedave <llanitedave@veawb.coop> - 2013-03-12 22:35 -0700
    Re: How can i create a random array of floats from 0 to 5 in python llanitedave <llanitedave@veawb.coop> - 2013-03-12 13:21 -0700
  Re: How can i create a random array of floats from 0 to 5 in python Maarten <maarten.sneep@knmi.nl> - 2013-03-12 10:47 -0700

csiph-web