Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
aradermacher committed Dec 18, 2024
1 parent 4c20182 commit 601aab1
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions probeye/inference/bias/likelihood_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,14 @@ def loglike(
if stds_are_scalar:
std_vector = np.full_like(residual_vector, np.sqrt(variance))
ll = -0.5 * n * np.log(2 * np.pi * self.tolerance**2 * variance)
ll -= (
0.5

* np.sum(
np.square(self.weight_mean * residual_vector)/ variance
+ np.square(
self.weight_std
* np.sqrt(np.square(response_vector[1]) + np.square(std_vector))
- self.gamma * np.abs(residual_vector)
)/ self.tolerance**2
ll -= 0.5 * np.sum(
np.square(self.weight_mean * residual_vector) / variance
+ np.square(
self.weight_std
* np.sqrt(np.square(response_vector[1]) + np.square(std_vector))
- self.gamma * np.abs(residual_vector)
)
/ self.tolerance**2
)

# Heteroscedastic noise (not implemented)
Expand Down Expand Up @@ -294,7 +291,8 @@ def loglike(

# Calculate the intermediate statistics
sigma_model_population = np.sqrt(
self.gamma**2 * np.square(residual_vector)
self.gamma**2
* np.square(residual_vector)
# + variance
)
sigma_model_sample = np.sqrt(np.square(response_vector[1]) + variance)
Expand All @@ -317,6 +315,7 @@ def loglike(
ll += ((n - 1) / 2 - 1) * np.log(n * sample_variance / population_variance)
return ll


class SampledGlobalMomentMatchingModelError(EmbeddedUncorrelatedModelError):
"""
This class implements the global moment matching likelihood model.
Expand Down Expand Up @@ -353,8 +352,8 @@ def loglike(
if np.isnan(response_vector).any():
return -np.inf

observations = residual_vector + response_vector[0] # This is the observed data
observations = residual_vector + response_vector[0] # This is the observed data

# Load the standard deviations and noise values
std_model, std_meas, stds_are_scalar = self.std_values(prms)
variance = np.power(std_model, 2)
Expand All @@ -374,7 +373,7 @@ def loglike(
variance += np.power(std_meas, 2)
if stds_are_scalar:
ll -= 0.5 * np.log(2 * np.pi / n * population_variance)
ll -= 0.5 * n / population_variance * np.square(sample_mean-mean_response)
ll -= 0.5 * n / population_variance * np.square(sample_mean - mean_response)
ll -= 0.5 * n * sample_variance / population_variance
ll -= (n - 1) / 2 * np.log(2)
ll -= math.lgamma((n - 1) / 2)
Expand Down Expand Up @@ -419,8 +418,6 @@ def loglike(
if np.isnan(response_vector).any():
return -np.inf



# Load the standard deviations and noise values
std_model, std_meas, stds_are_scalar = self.std_values(prms)
variance = np.power(std_model, 2)
Expand All @@ -439,13 +436,16 @@ def loglike(
variance += np.power(std_meas, 2)
if stds_are_scalar:
ll -= 0.5 * np.log(2 * np.pi / n * population_variance)
ll -= 0.5 * n / population_variance * np.square(mean_residual) # This is making it noise-sensitive
ll -= (
0.5 * n / population_variance * np.square(mean_residual)
) # This is making it noise-sensitive
ll -= 0.5 * n * sample_variance / population_variance
ll -= (n - 1) / 2 * np.log(2)
ll -= math.lgamma((n - 1) / 2)
ll += ((n - 1) / 2 - 1) * np.log(n * sample_variance / population_variance)
return ll


class IndependentNormalModelError(EmbeddedUncorrelatedModelError):
"""
This class implements the independent normal likelihood model.
Expand Down

0 comments on commit 601aab1

Please sign in to comment.