y = g(inputSample) outputObservationNoiseSigma = 0.05 meanNoise = ot.Point(outputDimension) covarianceNoise = ot.Point(outputDimension, outputObservationNoiseSigma) R = ot.IdentityMatrix(outputDimension) observationOutputNoise = ot.Normal(meanNoise, covarianceNoise, R) # Add noise sampleNoise = observationOutputNoise.getSample(size) y += sampleNoise candidate = [1.0] * 3 bootstrapSizes = [0, 100] for bootstrapSize in bootstrapSizes: algo = ot.NonLinearLeastSquaresCalibration(model, x, y, candidate) algo.setBootstrapSize(bootstrapSize) algo.run() # To avoid discrepance between the plaforms with or without CMinpack # Check MAP calibrationResult = algo.getResult() parameterMAP = calibrationResult.getParameterMAP() print("(Auto) MAP=", repr(parameterMAP)) rtol = 1.0e-2 atol = 0.0 ott.assert_almost_equal(parameterMAP, trueParameter, rtol, atol) algo.setOptimizationAlgorithm( ot.MultiStart( ot.TNC(), ot.LowDiscrepancyExperiment( ot.SobolSequence(),
# %% # There are several methods to solve the problem. # # * Given that the problem is not identifiable, we can use some regularization method. Two methods are provided in the library: the Gaussian linear least squares `GaussianLinearCalibration` and the Gaussian non linear least squares `GaussianNonlinearCalibration`. # * We can change the problem, replacing it with a problem which is identifiable. In the flooding model, we can view :math:`Z_v` and :math:`Z_m` as constants and calibrate :math:`K_s` only. # %% # Calibration with non linear least squares # ----------------------------------------- # %% # The `NonLinearLeastSquaresCalibration` class performs the non linear least squares calibration by minimizing the squared euclidian norm between the predictions and the observations. # %% algo = ot.NonLinearLeastSquaresCalibration(mycf, Qobs, Hobs, thetaPrior) # %% # The `run` method computes the solution of the problem. # %% algo.run() # %% calibrationResult = algo.getResult() # %% # Analysis of the results # ----------------------- # %%
# # Moreover, the distribution of the residuals is close to being gaussian. # %% graph = calibrationResult.drawParameterDistributions() view = viewer.View(graph) # %% # Calibration with nonlinear least squares # ---------------------------------------- # %% # The `NonLinearLeastSquaresCalibration` class performs the non linear least squares calibration by minimizing the squared euclidian norm between the predictions and the observations. # %% algo = ot.NonLinearLeastSquaresCalibration(mycf, observedStrain, observedStress, thetaPrior) # %% # The `run` method computes the solution of the problem. # %% algo.run() # %% calibrationResult = algo.getResult() # %% # Analysis of the results # ----------------------- # %%