Skip to content

Commit abfadb5

Browse files
committed
v2: unscaled obs for noise
1 parent c09921a commit abfadb5

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

petab/v2/calculate.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ def calculate_residuals_for_table(
151151

152152
# scale simulation and measurement
153153

154-
simulation = scale(simulation, trafo)
155-
measurement = scale(measurement, trafo)
154+
scaled_simulation = scale(simulation, trafo)
155+
scaled_measurement = scale(measurement, trafo)
156156

157157
# non-normalized residual is just the difference
158-
residual = measurement - simulation
158+
residual = scaled_measurement - scaled_simulation
159159

160160
if normalize:
161161
# divide by standard deviation
@@ -373,7 +373,6 @@ def calculate_llh_for_table(
373373
"""Calculate log-likelihood for one set of tables. For the arguments, see
374374
`calculate_llh`.
375375
"""
376-
from petab.v1 import scale
377376

378377
llhs = []
379378

@@ -415,7 +414,7 @@ def calculate_llh_for_table(
415414
row,
416415
noise_formulas,
417416
parameter_df,
418-
scale(simulation, obs_scale),
417+
simulation,
419418
observable,
420419
)
421420

tests/v2/test_calculate.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ def model_non_numeric_overrides():
204204
simulation_df[SIMULATION] = [2, 3]
205205

206206
expected_residuals = {
207-
(np.log(0.5) - np.log(2)) / (2 * 7 + 8 + 4 + np.log(2)),
208-
(np.log(1) - np.log(3)) / (2 * 2 + 3 + 4 + np.log(3)),
207+
(np.log(0.5) - np.log(2)) / (2 * 7 + 8 + 4 + 2),
208+
(np.log(1) - np.log(3)) / (2 * 2 + 3 + 4 + 3),
209209
}
210210
expected_residuals_nonorm = {
211211
np.log(0.5) - np.log(2),
@@ -217,8 +217,7 @@ def model_non_numeric_overrides():
217217
* np.log(
218218
2
219219
* np.pi
220-
* np.array([2 * 7 + 8 + 4 + np.log(2), 2 * 2 + 3 + 4 + np.log(3)])
221-
** 2
220+
* np.array([2 * 7 + 8 + 4 + 2, 2 * 2 + 3 + 4 + 3]) ** 2
222221
* np.array([0.5, 1]) ** 2
223222
).sum()
224223
)

0 commit comments

Comments
 (0)