简体   繁体   English

阵列中标准偏差的可视化

[英]Visualization of Standard Deviation in an array

As a python newbie I need a little help. 作为python新手,我需要一些帮助。 I have an array with 100 rows and 100 columns. 我有一个包含100行和100列的数组。 Each position stands for a temperature value. 每个位置代表一个温度值。 I now want to calculate the mean of the whole array (I have that so far) and then create a new array with the same dimension like the first one and with the standrard deviation at each positions. 现在,我想计算整个数组的均值(到目前为止,我已经知道了),然后创建一个尺寸与第一个数组相同的新数组,并且每个位置的标准偏差都相同。 At the end I want to get an array with the deviation from the mean at each postion, so I want to know, how far each value spreads from the mean. 最后,我想获得一个数组,每个数组的均值均偏离平均值,因此我想知道每个值与均值的差值。 I hope you understand what I mean? 我希望你明白我的意思吗? For better understanding: the array is an infrared thermography image of a house. 为了更好地理解:该阵列是房屋的红外热像图。 With the calulation of standard deviation I want to get the best reactive/sensitive pixels in the image. 通过标准偏差的计算,我希望获得图像中最佳的反应性/敏感像素。 Maybe someone has done something like this before. 也许以前有人做过这样的事情。 In the end I want to export the file, so that I get an image that is similar looking to the infrared image. 最后,我要导出文件,以便获得与红外图像相似的图像。 But not with the raw temperatures but the standard deviation temperatures. 但不是原始温度,而是标准差温度。

Importing the file and calculating the mean like this: 导入文件并计算平均值,如下所示:

data_mean = []

my_array = np.genfromtxt((line.replace(',','.') for line in data),skip_header=9,delimiter=";")

data_mean.append(np.nanmean(my_array))

Then I need calculation the standard deviation of each position in the array. 然后,我需要计算数组中每个位置的标准偏差。

Thank you so much in advance for any help! 提前非常感谢您的帮助!

data_mean = np.mean(my_array) #gets you the mean of the whole array

return an array where every value is the mean of your data 返回一个数组,其中每个值都是数据的平均值

meanArray = np.ones(my_array.shape)*data_mean 

variationFromMean = my_array - meanArray

Is this what you were looking for? 这是您要找的东西吗?

If you are keeping the data in an array format here is a solution: 如果将数据保留为数组格式,则可以采用以下解决方案:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM