title: Generating random numbers under very specific constraints
body: <p>I am faced with the following programming problem. I need to generate <code>n</code> <code>(a, b)</code> tuples for which the sum of all <code>a</code>'s is a given <code>A</code> and sum of all <code>b</code>'s is a given <code>B</code> and for each tuple the ratio of <code>a / b</code> is in the range <code>(c_min, c_max)</code>. <code>A / B</code> 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 <code>a / b</code> values are more-or-less uniformly distributed in the given range.</p>
  
  <p>Some clarifications and meta-constraints:</p>
  
  <ul>
  <li><code>A</code>, <code>B</code>, <code>c_min</code>, and <code>c_max</code> are given. </li>
  <li>The ratio <code>A / B</code> is in the <code>(c_min, c_max)</code> range. This has to be so if the problem is to have a solution given the other constraints.</li>
  <li>a and b are <code>&gt;0</code> and non-integer.</li>
  </ul>
  
  <p>I am trying to implement this in Python but ideas in any language (English included) are much appreciated.</p>