我正在使用历史年度降雨量数据来设计' whatif'生态模型中降雨量变化的情景。为此,我试图对实际降雨量值进行抽样,以创建满足特定标准的降雨年份样本(例如降雨年份的样本比历史平均值湿10%)。
我已经提出了一种相对简单的暴力方法,如果我有一个标准(例如目标平均值),它就可以正常工作:
rainfall_values = c(270.8, 150.5, 486.2, 442.3, 397.7,
593.4191, 165.608, 116.9841, 265.69, 217.934, 358.138, 238.25,
449.842, 507.655, 344.38, 188.216, 210.058, 153.162, 232.26,
266.02801, 136.918, 230.634, 474.984, 581.156, 674.618, 359.16
)
#brute force
sample_size=10 #number of years included in each sample
n_replicates=1000 #number of total samples calculated
target=mean(rainfall_values)*1.1 #try to find samples that are 10% wetter than historical mean
tolerance=0.01*target #how close do we want to meet the target specified above?
#create large matrix of samples
sampled_DF=t(replicate(n_replicates, sample(x=rainfall_values, size=sample_size, replace=T)))
#calculate mean for each sample
Sampled_mean_vals=apply(sampled_DF,1, mean)
#create DF only with samples that meet the criteria
Sampled_DF_on_target=sampled_DF[Sampled_mean_vals>(target-tolerance)&Sampled_mean_vals<(target+tolerance),]
问题是我最终会有多个匹配的标准(不仅是一个平均目标,还有标准偏差和自相关系数等)。对于更复杂的多变量目标,这种强力方法在查找匹配时变得非常低效,我基本上必须查看数百万个样本,并且即使在并行化时也需要数天......
所以 - 我的问题是 - 有没有办法使用优化算法或其他非暴力方法来实现此搜索?