%matplotlib inline
%%python3
import matplotlib.pyplot as plt
import seaborn as sbn
from bayes_detect.test import test_image
plt.axis("scaled")
SrcArray = [[43.71, 22.91, 10.54, 3.34],
[101.62, 40.60, 1.37, 3.40],
[92.63, 110.56, 1.81, 3.66],
[183.60, 85.90, 1.23, 5.06],
[34.12, 162.54, 1.95, 6.02],
[153.87, 169.18, 1.06, 6.61],
[155.54, 32.14, 1.46, 4.05],
[130.56, 183.48, 1.63, 4.11]]
height = 200
width = 200
#format is [X,Y,A,R] for each source
data_map = test_image.make_source(src_array = SrcArray,height=height, width=width)
noise = 2.0
data_map = test_image.add_gaussian_noise(mean=0,sd=noise,data=data_map)
prior_array = [[0.0,200.0],[0.0,200.0],[1.0,12.5],[2.0,9.0]]
#uniform prior for each parameter. Sets them up in order of [X,Y,A,R]
Parameters:
*iterations
* number of iterations of the sampler
* setting a non positive number will default the system to run until convergence
*sample_params
*a dictionary with keys and values corresponding to parameters of the sampler
*{"type":"uniform"}
-uniform sampler. This is unusably slow.
*{"type":"metropolis", "disp":dispersion_value}
-metropolis hastings. Dispersion value can be set to anything. Default was 8.0
*{"type":"clustered_sampler", "minPts":min_pts_value, "eps":eps_value, "wait":wait value}
-runs clustering every wait iterations
-samples within a ellipsoid that encloses the cluster
-minPts and eps usually are 10
*stop_by_evidence
-True = run until convergence. This is automatically set if iterations is nonsensical.
-False = run for specified iterations
from bayes_detect.source_detection import detector
detector.run_source_detect(data_map = data_map, height = height, width = width, active_samples = 1200, iterations = 10000,
sample_params = {"type":"clustered_sampler", "minPts":10, "eps": 10, "wait":30}, prior = prior_array,
noise_rms = noise, stop_by_evidence = True)
Iteration: 1 maxZ: 4903.4776614 Iteration: 1000 maxZ: 639.606802092 Iteration: 2000 maxZ: 420.725433917 Iteration: 3000 maxZ: 367.806422393 Iteration: 4000 maxZ: 350.071745361 Iteration: 5000 maxZ: 341.997709776 Iteration: 6000 maxZ: 361.538163954 Iteration: 7000 maxZ: 238.400540805 Iteration: 8000 maxZ: 54.4858641498 elapsed time: 0:02:55.884466 log evidence: -112490.156178 number of iterations: 10000 likelihood calculations: 139210