本文整理汇总了Python中arch.bootstrap.IIDBootstrap.var方法的典型用法代码示例。如果您正苦于以下问题:Python IIDBootstrap.var方法的具体用法?Python IIDBootstrap.var怎么用?Python IIDBootstrap.var使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arch.bootstrap.IIDBootstrap
的用法示例。
在下文中一共展示了IIDBootstrap.var方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_iid_unequal_equiv
# 需要导入模块: from arch.bootstrap import IIDBootstrap [as 别名]
# 或者: from arch.bootstrap.IIDBootstrap import var [as 别名]
def test_iid_unequal_equiv():
rs = RandomState(0)
x = rs.randn(500)
rs1 = RandomState(0)
bs1 = IIDBootstrap(x, random_state=rs1)
rs2 = RandomState(0)
bs2 = IndependentSamplesBootstrap(x, random_state=rs2)
v1 = bs1.var(np.mean)
v2 = bs2.var(np.mean)
assert_allclose(v1, v2)
示例2: test_cov
# 需要导入模块: from arch.bootstrap import IIDBootstrap [as 别名]
# 或者: from arch.bootstrap.IIDBootstrap import var [as 别名]
def test_cov(self):
bs = IIDBootstrap(self.x)
num_bootstrap = 10
cov = bs.cov(func=self.func, reps=num_bootstrap, recenter=False)
bs.reset()
results = np.zeros((num_bootstrap, 2))
count = 0
for data, _ in bs.bootstrap(num_bootstrap):
results[count] = data[0].mean(axis=0)
count += 1
errors = results - self.x.mean(axis=0)
direct_cov = errors.T.dot(errors) / num_bootstrap
assert_allclose(cov, direct_cov)
bs.reset()
cov = bs.cov(func=self.func, recenter=True, reps=num_bootstrap)
errors = results - results.mean(axis=0)
direct_cov = errors.T.dot(errors) / num_bootstrap
assert_allclose(cov, direct_cov)
bs = IIDBootstrap(self.x_df)
cov = bs.cov(func=self.func, reps=num_bootstrap, recenter=False)
bs.reset()
var = bs.var(func=self.func, reps=num_bootstrap, recenter=False)
bs.reset()
results = np.zeros((num_bootstrap, 2))
count = 0
for data, _ in bs.bootstrap(num_bootstrap):
results[count] = data[0].mean(axis=0)
count += 1
errors = results - self.x.mean(axis=0)
direct_cov = errors.T.dot(errors) / num_bootstrap
assert_allclose(cov, direct_cov)
assert_allclose(var, np.diag(direct_cov))
bs.reset()
cov = bs.cov(func=self.func, recenter=True, reps=num_bootstrap)
errors = results - results.mean(axis=0)
direct_cov = errors.T.dot(errors) / num_bootstrap
assert_allclose(cov, direct_cov)