# Can't understand the Beta distribution as described in this paper

I'm reading through the following paper (1). On page 2, section 2.1, there's a description of the selection of a beta distribution used:

Since both the choice of s and the strategy for handling the case that all values are above the threshold affect the result, we propose to abandon the use of a single absolute threshold and instead use a prior parameter distribution S given by P(si), where si , i = 1, . . . , N are possible thresholds. We use thresholds ranging from 0.01 to unity in steps of 0.01, i.e. N = 100. The distributions used in our experiments are Beta distributions with means 0.1, 0.15, 0.2 (α = 1 and β = 18, 11 + 1/3, 8) as shown in Fig 2

Here's fig 2:

I think I understand the purpose - each of those 0.1, 0.15, 0.2 are the "important" value of the threshold, so I want the beta distribution to be highest at those increments, but I also want to test all values in the range 0.01-1.0 with a peak/mean at 0.1 or 0.15 or 0.2.

In the code (3), there are some beta distributions as hardcoded arrays of 100 values:

static float betaDist1[100] = {0.028911,0.048656,0.061306,0.068539,0.071703,0.071877,0.069915,0.066489,0.062117,0.057199,0.052034,0.046844,0.041786,0.036971,0.032470,0.028323,0.024549,0.021153,0.018124,0.015446,0.013096,0.011048,0.009275,0.007750,0.006445,0.005336,0.004397,0.003606,0.002945,0.002394,0.001937,0.001560,0.001250,0.000998,0.000792,0.000626,0.000492,0.000385,0.000300,0.000232,0.000179,0.000137,0.000104,0.000079,0.000060,0.000045,0.000033,0.000024,0.000018,0.000013,0.000009,0.000007,0.000005,0.000003,0.000002,0.000002,0.000001,0.000001,0.000001,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000};



Now I'm trying to actually generate those arrays, by plugging in the values (a = 1.0, b = 8.0/11.3333/18.0) into the Python scipy.stats.beta (4) module:

#!/usr/bin/env python3

from scipy.stats import beta
import sys

a = 1.0
bs = [8.0, 11.33333333, 18.0]

beta_distrib_1 = [[] for _ in range(3)]
beta_distrib_2 = [[] for _ in range(3)]

for i in range(100):
for j, b in enumerate(bs):
beta_distrib_1[j].append(beta.pdf(i, a, b))
beta_distrib_2[j].append(beta.pdf(i, a, b))

print(beta_distrib_1)
print(beta_distrib_2)


However, the output is not even close to those hardcoded arrays. Could somebody describe how to go from a=1.0,b=8.0 to those actual arrays of values? Should I be using the pdf function? What's the parameter x? Say I want to do something similar, but with 20 values instead of 100.

Additionally, if I use beta(1.0, 8.0), beta(1.0, 11.333), beta(1.0, 18.0), the means are not 0.1, 0.15, and 0.20 in scipy.

Also, my ultimate goal is to use the Boost C++ beta distribution library (5) - but I assume that once I understand the math behind the idea, I'll be able to proceed with any library in any language

• It can't be done because those hard-coded arrays aren't what they claim to be. Eg, the first is a close approximation to the pdf of a Beta$(1.83, 17.36)$ distribution at points spaced by $0.01$ (although it's hard to determine what their origin is, because there are only 100 of them instead of 101). Since the pdf of a Beta distribution is simple to compute (and you can obtain the probabilities over small intervals using a trapozoidal or Simpson's Rule calculation), why not just code it correctly yourself? BTW, stats.stackexchange.com/questions/12232 shows how to find the parameters.
– whuber
Mar 20, 2019 at 20:47
• Thanks - I'll use those formulae. Is my logic of applying pdf(x, a, b) with x in the range of N, to generate N values of a beta distribution correct? Mar 21, 2019 at 13:52
• Your code misses the mark because the Beta pdf is defined only for arguments $x$ between $0$ and $1.$ That's where the ambiguity in betaDist1 etc. lies: exactly which values of $x$ do these arrays correspond to? Possibilities include $0,0.01, \ldots, 0.99;$ $0.01,0.02,\ldots,1.00;$ $0.005,0.015,.\ldots,0.995;$ and $0,1/99,2/99,\ldots,1.$ And are the values intended to be the pdf at each $x$ or would they be the integrated probabilities of each of the little intervals? These reveal some of the many problems of using undocumented scientific code. Best to develop your own from scratch.
– whuber
Mar 21, 2019 at 14:03
• Thanks again for your help. If you reply as an answer, I'll select it as best answer. Mar 22, 2019 at 12:59