Skip to content
Permalink
048fa8e03f
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
37 lines (35 sloc) 587 Bytes
clear
clc
%creates the data given in the problem statement
data=[1,53,1
2,57,1
3,58,1
4,63,1
5,66,0
6,66.8,0
7,67,0
8,67.2,0
9,68,0
10,69,0
11,69.8,1
12,69.8,0
13,70.2,1
14,70.2,0
15,72,0
16,73,0
17,75,0
18,75,1
19,75.8,0
20,76.2,0
21,78,0
22,79,0
23,81,0];
%sets the data that is being analyzed
x=data(:,2);
y=data(:,3);
initial_a=[.1,.1];
% Set options for fminunc
options = optimset('GradObj', 'on', 'MaxIter', 400);
% Run fminunc to obtain the optimal theta
% This function will return theta and the cost
[theta, cost] = fminunc(@(a)(cost_logistic(a, x, y)), initial_a, options);