- Take each of the 144 columns of data individually.
- Create a histogram of data in each column using a bin size of 50.
- Fit a Gaussian distribution to each histogram.
- Extract the mean and standard deviation from each fitted Gaussian distribution.
How to measure mean and standard deviation according to bin size?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have 1 to 144 columns.
I want to know the standard deviation and mean value according to the bin size when performing Gaussian fitting for 144 columns.
I want to measure the value when 'bin size=50'.
0 comentarios
Respuestas (1)
MULI
el 20 de Feb. de 2024
You can follow these steps to know the mean value and standard deviation according to bin size.
clc;
clear all;
close all;
% Define the URL of the data file
url = 'https://in.mathworks.com/matlabcentral/answers/uploaded_files/833625/1to10_30s_15mm_diff_pivoted.txt';
% Download the data file
filename = websave('localdata.txt', url);
% Load the data into MATLAB using readmatrix
data = readmatrix(filename);
% Define the number of columns and bin size
nColumns = 144;
binSize = 50;
% Preallocate arrays for means and standard deviations
means = zeros(1, nColumns);
stdDevs = zeros(1, nColumns);
% Loop through each column to perform Gaussian fitting
for col = 1:nColumns
columnData = data(:, col); % Extract data for the current column
% Create histogram bins with the specified bin size
binEdges = min(columnData):binSize:max(columnData);
binCenters = binEdges(1:end-1) + binSize/2;
binCounts = histcounts(columnData, binEdges);
% Fit a Gaussian distribution to the binned data
% Define Gaussian function (normal distribution)
gaussEqn = 'a*exp(-((x-b)/c)^2)';
startPoints = [max(binCounts), mean(columnData), std(columnData)]; % Initial guess
% Perform the fit
fitObject = fit(binCenters(:), binCounts(:), gaussEqn, 'Start', startPoints);
% Extract the mean and standard deviation from the fit parameters
means(col) = fitObject.b;
stdDevs(col) = abs(fitObject.c); % Ensure standard deviation is positive
end
% Display the results
disp('Means of Gaussian fits for each column:');
disp(means);
disp('Standard deviations of Gaussian fits for each column:');
disp(stdDevs);
0 comentarios
Ver también
Categorías
Más información sobre Descriptive Statistics en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!