Distribution of sample mean

조회 수: 8 (최근 30일)
M Min
M Min 2016년 3월 12일
답변: Image Analyst 2016년 3월 12일
Hi. I want to get a distribution of sample mean. But I just can get sample mean itself, not the distribution.
e.g.
a = rand(5,1)
abar = mean(a)
You know, in that case, abar shows just one number.
How do I get a distribution of it?
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 3월 12일
What output would you be looking for? The mean and standard deviaton? The string 'uniform' since it is a uniform distribution?

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

답변 (1개)

Image Analyst
Image Analyst 2016년 3월 12일
Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
numberOfExperiments = 100000;
for k = 1 : numberOfExperiments
% Get 5 random numbers.
a = rand(5,1);
% Save the mean for this experiment.
abar(k) = mean(a);
end
% All done, so get a distribution of the means
histogram(abar);
grid on
title('Distribution of means', 'FontSize', fontSize);
xlabel('Mean Value', 'FontSize', fontSize);
ylabel('Count', 'FontSize', fontSize);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by