```
In [1]:
```from binary_tools.priors.priors import*

```
In [2]:
```print(default_function(55,2.3),default_function_log(1.4,0))

```
```

```
In [3]:
```prob_mass(3,10,1,100,alpha=2.3,f_M=default_function)

```
Out[3]:
```

```
In [5]:
```rand_mass(1,100,alpha=2.3,f_M=default_function)

```
Out[5]:
```

```
In [6]:
```rand_mass_cdf(1,100,alpha=2.3,f_M=default_function)

```
Out[6]:
```

The fifth and final part of the file contains tests for the probability functions and the random functions. These tests are similar to the histogram tests in the test_kicks file.

These histogram based tests works by first creating a array of values containing outputs from the function being tested. That array is then used in the numpy.histogram function.

In order to check that the random functions are producing the distributions expected of them, the values of the histogram need to be conpared to the expected values directly calulated by the distribution. The equations of the cumulative distribution function of these distributions are as follows,

mass: $f(x) = ((1-\alpha)mass+M_{low}(1-\alpha))^{1/(1-\alpha)}$

mass log: $f(x) = \frac{\log_{10}((1-\alpha)\log_{10}(10)mass_{log}+10^{(1-\alpha)M_{low}})}{1-\alpha}$

ratio: $f(x) = ((1-\alpha)mass+R_{low}(1-\alpha))^{1/(1-\alpha)}$

period log: $f(x) = \frac{\log_{10}((1-\alpha)\log_{10}(10)mass_{log}+10^{(1-\alpha)P_{low}})}{1-\alpha}$

Where $M_{low}$, $R_{low}$, and $P_{low}$ are the lower bounds of the distribution

By evaluating the cdf of the distributions from one bin to the next, the expected probability of the bin was found. That probability was multiplied by the number of points in a new test array so the difference in the values between the expected output, and the function output calculated previously, could be compaired on a graph.

In order to numerically compare the expected probability to the function probability, each value from the function histogram was first divided by the sum of all the values to obtain the probability of each bin. Then the difference between the expected probability and the function probability was compared to a given tolerance to see if the test would pass.

```
success = True
tolerance = max(vals)*tolerance
for k in range(0,len(vals)):
prob_hist = vals[k]/(sum(vals))
if abs(prob_test[k]-prob_hist)>tolerance:
success = False
break
```

```
In [7]:
```test_rand_mass(1,100,num_sample=10000, nbins=20, tolerance = 1e-3, seed="Feyra", cdf=True,\
plot=True, save=False)

```
Out[7]:
```

```
In [8]:
```test_rand_mass_log(0,2,num_sample=10000, nbins=20, tolerance = 1e-3, seed="Stewart",\
cdf=True, plot=True, save=False)

```
Out[8]:
```

```
In [9]:
```test_rand_ratio(0.01, 0.99, test_alpha=2, num_sample=10000, nbins=20, tolerance = 1e-3,\
seed="Lee", cdf=True, plot=True, save=False)

```
Out[9]:
```

```
In [10]:
```test_rand_period_log(0,3.6,test_alpha=0,num_sample=10000,nbins=20,tolerance = 1e-3,\
seed="Hardy",cdf=True,plot=True,save=False)

```
Out[10]:
```

```
In [ ]:
```