Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function q = find_strategy_2normal(distribution1, distribution2)
- % same function as in the previous assignment, only extreme
- % values of priors are handled now
- Am = distribution1.Mean;
- As = distribution1.Sigma;
- Ap = distribution1.Prior;
- Cm = distribution2.Mean;
- Cs = distribution2.Sigma;
- Cp = distribution2.Prior;
- if distribution1.Prior == 1
- q.decision = [1 1 1];
- q.t1 = -Inf;
- q.t2 = Inf;
- return
- elseif distribution2.Prior == 1
- q.decision = [2 2 2];
- q.t1 = -Inf;
- q.t2 = Inf;
- return
- end
- % quadratic discriminative function
- Coef = zeros(1,3);
- Coef(1) = 1/(2*Cs^2) - 1/(2*As^2); % a
- Coef(2) = Am/(As^2) - Cm/(Cs^2); % b
- Coef(3) = log((Ap*Cs)/(As*Cp))+Cm^2/(2*Cs^2)-Am^2/(2*As^2); % c
- % computing the polinomial roots
- Ts = roots(Coef); % thresholds
- is_convex = Coef(1) > 0;
- % assign thresholds and decisions
- if isreal(Ts)
- if Ts(1) ~= Ts(2)
- q.t1 = min(Ts);
- q.t2 = max(Ts);
- if is_convex
- q.decision = [1 2 1]; %not guess
- else
- q.decision = [2 1 2]; %not guess
- end
- else
- q.t1 = -Inf;
- q.t2 = Inf;
- if is_convex
- q.decision = [1 1 1]; %not guess
- else
- q.decision = [2 2 2]; %not guess
- end
- end
- else
- q.t1 = -Inf;
- q.t2 = Inf;
- if is_convex
- q.decision = [1 1 1]; %not guess
- else
- q.decision = [2 2 2]; %not guess
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment