Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need help with this question (1) Using the shell program lab1.m, write a program that will take an individual sample value as the input and

need help with this question

(1) Using the shell program lab1.m, write a program that will take an individual sample value as the input and will return the posterior probabilities and the value of g(x2)

(3.) Identify the class labels for the feature values using your program, and indicate their respective posterior probabilities and discriminant function values: x1 = [3.3, 4.4, 5.0, 5.7, 6.3]

lab1.m

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ELE 888/ EE 8209: LAB 1: Bayesian Decision Theory %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [posteriors_x,g_x]=lab1(x,Training_Data)

% x = individual sample to be tested (to identify its probable class label) % featureOfInterest = index of relevant feature (column) in Training_Data % Train_Data = Matrix containing the training samples and numeric class labels % posterior_x = Posterior probabilities % g_x = value of the discriminant function

D=Training_Data;

% D is MxN (M samples, N columns = N-1 features + 1 label) [M,N]=size(D); f=D(:,1); % feature samples la=D(:,N); % class labels

%% %%%%Prior Probabilities%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Hint: use the commands "find" and "length"

disp('Prior probabilities:'); Pr1 = Pr2 =

%% %%%%%Class-conditional probabilities%%%%%%%%%%%%%%%%%%%%%%%

disp('Mean & Std for class 1 & 2'); m11 = % mean of the class conditional density p(x/w1) std11 = % Standard deviation of the class conditional density p(x/w1)

m12 = % mean of the class conditional density p(x/w2) std12= % Standard deviation of the class conditional density p(x/w2)

disp(['Conditional probabilities for x=' num2str(x)]); cp11= % use the above mean, std and the test feature to calculate p(x/w1)

cp12= % use the above mean, std and the test feature to calculate p(x/w2)

%% %%%%%%Compute the posterior probabilities%%%%%%%%%%%%%%%%%%%%

disp('Posterior prob. for the test feature');

pos11= % p(w1/x) for the given test feature value

pos12= % p(w2/x) for the given test feature value

posteriors_x=

%% %%%%%%Discriminant function for min error rate classifier%%%

disp('Discriminant function for the test feature');

g_x= % compute the g(x) for min err rate classifier.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions