Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:11:34+00:00 2026-05-30T07:11:34+00:00

How would you implement a function that is returning a random number from interval

  • 0

How would you implement a function that is returning a random number from interval 1..1000
in the case there is a number N determining the chance of reaching higher numbers or lower numbers?

It should behave as follows:
e.g.

  • if N = 0 and we will generate many times the random number we will get a certain equilibrium (every number from interval 1..1000 has equal chance).
  • if N = 2321 (I call it positive factor) it will be very hard to achieve small number (often will be generated numbers > 900, sometimes numbers near 500 and rarely numbers < 100). The highest the positive factor the highest probability for high numbers
  • if N = -2321 (negative factor) this will be the opposite of positive factor

It’s clear that the generated numbers will create for given N certain characteristic curve. Could you advise me how to achieve this goal and what curves can I create? What possibilities do I have here? How would you limit positive and negative factors etc.

thank you for help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:11:35+00:00Added an answer on May 30, 2026 at 7:11 am

    If you generate a uniform random number, and then raise it to a power > 1, it will get smaller, but stay in the range [0, 1]. If you raise it to a power greater than 0 but less than 1, it will get larger, but stay in the range [0, 1].

    So you can use the exponent to pick a power when generating your random numbers.

    def biased_random(scale, bias):
      return random.random() ** bias * scale
    
    sum(biased_random(1000, 2.5) for x in range(100)) / 100
      291.59652962214676  # average less than 500
    
    max(biased_random(1000, 2.5) for x in range(100))
      963.81166161355998  # but still occasionally generates large numbers
    
    sum(biased_random(1000, .3) for x in range(100)) / 100
      813.90199860117821   # average > 500
    
    min(biased_random(1000, .3) for x in range(100))
      265.25040459294883   # but still occasionally generates small numbers
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an R library/function that would implement INTELLIGENT label placement in R plot?
I'm supposed to implement a function that erases a range of values from containers.
During a typical day programming, I implement functions in a way that I would
I would like to implement a frac function in C# (just like the one
I am about to implement a function that loads potentially large set of data
Is it possible to implement a function that results in this mapping: { (0x01,
I would like to implement a trampoline in java by returning a thunk whenever
What is the Objective-C equivalent of Double.NaN from Java? I've got a function that
What would you name a function that takes a list and a function, and
I have this hashCode function that I have been trying to implement with Eclipse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.