當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Python Scipy stats.bayes_mvs()用法及代碼示例


scipy.stats.bayes_mvs(arr,alpha)函數在給定的貝葉斯置信區間內計算均值,方差和標準差。

參數:
arr : [array_like] The input data can be multidimensional but will be flattened before use.
alpha : Probability that the returned confidence interval contains the true parameter.

Results: mean, variance and standard deviation in the given Bayesian confidence interval.



代碼1:工作中

# stats.bayes_mvs() method    
import numpy as np 
from scipy import stats 
    
arr1 = [[20, 2, 7, 1, 34], 
        [50, 12, 12, 34, 4]] 
  
arr2 = [50, 12, 12, 34, 4] 
  
print ("\narr1:", arr1) 
print ("\narr2:", arr2) 
  
mean, var, std = stats.bayes_mvs(arr1, 0.9) 
  
print ("\nMean of array1:", mean) 
print ("\nvar of array1:", var) 
print ("\nstd of array1:", std) 
  
mean, var, std = stats.bayes_mvs(arr2, 0.5) 
  
print ("\nMean of array2:", mean) 
print ("\nvar of array2:", var) 
print ("\nstd of array2:", std) 
  

輸出:

arr1: [[20, 2, 7, 1, 34], [50, 12, 12, 34, 4]]

arr2: [50, 12, 12, 34, 4]

Mean of array1: Mean(statistic=17.6, minmax=(7.99212522273964, 27.207874777260358))

var of array1: Variance(statistic=353.2, minmax=(146.13176149159307, 743.5537128176551))

std of array1: Std_dev(statistic=18.136411760663574, minmax=(12.088497073316974, 27.26818132581737))

Mean of array2: Mean(statistic=22.4, minmax=(16.090582413339323, 28.709417586660674))

var of array2: Variance(statistic=725.6, minmax=(269.47585801746374, 754.8278687119639))

std of array2: Std_dev(statistic=23.872262300862655, minmax=(16.415719844632576, 27.474130900029646))



相關用法


注:本文由純淨天空篩選整理自vishal3096大神的英文原創作品 sciPy stats.bayes_mvs() function | Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。