# Logprior distribution. It defines the allowed range my variables can vary over. It works for the (xn+iyn) version. Check version below!!!
def log_prior(theta):
x_s = theta[0::4]
y_s = theta[1::4]
a_s = theta[2::4]
b_s = theta[3::4]
if all(-10 <= t <= 10 for t in x_s) and all(-10 <= t <= 10 for t in y_s) and all(-0.4 <= t <= 0.4 for t in a_s) and all(-0.4 <= t <= 0.4 for t in b_s):
return 0.0
return -np.inf
```
%% Cell type:code id: tags:
``` python
# Logposterior distribution for the residuals case .
def log_probability(theta):
lp = log_prior(theta)
if not np.isfinite(lp):
return -np.inf
return lp + log_likelihood(theta)
```
%% Cell type:code id: tags:
``` python
# Logposterior distribution for the mismatch case. Not used yet.
def log_probability_match(theta):
lp = log_prior(theta)
if not np.isfinite(lp):
return -np.inf
return lp + log_likelihood_match(theta)
```
%% Cell type:markdown id: tags:
Maximum estimator Fitting. Same use as in mathematica
%% Cell type:code id: tags:
``` python
#I need to provid an initial guess for 4*(nmax+1) the parameters
# Logprior distribution. It defines the allowed range my variables can vary over.
#It works for the (xn*Exp[iyn]) version!!!
def log_prior(theta):
x_s = theta[0::4]
y_s = theta[1::4]
a_s = theta[2::4]
b_s = theta[3::4]
if all(0 <= t <= 10 for t in x_s) and all(0 <= t <= 2*np.pi for t in y_s) and all(-0.4 <= t <= 0.4 for t in a_s) and all(-0.4 <= t <= 0.4 for t in b_s):
return 0.0
return -np.inf
```
%% Cell type:code id: tags:
``` python
#Define you initial position of your 4*(nmax+1) variables.