[英]Visualization of Standard Deviation in an array
作為python新手,我需要一些幫助。 我有一個包含100行和100列的數組。 每個位置代表一個溫度值。 現在,我想計算整個數組的均值(到目前為止,我已經知道了),然后創建一個尺寸與第一個數組相同的新數組,並且每個位置的標准偏差都相同。 最后,我想獲得一個數組,每個數組的均值均偏離平均值,因此我想知道每個值與均值的差值。 我希望你明白我的意思嗎? 為了更好地理解:該陣列是房屋的紅外熱像圖。 通過標准偏差的計算,我希望獲得圖像中最佳的反應性/敏感像素。 也許以前有人做過這樣的事情。 最后,我要導出文件,以便獲得與紅外圖像相似的圖像。 但不是原始溫度,而是標准差溫度。
導入文件並計算平均值,如下所示:
data_mean = []
my_array = np.genfromtxt((line.replace(',','.') for line in data),skip_header=9,delimiter=";")
data_mean.append(np.nanmean(my_array))
然后,我需要計算數組中每個位置的標准偏差。
提前非常感謝您的幫助!
data_mean = np.mean(my_array) #gets you the mean of the whole array
返回一個數組,其中每個值都是數據的平均值
meanArray = np.ones(my_array.shape)*data_mean
variationFromMean = my_array - meanArray
這是您要找的東西嗎?
如果將數據保留為數組格式,則可以采用以下解決方案:
import numpy as np
#Find the mean of the array data values
mean_value = np.mean(data_mean)
#Find the standard deviation of the array data values
standard_deviation = np.std(data_mean)
#create an array consisting of the standard deviations from the mean
array = data_mean/standard_deviation
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.