拉丁立方抽样算法

import numpy as np

#区间下限函数
def partition_lower (lower_limit,upper_limit,number_of_sample):
    section_variable = np.array([lower_limit, upper_limit]).reshape(-1,1) #变量区间上下限列向量
    coefficient_f = np.zeros((number_of_sample,2))
    for i in range(number_of_sample):
        coefficient_f[i,0] = 1-(i)/number_of_sample
        coefficient_f[i,1] = (i)/number_of_sample
    partition_range = coefficient_f@section_variable
    return partition_range #返回区间下限

#区间上限函数
def partition_upper (lower_limit,upper_limit,number_of_sample):
    section_variable = np.array([lower_limit, upper_limit]).reshape(-1,1) #变量区间上下限列向量
    coefficient_f = np.zeros((number_of_sample,2))
    for i in range(number_of_sample):
        coefficient_f[i,0] = 1-(i+1)/number_of_sample
        coefficient_f[i,1] = (i+1)/number_of_sample
    partition_range = coefficient_f@section_variable
    return partition_range #返回区间上限

lower_limit = partition_lower(0,10,10) #将0-10分成10个等长区间,获得每个区间的下限
upper_limit = partition_upper(0,10,10) #将0-10分成10个等长区间,获得每个区间的上限
print(lower_limit.T)
print(upper_limit.T)

 

你可能感兴趣的:(算法)