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

Newsgroups comp.lang.python
Date 2013-03-12 10:47 -0700
References <mailman.3237.1363108626.2939.python-list@python.org>
Subject Re: How can i create a random array of floats from 0 to 5 in python
From Maarten <maarten.sneep@knmi.nl>
Message-ID <mailman.3242.1363110453.2939.python-list@python.org> (permalink)

Show all headers | 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