Python Uniform Random Variable function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ritesh247
    New Member
    • Mar 2010
    • 12

    Python Uniform Random Variable function

    Hey,
    I am doing a project on one of my modules and I am supposed to build a function that gives uniform random variable between lets say Y and Z...I was wondering how this function can be built??

    Thanking you,
    Ritesh.
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    You may be able to use the random module.
    Code:
    >>> import random
    >>> random.randint(0,120)
    52
    >>> random.randint(0,120)
    15
    >>>

    Comment

    • Glenton
      Recognized Expert Contributor
      • Nov 2008
      • 391

      #3
      numpy or scipy also have random functions of this sort, that are able to generate an array of random numbers, rather than 1 at a time. Might be useful...

      Of course, if you want to write the whole function from scratch, that's a different story. But then you need to tell us what algorithm you want to use, and show us what you've done so far!

      Comment

      Working...