  We developed a novel direct algorithm to derive the mass-ratio distribution
(MRD) of short-period binaries from an observed sample of single-lined
spectroscopic binaries (SB1). The algorithm considers a class of parameterized
MRDs and finds the set of parameters that best fits the observed sample. The
algorithm consists of four parts. First, we define a new observable, the
`modified mass function', that can be calculated for each binary in the sample.
We show that the distribution of the modified mass function follows the shape
of the underlying MRD, turning it more advantageous than the previously used
mass function, reduced mass function or reduced mass function logarithm.
Second, we derive the likelihood of the sample of modified mass functions to be
observed given an assumed MRD. An MCMC search enables the algorithm to find the
parameters that best fit the observations. Third, we suggest to express the
unknown MRD by a linear combination of a basis of functions that spans the
possible MRDs. We suggest two such bases. Fourth, we show how to account for
the undetected systems that have an RV amplitude below a certain threshold.
Without the correction, this observational bias suppresses the derived MRD for
low mass ratios. Numerous simulations show that the algorithm works well with
either of the two suggested bases. The four parts of the algorithm are
independent, but the combination of the four turn the algorithm to be highly
effective in deriving the MRD of the binary population.
