@@ -155,15 +155,13 @@ def calculate_residuals_for_table(
155155 measurement = scale (measurement , trafo )
156156
157157 # non-normalized residual is just the difference
158- residual = simulation - measurement
158+ residual = measurement - simulation
159159
160- noise_value = 1
161160 if normalize :
162- # look up noise standard deviation
163- noise_value = evaluate_noise_formula (
161+ # divide by standard deviation
162+ residual / = evaluate_noise_formula (
164163 row , noise_formulas , parameter_df , simulation , observable
165164 )
166- residual /= noise_value
167165
168166 # fill in value
169167 residual_df .loc [irow , RESIDUAL ] = residual
@@ -181,13 +179,10 @@ def get_symbolic_noise_formulas(observable_df) -> dict[str, sp.Expr]:
181179 """
182180 noise_formulas = {}
183181 # iterate over observables
184- for row in observable_df .itertuples ():
185- observable_id = row .Index
186- if NOISE_FORMULA not in observable_df .columns :
187- noise_formula = None
188- else :
189- noise_formula = sympify_petab (row .noiseFormula )
190- noise_formulas [observable_id ] = noise_formula
182+ for observable_id , row in observable_df .iterrows ():
183+ noise_formulas [observable_id ] = (
184+ sympify_petab (row .noiseFormula ) if NOISE_FORMULA in row else None
185+ )
191186 return noise_formulas
192187
193188
0 commit comments