显示数组中的标准偏差

时间:2023-02-01 14:57:31

As a python newbie I need a little help. I have an array with 100 rows and 100 columns. 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.

作为一个python新手,我需要一点帮助。我有一个包含100行和100列的数组。每个位置代表一个温度值。现在我要计算整个数组的均值(到目前为止我已经有了这个),然后创建一个新的数组,其维度与第一个相同,每个位置都有standrard偏差。最后,我想要得到一个数组在每个位置上都偏离均值,我想知道,每个值离均值有多远。我希望你明白我的意思?为了更好的理解:阵列是一个房子的红外热像图。通过对标准偏差的计算,我希望得到图像中最好的反应/敏感像素。也许有人以前做过这样的事。最后,我想要导出文件,这样我就可以得到一个类似于红外图像的图像。但不是原始温度而是标准差温度。

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!

非常感谢您的帮助!

2 个解决方案

#1


0  

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?

这就是你要找的吗?

#2


0  

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

#1


0  

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?

这就是你要找的吗?

#2


0  

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