# How to perform t-test for a temperature anomaly data set?

조회 수: 13 (최근 30일)
Ashfaq Ahmed 2023년 11월 7일
답변: Shubham 2023년 11월 24일
Hi all, let's say, I have a 376x268x235 3D matrix, with values ranging from -2.5°C to 0.65°C.
Here, 376x268 is the grid system and 235 is the time step.
I want to calculate the signal-to-noise (SNR) ratio from the composite (average) of the 235 images. Here, the signal is the mean temperature of each corresponding pixel and the noise is the variability (standard error).
Also, how can I define the statistical significance of my signal-to-noise ratio plot in a way as in I am showing a 5% significance (95% confidence level) of every pixel's SNR threshold using a one-sided Student’s t-test?
Any feedback will be greatly appreciated.

댓글을 달려면 로그인하십시오.

### 답변 (1개)

Shubham 2023년 11월 24일
Hey Ashfaq,
I understand that you want to calculate signal-to-noise (SNR) ratio using the average of 235 images and then perform the one-sided Student’s t-test with 5% significance (95% confidence).
Refer to the following code using a dummy data below:
% Dummy data generation
% 376x268x235, values ranging from -2.5 to 0.65
dummyData = -2.5 + (0.65 + 2.5) * rand(376, 268, 235);
% Calculate the Mean and Standard Error for Each Pixel
meanTemp = mean(dummyData, 3);
stdTemp = std(dummyData, 0, 3);
n = size(dummyData, 3);
seTemp = stdTemp / sqrt(n);
% Calculate the SNR for Each Pixel
snr = meanTemp ./ seTemp;
% Plot the SNR
figure;
imagesc(snr);
colorbar;
title('Signal-to-Noise Ratio (SNR)');
axis image;
I am assuming that you want to perform Student’s t-test with the null hypothesis that the data comes from normal distribution with mean equal to zero. Normally one would be using the “ttest” function given in the documentation as follows:
[h,~,~,stats] = ttest(x,0,"Alpha",0.05,"Tail","left")
Here the above line performs a t-test on sample "x" with mean 0 and 5% significance while specifying the direction for the one-sided test. The value of "hrepresents whether the null hypothesis was accepted or rejected.
In your case, the signal-to-noise ratio is stored in a matrix. We can use signal-to-noise values (t-values) for comparison with "t-critical values.
t_critical = tinv(0.95, n - 1);
statistical_Significance = abs(snr)>t_critical;
If the "t-value" lies in the bounds of t-criticalthen the null hypothesis is considered over the alternate hypothesis.
Hope this helps!

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by