You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于OpenTURNS的Kriging模型Sobol指数及置信区间计算咨询

使用OpenTURNS从Kriging模型计算带置信区间的Sobol'指数

完全可以通过OpenTURNS实现你的需求,具体实现方式如下:

1. 基于Kriging模型计算Sobol'指数

OpenTURNS原生支持基于Kriging代理模型计算Sobol'指数。你需要先通过KrigingAlgorithm类完成Kriging模型的训练,再将训练好的元模型传入SobolIndicesAlgorithm类,即可计算一阶、总阶等各类Sobol'指数。

2. 同时纳入元模型误差与蒙特卡洛误差的置信区间

OpenTURNS的Sobol'指数计算模块支持通过Bootstrap抽样来估计置信区间,该方法会同时覆盖两种误差来源:

  • 蒙特卡洛误差:来自Sobol'指数计算过程中的抽样随机性
  • 元模型误差:Kriging模型本身的预测不确定性会在每次Bootstrap抽样的预测环节中被纳入

你可以通过setBootstrapSize()指定抽样次数(次数越高,置信区间估计越稳健),再通过getFirstOrderIndicesInterval()和getTotalOrderIndicesInterval()方法获取对应指数的置信区间。

示例代码

import openturns as ot

# 定义输入变量分布与真实模型
input_dist = ot.ComposedDistribution([ot.Uniform(0, 1)] * 2)
true_model = ot.SymbolicFunction(["x1", "x2"], ["x1 + x2^2"])

# 生成训练样本并拟合Kriging模型
train_sample = input_dist.getSample(20)
train_output = true_model(train_sample)
basis = ot.ConstantBasisFactory(2).build()
covariance_model = ot.SquaredExponential([1.0] * 2, [1.0])
kriging_algo = ot.KrigingAlgorithm(train_sample, train_output, covariance_model, basis)
kriging_algo.run()
kriging_model = kriging_algo.getResult().getMetaModel()

# 配置Sobol指数计算并生成置信区间
sobol_algo = ot.SobolIndicesAlgorithm(kriging_model, input_dist)
sobol_algo.setBootstrapSize(100)  # 设置Bootstrap抽样次数
sobol_algo.run()

# 提取结果
first_order_indices = sobol_algo.getFirstOrderIndices()
first_order_ci = sobol_algo.getFirstOrderIndicesInterval()
total_order_indices = sobol_algo.getTotalOrderIndices()
total_order_ci = sobol_algo.getTotalOrderIndicesInterval()

print("一阶Sobol指数:", first_order_indices)
print("一阶指数95%置信区间:", first_order_ci)
print("总阶Sobol指数:", total_order_indices)
print("总阶指数95%置信区间:", total_order_ci)

在上述代码中,Bootstrap过程会重复执行Sobol'指数计算,每次都会基于Kriging模型的预测输出(包含模型自身的不确定性),最终得到的置信区间同时考虑了元模型误差与蒙特卡洛抽样误差。

内容的提问来源于stack exchange,提问作者Alexis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 22:39:20