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 6745225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:10:44+00:00 2026-05-26T12:10:44+00:00

I am faced with the following programming problem. I need to generate n (a,

  • 0

I am faced with the following programming problem. I need to generate n (a, b) tuples for which the sum of all a‘s is a given A and sum of all b‘s is a given B and for each tuple the ratio of a / b is in the range (c_min, c_max). A / B is within the same range, too. I am also trying to make sure there is no bias in the result other than what is introduced by the constraints and the a / b values are more-or-less uniformly distributed in the given range.

Some clarifications and meta-constraints:

  • A, B, c_min, and c_max are given.
  • The ratio A / B is in the (c_min, c_max) range. This has to be so if the problem is to have a solution given the other constraints.
  • a and b are >0 and non-integer.

I am trying to implement this in Python but ideas in any language (English included) are much appreciated.

  • 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-26T12:10:45+00:00Added an answer on May 26, 2026 at 12:10 pm

    Start by generating as many identical tuples, n, as you need:

    (A/n, B/n)

    Now pick two tuples at random. Make a random change to the a value of one, and a compensating change to the a value of the other, keeping everything within the given constraints. Put the two tuples back.

    Now pick another random pair. This times twiddle with the b values.

    Lather, rinse repeat.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I faced a following problem: generate N unique alphanumeric strings from a restricted alphabet.
I am faced with the following problem. I need to (de)serialize (binary) a stream
I am currently faced with the following problem: Given is a tree with an
I am faced with the following issue. I need to capture a range of
I'm refactoring a library we currently use, and I'm faced with the following problem.
I've faced the following problem. I'm developing a form for the site and this
While working on ASP.NET MVC 2 web site I faced to the following problem.
The problem I've just faced is what to do in the following case: func
Say I get the following question Console.WriteLine(Which teams have faced eachother? - use Red
Today I faced the following problem: I registered a new user on my Joobla

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.