Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need help in defining the type of distribution used in software so that I could use some standard distribution library for this purpose. I apologize for not using proper terms. It takes "center" value and an alpha parameter (0 to 1) and produces N values within a given range, so that values are "clustered" around this "center" value. The less alpha the less they are "centered".

For example, if I feed a range of 1-5 with center at 4, alpha=0.5 and ask for 20 values the result will look something like this:

1:1 times
2:3 times
3:4 times
4:7 times
5:5 times

You get the idea. Thanks!

P.S. In case it might help, I provided some extracts from code

The code for probability density function:

private function assessProbabilityDensityFunction(){
        for ($i = 0; $i < $this->valueRange->getNumberOfValues(); $i++)
            $probabilityDensityFunction[$i] = $this->probabilityFunction() * $this->probabilityCenteredCoefficient($i);
        return $probabilityDensityFunction;

private function probabilityFunction(){
        return (1 - $this->settings->getAlpha()) / (1 - pow($this->settings->getAlpha(), $this->valueRange->getNumberOfValues() - $this->CentralValueSerialNumber() + 1) + $this->settings->getAlpha() - pow($this->settings->getAlpha(), $this->CentralValueSerialNumber()));

private function distanceFromCentralValue($serialNumber){
        return abs($this->CentralValueSerialNumber() - $serialNumber - 1);

And here's the cumulative function code

private function assessCumulativeDistributionFunction(){
    $cumulativeDistributionFunction = array();
    $cumulativeDistributionFunction[0] = $this->probabilityFunction->getValue(0);
    for ($i = 1; $i < $this->getValueRange()->getNumberOfValues(); $i++)
        $cumulativeDistributionFunction[$i] = $cumulativeDistributionFunction[$i - 1] + $this->probabilityFunction->getValue($i);
    return $cumulativeDistributionFunction;

And here's how we get distributed values

public function getValue(){
   return  $this->multinomialDistribution()+$this->cumulativeFunction->getValueRange()->getFromValue();

private function multinomialDistribution(){
   $rnd= lcg_value(); // random (0,1)
   for ($i=0; $i<$this->cumulativeFunction->getValueRange()->getNumberOfValues(); $i++)
     if ($this->cumulativeFunction->getValue($i) > $rnd) return $i;
   throw new Exception("Should always return a value");
share|cite|improve this question
It should be The less alpha the less they are "clustered"I guess? The specification is quite vague, so it would help to know your intent. Are you interested in the generation of values or what? – leonbloy Oct 12 '11 at 16:18
Correct, the less alpha the less they are clustered around specified center. I'm interested in generating values that are distributed like that. – Boris Mikhaylov Oct 12 '11 at 16:22
Also posted to stats.SE? – Dilip Sarwate Oct 12 '11 at 17:27
up vote 0 down vote accepted

A possible generation recipe (ad hoc) would be to use a Beta distribution properly normalized and discretized. For example: you want to generate a variable $X$ in the range $1..N$ with mean $M$ ($N=5 M=4$ in the example), so well generate a Beta variable $Y$ with parameters $(a,b)$, and return $X = ceil(N \; Y)$. To choose $(a,b)$, we note that $E(X) \approx N E(Y) + 1/2$, so we want $E(Y) = (4-1/2)/5 = 0.7$. From this you get a (linear) relation between the paramenters $(a,b)$. The remaining degree of freedom can be used to alter the variance (specifically, growin $a$ decreases the variance).

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.