1
$\begingroup$

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(){
        $probabilityDensityFunction=array();
        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");
}
  • 0
    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?2011-10-12
  • 0
    Correct, the less alpha the less they are clustered around specified center. I'm interested in generating values that are distributed like that.2011-10-12
  • 0
    Also posted to stats.SE?2011-10-12

1 Answers 1

0

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).