About 168,000 results
Open links in new tab
  1. python - Generate random integers between 0 and 9 - Stack …

    Then to generate random integers, call integers() or choice(). It is much faster than the standard library if you want to generate a large list of random numbers (e.g. to generate 1 million …

  2. Generating a list of random numbers, summing to 1

    For e.g: lets say you want to generate 3 numbers, with min_thresh=0.2. We create a portion to fill by random numbers [1 - (0.2x3) = 0.4]. We fill that portion and add 0.2 to all values, so we can …

  3. Generate 'n' unique random numbers within a range [duplicate]

    Apr 3, 2014 · I know how to generate a random number within a range in Python. random.randint(numLow, numHigh) And I know I can put this in a loop to generate n amount of …

  4. Generate random numbers with a given (numerical) distribution

    Nov 24, 2010 · I have a file with some probabilities for different values e.g.: 1 0.1 2 0.05 3 0.05 4 0.2 5 0.4 6 0.2 I would like to generate random numbers using this distribution. Does an …

  5. Python: Random numbers into a list - Stack Overflow

    You could use random.sample to generate the list with one call: import random my_randoms = random.sample(range(100), 10) That generates numbers in the (inclusive) range from 0 to 99.

  6. python - How do I create a list of random numbers without …

    Mar 18, 2012 · I've made a quick and dirty adjustment function (that doesn't remove duplicates). You could generate a list of random numbers and pass it to this to get a list of unique …

  7. python - How to generate a random number with a specific …

    Jul 4, 2021 · And if zero is never allowed, then you'll have to explicitly reject numbers with a zero in them, or draw n random.randint(1,9) numbers. Aside: it is interesting that randint(a,b) uses …

  8. Generate true random numbers in python - Stack Overflow

    Sep 5, 2020 · There are many ways of generating random numbers, with exactly 1 thing in common - they all require external input. Let's say you use a simple RNG like games use. The …

  9. python - How to get a random number between a float range

    Oct 24, 2023 · import random random.uniform(a, b) # range [a, b) or [a, b] depending on floating-point rounding Python provides other distributions if you need. If you have numpy imported …

  10. Python - generate same random numbers - Stack Overflow

    Mar 9, 2017 · def main(): x = [randint(1,100) for i in range(1,100)] return x This returns 100 random numbers btw 1 and 100. Each time I call the function, it returns a different sequence of …

Refresh