# how can i get 6 gaussian distribution?

1 visualización (últimos 30 días)
dongchan el 8 de Jun. de 2023
Respondida: Muskan el 13 de Jun. de 2023
I'd like to draw a histogram of six Gaussian distributions that have six local max values as the average value, over the histogram. I also want to know how to figure out the initial estimates of the mean value, standard deviation, and height of the Gaussian distribution.
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Jon el 8 de Jun. de 2023
Please write some code and then ask for help regarding the code you have written

Iniciar sesión para comentar.

### Respuestas (2)

Kautuk Raj el 13 de Jun. de 2023
To draw a histogram of six Gaussian distributions with six local max values as the average value, we can use the histogram function in MATLAB with the Normalization and BinWidth options. This is an example implementation:
% Define the x values for the histogram
x = linspace(-10, 10, 1000);
% Define the parameters for the six Gaussian distributions
means = [-8, -5, -2, 2, 5, 8];
stds = [1, 1.5, 2, 2.5, 3, 3.5];
heights = [0.05, 0.1, 0.2, 0.3, 0.4, 0.5];
% Create a matrix to store the y values for each Gaussian distribution
y = zeros(length(x), length(means));
% Calculate the y values for each Gaussian distribution
for i = 1:length(means)
y(:, i) = heights(i) * exp(-(x - means(i)).^2 / (2 * stds(i)^2));
end
% Create a histogram of the data
figure;
histogram(x, 'BinWidth', 0.1, 'Normalization', 'pdf', 'EdgeColor', 'none');
% Overlay the Gaussian distributions on the histogram
hold on;
plot(x, y, 'LineWidth', 2, 'Color', 'r');
The resultant plot looks like this:
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Muskan el 13 de Jun. de 2023
Hi Dongchan,
As per my understanding of the question, to draw a histogram of six Gaussian distributions, you can use the "histfit()" function in MATLAB.
The "mean" and "std" functions in MATLAB can be used to estimate the initial mean value and standard deviation of a Gaussian distribution based on a set of data.
You can refer to the following documentation for more information.
Thanks
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Histograms en Help Center y File Exchange.

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by