无法更改数据类型以传递统计CDF函数



我有一个包含4列的数据帧:sample_means、sample_size、MW_wind_speed和sample_stdev。根据这些值,我计算了一个测试统计数据("testrongtat"(,我想通过统计数据包CDF函数(见最后一行代码(来计算数据帧中每一行的p值。然而,我在最后一行一直收到一个错误:

"类型错误:int对象不可下标">

我无法更改testrongtat数据的类型,因为它是一个系列,所以我不知道该怎么办。我需要如何调整我的数据以通过CDF函数传递I?

#define data from columns of the dataframe
sample_means = new_df['sample_mean']
sample_size = new_df['sample_size']
MW_wind_speed = new_df['MW_wind_speed']
sample_stdev = new_df['sample_stdev']
#calculate s value and z_value
s_x = sample_stdev/(np.sqrt(sample_size-1))
test_stat = (np.abs(sample_means - MW_wind_speed))/s_x
#calculate p-values by passing z value through CDF function
from scipy.stats import norm
p_values = 2[1-norm.cdf(test_stat)]

下面是绕过它的好方法!我认为该类型的问题是我没有包括2*(1-norm.cdf(testrongtat((

#calculate s value and z_value
s_x = sample_stdev/(np.sqrt(sample_size-1))
z_value = (np.abs(sample_means - MW_wind_speed))/s_x
new_df['s_value'] = s_x
new_df['test_statistic'] = test_stat
new_df = new_df.dropna()
#make a a t distribution object for t with 10 deg of freedom (best approximation)
t_dist = stats.t(10)
cdf_values = t_dist.cdf(test_stat)
p_values = 2*(1-cdf_values)

相关内容

  • 没有找到相关文章

最新更新