<< Chapter < Page Chapter >> Page >

qsample.m Simulates a sample for a given population density. Determines sample parameters and approximate population parameters. Assumes dfsetup or acsetup has been run. Takes asinput the distribution matrices X , P X and the sample size n . Uses a random number generator to obtain the probability matrix U and uses the m-function dquant to determine the sample. Assumes dfsetup or acsetup has been run.

% QSAMPLE file qsample.m Simulates sample for given population density % Version of 1/31/96% Determines sample parameters % and approximate population parameters.% Assumes dfsetup or acsetup has been run X = input('Enter row matrix of VALUES ');PX = input('Enter row matrix of PROBABILITIES '); n = input('Sample size n = ');m = length(X); U = rand(1,n);T = dquant(X,PX,U); ex = sum(T)/n;EX = dot(X,PX); vx = sum(T.^2)/n - ex^2;VX = dot(X.^2,PX) - EX^2; disp('The sample is in column vector T')disp(['Sample average ex = ', num2str(ex),])disp(['Approximate population mean E(X) = ',num2str(EX),])disp(['Sample variance vx = ',num2str(vx),])disp(['Approximate population variance V(X) = ',num2str(VX),])
Got questions? Get instant answers now!

targetset.m Setup for arrival at a target set of values. Used in conjunction with the m-procedure targetrun to determine the number of trials needed to visit k of a specified set of target values. Input consists of the distribution matrices X , P X and the specified set E of target values.

% TARGETSET file targetset.m Setup for sample arrival at target set % Version of 6/24/95X = input('Enter population VALUES '); PX = input('Enter population PROBABILITIES ');ms = length(X); x = 1:ms; % Value indicesdisp('The set of population values is') disp(X);E = input('Enter the set of target values '); ne = length(E);e = zeros(1,ne); for i = 1:nee(i) = dot(E(i) == X,x); % Target value indices endF = [0 cumsum(PX)];A = F(1:ms); B = F(2:ms+1);disp('Call for targetrun')
Got questions? Get instant answers now!

targetrun.m Assumes the m-file targetset has provided the basic data. Input consists of the number r of repetitions and the number k of the target states to visit. Calculates and displays various results.

% TARGETRUN file targetrun.m Number of trials to visit k target values % Version of 6/24/95 Rev for Version 5.1 1/30/98% Assumes the procedure targetset has been run. r = input('Enter the number ofrepetitions '); disp('The target set is')disp(E) ks = input('Enter the number of target values to visit ');if isempty(ks) ks = ne;end if ks>ne ks = ne;end clear T % Trajectory in value indices (reset)R0 = zeros(1,ms); % Indicator for target value indices R0(e) = ones(1,ne);S = zeros(1,r); % Number of trials for each run (reset) for k = 1:rR = R0; i = 1;while sum(R)>ne - ks u = rand(1,1);s = ((A<u)&(u<= B))*x'; if R(s) == 1 % Deletes indices as values reachedR(s) = 0; endT(i) = s; i = i+1;end S(k) = i-1;end if r == 1disp(['The number of trials to completion is ',int2str(i-1),])disp(['The initial value is ',num2str(X(T(1))),])disp(['The terminal value is ',num2str(X(T(i-1))),])N = 1:i-1; TR = [N;X(T)]'; disp('To view the trajectory, call for TR')else [t,f]= csort(S,ones(1,r)); D = [t;f]'; p = f/r;AV = dot(t,p); SD = sqrt(dot(t.^2,p) - AV^2);MN = min(t); MX = max(t);disp(['The average completion time is ',num2str(AV),])disp(['The standard deviation is ',num2str(SD),])disp(['The minimum completion time is ',int2str(MN),])disp(['The maximum completion time is ',int2str(MX),])disp(' ') disp('To view a detailed count, call for D.')disp('The first column shows the various completion times;') disp('the second column shows the numbers of trials yielding those times')plot(t,cumsum(p)) gridtitle('Fraction of Runs t Steps or Less') ylabel('Fraction of runs')xlabel('t = number of steps to complete run') end
Got questions? Get instant answers now!

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Applied probability. OpenStax CNX. Aug 31, 2009 Download for free at http://cnx.org/content/col10708/1.6
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Applied probability' conversation and receive update notifications?

Ask