<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>blaceman</title>
  <subtitle>懵懂 前进 憧憬</subtitle>
  <link href="/atom.xml" rel="self"/>
  
  <link href="https://blaceman.github.io/"/>
  <updated>2018-06-11T03:15:18.000Z</updated>
  <id>https://blaceman.github.io/</id>
  
  <author>
    <name>blaceman</name>
    
  </author>
  
  <generator uri="http://hexo.io/">Hexo</generator>
  
  <entry>
    <title></title>
    <link href="https://blaceman.github.io/2018/06/11/iOS%E9%80%86%E5%90%91%E6%80%BB%E7%BB%93/"/>
    <id>https://blaceman.github.io/2018/06/11/iOS逆向总结/</id>
    <published>2018-06-11T03:15:18.000Z</published>
    <updated>2018-06-11T03:15:18.000Z</updated>
    
    <content type="html"><![CDATA[<!doctype html>
<html>
<head>
<meta charset="UTF-8"><meta name="viewport" content="width=device-width initial-scale=1">
<title>iOS逆向工程总结</title><link href="https://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700,700italic&subset=latin,cyrillic-ext,cyrillic,latin-ext" rel="stylesheet" type="text/css"><style type="text/css">html {overflow-x: initial !important;}#write, body { height: auto; }
#write, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write ol, #write p, #write ul { position: relative; }
#write, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p, #write pre { width: inherit; }
#write, pre { white-space: pre-wrap; }
.CodeMirror, .md-fences, table { text-align: left; }
.md-reset, a:active, a:hover { outline: 0px; }
.md-reset, .md-toc-item a { text-decoration: none; }
.MathJax_SVG, .md-reset { float: none; direction: ltr; }
:root { --bg-color: #ffffff; --text-color: #333333; }
html { font-size: 14px; background-color: var(--bg-color); color: var(--text-color); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body { margin: 0px; padding: 0px; bottom: 0px; top: 0px; left: 0px; right: 0px; font-size: 1rem; line-height: 1.42857143; overflow-x: hidden; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit inherit; background-repeat: inherit inherit; }
a.url { word-break: break-all; }
.in-text-selection, ::selection { background-color: rgb(181, 214, 252); text-shadow: none; background-position: initial initial; background-repeat: initial initial; }
#write { margin: 0px auto; word-break: normal; word-wrap: break-word; padding-bottom: 70px; overflow-x: visible; }
.first-line-indent #write p .md-line { text-indent: 0px; }
.first-line-indent #write li, .first-line-indent #write p, .first-line-indent #write p .md-line:first-child { text-indent: 2em; }
.for-image #write { padding-left: 8px; padding-right: 8px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
@media screen and (max-width: 500px) { 
  body.typora-export { padding-left: 0px; padding-right: 0px; }
  .CodeMirror-sizer { margin-left: 0px !important; }
  .CodeMirror-gutters { display: none !important; }
}
#write > blockquote:first-child, #write > div:first-child, #write > ol:first-child, #write > p:first-child, #write > pre:first-child, #write > table:first-child, #write > ul:first-child { margin-top: 30px; }
#write li > table:first-child { margin-top: -20px; }
img { max-width: 100%; vertical-align: middle; }
button, input, select, textarea { color: inherit; font-family: inherit; font-size: inherit; font-style: inherit; font-variant-caps: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
*, ::after, ::before { box-sizing: border-box; }
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
p { -webkit-margin-before: 1rem; -webkit-margin-after: 1rem; -webkit-margin-start: 0px; -webkit-margin-end: 0px; }
.mathjax-block { margin-top: 0px; margin-bottom: 0px; -webkit-margin-before: 0px; -webkit-margin-after: 0px; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: 700; font-style: italic; }
a { cursor: pointer; }
sup.md-footnote { padding: 2px 4px; background-color: rgba(238, 238, 238, 0.701961); color: rgb(85, 85, 85); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; }
#write > figure:first-child { margin-top: 16px; }
figure { overflow-x: auto; margin: -8px 0px 0px -8px; max-width: calc(100% + 16px); padding: 8px; }
tr { break-inside: avoid; break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; break-inside: auto; }
.CodeMirror-line, .md-fences { break-inside: avoid; }
table.md-table td { min-width: 80px; }
.CodeMirror-gutters { border-right-width: 0px; background-color: inherit; margin-right: 4px; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
.md-fences { font-size: 0.9rem; display: block; overflow: visible; white-space: pre; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; background-position: inherit inherit; background-repeat: inherit inherit; }
.md-diagram-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }
.md-fences .CodeMirror.CodeMirror-wrap { top: -1.6em; margin-bottom: -1.6em; }
.md-fences.mock-cm { white-space: pre-wrap; }
.show-fences-line-number .md-fences { padding-left: 0px; }
.show-fences-line-number .md-fences.mock-cm { padding-left: 40px; }
.footnotes { opacity: 0.8; font-size: 0.9rem; margin-top: 1em; margin-bottom: 1em; }
.footnotes + .footnotes { margin-top: 0px; }
.md-reset { margin: 0px; padding: 0px; border: 0px; vertical-align: top; text-shadow: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; line-height: normal; font-weight: 400; text-align: left; box-sizing: content-box; background-position: 0px 0px; background-repeat: initial initial; }
.md-toc-inner, a img, img a { cursor: pointer; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li .mathjax-block, li p { margin: 0.5rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; white-space: normal; }
@media print { 
  body, html { border: 1px solid transparent; height: 99%; break-after: avoid-page; break-before: avoid-page; }
  #write { margin-top: 0px; border-color: transparent !important; }
  .typora-export * { -webkit-print-color-adjust: exact; }
  h1, h2, h3, h4, h5, h6 { break-after: avoid-page; orphans: 2; }
  p { orphans: 4; }
  html.blink-to-pdf { font-size: 13px; }
  .typora-export #write { padding-left: 1cm; padding-right: 1cm; padding-bottom: 0px; break-after: avoid-page; }
  .typora-export #write::after { height: 0px; }
  @page { margin: 20mm 0px; }
}
.footnote-line { white-space: pre-wrap; margin-top: 0.714em; font-size: 0.7em; }
pre.md-meta-block { font-size: 0.8rem; min-height: 0.8rem; white-space: pre-wrap; background-color: rgb(204, 204, 204); display: block; overflow-x: hidden; background-position: initial initial; background-repeat: initial initial; }
p > img:only-child { display: block; margin: auto; }
.md-line > .md-image:only-child, p > .md-image:only-child { display: inline-block; width: 100%; text-align: center; }
.mathjax-block:not(:empty)::after, .md-toc-content::after, .md-toc::after { display: none; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.mathjax-block { white-space: pre; overflow: hidden; width: 100%; }
p + .mathjax-block { margin-top: -1.143rem; }
[contenteditable="true"]:active, [contenteditable="true"]:focus { outline: 0px; box-shadow: none; }
.md-task-list-item { position: relative; list-style-type: none; }
.task-list-item.md-task-list-item { padding-left: 0px; }
.md-task-list-item > input { position: absolute; top: 0px; left: 0px; margin-left: -1.2em; margin-top: calc(1em - 10px); }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; }
.MathJax_SVG, .mathjax-block .MathJax_SVG_Display { text-indent: 0px; max-width: none; max-height: none; min-height: 0px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc-item { display: block; color: rgb(65, 131, 196); }
.md-toc-inner:hover { }
.md-toc-inner { display: inline-block; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: 700; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
@media screen and (max-width: 48em) { 
  .md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
  .md-toc-h4 .md-toc-inner { margin-left: 5em; }
  .md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
  .md-toc-h6 .md-toc-inner { margin-left: 8em; }
}
a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.md-attr { display: none; }
.md-fn-count::after { content: "."; }
code, pre, tt { font-family: var(--monospace); }
.md-comment { color: rgb(162, 127, 3); opacity: 0.8; font-family: var(--monospace); }
code { text-align: left; }
a.md-print-anchor { border: none !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: 0px !important; text-shadow: initial !important; background-position: 0px 0px !important; background-repeat: initial initial !important; }
.md-inline-math .MathJax_SVG .noError { display: none !important; }
.mathjax-block .MathJax_SVG_Display { text-align: center; margin: 1em 0px; position: relative; min-width: 100%; width: auto; display: block !important; }
.MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display { width: auto; margin: inherit; display: inline-block !important; }
.MathJax_SVG .MJX-monospace { font-family: monospace; }
.MathJax_SVG .MJX-sans-serif { font-family: sans-serif; }
.MathJax_SVG { display: inline; font-style: normal; font-weight: 400; line-height: normal; zoom: 90%; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; min-width: 0px; border: 0px; padding: 0px; margin: 0px; }
.MathJax_SVG * { transition: none; }
.os-windows.monocolor-emoji .md-emoji { font-family: "Segoe UI Symbol", sans-serif; }
.md-diagram-panel > svg, [lang="flow"] svg, [lang="mermaid"] svg { max-width: 100%; }
[lang="mermaid"] .node text { font-size: 1rem; }
table tr th { border-bottom-width: 0px; }


/* meyer reset -- http://meyerweb.com/eric/tools/css/reset/ , v2.0 | 20110126 | License: none (public domain) */

@include-when-export url(https://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700,700italic&subset=latin,cyrillic-ext,cyrillic,latin-ext);

/* =========== */

@font-face {
    font-family: 'PT Serif';
    font-style: normal;
    font-weight: normal;
    src: local('PT Serif'), local('PTSerif-Regular'), url(file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Regular.ttf);
}
@font-face {
    font-family: 'PT Serif';
    font-style: italic;
    font-weight: normal;
    src: local('PT Serif'), local('PTSerif-Italic'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Italic.ttf')
}

@font-face {
    font-family: 'PT Serif';
    font-style: normal;
    font-weight: bold;
    src: local('PT Serif'), local('PTSerif-Bold'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Bold.ttf')
}

@font-face {
    font-family: 'PT Serif';
    font-style: italic;
    font-weight: bold;
    src: local('PT Serif'), local('PTSerif-BoldItalic'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-BoldItalic.ttf')
}

:root {
	--active-file-bg-color: #dadada;
	--active-file-bg-color: rgba(32, 43, 51, 0.63);
	--active-file-text-color: white;
	--bg-color: #f3f2ee;
	--text-color: #1f0909;
}

html {
	font-size: 16px;
}

html, body {
	background-color: #f3f2ee;
	font-family: "PT Serif", 'Times New Roman', Times;
	color: #1f0909;
	line-height: 1.5em;
}

/*#write {
	overflow-x: auto;
    max-width: initial;
	padding-left: calc(50% - 17em);
    padding-right: calc(50% - 17em);
}

@media (max-width: 36em) {
 	#write {
 		padding-left: 1em;
    	padding-right: 1em;
 	}
}*/

#write {
	max-width: 40em;
}

ol,
ul {
	list-style: none;
}
blockquote,
q {
	quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
/* styles */

/* ====== */

/* headings */

h1,
h2,
h3,
h4,
h5,
h6 {
	font-weight: bold;
}
h1 {
	font-size: 1.875em;
	/*30 / 16*/
	line-height: 1.6em;
	/* 48 / 30*/
	margin-top: 2em;
}
h2,
h3 {
	font-size: 1.3125em;
	/*21 / 16*/
	line-height: 1.15;
	/*24 / 21*/
	margin-top: 2.285714em;
	/*48 / 21*/
	margin-bottom: 1.15em;
	/*24 / 21*/
}
h3 {
	font-weight: normal;
}
h4 {
	font-size: 1.125em;
	/*18 / 16*/
	margin-top: 2.67em;
	/*48 / 18*/
}
h5,
h6 {
	font-size: 1em;
	/*16*/
}
h1 {
	border-bottom: 1px solid;
	margin-bottom: 1.875em;
	padding-bottom: 0.8125em;
}
/* links */

a {
	text-decoration: none;
	color: #065588;
}
a:hover,
a:active {
	text-decoration: underline;
}
/* block spacing */

p,
blockquote,
.md-fences {
	margin-bottom: 1.5em;
}
h1,
h2,
h3,
h4,
h5,
h6 {
	margin-bottom: 1.5em;
}
/* blockquote */

blockquote {
	font-style: italic;
	border-left: 5px solid;
	margin-left: 2em;
	padding-left: 1em;
}
/* lists */

ul,
ol {
	margin: 0 0 1.5em 1.5em;
}
ol li {
	list-style-type: decimal;
	list-style-position: outside;
}
ul li {
	list-style-type: disc;
	list-style-position: outside;
}
/* tables */
.md-meta,.md-before, .md-after {
	color:#999;
}

table {
	margin-bottom: 1.5em;
	/*24 / 16*/
	font-size: 1em;
	/* width: 100%; */
}
thead th,
tfoot th {
	padding: .25em .25em .25em .4em;
	text-transform: uppercase;
}
th {
	text-align: left;
}
td {
	vertical-align: top;
	padding: .25em .25em .25em .4em;
}

code,
.md-fences {
	background-color: #dadada;
	padding-left: 1ch;
	padding-right: 1ch;
}
.md-fences {
	margin-left: 2em;
	margin-bottom: 3em;
}

.md-fences .CodeMirror.CodeMirror-wrap {
	top: -0.8em;
}

pre,
code,
tt {
	font-size: .875em;
	line-height: 1.714285em;
}
/* some fixes */

h1 {
	line-height: 1.3em;
	font-weight: normal;
	margin-bottom: 0.5em;
}

p + ul,
p + ol{
	margin-top: -1em;
}

h3 + ul,
h4 + ul,
h5 + ul,
h6 + ul,
h3 + ol,
h4 + ol,
h5 + ol,
h6 + ol {
	margin-top: .5em;
}

li > ul,
li > ol {
	margin-top: inherit;
}

h2,
h3 {
	margin-bottom: .75em;
}
hr {
	border-top: none;
	border-right: none;
	border-bottom: 1px solid;
	border-left: none;
}
h1 {
	border-color: #c5c5c5;
}
blockquote {
	border-color: #bababa;
	color: #656565;
}
thead.md-table-edit {
	background-color: transparent;
}
thead {
	background-color: #dadada;
}
tr:nth-child(even) {
	background: #e8e7e7;
}
hr {
	border-color: #c5c5c5;
}
.task-list{
	padding-left: 1rem;
}

.md-task-list-item {
	padding-left: 1.5rem;
	list-style-type: none;
}

.md-task-list-item > input:before {
	content: '\221A';
	display: inline-block;
	width: 1.25rem;
  	height: 1.6rem;
	vertical-align: middle;
	text-align: center;
	color: #ddd;
	background-color: #F3F2EE;
}

.md-task-list-item > input:checked:before,
.md-task-list-item > input[checked]:before{
	color: inherit;
}

#write pre.md-meta-block {
	min-height: 1.875rem;
	color: #555;
	border: 0px;
	background: transparent;
	margin-top: -4px;
	margin-left: 1em;
	margin-top: 1em;
}

.md-image>.md-meta {
	color: #9B5146;
}

.md-image>.md-meta{
	font-family: Menlo, 'Ubuntu Mono', Consolas, 'Courier New', 'Microsoft Yahei', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', sans-serif;
}


#write>h3.md-focus:before{
	left: -1.5rem;
	color:#999;
	border-color:#999;
}
#write>h4.md-focus:before{
	left: -1.5rem;
	top: .25rem;
	color:#999;
	border-color:#999;
}
#write>h5.md-focus:before{
	left: -1.5rem;
	top: .0.3125rem;
	color:#999;
	border-color:#999;
}
#write>h6.md-focus:before{
	left: -1.5rem;
	top: 0.3125rem;
	color:#999;
	border-color:#999;
}

.md-toc:focus .md-toc-content{
	margin-top: 19px;
}

.md-toc-content:empty:before{
	color: #065588;
}
.md-toc-item {
	color: #065588;
}
#write div.md-toc-tooltip {
	background-color: #f3f2ee;
}

#typora-sidebar {
	background-color: #f3f2ee;
	-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.375);
  	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.375);
}

.pin-outline #typora-sidebar {
	background: inherit;
	box-shadow: none;
	border-right: 1px dashed;
}

.pin-outline #typora-sidebar:hover .outline-title-wrapper {
	border-left:1px dashed;
}

.outline-item:hover {
  background-color: #dadada;
  border-left: 28px solid #dadada;
  border-right: 18px solid #dadada;
}

.typora-node .outline-item:hover {
  	border-right: 28px solid #dadada;
}

.outline-expander:before {
  content: "\f0da";
  font-family: FontAwesome;
  font-size:14px;
  top: 1px;
}

.outline-expander:hover:before,
.outline-item-open>.outline-item>.outline-expander:before {
  content: "\f0d7";
}

.modal-content {
	background-color: #f3f2ee;
}

.auto-suggest-container ul li {
	list-style-type: none;
}

/** UI for electron */

.megamenu-menu,
#top-titlebar, #top-titlebar *,
.megamenu-content {
	background: #f3f2ee;
	color: #1f0909;
}

.megamenu-menu-header {
	border-bottom: 1px dashed #202B33;
}

.megamenu-menu {
	box-shadow: none;
	border-right: 1px dashed;
}

header, .context-menu, .megamenu-content, footer {
	font-family: "PT Serif", 'Times New Roman', Times;
    color: #1f0909;
}

#megamenu-back-btn {
	color: #1f0909;
	border-color: #1f0909;
}

.megamenu-menu-header #megamenu-menu-header-title:before {
	color: #1f0909;
}

.megamenu-menu-list li a:hover, .megamenu-menu-list li a.active {
	color: inherit;
	background-color: #e8e7df;
}

.long-btn:hover {
	background-color: #e8e7df;
}

#recent-file-panel tbody tr:nth-child(2n-1) {
    background-color: transparent !important;
}

.megamenu-menu-panel tbody tr:hover td:nth-child(2) {
    color: inherit;
}

.megamenu-menu-panel .btn {
	background-color: #D2D1D1;
}

.btn-default {
	background-color: transparent;
}

.typora-sourceview-on #toggle-sourceview-btn,
.show-word-count #footer-word-count {
	background: #c7c5c5;
}

#typora-quick-open {
    background-color: inherit;
}

.md-diagram-panel {
	margin-left: -1ch;
	margin-top: 24px;
}

.file-list-item-file-name {
	font-weight: initial;
}

.file-list-item-summary {
	opacity: 1;
}

.file-list-item {
	color: #777;
}

.file-list-item.active {
	background-color: inherit;
	color: black;
}

.ty-side-sort-btn.active {
	background-color: inherit;
}

.file-list-item.active .file-list-item-file-name  {
	font-weight: bold;
}

.file-list-item{
    opacity:1 !important;
}

.file-library-node.active>.file-node-background{
	background-color: rgba(32, 43, 51, 0.63);
	background-color: var(--active-file-bg-color);
}

.file-tree-node.active>.file-node-content{
	color: white;
	color: var(--active-file-text-color);
}

.md-task-list-item>input {
	margin-left: -1.6em;
	margin-top: calc(1rem - 12px);
}


 .typora-export p, .typora-export .footnote-line {white-space: normal;} 
</style>
</head>
<body class="typora-export">
<div id="write" class="is-mac show-fences-line-number"><hr><div class="md-toc" mdtype="toc"><p class="md-toc-content"><span class="md-toc-item md-toc-h3" data-ref="n4"><a class="md-toc-inner" href="#header-n4">iOS 逆向概念</a></span><span class="md-toc-item md-toc-h4" data-ref="n5"><a class="md-toc-inner" href="#header-n5">1.逆向的作用</a></span><span class="md-toc-item md-toc-h4" data-ref="n20"><a class="md-toc-inner" href="#header-n20">2.逆向工具</a></span><span class="md-toc-item md-toc-h4" data-ref="n42"><a class="md-toc-inner" href="#header-n42">3.iOS 目录结构</a></span><span class="md-toc-item md-toc-h4" data-ref="n101"><a class="md-toc-inner" href="#header-n101">4.iOS二进制文件类型</a></span><span class="md-toc-item md-toc-h3" data-ref="n172"><a class="md-toc-inner" href="#header-n172">OSX工具</a></span><span class="md-toc-item md-toc-h4" data-ref="n173"><a class="md-toc-inner" href="#header-n173">1.class-dump</a></span><span class="md-toc-item md-toc-h4" data-ref="n190"><a class="md-toc-inner" href="#header-n190">2.Theos</a></span><span class="md-toc-item md-toc-h4" data-ref="n222"><a class="md-toc-inner" href="#header-n222">3.Reveal</a></span><span class="md-toc-item md-toc-h4" data-ref="n236"><a class="md-toc-inner" href="#header-n236">4.IDA</a></span><span class="md-toc-item md-toc-h4" data-ref="n255"><a class="md-toc-inner" href="#header-n255">5.非越狱开发(MonkeyDey)</a></span><span class="md-toc-item md-toc-h3" data-ref="n263"><a class="md-toc-inner" href="#header-n263">iOS工具集</a></span><span class="md-toc-item md-toc-h4" data-ref="n264"><a class="md-toc-inner" href="#header-n264">1.Cydia Substrate</a></span><span class="md-toc-item md-toc-h4" data-ref="n269"><a class="md-toc-inner" href="#header-n269">2.cycript</a></span><span class="md-toc-item md-toc-h4" data-ref="n283"><a class="md-toc-inner" href="#header-n283">3.lldb</a></span><span class="md-toc-item md-toc-h4" data-ref="n315"><a class="md-toc-inner" href="#header-n315">4.dumpdecrypted</a></span><span class="md-toc-item md-toc-h4" data-ref="n326"><a class="md-toc-inner" href="#header-n326">5.OpenSSH</a></span><span class="md-toc-item md-toc-h4" data-ref="n334"><a class="md-toc-inner" href="#header-n334">6.usbmuxd</a></span><span class="md-toc-item md-toc-h4" data-ref="n339"><a class="md-toc-inner" href="#header-n339">7.iflie、Filza</a></span><span class="md-toc-item md-toc-h4" data-ref="n344"><a class="md-toc-inner" href="#header-n344">8.MTerminal</a></span><span class="md-toc-item md-toc-h4" data-ref="n349"><a class="md-toc-inner" href="#header-n349">9.syslogd</a></span><span class="md-toc-item md-toc-h3" data-ref="n360"><a class="md-toc-inner" href="#header-n360">优秀资源文章</a></span></p></div><h3 id="ios-逆向概念"><a name="header-n4" class="md-header-anchor "></a>iOS 逆向概念</h3><h4 id="1逆向的作用"><a name="header-n5" class="md-header-anchor "></a>1.逆向的作用</h4><ul><li><p>通过分析目标程序，拿到关键信息 ,可以归类于安全相关的逆向工程</p><ol start=""><li>评定安全等级</li><li>修改软件使用限制,逻辑,功能等</li><li>开发相关逆向工程</li></ol></li></ul><h4 id="2逆向工具"><a name="header-n20" class="md-header-anchor "></a>2.逆向工具</h4><figure><table><thead><tr><th style="text-align:center;">检测工具</th><th style="text-align:center;">反汇编工具</th><th style="text-align:center;">调试工具</th><th style="text-align:center;">开发工具</th></tr></thead><tbody><tr><td style="text-align:center;">Reveal(监测UI)</td><td style="text-align:center;">IDA</td><td style="text-align:center;">lldb</td><td style="text-align:center;">iOSOpenDev</td></tr><tr><td style="text-align:center;">snoop-it(网络活动)</td><td style="text-align:center;">Hopper</td><td style="text-align:center;">\</td><td style="text-align:center;">Theos</td></tr><tr><td style="text-align:center;">introspy(分析应用程序)</td><td style="text-align:center;">\</td><td style="text-align:center;">\</td><td style="text-align:center;">\</td></tr></tbody></table></figure><h4 id="3ios-目录结构"><a name="header-n42" class="md-header-anchor "></a>3.iOS 目录结构</h4><ul><li>·/：根目录，以斜杠表示，其他所有文件和目录在根目录下展开 </li><li>·/bin：“binary”的简写，存放提供用户级基础功能的二进制文件，如ls、ps等 </li><li>·/boot：存放能使系统成功启动的所有文件。iOS中此目录为空”</li><li>·/dev：“device”的简写，存放BSD设备文件” “每个文件代表系统的一个块设备或字符设备</li><li>·/sbin：“system binaries”的简写，存放提供系统级基础功能的二进制文件，如netstat、reboot等 </li><li>·/etc：“Et Cetera”的简写，存放系统脚本及配置文件，如passwd、hosts等。在iOS中，/etc是一个符号链接，实际指向/private/etc。 </li><li>·/lib：存放系统库文件、内核模块及设备驱动等。iOS中此目录为空 </li><li>·/mnt：“mount”的简写，存放临时的文件系统挂载点。iOS中此目录为空。 </li><li>·/private：存放两个目录，分别是/private/etc和/private/var </li><li>·/tmp：临时目录。在iOS中，/tmp是一个符号链接，实际指向/private/var/tmp。 </li><li>·/usr：包含了大多数用户工具和程序。/usr/bin包含那些/bin和/sbin中未出现的基础功能，如nm、killall等；/usr/include包含所有的标准C头文件；/usr/lib存放库文件。 </li><li>·/var：“variable”的简写，存放一些经常更改的文件，比如日志、用户数据、临时文件等”“其中/var/mobile和/var/root分别存放了mobile用户和root用户的文件，是重点关注的目录。 </li><li>/Applications：存放所有的系统App和来自于Cydia的App，不包括StoreApp </li><li>·/Developer：如果一台设备连接Xcode后被指定为调试用机（如图2-4所示），Xcode就会在iOS中生成这个目录 </li><li>·/Library：存放一些提供系统支持的数据 </li><li>·/System/Library：iOS文件系统中最重要的目录之一，存放大量系统组件 </li><li>·/System/Library/Frameworks和/System/Library/PrivateFrameworks：存放iOS中的各种framework，其中出现在SDK文档里的只是冰山一角，还有数不清的未公开功能等待我们去挖掘 </li><li>·/System/Library/CoreServices里的SpringBoard.app：iOS桌面管理器（类似于Windows里的explorer），是用户与系统交流的最重要中介 </li><li>/User：用户目录，实际指向/var/mobile  &quot;·/var/mobile/Media/DCIM下存放照片 &quot; “·/var/mobile/Media/Recordings下存放录音文件；” “·/var/mobile/Library/SMS下存放短信数据库；” “·/var/mobile/Library/Mail下存放邮件数据。”  “非常重要的子目录是/var/mobile/Containers，存放StoreApp。值得注意的是，App的可执行文件在bundle与App中的数据目录被分别存放在/var/mobile/Containers/Bundle和/var/mobile/Containers/Data这两个不同目录下” </li></ul><h4 id="4ios二进制文件类型"><a name="header-n101" class="md-header-anchor "></a>4.iOS二进制文件类型</h4><ul><li><p>Application</p><ul><li><p>1.bundle</p><ul><li>App和framework</li><li>PreferenceBundle(依附于setting)</li></ul></li><li><p>App目录结构</p><ul><li><p>Info.plist(记录App的基本信息 )</p><p>关注Bundle Identifier ,可执行文件名等有用信息</p></li><li><p>可执行文件</p><p>BundleExecutable</p></li><li><p>lproj目录(本地化字符串)</p></li></ul></li><li><p>系统App VS.StoreApp</p><ul><li><p>目录结构</p><p>系统App(Cydia APP):/Applications   权限:root</p><p>StoreApp:/var/mobile/Containers/    权限:mobile</p></li><li><p>安装包格式与权限</p><ul><li>系统(cydia)App: .deb</li><li>storeApp:  .ipa</li></ul></li><li><p>沙盒</p></li></ul></li></ul></li><li><p>Dynamic Library</p><p>在iOS中，lib分为static和dynamic两种:</p><p>​	1.其中static lib在编译阶段成为App可执行文件的一部分，会增加可执行文件的大小</p><p>​	2.dylib不会改变可执行文件的大小，只有当App需要用到这个dylib时，iOS才会把它加载进内存，成为App进程的一部分</p><p>lib 本身并不是可执行文件，不能独立运行，只能为别的进程服务，而且它们寄生在别的进程里，成为了这个进程的一部分。</p></li><li><p>Deamon(后台) </p></li></ul><h3 id="osx工具"><a name="header-n172" class="md-header-anchor "></a>OSX工具</h3><h4 id="1class-dump"><a name="header-n173" class="md-header-anchor "></a>1.class-dump</h4><ul><li>作用:用来dump目标文件的class信息的工具</li><li>原理:利用Objective-C语言的runtime的特性，将存储在mach-O文件中的@interface和@protocol信息提取出来，并生成对应的.h文件</li><li>安装使用:<a href="https://www.jianshu.com/p/1e3fe0a8c048" target="_blank" class="url">https://www.jianshu.com/p/1e3fe0a8c048</a></li><li>主要命令行:class-dump -H [.app文件的路径] -o [输出文件夹路径]</li><li>局限:1.没有加密的App。APPStore上的App就需要配合Dumpdecrypted破壳了 2.只能在作用于纯OC项目,对于Swift无能为力</li></ul><h4 id="2theos"><a name="header-n190" class="md-header-anchor "></a>2.Theos</h4><ul><li><p>作用:越狱工具开发包(开发工具)</p></li><li><p>安装使用:<a href="https://www.cnblogs.com/ludashi/p/5714095.html" target="_blank" class="url">https://www.cnblogs.com/ludashi/p/5714095.html</a></p></li><li><p>主要命令行:</p><ol start=""><li>export THEOS=theos文件所在路径(一般为/opt/theos)</li><li>$THEOS/bin/nic.pl        新建工程</li><li>make   编译</li><li>make package   打包</li><li>make install 安装</li></ol></li><li><p>语言:<a href="http://iphonedevwiki.net/index.php/Logos">Logos</a></p><p>&nbsp;</p></li></ul><h4 id="3reveal"><a name="header-n222" class="md-header-anchor "></a>3.Reveal</h4><ul><li>作用:监测UI布局</li><li>安装教程: <a href="https://blog.csdn.net/hello_hwc/article/details/69365095" target="_blank" class="url">https://blog.csdn.net/hello_hwc/article/details/69365095</a></li><li>主要命令行:/</li><li>注意:OSX与iOS要在同一网段下</li></ul><h4 id="4ida"><a name="header-n236" class="md-header-anchor "></a>4.IDA</h4><ul><li>作用:反汇编工具,看源代码的</li><li>下载安装:<a href="https://www.hex-rays.com/products/ida/support/download_demo.shtml" target="_blank" class="url">https://www.hex-rays.com/products/ida/support/download_demo.shtml</a></li><li>教程:<a href="http://www.freebuf.com/column/157939.html" target="_blank" class="url">http://www.freebuf.com/column/157939.html</a></li><li>主要操作:空格键 、F5等</li><li>难点:汇编</li></ul><p>&nbsp;</p><h4 id="5非越狱开发monkeydey"><a name="header-n255" class="md-header-anchor "></a>5.非越狱开发(MonkeyDey)</h4><ul><li>作用:非越狱开发</li><li>教程:<a href="http://bbs.iosre.com/t/topic/8696" target="_blank" class="url">http://bbs.iosre.com/t/topic/8696</a></li></ul><h3 id="ios工具集"><a name="header-n263" class="md-header-anchor "></a>iOS工具集</h3><h4 id="1cydia-substrate"><a name="header-n264" class="md-header-anchor "></a>1.Cydia Substrate</h4><ul><li>作用:绝大部分tweak正常工作的基础，它由MobileHooker、MobileLoade和Safe mode 组成。 cydia商店可直接下载</li></ul><h4 id="2cycript"><a name="header-n269" class="md-header-anchor "></a>2.cycript</h4><ul><li>作用:脚本语言,测试(调试)运行的App</li><li>安装:cydia直接下载安装</li><li>教程:<a href="http://www.cycript.org/manual/" target="_blank" class="url">http://www.cycript.org/manual/</a>、<a href="https://www.jianshu.com/p/7c41b03c9eb3" target="_blank" class="url">https://www.jianshu.com/p/7c41b03c9eb3</a></li><li>语言:Objective-C与javascript</li></ul><h4 id="3lldb"><a name="header-n283" class="md-header-anchor "></a>3.lldb</h4><ul><li><p>作用:Xcode自带的调试工具</p></li><li><p>安装教程:<a href="http://www.qingpingshan.com/rjbc/ios/140197.html" target="_blank" class="url">http://www.qingpingshan.com/rjbc/ios/140197.html</a></p></li><li><p>使用教程:<a href="http://www.dllhook.com/post/51.html" target="_blank" class="url">http://www.dllhook.com/post/51.html</a></p></li><li><p>主要命令行:</p><ul><li>直接启动进程：debugserver -x backboard *:1234 /path/to/app/executable</li><li>附加进程：./debugserver *:1234 -a &quot;YourAPPName&quot;</li><li>po(打印对象信息) p(打印值) c(继续执行) s、si(单步执行,子函数进入) 、n、ni(单步执行,子函数跳过)</li><li>breakpoint 断点设置,详细看书,或者是教程</li><li>image list -o -f 模块基地址</li></ul></li></ul><p>&nbsp;</p><h4 id="4dumpdecrypted"><a name="header-n315" class="md-header-anchor "></a>4.dumpdecrypted</h4><ul><li>作用:AppStrore榔头,在AppStore下载的app不能直接dump,要配合dumpdecrypted才可以导出头文件信息</li><li>使用安装:<a href="https://www.jianshu.com/p/039dfd040253" target="_blank" class="url">https://www.jianshu.com/p/039dfd040253</a></li><li>主要命令行:DYLD_INSERT_LIBRARIES=/path/to/dumpdecrypted.dylib /path/to/executable</li></ul><h4 id="5openssh"><a name="header-n326" class="md-header-anchor "></a>5.OpenSSH</h4><ul><li>作用:iOS设备安装ssh服务,cydia可直接下载</li><li>命令行:ssh  scp等</li></ul><h4 id="6usbmuxd"><a name="header-n334" class="md-header-anchor "></a>6.usbmuxd</h4><ul><li>作用:usb的ssh服务</li></ul><h4 id="7iflie-filza"><a name="header-n339" class="md-header-anchor "></a>7.iflie、Filza</h4><ul><li>作用:iOS文件管理工具</li></ul><h4 id="8mterminal"><a name="header-n344" class="md-header-anchor "></a>8.MTerminal</h4><ul><li>作用:ios 终端 输入</li></ul><h4 id="9syslogd"><a name="header-n349" class="md-header-anchor "></a>9.syslogd</h4><ul><li>作用:系统日记</li></ul><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><h3 id="优秀资源文章"><a name="header-n360" class="md-header-anchor "></a>优秀资源文章</h3><ul><li><a href="https://niyaoyao.github.io/2017/05/09/Learning-Reverse-From-Today-D4" target="_blank" class="url">https://niyaoyao.github.io/2017/05/09/Learning-Reverse-From-Today-D4</a>/</li></ul></div>
</body>
</html>]]></content>
    
    <summary type="html">
    
      &lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width initial-scale=1&quot;&gt;
&lt;title&gt;iOS逆向工程总结&lt;/ti
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title></title>
    <link href="https://blaceman.github.io/2017/06/12/%E4%BD%A0%E7%9A%84%E5%9F%8E%E5%B8%82/"/>
    <id>https://blaceman.github.io/2017/06/12/你的城市/</id>
    <published>2017-06-12T02:28:02.000Z</published>
    <updated>2017-06-12T02:28:02.000Z</updated>
    
    <content type="html"><![CDATA[<!doctype html>
<html>
<head>
<meta charset="UTF-8"><meta name="viewport" content="width=device-width initial-scale=1">
<title>你的城市.md</title><link href="https://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700,700italic&subset=latin,cyrillic-ext,cyrillic,latin-ext" rel="stylesheet" type="text/css"><style type="text/css">html, body {overflow-x: initial !important;}html { font-size: 14px; background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); }
body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1rem; line-height: 1.42857143; overflow-x: hidden; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit inherit; background-repeat: inherit inherit; }
a:active, a:hover { outline: 0px; }
.in-text-selection, ::selection { background-color: rgb(181, 214, 252); text-shadow: none; background-position: initial initial; background-repeat: initial initial; }
#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; word-wrap: break-word; position: relative; padding-bottom: 70px; white-space: pre-wrap; overflow-x: auto; }
.for-image #write { padding-left: 8px; padding-right: 8px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
@media screen and (max-width: 500px) { 
  body.typora-export { padding-left: 0px; padding-right: 0px; }
  .CodeMirror-sizer { margin-left: 0px !important; }
  .CodeMirror-gutters { display: none !important; }
}
.typora-export #write { margin: 0px auto; }
#write > p:first-child, #write > ul:first-child, #write > ol:first-child, #write > pre:first-child, #write > blockquote:first-child, #write > div:first-child, #write > table:first-child { margin-top: 30px; }
#write li > table:first-child { margin-top: -20px; }
img { max-width: 100%; vertical-align: middle; }
input, button, select, textarea { color: inherit; font-family: inherit; font-size: inherit; font-style: inherit; font-variant-caps: inherit; font-weight: inherit; line-height: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
::before, ::after, * { box-sizing: border-box; }
#write p, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write div, #write pre { width: inherit; }
#write p, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6 { position: relative; }
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
p { -webkit-margin-before: 1rem; -webkit-margin-after: 1rem; -webkit-margin-start: 0px; -webkit-margin-end: 0px; }
.mathjax-block { margin-top: 0px; margin-bottom: 0px; -webkit-margin-before: 0rem; -webkit-margin-after: 0rem; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: bold; font-style: italic; }
a { cursor: pointer; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; margin: 4px 0px 0px; }
tr { page-break-inside: avoid; page-break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; page-break-inside: auto; text-align: left; }
table.md-table td { min-width: 80px; }
.CodeMirror-gutters { border-right-width: 0px; background-color: inherit; }
.CodeMirror { text-align: left; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
pre { white-space: pre-wrap; }
.CodeMirror-gutters { margin-right: 4px; }
.md-fences { font-size: 0.9rem; display: block; page-break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; background-position: inherit inherit; background-repeat: inherit inherit; }
.md-diagram-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }
.md-fences .CodeMirror.CodeMirror-wrap { top: -1.6em; margin-bottom: -1.6em; }
.md-fences.mock-cm { white-space: pre-wrap; }
.show-fences-line-number .md-fences { padding-left: 0px; }
.show-fences-line-number .md-fences.mock-cm { padding-left: 40px; }
.footnotes { opacity: 0.8; font-size: 0.9rem; padding-top: 1em; padding-bottom: 1em; }
.footnotes + .footnotes { margin-top: -1em; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; background-color: transparent; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; line-height: normal; font-weight: normal; text-align: left; box-sizing: content-box; direction: ltr; background-position: initial initial; background-repeat: initial initial; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li p, li .mathjax-block { margin: 0.5rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; }
@media print { 
  html, body { height: 100%; }
  .typora-export * { -webkit-print-color-adjust: exact; }
  h1, h2, h3, h4, h5, h6 { page-break-after: avoid; orphans: 2; }
  p { orphans: 4; }
  html.blink-to-pdf { font-size: 13px; }
  .typora-export #write { padding-left: 1cm; padding-right: 1cm; }
  .typora-export #write::after { height: 0px; }
  @page { margin: 20mm 0mm; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
pre.md-meta-block { font-size: 0.8rem; min-height: 2.86rem; white-space: pre-wrap; background-color: rgb(204, 204, 204); display: block; overflow-x: hidden; background-position: initial initial; background-repeat: initial initial; }
p .md-image:only-child { display: inline-block; width: 100%; text-align: center; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.mathjax-block { white-space: pre; overflow: hidden; width: 100%; }
p + .mathjax-block { margin-top: -1.143rem; }
.mathjax-block:not(:empty)::after { display: none; }
[contenteditable="true"]:active, [contenteditable="true"]:focus { outline: none; box-shadow: none; }
.task-list { list-style-type: none; }
.task-list-item { position: relative; padding-left: 1em; }
.task-list-item input { position: absolute; top: 0px; left: 0px; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc::after, .md-toc-content::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); text-decoration: none; }
.md-toc-inner:hover { }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: bold; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
@media screen and (max-width: 48em) { 
  .md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
  .md-toc-h4 .md-toc-inner { margin-left: 5em; }
  .md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
  .md-toc-h6 .md-toc-inner { margin-left: 8em; }
}
a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.md-attr { display: none; }
.md-fn-count::after { content: '.'; }
.md-tag { opacity: 0.5; }
.md-comment { color: rgb(162, 127, 3); opacity: 0.8; font-family: monospace; }
code { text-align: left; }
h1 .md-tag, h2 .md-tag, h3 .md-tag, h4 .md-tag, h5 .md-tag, h6 .md-tag { font-weight: initial; opacity: 0.35; }
a.md-print-anchor { border: none !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: none !important; background-color: transparent !important; text-shadow: initial !important; background-position: initial initial !important; background-repeat: initial initial !important; }
.md-inline-math .MathJax_SVG .noError { display: none !important; }
.mathjax-block .MathJax_SVG_Display { text-align: center; margin: 1em 0em; position: relative; text-indent: 0px; max-width: none; max-height: none; min-height: 0px; min-width: 100%; width: auto; display: block !important; }
.MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display { width: auto; margin: inherit; display: inline-block !important; }
.MathJax_SVG .MJX-monospace { font-family: monospace; }
.MathJax_SVG .MJX-sans-serif { font-family: sans-serif; }
.MathJax_SVG { display: inline; font-style: normal; font-weight: normal; line-height: normal; zoom: 90%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; }
.MathJax_SVG * { -webkit-transition: none; transition: none; }


/* meyer reset -- http://meyerweb.com/eric/tools/css/reset/ , v2.0 | 20110126 | License: none (public domain) */

@include-when-export url(https://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700,700italic&subset=latin,cyrillic-ext,cyrillic,latin-ext);

/* =========== */

@font-face {
    font-family: 'PT Serif';
    font-style: normal;
    font-weight: normal;
    src: local('PT Serif'), local('PTSerif-Regular'), url(file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Regular.ttf);
}
@font-face {
    font-family: 'PT Serif';
    font-style: italic;
    font-weight: normal;
    src: local('PT Serif'), local('PTSerif-Italic'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Italic.ttf')
}

@font-face {
    font-family: 'PT Serif';
    font-style: normal;
    font-weight: bold;
    src: local('PT Serif'), local('PTSerif-Bold'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Bold.ttf')
}

@font-face {
    font-family: 'PT Serif';
    font-style: italic;
    font-weight: bold;
    src: local('PT Serif'), local('PTSerif-BoldItalic'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-BoldItalic.ttf')
}

html {
	font-size: 16px;
}

html, body {
	background-color: #f3f2ee;
	font-family: "PT Serif", 'Times New Roman', Times;
	color: #1f0909;
	line-height: 1.5em;
}

/*#write {
	overflow-x: auto;
    max-width: initial;
	padding-left: calc(50% - 17em);
    padding-right: calc(50% - 17em);
}

@media (max-width: 36em) {
 	#write {
 		padding-left: 1em;
    	padding-right: 1em;
 	}
}*/

#write {
	max-width: 40em;
}

ol,
ul {
	list-style: none;
}
blockquote,
q {
	quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
/* styles */

/* ====== */

/* headings */

h1,
h2,
h3,
h4,
h5,
h6 {
	font-weight: bold;
}
h1 {
	font-size: 1.875em;
	/*30 / 16*/
	line-height: 1.6em;
	/* 48 / 30*/
	margin-top: 2em;
}
h2,
h3 {
	font-size: 1.3125em;
	/*21 / 16*/
	line-height: 1.15;
	/*24 / 21*/
	margin-top: 2.285714em;
	/*48 / 21*/
	margin-bottom: 1.15em;
	/*24 / 21*/
}
h3 {
	font-weight: normal;
}
h4 {
	font-size: 1.125em;
	/*18 / 16*/
	margin-top: 2.67em;
	/*48 / 18*/
}
h5,
h6 {
	font-size: 1em;
	/*16*/
}
h1 {
	border-bottom: 1px solid;
	margin-bottom: 1.875em;
	padding-bottom: 0.8125em;
}
/* links */

a {
	text-decoration: none;
	color: #065588;
}
a:hover,
a:active {
	text-decoration: underline;
}
/* block spacing */

p,
blockquote,
.md-fences {
	margin-bottom: 1.5em;
}
h1,
h2,
h3,
h4,
h5,
h6 {
	margin-bottom: 1.5em;
}
/* blockquote */

blockquote {
	font-style: italic;
	border-left: 5px solid;
	margin-left: 2em;
	padding-left: 1em;
}
/* lists */

ul,
ol {
	margin: 0 0 1.5em 1.5em;
}
ol li {
	list-style-type: decimal;
	list-style-position: outside;
}
ul li {
	list-style-type: disc;
	list-style-position: outside;
}
/* tables */
.md-meta,.md-before, .md-after {
	color:#999;
}

table {
	margin-bottom: 1.5em;
	/*24 / 16*/
	font-size: 1em;
	/* width: 100%; */
}
thead th,
tfoot th {
	padding: .25em .25em .25em .4em;
	text-transform: uppercase;
}
th {
	text-align: left;
}
td {
	vertical-align: top;
	padding: .25em .25em .25em .4em;
}

code,
.md-fences {
	background-color: #dadada;
	padding-left: 1ch;
	padding-right: 1ch;
}
.md-fences {
	margin-left: 2em;
	margin-bottom: 3em;
}

.md-fences .CodeMirror.CodeMirror-wrap {
	top: -0.8em;
}

pre,
code,
tt {
	font-size: .875em;
	line-height: 1.714285em;
}
/* some fixes */

h1 {
	line-height: 1.3em;
	font-weight: normal;
	margin-bottom: 0.5em;
}

p + ul,
p + ol{
	margin-top: -1em;
}

h3 + ul,
h4 + ul,
h5 + ul,
h6 + ul,
h3 + ol,
h4 + ol,
h5 + ol,
h6 + ol {
	margin-top: .5em;
}

li > ul,
li > ol {
	margin-top: inherit;
}

h2,
h3 {
	margin-bottom: .75em;
}
hr {
	border-top: none;
	border-right: none;
	border-bottom: 1px solid;
	border-left: none;
}
h1 {
	border-color: #c5c5c5;
}
blockquote {
	border-color: #bababa;
	color: #656565;
}
thead.md-table-edit {
	background-color: transparent;
}
thead {
	background-color: #dadada;
}
tr:nth-child(even) {
	background: #e8e7e7;
}
hr {
	border-color: #c5c5c5;
}
.task-list{
	padding-left: 1rem;
}

.task-list-item {
	padding-left: 1.5rem;
	list-style-type: none;
}

.task-list-item input:before {
	content: '\221A';
	display: inline-block;
	width: 1.25rem;
  	height: 1.6rem;
	vertical-align: middle;
	text-align: center;
	color: #ddd;
	background-color: #F3F2EE;
}

.task-list-item input:checked:before,
.task-list-item input[checked]:before{
	color: inherit;
}

#write pre.md-meta-block {
	min-height: 1.875rem;
	color: #555;
	border: 0px;
	background: transparent;
	margin-top: -4px;
	margin-left: 1em;
	margin-top: 1em;
}

.md-image>.md-meta {
	color: #9B5146;
}

.md-image>.md-meta{
	font-family: Menlo, 'Ubuntu Mono', Consolas, 'Courier New', 'Microsoft Yahei', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', sans-serif;
}


#write>h3.md-focus:before{
	left: -1.5rem;
	color:#999;
	border-color:#999;
}
#write>h4.md-focus:before{
	left: -1.5rem;
	top: .25rem;
	color:#999;
	border-color:#999;
}
#write>h5.md-focus:before{
	left: -1.5rem;
	top: .0.3125rem;
	color:#999;
	border-color:#999;
}
#write>h6.md-focus:before{
	left: -1.5rem;
	top: 0.3125rem;
	color:#999;
	border-color:#999;
}

.md-toc:focus .md-toc-content{
	margin-top: 19px;
}

.md-toc-content:empty:before{
	color: #065588;
}
.md-toc-item {
	color: #065588;
}
#write div.md-toc-tooltip {
	background-color: #f3f2ee;
}

#outline-dropmenu {
	background-color: #f3f2ee;
	-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.375);
  	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.375);
}

.pin-outline #outline-dropmenu {
	background: inherit;
	box-shadow: none;
	border-right: 1px dashed;
}

.pin-outline #outline-dropmenu:hover .outline-title-wrapper {
	border-left:1px dashed;
}

.outline-item:hover {
  background-color: #dadada;
  border-left: 28px solid #dadada;
  border-right: 18px solid #dadada;
}

.typora-node .outline-item:hover {
  	border-right: 28px solid #dadada;
}

.outline-expander:before {
  content: "\f0da";
  font-family: FontAwesome;
  font-size:14px;
  top: 1px;
}

.outline-expander:hover:before,
.outline-item-open>.outline-item>.outline-expander:before {
  content: "\f0d7";
}

.modal-content {
	background-color: #f3f2ee;
}

.auto-suggest-container ul li {
	list-style-type: none;
}

/** UI for electron */

.megamenu-menu,
#top-titlebar, #top-titlebar *,
.megamenu-content {
	background: #f3f2ee;
	color: #1f0909;
}

.megamenu-menu-header {
	border-bottom: 1px dashed #202B33;
}

.megamenu-menu {
	box-shadow: none;
	border-right: 1px dashed;
}

header, .context-menu, .megamenu-content, footer {
	font-family: "PT Serif", 'Times New Roman', Times;
    color: #1f0909;
}

#megamenu-back-btn {
	color: #1f0909;
	border-color: #1f0909;
}

.megamenu-menu-header #megamenu-menu-header-title:before {
	color: #1f0909;
}

.megamenu-menu-list li a:hover, .megamenu-menu-list li a.active {
	color: inherit;
	background-color: #e8e7df;
}

.long-btn:hover {
	background-color: #e8e7df;
}

#recent-file-panel tbody tr:nth-child(2n-1) {
    background-color: transparent !important;
}

.megamenu-menu-panel tbody tr:hover td:nth-child(2) {
    color: inherit;
}

.megamenu-menu-panel .btn {
	background-color: #D2D1D1;
}

.btn-default {
	background-color: transparent;
}

.typora-sourceview-on #toggle-sourceview-btn,
.show-word-count #footer-word-count {
	background: #c7c5c5;
}

#typora-quick-open {
    background-color: inherit;
}

.md-diagram-panel {
	margin-left: -1ch;
	margin-top: 24px;
}



</style>
</head>
<body class="typora-export">
<div id="write" class="is-mac"><h3 id="你的城市"><a name="header-c7" class="md-header-anchor "></a>你的城市</h3><p><iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="330" height="86" src="https://music.163.com/outchain/player?type=2&id=4873341&auto=1&height=66"></iframe></p><p>你的城市那么大,有没有一处地方能容下我?</p><p></p><p><img src="https://ws4.sinaimg.cn/large/006tKfTcgy1fgi65mu7eoj30et0m8ab4.jpg" alt="img-38376e151ae658b60ffe366236859d0e"></p><p>朋友对我两说:&quot;他都成事了,叫我两抓紧点,拖糖有必要发一下&quot;!我竟语塞了一会,不知该如何回答。</p><p>很多事情,看起来自己是挺闹她心的。但回想起来才发现这是必然的结果。</p><p>我说我会离开这里,去另外的城市生活。她说&quot;走吧,你会遇到更好的女生&quot;。有时候我在想,如果我温柔以待,结果是不是会不同。后悔每一次对她嚷嚷!粗心如我,不懂女生心思。</p><p><img src="https://ws1.sinaimg.cn/large/006tKfTcgy1fgi65nxti7j30dt0i8t9k.jpg" alt="img_1055"></p><p>记得那是跨年的日子,也就是2016初的那几天,我从高中好友那里带来了两条手链。那晚,我去接她,说:&quot;这是你的跨年礼物,一年不变你还是老样子&quot;。她笑了笑说,&quot;你也是&quot;。我没说太多的煽情的话。她戴上手链,并要求我戴上。我曾许诺,今年会变得更好的,但生活却一塌糊涂!我知道她那会一直戴着这手链,而我却把它放在我的床头那。偶尔拿出来看看。</p><p>愿生活如此,何必年华在变迁!岁月的躁动,生活的不安,让情感变得脆弱敏感!甚至可以说是一击而溃。初春的天,看起来并不是那么的容易。甚至有点不太想回忆!究竟而说,脆弱敏感的灵魂,所谓的到处碰壁,也只不过是没过心里的那墙,而自卑不亢!人为人,之所以为强人,也不过是内心束缚较为自由,对事情的有所把握与自信。而我却恰好与之相反,不断的寻求外界的认可。</p><p>然而有趣的灵魂,并不不会总是堕落!慢慢的我知道,为坚持与自律才是内心自信的保障。在学车的那段时间,也是我内心较为平静的日子。想了许多,包括感情。逗b如我,再次上线!</p><p><img src="https://ws1.sinaimg.cn/large/006tKfTcgy1fgi65m9q1aj308c04oq37.jpg" alt="images"></p><p>还记得吗?你我曾约好,记得时,给对方道一句晚安。但5月份以来,就硬是没说上几句话。感情平淡期?恩?我不知道。但你现在过得好就好!偶尔我也会吐槽和羡慕一下你的生活!也当做是生活的点滴吧。至于岁月,我已毫无概念。</p><p>猛然回头,一年的时光也匆匆!偶尔也想起初次见面,也是好笑!没想到,我们的关系变得如此的好。不是一次普通的旅行吗?恩,确实是一次普通的旅行,普通的人,普通的事。唯一不普通的就是,是旅程中有你我!(煽情了,该熄火了!)但也仅仅是我不普通罢了!</p><p>何事悲秋,伤感了岁月?我猜所有人都是那一瞬,那一瞬死灰的心。不管是李煜的&quot;雕阑玉砌应犹在，只是朱颜改!&quot;还是杜牧的&quot;商女不知亡国恨，隔江犹唱后庭花!&quot;等前朝往事就是很好的论证了。能做的就是把热度降低,以免过于失落。</p><p>最后,至于前路如何?我并不关心。我关心的是如何变得更强。人生的无奈,莫过于在你无能为力的时候,不得不辜负别人对你期待,对你的爱!不敢赤裸相见,辗转反侧,告诉自己这样就好。人生如此,唯静心与努力不可辜负!你知道吗?我成长了!知道只有自己内心足够强大,不管是未来如此,一路向前,放下往事,或是不舍,只因为我不想再失去美好的东西!</p></div>
</body>
</html>]]></content>
    
    <summary type="html">
    
      &lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width initial-scale=1&quot;&gt;
&lt;title&gt;你的城市.md&lt;/titl
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title></title>
    <link href="https://blaceman.github.io/2017/05/30/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E5%85%A5%E9%97%A8/"/>
    <id>https://blaceman.github.io/2017/05/30/机器学习入门/</id>
    <published>2017-05-30T14:23:28.000Z</published>
    <updated>2017-05-30T14:23:28.000Z</updated>
    
    <content type="html"><![CDATA[<!doctype html>
<html>
<head>
<meta charset="UTF-8"><meta name="viewport" content="width=device-width initial-scale=1">
<title>机器学习入门</title><link href="https://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700,700italic&subset=latin,cyrillic-ext,cyrillic,latin-ext" rel="stylesheet" type="text/css"><style type="text/css">html, body {overflow-x: initial !important;}.mermaid .label { color: rgb(51, 51, 51); }
.node rect, .node circle, .node ellipse, .node polygon { fill: #ececff; stroke: #ccccff; stroke-width: 1px; }
.edgePath .path { stroke: #333333; }
.edgeLabel { background-color: rgb(232, 232, 232); }
.cluster rect { fill: #ffffde !important; stroke: #aaaa33 !important; stroke-width: 1px !important; }
.cluster text { fill: #333333; }
.actor { stroke: #ccccff; fill: #ececff; }
text.actor { fill: #000000; stroke: none; }
.actor-line { stroke: #808080; }
.messageLine0 { stroke-width: 1.5px; stroke: #333333; }
.messageLine1 { stroke-width: 1.5px; stroke: #333333; }
#arrowhead { fill: #333333; }
#crosshead path { fill: #333333 !important; stroke: #333333 !important; }
.messageText { fill: #333333; stroke: none; }
.labelBox { stroke: #ccccff; fill: #ececff; }
.labelText { fill: #000000; stroke: none; }
.loopText { fill: #000000; stroke: none; }
.loopLine { stroke-width: 2px; stroke: #ccccff; }
.note { stroke: #aaaa33; fill: #fff5ad; }
.noteText { fill: #000000; stroke: none; font-family: 'trebuchet ms', verdana, arial; font-size: 14px; }
.section { stroke: none; opacity: 0.2; }
.section0 { fill: rgba(102, 102, 255, 0.49019607843137253); }
.section2 { fill: #fff400; }
.section1, .section3 { fill: #ffffff; opacity: 0.2; }
.sectionTitle0 { fill: #333333; }
.sectionTitle1 { fill: #333333; }
.sectionTitle2 { fill: #333333; }
.sectionTitle3 { fill: #333333; }
.sectionTitle { text-anchor: start; font-size: 11px; }
.grid .tick { stroke: #d3d3d3; opacity: 0.3; shape-rendering: crispedges; }
.grid path { stroke-width: 0px; }
.today { fill: none; stroke: #ff0000; stroke-width: 2px; }
.task { stroke-width: 2px; }
.taskText { text-anchor: middle; font-size: 11px; }
.taskTextOutsideRight { fill: #000000; text-anchor: start; font-size: 11px; }
.taskTextOutsideLeft { fill: #000000; text-anchor: end; font-size: 11px; }
.taskText0, .taskText1, .taskText2, .taskText3 { fill: #ffffff; }
.task0, .task1, .task2, .task3 { fill: #8a90dd; stroke: #534fbc; }
.taskTextOutside0, .taskTextOutside2 { fill: #000000; }
.taskTextOutside1, .taskTextOutside3 { fill: #000000; }
.active0, .active1, .active2, .active3 { fill: #bfc7ff; stroke: #534fbc; }
.activeText0, .activeText1, .activeText2, .activeText3 { fill: #000000 !important; }
.done0, .done1, .done2, .done3 { stroke: #808080; fill: #d3d3d3; stroke-width: 2px; }
.doneText0, .doneText1, .doneText2, .doneText3 { fill: #000000 !important; }
.crit0, .crit1, .crit2, .crit3 { stroke: #ff8888; fill: #ff0000; stroke-width: 2px; }
.activeCrit0, .activeCrit1, .activeCrit2, .activeCrit3 { stroke: #ff8888; fill: #bfc7ff; stroke-width: 2px; }
.doneCrit0, .doneCrit1, .doneCrit2, .doneCrit3 { stroke: #ff8888; fill: #d3d3d3; stroke-width: 2px; cursor: pointer; shape-rendering: crispedges; }
.doneCritText0, .doneCritText1, .doneCritText2, .doneCritText3 { fill: #000000 !important; }
.activeCritText0, .activeCritText1, .activeCritText2, .activeCritText3 { fill: #000000 !important; }
.titleText { text-anchor: middle; font-size: 18px; fill: #000000; }
.node text { font-family: 'trebuchet ms', verdana, arial; font-size: 14px; }
div.mermaidTooltip { position: absolute; text-align: center; max-width: 200px; padding: 2px; font-family: 'trebuchet ms', verdana, arial; font-size: 12px; background-color: rgb(255, 255, 222); border: 1px solid rgb(170, 170, 51); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; pointer-events: none; z-index: 100; background-position: initial initial; background-repeat: initial initial; }
#write .md-diagram-panel .md-diagram-panel-preview div { }


.CodeMirror { height: auto; }
.CodeMirror-scroll { overflow-y: hidden; overflow-x: auto; }
.CodeMirror-lines { padding: 4px 0px; }
.CodeMirror pre { }
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { background-color: white; }
.CodeMirror-gutters { border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); background-color: rgb(247, 247, 247); white-space: nowrap; }
.CodeMirror-linenumbers { }
.CodeMirror-linenumber { padding: 0px 3px 0px 5px; text-align: right; color: rgb(153, 153, 153); }
.CodeMirror div.CodeMirror-cursor { border-left-width: 1px; border-left-style: solid; border-left-color: black; z-index: 3; }
.CodeMirror div.CodeMirror-secondarycursor { border-left-width: 1px; border-left-style: solid; border-left-color: silver; }
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor { width: auto; border: 0px; background-color: rgb(119, 238, 119); z-index: 1; background-position: initial initial; background-repeat: initial initial; }
.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite { }
.cm-tab { display: inline-block; }
.cm-s-typora-default .cm-header, .cm-s-typora-default .cm-property { color: rgb(217, 79, 138); }
.cm-s-typora-default pre.cm-header1:not(.cm-atom) :not(.cm-overlay) { font-size: 2rem; line-height: 2rem; }
.cm-s-typora-default pre.cm-header2:not(.cm-atom) :not(.cm-overlay) { font-size: 1.4rem; line-height: 1.4rem; }
.cm-s-typora-default .cm-atom, .cm-s-typora-default .cm-number { color: rgb(149, 132, 134); }
.cm-s-typora-default .cm-table-row, .cm-s-typora-default .cm-block-start { font-family: monospace; }
.cm-s-typora-default .cm-comment, .cm-s-typora-default .cm-code { color: rgb(74, 90, 159); font-family: monospace; }
.cm-s-typora-default .cm-tag { color: rgb(169, 68, 66); }
.cm-s-typora-default .cm-string { color: rgb(126, 134, 169); }
.cm-s-typora-default .cm-link { color: rgb(196, 122, 15); text-decoration: underline; }
.cm-s-typora-default .cm-variable-2, .cm-s-typora-default .cm-variable-1 { color: inherit; }
.cm-s-typora-default .cm-overlay { font-size: 1rem; font-family: monospace; }
.CodeMirror.cm-s-typora-default div.CodeMirror-cursor { border-left-width: 3px; border-left-style: solid; border-left-color: rgb(228, 98, 154); }
.cm-s-typora-default .CodeMirror-activeline-background { left: -60px; right: -30px; background-color: rgba(204, 204, 204, 0.2); background-position: initial initial; background-repeat: initial initial; }
.cm-s-typora-default .CodeMirror-gutters { border-right-style: none; background-color: inherit; }
.cm-s-typora-default .cm-trailing-space-new-line::after, .cm-startspace::after, .cm-starttab .cm-tab::after { content: '•'; position: absolute; left: 0px; opacity: 0; font-family: LetterGothicStd, monospace; }
.os-windows .cm-startspace::after, .os-windows .cm-starttab .cm-tab::after { left: -0.1em; }
.cm-starttab .cm-tab::after { content: ' '; }
.cm-startspace, .cm-tab, .cm-starttab, .cm-trailing-space-a, .cm-trailing-space-b, .cm-trailing-space-new-line { font-family: monospace; position: relative; }
.cm-s-typora-default .cm-trailing-space-new-line::after { content: '↓'; opacity: 0.3; }
.cm-s-inner .cm-keyword { color: rgb(119, 0, 136); }
.cm-s-inner .cm-atom, .cm-s-inner.cm-atom { color: rgb(34, 17, 153); }
.cm-s-inner .cm-number { color: rgb(17, 102, 68); }
.cm-s-inner .cm-def { color: rgb(0, 0, 255); }
.cm-s-inner .cm-variable { color: black; }
.cm-s-inner .cm-variable-2 { color: rgb(0, 85, 170); }
.cm-s-inner .cm-variable-3 { color: rgb(0, 136, 85); }
.cm-s-inner .cm-property { color: black; }
.cm-s-inner .cm-operator { color: rgb(152, 26, 26); }
.cm-s-inner .cm-comment, .cm-s-inner.cm-comment { color: rgb(170, 85, 0); }
.cm-s-inner .cm-string { color: rgb(170, 17, 17); }
.cm-s-inner .cm-string-2 { color: rgb(255, 85, 0); }
.cm-s-inner .cm-meta { color: rgb(85, 85, 85); }
.cm-s-inner .cm-qualifier { color: rgb(85, 85, 85); }
.cm-s-inner .cm-builtin { color: rgb(51, 0, 170); }
.cm-s-inner .cm-bracket { color: rgb(153, 153, 119); }
.cm-s-inner .cm-tag { color: rgb(17, 119, 0); }
.cm-s-inner .cm-attribute { color: rgb(0, 0, 204); }
.cm-s-inner .cm-header, .cm-s-inner.cm-header { color: blue; }
.cm-s-inner .cm-quote, .cm-s-inner.cm-quote { color: rgb(0, 153, 0); }
.cm-s-inner .cm-hr, .cm-s-inner.cm-hr { color: rgb(153, 153, 153); }
.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(0, 0, 204); }
.cm-negative { color: rgb(221, 68, 68); }
.cm-positive { color: rgb(34, 153, 34); }
.cm-header, .cm-strong { font-weight: bold; }
.cm-del { text-decoration: line-through; }
.cm-em { font-style: italic; }
.cm-link { text-decoration: underline; }
.cm-error { color: rgb(255, 0, 0); }
.cm-invalidchar { color: rgb(255, 0, 0); }
.cm-constant { color: rgb(38, 139, 210); }
.cm-defined { color: rgb(181, 137, 0); }
div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); }
.cm-s-inner .CodeMirror-activeline-background { background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit inherit; background-repeat: inherit inherit; }
.CodeMirror { position: relative; overflow: hidden; }
.CodeMirror-scroll { margin-bottom: -30px; margin-right: -30px; padding-bottom: 30px; padding-right: 30px; height: 100%; outline: none; position: relative; box-sizing: content-box; }
.CodeMirror-sizer { position: relative; }
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { position: absolute; z-index: 6; display: none; }
.CodeMirror-vscrollbar { right: 0px; top: 0px; overflow-x: hidden; overflow-y: scroll; }
.CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow-y: hidden; overflow-x: scroll; }
.CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; }
.CodeMirror-gutter-filler { left: 0px; bottom: 0px; }
.CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 30px; z-index: 3; }
.CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; }
.CodeMirror-lines { cursor: text; }
.CodeMirror pre { border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-width: 0px; background-color: transparent; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; word-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; background-position: initial initial; background-repeat: initial initial; }
.CodeMirror-wrap pre { word-wrap: break-word; white-space: pre-wrap; word-break: normal; }
.CodeMirror-code pre { border-right-width: 30px; border-right-style: solid; border-right-color: transparent; width: -webkit-fit-content; }
.CodeMirror-wrap .CodeMirror-code pre { border-right-style: none; width: auto; }
.CodeMirror-linebackground { position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 0; }
.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; }
.CodeMirror-widget { }
.CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; }
.CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; }
.CodeMirror-measure pre { position: static; }
.CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right-style: none; width: 0px; }
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
.CodeMirror-focused div.CodeMirror-cursor { visibility: inherit; }
.CodeMirror-selected { background-color: rgb(217, 217, 217); background-position: initial initial; background-repeat: initial initial; }
.CodeMirror-focused .CodeMirror-selected { background-color: rgb(215, 212, 240); background-position: initial initial; background-repeat: initial initial; }
.cm-searching { background-color: rgba(255, 255, 0, 0.4); background-position: initial initial; background-repeat: initial initial; }
.CodeMirror span { }
@media print { 
  .CodeMirror div.CodeMirror-cursor { visibility: hidden; }
}
.CodeMirror-lint-markers { width: 16px; }
.CodeMirror-lint-tooltip { background-color: infobackground; border: 1px solid black; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; color: infotext; font-family: monospace; overflow: hidden; padding: 2px 5px; position: fixed; white-space: pre-wrap; z-index: 10000; max-width: 600px; opacity: 0; -webkit-transition: opacity 0.4s; transition: opacity 0.4s; font-size: 0.8em; }
.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning { background-position: 0% 100%; background-repeat: repeat no-repeat; }
.CodeMirror-lint-mark-error { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==); }
.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning { cursor: pointer; display: inline-block; height: 16px; width: 16px; vertical-align: middle; position: relative; background-position: 50% 50%; background-repeat: no-repeat no-repeat; }
.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning { padding-left: 18px; background-position: 0% 0%; background-repeat: no-repeat no-repeat; }
.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=); }
.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=); }
.CodeMirror-lint-marker-multiple { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC); width: 100%; height: 100%; background-position: 100% 100%; background-repeat: no-repeat no-repeat; }


html { font-size: 14px; background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); }
body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1rem; line-height: 1.42857143; overflow-x: hidden; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit inherit; background-repeat: inherit inherit; }
a:active, a:hover { outline: 0px; }
.in-text-selection, ::selection { background-color: rgb(181, 214, 252); text-shadow: none; background-position: initial initial; background-repeat: initial initial; }
#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; word-wrap: break-word; position: relative; padding-bottom: 70px; white-space: pre-wrap; overflow-x: auto; }
.for-image #write { padding-left: 8px; padding-right: 8px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
@media screen and (max-width: 500px) { 
  body.typora-export { padding-left: 0px; padding-right: 0px; }
  .CodeMirror-sizer { margin-left: 0px !important; }
  .CodeMirror-gutters { display: none !important; }
}
.typora-export #write { margin: 0px auto; }
#write > p:first-child, #write > ul:first-child, #write > ol:first-child, #write > pre:first-child, #write > blockquote:first-child, #write > div:first-child, #write > table:first-child { margin-top: 30px; }
#write li > table:first-child { margin-top: -20px; }
img { max-width: 100%; vertical-align: middle; }
input, button, select, textarea { color: inherit; font-family: inherit; font-size: inherit; font-style: inherit; font-variant-caps: inherit; font-weight: inherit; line-height: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
::before, ::after, * { box-sizing: border-box; }
#write p, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write div, #write pre { width: inherit; }
#write p, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6 { position: relative; }
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
p { -webkit-margin-before: 1rem; -webkit-margin-after: 1rem; -webkit-margin-start: 0px; -webkit-margin-end: 0px; }
.mathjax-block { margin-top: 0px; margin-bottom: 0px; -webkit-margin-before: 0rem; -webkit-margin-after: 0rem; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: bold; font-style: italic; }
a { cursor: pointer; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; margin: 4px 0px 0px; }
tr { page-break-inside: avoid; page-break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; page-break-inside: auto; text-align: left; }
table.md-table td { min-width: 80px; }
.CodeMirror-gutters { border-right-width: 0px; background-color: inherit; }
.CodeMirror { text-align: left; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
pre { white-space: pre-wrap; }
.CodeMirror-gutters { margin-right: 4px; }
.md-fences { font-size: 0.9rem; display: block; page-break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; background-position: inherit inherit; background-repeat: inherit inherit; }
.md-diagram-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }
.md-fences .CodeMirror.CodeMirror-wrap { top: -1.6em; margin-bottom: -1.6em; }
.md-fences.mock-cm { white-space: pre-wrap; }
.show-fences-line-number .md-fences { padding-left: 0px; }
.show-fences-line-number .md-fences.mock-cm { padding-left: 40px; }
.footnotes { opacity: 0.8; font-size: 0.9rem; padding-top: 1em; padding-bottom: 1em; }
.footnotes + .footnotes { margin-top: -1em; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; background-color: transparent; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; line-height: normal; font-weight: normal; text-align: left; box-sizing: content-box; direction: ltr; background-position: initial initial; background-repeat: initial initial; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li p, li .mathjax-block { margin: 0.5rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; }
@media print { 
  html, body { height: 100%; }
  .typora-export * { -webkit-print-color-adjust: exact; }
  h1, h2, h3, h4, h5, h6 { page-break-after: avoid; orphans: 2; }
  p { orphans: 4; }
  html.blink-to-pdf { font-size: 13px; }
  .typora-export #write { padding-left: 1cm; padding-right: 1cm; }
  .typora-export #write::after { height: 0px; }
  @page { margin: 20mm 0mm; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
pre.md-meta-block { font-size: 0.8rem; min-height: 2.86rem; white-space: pre-wrap; background-color: rgb(204, 204, 204); display: block; overflow-x: hidden; background-position: initial initial; background-repeat: initial initial; }
p .md-image:only-child { display: inline-block; width: 100%; text-align: center; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.mathjax-block { white-space: pre; overflow: hidden; width: 100%; }
p + .mathjax-block { margin-top: -1.143rem; }
.mathjax-block:not(:empty)::after { display: none; }
[contenteditable="true"]:active, [contenteditable="true"]:focus { outline: none; box-shadow: none; }
.task-list { list-style-type: none; }
.task-list-item { position: relative; padding-left: 1em; }
.task-list-item input { position: absolute; top: 0px; left: 0px; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc::after, .md-toc-content::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); text-decoration: none; }
.md-toc-inner:hover { }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: bold; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
@media screen and (max-width: 48em) { 
  .md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
  .md-toc-h4 .md-toc-inner { margin-left: 5em; }
  .md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
  .md-toc-h6 .md-toc-inner { margin-left: 8em; }
}
a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.md-attr { display: none; }
.md-fn-count::after { content: '.'; }
.md-tag { opacity: 0.5; }
.md-comment { color: rgb(162, 127, 3); opacity: 0.8; font-family: monospace; }
code { text-align: left; }
h1 .md-tag, h2 .md-tag, h3 .md-tag, h4 .md-tag, h5 .md-tag, h6 .md-tag { font-weight: initial; opacity: 0.35; }
a.md-print-anchor { border: none !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: none !important; background-color: transparent !important; text-shadow: initial !important; background-position: initial initial !important; background-repeat: initial initial !important; }
.md-inline-math .MathJax_SVG .noError { display: none !important; }
.mathjax-block .MathJax_SVG_Display { text-align: center; margin: 1em 0em; position: relative; text-indent: 0px; max-width: none; max-height: none; min-height: 0px; min-width: 100%; width: auto; display: block !important; }
.MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display { width: auto; margin: inherit; display: inline-block !important; }
.MathJax_SVG .MJX-monospace { font-family: monospace; }
.MathJax_SVG .MJX-sans-serif { font-family: sans-serif; }
.MathJax_SVG { display: inline; font-style: normal; font-weight: normal; line-height: normal; zoom: 90%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; }
.MathJax_SVG * { -webkit-transition: none; transition: none; }


/* meyer reset -- http://meyerweb.com/eric/tools/css/reset/ , v2.0 | 20110126 | License: none (public domain) */

@include-when-export url(https://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700,700italic&subset=latin,cyrillic-ext,cyrillic,latin-ext);

/* =========== */

@font-face {
    font-family: 'PT Serif';
    font-style: normal;
    font-weight: normal;
    src: local('PT Serif'), local('PTSerif-Regular'), url(file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Regular.ttf);
}
@font-face {
    font-family: 'PT Serif';
    font-style: italic;
    font-weight: normal;
    src: local('PT Serif'), local('PTSerif-Italic'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Italic.ttf')
}

@font-face {
    font-family: 'PT Serif';
    font-style: normal;
    font-weight: bold;
    src: local('PT Serif'), local('PTSerif-Bold'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Bold.ttf')
}

@font-face {
    font-family: 'PT Serif';
    font-style: italic;
    font-weight: bold;
    src: local('PT Serif'), local('PTSerif-BoldItalic'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-BoldItalic.ttf')
}

html {
	font-size: 16px;
}

html, body {
	background-color: #f3f2ee;
	font-family: "PT Serif", 'Times New Roman', Times;
	color: #1f0909;
	line-height: 1.5em;
}

/*#write {
	overflow-x: auto;
    max-width: initial;
	padding-left: calc(50% - 17em);
    padding-right: calc(50% - 17em);
}

@media (max-width: 36em) {
 	#write {
 		padding-left: 1em;
    	padding-right: 1em;
 	}
}*/

#write {
	max-width: 40em;
}

ol,
ul {
	list-style: none;
}
blockquote,
q {
	quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
/* styles */

/* ====== */

/* headings */

h1,
h2,
h3,
h4,
h5,
h6 {
	font-weight: bold;
}
h1 {
	font-size: 1.875em;
	/*30 / 16*/
	line-height: 1.6em;
	/* 48 / 30*/
	margin-top: 2em;
}
h2,
h3 {
	font-size: 1.3125em;
	/*21 / 16*/
	line-height: 1.15;
	/*24 / 21*/
	margin-top: 2.285714em;
	/*48 / 21*/
	margin-bottom: 1.15em;
	/*24 / 21*/
}
h3 {
	font-weight: normal;
}
h4 {
	font-size: 1.125em;
	/*18 / 16*/
	margin-top: 2.67em;
	/*48 / 18*/
}
h5,
h6 {
	font-size: 1em;
	/*16*/
}
h1 {
	border-bottom: 1px solid;
	margin-bottom: 1.875em;
	padding-bottom: 0.8125em;
}
/* links */

a {
	text-decoration: none;
	color: #065588;
}
a:hover,
a:active {
	text-decoration: underline;
}
/* block spacing */

p,
blockquote,
.md-fences {
	margin-bottom: 1.5em;
}
h1,
h2,
h3,
h4,
h5,
h6 {
	margin-bottom: 1.5em;
}
/* blockquote */

blockquote {
	font-style: italic;
	border-left: 5px solid;
	margin-left: 2em;
	padding-left: 1em;
}
/* lists */

ul,
ol {
	margin: 0 0 1.5em 1.5em;
}
ol li {
	list-style-type: decimal;
	list-style-position: outside;
}
ul li {
	list-style-type: disc;
	list-style-position: outside;
}
/* tables */
.md-meta,.md-before, .md-after {
	color:#999;
}

table {
	margin-bottom: 1.5em;
	/*24 / 16*/
	font-size: 1em;
	/* width: 100%; */
}
thead th,
tfoot th {
	padding: .25em .25em .25em .4em;
	text-transform: uppercase;
}
th {
	text-align: left;
}
td {
	vertical-align: top;
	padding: .25em .25em .25em .4em;
}

code,
.md-fences {
	background-color: #dadada;
	padding-left: 1ch;
	padding-right: 1ch;
}
.md-fences {
	margin-left: 2em;
	margin-bottom: 3em;
}

.md-fences .CodeMirror.CodeMirror-wrap {
	top: -0.8em;
}

pre,
code,
tt {
	font-size: .875em;
	line-height: 1.714285em;
}
/* some fixes */

h1 {
	line-height: 1.3em;
	font-weight: normal;
	margin-bottom: 0.5em;
}

p + ul,
p + ol{
	margin-top: -1em;
}

h3 + ul,
h4 + ul,
h5 + ul,
h6 + ul,
h3 + ol,
h4 + ol,
h5 + ol,
h6 + ol {
	margin-top: .5em;
}

li > ul,
li > ol {
	margin-top: inherit;
}

h2,
h3 {
	margin-bottom: .75em;
}
hr {
	border-top: none;
	border-right: none;
	border-bottom: 1px solid;
	border-left: none;
}
h1 {
	border-color: #c5c5c5;
}
blockquote {
	border-color: #bababa;
	color: #656565;
}
thead.md-table-edit {
	background-color: transparent;
}
thead {
	background-color: #dadada;
}
tr:nth-child(even) {
	background: #e8e7e7;
}
hr {
	border-color: #c5c5c5;
}
.task-list{
	padding-left: 1rem;
}

.task-list-item {
	padding-left: 1.5rem;
	list-style-type: none;
}

.task-list-item input:before {
	content: '\221A';
	display: inline-block;
	width: 1.25rem;
  	height: 1.6rem;
	vertical-align: middle;
	text-align: center;
	color: #ddd;
	background-color: #F3F2EE;
}

.task-list-item input:checked:before,
.task-list-item input[checked]:before{
	color: inherit;
}

#write pre.md-meta-block {
	min-height: 1.875rem;
	color: #555;
	border: 0px;
	background: transparent;
	margin-top: -4px;
	margin-left: 1em;
	margin-top: 1em;
}

.md-image>.md-meta {
	color: #9B5146;
}

.md-image>.md-meta{
	font-family: Menlo, 'Ubuntu Mono', Consolas, 'Courier New', 'Microsoft Yahei', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', sans-serif;
}


#write>h3.md-focus:before{
	left: -1.5rem;
	color:#999;
	border-color:#999;
}
#write>h4.md-focus:before{
	left: -1.5rem;
	top: .25rem;
	color:#999;
	border-color:#999;
}
#write>h5.md-focus:before{
	left: -1.5rem;
	top: .0.3125rem;
	color:#999;
	border-color:#999;
}
#write>h6.md-focus:before{
	left: -1.5rem;
	top: 0.3125rem;
	color:#999;
	border-color:#999;
}

.md-toc:focus .md-toc-content{
	margin-top: 19px;
}

.md-toc-content:empty:before{
	color: #065588;
}
.md-toc-item {
	color: #065588;
}
#write div.md-toc-tooltip {
	background-color: #f3f2ee;
}

#outline-dropmenu {
	background-color: #f3f2ee;
	-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.375);
  	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.375);
}

.pin-outline #outline-dropmenu {
	background: inherit;
	box-shadow: none;
	border-right: 1px dashed;
}

.pin-outline #outline-dropmenu:hover .outline-title-wrapper {
	border-left:1px dashed;
}

.outline-item:hover {
  background-color: #dadada;
  border-left: 28px solid #dadada;
  border-right: 18px solid #dadada;
}

.typora-node .outline-item:hover {
  	border-right: 28px solid #dadada;
}

.outline-expander:before {
  content: "\f0da";
  font-family: FontAwesome;
  font-size:14px;
  top: 1px;
}

.outline-expander:hover:before,
.outline-item-open>.outline-item>.outline-expander:before {
  content: "\f0d7";
}

.modal-content {
	background-color: #f3f2ee;
}

.auto-suggest-container ul li {
	list-style-type: none;
}

/** UI for electron */

.megamenu-menu,
#top-titlebar, #top-titlebar *,
.megamenu-content {
	background: #f3f2ee;
	color: #1f0909;
}

.megamenu-menu-header {
	border-bottom: 1px dashed #202B33;
}

.megamenu-menu {
	box-shadow: none;
	border-right: 1px dashed;
}

header, .context-menu, .megamenu-content, footer {
	font-family: "PT Serif", 'Times New Roman', Times;
    color: #1f0909;
}

#megamenu-back-btn {
	color: #1f0909;
	border-color: #1f0909;
}

.megamenu-menu-header #megamenu-menu-header-title:before {
	color: #1f0909;
}

.megamenu-menu-list li a:hover, .megamenu-menu-list li a.active {
	color: inherit;
	background-color: #e8e7df;
}

.long-btn:hover {
	background-color: #e8e7df;
}

#recent-file-panel tbody tr:nth-child(2n-1) {
    background-color: transparent !important;
}

.megamenu-menu-panel tbody tr:hover td:nth-child(2) {
    color: inherit;
}

.megamenu-menu-panel .btn {
	background-color: #D2D1D1;
}

.btn-default {
	background-color: transparent;
}

.typora-sourceview-on #toggle-sourceview-btn,
.show-word-count #footer-word-count {
	background: #c7c5c5;
}

#typora-quick-open {
    background-color: inherit;
}

.md-diagram-panel {
	margin-left: -1ch;
	margin-top: 24px;
}



</style>
</head>
<body class="typora-export">
<div id="write" class="is-mac"><h3 id="机器学习入门"><a name="header-c7" class="md-header-anchor "></a>机器学习入门</h3><div class="md-toc" mdtype="toc"><p class="md-toc-content"><span class="md-toc-item md-toc-h3" data-ref="c7"><a class="md-toc-inner" style="" href="#header-c7">机器学习入门</a></span><span class="md-toc-item md-toc-h4" data-ref="c9"><a class="md-toc-inner" style="" href="#header-c9">1.简介</a></span><span class="md-toc-item md-toc-h5" data-ref="c10"><a class="md-toc-inner" style="" href="#header-c10">1.1 什么是机器学习</a></span><span class="md-toc-item md-toc-h5" data-ref="c47"><a class="md-toc-inner" style="" href="#header-c47">1.2机器学习的发展</a></span><span class="md-toc-item md-toc-h4" data-ref="c53"><a class="md-toc-inner" style="" href="#header-c53">2.octave的安装和使用</a></span><span class="md-toc-item md-toc-h5" data-ref="c54"><a class="md-toc-inner" style="" href="#header-c54">2.1 octave安装</a></span><span class="md-toc-item md-toc-h5" data-ref="c66"><a class="md-toc-inner" style="" href="#header-c66">2.2 octave的使用</a></span><span class="md-toc-item md-toc-h4" data-ref="c97"><a class="md-toc-inner" style="" href="#header-c97">3.Supervised Learning and Unsupervised Learning(监督学习与无监督学习)</a></span><span class="md-toc-item md-toc-h5" data-ref="c98"><a class="md-toc-inner" style="" href="#header-c98">3.1 Supervised Learning(监督学习)</a></span><span class="md-toc-item md-toc-h5" data-ref="c107"><a class="md-toc-inner" style="" href="#header-c107">3.2 Unsupervised Learning(无监督学习)</a></span><span class="md-toc-item md-toc-h4" data-ref="c117"><a class="md-toc-inner" style="" href="#header-c117">4.Linear Regression Problem</a></span><span class="md-toc-item md-toc-h5" data-ref="c555"><a class="md-toc-inner" style="" href="#header-c555">4.1Cost Function</a></span><span class="md-toc-item md-toc-h5" data-ref="c140"><a class="md-toc-inner" style="" href="#header-c140">4.2Gradient Descent</a></span><span class="md-toc-item md-toc-h5" data-ref="c149"><a class="md-toc-inner" style="" href="#header-c149">4.3 Gradient Descent For Linear Regression</a></span><span class="md-toc-item md-toc-h5" data-ref="c159"><a class="md-toc-inner" style="" href="#header-c159">4.4 Linear Regression Feature Scaling</a></span><span class="md-toc-item md-toc-h5" data-ref="c172"><a class="md-toc-inner" style="" href="#header-c172">4.5 Polynomial Regression</a></span><span class="md-toc-item md-toc-h5" data-ref="c181"><a class="md-toc-inner" style="" href="#header-c181">4.6 Linear Regresstion Normal Equation</a></span><span class="md-toc-item md-toc-h4" data-ref="c206"><a class="md-toc-inner" style="" href="#header-c206">5.Classification Regression Problem</a></span><span class="md-toc-item md-toc-h5" data-ref="c583"><a class="md-toc-inner" style="" href="#header-c583">5.1 Classifican Hypothesis Representation</a></span><span class="md-toc-item md-toc-h5" data-ref="c220"><a class="md-toc-inner" style="" href="#header-c220">5.2 Decision Boundary</a></span><span class="md-toc-item md-toc-h5" data-ref="c239"><a class="md-toc-inner" style="" href="#header-c239">5.3 Logistic Regression Cost Function</a></span><span class="md-toc-item md-toc-h5" data-ref="c268"><a class="md-toc-inner" style="" href="#header-c268">5.4 Simplified Gradient Descent</a></span><span class="md-toc-item md-toc-h5" data-ref="c277"><a class="md-toc-inner" style="" href="#header-c277">5.5 Advance Optimization</a></span><span class="md-toc-item md-toc-h5" data-ref="c292"><a class="md-toc-inner" style="" href="#header-c292">5.6 Multiclass Classfication:One-vs-all</a></span><span class="md-toc-item md-toc-h4" data-ref="c304"><a class="md-toc-inner" style="" href="#header-c304">6.Solving the Problem of Over fitting</a></span><span class="md-toc-item md-toc-h5" data-ref="c305"><a class="md-toc-inner" style="" href="#header-c305">6.1 The Problem of Overfitting</a></span><span class="md-toc-item md-toc-h5" data-ref="c334"><a class="md-toc-inner" style="" href="#header-c334">6.2 Cost Function</a></span><span class="md-toc-item md-toc-h5" data-ref="c372"><a class="md-toc-inner" style="" href="#header-c372">6.3 Regularized Linear Regression</a></span><span class="md-toc-item md-toc-h5" data-ref="c521"><a class="md-toc-inner" style="" href="#header-c521">6.4 Regularized Logistic Regression</a></span><span class="md-toc-item md-toc-h4" data-ref="c539"><a class="md-toc-inner" style="" href="#header-c539">7.Netral Networkings </a></span></p></div><h4 id="1简介"><a name="header-c9" class="md-header-anchor "></a>1.简介</h4><h5 id="11-什么是机器学习"><a name="header-c10" class="md-header-anchor "></a>1.1 什么是机器学习</h5><p>似乎在知乎找到答案:</p><p><img src="https://ws1.sinaimg.cn/large/006tNc79gy1ffqv940asij30go0e1wg2.jpg" alt="Machine learning"></p><p>又或者说:</p><blockquote><p>- 1+1等于几 ？</p><p>- 50
- 傻x，多了</p><p>- 1+2等于几？
- 20
- 傻x，多了</p><p>- 3+4等于几
- 7
- 傻x，对了</p><p>- 6+9等于几
- 13
- 傻x，少了</p><p>很多很多次以后……</p><p>- 2+2等于几
- 4</p><p>- 4+5等于几
- 9</p></blockquote><p>哈哈哈!允许我笑那么一会儿!</p><p>其真正的定义是:<strong>A computer program is said to learn from experiene E with repect to  some class of  tasks T and performance measure P, if its performance at tasks in T,as measured by P  improves with experience E.</strong></p><h5 id="12机器学习的发展"><a name="header-c47" class="md-header-anchor "></a>1.2机器学习的发展</h5><p>随着AlphaGo再一次在击败人类世界冠军,无人汽车领域的突破,人工智能助理等,其应用越来越广泛,机器学习的前途越发光明,可以说是一发不可收拾的状态!但我们知道任何事物的取得的都离不开其自身的发展,机器学习也一样!</p><p>20世纪90年代中期到 21 世纪 00 年代中期是机器学习发展的黄金时期,是统计学和科技学科的结合发展期!主要标志是学术界涌现出一批重要成果，比如，基于统计学习理论的<strong>支持向量机、随机森林和 Boosting</strong> 等集成分类方法，<strong>概率图模型</strong>，基于再生核理论的非线性数据分析与处理方法，<strong>非参数贝叶斯方法</strong>，基于正则化理论的<strong>稀疏学习模型及应用</strong>等等。这些成果奠定了统计学习的理论基础和框架。正因为有了前辈们这些贡献,才有现在机器学习的应用的前景,我猜不出几年,机器学习的应用会越来越火爆!所以抓住机会学一波!</p><div class="md-diagram-panel" mdtype="math_block"><svg id="mermaidChart0" width="503" xmlns="http://www.w3.org/2000/svg" height="272" viewbox="0 0 523 292" style="height: 332px;"><g><g class="output"><g class="clusters"><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M211.5,64L211.5,89L243.14893617021278,114" marker-end="url(#arrowhead16)" style="fill:none"/><defs><marker id="arrowhead16" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M330.5,64L330.5,89L298.8510638297872,114" marker-end="url(#arrowhead17)" style="fill:none"/><defs><marker id="arrowhead17" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M233,144.44444444444446L59.5,183L59.5,208" marker-end="url(#arrowhead18)" style="fill:none"/><defs><marker id="arrowhead18" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M238.2340425531915,158L201,183L201,208" marker-end="url(#arrowhead19)" style="fill:none"/><defs><marker id="arrowhead19" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M303.7659574468085,158L341,183L341,208" marker-end="url(#arrowhead20)" style="fill:none"/><defs><marker id="arrowhead20" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M309,145.65405405405406L456,183L456,208" marker-end="url(#arrowhead21)" style="fill:none"/><defs><marker id="arrowhead21" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g></g><g class="nodes"><g class="node" id="id1" transform="translate(211.5,42)" style="opacity: 1;"><rect rx="5" ry="5" x="-31" y="-22" width="62" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-21,-12)"><foreignobject width="42" height="24"><div style="display: inline-block; white-space: nowrap;">统计学</div></foreignobject></g></g></g><g class="node" id="id" transform="translate(271,136)" style="opacity: 1;"><rect rx="5" ry="5" x="-38" y="-22" width="76" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-28,-12)"><foreignobject width="56" height="24"><div style="display: inline-block; white-space: nowrap;">机器学习</div></foreignobject></g></g></g><g class="node" id="id2" transform="translate(330.5,42)" style="opacity: 1;"><rect rx="5" ry="5" x="-38" y="-22" width="76" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-28,-12)"><foreignobject width="56" height="24"><div style="display: inline-block; white-space: nowrap;">计算机学</div></foreignobject></g></g></g><g class="node" id="id3" transform="translate(59.5,230)" style="opacity: 1;"><rect rx="5" ry="5" x="-39.5" y="-22" width="79" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-29.5,-12)"><foreignobject width="59" height="24"><div style="display: inline-block; white-space: nowrap;">AlphaGo</div></foreignobject></g></g></g><g class="node" id="id4" transform="translate(201,230)" style="opacity: 1;"><rect rx="5" ry="5" x="-52" y="-22" width="104" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-42,-12)"><foreignobject width="84" height="24"><div style="display: inline-block; white-space: nowrap;">无人驾驶汽车</div></foreignobject></g></g></g><g class="node" id="id5" transform="translate(341,230)" style="opacity: 1;"><rect rx="5" ry="5" x="-38" y="-22" width="76" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-28,-12)"><foreignobject width="56" height="24"><div style="display: inline-block; white-space: nowrap;">智能助理</div></foreignobject></g></g></g><g class="node" id="id6" transform="translate(456,230)" style="opacity: 1;"><rect rx="5" ry="5" x="-27" y="-22" width="54" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-17,-12)"><foreignobject width="34" height="24"><div style="display: inline-block; white-space: nowrap;">....</div></foreignobject></g></g></g></g></g></g></g></svg></div><h4 id="2octave的安装和使用"><a name="header-c53" class="md-header-anchor "></a>2.octave的安装和使用</h4><h5 id="21-octave安装"><a name="header-c54" class="md-header-anchor "></a>2.1 octave安装</h5><p>octave是一款用于数值计算和绘图的开源软件。是学习机器学习入门的较好软件,当然你也可以直接用Python,R,C++等语言进行开发!如果你是新手,建议先用octave/malab;如果你会Python等,那么你也可以选择直接用你这门语言。</p><p>终端键入:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="shell"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><div style="width: 50px; height: 50px; overflow-x: scroll;"></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;">brew install <span class="cm-builtin">gcc</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;">brew install Caskroom/cask/xquartz</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;">brew install octave</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 72px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>等终端跑完就好,像是要梯子。别问我brew是啥!</p><p>在终端输入:<code>$ octave</code>出现如下界面:</p><p><img src="https://ws3.sinaimg.cn/large/006tNbRwgy1fg3r68q0baj30sp0l3q5y.jpg" alt="屏幕快照 2017-05-24 17.36.44"></p><h5 id="22-octave的使用"><a name="header-c66" class="md-header-anchor "></a>2.2 octave的使用</h5><p>octave分为工作区,命令窗口,Editor三个区,也故名思议三个区负责不同的职责!工作区负责是变量存储,命令窗口负责键入执行命令,而Editor负责修改编辑文件!当然如果你觉得这个编译器不好(好渣)的话,你可以改用Sublime,Vim等比较主流的编辑器!这并没有什么影响!</p><p><img src="https://ws4.sinaimg.cn/large/006tNbRwgy1fg3r6g66e6j30sp0l3ade.jpg" alt="屏幕快照 2017-05-24 17.36.44 2"></p><p>ok,看到这里,如果你还没有完成octave的安装的话,那最好还请耐心的等等吧,但看下也无妨,哈哈!</p><p>1.在octave命令窗口键入:<code>&gt;&gt; 2+ 2</code>然后回车,你会看到命令窗口显示ans = 4;而左边的工作区则保存ans这个临时变量及相关的类,维度,值。恩!这是最简单的计算!</p><p>2.octave包括许多的内建函数,这给我们极大的计算方便,像sin,cos,log等,输入:<code>&gt;&gt;sin(3)</code>,你会看到输出ans = 0.14112;</p><p>3.octave允许你自定义变量来存储,例如键入<code>&gt;&gt;sum = 1 + 2 + 3 + 4</code>输出的就是sum = 10;而工作区是存储sum变量而不是ans。如果你需要查看某个变量的数值,输入其变量名并回车即可。如果你想查看当前名命名或者使用的函数
名和变量名,输入<code>&gt;&gt; who</code></p><p>4.如果你需要从当前的变量空间中删除某个变量,<code>clear</code> 命令能移出所有的变量,或者移出某个特定变量,如:<code>clear name</code></p><p>5.octave的数值表示有两种,分别是<code>format long</code>和<code>format short</code>对应的是15位和5位~</p><p>6.载入与保存数据:当你要离开octave,但保存当前这些变量的话输入<code>save anyname</code> 系统将保存数据在你所在的目录下;然后重新加载的话是<code>load anyname</code>,如果你想保存时某些变量,那么键入<code>save filename var1 var2 ...</code></p><p>7.如果你对某些函数不太清楚其作用,你可以键入:<code>help commandname</code> 例如<code>help sqrt</code></p><p>8.构造向量:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="octave"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 39px;"></div><div class="CodeMirror-hscrollbar" style="left: 35px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 35px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><div style="width: 50px; height: 50px; overflow-x: scroll;"></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 27px;">1</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-comment">%常规构造</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-operator">&gt;&gt;</span> <span class="cm-variable">a</span>=[<span class="cm-number">1</span> <span class="cm-number">4</span> <span class="cm-number">5</span>]</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">3</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-variable">a</span>=</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">4</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp;  <span class="cm-number">1</span> <span class="cm-number">4</span> <span class="cm-number">5</span> </span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">5</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-operator">&gt;&gt;</span> <span class="cm-variable">b</span>=[<span class="cm-number">2</span>,<span class="cm-number">1</span>,<span class="cm-number">0</span>]</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">6</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-variable">b</span>= </span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">7</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp;  <span class="cm-number">2</span> <span class="cm-number">1</span> <span class="cm-number">0</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">8</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-operator">&gt;&gt;</span> <span class="cm-variable">c</span>=[<span class="cm-number">4</span>;<span class="cm-number">7</span>;<span class="cm-number">10</span>]</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">9</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-variable">c</span>=</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 27px;">10</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp;  <span class="cm-number">4</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">11</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp;  <span class="cm-number">7</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">12</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp;  <span class="cm-number">10</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">13</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-operator">&gt;&gt;</span> <span class="cm-variable">e</span> = [<span class="cm-number">2</span>;<span class="cm-variable">c</span>]; </span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">14</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-variable">e</span>= </span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">15</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp;  <span class="cm-number">2</span> </span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">16</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp;  <span class="cm-number">4</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">17</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp;  <span class="cm-number">7</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">18</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp;  <span class="cm-number">10</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">19</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-operator">&gt;&gt;</span> <span class="cm-variable">f</span> = <span class="cm-number">2</span> : <span class="cm-number">6</span> <span class="cm-comment">%冒号表达式构建</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 27px;">20</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; <span class="cm-variable">f</span> = </span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">21</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; <span class="cm-number">2</span> <span class="cm-number">3</span> <span class="cm-number">4</span> <span class="cm-number">5</span> <span class="cm-number">6</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">22</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-operator">&gt;&gt;</span> <span class="cm-variable">g</span> = <span class="cm-number">2</span>:<span class="cm-number">0.3</span>:<span class="cm-number">3</span> <span class="cm-comment">%从第一个数字以第二个数字为递增速率到第三个数字</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">23</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; <span class="cm-variable">e</span>=</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 27px;">24</div></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp;  <span class="cm-number">2.0000</span> <span class="cm-number">2.3000</span> <span class="cm-number">2.6000</span> <span class="cm-number">2.9000</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 576px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 35px;"></div></div></div></div></pre><p></p><ol start="9"><li>当然还有很多,比如说是绘图(plot),编写脚本文件,编写一个函数,3d绘图(plot3),编写一个可执行程序等等,然后不费口水了,点击<a href="https://github.com/blaceman/machine-learning-/blob/master/octave-tutorial-cn%20(2).pdf">这里</a>查看具体教程,哈哈,偷懒的博主!</li></ol><h4 id="3supervised-learning-and-unsupervised-learning监督学习与无监督学习"><a name="header-c97" class="md-header-anchor "></a>3.Supervised Learning and Unsupervised Learning(监督学习与无监督学习)</h4><h5 id="31-supervised-learning监督学习"><a name="header-c98" class="md-header-anchor "></a>3.1 Supervised Learning(监督学习)</h5><p>What&#39;s Supervised? <strong><em>In Supervised Learning,we are gived a data set and already know what our correct output should look like, having the idea that there is  a relationship between input and output.</em></strong></p><p>Supervised learning problems are categorized into <strong>&quot;regression&quot; and &quot;classification&quot; problems.</strong></p><p>regression problems:<strong>we are trying to predict result within a continuous output,meaning that we are trying to map intput avariable to some continuous funtion</strong>.</p><p>classification problem:<strong>we are trying to pridict result in a decreat output in other words, we are trying to map input variables into discrete categories</strong></p><h5 id="32-unsupervised-learning无监督学习"><a name="header-c107" class="md-header-anchor "></a>3.2 Unsupervised Learning(无监督学习)</h5><p><strong><em>Unsupervised Learning  allow us to approach problem with little and no idea what our result should look like. we should  derive structure from the data where we don&#39;t necessarily know the effct of variable</em></strong></p><p><strong>We can derive this structure by clustering the data based on relationships among the variables in the data.</strong></p><p>With unsupervised learning there is no feedback based on the prediction results.</p><p>the figure below shows the machine learning structure:</p><div class="md-diagram-panel" mdtype="math_block"><svg id="mermaidChart1" width="580.5" xmlns="http://www.w3.org/2000/svg" height="272" viewbox="0 0 600.5 292" style="height: 332px;"><g><g class="output"><g class="clusters"><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M287.79787234042556,64L224.5,89L224.5,114" marker-end="url(#arrowhead35)" style="fill:none"/><defs><marker id="arrowhead35" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M399.20212765957444,64L462.5,89L462.5,114" marker-end="url(#arrowhead36)" style="fill:none"/><defs><marker id="arrowhead36" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M168.79787234042553,158L105.5,183L105.5,208" marker-end="url(#arrowhead37)" style="fill:none"/><defs><marker id="arrowhead37" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M280.20212765957444,158L343.5,183L343.5,208" marker-end="url(#arrowhead38)" style="fill:none"/><defs><marker id="arrowhead38" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g></g><g class="nodes"><g class="node" id="id" transform="translate(343.5,42)" style="opacity: 1;"><rect rx="5" ry="5" x="-77" y="-22" width="154" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-67,-12)"><foreignobject width="134" height="24"><div style="display: inline-block; white-space: nowrap;">machine learning</div></foreignobject></g></g></g><g class="node" id="id1" transform="translate(224.5,136)" style="opacity: 1;"><rect rx="5" ry="5" x="-90" y="-22" width="180" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-80,-12)"><foreignobject width="160" height="24"><div style="display: inline-block; white-space: nowrap;">supervised learning</div></foreignobject></g></g></g><g class="node" id="id2" transform="translate(462.5,136)" style="opacity: 1;"><rect rx="5" ry="5" x="-98" y="-22" width="196" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-88,-12)"><foreignobject width="176" height="24"><div style="display: inline-block; white-space: nowrap;">unsupervised learning</div></foreignobject></g></g></g><g class="node" id="id3" transform="translate(105.5,230)" style="opacity: 1;"><rect rx="5" ry="5" x="-85.5" y="-22" width="171" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-75.5,-12)"><foreignobject width="151" height="24"><div style="display: inline-block; white-space: nowrap;">regression problem</div></foreignobject></g></g></g><g class="node" id="id4" transform="translate(343.5,230)" style="opacity: 1;"><rect rx="5" ry="5" x="-102.5" y="-22" width="205" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-92.5,-12)"><foreignobject width="185" height="24"><div style="display: inline-block; white-space: nowrap;">classification problem</div></foreignobject></g></g></g></g></g></g></g></svg></div><h4 id="4linear-regression-problem"><a name="header-c117" class="md-header-anchor "></a>4.Linear Regression Problem</h4><h5 id="41cost-function"><a name="header-c555" class="md-header-anchor "></a>4.1Cost Function</h5><p>what&#39;s Cost Function? <strong>it is usually used to measure accuracy of our hypothesis function</strong></p><p>That&#39;s need average difference of all results of the hypothesis with input from x&#39;s and the actual out y&#39;s. The math block below show:</p><div contenteditable="false" class="mathjax-block md-end-block" id="mathjax-c121" cid="c121" mdtype="math_block"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-1-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="37.543ex" height="6.884ex" viewbox="0 -1670.4 16164.3 2964.1" role="img" focusable="false" style="vertical-align: -3.005ex;"><defs><path stroke-width="1" id="E1-MJMATHI-4A" d="M447 625Q447 637 354 637H329Q323 642 323 645T325 664Q329 677 335 683H352Q393 681 498 681Q541 681 568 681T605 682T619 682Q633 682 633 672Q633 670 630 658Q626 642 623 640T604 637Q552 637 545 623Q541 610 483 376Q420 128 419 127Q397 64 333 21T195 -22Q137 -22 97 8T57 88Q57 130 80 152T132 174Q177 174 182 130Q182 98 164 80T123 56Q115 54 115 53T122 44Q148 15 197 15Q235 15 271 47T324 130Q328 142 387 380T447 625Z"/><path stroke-width="1" id="E1-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E1-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E1-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/><path stroke-width="1" id="E1-MJMAIN-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z"/><path stroke-width="1" id="E1-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E1-MJMAIN-2E" d="M78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"/><path stroke-width="1" id="E1-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E1-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E1-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"/><path stroke-width="1" id="E1-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1-MJSZ2-2211" d="M60 948Q63 950 665 950H1267L1325 815Q1384 677 1388 669H1348L1341 683Q1320 724 1285 761Q1235 809 1174 838T1033 881T882 898T699 902H574H543H251L259 891Q722 258 724 252Q725 250 724 246Q721 243 460 -56L196 -356Q196 -357 407 -357Q459 -357 548 -357T676 -358Q812 -358 896 -353T1063 -332T1204 -283T1307 -196Q1328 -170 1348 -124H1388Q1388 -125 1381 -145T1356 -210T1325 -294L1267 -449L666 -450Q64 -450 61 -448Q55 -446 55 -439Q55 -437 57 -433L590 177Q590 178 557 222T452 366T322 544L56 909L55 924Q55 945 60 948Z"/><path stroke-width="1" id="E1-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E1-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E1-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E1-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E1-MJMATHI-4A" x="0" y="0"/><use xlink:href="#E1-MJMAIN-28" x="633" y="0"/><g transform="translate(1023,0)"><use xlink:href="#E1-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1-MJMAIN-30" x="663" y="-213"/></g><use xlink:href="#E1-MJMAIN-2C" x="1946" y="0"/><g transform="translate(2391,0)"><use xlink:href="#E1-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1-MJMAIN-31" x="663" y="-213"/></g><use xlink:href="#E1-MJMAIN-2C" x="3314" y="0"/><use xlink:href="#E1-MJMAIN-2E" x="3760" y="0"/><use xlink:href="#E1-MJMAIN-2E" x="4205" y="0"/><use xlink:href="#E1-MJMAIN-2E" x="4650" y="0"/><use xlink:href="#E1-MJMAIN-29" x="5095" y="0"/><use xlink:href="#E1-MJMAIN-3D" x="5762" y="0"/><g transform="translate(6541,0)"><g transform="translate(397,0)"><rect stroke="none" width="1499" height="60" x="0" y="220"/><use xlink:href="#E1-MJMAIN-31" x="499" y="676"/><g transform="translate(60,-686)"><use xlink:href="#E1-MJMAIN-32" x="0" y="0"/><use xlink:href="#E1-MJMATHI-6D" x="500" y="0"/></g></g></g><g transform="translate(8724,0)"><use xlink:href="#E1-MJSZ2-2211" x="0" y="0"/><g transform="translate(147,-1090)"><use transform="scale(0.707)" xlink:href="#E1-MJMATHI-69" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1-MJMAIN-3D" x="345" y="0"/><use transform="scale(0.707)" xlink:href="#E1-MJMAIN-31" x="1124" y="0"/></g><use transform="scale(0.707)" xlink:href="#E1-MJMATHI-6D" x="582" y="1627"/></g><use xlink:href="#E1-MJMAIN-28" x="10169" y="0"/><g transform="translate(10558,0)"><use xlink:href="#E1-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E1-MJMAIN-28" x="11567" y="0"/><g transform="translate(11956,0)"><use xlink:href="#E1-MJMATHI-78" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1-MJMATHI-69" x="809" y="-213"/></g><use xlink:href="#E1-MJMAIN-29" x="12873" y="0"/><use xlink:href="#E1-MJMAIN-2212" x="13485" y="0"/><g transform="translate(14486,0)"><use xlink:href="#E1-MJMATHI-79" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1-MJMATHI-69" x="693" y="-213"/></g><g transform="translate(15320,0)"><use xlink:href="#E1-MJMAIN-29" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1-MJMAIN-32" x="550" y="583"/></g></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-1">
J(\theta_0,\theta_1 ,...) = \frac{1}{2m} \sum_{i=1}^m(h_\theta(x_i) - y_i)^2
</script></div><p>Suppose we use X(m * (n + 1)) matrix as my input variables ,Y(m * 1) matrix as my output variable,<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-71-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.09ex" height="2.134ex" viewbox="0 -809.3 469.5 918.9" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E71-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E71-MJMATHI-3B8" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-71">\theta</script>((n + 1) * 1) as parameter of h<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-71-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.09ex" height="2.134ex" viewbox="0 -809.3 469.5 918.9" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E71-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E71-MJMATHI-3B8" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-71">\theta</script>,so the math block is:</p><div contenteditable="false" class="mathjax-block md-end-block" id="mathjax-c124" cid="c124" mdtype="math_block"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-2-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="49.032ex" height="5.009ex" viewbox="0 -1401.3 21111 2156.8" role="img" focusable="false" style="vertical-align: -1.755ex;"><defs><path stroke-width="1" id="E2-MJMATHI-4A" d="M447 625Q447 637 354 637H329Q323 642 323 645T325 664Q329 677 335 683H352Q393 681 498 681Q541 681 568 681T605 682T619 682Q633 682 633 672Q633 670 630 658Q626 642 623 640T604 637Q552 637 545 623Q541 610 483 376Q420 128 419 127Q397 64 333 21T195 -22Q137 -22 97 8T57 88Q57 130 80 152T132 174Q177 174 182 130Q182 98 164 80T123 56Q115 54 115 53T122 44Q148 15 197 15Q235 15 271 47T324 130Q328 142 387 380T447 625Z"/><path stroke-width="1" id="E2-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E2-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E2-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/><path stroke-width="1" id="E2-MJMAIN-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z"/><path stroke-width="1" id="E2-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E2-MJMAIN-2E" d="M78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"/><path stroke-width="1" id="E2-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E2-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E2-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"/><path stroke-width="1" id="E2-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E2-MJMAIN-2217" d="M229 286Q216 420 216 436Q216 454 240 464Q241 464 245 464T251 465Q263 464 273 456T283 436Q283 419 277 356T270 286L328 328Q384 369 389 372T399 375Q412 375 423 365T435 338Q435 325 425 315Q420 312 357 282T289 250L355 219L425 184Q434 175 434 161Q434 146 425 136T401 125Q393 125 383 131T328 171L270 213Q283 79 283 63Q283 53 276 44T250 35Q231 35 224 44T216 63Q216 80 222 143T229 213L171 171Q115 130 110 127Q106 124 100 124Q87 124 76 134T64 161Q64 166 64 169T67 175T72 181T81 188T94 195T113 204T138 215T170 230T210 250L74 315Q65 324 65 338Q65 353 74 363T98 374Q106 374 116 368T171 328L229 286Z"/><path stroke-width="1" id="E2-MJMATHI-58" d="M42 0H40Q26 0 26 11Q26 15 29 27Q33 41 36 43T55 46Q141 49 190 98Q200 108 306 224T411 342Q302 620 297 625Q288 636 234 637H206Q200 643 200 645T202 664Q206 677 212 683H226Q260 681 347 681Q380 681 408 681T453 682T473 682Q490 682 490 671Q490 670 488 658Q484 643 481 640T465 637Q434 634 411 620L488 426L541 485Q646 598 646 610Q646 628 622 635Q617 635 609 637Q594 637 594 648Q594 650 596 664Q600 677 606 683H618Q619 683 643 683T697 681T738 680Q828 680 837 683H845Q852 676 852 672Q850 647 840 637H824Q790 636 763 628T722 611T698 593L687 584Q687 585 592 480L505 384Q505 383 536 304T601 142T638 56Q648 47 699 46Q734 46 734 37Q734 35 732 23Q728 7 725 4T711 1Q708 1 678 1T589 2Q528 2 496 2T461 1Q444 1 444 10Q444 11 446 25Q448 35 450 39T455 44T464 46T480 47T506 54Q523 62 523 64Q522 64 476 181L429 299Q241 95 236 84Q232 76 232 72Q232 53 261 47Q262 47 267 47T273 46Q276 46 277 46T280 45T283 42T284 35Q284 26 282 19Q279 6 276 4T261 1Q258 1 243 1T201 2T142 2Q64 2 42 0Z"/><path stroke-width="1" id="E2-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E2-MJMATHI-59" d="M66 637Q54 637 49 637T39 638T32 641T30 647T33 664T42 682Q44 683 56 683Q104 680 165 680Q288 680 306 683H316Q322 677 322 674T320 656Q316 643 310 637H298Q242 637 242 624Q242 619 292 477T343 333L346 336Q350 340 358 349T379 373T411 410T454 461Q546 568 561 587T577 618Q577 634 545 637Q528 637 528 647Q528 649 530 661Q533 676 535 679T549 683Q551 683 578 682T657 680Q684 680 713 681T746 682Q763 682 763 673Q763 669 760 657T755 643Q753 637 734 637Q662 632 617 587Q608 578 477 424L348 273L322 169Q295 62 295 57Q295 46 363 46Q379 46 384 45T390 35Q390 33 388 23Q384 6 382 4T366 1Q361 1 324 1T232 2Q170 2 138 2T102 1Q84 1 84 9Q84 14 87 24Q88 27 89 30T90 35T91 39T93 42T96 44T101 45T107 45T116 46T129 46Q168 47 180 50T198 63Q201 68 227 171L252 274L129 623Q128 624 127 625T125 627T122 629T118 631T113 633T105 634T96 635T83 636T66 637Z"/><path stroke-width="1" id="E2-MJMATHI-54" d="M40 437Q21 437 21 445Q21 450 37 501T71 602L88 651Q93 669 101 677H569H659Q691 677 697 676T704 667Q704 661 687 553T668 444Q668 437 649 437Q640 437 637 437T631 442L629 445Q629 451 635 490T641 551Q641 586 628 604T573 629Q568 630 515 631Q469 631 457 630T439 622Q438 621 368 343T298 60Q298 48 386 46Q418 46 427 45T436 36Q436 31 433 22Q429 4 424 1L422 0Q419 0 415 0Q410 0 363 1T228 2Q99 2 64 0H49Q43 6 43 9T45 27Q49 40 55 46H83H94Q174 46 189 55Q190 56 191 56Q196 59 201 76T241 233Q258 301 269 344Q339 619 339 625Q339 630 310 630H279Q212 630 191 624Q146 614 121 583T67 467Q60 445 57 441T43 437H40Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E2-MJMATHI-4A" x="0" y="0"/><use xlink:href="#E2-MJMAIN-28" x="633" y="0"/><g transform="translate(1023,0)"><use xlink:href="#E2-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-30" x="663" y="-213"/></g><use xlink:href="#E2-MJMAIN-2C" x="1946" y="0"/><g transform="translate(2391,0)"><use xlink:href="#E2-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-31" x="663" y="-213"/></g><use xlink:href="#E2-MJMAIN-2C" x="3314" y="0"/><use xlink:href="#E2-MJMAIN-2E" x="3760" y="0"/><use xlink:href="#E2-MJMAIN-2E" x="4205" y="0"/><use xlink:href="#E2-MJMAIN-2E" x="4650" y="0"/><use xlink:href="#E2-MJMAIN-29" x="5095" y="0"/><use xlink:href="#E2-MJMAIN-3D" x="5762" y="0"/><g transform="translate(6541,0)"><g transform="translate(397,0)"><rect stroke="none" width="1499" height="60" x="0" y="220"/><use xlink:href="#E2-MJMAIN-31" x="499" y="676"/><g transform="translate(60,-686)"><use xlink:href="#E2-MJMAIN-32" x="0" y="0"/><use xlink:href="#E2-MJMATHI-6D" x="500" y="0"/></g></g></g><use xlink:href="#E2-MJMAIN-2217" x="8780" y="0"/><use xlink:href="#E2-MJMAIN-28" x="9503" y="0"/><use xlink:href="#E2-MJMATHI-58" x="9892" y="0"/><use xlink:href="#E2-MJMAIN-2217" x="10967" y="0"/><use xlink:href="#E2-MJMATHI-3B8" x="11690" y="0"/><use xlink:href="#E2-MJMAIN-2212" x="12381" y="0"/><use xlink:href="#E2-MJMATHI-59" x="13382" y="0"/><g transform="translate(14146,0)"><use xlink:href="#E2-MJMAIN-29" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMATHI-54" x="550" y="583"/></g><use xlink:href="#E2-MJMAIN-2217" x="15355" y="0"/><use xlink:href="#E2-MJMAIN-28" x="16078" y="0"/><use xlink:href="#E2-MJMATHI-58" x="16468" y="0"/><use xlink:href="#E2-MJMAIN-2217" x="17542" y="0"/><use xlink:href="#E2-MJMATHI-3B8" x="18265" y="0"/><use xlink:href="#E2-MJMAIN-2212" x="18957" y="0"/><use xlink:href="#E2-MJMATHI-59" x="19958" y="0"/><use xlink:href="#E2-MJMAIN-29" x="20721" y="0"/></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-2">
J(\theta_0,\theta_1,...) = \frac{1}{2m}*(X * \theta - Y)^T * (X * \theta - Y)
</script></div><p>and the J(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-40-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.509ex" viewbox="0 -809.3 923.4 1080.4" role="img" focusable="false" style="vertical-align: -0.63ex;"><defs><path stroke-width="1" id="E40-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E40-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E40-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E40-MJMAIN-30" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-40">\theta_0</script>,<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script>,…) closer to zero and more fit data!</p><p>As an example:we have some data set X = <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-17-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.006ex" height="9.134ex" viewbox="0 -2208.6 2155.6 3932.8" role="img" focusable="false" style="vertical-align: -4.005ex;"><defs><path stroke-width="1" id="E17-MJMAIN-5B" d="M118 -250V750H255V710H158V-210H255V-250H118Z"/><path stroke-width="1" id="E17-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E17-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"/><path stroke-width="1" id="E17-MJMAIN-33" d="M127 463Q100 463 85 480T69 524Q69 579 117 622T233 665Q268 665 277 664Q351 652 390 611T430 522Q430 470 396 421T302 350L299 348Q299 347 308 345T337 336T375 315Q457 262 457 175Q457 96 395 37T238 -22Q158 -22 100 21T42 130Q42 158 60 175T105 193Q133 193 151 175T169 130Q169 119 166 110T159 94T148 82T136 74T126 70T118 67L114 66Q165 21 238 21Q293 21 321 74Q338 107 338 175V195Q338 290 274 322Q259 328 213 329L171 330L168 332Q166 335 166 348Q166 366 174 366Q202 366 232 371Q266 376 294 413T322 525V533Q322 590 287 612Q265 626 240 626Q208 626 181 615T143 592T132 580H135Q138 579 143 578T153 573T165 566T175 555T183 540T186 520Q186 498 172 481T127 463Z"/><path stroke-width="1" id="E17-MJMAIN-5D" d="M22 710V750H159V-250H22V-210H119V710H22Z"/><path stroke-width="1" id="E17-MJSZ4-23A1" d="M319 -645V1154H666V1070H403V-645H319Z"/><path stroke-width="1" id="E17-MJSZ4-23A3" d="M319 -644V1155H403V-560H666V-644H319Z"/><path stroke-width="1" id="E17-MJSZ4-23A2" d="M319 0V602H403V0H319Z"/><path stroke-width="1" id="E17-MJSZ4-23A4" d="M0 1070V1154H347V-645H263V1070H0Z"/><path stroke-width="1" id="E17-MJSZ4-23A6" d="M263 -560V1155H347V-644H0V-560H263Z"/><path stroke-width="1" id="E17-MJSZ4-23A5" d="M263 0V602H347V0H263Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><g transform="translate(0,2150)"><use xlink:href="#E17-MJSZ4-23A1" x="0" y="-1155"/><g transform="translate(0,-2048.5066225165565) scale(1,0.49337748344370863)"><use xlink:href="#E17-MJSZ4-23A2"/></g><use xlink:href="#E17-MJSZ4-23A3" x="0" y="-3155"/></g><g transform="translate(834,0)"><g transform="translate(-14,0)"><use xlink:href="#E17-MJMAIN-31" x="0" y="1350"/><use xlink:href="#E17-MJMAIN-32" x="0" y="-50"/><use xlink:href="#E17-MJMAIN-33" x="0" y="-1450"/></g></g><g transform="translate(1488,2150)"><use xlink:href="#E17-MJSZ4-23A4" x="0" y="-1155"/><g transform="translate(0,-2048.5066225165565) scale(1,0.49337748344370863)"><use xlink:href="#E17-MJSZ4-23A5"/></g><use xlink:href="#E17-MJSZ4-23A6" x="0" y="-3155"/></g></g></svg></span><script type="math/tex" id="MathJax-Element-17">\begin{bmatrix}1 \\2\\3\end{bmatrix}</script>,Y = <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-18-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.006ex" height="9.134ex" viewbox="0 -2208.6 2155.6 3932.8" role="img" focusable="false" style="vertical-align: -4.005ex;"><defs><path stroke-width="1" id="E18-MJMAIN-5B" d="M118 -250V750H255V710H158V-210H255V-250H118Z"/><path stroke-width="1" id="E18-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E18-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"/><path stroke-width="1" id="E18-MJMAIN-33" d="M127 463Q100 463 85 480T69 524Q69 579 117 622T233 665Q268 665 277 664Q351 652 390 611T430 522Q430 470 396 421T302 350L299 348Q299 347 308 345T337 336T375 315Q457 262 457 175Q457 96 395 37T238 -22Q158 -22 100 21T42 130Q42 158 60 175T105 193Q133 193 151 175T169 130Q169 119 166 110T159 94T148 82T136 74T126 70T118 67L114 66Q165 21 238 21Q293 21 321 74Q338 107 338 175V195Q338 290 274 322Q259 328 213 329L171 330L168 332Q166 335 166 348Q166 366 174 366Q202 366 232 371Q266 376 294 413T322 525V533Q322 590 287 612Q265 626 240 626Q208 626 181 615T143 592T132 580H135Q138 579 143 578T153 573T165 566T175 555T183 540T186 520Q186 498 172 481T127 463Z"/><path stroke-width="1" id="E18-MJMAIN-5D" d="M22 710V750H159V-250H22V-210H119V710H22Z"/><path stroke-width="1" id="E18-MJSZ4-23A1" d="M319 -645V1154H666V1070H403V-645H319Z"/><path stroke-width="1" id="E18-MJSZ4-23A3" d="M319 -644V1155H403V-560H666V-644H319Z"/><path stroke-width="1" id="E18-MJSZ4-23A2" d="M319 0V602H403V0H319Z"/><path stroke-width="1" id="E18-MJSZ4-23A4" d="M0 1070V1154H347V-645H263V1070H0Z"/><path stroke-width="1" id="E18-MJSZ4-23A6" d="M263 -560V1155H347V-644H0V-560H263Z"/><path stroke-width="1" id="E18-MJSZ4-23A5" d="M263 0V602H347V0H263Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><g transform="translate(0,2150)"><use xlink:href="#E18-MJSZ4-23A1" x="0" y="-1155"/><g transform="translate(0,-2048.5066225165565) scale(1,0.49337748344370863)"><use xlink:href="#E18-MJSZ4-23A2"/></g><use xlink:href="#E18-MJSZ4-23A3" x="0" y="-3155"/></g><g transform="translate(834,0)"><g transform="translate(-14,0)"><use xlink:href="#E18-MJMAIN-31" x="0" y="1350"/><use xlink:href="#E18-MJMAIN-32" x="0" y="-50"/><use xlink:href="#E18-MJMAIN-33" x="0" y="-1450"/></g></g><g transform="translate(1488,2150)"><use xlink:href="#E18-MJSZ4-23A4" x="0" y="-1155"/><g transform="translate(0,-2048.5066225165565) scale(1,0.49337748344370863)"><use xlink:href="#E18-MJSZ4-23A5"/></g><use xlink:href="#E18-MJSZ4-23A6" x="0" y="-3155"/></g></g></svg></span><script type="math/tex" id="MathJax-Element-18">\begin{bmatrix}1\\2\\3\end{bmatrix}</script>,we can plot it in octave as below:</p><p><img src="https://ws3.sinaimg.cn/large/006tNbRwgy1fg3r6bw0f8j30xc0p0dgd.jpg" alt="graph1"></p><p>suppose h<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-71-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.09ex" height="2.134ex" viewbox="0 -809.3 469.5 918.9" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E71-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E71-MJMATHI-3B8" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-71">\theta</script> = <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-20-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="3.474ex" height="2.384ex" viewbox="0 -809.3 1495.9 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E20-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E20-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E20-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E20-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E20-MJMAIN-31" x="663" y="-213"/><use xlink:href="#E20-MJMATHI-78" x="923" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-20">\theta_1x </script>+ <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-40-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.509ex" viewbox="0 -809.3 923.4 1080.4" role="img" focusable="false" style="vertical-align: -0.63ex;"><defs><path stroke-width="1" id="E40-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E40-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E40-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E40-MJMAIN-30" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-40">\theta_0</script> (<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-40-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.509ex" viewbox="0 -809.3 923.4 1080.4" role="img" focusable="false" style="vertical-align: -0.63ex;"><defs><path stroke-width="1" id="E40-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E40-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E40-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E40-MJMAIN-30" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-40">\theta_0</script> = 0);as <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script> = 2,<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-24-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="8.215ex" height="2.384ex" viewbox="0 -809.3 3537 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E24-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E24-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E24-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E24-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/><path stroke-width="1" id="E24-MJMAIN-2E" d="M78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"/><path stroke-width="1" id="E24-MJMAIN-35" d="M164 157Q164 133 148 117T109 101H102Q148 22 224 22Q294 22 326 82Q345 115 345 210Q345 313 318 349Q292 382 260 382H254Q176 382 136 314Q132 307 129 306T114 304Q97 304 95 310Q93 314 93 485V614Q93 664 98 664Q100 666 102 666Q103 666 123 658T178 642T253 634Q324 634 389 662Q397 666 402 666Q410 666 410 648V635Q328 538 205 538Q174 538 149 544L139 546V374Q158 388 169 396T205 412T256 420Q337 420 393 355T449 201Q449 109 385 44T229 -22Q148 -22 99 32T50 154Q50 178 61 192T84 210T107 214Q132 214 148 197T164 157Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E24-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E24-MJMAIN-31" x="663" y="-213"/><use xlink:href="#E24-MJMAIN-3D" x="1201" y="0"/><g transform="translate(2257,0)"><use xlink:href="#E24-MJMAIN-30"/><use xlink:href="#E24-MJMAIN-2E" x="500" y="0"/><use xlink:href="#E24-MJMAIN-35" x="779" y="0"/></g></g></svg></span><script type="math/tex" id="MathJax-Element-24">\theta_1 = 0.5</script>,<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script> = 1,the figure as:<img src="https://ws2.sinaimg.cn/large/006tNbRwgy1fg3r6dvt97j30xc0p0jsw.jpg" alt="figure1"></p><p>and when <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script> =  2, J(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-27-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="3.049ex" height="2.634ex" viewbox="0 -809.3 1312.9 1134.2" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E27-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E27-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E27-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E27-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E27-MJMAIN-31" x="663" y="-213"/><use xlink:href="#E27-MJMAIN-29" x="923" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-27">\theta_1) </script> = 2.3333; when <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script> =  0.5, J(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script>)  = 0.58333; when <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script> =  1, J(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script>)  = 0, so when J(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script>)  = 0,it&#39;s more fit data.</p><p>the relationship between J(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script>) and <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script> is:</p><p><img src="https://ws3.sinaimg.cn/large/006tNbRwgy1fg3r6b05g4j30xc0p0aax.jpg" alt="figure2">If you have more data, you can see that this is a square function as shown above.when J(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script>) approach 0,it&#39;s converges to approach  minimum and more fit data.So <strong>cost function is usually used to measure accuracy of our hypothesis function</strong>.</p><h5 id="42gradient-descent"><a name="header-c140" class="md-header-anchor "></a>4.2Gradient Descent</h5><p>So we have our hypothesis function and we have a way of measuring how well it fits into the data. Now we need to estimate the parameters in the hypothesis function. That&#39;s where gradient descent comes in.</p><p>The gradient descent algorithm is:</p><p>repeat until convergence:</p><p><span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-36-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2ex" height="2.759ex" viewbox="0 -809.3 861.2 1188" role="img" focusable="false" style="vertical-align: -0.88ex;"><defs><path stroke-width="1" id="E36-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E36-MJMATHI-6A" d="M297 596Q297 627 318 644T361 661Q378 661 389 651T403 623Q403 595 384 576T340 557Q322 557 310 567T297 596ZM288 376Q288 405 262 405Q240 405 220 393T185 362T161 325T144 293L137 279Q135 278 121 278H107Q101 284 101 286T105 299Q126 348 164 391T252 441Q253 441 260 441T272 442Q296 441 316 432Q341 418 354 401T367 348V332L318 133Q267 -67 264 -75Q246 -125 194 -164T75 -204Q25 -204 7 -183T-12 -137Q-12 -110 7 -91T53 -71Q70 -71 82 -81T95 -112Q95 -148 63 -167Q69 -168 77 -168Q111 -168 139 -140T182 -74L193 -32Q204 11 219 72T251 197T278 308T289 365Q289 372 288 376Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E36-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E36-MJMATHI-6A" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-36">\theta_j </script>:= <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-74-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2ex" height="2.759ex" viewbox="0 -809.3 861.2 1188" role="img" focusable="false" style="vertical-align: -0.88ex;"><defs><path stroke-width="1" id="E74-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E74-MJMATHI-6A" d="M297 596Q297 627 318 644T361 661Q378 661 389 651T403 623Q403 595 384 576T340 557Q322 557 310 567T297 596ZM288 376Q288 405 262 405Q240 405 220 393T185 362T161 325T144 293L137 279Q135 278 121 278H107Q101 284 101 286T105 299Q126 348 164 391T252 441Q253 441 260 441T272 442Q296 441 316 432Q341 418 354 401T367 348V332L318 133Q267 -67 264 -75Q246 -125 194 -164T75 -204Q25 -204 7 -183T-12 -137Q-12 -110 7 -91T53 -71Q70 -71 82 -81T95 -112Q95 -148 63 -167Q69 -168 77 -168Q111 -168 139 -140T182 -74L193 -32Q204 11 219 72T251 197T278 308T289 365Q289 372 288 376Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E74-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E74-MJMATHI-6A" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-74">\theta_j</script> - <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-38-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.488ex" height="1.509ex" viewbox="0 -540.2 640.5 649.8" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E38-MJMATHI-3B1" d="M34 156Q34 270 120 356T309 442Q379 442 421 402T478 304Q484 275 485 237V208Q534 282 560 374Q564 388 566 390T582 393Q603 393 603 385Q603 376 594 346T558 261T497 161L486 147L487 123Q489 67 495 47T514 26Q528 28 540 37T557 60Q559 67 562 68T577 70Q597 70 597 62Q597 56 591 43Q579 19 556 5T512 -10H505Q438 -10 414 62L411 69L400 61Q390 53 370 41T325 18T267 -2T203 -11Q124 -11 79 39T34 156ZM208 26Q257 26 306 47T379 90L403 112Q401 255 396 290Q382 405 304 405Q235 405 183 332Q156 292 139 224T121 120Q121 71 146 49T208 26Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E38-MJMATHI-3B1" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-38">\alpha</script> <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-39-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.48ex" height="3.634ex" viewbox="0 -1024.6 1067.8 1564.8" role="img" focusable="false" style="vertical-align: -1.255ex;"><defs><path stroke-width="1" id="E39-MJMAIN-2202" d="M202 508Q179 508 169 520T158 547Q158 557 164 577T185 624T230 675T301 710L333 715H345Q378 715 384 714Q447 703 489 661T549 568T566 457Q566 362 519 240T402 53Q321 -22 223 -22Q123 -22 73 56Q42 102 42 148V159Q42 276 129 370T322 465Q383 465 414 434T455 367L458 378Q478 461 478 515Q478 603 437 639T344 676Q266 676 223 612Q264 606 264 572Q264 547 246 528T202 508ZM430 306Q430 372 401 400T333 428Q270 428 222 382Q197 354 183 323T150 221Q132 149 132 116Q132 21 232 21Q244 21 250 22Q327 35 374 112Q389 137 409 196T430 306Z"/><path stroke-width="1" id="E39-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><g transform="translate(120,0)"><rect stroke="none" width="827" height="60" x="0" y="220"/><use transform="scale(0.707)" xlink:href="#E39-MJMAIN-2202" x="319" y="604"/><g transform="translate(60,-418)"><use transform="scale(0.707)" xlink:href="#E39-MJMAIN-2202" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E39-MJMATHI-3B8" x="531" y="0"/></g></g></g></svg></span><script type="math/tex" id="MathJax-Element-39">\frac{∂}{∂\theta}</script>J (<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-40-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.509ex" viewbox="0 -809.3 923.4 1080.4" role="img" focusable="false" style="vertical-align: -0.63ex;"><defs><path stroke-width="1" id="E40-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E40-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E40-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E40-MJMAIN-30" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-40">\theta_0</script>,<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-41-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.145ex" height="2.384ex" viewbox="0 -809.3 923.4 1026.6" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E41-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E41-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E41-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E41-MJMAIN-31" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-41">\theta_1</script>)</p><h5 id="43-gradient-descent-for-linear-regression"><a name="header-c149" class="md-header-anchor "></a>4.3 Gradient Descent For Linear Regression</h5><p>when we applied to the case of linear regression, a new gradient equation that is called <strong>batch gradient descent</strong> can be derived. as below shown:</p><p>Gradient Descent for Multiple Variables:</p><p>repeat until convergence:{</p><div class="mathjax-block" contenteditable="false" style="" cid="c155" mdtype="math_block" id="math-jaxc155"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-1127-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="36.013ex" height="6.884ex" viewbox="0 -1670.4 15505.7 2964.1" role="img" focusable="false" style="vertical-align: -3.005ex;"><defs><path stroke-width="1" id="E1187-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E1187-MJMATHI-6A" d="M297 596Q297 627 318 644T361 661Q378 661 389 651T403 623Q403 595 384 576T340 557Q322 557 310 567T297 596ZM288 376Q288 405 262 405Q240 405 220 393T185 362T161 325T144 293L137 279Q135 278 121 278H107Q101 284 101 286T105 299Q126 348 164 391T252 441Q253 441 260 441T272 442Q296 441 316 432Q341 418 354 401T367 348V332L318 133Q267 -67 264 -75Q246 -125 194 -164T75 -204Q25 -204 7 -183T-12 -137Q-12 -110 7 -91T53 -71Q70 -71 82 -81T95 -112Q95 -148 63 -167Q69 -168 77 -168Q111 -168 139 -140T182 -74L193 -32Q204 11 219 72T251 197T278 308T289 365Q289 372 288 376Z"/><path stroke-width="1" id="E1187-MJMAIN-3A" d="M78 370Q78 394 95 412T138 430Q162 430 180 414T199 371Q199 346 182 328T139 310T96 327T78 370ZM78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"/><path stroke-width="1" id="E1187-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E1187-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E1187-MJMATHI-61" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"/><path stroke-width="1" id="E1187-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E1187-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1187-MJSZ2-2211" d="M60 948Q63 950 665 950H1267L1325 815Q1384 677 1388 669H1348L1341 683Q1320 724 1285 761Q1235 809 1174 838T1033 881T882 898T699 902H574H543H251L259 891Q722 258 724 252Q725 250 724 246Q721 243 460 -56L196 -356Q196 -357 407 -357Q459 -357 548 -357T676 -358Q812 -358 896 -353T1063 -332T1204 -283T1307 -196Q1328 -170 1348 -124H1388Q1388 -125 1381 -145T1356 -210T1325 -294L1267 -449L666 -450Q64 -450 61 -448Q55 -446 55 -439Q55 -437 57 -433L590 177Q590 178 557 222T452 366T322 544L56 909L55 924Q55 945 60 948Z"/><path stroke-width="1" id="E1187-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1187-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E1187-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E1187-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E1187-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E1187-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E1187-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1187-MJMATHI-6A" x="663" y="-213"/><g transform="translate(1138,0)"><use xlink:href="#E1187-MJMAIN-3A"/><use xlink:href="#E1187-MJMAIN-3D" x="278" y="0"/></g><g transform="translate(2473,0)"><use xlink:href="#E1187-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1187-MJMATHI-6A" x="663" y="-213"/></g><use xlink:href="#E1187-MJMAIN-2212" x="3557" y="0"/><use xlink:href="#E1187-MJMATHI-61" x="4557" y="0"/><g transform="translate(5087,0)"><g transform="translate(120,0)"><rect stroke="none" width="998" height="60" x="0" y="220"/><use xlink:href="#E1187-MJMAIN-31" x="249" y="676"/><use xlink:href="#E1187-MJMATHI-6D" x="60" y="-686"/></g></g><g transform="translate(6492,0)"><use xlink:href="#E1187-MJSZ2-2211" x="0" y="0"/><g transform="translate(147,-1090)"><use transform="scale(0.707)" xlink:href="#E1187-MJMATHI-69" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1187-MJMAIN-3D" x="345" y="0"/><use transform="scale(0.707)" xlink:href="#E1187-MJMAIN-31" x="1124" y="0"/></g><use transform="scale(0.707)" xlink:href="#E1187-MJMATHI-6D" x="582" y="1627"/></g><use xlink:href="#E1187-MJMAIN-28" x="7937" y="0"/><g transform="translate(8326,0)"><use xlink:href="#E1187-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1187-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E1187-MJMAIN-28" x="9335" y="0"/><g transform="translate(9724,0)"><use xlink:href="#E1187-MJMATHI-78" x="0" y="0"/><g transform="translate(572,412)"><use transform="scale(0.707)" xlink:href="#E1187-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1187-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1187-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E1187-MJMAIN-29" x="11192" y="0"/><use xlink:href="#E1187-MJMAIN-2212" x="11803" y="0"/><g transform="translate(12804,0)"><use xlink:href="#E1187-MJMATHI-79" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1187-MJMATHI-69" x="706" y="583"/></g><use xlink:href="#E1187-MJMAIN-29" x="13648" y="0"/><g transform="translate(14038,0)"><use xlink:href="#E1187-MJMATHI-78" x="0" y="0"/><g transform="translate(572,521)"><use transform="scale(0.707)" xlink:href="#E1187-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1187-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1187-MJMAIN-29" x="734" y="0"/></g><use transform="scale(0.707)" xlink:href="#E1187-MJMATHI-6A" x="809" y="-430"/></g></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-1127">
\theta_j := \theta_j - a\frac{1}{m}\sum_{i = 1}^{m}(h_\theta(x^{(i)}) - y^{i})  x_{j}^{(i)}
</script></div><p>}</p><h5 id="44-linear-regression-feature-scaling"><a name="header-c159" class="md-header-anchor "></a>4.4 Linear Regression Feature Scaling</h5><p>we can speed up gradient descent by having each of input values <strong>in roughly the same range</strong>.because <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-71-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.09ex" height="2.134ex" viewbox="0 -809.3 469.5 918.9" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E71-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E71-MJMATHI-3B8" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-71">\theta</script> will descend quickly on small ranges and slowly on large ranges, and so will oscillate inefficiently down to the optimum when the variables are very uneven.</p><p>Ideally:</p><p>−1 ≤ x(i) ≤ 1</p><p>Two techniques to help with this are <strong>feature scaling</strong> and <strong>mean normalization</strong>:</p><p><span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-43-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.129ex" height="1.759ex" viewbox="0 -540.2 916.8 757.5" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E43-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E43-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E43-MJMATHI-78" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E43-MJMATHI-69" x="809" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-43">x_i</script> := <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-44-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.126ex" height="3.384ex" viewbox="0 -916.9 2207 1457.1" role="img" focusable="false" style="vertical-align: -1.255ex;"><defs><path stroke-width="1" id="E44-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E44-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E44-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E44-MJMATHI-75" d="M21 287Q21 295 30 318T55 370T99 420T158 442Q204 442 227 417T250 358Q250 340 216 246T182 105Q182 62 196 45T238 27T291 44T328 78L339 95Q341 99 377 247Q407 367 413 387T427 416Q444 431 463 431Q480 431 488 421T496 402L420 84Q419 79 419 68Q419 43 426 35T447 26Q469 29 482 57T512 145Q514 153 532 153Q551 153 551 144Q550 139 549 130T540 98T523 55T498 17T462 -8Q454 -10 438 -10Q372 -10 347 46Q345 45 336 36T318 21T296 6T267 -6T233 -11Q189 -11 155 7Q103 38 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E44-MJMATHI-73" d="M131 289Q131 321 147 354T203 415T300 442Q362 442 390 415T419 355Q419 323 402 308T364 292Q351 292 340 300T328 326Q328 342 337 354T354 372T367 378Q368 378 368 379Q368 382 361 388T336 399T297 405Q249 405 227 379T204 326Q204 301 223 291T278 274T330 259Q396 230 396 163Q396 135 385 107T352 51T289 7T195 -10Q118 -10 86 19T53 87Q53 126 74 143T118 160Q133 160 146 151T160 120Q160 94 142 76T111 58Q109 57 108 57T107 55Q108 52 115 47T146 34T201 27Q237 27 263 38T301 66T318 97T323 122Q323 150 302 164T254 181T195 196T148 231Q131 256 131 289Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><g transform="translate(120,0)"><rect stroke="none" width="1967" height="60" x="0" y="220"/><g transform="translate(60,522)"><use transform="scale(0.707)" xlink:href="#E44-MJMATHI-78" x="0" y="0"/><use transform="scale(0.5)" xlink:href="#E44-MJMATHI-69" x="809" y="-213"/><use transform="scale(0.707)" xlink:href="#E44-MJMAIN-2212" x="916" y="0"/><g transform="translate(1198,0)"><use transform="scale(0.707)" xlink:href="#E44-MJMATHI-75" x="0" y="0"/><use transform="scale(0.5)" xlink:href="#E44-MJMATHI-69" x="809" y="-213"/></g></g><g transform="translate(695,-345)"><use transform="scale(0.707)" xlink:href="#E44-MJMATHI-73" x="0" y="0"/><use transform="scale(0.5)" xlink:href="#E44-MJMATHI-69" x="663" y="-213"/></g></g></g></svg></span><script type="math/tex" id="MathJax-Element-44">\frac{x_i - u_i}{s_i}</script></p><p><span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-45-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.129ex" height="1.759ex" viewbox="0 -540.2 916.8 757.5" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E45-MJMATHI-75" d="M21 287Q21 295 30 318T55 370T99 420T158 442Q204 442 227 417T250 358Q250 340 216 246T182 105Q182 62 196 45T238 27T291 44T328 78L339 95Q341 99 377 247Q407 367 413 387T427 416Q444 431 463 431Q480 431 488 421T496 402L420 84Q419 79 419 68Q419 43 426 35T447 26Q469 29 482 57T512 145Q514 153 532 153Q551 153 551 144Q550 139 549 130T540 98T523 55T498 17T462 -8Q454 -10 438 -10Q372 -10 347 46Q345 45 336 36T318 21T296 6T267 -6T233 -11Q189 -11 155 7Q103 38 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E45-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E45-MJMATHI-75" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E45-MJMATHI-69" x="809" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-45">u_i</script> is the average of all the values for feature(i) and <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-47-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.89ex" height="1.759ex" viewbox="0 -540.2 813.8 757.5" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E47-MJMATHI-73" d="M131 289Q131 321 147 354T203 415T300 442Q362 442 390 415T419 355Q419 323 402 308T364 292Q351 292 340 300T328 326Q328 342 337 354T354 372T367 378Q368 378 368 379Q368 382 361 388T336 399T297 405Q249 405 227 379T204 326Q204 301 223 291T278 274T330 259Q396 230 396 163Q396 135 385 107T352 51T289 7T195 -10Q118 -10 86 19T53 87Q53 126 74 143T118 160Q133 160 146 151T160 120Q160 94 142 76T111 58Q109 57 108 57T107 55Q108 52 115 47T146 34T201 27Q237 27 263 38T301 66T318 97T323 122Q323 150 302 164T254 181T195 196T148 231Q131 256 131 289Z"/><path stroke-width="1" id="E47-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E47-MJMATHI-73" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E47-MJMATHI-69" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-47">s_i</script> is the range of values(max - min),or <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-47-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.89ex" height="1.759ex" viewbox="0 -540.2 813.8 757.5" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E47-MJMATHI-73" d="M131 289Q131 321 147 354T203 415T300 442Q362 442 390 415T419 355Q419 323 402 308T364 292Q351 292 340 300T328 326Q328 342 337 354T354 372T367 378Q368 378 368 379Q368 382 361 388T336 399T297 405Q249 405 227 379T204 326Q204 301 223 291T278 274T330 259Q396 230 396 163Q396 135 385 107T352 51T289 7T195 -10Q118 -10 86 19T53 87Q53 126 74 143T118 160Q133 160 146 151T160 120Q160 94 142 76T111 58Q109 57 108 57T107 55Q108 52 115 47T146 34T201 27Q237 27 263 38T301 66T318 97T323 122Q323 150 302 164T254 181T195 196T148 231Q131 256 131 289Z"/><path stroke-width="1" id="E47-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E47-MJMATHI-73" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E47-MJMATHI-69" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-47">s_i</script> is the standard deviation.</p><h5 id="45-polynomial-regression"><a name="header-c172" class="md-header-anchor "></a>4.5 Polynomial Regression</h5><p>Our hypothesis need not be linear(a straight line)if that does fit the data well.</p><p>we can <strong>change behavior and curve</strong> of our hypothesis function by making quadratic,cubic or square root function.</p><p>One important thing to keep in mind is, if you choose your features this way then feature scaling becomes very important.</p><p>eg. if x1 has range 1 - 1000 then range of x21 becomes 1 - 1000000 and that of x31 becomes 1 - 1000000000.</p><h5 id="46-linear-regresstion-normal-equation"><a name="header-c181" class="md-header-anchor "></a>4.6 Linear Regresstion Normal Equation</h5><p>Gradient descent gives one way of minizing J.Let&#39;s discuss a second way of doing so,this time performing the minimization explicitly and without resoring to an iterative algorithm.the normal equation formula is given below:</p><div contenteditable="false" class="mathjax-block md-end-block" id="mathjax-c183" cid="c183" mdtype="math_block"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-4-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="20.433ex" height="3.009ex" viewbox="0 -970.7 8797.7 1295.7" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E4-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E4-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E4-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E4-MJMATHI-58" d="M42 0H40Q26 0 26 11Q26 15 29 27Q33 41 36 43T55 46Q141 49 190 98Q200 108 306 224T411 342Q302 620 297 625Q288 636 234 637H206Q200 643 200 645T202 664Q206 677 212 683H226Q260 681 347 681Q380 681 408 681T453 682T473 682Q490 682 490 671Q490 670 488 658Q484 643 481 640T465 637Q434 634 411 620L488 426L541 485Q646 598 646 610Q646 628 622 635Q617 635 609 637Q594 637 594 648Q594 650 596 664Q600 677 606 683H618Q619 683 643 683T697 681T738 680Q828 680 837 683H845Q852 676 852 672Q850 647 840 637H824Q790 636 763 628T722 611T698 593L687 584Q687 585 592 480L505 384Q505 383 536 304T601 142T638 56Q648 47 699 46Q734 46 734 37Q734 35 732 23Q728 7 725 4T711 1Q708 1 678 1T589 2Q528 2 496 2T461 1Q444 1 444 10Q444 11 446 25Q448 35 450 39T455 44T464 46T480 47T506 54Q523 62 523 64Q522 64 476 181L429 299Q241 95 236 84Q232 76 232 72Q232 53 261 47Q262 47 267 47T273 46Q276 46 277 46T280 45T283 42T284 35Q284 26 282 19Q279 6 276 4T261 1Q258 1 243 1T201 2T142 2Q64 2 42 0Z"/><path stroke-width="1" id="E4-MJMATHI-54" d="M40 437Q21 437 21 445Q21 450 37 501T71 602L88 651Q93 669 101 677H569H659Q691 677 697 676T704 667Q704 661 687 553T668 444Q668 437 649 437Q640 437 637 437T631 442L629 445Q629 451 635 490T641 551Q641 586 628 604T573 629Q568 630 515 631Q469 631 457 630T439 622Q438 621 368 343T298 60Q298 48 386 46Q418 46 427 45T436 36Q436 31 433 22Q429 4 424 1L422 0Q419 0 415 0Q410 0 363 1T228 2Q99 2 64 0H49Q43 6 43 9T45 27Q49 40 55 46H83H94Q174 46 189 55Q190 56 191 56Q196 59 201 76T241 233Q258 301 269 344Q339 619 339 625Q339 630 310 630H279Q212 630 191 624Q146 614 121 583T67 467Q60 445 57 441T43 437H40Z"/><path stroke-width="1" id="E4-MJMAIN-2217" d="M229 286Q216 420 216 436Q216 454 240 464Q241 464 245 464T251 465Q263 464 273 456T283 436Q283 419 277 356T270 286L328 328Q384 369 389 372T399 375Q412 375 423 365T435 338Q435 325 425 315Q420 312 357 282T289 250L355 219L425 184Q434 175 434 161Q434 146 425 136T401 125Q393 125 383 131T328 171L270 213Q283 79 283 63Q283 53 276 44T250 35Q231 35 224 44T216 63Q216 80 222 143T229 213L171 171Q115 130 110 127Q106 124 100 124Q87 124 76 134T64 161Q64 166 64 169T67 175T72 181T81 188T94 195T113 204T138 215T170 230T210 250L74 315Q65 324 65 338Q65 353 74 363T98 374Q106 374 116 368T171 328L229 286Z"/><path stroke-width="1" id="E4-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E4-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E4-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E4-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E4-MJMATHI-3B8" x="0" y="0"/><use xlink:href="#E4-MJMAIN-3D" x="747" y="0"/><use xlink:href="#E4-MJMAIN-28" x="1803" y="0"/><g transform="translate(2193,0)"><use xlink:href="#E4-MJMATHI-58" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E4-MJMATHI-54" x="1215" y="583"/></g><use xlink:href="#E4-MJMAIN-2217" x="3873" y="0"/><use xlink:href="#E4-MJMATHI-58" x="4595" y="0"/><g transform="translate(5448,0)"><use xlink:href="#E4-MJMAIN-29" x="0" y="0"/><g transform="translate(389,412)"><use transform="scale(0.707)" xlink:href="#E4-MJMAIN-2212" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E4-MJMAIN-31" x="778" y="0"/></g></g><g transform="translate(6842,0)"><use xlink:href="#E4-MJMATHI-58" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E4-MJMATHI-54" x="1215" y="583"/></g><use xlink:href="#E4-MJMATHI-79" x="8300" y="0"/></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-4">
\theta = (X^T * X)^{-1} X^Ty
</script></div><p>The following is a comparison of gradient descent and the normal equation:</p><table><thead><tr><th>Gradient Descent</th><th>Normal equation</th></tr></thead><tbody><tr><td>Need to choose alpha</td><td>No need choose alpha</td></tr><tr><td>Need many iteration</td><td>No need to iterate</td></tr><tr><td>O(k<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-48-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.449ex" height="2.384ex" viewbox="0 -916.9 1054.4 1026.6" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E48-MJMATHI-6E" d="M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E48-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E48-MJMATHI-6E" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E48-MJMAIN-32" x="849" y="513"/></g></svg></span><script type="math/tex" id="MathJax-Element-48">n^2</script>)</td><td>O(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-49-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.449ex" height="2.384ex" viewbox="0 -916.9 1054.4 1026.6" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E49-MJMATHI-6E" d="M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E49-MJMAIN-33" d="M127 463Q100 463 85 480T69 524Q69 579 117 622T233 665Q268 665 277 664Q351 652 390 611T430 522Q430 470 396 421T302 350L299 348Q299 347 308 345T337 336T375 315Q457 262 457 175Q457 96 395 37T238 -22Q158 -22 100 21T42 130Q42 158 60 175T105 193Q133 193 151 175T169 130Q169 119 166 110T159 94T148 82T136 74T126 70T118 67L114 66Q165 21 238 21Q293 21 321 74Q338 107 338 175V195Q338 290 274 322Q259 328 213 329L171 330L168 332Q166 335 166 348Q166 366 174 366Q202 366 232 371Q266 376 294 413T322 525V533Q322 590 287 612Q265 626 240 626Q208 626 181 615T143 592T132 580H135Q138 579 143 578T153 573T165 566T175 555T183 540T186 520Q186 498 172 481T127 463Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E49-MJMATHI-6E" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E49-MJMAIN-33" x="849" y="513"/></g></svg></span><script type="math/tex" id="MathJax-Element-49">n^3</script>),need to calculate inverse of <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-50-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="3.386ex" height="2.384ex" viewbox="0 -916.9 1457.9 1026.6" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E50-MJMATHI-58" d="M42 0H40Q26 0 26 11Q26 15 29 27Q33 41 36 43T55 46Q141 49 190 98Q200 108 306 224T411 342Q302 620 297 625Q288 636 234 637H206Q200 643 200 645T202 664Q206 677 212 683H226Q260 681 347 681Q380 681 408 681T453 682T473 682Q490 682 490 671Q490 670 488 658Q484 643 481 640T465 637Q434 634 411 620L488 426L541 485Q646 598 646 610Q646 628 622 635Q617 635 609 637Q594 637 594 648Q594 650 596 664Q600 677 606 683H618Q619 683 643 683T697 681T738 680Q828 680 837 683H845Q852 676 852 672Q850 647 840 637H824Q790 636 763 628T722 611T698 593L687 584Q687 585 592 480L505 384Q505 383 536 304T601 142T638 56Q648 47 699 46Q734 46 734 37Q734 35 732 23Q728 7 725 4T711 1Q708 1 678 1T589 2Q528 2 496 2T461 1Q444 1 444 10Q444 11 446 25Q448 35 450 39T455 44T464 46T480 47T506 54Q523 62 523 64Q522 64 476 181L429 299Q241 95 236 84Q232 76 232 72Q232 53 261 47Q262 47 267 47T273 46Q276 46 277 46T280 45T283 42T284 35Q284 26 282 19Q279 6 276 4T261 1Q258 1 243 1T201 2T142 2Q64 2 42 0Z"/><path stroke-width="1" id="E50-MJMATHI-54" d="M40 437Q21 437 21 445Q21 450 37 501T71 602L88 651Q93 669 101 677H569H659Q691 677 697 676T704 667Q704 661 687 553T668 444Q668 437 649 437Q640 437 637 437T631 442L629 445Q629 451 635 490T641 551Q641 586 628 604T573 629Q568 630 515 631Q469 631 457 630T439 622Q438 621 368 343T298 60Q298 48 386 46Q418 46 427 45T436 36Q436 31 433 22Q429 4 424 1L422 0Q419 0 415 0Q410 0 363 1T228 2Q99 2 64 0H49Q43 6 43 9T45 27Q49 40 55 46H83H94Q174 46 189 55Q190 56 191 56Q196 59 201 76T241 233Q258 301 269 344Q339 619 339 625Q339 630 310 630H279Q212 630 191 624Q146 614 121 583T67 467Q60 445 57 441T43 437H40Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E50-MJMATHI-58" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E50-MJMATHI-54" x="1215" y="513"/></g></svg></span><script type="math/tex" id="MathJax-Element-50">X^T</script>X</td></tr><tr><td>Work well when n is large</td><td>Slow if n is large</td></tr></tbody></table><p>To summarize regression of the bove:</p><div class="md-diagram-panel" mdtype="math_block"><svg id="mermaidChart2" width="696.75" xmlns="http://www.w3.org/2000/svg" height="366" viewbox="0 0 716.75 386" style="height: 426px;"><g><g class="output"><g class="clusters"><g class="edgePaths"><g class="edgePath" style="opacity: 1;"><path class="path" d="M297.75,53.38162162162162L122.5,89L122.5,114" marker-end="url(#arrowhead64)" style="fill:none"/><defs><marker id="arrowhead64" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M122.5,158L122.5,183L122.5,208" marker-end="url(#arrowhead65)" style="fill:none"/><defs><marker id="arrowhead65" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M353.75,64L353.75,89L353.75,114" marker-end="url(#arrowhead66)" style="fill:none"/><defs><marker id="arrowhead66" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M379.02659574468083,158L407.75,183L407.75,208" marker-end="url(#arrowhead67)" style="fill:none"/><defs><marker id="arrowhead67" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M409.75,52.528L603.75,89L603.75,136L603.75,183L603.75,208" marker-end="url(#arrowhead68)" style="fill:none"/><defs><marker id="arrowhead68" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M328.47340425531917,158L299.75,183L299.75,230L299.75,277L357.1968085106383,302" marker-end="url(#arrowhead69)" style="fill:none"/><defs><marker id="arrowhead69" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M407.75,252L407.75,277L407.75,302" marker-end="url(#arrowhead70)" style="fill:none"/><defs><marker id="arrowhead70" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g><g class="edgePath" style="opacity: 1;"><path class="path" d="M603.75,252L603.75,277L499.49468085106383,302" marker-end="url(#arrowhead71)" style="fill:none"/><defs><marker id="arrowhead71" viewbox="0 0 10 10" refx="9" refy="5" markerunits="strokeWidth" markerwidth="8" markerheight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="fill: #333"/></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g><g class="edgeLabel" transform="" style="opacity: 1;"><g transform="translate(0,0)" class="label"><foreignobject width="0" height="0"><div style="display: inline-block; white-space: nowrap;"><span class="edgeLabel"/></div></foreignobject></g></g></g><g class="nodes"><g class="node" id="id" transform="translate(353.75,42)" style="opacity: 1;"><rect rx="5" ry="5" x="-56" y="-22" width="112" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-46,-12)"><foreignobject width="92" height="24"><div style="display: inline-block; white-space: nowrap;">Regresstion</div></foreignobject></g></g></g><g class="node" id="id1" transform="translate(122.5,136)" style="opacity: 1;"><rect rx="5" ry="5" x="-64.5" y="-22" width="129" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-54.5,-12)"><foreignobject width="109" height="24"><div style="display: inline-block; white-space: nowrap;">Cost function</div></foreignobject></g></g></g><g class="node" id="id6" transform="translate(122.5,230)" style="opacity: 1;"><rect rx="5" ry="5" x="-102.5" y="-22" width="205" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-92.5,-12)"><foreignobject width="185" height="24"><div style="display: inline-block; white-space: nowrap;">accuracy of hypothesis</div></foreignobject></g></g></g><g class="node" id="id2" transform="translate(353.75,136)" style="opacity: 1;"><rect rx="5" ry="5" x="-102.5" y="-22" width="205" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-92.5,-12)"><foreignobject width="185" height="24"><div style="display: inline-block; white-space: nowrap;">batch gradient descent</div></foreignobject></g></g></g><g class="node" id="id3" transform="translate(407.75,230)" style="opacity: 1;"><rect rx="5" ry="5" x="-73" y="-22" width="146" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-63,-12)"><foreignobject width="126" height="24"><div style="display: inline-block; white-space: nowrap;">Feature Scaling</div></foreignobject></g></g></g><g class="node" id="id4" transform="translate(603.75,230)" style="opacity: 1;"><rect rx="5" ry="5" x="-73" y="-22" width="146" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-63,-12)"><foreignobject width="126" height="24"><div style="display: inline-block; white-space: nowrap;">Normal Equation</div></foreignobject></g></g></g><g class="node" id="id5" transform="translate(407.75,324)" style="opacity: 1;"><rect rx="5" ry="5" x="-102.5" y="-22" width="205" height="44"/><g class="label" transform="translate(0,0)"><g transform="translate(-92.5,-12)"><foreignobject width="185" height="24"><div style="display: inline-block; white-space: nowrap;">seeking opimal value:θ</div></foreignobject></g></g></g></g></g></g></g></svg></div><h4 id="5classification-regression-problem"><a name="header-c206" class="md-header-anchor "></a>5.Classification Regression Problem</h4><h5 id="51-classifican-hypothesis-representation"><a name="header-c583" class="md-header-anchor "></a>5.1 Classifican Hypothesis Representation</h5><p>Sigmoid Function or Logistic Function:</p><p><span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-75-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.342ex" height="2.384ex" viewbox="0 -755.5 1008.5 1026.6" role="img" focusable="false" style="vertical-align: -0.63ex;"><defs><path stroke-width="1" id="E75-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E75-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E75-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E75-MJMATHI-3B8" x="815" y="-219"/></g></svg></span><script type="math/tex" id="MathJax-Element-75">h_\theta</script>(x) = g(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-52-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.48ex" height="2.384ex" viewbox="0 -916.9 1067.7 1026.6" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E52-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E52-MJMATHI-54" d="M40 437Q21 437 21 445Q21 450 37 501T71 602L88 651Q93 669 101 677H569H659Q691 677 697 676T704 667Q704 661 687 553T668 444Q668 437 649 437Q640 437 637 437T631 442L629 445Q629 451 635 490T641 551Q641 586 628 604T573 629Q568 630 515 631Q469 631 457 630T439 622Q438 621 368 343T298 60Q298 48 386 46Q418 46 427 45T436 36Q436 31 433 22Q429 4 424 1L422 0Q419 0 415 0Q410 0 363 1T228 2Q99 2 64 0H49Q43 6 43 9T45 27Q49 40 55 46H83H94Q174 46 189 55Q190 56 191 56Q196 59 201 76T241 233Q258 301 269 344Q339 619 339 625Q339 630 310 630H279Q212 630 191 624Q146 614 121 583T67 467Q60 445 57 441T43 437H40Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E52-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E52-MJMATHI-54" x="663" y="513"/></g></svg></span><script type="math/tex" id="MathJax-Element-52">\theta^T</script>x)</p><p>z = <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-71-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.09ex" height="2.134ex" viewbox="0 -809.3 469.5 918.9" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E71-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E71-MJMATHI-3B8" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-71">\theta</script>x</p><p>g(z) = <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-54-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.315ex" height="3.509ex" viewbox="0 -970.7 2288.5 1510.9" role="img" focusable="false" style="vertical-align: -1.255ex;"><defs><path stroke-width="1" id="E54-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E54-MJMAIN-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"/><path stroke-width="1" id="E54-MJMATHI-65" d="M39 168Q39 225 58 272T107 350T174 402T244 433T307 442H310Q355 442 388 420T421 355Q421 265 310 237Q261 224 176 223Q139 223 138 221Q138 219 132 186T125 128Q125 81 146 54T209 26T302 45T394 111Q403 121 406 121Q410 121 419 112T429 98T420 82T390 55T344 24T281 -1T205 -11Q126 -11 83 42T39 168ZM373 353Q367 405 305 405Q272 405 244 391T199 357T170 316T154 280T149 261Q149 260 169 260Q282 260 327 284T373 353Z"/><path stroke-width="1" id="E54-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E54-MJMATHI-7A" d="M347 338Q337 338 294 349T231 360Q211 360 197 356T174 346T162 335T155 324L153 320Q150 317 138 317Q117 317 117 325Q117 330 120 339Q133 378 163 406T229 440Q241 442 246 442Q271 442 291 425T329 392T367 375Q389 375 411 408T434 441Q435 442 449 442H462Q468 436 468 434Q468 430 463 420T449 399T432 377T418 358L411 349Q368 298 275 214T160 106L148 94L163 93Q185 93 227 82T290 71Q328 71 360 90T402 140Q406 149 409 151T424 153Q443 153 443 143Q443 138 442 134Q425 72 376 31T278 -11Q252 -11 232 6T193 40T155 57Q111 57 76 -3Q70 -11 59 -11H54H41Q35 -5 35 -2Q35 13 93 84Q132 129 225 214T340 322Q352 338 347 338Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><g transform="translate(120,0)"><rect stroke="none" width="2048" height="60" x="0" y="220"/><use transform="scale(0.707)" xlink:href="#E54-MJMAIN-31" x="1198" y="582"/><g transform="translate(59,-383)"><use transform="scale(0.707)" xlink:href="#E54-MJMAIN-31" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E54-MJMAIN-2B" x="500" y="0"/><g transform="translate(904,0)"><use transform="scale(0.707)" xlink:href="#E54-MJMATHI-65" x="0" y="0"/><g transform="translate(329,204)"><use transform="scale(0.5)" xlink:href="#E54-MJMAIN-2212" x="0" y="0"/><use transform="scale(0.5)" xlink:href="#E54-MJMATHI-7A" x="778" y="0"/></g></g></g></g></g></svg></span><script type="math/tex" id="MathJax-Element-54">\frac{1}{1 + e^{-z}}</script></p><p>The following image shows us what the sigmoid function looks like:<img src="https://ws1.sinaimg.cn/large/006tNbRwgy1fg3r6c9xggj30my03kglx.jpg" alt="1WFqZHntEead-BJkoDOYOw_2413fbec8ff9fa1f19aaf78265b8a33b_Logistic_function">The function g(z),shown here,map any real number to the(0,1)interval</p><p>hθ(x) will give us the <strong>probability</strong> that our output is 1. For example, hθ(x)=0.7 gives us a probability of 70% that our output is 1. Our probability that our prediction is 0 is just the complement of our probability that it is 1 (e.g. if probability that it is 1 is 70%, then the probability that it is 0 is 30%).</p><pre class="md-fences mock-cm" style="display:block;position:relative">hθ(x)=P(y=1|x;θ)=1−P(y=0|x;θ)
P(y=0|x;θ)+P(y=1|x;θ)=1</pre><h5 id="52-decision-boundary"><a name="header-c220" class="md-header-anchor "></a>5.2 Decision Boundary</h5><p>in order to get our discreat 0 or 1 classification,we can translate the output of the hypothesis function as follows:</p><p><span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-75-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.342ex" height="2.384ex" viewbox="0 -755.5 1008.5 1026.6" role="img" focusable="false" style="vertical-align: -0.63ex;"><defs><path stroke-width="1" id="E75-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E75-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E75-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E75-MJMATHI-3B8" x="815" y="-219"/></g></svg></span><script type="math/tex" id="MathJax-Element-75">h_\theta</script>(x)<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-56-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.808ex" height="2.134ex" viewbox="0 -701.7 778.5 918.9" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E56-MJMAIN-2265" d="M83 616Q83 624 89 630T99 636Q107 636 253 568T543 431T687 361Q694 356 694 346T687 331Q685 329 395 192L107 56H101Q83 58 83 76Q83 77 83 79Q82 86 98 95Q117 105 248 167Q326 204 378 228L626 346L360 472Q291 505 200 548Q112 589 98 597T83 616ZM84 -118Q84 -108 99 -98H678Q694 -104 694 -118Q694 -130 679 -138H98Q84 -131 84 -118Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E56-MJMAIN-2265" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-56">\ge</script> 0.5 -&gt; y = 1</p><p><span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-75-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.342ex" height="2.384ex" viewbox="0 -755.5 1008.5 1026.6" role="img" focusable="false" style="vertical-align: -0.63ex;"><defs><path stroke-width="1" id="E75-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E75-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E75-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E75-MJMATHI-3B8" x="815" y="-219"/></g></svg></span><script type="math/tex" id="MathJax-Element-75">h_\theta</script>(x)<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-58-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.808ex" height="2.134ex" viewbox="0 -701.7 778.5 918.9" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E58-MJMAIN-2264" d="M674 636Q682 636 688 630T694 615T687 601Q686 600 417 472L151 346L399 228Q687 92 691 87Q694 81 694 76Q694 58 676 56H670L382 192Q92 329 90 331Q83 336 83 348Q84 359 96 365Q104 369 382 500T665 634Q669 636 674 636ZM84 -118Q84 -108 99 -98H678Q694 -104 694 -118Q694 -130 679 -138H98Q84 -131 84 -118Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E58-MJMAIN-2264" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-58">\le</script> 0.5 -&gt; y = 0</p><p>and </p><p><span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-59-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="18.246ex" height="2.884ex" viewbox="0 -916.9 7855.8 1241.8" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E59-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E59-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E59-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E59-MJMATHI-67" d="M311 43Q296 30 267 15T206 0Q143 0 105 45T66 160Q66 265 143 353T314 442Q361 442 401 394L404 398Q406 401 409 404T418 412T431 419T447 422Q461 422 470 413T480 394Q480 379 423 152T363 -80Q345 -134 286 -169T151 -205Q10 -205 10 -137Q10 -111 28 -91T74 -71Q89 -71 102 -80T116 -111Q116 -121 114 -130T107 -144T99 -154T92 -162L90 -164H91Q101 -167 151 -167Q189 -167 211 -155Q234 -144 254 -122T282 -75Q288 -56 298 -13Q311 35 311 43ZM384 328L380 339Q377 350 375 354T369 368T359 382T346 393T328 402T306 405Q262 405 221 352Q191 313 171 233T151 117Q151 38 213 38Q269 38 323 108L331 118L384 328Z"/><path stroke-width="1" id="E59-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E59-MJMATHI-54" d="M40 437Q21 437 21 445Q21 450 37 501T71 602L88 651Q93 669 101 677H569H659Q691 677 697 676T704 667Q704 661 687 553T668 444Q668 437 649 437Q640 437 637 437T631 442L629 445Q629 451 635 490T641 551Q641 586 628 604T573 629Q568 630 515 631Q469 631 457 630T439 622Q438 621 368 343T298 60Q298 48 386 46Q418 46 427 45T436 36Q436 31 433 22Q429 4 424 1L422 0Q419 0 415 0Q410 0 363 1T228 2Q99 2 64 0H49Q43 6 43 9T45 27Q49 40 55 46H83H94Q174 46 189 55Q190 56 191 56Q196 59 201 76T241 233Q258 301 269 344Q339 619 339 625Q339 630 310 630H279Q212 630 191 624Q146 614 121 583T67 467Q60 445 57 441T43 437H40Z"/><path stroke-width="1" id="E59-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E59-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E59-MJMAIN-2265" d="M83 616Q83 624 89 630T99 636Q107 636 253 568T543 431T687 361Q694 356 694 346T687 331Q685 329 395 192L107 56H101Q83 58 83 76Q83 77 83 79Q82 86 98 95Q117 105 248 167Q326 204 378 228L626 346L360 472Q291 505 200 548Q112 589 98 597T83 616ZM84 -118Q84 -108 99 -98H678Q694 -104 694 -118Q694 -130 679 -138H98Q84 -131 84 -118Z"/><path stroke-width="1" id="E59-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/><path stroke-width="1" id="E59-MJMAIN-2E" d="M78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"/><path stroke-width="1" id="E59-MJMAIN-35" d="M164 157Q164 133 148 117T109 101H102Q148 22 224 22Q294 22 326 82Q345 115 345 210Q345 313 318 349Q292 382 260 382H254Q176 382 136 314Q132 307 129 306T114 304Q97 304 95 310Q93 314 93 485V614Q93 664 98 664Q100 666 102 666Q103 666 123 658T178 642T253 634Q324 634 389 662Q397 666 402 666Q410 666 410 648V635Q328 538 205 538Q174 538 149 544L139 546V374Q158 388 169 396T205 412T256 420Q337 420 393 355T449 201Q449 109 385 44T229 -22Q148 -22 99 32T50 154Q50 178 61 192T84 210T107 214Q132 214 148 197T164 157Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E59-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E59-MJMATHI-3B8" x="815" y="-219"/><use xlink:href="#E59-MJMAIN-3D" x="1286" y="0"/><use xlink:href="#E59-MJMATHI-67" x="2342" y="0"/><use xlink:href="#E59-MJMAIN-28" x="2823" y="0"/><g transform="translate(3212,0)"><use xlink:href="#E59-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E59-MJMATHI-54" x="663" y="513"/></g><use xlink:href="#E59-MJMATHI-78" x="4280" y="0"/><use xlink:href="#E59-MJMAIN-29" x="4852" y="0"/><use xlink:href="#E59-MJMAIN-2265" x="5519" y="0"/><g transform="translate(6576,0)"><use xlink:href="#E59-MJMAIN-30"/><use xlink:href="#E59-MJMAIN-2E" x="500" y="0"/><use xlink:href="#E59-MJMAIN-35" x="779" y="0"/></g></g></svg></span><script type="math/tex" id="MathJax-Element-59">h_\theta = g(\theta^Tx)\ge0.5</script>,when <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-60-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="8.07ex" height="2.634ex" viewbox="0 -916.9 3474.7 1134.2" role="img" focusable="false" style="vertical-align: -0.505ex;"><defs><path stroke-width="1" id="E60-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E60-MJMATHI-54" d="M40 437Q21 437 21 445Q21 450 37 501T71 602L88 651Q93 669 101 677H569H659Q691 677 697 676T704 667Q704 661 687 553T668 444Q668 437 649 437Q640 437 637 437T631 442L629 445Q629 451 635 490T641 551Q641 586 628 604T573 629Q568 630 515 631Q469 631 457 630T439 622Q438 621 368 343T298 60Q298 48 386 46Q418 46 427 45T436 36Q436 31 433 22Q429 4 424 1L422 0Q419 0 415 0Q410 0 363 1T228 2Q99 2 64 0H49Q43 6 43 9T45 27Q49 40 55 46H83H94Q174 46 189 55Q190 56 191 56Q196 59 201 76T241 233Q258 301 269 344Q339 619 339 625Q339 630 310 630H279Q212 630 191 624Q146 614 121 583T67 467Q60 445 57 441T43 437H40Z"/><path stroke-width="1" id="E60-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E60-MJMAIN-2265" d="M83 616Q83 624 89 630T99 636Q107 636 253 568T543 431T687 361Q694 356 694 346T687 331Q685 329 395 192L107 56H101Q83 58 83 76Q83 77 83 79Q82 86 98 95Q117 105 248 167Q326 204 378 228L626 346L360 472Q291 505 200 548Q112 589 98 597T83 616ZM84 -118Q84 -108 99 -98H678Q694 -104 694 -118Q694 -130 679 -138H98Q84 -131 84 -118Z"/><path stroke-width="1" id="E60-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E60-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E60-MJMATHI-54" x="663" y="513"/><use xlink:href="#E60-MJMATHI-78" x="1067" y="0"/><use xlink:href="#E60-MJMAIN-2265" x="1917" y="0"/><use xlink:href="#E60-MJMAIN-30" x="2974" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-60">\theta^Tx \ge 0</script></p><p>so</p><p><span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-61-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="15.771ex" height="2.759ex" viewbox="0 -916.9 6790.3 1188" role="img" focusable="false" style="vertical-align: -0.63ex;"><defs><path stroke-width="1" id="E61-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E61-MJMATHI-54" d="M40 437Q21 437 21 445Q21 450 37 501T71 602L88 651Q93 669 101 677H569H659Q691 677 697 676T704 667Q704 661 687 553T668 444Q668 437 649 437Q640 437 637 437T631 442L629 445Q629 451 635 490T641 551Q641 586 628 604T573 629Q568 630 515 631Q469 631 457 630T439 622Q438 621 368 343T298 60Q298 48 386 46Q418 46 427 45T436 36Q436 31 433 22Q429 4 424 1L422 0Q419 0 415 0Q410 0 363 1T228 2Q99 2 64 0H49Q43 6 43 9T45 27Q49 40 55 46H83H94Q174 46 189 55Q190 56 191 56Q196 59 201 76T241 233Q258 301 269 344Q339 619 339 625Q339 630 310 630H279Q212 630 191 624Q146 614 121 583T67 467Q60 445 57 441T43 437H40Z"/><path stroke-width="1" id="E61-MJMAIN-2265" d="M83 616Q83 624 89 630T99 636Q107 636 253 568T543 431T687 361Q694 356 694 346T687 331Q685 329 395 192L107 56H101Q83 58 83 76Q83 77 83 79Q82 86 98 95Q117 105 248 167Q326 204 378 228L626 346L360 472Q291 505 200 548Q112 589 98 597T83 616ZM84 -118Q84 -108 99 -98H678Q694 -104 694 -118Q694 -130 679 -138H98Q84 -131 84 -118Z"/><path stroke-width="1" id="E61-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/><path stroke-width="1" id="E61-MJMAIN-2192" d="M56 237T56 250T70 270H835Q719 357 692 493Q692 494 692 496T691 499Q691 511 708 511H711Q720 511 723 510T729 506T732 497T735 481T743 456Q765 389 816 336T935 261Q944 258 944 250Q944 244 939 241T915 231T877 212Q836 186 806 152T761 85T740 35T732 4Q730 -6 727 -8T711 -11Q691 -11 691 0Q691 7 696 25Q728 151 835 230H70Q56 237 56 250Z"/><path stroke-width="1" id="E61-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E61-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E61-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E61-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E61-MJMATHI-54" x="663" y="513"/><use xlink:href="#E61-MJMAIN-2265" x="1345" y="0"/><use xlink:href="#E61-MJMAIN-30" x="2401" y="0"/><use xlink:href="#E61-MJMAIN-2192" x="3179" y="0"/><use xlink:href="#E61-MJMATHI-79" x="4458" y="0"/><use xlink:href="#E61-MJMAIN-3D" x="5233" y="0"/><use xlink:href="#E61-MJMAIN-31" x="6289" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-61">\theta^T \ge 0 \rightarrow y =1</script></p><p><span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-62-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="15.771ex" height="2.759ex" viewbox="0 -916.9 6790.3 1188" role="img" focusable="false" style="vertical-align: -0.63ex;"><defs><path stroke-width="1" id="E62-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E62-MJMATHI-54" d="M40 437Q21 437 21 445Q21 450 37 501T71 602L88 651Q93 669 101 677H569H659Q691 677 697 676T704 667Q704 661 687 553T668 444Q668 437 649 437Q640 437 637 437T631 442L629 445Q629 451 635 490T641 551Q641 586 628 604T573 629Q568 630 515 631Q469 631 457 630T439 622Q438 621 368 343T298 60Q298 48 386 46Q418 46 427 45T436 36Q436 31 433 22Q429 4 424 1L422 0Q419 0 415 0Q410 0 363 1T228 2Q99 2 64 0H49Q43 6 43 9T45 27Q49 40 55 46H83H94Q174 46 189 55Q190 56 191 56Q196 59 201 76T241 233Q258 301 269 344Q339 619 339 625Q339 630 310 630H279Q212 630 191 624Q146 614 121 583T67 467Q60 445 57 441T43 437H40Z"/><path stroke-width="1" id="E62-MJMAIN-3C" d="M694 -11T694 -19T688 -33T678 -40Q671 -40 524 29T234 166L90 235Q83 240 83 250Q83 261 91 266Q664 540 678 540Q681 540 687 534T694 519T687 505Q686 504 417 376L151 250L417 124Q686 -4 687 -5Q694 -11 694 -19Z"/><path stroke-width="1" id="E62-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/><path stroke-width="1" id="E62-MJMAIN-2192" d="M56 237T56 250T70 270H835Q719 357 692 493Q692 494 692 496T691 499Q691 511 708 511H711Q720 511 723 510T729 506T732 497T735 481T743 456Q765 389 816 336T935 261Q944 258 944 250Q944 244 939 241T915 231T877 212Q836 186 806 152T761 85T740 35T732 4Q730 -6 727 -8T711 -11Q691 -11 691 0Q691 7 696 25Q728 151 835 230H70Q56 237 56 250Z"/><path stroke-width="1" id="E62-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E62-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E62-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E62-MJMATHI-54" x="663" y="513"/><use xlink:href="#E62-MJMAIN-3C" x="1345" y="0"/><use xlink:href="#E62-MJMAIN-30" x="2401" y="0"/><use xlink:href="#E62-MJMAIN-2192" x="3179" y="0"/><use xlink:href="#E62-MJMATHI-79" x="4458" y="0"/><use xlink:href="#E62-MJMAIN-3D" x="5233" y="0"/><use xlink:href="#E62-MJMAIN-30" x="6289" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-62">\theta^T < 0 \rightarrow y =0</script></p><p>The <strong>decision boundary</strong> is the line that separates the area where y = 1 and y = 0.it is created by hypothesis function.</p><h5 id="53-logistic-regression-cost-function"><a name="header-c239" class="md-header-anchor "></a>5.3 Logistic Regression Cost Function</h5><p>We cannot use the same cost function that we use for linear regression because the Logistic Function will cause the output to be wavy, causing many local optima. In other words, it will not be a convex function.</p><p>Instead, our cost function for logistic regression looks like:</p><div contenteditable="false" class="mathjax-block md-end-block" id="mathjax-c243" cid="c243" mdtype="math_block"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-5-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="28.813ex" height="5.009ex" viewbox="0 -1401.3 12405.6 2156.8" role="img" focusable="false" style="vertical-align: -1.755ex;"><defs><path stroke-width="1" id="E5-MJMATHI-4A" d="M447 625Q447 637 354 637H329Q323 642 323 645T325 664Q329 677 335 683H352Q393 681 498 681Q541 681 568 681T605 682T619 682Q633 682 633 672Q633 670 630 658Q626 642 623 640T604 637Q552 637 545 623Q541 610 483 376Q420 128 419 127Q397 64 333 21T195 -22Q137 -22 97 8T57 88Q57 130 80 152T132 174Q177 174 182 130Q182 98 164 80T123 56Q115 54 115 53T122 44Q148 15 197 15Q235 15 271 47T324 130Q328 142 387 380T447 625Z"/><path stroke-width="1" id="E5-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E5-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E5-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E5-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E5-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E5-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E5-MJMATHI-43" d="M50 252Q50 367 117 473T286 641T490 704Q580 704 633 653Q642 643 648 636T656 626L657 623Q660 623 684 649Q691 655 699 663T715 679T725 690L740 705H746Q760 705 760 698Q760 694 728 561Q692 422 692 421Q690 416 687 415T669 413H653Q647 419 647 422Q647 423 648 429T650 449T651 481Q651 552 619 605T510 659Q484 659 454 652T382 628T299 572T226 479Q194 422 175 346T156 222Q156 108 232 58Q280 24 350 24Q441 24 512 92T606 240Q610 253 612 255T628 257Q648 257 648 248Q648 243 647 239Q618 132 523 55T319 -22Q206 -22 128 53T50 252Z"/><path stroke-width="1" id="E5-MJMATHI-6F" d="M201 -11Q126 -11 80 38T34 156Q34 221 64 279T146 380Q222 441 301 441Q333 441 341 440Q354 437 367 433T402 417T438 387T464 338T476 268Q476 161 390 75T201 -11ZM121 120Q121 70 147 48T206 26Q250 26 289 58T351 142Q360 163 374 216T388 308Q388 352 370 375Q346 405 306 405Q243 405 195 347Q158 303 140 230T121 120Z"/><path stroke-width="1" id="E5-MJMATHI-73" d="M131 289Q131 321 147 354T203 415T300 442Q362 442 390 415T419 355Q419 323 402 308T364 292Q351 292 340 300T328 326Q328 342 337 354T354 372T367 378Q368 378 368 379Q368 382 361 388T336 399T297 405Q249 405 227 379T204 326Q204 301 223 291T278 274T330 259Q396 230 396 163Q396 135 385 107T352 51T289 7T195 -10Q118 -10 86 19T53 87Q53 126 74 143T118 160Q133 160 146 151T160 120Q160 94 142 76T111 58Q109 57 108 57T107 55Q108 52 115 47T146 34T201 27Q237 27 263 38T301 66T318 97T323 122Q323 150 302 164T254 181T195 196T148 231Q131 256 131 289Z"/><path stroke-width="1" id="E5-MJMATHI-74" d="M26 385Q19 392 19 395Q19 399 22 411T27 425Q29 430 36 430T87 431H140L159 511Q162 522 166 540T173 566T179 586T187 603T197 615T211 624T229 626Q247 625 254 615T261 596Q261 589 252 549T232 470L222 433Q222 431 272 431H323Q330 424 330 420Q330 398 317 385H210L174 240Q135 80 135 68Q135 26 162 26Q197 26 230 60T283 144Q285 150 288 151T303 153H307Q322 153 322 145Q322 142 319 133Q314 117 301 95T267 48T216 6T155 -11Q125 -11 98 4T59 56Q57 64 57 83V101L92 241Q127 382 128 383Q128 385 77 385H26Z"/><path stroke-width="1" id="E5-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E5-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E5-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E5-MJMAIN-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z"/><path stroke-width="1" id="E5-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E5-MJMATHI-4A" x="0" y="0"/><use xlink:href="#E5-MJMAIN-28" x="633" y="0"/><use xlink:href="#E5-MJMATHI-3B8" x="1023" y="0"/><use xlink:href="#E5-MJMAIN-29" x="1492" y="0"/><use xlink:href="#E5-MJMAIN-3D" x="2159" y="0"/><g transform="translate(2938,0)"><g transform="translate(397,0)"><rect stroke="none" width="998" height="60" x="0" y="220"/><use xlink:href="#E5-MJMAIN-31" x="249" y="676"/><use xlink:href="#E5-MJMATHI-6D" x="60" y="-686"/></g></g><use xlink:href="#E5-MJMATHI-43" x="4454" y="0"/><use xlink:href="#E5-MJMATHI-6F" x="5215" y="0"/><use xlink:href="#E5-MJMATHI-73" x="5700" y="0"/><use xlink:href="#E5-MJMATHI-74" x="6170" y="0"/><use xlink:href="#E5-MJMAIN-28" x="6531" y="0"/><g transform="translate(6921,0)"><use xlink:href="#E5-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E5-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E5-MJMAIN-28" x="7929" y="0"/><g transform="translate(8319,0)"><use xlink:href="#E5-MJMATHI-78" x="0" y="0"/><g transform="translate(572,412)"><use transform="scale(0.707)" xlink:href="#E5-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E5-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E5-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E5-MJMAIN-29" x="9786" y="0"/><use xlink:href="#E5-MJMAIN-2C" x="10176" y="0"/><g transform="translate(10621,0)"><use xlink:href="#E5-MJMATHI-79" x="0" y="0"/><g transform="translate(499,412)"><use transform="scale(0.707)" xlink:href="#E5-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E5-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E5-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E5-MJMAIN-29" x="12016" y="0"/></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-5">
J(\theta) = \frac{1}{m}Cost(h_\theta(x^{(i)}),y^{(i)})
</script></div><p>If y = 1:</p><div contenteditable="false" class="mathjax-block md-end-block" id="mathjax-c246" cid="c246" mdtype="math_block"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-6-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="33.601ex" height="3.134ex" viewbox="0 -1024.6 14467.1 1349.5" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E6-MJMATHI-43" d="M50 252Q50 367 117 473T286 641T490 704Q580 704 633 653Q642 643 648 636T656 626L657 623Q660 623 684 649Q691 655 699 663T715 679T725 690L740 705H746Q760 705 760 698Q760 694 728 561Q692 422 692 421Q690 416 687 415T669 413H653Q647 419 647 422Q647 423 648 429T650 449T651 481Q651 552 619 605T510 659Q484 659 454 652T382 628T299 572T226 479Q194 422 175 346T156 222Q156 108 232 58Q280 24 350 24Q441 24 512 92T606 240Q610 253 612 255T628 257Q648 257 648 248Q648 243 647 239Q618 132 523 55T319 -22Q206 -22 128 53T50 252Z"/><path stroke-width="1" id="E6-MJMATHI-6F" d="M201 -11Q126 -11 80 38T34 156Q34 221 64 279T146 380Q222 441 301 441Q333 441 341 440Q354 437 367 433T402 417T438 387T464 338T476 268Q476 161 390 75T201 -11ZM121 120Q121 70 147 48T206 26Q250 26 289 58T351 142Q360 163 374 216T388 308Q388 352 370 375Q346 405 306 405Q243 405 195 347Q158 303 140 230T121 120Z"/><path stroke-width="1" id="E6-MJMATHI-73" d="M131 289Q131 321 147 354T203 415T300 442Q362 442 390 415T419 355Q419 323 402 308T364 292Q351 292 340 300T328 326Q328 342 337 354T354 372T367 378Q368 378 368 379Q368 382 361 388T336 399T297 405Q249 405 227 379T204 326Q204 301 223 291T278 274T330 259Q396 230 396 163Q396 135 385 107T352 51T289 7T195 -10Q118 -10 86 19T53 87Q53 126 74 143T118 160Q133 160 146 151T160 120Q160 94 142 76T111 58Q109 57 108 57T107 55Q108 52 115 47T146 34T201 27Q237 27 263 38T301 66T318 97T323 122Q323 150 302 164T254 181T195 196T148 231Q131 256 131 289Z"/><path stroke-width="1" id="E6-MJMATHI-74" d="M26 385Q19 392 19 395Q19 399 22 411T27 425Q29 430 36 430T87 431H140L159 511Q162 522 166 540T173 566T179 586T187 603T197 615T211 624T229 626Q247 625 254 615T261 596Q261 589 252 549T232 470L222 433Q222 431 272 431H323Q330 424 330 420Q330 398 317 385H210L174 240Q135 80 135 68Q135 26 162 26Q197 26 230 60T283 144Q285 150 288 151T303 153H307Q322 153 322 145Q322 142 319 133Q314 117 301 95T267 48T216 6T155 -11Q125 -11 98 4T59 56Q57 64 57 83V101L92 241Q127 382 128 383Q128 385 77 385H26Z"/><path stroke-width="1" id="E6-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E6-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E6-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E6-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E6-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E6-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E6-MJMAIN-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z"/><path stroke-width="1" id="E6-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E6-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E6-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E6-MJMATHI-6C" d="M117 59Q117 26 142 26Q179 26 205 131Q211 151 215 152Q217 153 225 153H229Q238 153 241 153T246 151T248 144Q247 138 245 128T234 90T214 43T183 6T137 -11Q101 -11 70 11T38 85Q38 97 39 102L104 360Q167 615 167 623Q167 626 166 628T162 632T157 634T149 635T141 636T132 637T122 637Q112 637 109 637T101 638T95 641T94 647Q94 649 96 661Q101 680 107 682T179 688Q194 689 213 690T243 693T254 694Q266 694 266 686Q266 675 193 386T118 83Q118 81 118 75T117 65V59Z"/><path stroke-width="1" id="E6-MJMATHI-67" d="M311 43Q296 30 267 15T206 0Q143 0 105 45T66 160Q66 265 143 353T314 442Q361 442 401 394L404 398Q406 401 409 404T418 412T431 419T447 422Q461 422 470 413T480 394Q480 379 423 152T363 -80Q345 -134 286 -169T151 -205Q10 -205 10 -137Q10 -111 28 -91T74 -71Q89 -71 102 -80T116 -111Q116 -121 114 -130T107 -144T99 -154T92 -162L90 -164H91Q101 -167 151 -167Q189 -167 211 -155Q234 -144 254 -122T282 -75Q288 -56 298 -13Q311 35 311 43ZM384 328L380 339Q377 350 375 354T369 368T359 382T346 393T328 402T306 405Q262 405 221 352Q191 313 171 233T151 117Q151 38 213 38Q269 38 323 108L331 118L384 328Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E6-MJMATHI-43" x="0" y="0"/><use xlink:href="#E6-MJMATHI-6F" x="760" y="0"/><use xlink:href="#E6-MJMATHI-73" x="1246" y="0"/><use xlink:href="#E6-MJMATHI-74" x="1715" y="0"/><use xlink:href="#E6-MJMAIN-28" x="2077" y="0"/><g transform="translate(2466,0)"><use xlink:href="#E6-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E6-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E6-MJMAIN-28" x="3474" y="0"/><g transform="translate(3864,0)"><use xlink:href="#E6-MJMATHI-78" x="0" y="0"/><g transform="translate(572,412)"><use transform="scale(0.707)" xlink:href="#E6-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E6-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E6-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E6-MJMAIN-29" x="5332" y="0"/><use xlink:href="#E6-MJMAIN-2C" x="5721" y="0"/><g transform="translate(6166,0)"><use xlink:href="#E6-MJMATHI-79" x="0" y="0"/><g transform="translate(499,412)"><use transform="scale(0.707)" xlink:href="#E6-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E6-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E6-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E6-MJMAIN-29" x="7561" y="0"/><use xlink:href="#E6-MJMAIN-3D" x="8228" y="0"/><use xlink:href="#E6-MJMAIN-2212" x="9285" y="0"/><use xlink:href="#E6-MJMATHI-6C" x="10063" y="0"/><use xlink:href="#E6-MJMATHI-6F" x="10362" y="0"/><use xlink:href="#E6-MJMATHI-67" x="10847" y="0"/><use xlink:href="#E6-MJMAIN-28" x="11328" y="0"/><g transform="translate(11717,0)"><use xlink:href="#E6-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E6-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E6-MJMAIN-28" x="12726" y="0"/><use xlink:href="#E6-MJMATHI-78" x="13115" y="0"/><use xlink:href="#E6-MJMAIN-29" x="13688" y="0"/><use xlink:href="#E6-MJMAIN-29" x="14077" y="0"/></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-6">
Cost(h_\theta(x^{(i)}),y^{(i)}) = -log(h_\theta(x))
</script></div><p>If y = 0:</p><div contenteditable="false" class="mathjax-block md-end-block" id="mathjax-c249" cid="c249" mdtype="math_block"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-7-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="37.604ex" height="3.134ex" viewbox="0 -1024.6 16190.6 1349.5" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E7-MJMATHI-43" d="M50 252Q50 367 117 473T286 641T490 704Q580 704 633 653Q642 643 648 636T656 626L657 623Q660 623 684 649Q691 655 699 663T715 679T725 690L740 705H746Q760 705 760 698Q760 694 728 561Q692 422 692 421Q690 416 687 415T669 413H653Q647 419 647 422Q647 423 648 429T650 449T651 481Q651 552 619 605T510 659Q484 659 454 652T382 628T299 572T226 479Q194 422 175 346T156 222Q156 108 232 58Q280 24 350 24Q441 24 512 92T606 240Q610 253 612 255T628 257Q648 257 648 248Q648 243 647 239Q618 132 523 55T319 -22Q206 -22 128 53T50 252Z"/><path stroke-width="1" id="E7-MJMATHI-6F" d="M201 -11Q126 -11 80 38T34 156Q34 221 64 279T146 380Q222 441 301 441Q333 441 341 440Q354 437 367 433T402 417T438 387T464 338T476 268Q476 161 390 75T201 -11ZM121 120Q121 70 147 48T206 26Q250 26 289 58T351 142Q360 163 374 216T388 308Q388 352 370 375Q346 405 306 405Q243 405 195 347Q158 303 140 230T121 120Z"/><path stroke-width="1" id="E7-MJMATHI-73" d="M131 289Q131 321 147 354T203 415T300 442Q362 442 390 415T419 355Q419 323 402 308T364 292Q351 292 340 300T328 326Q328 342 337 354T354 372T367 378Q368 378 368 379Q368 382 361 388T336 399T297 405Q249 405 227 379T204 326Q204 301 223 291T278 274T330 259Q396 230 396 163Q396 135 385 107T352 51T289 7T195 -10Q118 -10 86 19T53 87Q53 126 74 143T118 160Q133 160 146 151T160 120Q160 94 142 76T111 58Q109 57 108 57T107 55Q108 52 115 47T146 34T201 27Q237 27 263 38T301 66T318 97T323 122Q323 150 302 164T254 181T195 196T148 231Q131 256 131 289Z"/><path stroke-width="1" id="E7-MJMATHI-74" d="M26 385Q19 392 19 395Q19 399 22 411T27 425Q29 430 36 430T87 431H140L159 511Q162 522 166 540T173 566T179 586T187 603T197 615T211 624T229 626Q247 625 254 615T261 596Q261 589 252 549T232 470L222 433Q222 431 272 431H323Q330 424 330 420Q330 398 317 385H210L174 240Q135 80 135 68Q135 26 162 26Q197 26 230 60T283 144Q285 150 288 151T303 153H307Q322 153 322 145Q322 142 319 133Q314 117 301 95T267 48T216 6T155 -11Q125 -11 98 4T59 56Q57 64 57 83V101L92 241Q127 382 128 383Q128 385 77 385H26Z"/><path stroke-width="1" id="E7-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E7-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E7-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E7-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E7-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E7-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E7-MJMAIN-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z"/><path stroke-width="1" id="E7-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E7-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E7-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E7-MJMATHI-6C" d="M117 59Q117 26 142 26Q179 26 205 131Q211 151 215 152Q217 153 225 153H229Q238 153 241 153T246 151T248 144Q247 138 245 128T234 90T214 43T183 6T137 -11Q101 -11 70 11T38 85Q38 97 39 102L104 360Q167 615 167 623Q167 626 166 628T162 632T157 634T149 635T141 636T132 637T122 637Q112 637 109 637T101 638T95 641T94 647Q94 649 96 661Q101 680 107 682T179 688Q194 689 213 690T243 693T254 694Q266 694 266 686Q266 675 193 386T118 83Q118 81 118 75T117 65V59Z"/><path stroke-width="1" id="E7-MJMATHI-67" d="M311 43Q296 30 267 15T206 0Q143 0 105 45T66 160Q66 265 143 353T314 442Q361 442 401 394L404 398Q406 401 409 404T418 412T431 419T447 422Q461 422 470 413T480 394Q480 379 423 152T363 -80Q345 -134 286 -169T151 -205Q10 -205 10 -137Q10 -111 28 -91T74 -71Q89 -71 102 -80T116 -111Q116 -121 114 -130T107 -144T99 -154T92 -162L90 -164H91Q101 -167 151 -167Q189 -167 211 -155Q234 -144 254 -122T282 -75Q288 -56 298 -13Q311 35 311 43ZM384 328L380 339Q377 350 375 354T369 368T359 382T346 393T328 402T306 405Q262 405 221 352Q191 313 171 233T151 117Q151 38 213 38Q269 38 323 108L331 118L384 328Z"/><path stroke-width="1" id="E7-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E7-MJMATHI-43" x="0" y="0"/><use xlink:href="#E7-MJMATHI-6F" x="760" y="0"/><use xlink:href="#E7-MJMATHI-73" x="1246" y="0"/><use xlink:href="#E7-MJMATHI-74" x="1715" y="0"/><use xlink:href="#E7-MJMAIN-28" x="2077" y="0"/><g transform="translate(2466,0)"><use xlink:href="#E7-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E7-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E7-MJMAIN-28" x="3474" y="0"/><g transform="translate(3864,0)"><use xlink:href="#E7-MJMATHI-78" x="0" y="0"/><g transform="translate(572,412)"><use transform="scale(0.707)" xlink:href="#E7-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E7-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E7-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E7-MJMAIN-29" x="5332" y="0"/><use xlink:href="#E7-MJMAIN-2C" x="5721" y="0"/><g transform="translate(6166,0)"><use xlink:href="#E7-MJMATHI-79" x="0" y="0"/><g transform="translate(499,412)"><use transform="scale(0.707)" xlink:href="#E7-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E7-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E7-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E7-MJMAIN-29" x="7561" y="0"/><use xlink:href="#E7-MJMAIN-3D" x="8228" y="0"/><use xlink:href="#E7-MJMAIN-2212" x="9285" y="0"/><use xlink:href="#E7-MJMATHI-6C" x="10063" y="0"/><use xlink:href="#E7-MJMATHI-6F" x="10362" y="0"/><use xlink:href="#E7-MJMATHI-67" x="10847" y="0"/><use xlink:href="#E7-MJMAIN-28" x="11328" y="0"/><use xlink:href="#E7-MJMAIN-31" x="11717" y="0"/><use xlink:href="#E7-MJMAIN-2212" x="12440" y="0"/><g transform="translate(13441,0)"><use xlink:href="#E7-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E7-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E7-MJMAIN-28" x="14449" y="0"/><use xlink:href="#E7-MJMATHI-78" x="14839" y="0"/><use xlink:href="#E7-MJMAIN-29" x="15411" y="0"/><use xlink:href="#E7-MJMAIN-29" x="15801" y="0"/></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-7">
Cost(h_\theta(x^{(i)}),y^{(i)}) = -log(1 - h_\theta(x))
</script></div><p>When y = 1,we get the follow plot for J(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-71-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.09ex" height="2.134ex" viewbox="0 -809.3 469.5 918.9" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E71-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E71-MJMATHI-3B8" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-71">\theta</script>) vs <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-73-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.481ex" height="2.634ex" viewbox="0 -809.3 2360 1134.2" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E73-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E73-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E73-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E73-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E73-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E73-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E73-MJMATHI-3B8" x="815" y="-219"/><use xlink:href="#E73-MJMAIN-28" x="1008" y="0"/><use xlink:href="#E73-MJMATHI-78" x="1397" y="0"/><use xlink:href="#E73-MJMAIN-29" x="1970" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-73">h_\theta(x)</script>:</p><p><img src="https://ws1.sinaimg.cn/large/006tNbRwgy1fg3r6adiv0j308c06sjrf.jpg" alt="Q9sX8nnxEeamDApmnD43Fw_1cb67ecfac77b134606532f5caf98ee4_Logistic_regression_cost_function_positive_class-1"></p><p>In contrast,when y = 0, we can get as below:</p><p><img src="https://ws1.sinaimg.cn/large/006tNbRwgy1fg3r6fv1ihj308b07smx6.jpg" alt="Ut7vvXnxEead-BJkoDOYOw_f719f2858d78dd66d80c5ec0d8e6b3fa_Logistic_regression_cost_function_negative_class"></p><p>When Cost(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-65-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="7.671ex" height="2.634ex" viewbox="0 -809.3 3302.7 1134.2" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E65-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E65-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E65-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E65-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E65-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E65-MJMAIN-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z"/><path stroke-width="1" id="E65-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E65-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E65-MJMATHI-3B8" x="815" y="-219"/><use xlink:href="#E65-MJMAIN-28" x="1008" y="0"/><use xlink:href="#E65-MJMATHI-78" x="1397" y="0"/><use xlink:href="#E65-MJMAIN-29" x="1970" y="0"/><use xlink:href="#E65-MJMAIN-2C" x="2359" y="0"/><use xlink:href="#E65-MJMATHI-79" x="2805" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-65">h_\theta(x),y</script>) = 0, <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-73-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.481ex" height="2.634ex" viewbox="0 -809.3 2360 1134.2" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E73-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E73-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E73-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E73-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E73-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E73-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E73-MJMATHI-3B8" x="815" y="-219"/><use xlink:href="#E73-MJMAIN-28" x="1008" y="0"/><use xlink:href="#E73-MJMATHI-78" x="1397" y="0"/><use xlink:href="#E73-MJMAIN-29" x="1970" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-73">h_\theta(x)</script> = y.in contrast, when <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-73-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.481ex" height="2.634ex" viewbox="0 -809.3 2360 1134.2" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E73-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E73-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E73-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E73-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E73-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E73-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E73-MJMATHI-3B8" x="815" y="-219"/><use xlink:href="#E73-MJMAIN-28" x="1008" y="0"/><use xlink:href="#E73-MJMATHI-78" x="1397" y="0"/><use xlink:href="#E73-MJMAIN-29" x="1970" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-73">h_\theta(x)</script> = y, Cost(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-75-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.342ex" height="2.384ex" viewbox="0 -755.5 1008.5 1026.6" role="img" focusable="false" style="vertical-align: -0.63ex;"><defs><path stroke-width="1" id="E75-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E75-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E75-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E75-MJMATHI-3B8" x="815" y="-219"/></g></svg></span><script type="math/tex" id="MathJax-Element-75">h_\theta</script>(x),y) = 0.</p><p>We can compress our function&#39;s two conditional case into case:</p><div class="mathjax-block" style="" contenteditable="false" cid="c262" mdtype="math_block" id="math-jaxc262"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-122-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="54.632ex" height="2.634ex" viewbox="0 -809.3 23522 1134.2" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E134-MJMATHI-43" d="M50 252Q50 367 117 473T286 641T490 704Q580 704 633 653Q642 643 648 636T656 626L657 623Q660 623 684 649Q691 655 699 663T715 679T725 690L740 705H746Q760 705 760 698Q760 694 728 561Q692 422 692 421Q690 416 687 415T669 413H653Q647 419 647 422Q647 423 648 429T650 449T651 481Q651 552 619 605T510 659Q484 659 454 652T382 628T299 572T226 479Q194 422 175 346T156 222Q156 108 232 58Q280 24 350 24Q441 24 512 92T606 240Q610 253 612 255T628 257Q648 257 648 248Q648 243 647 239Q618 132 523 55T319 -22Q206 -22 128 53T50 252Z"/><path stroke-width="1" id="E134-MJMATHI-6F" d="M201 -11Q126 -11 80 38T34 156Q34 221 64 279T146 380Q222 441 301 441Q333 441 341 440Q354 437 367 433T402 417T438 387T464 338T476 268Q476 161 390 75T201 -11ZM121 120Q121 70 147 48T206 26Q250 26 289 58T351 142Q360 163 374 216T388 308Q388 352 370 375Q346 405 306 405Q243 405 195 347Q158 303 140 230T121 120Z"/><path stroke-width="1" id="E134-MJMATHI-73" d="M131 289Q131 321 147 354T203 415T300 442Q362 442 390 415T419 355Q419 323 402 308T364 292Q351 292 340 300T328 326Q328 342 337 354T354 372T367 378Q368 378 368 379Q368 382 361 388T336 399T297 405Q249 405 227 379T204 326Q204 301 223 291T278 274T330 259Q396 230 396 163Q396 135 385 107T352 51T289 7T195 -10Q118 -10 86 19T53 87Q53 126 74 143T118 160Q133 160 146 151T160 120Q160 94 142 76T111 58Q109 57 108 57T107 55Q108 52 115 47T146 34T201 27Q237 27 263 38T301 66T318 97T323 122Q323 150 302 164T254 181T195 196T148 231Q131 256 131 289Z"/><path stroke-width="1" id="E134-MJMATHI-74" d="M26 385Q19 392 19 395Q19 399 22 411T27 425Q29 430 36 430T87 431H140L159 511Q162 522 166 540T173 566T179 586T187 603T197 615T211 624T229 626Q247 625 254 615T261 596Q261 589 252 549T232 470L222 433Q222 431 272 431H323Q330 424 330 420Q330 398 317 385H210L174 240Q135 80 135 68Q135 26 162 26Q197 26 230 60T283 144Q285 150 288 151T303 153H307Q322 153 322 145Q322 142 319 133Q314 117 301 95T267 48T216 6T155 -11Q125 -11 98 4T59 56Q57 64 57 83V101L92 241Q127 382 128 383Q128 385 77 385H26Z"/><path stroke-width="1" id="E134-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E134-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E134-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E134-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E134-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E134-MJMAIN-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z"/><path stroke-width="1" id="E134-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E134-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E134-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E134-MJMATHI-6C" d="M117 59Q117 26 142 26Q179 26 205 131Q211 151 215 152Q217 153 225 153H229Q238 153 241 153T246 151T248 144Q247 138 245 128T234 90T214 43T183 6T137 -11Q101 -11 70 11T38 85Q38 97 39 102L104 360Q167 615 167 623Q167 626 166 628T162 632T157 634T149 635T141 636T132 637T122 637Q112 637 109 637T101 638T95 641T94 647Q94 649 96 661Q101 680 107 682T179 688Q194 689 213 690T243 693T254 694Q266 694 266 686Q266 675 193 386T118 83Q118 81 118 75T117 65V59Z"/><path stroke-width="1" id="E134-MJMATHI-67" d="M311 43Q296 30 267 15T206 0Q143 0 105 45T66 160Q66 265 143 353T314 442Q361 442 401 394L404 398Q406 401 409 404T418 412T431 419T447 422Q461 422 470 413T480 394Q480 379 423 152T363 -80Q345 -134 286 -169T151 -205Q10 -205 10 -137Q10 -111 28 -91T74 -71Q89 -71 102 -80T116 -111Q116 -121 114 -130T107 -144T99 -154T92 -162L90 -164H91Q101 -167 151 -167Q189 -167 211 -155Q234 -144 254 -122T282 -75Q288 -56 298 -13Q311 35 311 43ZM384 328L380 339Q377 350 375 354T369 368T359 382T346 393T328 402T306 405Q262 405 221 352Q191 313 171 233T151 117Q151 38 213 38Q269 38 323 108L331 118L384 328Z"/><path stroke-width="1" id="E134-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E134-MJMATHI-43" x="0" y="0"/><use xlink:href="#E134-MJMATHI-6F" x="760" y="0"/><use xlink:href="#E134-MJMATHI-73" x="1246" y="0"/><use xlink:href="#E134-MJMATHI-74" x="1715" y="0"/><use xlink:href="#E134-MJMAIN-28" x="2077" y="0"/><g transform="translate(2466,0)"><use xlink:href="#E134-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E134-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E134-MJMAIN-28" x="3474" y="0"/><use xlink:href="#E134-MJMATHI-78" x="3864" y="0"/><use xlink:href="#E134-MJMAIN-29" x="4436" y="0"/><use xlink:href="#E134-MJMAIN-2C" x="4826" y="0"/><use xlink:href="#E134-MJMATHI-79" x="5271" y="0"/><use xlink:href="#E134-MJMAIN-29" x="5769" y="0"/><use xlink:href="#E134-MJMAIN-3D" x="6436" y="0"/><use xlink:href="#E134-MJMAIN-2212" x="7492" y="0"/><use xlink:href="#E134-MJMATHI-79" x="8271" y="0"/><use xlink:href="#E134-MJMATHI-6C" x="8768" y="0"/><use xlink:href="#E134-MJMATHI-6F" x="9067" y="0"/><use xlink:href="#E134-MJMATHI-67" x="9552" y="0"/><use xlink:href="#E134-MJMAIN-28" x="10033" y="0"/><g transform="translate(10422,0)"><use xlink:href="#E134-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E134-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E134-MJMAIN-28" x="11431" y="0"/><use xlink:href="#E134-MJMATHI-78" x="11820" y="0"/><use xlink:href="#E134-MJMAIN-29" x="12393" y="0"/><use xlink:href="#E134-MJMAIN-29" x="12782" y="0"/><use xlink:href="#E134-MJMAIN-2212" x="13394" y="0"/><use xlink:href="#E134-MJMAIN-28" x="14395" y="0"/><use xlink:href="#E134-MJMAIN-31" x="14784" y="0"/><use xlink:href="#E134-MJMAIN-2212" x="15507" y="0"/><use xlink:href="#E134-MJMATHI-79" x="16508" y="0"/><use xlink:href="#E134-MJMAIN-29" x="17005" y="0"/><use xlink:href="#E134-MJMATHI-6C" x="17395" y="0"/><use xlink:href="#E134-MJMATHI-6F" x="17693" y="0"/><use xlink:href="#E134-MJMATHI-67" x="18179" y="0"/><use xlink:href="#E134-MJMAIN-28" x="18659" y="0"/><use xlink:href="#E134-MJMAIN-31" x="19049" y="0"/><use xlink:href="#E134-MJMAIN-2212" x="19771" y="0"/><g transform="translate(20772,0)"><use xlink:href="#E134-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E134-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E134-MJMAIN-28" x="21781" y="0"/><use xlink:href="#E134-MJMATHI-78" x="22170" y="0"/><use xlink:href="#E134-MJMAIN-29" x="22743" y="0"/><use xlink:href="#E134-MJMAIN-29" x="23132" y="0"/></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-122">
Cost(h_\theta(x),y) = -ylog(h_\theta(x))-(1 - y)log(1 - h_\theta(x))
</script></div><p>A vectorized implementation is:</p><div contenteditable="false" class="mathjax-block md-end-block" id="mathjax-c265" cid="c265" mdtype="math_block"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-9-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="10.433ex" height="2.634ex" viewbox="0 -809.3 4492.1 1134.2" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E9-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E9-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E9-MJMATHI-67" d="M311 43Q296 30 267 15T206 0Q143 0 105 45T66 160Q66 265 143 353T314 442Q361 442 401 394L404 398Q406 401 409 404T418 412T431 419T447 422Q461 422 470 413T480 394Q480 379 423 152T363 -80Q345 -134 286 -169T151 -205Q10 -205 10 -137Q10 -111 28 -91T74 -71Q89 -71 102 -80T116 -111Q116 -121 114 -130T107 -144T99 -154T92 -162L90 -164H91Q101 -167 151 -167Q189 -167 211 -155Q234 -144 254 -122T282 -75Q288 -56 298 -13Q311 35 311 43ZM384 328L380 339Q377 350 375 354T369 368T359 382T346 393T328 402T306 405Q262 405 221 352Q191 313 171 233T151 117Q151 38 213 38Q269 38 323 108L331 118L384 328Z"/><path stroke-width="1" id="E9-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E9-MJMATHI-58" d="M42 0H40Q26 0 26 11Q26 15 29 27Q33 41 36 43T55 46Q141 49 190 98Q200 108 306 224T411 342Q302 620 297 625Q288 636 234 637H206Q200 643 200 645T202 664Q206 677 212 683H226Q260 681 347 681Q380 681 408 681T453 682T473 682Q490 682 490 671Q490 670 488 658Q484 643 481 640T465 637Q434 634 411 620L488 426L541 485Q646 598 646 610Q646 628 622 635Q617 635 609 637Q594 637 594 648Q594 650 596 664Q600 677 606 683H618Q619 683 643 683T697 681T738 680Q828 680 837 683H845Q852 676 852 672Q850 647 840 637H824Q790 636 763 628T722 611T698 593L687 584Q687 585 592 480L505 384Q505 383 536 304T601 142T638 56Q648 47 699 46Q734 46 734 37Q734 35 732 23Q728 7 725 4T711 1Q708 1 678 1T589 2Q528 2 496 2T461 1Q444 1 444 10Q444 11 446 25Q448 35 450 39T455 44T464 46T480 47T506 54Q523 62 523 64Q522 64 476 181L429 299Q241 95 236 84Q232 76 232 72Q232 53 261 47Q262 47 267 47T273 46Q276 46 277 46T280 45T283 42T284 35Q284 26 282 19Q279 6 276 4T261 1Q258 1 243 1T201 2T142 2Q64 2 42 0Z"/><path stroke-width="1" id="E9-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E9-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E9-MJMATHI-68" x="0" y="0"/><use xlink:href="#E9-MJMAIN-3D" x="854" y="0"/><use xlink:href="#E9-MJMATHI-67" x="1910" y="0"/><use xlink:href="#E9-MJMAIN-28" x="2391" y="0"/><use xlink:href="#E9-MJMATHI-58" x="2780" y="0"/><use xlink:href="#E9-MJMATHI-3B8" x="3633" y="0"/><use xlink:href="#E9-MJMAIN-29" x="4102" y="0"/></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-9">
h = g(X\theta)
</script></div><div class="mathjax-block" style="" contenteditable="false" cid="c267" mdtype="math_block" id="math-jaxc267"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-1177-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="44.918ex" height="5.009ex" viewbox="0 -1401.3 19339.5 2156.8" role="img" focusable="false" style="vertical-align: -1.755ex;"><defs><path stroke-width="1" id="E1250-MJMATHI-4A" d="M447 625Q447 637 354 637H329Q323 642 323 645T325 664Q329 677 335 683H352Q393 681 498 681Q541 681 568 681T605 682T619 682Q633 682 633 672Q633 670 630 658Q626 642 623 640T604 637Q552 637 545 623Q541 610 483 376Q420 128 419 127Q397 64 333 21T195 -22Q137 -22 97 8T57 88Q57 130 80 152T132 174Q177 174 182 130Q182 98 164 80T123 56Q115 54 115 53T122 44Q148 15 197 15Q235 15 271 47T324 130Q328 142 387 380T447 625Z"/><path stroke-width="1" id="E1250-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E1250-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E1250-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E1250-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E1250-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E1250-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1250-MJMAIN-2E" d="M78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"/><path stroke-width="1" id="E1250-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E1250-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1250-MJMATHI-54" d="M40 437Q21 437 21 445Q21 450 37 501T71 602L88 651Q93 669 101 677H569H659Q691 677 697 676T704 667Q704 661 687 553T668 444Q668 437 649 437Q640 437 637 437T631 442L629 445Q629 451 635 490T641 551Q641 586 628 604T573 629Q568 630 515 631Q469 631 457 630T439 622Q438 621 368 343T298 60Q298 48 386 46Q418 46 427 45T436 36Q436 31 433 22Q429 4 424 1L422 0Q419 0 415 0Q410 0 363 1T228 2Q99 2 64 0H49Q43 6 43 9T45 27Q49 40 55 46H83H94Q174 46 189 55Q190 56 191 56Q196 59 201 76T241 233Q258 301 269 344Q339 619 339 625Q339 630 310 630H279Q212 630 191 624Q146 614 121 583T67 467Q60 445 57 441T43 437H40Z"/><path stroke-width="1" id="E1250-MJMATHI-6C" d="M117 59Q117 26 142 26Q179 26 205 131Q211 151 215 152Q217 153 225 153H229Q238 153 241 153T246 151T248 144Q247 138 245 128T234 90T214 43T183 6T137 -11Q101 -11 70 11T38 85Q38 97 39 102L104 360Q167 615 167 623Q167 626 166 628T162 632T157 634T149 635T141 636T132 637T122 637Q112 637 109 637T101 638T95 641T94 647Q94 649 96 661Q101 680 107 682T179 688Q194 689 213 690T243 693T254 694Q266 694 266 686Q266 675 193 386T118 83Q118 81 118 75T117 65V59Z"/><path stroke-width="1" id="E1250-MJMATHI-6F" d="M201 -11Q126 -11 80 38T34 156Q34 221 64 279T146 380Q222 441 301 441Q333 441 341 440Q354 437 367 433T402 417T438 387T464 338T476 268Q476 161 390 75T201 -11ZM121 120Q121 70 147 48T206 26Q250 26 289 58T351 142Q360 163 374 216T388 308Q388 352 370 375Q346 405 306 405Q243 405 195 347Q158 303 140 230T121 120Z"/><path stroke-width="1" id="E1250-MJMATHI-67" d="M311 43Q296 30 267 15T206 0Q143 0 105 45T66 160Q66 265 143 353T314 442Q361 442 401 394L404 398Q406 401 409 404T418 412T431 419T447 422Q461 422 470 413T480 394Q480 379 423 152T363 -80Q345 -134 286 -169T151 -205Q10 -205 10 -137Q10 -111 28 -91T74 -71Q89 -71 102 -80T116 -111Q116 -121 114 -130T107 -144T99 -154T92 -162L90 -164H91Q101 -167 151 -167Q189 -167 211 -155Q234 -144 254 -122T282 -75Q288 -56 298 -13Q311 35 311 43ZM384 328L380 339Q377 350 375 354T369 368T359 382T346 393T328 402T306 405Q262 405 221 352Q191 313 171 233T151 117Q151 38 213 38Q269 38 323 108L331 118L384 328Z"/><path stroke-width="1" id="E1250-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E1250-MJMATHI-4A" x="0" y="0"/><use xlink:href="#E1250-MJMAIN-28" x="633" y="0"/><use xlink:href="#E1250-MJMATHI-3B8" x="1023" y="0"/><use xlink:href="#E1250-MJMAIN-29" x="1492" y="0"/><use xlink:href="#E1250-MJMAIN-3D" x="2159" y="0"/><g transform="translate(2938,0)"><g transform="translate(397,0)"><rect stroke="none" width="998" height="60" x="0" y="220"/><use xlink:href="#E1250-MJMAIN-31" x="249" y="676"/><use xlink:href="#E1250-MJMATHI-6D" x="60" y="-686"/></g></g><use xlink:href="#E1250-MJMAIN-2E" x="4454" y="0"/><use xlink:href="#E1250-MJMAIN-28" x="4899" y="0"/><use xlink:href="#E1250-MJMAIN-2212" x="5289" y="0"/><g transform="translate(6067,0)"><use xlink:href="#E1250-MJMATHI-79" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1250-MJMATHI-54" x="706" y="583"/></g><use xlink:href="#E1250-MJMATHI-6C" x="7165" y="0"/><use xlink:href="#E1250-MJMATHI-6F" x="7464" y="0"/><use xlink:href="#E1250-MJMATHI-67" x="7949" y="0"/><use xlink:href="#E1250-MJMAIN-28" x="8430" y="0"/><use xlink:href="#E1250-MJMATHI-68" x="8819" y="0"/><use xlink:href="#E1250-MJMAIN-29" x="9396" y="0"/><use xlink:href="#E1250-MJMAIN-2212" x="10007" y="0"/><use xlink:href="#E1250-MJMAIN-28" x="11008" y="0"/><use xlink:href="#E1250-MJMAIN-31" x="11397" y="0"/><use xlink:href="#E1250-MJMAIN-2212" x="12120" y="0"/><use xlink:href="#E1250-MJMATHI-79" x="13121" y="0"/><g transform="translate(13618,0)"><use xlink:href="#E1250-MJMAIN-29" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1250-MJMATHI-54" x="550" y="583"/></g><use xlink:href="#E1250-MJMATHI-6C" x="14606" y="0"/><use xlink:href="#E1250-MJMATHI-6F" x="14905" y="0"/><use xlink:href="#E1250-MJMATHI-67" x="15390" y="0"/><use xlink:href="#E1250-MJMAIN-28" x="15871" y="0"/><use xlink:href="#E1250-MJMAIN-31" x="16260" y="0"/><use xlink:href="#E1250-MJMAIN-2212" x="16983" y="0"/><use xlink:href="#E1250-MJMATHI-68" x="17984" y="0"/><use xlink:href="#E1250-MJMAIN-29" x="18560" y="0"/><use xlink:href="#E1250-MJMAIN-29" x="18950" y="0"/></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-1177">
J(\theta) = \frac{1}{m} .(-y^Tlog(h)-(1-y)^Tlog(1 -h))
</script></div><h5 id="54-simplified-gradient-descent"><a name="header-c268" class="md-header-anchor "></a>5.4 Simplified Gradient Descent</h5><p>Repeat{</p><div class="mathjax-block" style="" contenteditable="false" cid="c270" mdtype="math_block" id="math-jaxc270"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-112-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="36.013ex" height="6.884ex" viewbox="0 -1670.4 15505.7 2964.1" role="img" focusable="false" style="vertical-align: -3.005ex;"><defs><path stroke-width="1" id="E121-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E121-MJMATHI-6A" d="M297 596Q297 627 318 644T361 661Q378 661 389 651T403 623Q403 595 384 576T340 557Q322 557 310 567T297 596ZM288 376Q288 405 262 405Q240 405 220 393T185 362T161 325T144 293L137 279Q135 278 121 278H107Q101 284 101 286T105 299Q126 348 164 391T252 441Q253 441 260 441T272 442Q296 441 316 432Q341 418 354 401T367 348V332L318 133Q267 -67 264 -75Q246 -125 194 -164T75 -204Q25 -204 7 -183T-12 -137Q-12 -110 7 -91T53 -71Q70 -71 82 -81T95 -112Q95 -148 63 -167Q69 -168 77 -168Q111 -168 139 -140T182 -74L193 -32Q204 11 219 72T251 197T278 308T289 365Q289 372 288 376Z"/><path stroke-width="1" id="E121-MJMAIN-3A" d="M78 370Q78 394 95 412T138 430Q162 430 180 414T199 371Q199 346 182 328T139 310T96 327T78 370ZM78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"/><path stroke-width="1" id="E121-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E121-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E121-MJMATHI-61" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"/><path stroke-width="1" id="E121-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E121-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E121-MJSZ2-2211" d="M60 948Q63 950 665 950H1267L1325 815Q1384 677 1388 669H1348L1341 683Q1320 724 1285 761Q1235 809 1174 838T1033 881T882 898T699 902H574H543H251L259 891Q722 258 724 252Q725 250 724 246Q721 243 460 -56L196 -356Q196 -357 407 -357Q459 -357 548 -357T676 -358Q812 -358 896 -353T1063 -332T1204 -283T1307 -196Q1328 -170 1348 -124H1388Q1388 -125 1381 -145T1356 -210T1325 -294L1267 -449L666 -450Q64 -450 61 -448Q55 -446 55 -439Q55 -437 57 -433L590 177Q590 178 557 222T452 366T322 544L56 909L55 924Q55 945 60 948Z"/><path stroke-width="1" id="E121-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E121-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E121-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E121-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E121-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E121-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E121-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E121-MJMATHI-6A" x="663" y="-213"/><g transform="translate(1138,0)"><use xlink:href="#E121-MJMAIN-3A"/><use xlink:href="#E121-MJMAIN-3D" x="278" y="0"/></g><g transform="translate(2473,0)"><use xlink:href="#E121-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E121-MJMATHI-6A" x="663" y="-213"/></g><use xlink:href="#E121-MJMAIN-2212" x="3557" y="0"/><use xlink:href="#E121-MJMATHI-61" x="4557" y="0"/><g transform="translate(5087,0)"><g transform="translate(120,0)"><rect stroke="none" width="998" height="60" x="0" y="220"/><use xlink:href="#E121-MJMAIN-31" x="249" y="676"/><use xlink:href="#E121-MJMATHI-6D" x="60" y="-686"/></g></g><g transform="translate(6492,0)"><use xlink:href="#E121-MJSZ2-2211" x="0" y="0"/><g transform="translate(147,-1090)"><use transform="scale(0.707)" xlink:href="#E121-MJMATHI-69" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E121-MJMAIN-3D" x="345" y="0"/><use transform="scale(0.707)" xlink:href="#E121-MJMAIN-31" x="1124" y="0"/></g><use transform="scale(0.707)" xlink:href="#E121-MJMATHI-6D" x="582" y="1627"/></g><use xlink:href="#E121-MJMAIN-28" x="7937" y="0"/><g transform="translate(8326,0)"><use xlink:href="#E121-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E121-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E121-MJMAIN-28" x="9335" y="0"/><g transform="translate(9724,0)"><use xlink:href="#E121-MJMATHI-78" x="0" y="0"/><g transform="translate(572,412)"><use transform="scale(0.707)" xlink:href="#E121-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E121-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E121-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E121-MJMAIN-29" x="11192" y="0"/><use xlink:href="#E121-MJMAIN-2212" x="11803" y="0"/><g transform="translate(12804,0)"><use xlink:href="#E121-MJMATHI-79" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E121-MJMATHI-69" x="706" y="583"/></g><use xlink:href="#E121-MJMAIN-29" x="13648" y="0"/><g transform="translate(14038,0)"><use xlink:href="#E121-MJMATHI-78" x="0" y="0"/><g transform="translate(572,521)"><use transform="scale(0.707)" xlink:href="#E121-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E121-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E121-MJMAIN-29" x="734" y="0"/></g><use transform="scale(0.707)" xlink:href="#E121-MJMATHI-6A" x="809" y="-430"/></g></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-112">
\theta_j := \theta_j - a\frac{1}{m}\sum_{i = 1}^{m}(h_\theta(x^{(i)}) - y^{i})  x_{j}^{(i)}
</script></div><p>}</p><p>A Vectorized implementation is:</p><div class="mathjax-block" style="" contenteditable="false" cid="c275" mdtype="math_block" id="math-jaxc275"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-1175-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="27.197ex" height="4.509ex" viewbox="0 -1186 11709.8 1941.5" role="img" focusable="false" style="vertical-align: -1.755ex;"><defs><path stroke-width="1" id="E1247-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E1247-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E1247-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E1247-MJMATHI-61" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"/><path stroke-width="1" id="E1247-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1247-MJMATHI-58" d="M42 0H40Q26 0 26 11Q26 15 29 27Q33 41 36 43T55 46Q141 49 190 98Q200 108 306 224T411 342Q302 620 297 625Q288 636 234 637H206Q200 643 200 645T202 664Q206 677 212 683H226Q260 681 347 681Q380 681 408 681T453 682T473 682Q490 682 490 671Q490 670 488 658Q484 643 481 640T465 637Q434 634 411 620L488 426L541 485Q646 598 646 610Q646 628 622 635Q617 635 609 637Q594 637 594 648Q594 650 596 664Q600 677 606 683H618Q619 683 643 683T697 681T738 680Q828 680 837 683H845Q852 676 852 672Q850 647 840 637H824Q790 636 763 628T722 611T698 593L687 584Q687 585 592 480L505 384Q505 383 536 304T601 142T638 56Q648 47 699 46Q734 46 734 37Q734 35 732 23Q728 7 725 4T711 1Q708 1 678 1T589 2Q528 2 496 2T461 1Q444 1 444 10Q444 11 446 25Q448 35 450 39T455 44T464 46T480 47T506 54Q523 62 523 64Q522 64 476 181L429 299Q241 95 236 84Q232 76 232 72Q232 53 261 47Q262 47 267 47T273 46Q276 46 277 46T280 45T283 42T284 35Q284 26 282 19Q279 6 276 4T261 1Q258 1 243 1T201 2T142 2Q64 2 42 0Z"/><path stroke-width="1" id="E1247-MJMATHI-54" d="M40 437Q21 437 21 445Q21 450 37 501T71 602L88 651Q93 669 101 677H569H659Q691 677 697 676T704 667Q704 661 687 553T668 444Q668 437 649 437Q640 437 637 437T631 442L629 445Q629 451 635 490T641 551Q641 586 628 604T573 629Q568 630 515 631Q469 631 457 630T439 622Q438 621 368 343T298 60Q298 48 386 46Q418 46 427 45T436 36Q436 31 433 22Q429 4 424 1L422 0Q419 0 415 0Q410 0 363 1T228 2Q99 2 64 0H49Q43 6 43 9T45 27Q49 40 55 46H83H94Q174 46 189 55Q190 56 191 56Q196 59 201 76T241 233Q258 301 269 344Q339 619 339 625Q339 630 310 630H279Q212 630 191 624Q146 614 121 583T67 467Q60 445 57 441T43 437H40Z"/><path stroke-width="1" id="E1247-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E1247-MJMATHI-67" d="M311 43Q296 30 267 15T206 0Q143 0 105 45T66 160Q66 265 143 353T314 442Q361 442 401 394L404 398Q406 401 409 404T418 412T431 419T447 422Q461 422 470 413T480 394Q480 379 423 152T363 -80Q345 -134 286 -169T151 -205Q10 -205 10 -137Q10 -111 28 -91T74 -71Q89 -71 102 -80T116 -111Q116 -121 114 -130T107 -144T99 -154T92 -162L90 -164H91Q101 -167 151 -167Q189 -167 211 -155Q234 -144 254 -122T282 -75Q288 -56 298 -13Q311 35 311 43ZM384 328L380 339Q377 350 375 354T369 368T359 382T346 393T328 402T306 405Q262 405 221 352Q191 313 171 233T151 117Q151 38 213 38Q269 38 323 108L331 118L384 328Z"/><path stroke-width="1" id="E1247-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E1247-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1247-MJMAIN-20D7" d="M-123 694Q-123 702 -118 708T-103 714Q-93 714 -88 706T-80 687T-67 660T-40 633Q-29 626 -29 615Q-29 606 -36 600T-53 590T-83 571T-121 531Q-135 516 -143 516T-157 522T-163 536T-152 559T-129 584T-116 595H-287L-458 596Q-459 597 -461 599T-466 602T-469 607T-471 615Q-471 622 -458 635H-99Q-123 673 -123 694Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E1247-MJMATHI-3B8" x="0" y="0"/><use xlink:href="#E1247-MJMAIN-3D" x="747" y="0"/><use xlink:href="#E1247-MJMATHI-3B8" x="1803" y="0"/><use xlink:href="#E1247-MJMAIN-2212" x="2495" y="0"/><g transform="translate(3273,0)"><g transform="translate(342,0)"><rect stroke="none" width="998" height="60" x="0" y="220"/><use xlink:href="#E1247-MJMATHI-61" x="234" y="676"/><use xlink:href="#E1247-MJMATHI-6D" x="60" y="-686"/></g></g><g transform="translate(4734,0)"><use xlink:href="#E1247-MJMATHI-58" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1247-MJMATHI-54" x="1215" y="583"/></g><use xlink:href="#E1247-MJMAIN-28" x="6192" y="0"/><use xlink:href="#E1247-MJMATHI-67" x="6581" y="0"/><use xlink:href="#E1247-MJMAIN-28" x="7062" y="0"/><use xlink:href="#E1247-MJMATHI-58" x="7451" y="0"/><use xlink:href="#E1247-MJMATHI-3B8" x="8304" y="0"/><use xlink:href="#E1247-MJMAIN-29" x="8773" y="0"/><use xlink:href="#E1247-MJMAIN-2212" x="9385" y="0"/><g transform="translate(10386,0)"><use xlink:href="#E1247-MJMATHI-79" x="0" y="0"/><use xlink:href="#E1247-MJMAIN-20D7" x="543" y="9"/></g><use xlink:href="#E1247-MJMAIN-29" x="10930" y="0"/><use xlink:href="#E1247-MJMAIN-29" x="11320" y="0"/></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-1175">
\theta = \theta - \frac{a}{m}X^T(g(X\theta) - \vec{y} ))
</script></div><h5 id="55-advance-optimization"><a name="header-c277" class="md-header-anchor "></a>5.5 Advance Optimization</h5><p>Octave provides library to calculate optimize <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-71-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.09ex" height="2.134ex" viewbox="0 -809.3 469.5 918.9" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E71-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E71-MJMATHI-3B8" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-71">\theta</script>,so we only use it</p><p>We first need to provide a function that evaluates the following two function for a given input value <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-71-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.09ex" height="2.134ex" viewbox="0 -809.3 469.5 918.9" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E71-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E71-MJMATHI-3B8" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-71">\theta</script>:</p><p>J(<span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-71-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.09ex" height="2.134ex" viewbox="0 -809.3 469.5 918.9" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E71-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E71-MJMATHI-3B8" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-71">\theta</script>)</p><p><span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-72-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="7.494ex" height="4.009ex" viewbox="0 -1024.6 3226.8 1726.2" role="img" focusable="false" style="vertical-align: -1.63ex;"><defs><path stroke-width="1" id="E72-MJMAIN-2202" d="M202 508Q179 508 169 520T158 547Q158 557 164 577T185 624T230 675T301 710L333 715H345Q378 715 384 714Q447 703 489 661T549 568T566 457Q566 362 519 240T402 53Q321 -22 223 -22Q123 -22 73 56Q42 102 42 148V159Q42 276 129 370T322 465Q383 465 414 434T455 367L458 378Q478 461 478 515Q478 603 437 639T344 676Q266 676 223 612Q264 606 264 572Q264 547 246 528T202 508ZM430 306Q430 372 401 400T333 428Q270 428 222 382Q197 354 183 323T150 221Q132 149 132 116Q132 21 232 21Q244 21 250 22Q327 35 374 112Q389 137 409 196T430 306Z"/><path stroke-width="1" id="E72-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E72-MJMATHI-6A" d="M297 596Q297 627 318 644T361 661Q378 661 389 651T403 623Q403 595 384 576T340 557Q322 557 310 567T297 596ZM288 376Q288 405 262 405Q240 405 220 393T185 362T161 325T144 293L137 279Q135 278 121 278H107Q101 284 101 286T105 299Q126 348 164 391T252 441Q253 441 260 441T272 442Q296 441 316 432Q341 418 354 401T367 348V332L318 133Q267 -67 264 -75Q246 -125 194 -164T75 -204Q25 -204 7 -183T-12 -137Q-12 -110 7 -91T53 -71Q70 -71 82 -81T95 -112Q95 -148 63 -167Q69 -168 77 -168Q111 -168 139 -140T182 -74L193 -32Q204 11 219 72T251 197T278 308T289 365Q289 372 288 376Z"/><path stroke-width="1" id="E72-MJMATHI-4A" d="M447 625Q447 637 354 637H329Q323 642 323 645T325 664Q329 677 335 683H352Q393 681 498 681Q541 681 568 681T605 682T619 682Q633 682 633 672Q633 670 630 658Q626 642 623 640T604 637Q552 637 545 623Q541 610 483 376Q420 128 419 127Q397 64 333 21T195 -22Q137 -22 97 8T57 88Q57 130 80 152T132 174Q177 174 182 130Q182 98 164 80T123 56Q115 54 115 53T122 44Q148 15 197 15Q235 15 271 47T324 130Q328 142 387 380T447 625Z"/><path stroke-width="1" id="E72-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E72-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><g transform="translate(120,0)"><rect stroke="none" width="1104" height="60" x="0" y="220"/><use transform="scale(0.707)" xlink:href="#E72-MJMAIN-2202" x="515" y="604"/><g transform="translate(60,-418)"><use transform="scale(0.707)" xlink:href="#E72-MJMAIN-2202" x="0" y="0"/><g transform="translate(375,0)"><use transform="scale(0.707)" xlink:href="#E72-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.5)" xlink:href="#E72-MJMATHI-6A" x="663" y="-213"/></g></g></g><use xlink:href="#E72-MJMATHI-4A" x="1344" y="0"/><use xlink:href="#E72-MJMAIN-28" x="1978" y="0"/><use xlink:href="#E72-MJMATHI-3B8" x="2367" y="0"/><use xlink:href="#E72-MJMAIN-29" x="2837" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-72">\frac{∂}{∂\theta_j}J(\theta)</script></p><p>We can write a single function that both of these</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="octave"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><div style="width: 50px; height: 50px; overflow-x: scroll;"></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-builtin">function</span> [<span class="cm-variable">jVal</span>,<span class="cm-variable">gradient</span>] = <span class="cm-variable">CostFunction</span>(<span class="cm-variable">theta</span>)</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">jVal</span> = [<span class="cm-comment">...code to compute J(theta)...];</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">gradient</span> = [<span class="cm-comment">...code to compute derivate of J(theta)...];</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">4</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-keyword">end</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 96px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>then we can use octave&#39;s&quot;fminuce()&quot; optimization algorithm along the &quot;optimset()&quot; function that creates an object containing the options we want to send to &quot;fiminuc()&quot;</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="octave"> <div class="CodeMirror cm-s-inner CodeMirror-wrap   "><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><div style="width: 50px; height: 50px; overflow-x: scroll;"></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">options</span> = <span class="cm-variable">optimset</span>(<span class="cm-string">'GradObj'</span>,<span class="cm-string">'on'</span>,<span class="cm-string">'MaxIter'</span>,<span class="cm-number">100</span>);</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">initialTheta</span> = <span class="cm-builtin">zeros</span>(<span class="cm-number">2</span>,<span class="cm-number">1</span>);</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;">[<span class="cm-variable">optTheta</span>,<span class="cm-variable">functionVal</span>,<span class="cm-variable">exitFlag</span>] = <span class="cm-variable">fminunc</span>(<span class="cm-operator">@</span><span class="cm-variable">cosFunction</span>,<span class="cm-variable">initialTheta</span>,<span class="cm-variable">options</span>);</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 96px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><h5 id="56-multiclass-classficationone-vs-all"><a name="header-c292" class="md-header-anchor "></a>5.6 Multiclass Classfication:One-vs-all</h5><p>Now will approach the classification of data when we have more than categories.insted of y = {0,1} we will expand our definition  so that y = {0,1…n}.</p><p>Since y = {0,1,…n},we divide our problem into n+1 binary classification problems;in each one, we predict the probability that &#39;y&#39; is a member of one of our classes.</p><pre class="md-fences mock-cm" style="display:block;position:relative">y∈{0,1...n}
h(0)θ(x)=P(y=0|x;θ)
h(1)θ(x)=P(y=1|x;θ)
⋯
h(n)θ(x)=P(y=n|x;θ)
prediction=maxi(h(i)θ(x))</pre><p>We are basically choosing one class and then lumping all the others into a single second class. We do this repeatedly, applying binary logistic regression to each case, and then use the hypothesis that returned the highest value as our prediction.such as:</p><p><img src="https://ws2.sinaimg.cn/large/006tNbRwgy1fg3r6d42caj30d507ajsa.jpg" alt="cqmPjanSEeawbAp5ByfpEg_299fcfbd527b6b5a7440825628339c54_Screenshot-2016-11-13-10.52.29"></p><p>To make a prediction on a new x, pick the class ￼that maximizes <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-73-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.481ex" height="2.634ex" viewbox="0 -809.3 2360 1134.2" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E73-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E73-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E73-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E73-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E73-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E73-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E73-MJMATHI-3B8" x="815" y="-219"/><use xlink:href="#E73-MJMAIN-28" x="1008" y="0"/><use xlink:href="#E73-MJMATHI-78" x="1397" y="0"/><use xlink:href="#E73-MJMAIN-29" x="1970" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-73">h_\theta(x)</script>.</p><h4 id="6solving-the-problem-of-over-fitting"><a name="header-c304" class="md-header-anchor "></a>6.Solving the Problem of Over fitting</h4><h5 id="61-the-problem-of-overfitting"><a name="header-c305" class="md-header-anchor "></a>6.1 The Problem of Overfitting</h5><p><img src="https://ws3.sinaimg.cn/large/006tNbRwgy1fg3r69xwgjj30f0046dg7.jpg" alt="0cOOdKsMEeaCrQqTpeD5ng_2a806eb8d988461f716f4799915ab779_Screenshot-2016-11-15-00.23.30"></p><p>The figure on the left shown an instance of underfitting- in which the data clearly structure not captured by the model-and the figure on the right is an example of overfilling.</p><p><strong>Underfitting,or high bias</strong>,is when the form of our hypothesis function h maps poorly to the trend of the data It is usually caused by a function that is too simple or use too few features.</p><p><strong>Overfitting, or hight variance</strong>,,is caused by hypothesis function that fit the available data but don&#39;t generalize well to predict new data.It is usually caused by a complicated function that creates a lot of unnecessary curves and angles unrelated to the data.</p><p>This terminology is applied to both linear and logistic regression.there are two option to address the issue of overfitting</p><p>1)Reduce the number of features:</p><ul><li>Manually select which features to keep.</li><li>Use a model selection algorithm(studied later in the course)</li></ul><p>2) Regularization</p><ul><li>Keep all the features,but reduce the magnitude of parameters <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-74-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2ex" height="2.759ex" viewbox="0 -809.3 861.2 1188" role="img" focusable="false" style="vertical-align: -0.88ex;"><defs><path stroke-width="1" id="E74-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E74-MJMATHI-6A" d="M297 596Q297 627 318 644T361 661Q378 661 389 651T403 623Q403 595 384 576T340 557Q322 557 310 567T297 596ZM288 376Q288 405 262 405Q240 405 220 393T185 362T161 325T144 293L137 279Q135 278 121 278H107Q101 284 101 286T105 299Q126 348 164 391T252 441Q253 441 260 441T272 442Q296 441 316 432Q341 418 354 401T367 348V332L318 133Q267 -67 264 -75Q246 -125 194 -164T75 -204Q25 -204 7 -183T-12 -137Q-12 -110 7 -91T53 -71Q70 -71 82 -81T95 -112Q95 -148 63 -167Q69 -168 77 -168Q111 -168 139 -140T182 -74L193 -32Q204 11 219 72T251 197T278 308T289 365Q289 372 288 376Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E74-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E74-MJMATHI-6A" x="663" y="-213"/></g></svg></span><script type="math/tex" id="MathJax-Element-74">\theta_j</script></li><li>Regularization works well when we have a lot of slightly useful features.</li></ul><h5 id="62-cost-function"><a name="header-c334" class="md-header-anchor "></a>6.2 Cost Function</h5><p>We regularize all of our theta paramter in single summation as:</p><div class="mathjax-block" contenteditable="false" style="" cid="c361" mdtype="math_block" id="math-jaxc361"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-1143-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="39.995ex" height="7.134ex" viewbox="0 -1670.4 17220.1 3071.7" role="img" focusable="false" style="vertical-align: -3.255ex;"><defs><path stroke-width="1" id="E1206-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1206-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1206-MJMATHI-6E" d="M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1206-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E1206-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E1206-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"/><path stroke-width="1" id="E1206-MJSZ2-2211" d="M60 948Q63 950 665 950H1267L1325 815Q1384 677 1388 669H1348L1341 683Q1320 724 1285 761Q1235 809 1174 838T1033 881T882 898T699 902H574H543H251L259 891Q722 258 724 252Q725 250 724 246Q721 243 460 -56L196 -356Q196 -357 407 -357Q459 -357 548 -357T676 -358Q812 -358 896 -353T1063 -332T1204 -283T1307 -196Q1328 -170 1348 -124H1388Q1388 -125 1381 -145T1356 -210T1325 -294L1267 -449L666 -450Q64 -450 61 -448Q55 -446 55 -439Q55 -437 57 -433L590 177Q590 178 557 222T452 366T322 544L56 909L55 924Q55 945 60 948Z"/><path stroke-width="1" id="E1206-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E1206-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E1206-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E1206-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E1206-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E1206-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E1206-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1206-MJMAIN-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"/><path stroke-width="1" id="E1206-MJMATHI-3BB" d="M166 673Q166 685 183 694H202Q292 691 316 644Q322 629 373 486T474 207T524 67Q531 47 537 34T546 15T551 6T555 2T556 -2T550 -11H482Q457 3 450 18T399 152L354 277L340 262Q327 246 293 207T236 141Q211 112 174 69Q123 9 111 -1T83 -12Q47 -12 47 20Q47 37 61 52T199 187Q229 216 266 252T321 306L338 322Q338 323 288 462T234 612Q214 657 183 657Q166 657 166 673Z"/><path stroke-width="1" id="E1206-MJMATHI-6A" d="M297 596Q297 627 318 644T361 661Q378 661 389 651T403 623Q403 595 384 576T340 557Q322 557 310 567T297 596ZM288 376Q288 405 262 405Q240 405 220 393T185 362T161 325T144 293L137 279Q135 278 121 278H107Q101 284 101 286T105 299Q126 348 164 391T252 441Q253 441 260 441T272 442Q296 441 316 432Q341 418 354 401T367 348V332L318 133Q267 -67 264 -75Q246 -125 194 -164T75 -204Q25 -204 7 -183T-12 -137Q-12 -110 7 -91T53 -71Q70 -71 82 -81T95 -112Q95 -148 63 -167Q69 -168 77 -168Q111 -168 139 -140T182 -74L193 -32Q204 11 219 72T251 197T278 308T289 365Q289 372 288 376Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E1206-MJMATHI-6D" x="0" y="0"/><use xlink:href="#E1206-MJMATHI-69" x="878" y="0"/><g transform="translate(1224,0)"><use xlink:href="#E1206-MJMATHI-6E" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMATHI-3B8" x="849" y="-219"/></g><g transform="translate(2256,0)"><g transform="translate(120,0)"><rect stroke="none" width="1499" height="60" x="0" y="220"/><use xlink:href="#E1206-MJMAIN-31" x="499" y="676"/><g transform="translate(60,-686)"><use xlink:href="#E1206-MJMAIN-32" x="0" y="0"/><use xlink:href="#E1206-MJMATHI-6D" x="500" y="0"/></g></g></g><g transform="translate(4162,0)"><use xlink:href="#E1206-MJSZ2-2211" x="0" y="0"/><g transform="translate(147,-1090)"><use transform="scale(0.707)" xlink:href="#E1206-MJMATHI-69" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMAIN-3D" x="345" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMAIN-31" x="1124" y="0"/></g><use transform="scale(0.707)" xlink:href="#E1206-MJMATHI-6D" x="582" y="1627"/></g><use xlink:href="#E1206-MJMAIN-28" x="5606" y="0"/><g transform="translate(5996,0)"><use xlink:href="#E1206-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E1206-MJMAIN-28" x="7004" y="0"/><g transform="translate(7394,0)"><use xlink:href="#E1206-MJMATHI-78" x="0" y="0"/><g transform="translate(572,412)"><use transform="scale(0.707)" xlink:href="#E1206-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E1206-MJMAIN-29" x="8861" y="0"/><use xlink:href="#E1206-MJMAIN-2212" x="9473" y="0"/><g transform="translate(10474,0)"><use xlink:href="#E1206-MJMATHI-79" x="0" y="0"/><g transform="translate(499,412)"><use transform="scale(0.707)" xlink:href="#E1206-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMAIN-29" x="734" y="0"/></g></g><g transform="translate(11869,0)"><use xlink:href="#E1206-MJMAIN-29" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMAIN-32" x="550" y="583"/></g><use xlink:href="#E1206-MJMAIN-2B" x="12934" y="0"/><use xlink:href="#E1206-MJMATHI-3BB" x="13935" y="0"/><g transform="translate(14685,0)"><use xlink:href="#E1206-MJSZ2-2211" x="0" y="0"/><g transform="translate(124,-1090)"><use transform="scale(0.707)" xlink:href="#E1206-MJMATHI-6A" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMAIN-3D" x="412" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMAIN-31" x="1191" y="0"/></g><use transform="scale(0.707)" xlink:href="#E1206-MJMATHI-6E" x="721" y="1627"/></g><g transform="translate(16296,0)"><use xlink:href="#E1206-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1206-MJMAIN-32" x="663" y="488"/><use transform="scale(0.707)" xlink:href="#E1206-MJMATHI-6A" x="663" y="-430"/></g></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-1143">
min_\theta\frac{1}{2m} \sum_{i = 1}^{m}(h_\theta(x^{(i)}) - y^{(i)})^2 + \lambda\sum_{j = 1}^{n}\theta_{j}^2
</script></div><p>The <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-235-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.355ex" height="2.009ex" viewbox="0 -755.5 583.5 865.1" role="img" focusable="false" style="vertical-align: -0.255ex;"><defs><path stroke-width="1" id="E254-MJMATHI-3BB" d="M166 673Q166 685 183 694H202Q292 691 316 644Q322 629 373 486T474 207T524 67Q531 47 537 34T546 15T551 6T555 2T556 -2T550 -11H482Q457 3 450 18T399 152L354 277L340 262Q327 246 293 207T236 141Q211 112 174 69Q123 9 111 -1T83 -12Q47 -12 47 20Q47 37 61 52T199 187Q229 216 266 252T321 306L338 322Q338 323 288 462T234 612Q214 657 183 657Q166 657 166 673Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E254-MJMATHI-3BB" x="0" y="0"/></g></svg></span><script type="math/tex" id="MathJax-Element-235">\lambda</script>,or lambda,is the regularization parameter. it determines how much the cost of theta are inflated.</p><h5 id="63-regularized-linear-regression"><a name="header-c372" class="md-header-anchor "></a>6.3 Regularized Linear Regression</h5><p> We can apply regularization to lineat regression and logistic regression</p><p>Gradient Descent </p><p>We will modify our gradient descent function to separate out θ0 from the rest of the parameters because we do not want to penalize θ0</p><p>Repeat{</p><div class="mathjax-block" style="" contenteditable="false" cid="c414" mdtype="math_block" id="math-jaxc414"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-1154-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="36.677ex" height="6.884ex" viewbox="0 -1670.4 15791.5 2964.1" role="img" focusable="false" style="vertical-align: -3.005ex;"><defs><path stroke-width="1" id="E1220-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E1220-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/><path stroke-width="1" id="E1220-MJMAIN-3A" d="M78 370Q78 394 95 412T138 430Q162 430 180 414T199 371Q199 346 182 328T139 310T96 327T78 370ZM78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"/><path stroke-width="1" id="E1220-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E1220-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E1220-MJMATHI-61" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"/><path stroke-width="1" id="E1220-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E1220-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1220-MJSZ2-2211" d="M60 948Q63 950 665 950H1267L1325 815Q1384 677 1388 669H1348L1341 683Q1320 724 1285 761Q1235 809 1174 838T1033 881T882 898T699 902H574H543H251L259 891Q722 258 724 252Q725 250 724 246Q721 243 460 -56L196 -356Q196 -357 407 -357Q459 -357 548 -357T676 -358Q812 -358 896 -353T1063 -332T1204 -283T1307 -196Q1328 -170 1348 -124H1388Q1388 -125 1381 -145T1356 -210T1325 -294L1267 -449L666 -450Q64 -450 61 -448Q55 -446 55 -439Q55 -437 57 -433L590 177Q590 178 557 222T452 366T322 544L56 909L55 924Q55 945 60 948Z"/><path stroke-width="1" id="E1220-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1220-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E1220-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E1220-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E1220-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E1220-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E1220-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1220-MJMAIN-30" x="663" y="-213"/><g transform="translate(1201,0)"><use xlink:href="#E1220-MJMAIN-3A"/><use xlink:href="#E1220-MJMAIN-3D" x="278" y="0"/></g><g transform="translate(2535,0)"><use xlink:href="#E1220-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1220-MJMAIN-30" x="663" y="-213"/></g><use xlink:href="#E1220-MJMAIN-2212" x="3681" y="0"/><use xlink:href="#E1220-MJMATHI-61" x="4682" y="0"/><g transform="translate(5211,0)"><g transform="translate(120,0)"><rect stroke="none" width="998" height="60" x="0" y="220"/><use xlink:href="#E1220-MJMAIN-31" x="249" y="676"/><use xlink:href="#E1220-MJMATHI-6D" x="60" y="-686"/></g></g><g transform="translate(6616,0)"><use xlink:href="#E1220-MJSZ2-2211" x="0" y="0"/><g transform="translate(147,-1090)"><use transform="scale(0.707)" xlink:href="#E1220-MJMATHI-69" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1220-MJMAIN-3D" x="345" y="0"/><use transform="scale(0.707)" xlink:href="#E1220-MJMAIN-31" x="1124" y="0"/></g><use transform="scale(0.707)" xlink:href="#E1220-MJMATHI-6D" x="582" y="1627"/></g><use xlink:href="#E1220-MJMAIN-28" x="8061" y="0"/><g transform="translate(8450,0)"><use xlink:href="#E1220-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1220-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E1220-MJMAIN-28" x="9459" y="0"/><g transform="translate(9848,0)"><use xlink:href="#E1220-MJMATHI-78" x="0" y="0"/><g transform="translate(572,412)"><use transform="scale(0.707)" xlink:href="#E1220-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1220-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1220-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E1220-MJMAIN-2212" x="11538" y="0"/><g transform="translate(12539,0)"><use xlink:href="#E1220-MJMATHI-79" x="0" y="0"/><g transform="translate(499,412)"><use transform="scale(0.707)" xlink:href="#E1220-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1220-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1220-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E1220-MJMAIN-29" x="13934" y="0"/><g transform="translate(14323,0)"><use xlink:href="#E1220-MJMATHI-78" x="0" y="0"/><g transform="translate(572,521)"><use transform="scale(0.707)" xlink:href="#E1220-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1220-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1220-MJMAIN-29" x="734" y="0"/></g><use transform="scale(0.707)" xlink:href="#E1220-MJMAIN-30" x="809" y="-435"/></g></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-1154">
\theta_0 := \theta_0 - a \frac{1}{m}\sum_{i = 1}^{m}(h_\theta(x^{(i)}-y^{(i)})x_0^{(i)}
</script></div><div class="mathjax-block" style="" contenteditable="false" cid="c417" mdtype="math_block" id="math-jaxc417"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-1205-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="67.277ex" height="6.884ex" viewbox="0 -1670.4 28966.6 2964.1" role="img" focusable="false" style="vertical-align: -3.005ex;"><defs><path stroke-width="1" id="E1298-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E1298-MJMATHI-6A" d="M297 596Q297 627 318 644T361 661Q378 661 389 651T403 623Q403 595 384 576T340 557Q322 557 310 567T297 596ZM288 376Q288 405 262 405Q240 405 220 393T185 362T161 325T144 293L137 279Q135 278 121 278H107Q101 284 101 286T105 299Q126 348 164 391T252 441Q253 441 260 441T272 442Q296 441 316 432Q341 418 354 401T367 348V332L318 133Q267 -67 264 -75Q246 -125 194 -164T75 -204Q25 -204 7 -183T-12 -137Q-12 -110 7 -91T53 -71Q70 -71 82 -81T95 -112Q95 -148 63 -167Q69 -168 77 -168Q111 -168 139 -140T182 -74L193 -32Q204 11 219 72T251 197T278 308T289 365Q289 372 288 376Z"/><path stroke-width="1" id="E1298-MJMAIN-3A" d="M78 370Q78 394 95 412T138 430Q162 430 180 414T199 371Q199 346 182 328T139 310T96 327T78 370ZM78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"/><path stroke-width="1" id="E1298-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E1298-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E1298-MJMATHI-61" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"/><path stroke-width="1" id="E1298-MJMAIN-5B" d="M118 -250V750H255V710H158V-210H255V-250H118Z"/><path stroke-width="1" id="E1298-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E1298-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E1298-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1298-MJSZ2-2211" d="M60 948Q63 950 665 950H1267L1325 815Q1384 677 1388 669H1348L1341 683Q1320 724 1285 761Q1235 809 1174 838T1033 881T882 898T699 902H574H543H251L259 891Q722 258 724 252Q725 250 724 246Q721 243 460 -56L196 -356Q196 -357 407 -357Q459 -357 548 -357T676 -358Q812 -358 896 -353T1063 -332T1204 -283T1307 -196Q1328 -170 1348 -124H1388Q1388 -125 1381 -145T1356 -210T1325 -294L1267 -449L666 -450Q64 -450 61 -448Q55 -446 55 -439Q55 -437 57 -433L590 177Q590 178 557 222T452 366T322 544L56 909L55 924Q55 945 60 948Z"/><path stroke-width="1" id="E1298-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1298-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E1298-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E1298-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E1298-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1298-MJMAIN-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"/><path stroke-width="1" id="E1298-MJMATHI-3BB" d="M166 673Q166 685 183 694H202Q292 691 316 644Q322 629 373 486T474 207T524 67Q531 47 537 34T546 15T551 6T555 2T556 -2T550 -11H482Q457 3 450 18T399 152L354 277L340 262Q327 246 293 207T236 141Q211 112 174 69Q123 9 111 -1T83 -12Q47 -12 47 20Q47 37 61 52T199 187Q229 216 266 252T321 306L338 322Q338 323 288 462T234 612Q214 657 183 657Q166 657 166 673Z"/><path stroke-width="1" id="E1298-MJMAIN-5D" d="M22 710V750H159V-250H22V-210H119V710H22Z"/><path stroke-width="1" id="E1298-MJMAIN-3E" d="M84 520Q84 528 88 533T96 539L99 540Q106 540 253 471T544 334L687 265Q694 260 694 250T687 235Q685 233 395 96L107 -40H101Q83 -38 83 -20Q83 -19 83 -17Q82 -10 98 -1Q117 9 248 71Q326 108 378 132L626 250L378 368Q90 504 86 509Q84 513 84 520Z"/><path stroke-width="1" id="E1298-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E1298-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMATHI-6A" x="663" y="-213"/><g transform="translate(1138,0)"><use xlink:href="#E1298-MJMAIN-3A"/><use xlink:href="#E1298-MJMAIN-3D" x="278" y="0"/></g><g transform="translate(2473,0)"><use xlink:href="#E1298-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMATHI-6A" x="663" y="-213"/></g><use xlink:href="#E1298-MJMAIN-2212" x="3557" y="0"/><use xlink:href="#E1298-MJMATHI-61" x="4557" y="0"/><use xlink:href="#E1298-MJMAIN-5B" x="5087" y="0"/><use xlink:href="#E1298-MJMAIN-28" x="5365" y="0"/><g transform="translate(5755,0)"><g transform="translate(120,0)"><rect stroke="none" width="998" height="60" x="0" y="220"/><use xlink:href="#E1298-MJMAIN-31" x="249" y="676"/><use xlink:href="#E1298-MJMATHI-6D" x="60" y="-686"/></g></g><g transform="translate(7160,0)"><use xlink:href="#E1298-MJSZ2-2211" x="0" y="0"/><g transform="translate(147,-1090)"><use transform="scale(0.707)" xlink:href="#E1298-MJMATHI-69" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMAIN-3D" x="345" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMAIN-31" x="1124" y="0"/></g><use transform="scale(0.707)" xlink:href="#E1298-MJMATHI-6D" x="582" y="1627"/></g><use xlink:href="#E1298-MJMAIN-28" x="8605" y="0"/><g transform="translate(8994,0)"><use xlink:href="#E1298-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E1298-MJMAIN-28" x="10003" y="0"/><g transform="translate(10392,0)"><use xlink:href="#E1298-MJMATHI-78" x="0" y="0"/><g transform="translate(572,412)"><use transform="scale(0.707)" xlink:href="#E1298-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E1298-MJMAIN-29" x="11860" y="0"/><use xlink:href="#E1298-MJMAIN-2212" x="12471" y="0"/><g transform="translate(13472,0)"><use xlink:href="#E1298-MJMATHI-79" x="0" y="0"/><g transform="translate(499,412)"><use transform="scale(0.707)" xlink:href="#E1298-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E1298-MJMAIN-29" x="14867" y="0"/><g transform="translate(15256,0)"><use xlink:href="#E1298-MJMATHI-78" x="0" y="0"/><g transform="translate(572,521)"><use transform="scale(0.707)" xlink:href="#E1298-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMAIN-29" x="734" y="0"/></g><use transform="scale(0.707)" xlink:href="#E1298-MJMATHI-6A" x="809" y="-430"/></g><use xlink:href="#E1298-MJMAIN-29" x="16724" y="0"/><use xlink:href="#E1298-MJMAIN-2B" x="17336" y="0"/><g transform="translate(18114,0)"><g transform="translate(342,0)"><rect stroke="none" width="998" height="60" x="0" y="220"/><use xlink:href="#E1298-MJMATHI-3BB" x="207" y="676"/><use xlink:href="#E1298-MJMATHI-6D" x="60" y="-686"/></g></g><g transform="translate(19575,0)"><use xlink:href="#E1298-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1298-MJMATHI-6A" x="663" y="-213"/></g><use xlink:href="#E1298-MJMAIN-5D" x="20436" y="0"/><use xlink:href="#E1298-MJMAIN-2212" x="20937" y="0"/><use xlink:href="#E1298-MJMAIN-2212" x="21938" y="0"/><use xlink:href="#E1298-MJMAIN-2212" x="22938" y="0"/><use xlink:href="#E1298-MJMAIN-2212" x="23939" y="0"/><use xlink:href="#E1298-MJMAIN-2212" x="24940" y="0"/><use xlink:href="#E1298-MJMAIN-2212" x="25940" y="0"/><use xlink:href="#E1298-MJMATHI-6A" x="26719" y="0"/><use xlink:href="#E1298-MJMAIN-3E" x="27409" y="0"/><use xlink:href="#E1298-MJMAIN-30" x="28466" y="0"/></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-1205">
\theta_j := \theta_j - a [(\frac{1}{m}\sum_{i = 1}^{m}(h_\theta(x^{(i)})-y^{(i)})x_j^{(i)}) + \frac{\lambda}{m}\theta_j]------j>0
</script></div><p>}</p><p>The term <span class="MathJax_Preview"></span><span class="MathJax_SVG" id="MathJax-Element-434-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="4.279ex" height="3.259ex" viewbox="0 -970.7 1842.4 1403.3" role="img" focusable="false" style="vertical-align: -1.005ex;"><defs><path stroke-width="1" id="E480-MJMATHI-3BB" d="M166 673Q166 685 183 694H202Q292 691 316 644Q322 629 373 486T474 207T524 67Q531 47 537 34T546 15T551 6T555 2T556 -2T550 -11H482Q457 3 450 18T399 152L354 277L340 262Q327 246 293 207T236 141Q211 112 174 69Q123 9 111 -1T83 -12Q47 -12 47 20Q47 37 61 52T199 187Q229 216 266 252T321 306L338 322Q338 323 288 462T234 612Q214 657 183 657Q166 657 166 673Z"/><path stroke-width="1" id="E480-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E480-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E480-MJMATHI-6A" d="M297 596Q297 627 318 644T361 661Q378 661 389 651T403 623Q403 595 384 576T340 557Q322 557 310 567T297 596ZM288 376Q288 405 262 405Q240 405 220 393T185 362T161 325T144 293L137 279Q135 278 121 278H107Q101 284 101 286T105 299Q126 348 164 391T252 441Q253 441 260 441T272 442Q296 441 316 432Q341 418 354 401T367 348V332L318 133Q267 -67 264 -75Q246 -125 194 -164T75 -204Q25 -204 7 -183T-12 -137Q-12 -110 7 -91T53 -71Q70 -71 82 -81T95 -112Q95 -148 63 -167Q69 -168 77 -168Q111 -168 139 -140T182 -74L193 -32Q204 11 219 72T251 197T278 308T289 365Q289 372 288 376Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><g transform="translate(120,0)"><rect stroke="none" width="741" height="60" x="0" y="220"/><use transform="scale(0.707)" xlink:href="#E480-MJMATHI-3BB" x="232" y="594"/><use transform="scale(0.707)" xlink:href="#E480-MJMATHI-6D" x="84" y="-488"/></g><g transform="translate(981,0)"><use xlink:href="#E480-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E480-MJMATHI-6A" x="663" y="-213"/></g></g></svg></span><script type="math/tex" id="MathJax-Element-434">\frac{\lambda}{m}\theta_j</script> performs our regularization. With some manipulation our update rule can also be represented as:</p><div class="mathjax-block" contenteditable="false" style="" cid="c443" mdtype="math_block" id="math-jaxc443"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-552-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="47.211ex" height="6.884ex" viewbox="0 -1670.4 20327 2964.1" role="img" focusable="false" style="vertical-align: -3.005ex;"><defs><path stroke-width="1" id="E600-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E600-MJMATHI-6A" d="M297 596Q297 627 318 644T361 661Q378 661 389 651T403 623Q403 595 384 576T340 557Q322 557 310 567T297 596ZM288 376Q288 405 262 405Q240 405 220 393T185 362T161 325T144 293L137 279Q135 278 121 278H107Q101 284 101 286T105 299Q126 348 164 391T252 441Q253 441 260 441T272 442Q296 441 316 432Q341 418 354 401T367 348V332L318 133Q267 -67 264 -75Q246 -125 194 -164T75 -204Q25 -204 7 -183T-12 -137Q-12 -110 7 -91T53 -71Q70 -71 82 -81T95 -112Q95 -148 63 -167Q69 -168 77 -168Q111 -168 139 -140T182 -74L193 -32Q204 11 219 72T251 197T278 308T289 365Q289 372 288 376Z"/><path stroke-width="1" id="E600-MJMAIN-3A" d="M78 370Q78 394 95 412T138 430Q162 430 180 414T199 371Q199 346 182 328T139 310T96 327T78 370ZM78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"/><path stroke-width="1" id="E600-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E600-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E600-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E600-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E600-MJMATHI-61" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"/><path stroke-width="1" id="E600-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E600-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E600-MJSZ2-2211" d="M60 948Q63 950 665 950H1267L1325 815Q1384 677 1388 669H1348L1341 683Q1320 724 1285 761Q1235 809 1174 838T1033 881T882 898T699 902H574H543H251L259 891Q722 258 724 252Q725 250 724 246Q721 243 460 -56L196 -356Q196 -357 407 -357Q459 -357 548 -357T676 -358Q812 -358 896 -353T1063 -332T1204 -283T1307 -196Q1328 -170 1348 -124H1388Q1388 -125 1381 -145T1356 -210T1325 -294L1267 -449L666 -450Q64 -450 61 -448Q55 -446 55 -439Q55 -437 57 -433L590 177Q590 178 557 222T452 366T322 544L56 909L55 924Q55 945 60 948Z"/><path stroke-width="1" id="E600-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E600-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E600-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E600-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E600-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E600-MJMATHI-6A" x="663" y="-213"/><g transform="translate(1138,0)"><use xlink:href="#E600-MJMAIN-3A"/><use xlink:href="#E600-MJMAIN-3D" x="278" y="0"/></g><g transform="translate(2473,0)"><use xlink:href="#E600-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E600-MJMATHI-6A" x="663" y="-213"/></g><use xlink:href="#E600-MJMAIN-28" x="3334" y="0"/><use xlink:href="#E600-MJMAIN-31" x="3724" y="0"/><use xlink:href="#E600-MJMAIN-2212" x="4447" y="0"/><use xlink:href="#E600-MJMATHI-61" x="5447" y="0"/><g transform="translate(5977,0)"><g transform="translate(120,0)"><rect stroke="none" width="998" height="60" x="0" y="220"/><use xlink:href="#E600-MJMAIN-31" x="249" y="676"/><use xlink:href="#E600-MJMATHI-6D" x="60" y="-686"/></g></g><use xlink:href="#E600-MJMAIN-29" x="7215" y="0"/><use xlink:href="#E600-MJMAIN-2212" x="7827" y="0"/><use xlink:href="#E600-MJMATHI-61" x="8828" y="0"/><g transform="translate(9357,0)"><g transform="translate(120,0)"><rect stroke="none" width="998" height="60" x="0" y="220"/><use xlink:href="#E600-MJMAIN-31" x="249" y="676"/><use xlink:href="#E600-MJMATHI-6D" x="60" y="-686"/></g></g><g transform="translate(10762,0)"><use xlink:href="#E600-MJSZ2-2211" x="0" y="0"/><g transform="translate(147,-1090)"><use transform="scale(0.707)" xlink:href="#E600-MJMATHI-69" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E600-MJMAIN-3D" x="345" y="0"/><use transform="scale(0.707)" xlink:href="#E600-MJMAIN-31" x="1124" y="0"/></g><use transform="scale(0.707)" xlink:href="#E600-MJMATHI-6D" x="582" y="1627"/></g><use xlink:href="#E600-MJMAIN-28" x="12207" y="0"/><g transform="translate(12596,0)"><use xlink:href="#E600-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E600-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E600-MJMAIN-28" x="13605" y="0"/><g transform="translate(13994,0)"><use xlink:href="#E600-MJMATHI-78" x="0" y="0"/><g transform="translate(572,412)"><use transform="scale(0.707)" xlink:href="#E600-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E600-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E600-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E600-MJMAIN-29" x="15462" y="0"/><use xlink:href="#E600-MJMAIN-2212" x="16074" y="0"/><g transform="translate(17075,0)"><use xlink:href="#E600-MJMATHI-79" x="0" y="0"/><g transform="translate(499,412)"><use transform="scale(0.707)" xlink:href="#E600-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E600-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E600-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E600-MJMAIN-29" x="18469" y="0"/><g transform="translate(18859,0)"><use xlink:href="#E600-MJMATHI-78" x="0" y="0"/><g transform="translate(572,521)"><use transform="scale(0.707)" xlink:href="#E600-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E600-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E600-MJMAIN-29" x="734" y="0"/></g><use transform="scale(0.707)" xlink:href="#E600-MJMATHI-6A" x="809" y="-430"/></g></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-552">
\theta_j := \theta_j(1 -a\frac{1}{m}) - a\frac{1}{m}\sum_{i = 1}^{m}(h_\theta(x^{(i)}) - y^{(i)})x_j^{(i)}
</script></div><p>The first term in the above equation, 1−αλm will always be less than 1. Intuitively you can see it as reducing the value of θj by some amount on every update. Notice that the second term is now exactly the same as it was before.</p><p>Normal Equation</p><p>Now let&#39;s approach regularzation using the alternate method of the non-iterative normal equation.</p><div class="mathjax-block" contenteditable="false" cid="c479" mdtype="math_block" id="math-jaxc479"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-620-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="24.232ex" height="3.009ex" viewbox="0 -970.7 10433.1 1295.7" role="img" focusable="false" style="vertical-align: -0.755ex;"><defs><path stroke-width="1" id="E670-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E670-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E670-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E670-MJMATHI-58" d="M42 0H40Q26 0 26 11Q26 15 29 27Q33 41 36 43T55 46Q141 49 190 98Q200 108 306 224T411 342Q302 620 297 625Q288 636 234 637H206Q200 643 200 645T202 664Q206 677 212 683H226Q260 681 347 681Q380 681 408 681T453 682T473 682Q490 682 490 671Q490 670 488 658Q484 643 481 640T465 637Q434 634 411 620L488 426L541 485Q646 598 646 610Q646 628 622 635Q617 635 609 637Q594 637 594 648Q594 650 596 664Q600 677 606 683H618Q619 683 643 683T697 681T738 680Q828 680 837 683H845Q852 676 852 672Q850 647 840 637H824Q790 636 763 628T722 611T698 593L687 584Q687 585 592 480L505 384Q505 383 536 304T601 142T638 56Q648 47 699 46Q734 46 734 37Q734 35 732 23Q728 7 725 4T711 1Q708 1 678 1T589 2Q528 2 496 2T461 1Q444 1 444 10Q444 11 446 25Q448 35 450 39T455 44T464 46T480 47T506 54Q523 62 523 64Q522 64 476 181L429 299Q241 95 236 84Q232 76 232 72Q232 53 261 47Q262 47 267 47T273 46Q276 46 277 46T280 45T283 42T284 35Q284 26 282 19Q279 6 276 4T261 1Q258 1 243 1T201 2T142 2Q64 2 42 0Z"/><path stroke-width="1" id="E670-MJMATHI-54" d="M40 437Q21 437 21 445Q21 450 37 501T71 602L88 651Q93 669 101 677H569H659Q691 677 697 676T704 667Q704 661 687 553T668 444Q668 437 649 437Q640 437 637 437T631 442L629 445Q629 451 635 490T641 551Q641 586 628 604T573 629Q568 630 515 631Q469 631 457 630T439 622Q438 621 368 343T298 60Q298 48 386 46Q418 46 427 45T436 36Q436 31 433 22Q429 4 424 1L422 0Q419 0 415 0Q410 0 363 1T228 2Q99 2 64 0H49Q43 6 43 9T45 27Q49 40 55 46H83H94Q174 46 189 55Q190 56 191 56Q196 59 201 76T241 233Q258 301 269 344Q339 619 339 625Q339 630 310 630H279Q212 630 191 624Q146 614 121 583T67 467Q60 445 57 441T43 437H40Z"/><path stroke-width="1" id="E670-MJMAIN-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"/><path stroke-width="1" id="E670-MJMATHI-3BB" d="M166 673Q166 685 183 694H202Q292 691 316 644Q322 629 373 486T474 207T524 67Q531 47 537 34T546 15T551 6T555 2T556 -2T550 -11H482Q457 3 450 18T399 152L354 277L340 262Q327 246 293 207T236 141Q211 112 174 69Q123 9 111 -1T83 -12Q47 -12 47 20Q47 37 61 52T199 187Q229 216 266 252T321 306L338 322Q338 323 288 462T234 612Q214 657 183 657Q166 657 166 673Z"/><path stroke-width="1" id="E670-MJMAIN-2217" d="M229 286Q216 420 216 436Q216 454 240 464Q241 464 245 464T251 465Q263 464 273 456T283 436Q283 419 277 356T270 286L328 328Q384 369 389 372T399 375Q412 375 423 365T435 338Q435 325 425 315Q420 312 357 282T289 250L355 219L425 184Q434 175 434 161Q434 146 425 136T401 125Q393 125 383 131T328 171L270 213Q283 79 283 63Q283 53 276 44T250 35Q231 35 224 44T216 63Q216 80 222 143T229 213L171 171Q115 130 110 127Q106 124 100 124Q87 124 76 134T64 161Q64 166 64 169T67 175T72 181T81 188T94 195T113 204T138 215T170 230T210 250L74 315Q65 324 65 338Q65 353 74 363T98 374Q106 374 116 368T171 328L229 286Z"/><path stroke-width="1" id="E670-MJMATHI-4C" d="M228 637Q194 637 192 641Q191 643 191 649Q191 673 202 682Q204 683 217 683Q271 680 344 680Q485 680 506 683H518Q524 677 524 674T522 656Q517 641 513 637H475Q406 636 394 628Q387 624 380 600T313 336Q297 271 279 198T252 88L243 52Q243 48 252 48T311 46H328Q360 46 379 47T428 54T478 72T522 106T564 161Q580 191 594 228T611 270Q616 273 628 273H641Q647 264 647 262T627 203T583 83T557 9Q555 4 553 3T537 0T494 -1Q483 -1 418 -1T294 0H116Q32 0 32 10Q32 17 34 24Q39 43 44 45Q48 46 59 46H65Q92 46 125 49Q139 52 144 61Q147 65 216 339T285 628Q285 635 228 637Z"/><path stroke-width="1" id="E670-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E670-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E670-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E670-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E670-MJMATHI-3B8" x="0" y="0"/><use xlink:href="#E670-MJMAIN-3D" x="747" y="0"/><use xlink:href="#E670-MJMAIN-28" x="1803" y="0"/><g transform="translate(2193,0)"><use xlink:href="#E670-MJMATHI-58" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E670-MJMATHI-54" x="1215" y="583"/></g><use xlink:href="#E670-MJMAIN-2B" x="3873" y="0"/><use xlink:href="#E670-MJMATHI-3BB" x="4873" y="0"/><use xlink:href="#E670-MJMAIN-2217" x="5679" y="0"/><use xlink:href="#E670-MJMATHI-4C" x="6402" y="0"/><g transform="translate(7083,0)"><use xlink:href="#E670-MJMAIN-29" x="0" y="0"/><g transform="translate(389,412)"><use transform="scale(0.707)" xlink:href="#E670-MJMAIN-2212" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E670-MJMAIN-31" x="778" y="0"/></g></g><g transform="translate(8477,0)"><use xlink:href="#E670-MJMATHI-58" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E670-MJMATHI-54" x="1215" y="583"/></g><use xlink:href="#E670-MJMATHI-79" x="9935" y="0"/></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-620">
\theta = (X^T + \lambda *L)^{-1}X^Ty
</script></div><div class="mathjax-block" style="" contenteditable="false" cid="c482" mdtype="math_block" id="math-jaxc482"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-950-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="30.886ex" height="14.134ex" viewbox="0 -3285 13298.2 6085.6" role="img" focusable="false" style="vertical-align: -6.505ex;"><defs><path stroke-width="1" id="E1007-MJMATHI-57" d="M436 683Q450 683 486 682T553 680Q604 680 638 681T677 682Q695 682 695 674Q695 670 692 659Q687 641 683 639T661 637Q636 636 621 632T600 624T597 615Q597 603 613 377T629 138L631 141Q633 144 637 151T649 170T666 200T690 241T720 295T759 362Q863 546 877 572T892 604Q892 619 873 628T831 637Q817 637 817 647Q817 650 819 660Q823 676 825 679T839 682Q842 682 856 682T895 682T949 681Q1015 681 1034 683Q1048 683 1048 672Q1048 666 1045 655T1038 640T1028 637Q1006 637 988 631T958 617T939 600T927 584L923 578L754 282Q586 -14 585 -15Q579 -22 561 -22Q546 -22 542 -17Q539 -14 523 229T506 480L494 462Q472 425 366 239Q222 -13 220 -15T215 -19Q210 -22 197 -22Q178 -22 176 -15Q176 -12 154 304T131 622Q129 631 121 633T82 637H58Q51 644 51 648Q52 671 64 683H76Q118 680 176 680Q301 680 313 683H323Q329 677 329 674T327 656Q322 641 318 637H297Q236 634 232 620Q262 160 266 136L501 550L499 587Q496 629 489 632Q483 636 447 637Q428 637 422 639T416 648Q416 650 418 660Q419 664 420 669T421 676T424 680T428 682T436 683Z"/><path stroke-width="1" id="E1007-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E1007-MJMATHI-65" d="M39 168Q39 225 58 272T107 350T174 402T244 433T307 442H310Q355 442 388 420T421 355Q421 265 310 237Q261 224 176 223Q139 223 138 221Q138 219 132 186T125 128Q125 81 146 54T209 26T302 45T394 111Q403 121 406 121Q410 121 419 112T429 98T420 82T390 55T344 24T281 -1T205 -11Q126 -11 83 42T39 168ZM373 353Q367 405 305 405Q272 405 244 391T199 357T170 316T154 280T149 261Q149 260 169 260Q282 260 327 284T373 353Z"/><path stroke-width="1" id="E1007-MJMATHI-72" d="M21 287Q22 290 23 295T28 317T38 348T53 381T73 411T99 433T132 442Q161 442 183 430T214 408T225 388Q227 382 228 382T236 389Q284 441 347 441H350Q398 441 422 400Q430 381 430 363Q430 333 417 315T391 292T366 288Q346 288 334 299T322 328Q322 376 378 392Q356 405 342 405Q286 405 239 331Q229 315 224 298T190 165Q156 25 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 114 189T154 366Q154 405 128 405Q107 405 92 377T68 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1007-MJMAIN-3A" d="M78 370Q78 394 95 412T138 430Q162 430 180 414T199 371Q199 346 182 328T139 310T96 327T78 370ZM78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z"/><path stroke-width="1" id="E1007-MJMATHI-4C" d="M228 637Q194 637 192 641Q191 643 191 649Q191 673 202 682Q204 683 217 683Q271 680 344 680Q485 680 506 683H518Q524 677 524 674T522 656Q517 641 513 637H475Q406 636 394 628Q387 624 380 600T313 336Q297 271 279 198T252 88L243 52Q243 48 252 48T311 46H328Q360 46 379 47T428 54T478 72T522 106T564 161Q580 191 594 228T611 270Q616 273 628 273H641Q647 264 647 262T627 203T583 83T557 9Q555 4 553 3T537 0T494 -1Q483 -1 418 -1T294 0H116Q32 0 32 10Q32 17 34 24Q39 43 44 45Q48 46 59 46H65Q92 46 125 49Q139 52 144 61Q147 65 216 339T285 628Q285 635 228 637Z"/><path stroke-width="1" id="E1007-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E1007-MJMAIN-5B" d="M118 -250V750H255V710H158V-210H255V-250H118Z"/><path stroke-width="1" id="E1007-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/><path stroke-width="1" id="E1007-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E1007-MJMAIN-22F1" d="M133 760Q133 784 150 802T193 820Q217 820 235 804T254 761Q254 736 237 718T194 700T151 717T133 760ZM580 460Q580 484 597 502T640 520Q664 520 682 504T701 461Q701 436 684 418T641 400T598 417T580 460ZM1027 160Q1027 184 1044 202T1087 220Q1111 220 1129 204T1148 161Q1148 136 1131 118T1088 100T1045 117T1027 160Z"/><path stroke-width="1" id="E1007-MJMAIN-5D" d="M22 710V750H159V-250H22V-210H119V710H22Z"/><path stroke-width="1" id="E1007-MJSZ4-23A1" d="M319 -645V1154H666V1070H403V-645H319Z"/><path stroke-width="1" id="E1007-MJSZ4-23A3" d="M319 -644V1155H403V-560H666V-644H319Z"/><path stroke-width="1" id="E1007-MJSZ4-23A2" d="M319 0V602H403V0H319Z"/><path stroke-width="1" id="E1007-MJSZ4-23A4" d="M0 1070V1154H347V-645H263V1070H0Z"/><path stroke-width="1" id="E1007-MJSZ4-23A6" d="M263 -560V1155H347V-644H0V-560H263Z"/><path stroke-width="1" id="E1007-MJSZ4-23A5" d="M263 0V602H347V0H263Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E1007-MJMATHI-57" x="0" y="0"/><use xlink:href="#E1007-MJMATHI-68" x="1048" y="0"/><use xlink:href="#E1007-MJMATHI-65" x="1625" y="0"/><use xlink:href="#E1007-MJMATHI-72" x="2091" y="0"/><use xlink:href="#E1007-MJMATHI-65" x="2543" y="0"/><use xlink:href="#E1007-MJMAIN-3A" x="3287" y="0"/><use xlink:href="#E1007-MJMATHI-4C" x="3843" y="0"/><use xlink:href="#E1007-MJMAIN-3D" x="4802" y="0"/><g transform="translate(5859,0)"><g transform="translate(0,3210)"><use xlink:href="#E1007-MJSZ4-23A1" x="0" y="-1155"/><g transform="translate(0,-4165.995033112583) scale(1,4.004966887417218)"><use xlink:href="#E1007-MJSZ4-23A2"/></g><use xlink:href="#E1007-MJSZ4-23A3" x="0" y="-5276"/></g><g transform="translate(834,0)"><g transform="translate(-14,0)"><use xlink:href="#E1007-MJMAIN-30" x="0" y="2410"/></g><g transform="translate(1486,0)"><use xlink:href="#E1007-MJMAIN-31" x="0" y="1010"/></g><g transform="translate(2987,0)"><use xlink:href="#E1007-MJMAIN-22F1" x="0" y="-1111"/></g><g transform="translate(5269,0)"><use xlink:href="#E1007-MJMAIN-31" x="0" y="-2511"/></g></g><g transform="translate(6771,3210)"><use xlink:href="#E1007-MJSZ4-23A4" x="0" y="-1155"/><g transform="translate(0,-4165.995033112583) scale(1,4.004966887417218)"><use xlink:href="#E1007-MJSZ4-23A5"/></g><use xlink:href="#E1007-MJSZ4-23A6" x="0" y="-5276"/></g></g></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-950">
Where: L = \begin{bmatrix}0   & &&         \\
                                   & 1  & &           \\
                                    & & \ddots&  \\
                                    & & & 1
                                    
        \end{bmatrix}
</script></div><p>L is a matrix with 0 at the top left and 1&#39;s down the diagonal, with 0&#39;s everywhere else. It should have dimension (n+1)×(n+1). Intuitively, this is the identity matrix (though we are not including x0), multiplied with a single real number λ.</p><p>Recall that if m &lt; n, then XTX is non-invertible. However, when we add the term λ⋅L, then XTX + λ⋅L becomes invertible.</p><p></p><h5 id="64-regularized-logistic-regression"><a name="header-c521" class="md-header-anchor "></a>6.4 Regularized Logistic Regression</h5><p>Cost Function:</p><div class="mathjax-block" contenteditable="false" cid="c546" mdtype="math_block" id="math-jaxc546"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-1210-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="74.091ex" height="7.134ex" viewbox="0 -1670.4 31900.1 3071.7" role="img" focusable="false" style="vertical-align: -3.255ex;"><defs><path stroke-width="1" id="E1305-MJMATHI-4A" d="M447 625Q447 637 354 637H329Q323 642 323 645T325 664Q329 677 335 683H352Q393 681 498 681Q541 681 568 681T605 682T619 682Q633 682 633 672Q633 670 630 658Q626 642 623 640T604 637Q552 637 545 623Q541 610 483 376Q420 128 419 127Q397 64 333 21T195 -22Q137 -22 97 8T57 88Q57 130 80 152T132 174Q177 174 182 130Q182 98 164 80T123 56Q115 54 115 53T122 44Q148 15 197 15Q235 15 271 47T324 130Q328 142 387 380T447 625Z"/><path stroke-width="1" id="E1305-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/><path stroke-width="1" id="E1305-MJMATHI-3B8" d="M35 200Q35 302 74 415T180 610T319 704Q320 704 327 704T339 705Q393 701 423 656Q462 596 462 495Q462 380 417 261T302 66T168 -10H161Q125 -10 99 10T60 63T41 130T35 200ZM383 566Q383 668 330 668Q294 668 260 623T204 521T170 421T157 371Q206 370 254 370L351 371Q352 372 359 404T375 484T383 566ZM113 132Q113 26 166 26Q181 26 198 36T239 74T287 161T335 307L340 324H145Q145 321 136 286T120 208T113 132Z"/><path stroke-width="1" id="E1305-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/><path stroke-width="1" id="E1305-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E1305-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"/><path stroke-width="1" id="E1305-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E1305-MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1305-MJSZ2-2211" d="M60 948Q63 950 665 950H1267L1325 815Q1384 677 1388 669H1348L1341 683Q1320 724 1285 761Q1235 809 1174 838T1033 881T882 898T699 902H574H543H251L259 891Q722 258 724 252Q725 250 724 246Q721 243 460 -56L196 -356Q196 -357 407 -357Q459 -357 548 -357T676 -358Q812 -358 896 -353T1063 -332T1204 -283T1307 -196Q1328 -170 1348 -124H1388Q1388 -125 1381 -145T1356 -210T1325 -294L1267 -449L666 -450Q64 -450 61 -448Q55 -446 55 -439Q55 -437 57 -433L590 177Q590 178 557 222T452 366T322 544L56 909L55 924Q55 945 60 948Z"/><path stroke-width="1" id="E1305-MJMATHI-69" d="M184 600Q184 624 203 642T247 661Q265 661 277 649T290 619Q290 596 270 577T226 557Q211 557 198 567T184 600ZM21 287Q21 295 30 318T54 369T98 420T158 442Q197 442 223 419T250 357Q250 340 236 301T196 196T154 83Q149 61 149 51Q149 26 166 26Q175 26 185 29T208 43T235 78T260 137Q263 149 265 151T282 153Q302 153 302 143Q302 135 293 112T268 61T223 11T161 -11Q129 -11 102 10T74 74Q74 91 79 106T122 220Q160 321 166 341T173 380Q173 404 156 404H154Q124 404 99 371T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1305-MJMAIN-5B" d="M118 -250V750H255V710H158V-210H255V-250H118Z"/><path stroke-width="1" id="E1305-MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E1305-MJMATHI-6C" d="M117 59Q117 26 142 26Q179 26 205 131Q211 151 215 152Q217 153 225 153H229Q238 153 241 153T246 151T248 144Q247 138 245 128T234 90T214 43T183 6T137 -11Q101 -11 70 11T38 85Q38 97 39 102L104 360Q167 615 167 623Q167 626 166 628T162 632T157 634T149 635T141 636T132 637T122 637Q112 637 109 637T101 638T95 641T94 647Q94 649 96 661Q101 680 107 682T179 688Q194 689 213 690T243 693T254 694Q266 694 266 686Q266 675 193 386T118 83Q118 81 118 75T117 65V59Z"/><path stroke-width="1" id="E1305-MJMATHI-6F" d="M201 -11Q126 -11 80 38T34 156Q34 221 64 279T146 380Q222 441 301 441Q333 441 341 440Q354 437 367 433T402 417T438 387T464 338T476 268Q476 161 390 75T201 -11ZM121 120Q121 70 147 48T206 26Q250 26 289 58T351 142Q360 163 374 216T388 308Q388 352 370 375Q346 405 306 405Q243 405 195 347Q158 303 140 230T121 120Z"/><path stroke-width="1" id="E1305-MJMATHI-67" d="M311 43Q296 30 267 15T206 0Q143 0 105 45T66 160Q66 265 143 353T314 442Q361 442 401 394L404 398Q406 401 409 404T418 412T431 419T447 422Q461 422 470 413T480 394Q480 379 423 152T363 -80Q345 -134 286 -169T151 -205Q10 -205 10 -137Q10 -111 28 -91T74 -71Q89 -71 102 -80T116 -111Q116 -121 114 -130T107 -144T99 -154T92 -162L90 -164H91Q101 -167 151 -167Q189 -167 211 -155Q234 -144 254 -122T282 -75Q288 -56 298 -13Q311 35 311 43ZM384 328L380 339Q377 350 375 354T369 368T359 382T346 393T328 402T306 405Q262 405 221 352Q191 313 171 233T151 117Q151 38 213 38Q269 38 323 108L331 118L384 328Z"/><path stroke-width="1" id="E1305-MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z"/><path stroke-width="1" id="E1305-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"/><path stroke-width="1" id="E1305-MJMAIN-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"/><path stroke-width="1" id="E1305-MJMAIN-5D" d="M22 710V750H159V-250H22V-210H119V710H22Z"/><path stroke-width="1" id="E1305-MJMATHI-3BB" d="M166 673Q166 685 183 694H202Q292 691 316 644Q322 629 373 486T474 207T524 67Q531 47 537 34T546 15T551 6T555 2T556 -2T550 -11H482Q457 3 450 18T399 152L354 277L340 262Q327 246 293 207T236 141Q211 112 174 69Q123 9 111 -1T83 -12Q47 -12 47 20Q47 37 61 52T199 187Q229 216 266 252T321 306L338 322Q338 323 288 462T234 612Q214 657 183 657Q166 657 166 673Z"/><path stroke-width="1" id="E1305-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"/><path stroke-width="1" id="E1305-MJMATHI-6A" d="M297 596Q297 627 318 644T361 661Q378 661 389 651T403 623Q403 595 384 576T340 557Q322 557 310 567T297 596ZM288 376Q288 405 262 405Q240 405 220 393T185 362T161 325T144 293L137 279Q135 278 121 278H107Q101 284 101 286T105 299Q126 348 164 391T252 441Q253 441 260 441T272 442Q296 441 316 432Q341 418 354 401T367 348V332L318 133Q267 -67 264 -75Q246 -125 194 -164T75 -204Q25 -204 7 -183T-12 -137Q-12 -110 7 -91T53 -71Q70 -71 82 -81T95 -112Q95 -148 63 -167Q69 -168 77 -168Q111 -168 139 -140T182 -74L193 -32Q204 11 219 72T251 197T278 308T289 365Q289 372 288 376Z"/><path stroke-width="1" id="E1305-MJMATHI-6E" d="M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E1305-MJMATHI-4A" x="0" y="0"/><use xlink:href="#E1305-MJMAIN-28" x="633" y="0"/><use xlink:href="#E1305-MJMATHI-3B8" x="1023" y="0"/><use xlink:href="#E1305-MJMAIN-29" x="1492" y="0"/><use xlink:href="#E1305-MJMAIN-3D" x="2159" y="0"/><use xlink:href="#E1305-MJMAIN-2212" x="3216" y="0"/><g transform="translate(3994,0)"><g transform="translate(120,0)"><rect stroke="none" width="998" height="60" x="0" y="220"/><use xlink:href="#E1305-MJMAIN-31" x="249" y="676"/><use xlink:href="#E1305-MJMATHI-6D" x="60" y="-686"/></g></g><g transform="translate(5399,0)"><use xlink:href="#E1305-MJSZ2-2211" x="0" y="0"/><g transform="translate(147,-1090)"><use transform="scale(0.707)" xlink:href="#E1305-MJMATHI-69" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-3D" x="345" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-31" x="1124" y="0"/></g><use transform="scale(0.707)" xlink:href="#E1305-MJMATHI-6D" x="582" y="1627"/></g><use xlink:href="#E1305-MJMAIN-5B" x="6844" y="0"/><g transform="translate(7122,0)"><use xlink:href="#E1305-MJMATHI-79" x="0" y="0"/><g transform="translate(499,412)"><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E1305-MJMATHI-6C" x="8517" y="0"/><use xlink:href="#E1305-MJMATHI-6F" x="8816" y="0"/><use xlink:href="#E1305-MJMATHI-67" x="9301" y="0"/><use xlink:href="#E1305-MJMAIN-28" x="9782" y="0"/><g transform="translate(10171,0)"><use xlink:href="#E1305-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E1305-MJMAIN-28" x="11180" y="0"/><g transform="translate(11569,0)"><use xlink:href="#E1305-MJMATHI-78" x="0" y="0"/><g transform="translate(572,412)"><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E1305-MJMAIN-29" x="13037" y="0"/><use xlink:href="#E1305-MJMAIN-29" x="13426" y="0"/><use xlink:href="#E1305-MJMAIN-2B" x="14038" y="0"/><use xlink:href="#E1305-MJMAIN-28" x="15039" y="0"/><use xlink:href="#E1305-MJMAIN-31" x="15428" y="0"/><use xlink:href="#E1305-MJMAIN-2212" x="16151" y="0"/><g transform="translate(17152,0)"><use xlink:href="#E1305-MJMATHI-79" x="0" y="0"/><g transform="translate(499,412)"><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E1305-MJMAIN-29" x="18546" y="0"/><use xlink:href="#E1305-MJMATHI-6C" x="18936" y="0"/><use xlink:href="#E1305-MJMATHI-6F" x="19234" y="0"/><use xlink:href="#E1305-MJMATHI-67" x="19720" y="0"/><use xlink:href="#E1305-MJMAIN-28" x="20200" y="0"/><use xlink:href="#E1305-MJMAIN-31" x="20590" y="0"/><use xlink:href="#E1305-MJMAIN-2212" x="21313" y="0"/><g transform="translate(22313,0)"><use xlink:href="#E1305-MJMATHI-68" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMATHI-3B8" x="815" y="-219"/></g><use xlink:href="#E1305-MJMAIN-28" x="23322" y="0"/><g transform="translate(23711,0)"><use xlink:href="#E1305-MJMATHI-78" x="0" y="0"/><g transform="translate(572,412)"><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-28" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMATHI-69" x="389" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-29" x="734" y="0"/></g></g><use xlink:href="#E1305-MJMAIN-29" x="25179" y="0"/><use xlink:href="#E1305-MJMAIN-29" x="25568" y="0"/><use xlink:href="#E1305-MJMAIN-5D" x="25958" y="0"/><use xlink:href="#E1305-MJMAIN-2B" x="26459" y="0"/><g transform="translate(27237,0)"><g transform="translate(342,0)"><rect stroke="none" width="1499" height="60" x="0" y="220"/><use xlink:href="#E1305-MJMATHI-3BB" x="457" y="676"/><g transform="translate(60,-686)"><use xlink:href="#E1305-MJMAIN-32" x="0" y="0"/><use xlink:href="#E1305-MJMATHI-6D" x="500" y="0"/></g></g></g><g transform="translate(29365,0)"><use xlink:href="#E1305-MJSZ2-2211" x="0" y="0"/><g transform="translate(124,-1090)"><use transform="scale(0.707)" xlink:href="#E1305-MJMATHI-6A" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-3D" x="412" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-31" x="1191" y="0"/></g><use transform="scale(0.707)" xlink:href="#E1305-MJMATHI-6E" x="721" y="1627"/></g><g transform="translate(30976,0)"><use xlink:href="#E1305-MJMATHI-3B8" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E1305-MJMAIN-32" x="663" y="488"/><use transform="scale(0.707)" xlink:href="#E1305-MJMATHI-6A" x="663" y="-430"/></g></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-1210">
J(\theta) = -\frac{1}{m}\sum_{i = 1}^{m}[y^{(i)}log(h_\theta(x^{(i)}))+(1 - y^{(i)})log(1 - h_\theta(x^{(i)})) ]+ \frac{\lambda}{2m}\sum_{j = 1}^{n}\theta_j^2
</script></div><p><img src="https://ws1.sinaimg.cn/large/006tNbRwgy1fg3r68zj8pj30de06hjrx.jpg" alt="dfHLC70SEea4MxKdJPaTxA_306de28804a7467f7d84da0fe3ee9c7b_Screen-Shot-2016-12-07-at-10.49.02-PM"></p><h4 id="7netral-networkings"><a name="header-c539" class="md-header-anchor "></a>7.Netral Networkings </h4><p> </p></div>
</body>
</html>]]></content>
    
    <summary type="html">
    
      &lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width initial-scale=1&quot;&gt;
&lt;title&gt;机器学习入门&lt;/title
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title></title>
    <link href="https://blaceman.github.io/2017/05/22/Markdown%20Reference%20copy/"/>
    <id>https://blaceman.github.io/2017/05/22/Markdown Reference copy/</id>
    <published>2017-05-22T08:57:12.000Z</published>
    <updated>2017-05-22T08:57:12.000Z</updated>
    
    <content type="html"><![CDATA[<!doctype html>
<html>
<head>
<meta charset="UTF-8"><meta name="viewport" content="width=device-width initial-scale=1">
<title>Markdown Reference copy.md</title><link href="https://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700,700italic&subset=latin,cyrillic-ext,cyrillic,latin-ext" rel="stylesheet" type="text/css"><style type="text/css">html, body {overflow-x: initial !important;}.CodeMirror { height: auto; }
.CodeMirror-scroll { overflow-y: hidden; overflow-x: auto; }
.CodeMirror-lines { padding: 4px 0px; }
.CodeMirror pre { }
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { background-color: white; }
.CodeMirror-gutters { border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); background-color: rgb(247, 247, 247); white-space: nowrap; }
.CodeMirror-linenumbers { }
.CodeMirror-linenumber { padding: 0px 3px 0px 5px; text-align: right; color: rgb(153, 153, 153); }
.CodeMirror div.CodeMirror-cursor { border-left-width: 1px; border-left-style: solid; border-left-color: black; z-index: 3; }
.CodeMirror div.CodeMirror-secondarycursor { border-left-width: 1px; border-left-style: solid; border-left-color: silver; }
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor { width: auto; border: 0px; background-color: rgb(119, 238, 119); z-index: 1; background-position: initial initial; background-repeat: initial initial; }
.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite { }
.cm-tab { display: inline-block; }
.cm-s-typora-default .cm-header, .cm-s-typora-default .cm-property { color: rgb(217, 79, 138); }
.cm-s-typora-default pre.cm-header1:not(.cm-atom) :not(.cm-overlay) { font-size: 2rem; line-height: 2rem; }
.cm-s-typora-default pre.cm-header2:not(.cm-atom) :not(.cm-overlay) { font-size: 1.4rem; line-height: 1.4rem; }
.cm-s-typora-default .cm-atom, .cm-s-typora-default .cm-number { color: rgb(149, 132, 134); }
.cm-s-typora-default .cm-table-row, .cm-s-typora-default .cm-block-start { font-family: monospace; }
.cm-s-typora-default .cm-comment, .cm-s-typora-default .cm-code { color: rgb(74, 90, 159); font-family: monospace; }
.cm-s-typora-default .cm-tag { color: rgb(169, 68, 66); }
.cm-s-typora-default .cm-string { color: rgb(126, 134, 169); }
.cm-s-typora-default .cm-link { color: rgb(196, 122, 15); text-decoration: underline; }
.cm-s-typora-default .cm-variable-2, .cm-s-typora-default .cm-variable-1 { color: inherit; }
.cm-s-typora-default .cm-overlay { font-size: 1rem; font-family: monospace; }
.CodeMirror.cm-s-typora-default div.CodeMirror-cursor { border-left-width: 3px; border-left-style: solid; border-left-color: rgb(228, 98, 154); }
.cm-s-typora-default .CodeMirror-activeline-background { left: -60px; right: -30px; background-color: rgba(204, 204, 204, 0.2); background-position: initial initial; background-repeat: initial initial; }
.cm-s-typora-default .CodeMirror-gutters { border-right-style: none; background-color: inherit; }
.cm-s-typora-default .cm-trailing-space-new-line::after, .cm-startspace::after, .cm-starttab .cm-tab::after { content: '•'; position: absolute; left: 0px; opacity: 0; font-family: LetterGothicStd, monospace; }
.os-windows .cm-startspace::after, .os-windows .cm-starttab .cm-tab::after { left: -0.1em; }
.cm-starttab .cm-tab::after { content: ' '; }
.cm-startspace, .cm-tab, .cm-starttab, .cm-trailing-space-a, .cm-trailing-space-b, .cm-trailing-space-new-line { font-family: monospace; position: relative; }
.cm-s-typora-default .cm-trailing-space-new-line::after { content: '↓'; opacity: 0.3; }
.cm-s-inner .cm-keyword { color: rgb(119, 0, 136); }
.cm-s-inner .cm-atom, .cm-s-inner.cm-atom { color: rgb(34, 17, 153); }
.cm-s-inner .cm-number { color: rgb(17, 102, 68); }
.cm-s-inner .cm-def { color: rgb(0, 0, 255); }
.cm-s-inner .cm-variable { color: black; }
.cm-s-inner .cm-variable-2 { color: rgb(0, 85, 170); }
.cm-s-inner .cm-variable-3 { color: rgb(0, 136, 85); }
.cm-s-inner .cm-property { color: black; }
.cm-s-inner .cm-operator { color: rgb(152, 26, 26); }
.cm-s-inner .cm-comment, .cm-s-inner.cm-comment { color: rgb(170, 85, 0); }
.cm-s-inner .cm-string { color: rgb(170, 17, 17); }
.cm-s-inner .cm-string-2 { color: rgb(255, 85, 0); }
.cm-s-inner .cm-meta { color: rgb(85, 85, 85); }
.cm-s-inner .cm-qualifier { color: rgb(85, 85, 85); }
.cm-s-inner .cm-builtin { color: rgb(51, 0, 170); }
.cm-s-inner .cm-bracket { color: rgb(153, 153, 119); }
.cm-s-inner .cm-tag { color: rgb(17, 119, 0); }
.cm-s-inner .cm-attribute { color: rgb(0, 0, 204); }
.cm-s-inner .cm-header, .cm-s-inner.cm-header { color: blue; }
.cm-s-inner .cm-quote, .cm-s-inner.cm-quote { color: rgb(0, 153, 0); }
.cm-s-inner .cm-hr, .cm-s-inner.cm-hr { color: rgb(153, 153, 153); }
.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(0, 0, 204); }
.cm-negative { color: rgb(221, 68, 68); }
.cm-positive { color: rgb(34, 153, 34); }
.cm-header, .cm-strong { font-weight: bold; }
.cm-del { text-decoration: line-through; }
.cm-em { font-style: italic; }
.cm-link { text-decoration: underline; }
.cm-error { color: rgb(255, 0, 0); }
.cm-invalidchar { color: rgb(255, 0, 0); }
.cm-constant { color: rgb(38, 139, 210); }
.cm-defined { color: rgb(181, 137, 0); }
div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); }
.cm-s-inner .CodeMirror-activeline-background { background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit inherit; background-repeat: inherit inherit; }
.CodeMirror { position: relative; overflow: hidden; }
.CodeMirror-scroll { margin-bottom: -30px; margin-right: -30px; padding-bottom: 30px; padding-right: 30px; height: 100%; outline: none; position: relative; box-sizing: content-box; }
.CodeMirror-sizer { position: relative; }
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { position: absolute; z-index: 6; display: none; }
.CodeMirror-vscrollbar { right: 0px; top: 0px; overflow-x: hidden; overflow-y: scroll; }
.CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow-y: hidden; overflow-x: scroll; }
.CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; }
.CodeMirror-gutter-filler { left: 0px; bottom: 0px; }
.CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 30px; z-index: 3; }
.CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; }
.CodeMirror-lines { cursor: text; }
.CodeMirror pre { border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-width: 0px; background-color: transparent; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; word-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; background-position: initial initial; background-repeat: initial initial; }
.CodeMirror-wrap pre { word-wrap: break-word; white-space: pre-wrap; word-break: normal; }
.CodeMirror-code pre { border-right-width: 30px; border-right-style: solid; border-right-color: transparent; width: -webkit-fit-content; }
.CodeMirror-wrap .CodeMirror-code pre { border-right-style: none; width: auto; }
.CodeMirror-linebackground { position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 0; }
.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; }
.CodeMirror-widget { }
.CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; }
.CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; }
.CodeMirror-measure pre { position: static; }
.CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right-style: none; width: 0px; }
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
.CodeMirror-focused div.CodeMirror-cursor { visibility: inherit; }
.CodeMirror-selected { background-color: rgb(217, 217, 217); background-position: initial initial; background-repeat: initial initial; }
.CodeMirror-focused .CodeMirror-selected { background-color: rgb(215, 212, 240); background-position: initial initial; background-repeat: initial initial; }
.cm-searching { background-color: rgba(255, 255, 0, 0.4); background-position: initial initial; background-repeat: initial initial; }
.CodeMirror span { }
@media print { 
  .CodeMirror div.CodeMirror-cursor { visibility: hidden; }
}
.CodeMirror-lint-markers { width: 16px; }
.CodeMirror-lint-tooltip { background-color: infobackground; border: 1px solid black; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; color: infotext; font-family: monospace; overflow: hidden; padding: 2px 5px; position: fixed; white-space: pre-wrap; z-index: 10000; max-width: 600px; opacity: 0; -webkit-transition: opacity 0.4s; transition: opacity 0.4s; font-size: 0.8em; }
.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning { background-position: 0% 100%; background-repeat: repeat no-repeat; }
.CodeMirror-lint-mark-error { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==); }
.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning { cursor: pointer; display: inline-block; height: 16px; width: 16px; vertical-align: middle; position: relative; background-position: 50% 50%; background-repeat: no-repeat no-repeat; }
.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning { padding-left: 18px; background-position: 0% 0%; background-repeat: no-repeat no-repeat; }
.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=); }
.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=); }
.CodeMirror-lint-marker-multiple { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC); width: 100%; height: 100%; background-position: 100% 100%; background-repeat: no-repeat no-repeat; }


html { font-size: 14px; background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); }
body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1rem; line-height: 1.42857143; overflow-x: hidden; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit inherit; background-repeat: inherit inherit; }
a:active, a:hover { outline: 0px; }
.in-text-selection, ::selection { background-color: rgb(181, 214, 252); text-shadow: none; background-position: initial initial; background-repeat: initial initial; }
#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; word-wrap: break-word; position: relative; padding-bottom: 70px; white-space: pre-wrap; overflow-x: auto; }
.for-image #write { padding-left: 8px; padding-right: 8px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
@media screen and (max-width: 500px) { 
  body.typora-export { padding-left: 0px; padding-right: 0px; }
  .CodeMirror-sizer { margin-left: 0px !important; }
  .CodeMirror-gutters { display: none !important; }
}
.typora-export #write { margin: 0px auto; }
#write > p:first-child, #write > ul:first-child, #write > ol:first-child, #write > pre:first-child, #write > blockquote:first-child, #write > div:first-child, #write > table:first-child { margin-top: 30px; }
#write li > table:first-child { margin-top: -20px; }
img { max-width: 100%; vertical-align: middle; }
input, button, select, textarea { color: inherit; font-family: inherit; font-size: inherit; font-style: inherit; font-variant-caps: inherit; font-weight: inherit; line-height: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
::before, ::after, * { box-sizing: border-box; }
#write p, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write div, #write pre { width: inherit; }
#write p, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6 { position: relative; }
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
p { -webkit-margin-before: 1rem; -webkit-margin-after: 1rem; -webkit-margin-start: 0px; -webkit-margin-end: 0px; }
.mathjax-block { margin-top: 0px; margin-bottom: 0px; -webkit-margin-before: 0rem; -webkit-margin-after: 0rem; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: bold; font-style: italic; }
a { cursor: pointer; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; margin: 4px 0px 0px; }
tr { page-break-inside: avoid; page-break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; page-break-inside: auto; text-align: left; }
table.md-table td { min-width: 80px; }
.CodeMirror-gutters { border-right-width: 0px; background-color: inherit; }
.CodeMirror { text-align: left; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
pre { white-space: pre-wrap; }
.CodeMirror-gutters { margin-right: 4px; }
.md-fences { font-size: 0.9rem; display: block; page-break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; background-position: inherit inherit; background-repeat: inherit inherit; }
.md-diagram-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }
.md-fences .CodeMirror.CodeMirror-wrap { top: -1.6em; margin-bottom: -1.6em; }
.md-fences.mock-cm { white-space: pre-wrap; }
.show-fences-line-number .md-fences { padding-left: 0px; }
.show-fences-line-number .md-fences.mock-cm { padding-left: 40px; }
.footnotes { opacity: 0.8; font-size: 0.9rem; padding-top: 1em; padding-bottom: 1em; }
.footnotes + .footnotes { margin-top: -1em; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; background-color: transparent; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; line-height: normal; font-weight: normal; text-align: left; box-sizing: content-box; direction: ltr; background-position: initial initial; background-repeat: initial initial; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li p, li .mathjax-block { margin: 0.5rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; }
@media print { 
  html, body { height: 100%; }
  .typora-export * { -webkit-print-color-adjust: exact; }
  h1, h2, h3, h4, h5, h6 { page-break-after: avoid; orphans: 2; }
  p { orphans: 4; }
  html.blink-to-pdf { font-size: 13px; }
  .typora-export #write { padding-left: 1cm; padding-right: 1cm; }
  .typora-export #write::after { height: 0px; }
  @page { margin: 20mm 0mm; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
pre.md-meta-block { font-size: 0.8rem; min-height: 2.86rem; white-space: pre-wrap; background-color: rgb(204, 204, 204); display: block; overflow-x: hidden; background-position: initial initial; background-repeat: initial initial; }
p .md-image:only-child { display: inline-block; width: 100%; text-align: center; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.mathjax-block { white-space: pre; overflow: hidden; width: 100%; }
p + .mathjax-block { margin-top: -1.143rem; }
.mathjax-block:not(:empty)::after { display: none; }
[contenteditable="true"]:active, [contenteditable="true"]:focus { outline: none; box-shadow: none; }
.task-list { list-style-type: none; }
.task-list-item { position: relative; padding-left: 1em; }
.task-list-item input { position: absolute; top: 0px; left: 0px; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc::after, .md-toc-content::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); text-decoration: none; }
.md-toc-inner:hover { }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: bold; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
@media screen and (max-width: 48em) { 
  .md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
  .md-toc-h4 .md-toc-inner { margin-left: 5em; }
  .md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
  .md-toc-h6 .md-toc-inner { margin-left: 8em; }
}
a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.md-attr { display: none; }
.md-fn-count::after { content: '.'; }
.md-tag { opacity: 0.5; }
.md-comment { color: rgb(162, 127, 3); opacity: 0.8; font-family: monospace; }
code { text-align: left; }
h1 .md-tag, h2 .md-tag, h3 .md-tag, h4 .md-tag, h5 .md-tag, h6 .md-tag { font-weight: initial; opacity: 0.35; }
a.md-print-anchor { border: none !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: none !important; background-color: transparent !important; text-shadow: initial !important; background-position: initial initial !important; background-repeat: initial initial !important; }
.md-inline-math .MathJax_SVG .noError { display: none !important; }
.mathjax-block .MathJax_SVG_Display { text-align: center; margin: 1em 0em; position: relative; text-indent: 0px; max-width: none; max-height: none; min-height: 0px; min-width: 100%; width: auto; display: block !important; }
.MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display { width: auto; margin: inherit; display: inline-block !important; }
.MathJax_SVG .MJX-monospace { font-family: monospace; }
.MathJax_SVG .MJX-sans-serif { font-family: sans-serif; }
.MathJax_SVG { display: inline; font-style: normal; font-weight: normal; line-height: normal; zoom: 90%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; }
.MathJax_SVG * { -webkit-transition: none; transition: none; }


/* meyer reset -- http://meyerweb.com/eric/tools/css/reset/ , v2.0 | 20110126 | License: none (public domain) */

@include-when-export url(https://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700,700italic&subset=latin,cyrillic-ext,cyrillic,latin-ext);

/* =========== */

@font-face {
    font-family: 'PT Serif';
    font-style: normal;
    font-weight: normal;
    src: local('PT Serif'), local('PTSerif-Regular'), url(file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Regular.ttf);
}
@font-face {
    font-family: 'PT Serif';
    font-style: italic;
    font-weight: normal;
    src: local('PT Serif'), local('PTSerif-Italic'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Italic.ttf')
}

@font-face {
    font-family: 'PT Serif';
    font-style: normal;
    font-weight: bold;
    src: local('PT Serif'), local('PTSerif-Bold'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-Bold.ttf')
}

@font-face {
    font-family: 'PT Serif';
    font-style: italic;
    font-weight: bold;
    src: local('PT Serif'), local('PTSerif-BoldItalic'), url('file:///Users/new4545/Library/Application%20Support/abnerworks.Typora/themes/newsprint/PT_Serif-Web-BoldItalic.ttf')
}

html {
	font-size: 16px;
}

html, body {
	background-color: #f3f2ee;
	font-family: "PT Serif", 'Times New Roman', Times;
	color: #1f0909;
	line-height: 1.5em;
}

/*#write {
	overflow-x: auto;
    max-width: initial;
	padding-left: calc(50% - 17em);
    padding-right: calc(50% - 17em);
}

@media (max-width: 36em) {
 	#write {
 		padding-left: 1em;
    	padding-right: 1em;
 	}
}*/

#write {
	max-width: 40em;
}

ol,
ul {
	list-style: none;
}
blockquote,
q {
	quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
/* styles */

/* ====== */

/* headings */

h1,
h2,
h3,
h4,
h5,
h6 {
	font-weight: bold;
}
h1 {
	font-size: 1.875em;
	/*30 / 16*/
	line-height: 1.6em;
	/* 48 / 30*/
	margin-top: 2em;
}
h2,
h3 {
	font-size: 1.3125em;
	/*21 / 16*/
	line-height: 1.15;
	/*24 / 21*/
	margin-top: 2.285714em;
	/*48 / 21*/
	margin-bottom: 1.15em;
	/*24 / 21*/
}
h3 {
	font-weight: normal;
}
h4 {
	font-size: 1.125em;
	/*18 / 16*/
	margin-top: 2.67em;
	/*48 / 18*/
}
h5,
h6 {
	font-size: 1em;
	/*16*/
}
h1 {
	border-bottom: 1px solid;
	margin-bottom: 1.875em;
	padding-bottom: 0.8125em;
}
/* links */

a {
	text-decoration: none;
	color: #065588;
}
a:hover,
a:active {
	text-decoration: underline;
}
/* block spacing */

p,
blockquote,
.md-fences {
	margin-bottom: 1.5em;
}
h1,
h2,
h3,
h4,
h5,
h6 {
	margin-bottom: 1.5em;
}
/* blockquote */

blockquote {
	font-style: italic;
	border-left: 5px solid;
	margin-left: 2em;
	padding-left: 1em;
}
/* lists */

ul,
ol {
	margin: 0 0 1.5em 1.5em;
}
ol li {
	list-style-type: decimal;
	list-style-position: outside;
}
ul li {
	list-style-type: disc;
	list-style-position: outside;
}
/* tables */
.md-meta,.md-before, .md-after {
	color:#999;
}

table {
	margin-bottom: 1.5em;
	/*24 / 16*/
	font-size: 1em;
	/* width: 100%; */
}
thead th,
tfoot th {
	padding: .25em .25em .25em .4em;
	text-transform: uppercase;
}
th {
	text-align: left;
}
td {
	vertical-align: top;
	padding: .25em .25em .25em .4em;
}

code,
.md-fences {
	background-color: #dadada;
	padding-left: 1ch;
	padding-right: 1ch;
}
.md-fences {
	margin-left: 2em;
	margin-bottom: 3em;
}

.md-fences .CodeMirror.CodeMirror-wrap {
	top: -0.8em;
}

pre,
code,
tt {
	font-size: .875em;
	line-height: 1.714285em;
}
/* some fixes */

h1 {
	line-height: 1.3em;
	font-weight: normal;
	margin-bottom: 0.5em;
}

p + ul,
p + ol{
	margin-top: -1em;
}

h3 + ul,
h4 + ul,
h5 + ul,
h6 + ul,
h3 + ol,
h4 + ol,
h5 + ol,
h6 + ol {
	margin-top: .5em;
}

li > ul,
li > ol {
	margin-top: inherit;
}

h2,
h3 {
	margin-bottom: .75em;
}
hr {
	border-top: none;
	border-right: none;
	border-bottom: 1px solid;
	border-left: none;
}
h1 {
	border-color: #c5c5c5;
}
blockquote {
	border-color: #bababa;
	color: #656565;
}
thead.md-table-edit {
	background-color: transparent;
}
thead {
	background-color: #dadada;
}
tr:nth-child(even) {
	background: #e8e7e7;
}
hr {
	border-color: #c5c5c5;
}
.task-list{
	padding-left: 1rem;
}

.task-list-item {
	padding-left: 1.5rem;
	list-style-type: none;
}

.task-list-item input:before {
	content: '\221A';
	display: inline-block;
	width: 1.25rem;
  	height: 1.6rem;
	vertical-align: middle;
	text-align: center;
	color: #ddd;
	background-color: #F3F2EE;
}

.task-list-item input:checked:before,
.task-list-item input[checked]:before{
	color: inherit;
}

#write pre.md-meta-block {
	min-height: 1.875rem;
	color: #555;
	border: 0px;
	background: transparent;
	margin-top: -4px;
	margin-left: 1em;
	margin-top: 1em;
}

.md-image>.md-meta {
	color: #9B5146;
}

.md-image>.md-meta{
	font-family: Menlo, 'Ubuntu Mono', Consolas, 'Courier New', 'Microsoft Yahei', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', sans-serif;
}


#write>h3.md-focus:before{
	left: -1.5rem;
	color:#999;
	border-color:#999;
}
#write>h4.md-focus:before{
	left: -1.5rem;
	top: .25rem;
	color:#999;
	border-color:#999;
}
#write>h5.md-focus:before{
	left: -1.5rem;
	top: .0.3125rem;
	color:#999;
	border-color:#999;
}
#write>h6.md-focus:before{
	left: -1.5rem;
	top: 0.3125rem;
	color:#999;
	border-color:#999;
}

.md-toc:focus .md-toc-content{
	margin-top: 19px;
}

.md-toc-content:empty:before{
	color: #065588;
}
.md-toc-item {
	color: #065588;
}
#write div.md-toc-tooltip {
	background-color: #f3f2ee;
}

#outline-dropmenu {
	background-color: #f3f2ee;
	-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.375);
  	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.375);
}

.pin-outline #outline-dropmenu {
	background: inherit;
	box-shadow: none;
	border-right: 1px dashed;
}

.pin-outline #outline-dropmenu:hover .outline-title-wrapper {
	border-left:1px dashed;
}

.outline-item:hover {
  background-color: #dadada;
  border-left: 28px solid #dadada;
  border-right: 18px solid #dadada;
}

.typora-node .outline-item:hover {
  	border-right: 28px solid #dadada;
}

.outline-expander:before {
  content: "\f0da";
  font-family: FontAwesome;
  font-size:14px;
  top: 1px;
}

.outline-expander:hover:before,
.outline-item-open>.outline-item>.outline-expander:before {
  content: "\f0d7";
}

.modal-content {
	background-color: #f3f2ee;
}

.auto-suggest-container ul li {
	list-style-type: none;
}

/** UI for electron */

.megamenu-menu,
#top-titlebar, #top-titlebar *,
.megamenu-content {
	background: #f3f2ee;
	color: #1f0909;
}

.megamenu-menu-header {
	border-bottom: 1px dashed #202B33;
}

.megamenu-menu {
	box-shadow: none;
	border-right: 1px dashed;
}

header, .context-menu, .megamenu-content, footer {
	font-family: "PT Serif", 'Times New Roman', Times;
    color: #1f0909;
}

#megamenu-back-btn {
	color: #1f0909;
	border-color: #1f0909;
}

.megamenu-menu-header #megamenu-menu-header-title:before {
	color: #1f0909;
}

.megamenu-menu-list li a:hover, .megamenu-menu-list li a.active {
	color: inherit;
	background-color: #e8e7df;
}

.long-btn:hover {
	background-color: #e8e7df;
}

#recent-file-panel tbody tr:nth-child(2n-1) {
    background-color: transparent !important;
}

.megamenu-menu-panel tbody tr:hover td:nth-child(2) {
    color: inherit;
}

.megamenu-menu-panel .btn {
	background-color: #D2D1D1;
}

.btn-default {
	background-color: transparent;
}

.typora-sourceview-on #toggle-sourceview-btn,
.show-word-count #footer-word-count {
	background: #c7c5c5;
}

#typora-quick-open {
    background-color: inherit;
}

.md-diagram-panel {
	margin-left: -1ch;
	margin-top: 24px;
}



</style>
</head>
<body class="typora-export">
<div id="write" class="is-mac"><h1 id="markdown-for-typora"><a name="header-c5" class="md-header-anchor "></a>Markdown For Typora</h1><h2 id="overview"><a name="header-c7" class="md-header-anchor "></a>Overview</h2><p><strong>Markdown</strong> is created by <a href="http://daringfireball.net/">Daring Fireball</a>, the original guideline is <a href="http://daringfireball.net/projects/markdown/syntax">here</a>. Its syntax, however, varies between different parsers or editors. <strong>Typora</strong> is using <a href="https://help.github.com/articles/github-flavored-markdown/" target="_blank">GitHub Flavored Markdown</a>. </p><p>Please note that HTML fragments in markdown source will be recognized but not parsed or rendered. Also, there may be small reformatting on the original markdown source code after saving.</p><p><em>Outline</em></p><div class="md-toc" mdtype="toc"><p class="md-toc-content"><span class="md-toc-item md-toc-h1" data-ref="c5"><a class="md-toc-inner" style="" href="#header-c5">Markdown For Typora</a></span><span class="md-toc-item md-toc-h2" data-ref="c7"><a class="md-toc-inner" style="" href="#header-c7">Overview</a></span><span class="md-toc-item md-toc-h2" data-ref="c15"><a class="md-toc-inner" style="" href="#header-c15">Block Elements</a></span><span class="md-toc-item md-toc-h3" data-ref="c16"><a class="md-toc-inner" style="" href="#header-c16">Paragraph and line breaks</a></span><span class="md-toc-item md-toc-h3" data-ref="c21"><a class="md-toc-inner" style="" href="#header-c21">Headers</a></span><span class="md-toc-item md-toc-h3" data-ref="c27"><a class="md-toc-inner" style="" href="#header-c27">Blockquotes</a></span><span class="md-toc-item md-toc-h3" data-ref="c33"><a class="md-toc-inner" style="" href="#header-c33">Lists</a></span><span class="md-toc-item md-toc-h3" data-ref="c39"><a class="md-toc-inner" style="" href="#header-c39">Task List</a></span><span class="md-toc-item md-toc-h3" data-ref="c45"><a class="md-toc-inner" style="" href="#header-c45">(Fenced) Code Blocks</a></span><span class="md-toc-item md-toc-h3" data-ref="c51"><a class="md-toc-inner" style="" href="#header-c51">Math Blocks</a></span><span class="md-toc-item md-toc-h3" data-ref="c60"><a class="md-toc-inner" style="" href="#header-c60">Tables</a></span><span class="md-toc-item md-toc-h3" data-ref="c77"><a class="md-toc-inner" style="" href="#header-c77">Footnotes</a></span><span class="md-toc-item md-toc-h3" data-ref="c86"><a class="md-toc-inner" style="" href="#header-c86">Horizontal Rules</a></span><span class="md-toc-item md-toc-h3" data-ref="c90"><a class="md-toc-inner" style="" href="#header-c90">YAML Front Matter</a></span><span class="md-toc-item md-toc-h3" data-ref="c93"><a class="md-toc-inner" style="" href="#header-c93">Table of Contents (TOC)</a></span><span class="md-toc-item md-toc-h3" data-ref="c96"><a class="md-toc-inner" style="" href="#header-c96">Diagrams (Sequence, Flowchart and Mermaid)</a></span><span class="md-toc-item md-toc-h2" data-ref="c101"><a class="md-toc-inner" style="" href="#header-c101">Span Elements</a></span><span class="md-toc-item md-toc-h3" data-ref="c104"><a class="md-toc-inner" style="" href="#header-c104">Links</a></span><span class="md-toc-item md-toc-h4" data-ref="c118"><a class="md-toc-inner" style="" href="#header-c118">Internal Links</a></span><span class="md-toc-item md-toc-h4" data-ref="c123"><a class="md-toc-inner" style="" href="#header-c123">Reference Links</a></span><span class="md-toc-item md-toc-h3" data-ref="c137"><a class="md-toc-inner" style="" href="#header-c137">URLs</a></span><span class="md-toc-item md-toc-h3" data-ref="c144"><a class="md-toc-inner" style="" href="#header-c144">Images</a></span><span class="md-toc-item md-toc-h3" data-ref="c152"><a class="md-toc-inner" style="" href="#header-c152">Emphasis</a></span><span class="md-toc-item md-toc-h3" data-ref="c174"><a class="md-toc-inner" style="" href="#header-c174">Strong</a></span><span class="md-toc-item md-toc-h3" data-ref="c186"><a class="md-toc-inner" style="" href="#header-c186">Code</a></span><span class="md-toc-item md-toc-h3" data-ref="c194"><a class="md-toc-inner" style="" href="#header-c194">Strikethrough</a></span><span class="md-toc-item md-toc-h3" data-ref="c199"><a class="md-toc-inner" style="" href="#header-c199">Underline</a></span><span class="md-toc-item md-toc-h3" data-ref="c204"><a class="md-toc-inner" style="" href="#header-c204">Emoji 😆</a></span><span class="md-toc-item md-toc-h3" data-ref="c209"><a class="md-toc-inner" style="" href="#header-c209">HTML</a></span><span class="md-toc-item md-toc-h3" data-ref="c229"><a class="md-toc-inner" style="" href="#header-c229">Inline Math</a></span><span class="md-toc-item md-toc-h3" data-ref="c236"><a class="md-toc-inner" style="" href="#header-c236">Subscript</a></span><span class="md-toc-item md-toc-h3" data-ref="c239"><a class="md-toc-inner" style="" href="#header-c239">Superscript</a></span><span class="md-toc-item md-toc-h3" data-ref="c242"><a class="md-toc-inner" style="" href="#header-c242">Highlight</a></span></p></div><h2 id="block-elements"><a name="header-c15" class="md-header-anchor "></a>Block Elements</h2><h3 id="paragraph-and-line-breaks"><a name="header-c16" class="md-header-anchor "></a>Paragraph and line breaks</h3><p>A paragraph is simply one or more consecutive lines of text. In markdown source code, paragraphs are separated by more than one blank lines. In Typora, you only need to press <code>Return</code> to create a new paragraph.</p><p>Press <code>Shift</code> + <code>Return</code> to create a single line break. However, most markdown parser will ignore single line break, to make other markdown parsers recognize your line break, you can leave two whitespace at the end of the line, or insert <code>&lt;br/&gt;</code>.</p><h3 id="headers"><a name="header-c21" class="md-header-anchor "></a>Headers</h3><p>Headers use 1-6 hash characters at the start of the line, corresponding to header levels 1-6. For example:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><div style="width: 50px; height: 50px; overflow-x: scroll;"></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=" cm-header cm-header1 "><span style="padding-right: 0.1px;"><span class=" cm-header cm-header1"># This is an H1</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">3</div></div><pre class=" cm-header cm-header2 "><span style="padding-right: 0.1px;"><span class=" cm-header cm-header2">## This is an H2</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">4</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">5</div></div><pre class=" cm-header cm-header6 "><span style="padding-right: 0.1px;"><span class=" cm-header cm-header6">###### This is an H6</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 120px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>In typora, input ‘#’s followed by title content, and press <code>Return</code> key will create a header.</p><h3 id="blockquotes"><a name="header-c27" class="md-header-anchor "></a>Blockquotes</h3><p>Markdown uses email-style &gt; characters for block quoting. They are presented as:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>7</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=" cm-atom "><span style="padding-right: 0.1px;"><span class=" cm-block-start cm-atom">&gt; </span><span class=" cm-atom">This is a blockquote with two paragraphs. This is first paragraph.</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=" cm-atom "><span style="padding-right: 0.1px;"><span class=" cm-block-start cm-atom">&gt;</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">3</div></div><pre class=" cm-atom "><span style="padding-right: 0.1px;"><span class=" cm-block-start cm-atom">&gt; </span><span class=" cm-atom">This is second pragraph.Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">4</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">5</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">6</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">7</div></div><pre class=" cm-atom "><span style="padding-right: 0.1px;"><span class=" cm-block-start cm-atom">&gt; </span><span class=" cm-atom">This is another blockquote with one paragraph. There is three empty line to seperate two blockquote.</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 240px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>In typora, just input ‘&gt;’ followed by quote contents a block quote is  generated. Typora will insert proper ‘&gt;’ or line break for you. Block quote inside anther block quote is allowed by adding additional levels of ‘&gt;’. </p><h3 id="lists"><a name="header-c33" class="md-header-anchor "></a>Lists</h3><p>Input <code>* list item 1</code> will create an un-ordered list, the <code>*</code> symbol can be replace with <code>+</code> or <code>-</code>. </p><p>Input <code>1. list item 1</code> will create an ordered list, their markdown source code is like:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>9</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=" cm-header cm-header2 "><span style="padding-right: 0.1px;"><span class=" cm-header cm-header2">## un-ordered list</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-variable-2">* &nbsp; </span><span class="cm-variable-2">Red</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-variable-2">* &nbsp; </span><span class="cm-variable-2">Green</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">4</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-variable-2">* &nbsp; </span><span class="cm-variable-2">Blue</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">5</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">6</div></div><pre class=" cm-header cm-header2 "><span style="padding-right: 0.1px;"><span class=" cm-header cm-header2">## ordered list</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">7</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-variable-2">1.  </span><span class="cm-variable-2">Red</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">8</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-variable-2">2. <span class="cm-tab"> </span></span><span class="cm-variable-2">Green</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">9</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-variable-2">3.<span class="cm-tab">  </span></span><span class="cm-variable-2">Blue</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 216px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><h3 id="task-list"><a name="header-c39" class="md-header-anchor "></a>Task List</h3><p>Task lists are lists with items marked as either [ ] or [x] (incomplete or complete). For example:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>5</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-block-start cm-variable-2">- </span><span class="cm-formatting cm-formatting-task cm-block-start cm-meta">[ ] </span><span class="cm-variable-2">a task list item</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-block-start cm-variable-2">- </span><span class="cm-formatting cm-formatting-task cm-block-start cm-meta">[ ] </span><span class="cm-variable-2">list syntax required</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-block-start cm-variable-2">- </span><span class="cm-formatting cm-formatting-task cm-block-start cm-meta">[ ] </span><span class="cm-variable-2">normal </span><span class="cm-strong cm-variable-2">**formatting**</span><span class="cm-variable-2">, @mentions, #1234 refs</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">4</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-block-start cm-variable-2">- </span><span class="cm-formatting cm-formatting-task cm-block-start cm-meta">[ ] </span><span class="cm-variable-2">incomplete</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">5</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-block-start cm-variable-2">- </span><span class="cm-formatting cm-formatting-task cm-block-start cm-property">[x] </span><span class="cm-variable-2">completed</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 120px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>You can change the complete/incomplete state by click the checkbox before the item.</p><h3 id="fenced-code-blocks"><a name="header-c45" class="md-header-anchor "></a>(Fenced) Code Blocks</h3><p>Typora only support fences in Github Flavored Markdown. Original code blocks in markdown is not supported.</p><p>Using fences is easy: Input ``` and press <code>return</code>. Add an optional language identifier after ``` and we&#39;ll run it through syntax highlighting:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="gfm"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 39px;"></div><div class="CodeMirror-hscrollbar" style="left: 35px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 35px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>14</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 27px;">1</div></div><pre class=""><span style="padding-right: 0.1px;">Here's an example:</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">3</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-comment">```</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">4</div></div><pre class=" cm-s-inner "><span style="padding-right: 0.1px;"><span class=" cm-overlay cm-code">function test() {</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">5</div></div><pre class=" cm-s-inner "><span style="padding-right: 0.1px;">  <span class=" cm-overlay cm-code">console.log("notice the blank line before this function?");</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">6</div></div><pre class=" cm-s-inner "><span style="padding-right: 0.1px;"><span class=" cm-overlay cm-code">}</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">7</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-comment">```</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">8</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">9</div></div><pre class=""><span style="padding-right: 0.1px;">syntax highlighting:</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 27px;">10</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-block-start cm-comment">```ruby</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">11</div></div><pre class=" cm-s-inner "><span style="padding-right: 0.1px;"><span class=" cm-overlay cm-keyword">require</span><span class=" cm-overlay "> </span><span class=" cm-overlay cm-string">'redcarpet'</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">12</div></div><pre class=" cm-s-inner "><span style="padding-right: 0.1px;"><span class=" cm-overlay cm-variable">markdown</span><span class=" cm-overlay "> </span><span class=" cm-overlay cm-operator">=</span><span class=" cm-overlay "> </span><span class=" cm-overlay cm-tag">Redcarpet</span><span class=" cm-overlay cm-operator">.</span><span class=" cm-overlay cm-variable">new</span><span class=" cm-overlay ">(</span><span class=" cm-overlay cm-string">"Hello World!"</span><span class=" cm-overlay ">)</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 27px;">13</div></div><pre class=" cm-s-inner "><span style="padding-right: 0.1px;"><span class=" cm-overlay cm-variable">puts</span><span class=" cm-overlay "> </span><span class=" cm-overlay cm-variable">markdown</span><span class=" cm-overlay cm-operator">.</span><span class=" cm-overlay cm-variable">to_html</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -35px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 27px;">14</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-comment">```</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 360px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 35px;"></div></div></div></div></pre><h3 id="math-blocks"><a name="header-c51" class="md-header-anchor "></a>Math Blocks</h3><p>You can render <em>LaTeX</em> mathematical expressions using <strong>MathJax</strong>.</p><p>Input <code>$$</code>, then press &#39;Return&#39; key will trigger an input field which accept <em>Tex/LaTex</em> source. Following is an example:</p><div contenteditable="false" class="mathjax-block md-end-block" id="mathjax-c55" cid="c55" mdtype="math_block"><span class="MathJax_Preview"></span><span class="MathJax_SVG_Display" style="text-align: center;"><span class="MathJax_SVG" id="MathJax-Element-2-Frame" tabindex="-1" style="font-size: 100%; display: inline-block;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" width="26.37ex" height="10.884ex" viewbox="0 -2585.3 11353.6 4686.3" role="img" focusable="false" style="vertical-align: -4.88ex;"><defs><path stroke-width="1" id="E2-MJMAINB-56" d="M592 686H604Q615 685 631 685T666 684T700 684T724 683Q829 683 835 686H843V624H744L611 315Q584 254 546 165Q492 40 482 19T461 -6L460 -7H409Q398 -4 391 9Q385 20 257 315L124 624H25V686H36Q57 683 190 683Q340 683 364 686H377V624H289L384 403L480 185L492 212Q504 240 529 298T575 405L670 624H582V686H592Z"/><path stroke-width="1" id="E2-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"/><path stroke-width="1" id="E2-MJMAIN-D7" d="M630 29Q630 9 609 9Q604 9 587 25T493 118L389 222L284 117Q178 13 175 11Q171 9 168 9Q160 9 154 15T147 29Q147 36 161 51T255 146L359 250L255 354Q174 435 161 449T147 471Q147 480 153 485T168 490Q173 490 175 489Q178 487 284 383L389 278L493 382Q570 459 587 475T609 491Q630 491 630 471Q630 464 620 453T522 355L418 250L522 145Q606 61 618 48T630 29Z"/><path stroke-width="1" id="E2-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"/><path stroke-width="1" id="E2-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"/><path stroke-width="1" id="E2-MJMAIN-7C" d="M139 -249H137Q125 -249 119 -235V251L120 737Q130 750 139 750Q152 750 159 735V-235Q151 -249 141 -249H139Z"/><path stroke-width="1" id="E2-MJMAINB-69" d="M72 610Q72 649 98 672T159 695Q193 693 217 670T241 610Q241 572 217 549T157 525Q120 525 96 548T72 610ZM46 442L136 446L226 450H232V62H294V0H286Q271 3 171 3Q67 3 49 0H40V62H109V209Q109 358 108 362Q103 380 55 380H43V442H46Z"/><path stroke-width="1" id="E2-MJMAINB-6A" d="M104 610Q104 649 130 672T191 695Q225 693 249 670T273 610Q273 572 249 549T189 525Q152 525 128 548T104 610ZM78 442L173 446L268 450H274V196Q274 -5 274 -37T269 -83Q256 -132 201 -166T71 -200Q10 -200 -30 -173T-71 -102Q-71 -70 -51 -51T-1 -31Q27 -31 48 -49T69 -100Q69 -121 53 -147H56Q66 -149 77 -149H80Q90 -149 100 -146T127 -125T149 -73Q151 -55 151 149V362Q150 364 148 366T145 370T142 373T138 375T133 377T124 378T113 379T97 380H75V442H78Z"/><path stroke-width="1" id="E2-MJMAINB-6B" d="M32 686L123 690Q214 694 215 694H221V255L377 382H346V444H355Q370 441 476 441Q544 441 556 444H562V382H476L347 277L515 62H587V0H579Q564 3 476 3Q370 3 352 0H343V62H358L373 63L260 206L237 189L216 172V62H285V0H277Q259 3 157 3Q46 3 37 0H29V62H98V332Q98 387 98 453T99 534Q99 593 97 605T83 620Q69 624 42 624H29V686H32Z"/><path stroke-width="1" id="E2-MJMAIN-2202" d="M202 508Q179 508 169 520T158 547Q158 557 164 577T185 624T230 675T301 710L333 715H345Q378 715 384 714Q447 703 489 661T549 568T566 457Q566 362 519 240T402 53Q321 -22 223 -22Q123 -22 73 56Q42 102 42 148V159Q42 276 129 370T322 465Q383 465 414 434T455 367L458 378Q478 461 478 515Q478 603 437 639T344 676Q266 676 223 612Q264 606 264 572Q264 547 246 528T202 508ZM430 306Q430 372 401 400T333 428Q270 428 222 382Q197 354 183 323T150 221Q132 149 132 116Q132 21 232 21Q244 21 250 22Q327 35 374 112Q389 137 409 196T430 306Z"/><path stroke-width="1" id="E2-MJMATHI-58" d="M42 0H40Q26 0 26 11Q26 15 29 27Q33 41 36 43T55 46Q141 49 190 98Q200 108 306 224T411 342Q302 620 297 625Q288 636 234 637H206Q200 643 200 645T202 664Q206 677 212 683H226Q260 681 347 681Q380 681 408 681T453 682T473 682Q490 682 490 671Q490 670 488 658Q484 643 481 640T465 637Q434 634 411 620L488 426L541 485Q646 598 646 610Q646 628 622 635Q617 635 609 637Q594 637 594 648Q594 650 596 664Q600 677 606 683H618Q619 683 643 683T697 681T738 680Q828 680 837 683H845Q852 676 852 672Q850 647 840 637H824Q790 636 763 628T722 611T698 593L687 584Q687 585 592 480L505 384Q505 383 536 304T601 142T638 56Q648 47 699 46Q734 46 734 37Q734 35 732 23Q728 7 725 4T711 1Q708 1 678 1T589 2Q528 2 496 2T461 1Q444 1 444 10Q444 11 446 25Q448 35 450 39T455 44T464 46T480 47T506 54Q523 62 523 64Q522 64 476 181L429 299Q241 95 236 84Q232 76 232 72Q232 53 261 47Q262 47 267 47T273 46Q276 46 277 46T280 45T283 42T284 35Q284 26 282 19Q279 6 276 4T261 1Q258 1 243 1T201 2T142 2Q64 2 42 0Z"/><path stroke-width="1" id="E2-MJMATHI-75" d="M21 287Q21 295 30 318T55 370T99 420T158 442Q204 442 227 417T250 358Q250 340 216 246T182 105Q182 62 196 45T238 27T291 44T328 78L339 95Q341 99 377 247Q407 367 413 387T427 416Q444 431 463 431Q480 431 488 421T496 402L420 84Q419 79 419 68Q419 43 426 35T447 26Q469 29 482 57T512 145Q514 153 532 153Q551 153 551 144Q550 139 549 130T540 98T523 55T498 17T462 -8Q454 -10 438 -10Q372 -10 347 46Q345 45 336 36T318 21T296 6T267 -6T233 -11Q189 -11 155 7Q103 38 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z"/><path stroke-width="1" id="E2-MJMATHI-59" d="M66 637Q54 637 49 637T39 638T32 641T30 647T33 664T42 682Q44 683 56 683Q104 680 165 680Q288 680 306 683H316Q322 677 322 674T320 656Q316 643 310 637H298Q242 637 242 624Q242 619 292 477T343 333L346 336Q350 340 358 349T379 373T411 410T454 461Q546 568 561 587T577 618Q577 634 545 637Q528 637 528 647Q528 649 530 661Q533 676 535 679T549 683Q551 683 578 682T657 680Q684 680 713 681T746 682Q763 682 763 673Q763 669 760 657T755 643Q753 637 734 637Q662 632 617 587Q608 578 477 424L348 273L322 169Q295 62 295 57Q295 46 363 46Q379 46 384 45T390 35Q390 33 388 23Q384 6 382 4T366 1Q361 1 324 1T232 2Q170 2 138 2T102 1Q84 1 84 9Q84 14 87 24Q88 27 89 30T90 35T91 39T93 42T96 44T101 45T107 45T116 46T129 46Q168 47 180 50T198 63Q201 68 227 171L252 274L129 623Q128 624 127 625T125 627T122 629T118 631T113 633T105 634T96 635T83 636T66 637Z"/><path stroke-width="1" id="E2-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"/><path stroke-width="1" id="E2-MJMATHI-76" d="M173 380Q173 405 154 405Q130 405 104 376T61 287Q60 286 59 284T58 281T56 279T53 278T49 278T41 278H27Q21 284 21 287Q21 294 29 316T53 368T97 419T160 441Q202 441 225 417T249 361Q249 344 246 335Q246 329 231 291T200 202T182 113Q182 86 187 69Q200 26 250 26Q287 26 319 60T369 139T398 222T409 277Q409 300 401 317T383 343T365 361T357 383Q357 405 376 424T417 443Q436 443 451 425T467 367Q467 340 455 284T418 159T347 40T241 -11Q177 -11 139 22Q102 54 102 117Q102 148 110 181T151 298Q173 362 173 380Z"/><path stroke-width="1" id="E2-MJMAIN-2223" d="M139 -249H137Q125 -249 119 -235V251L120 737Q130 750 139 750Q152 750 159 735V-235Q151 -249 141 -249H139Z"/></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><use xlink:href="#E2-MJMAINB-56" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-31" x="1229" y="-213"/><use xlink:href="#E2-MJMAIN-D7" x="1545" y="0"/><g transform="translate(2546,0)"><use xlink:href="#E2-MJMAINB-56" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-32" x="1229" y="-213"/></g><use xlink:href="#E2-MJMAIN-3D" x="4147" y="0"/><g transform="translate(5203,0)"><g transform="translate(0,2517)"><use xlink:href="#E2-MJMAIN-2223" x="0" y="-751"/><g transform="translate(0,-2926.296570590173) scale(1,2.6302217983890452)"><use xlink:href="#E2-MJMAIN-2223"/></g><use xlink:href="#E2-MJMAIN-2223" x="0" y="-4285"/></g><g transform="translate(445,0)"><g transform="translate(-14,0)"><use xlink:href="#E2-MJMAINB-69" x="522" y="1717"/><g transform="translate(0,182)"><g transform="translate(120,0)"><rect stroke="none" width="1124" height="60" x="0" y="220"/><g transform="translate(59,427)"><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-2202" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMATHI-58" x="567" y="0"/></g><g transform="translate(158,-418)"><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-2202" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMATHI-75" x="567" y="0"/></g></g></g><g transform="translate(0,-1584)"><g transform="translate(120,0)"><rect stroke="none" width="1124" height="60" x="0" y="220"/><g transform="translate(59,427)"><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-2202" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMATHI-58" x="567" y="0"/></g><g transform="translate(189,-418)"><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-2202" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMATHI-76" x="567" y="0"/></g></g></g></g><g transform="translate(2350,0)"><use xlink:href="#E2-MJMAINB-6A" x="474" y="1717"/><g transform="translate(0,182)"><g transform="translate(120,0)"><rect stroke="none" width="1061" height="60" x="0" y="220"/><g transform="translate(60,427)"><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-2202" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMATHI-59" x="567" y="0"/></g><g transform="translate(127,-418)"><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-2202" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMATHI-75" x="567" y="0"/></g></g></g><g transform="translate(0,-1584)"><g transform="translate(120,0)"><rect stroke="none" width="1061" height="60" x="0" y="220"/><g transform="translate(60,427)"><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-2202" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMATHI-59" x="567" y="0"/></g><g transform="translate(158,-418)"><use transform="scale(0.707)" xlink:href="#E2-MJMAIN-2202" x="0" y="0"/><use transform="scale(0.707)" xlink:href="#E2-MJMATHI-76" x="567" y="0"/></g></g></g></g><g transform="translate(4651,0)"><use xlink:href="#E2-MJMAINB-6B" x="0" y="1717"/><use xlink:href="#E2-MJMAIN-30" x="53" y="182"/><use xlink:href="#E2-MJMAIN-30" x="53" y="-1584"/></g></g><g transform="translate(5871,2517)"><use xlink:href="#E2-MJMAIN-2223" x="0" y="-751"/><g transform="translate(0,-2926.296570590173) scale(1,2.6302217983890452)"><use xlink:href="#E2-MJMAIN-2223"/></g><use xlink:href="#E2-MJMAIN-2223" x="0" y="-4285"/></g></g></g></svg></span></span><script type="math/tex; mode=display" id="MathJax-Element-2">
\mathbf{V}_1 \times \mathbf{V}_2 =  \begin{vmatrix} 
\mathbf{i} & \mathbf{j} & \mathbf{k} \\
\frac{\partial X}{\partial u} &  \frac{\partial Y}{\partial u} & 0 \\
\frac{\partial X}{\partial v} &  \frac{\partial Y}{\partial v} & 0 \\
\end{vmatrix}
</script></div><p>In markdown source file, math block is <em>LaTeX</em> expression wrapped by ‘$$’ mark:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>7</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-comment">$$</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=" cm-s-inner "><span style="padding-right: 0.1px;"><span class="cm-block-start cm-comment">\mathbf</span><span class=" cm-overlay cm-bracket">{</span><span class=" cm-overlay ">V</span><span class=" cm-overlay cm-bracket">}</span><span class=" cm-overlay ">_1 </span><span class=" cm-overlay cm-tag">\times</span><span class=" cm-overlay "> </span><span class=" cm-overlay cm-tag">\mathbf</span><span class=" cm-overlay cm-bracket">{</span><span class=" cm-overlay ">V</span><span class=" cm-overlay cm-bracket">}</span><span class=" cm-overlay ">_2 =  </span><span class=" cm-overlay cm-tag">\begin</span><span class=" cm-overlay cm-bracket">{</span><span class=" cm-overlay cm-atom">vmatrix</span><span class=" cm-overlay cm-bracket">}</span><span class=" cm-overlay "> </span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">3</div></div><pre class=" cm-s-inner "><span style="padding-right: 0.1px;"><span class=" cm-overlay cm-tag">\mathbf</span><span class=" cm-overlay cm-bracket">{</span><span class=" cm-overlay ">i</span><span class=" cm-overlay cm-bracket">}</span><span class=" cm-overlay "> &amp; </span><span class=" cm-overlay cm-tag">\mathbf</span><span class=" cm-overlay cm-bracket">{</span><span class=" cm-overlay ">j</span><span class=" cm-overlay cm-bracket">}</span><span class=" cm-overlay "> &amp; </span><span class=" cm-overlay cm-tag">\mathbf</span><span class=" cm-overlay cm-bracket">{</span><span class=" cm-overlay ">k</span><span class=" cm-overlay cm-bracket">}</span><span class=" cm-overlay "> </span><span class=" cm-overlay cm-tag">\\</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">4</div></div><pre class=" cm-s-inner "><span style="padding-right: 0.1px;"><span class=" cm-overlay cm-tag">\frac</span><span class=" cm-overlay cm-bracket">{</span><span class=" cm-overlay cm-tag">\partial</span><span class=" cm-overlay "> X</span><span class=" cm-overlay cm-bracket">}{</span><span class=" cm-overlay cm-tag">\partial</span><span class=" cm-overlay "> u</span><span class=" cm-overlay cm-bracket">}</span><span class=" cm-overlay "> &amp;  </span><span class=" cm-overlay cm-tag">\frac</span><span class=" cm-overlay cm-bracket">{</span><span class=" cm-overlay cm-tag">\partial</span><span class=" cm-overlay "> Y</span><span class=" cm-overlay cm-bracket">}{</span><span class=" cm-overlay cm-tag">\partial</span><span class=" cm-overlay "> u</span><span class=" cm-overlay cm-bracket">}</span><span class=" cm-overlay "> &amp; 0 </span><span class=" cm-overlay cm-tag">\\</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">5</div></div><pre class=" cm-s-inner "><span style="padding-right: 0.1px;"><span class=" cm-overlay cm-tag">\frac</span><span class=" cm-overlay cm-bracket">{</span><span class=" cm-overlay cm-tag">\partial</span><span class=" cm-overlay "> X</span><span class=" cm-overlay cm-bracket">}{</span><span class=" cm-overlay cm-tag">\partial</span><span class=" cm-overlay "> v</span><span class=" cm-overlay cm-bracket">}</span><span class=" cm-overlay "> &amp;  </span><span class=" cm-overlay cm-tag">\frac</span><span class=" cm-overlay cm-bracket">{</span><span class=" cm-overlay cm-tag">\partial</span><span class=" cm-overlay "> Y</span><span class=" cm-overlay cm-bracket">}{</span><span class=" cm-overlay cm-tag">\partial</span><span class=" cm-overlay "> v</span><span class=" cm-overlay cm-bracket">}</span><span class=" cm-overlay "> &amp; 0 </span><span class=" cm-overlay cm-tag">\\</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">6</div></div><pre class=" cm-s-inner "><span style="padding-right: 0.1px;"><span class=" cm-overlay cm-tag">\end</span><span class=" cm-overlay cm-bracket">{</span><span class=" cm-overlay cm-atom">vmatrix</span><span class=" cm-overlay cm-bracket">}</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">7</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-comment">$$</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 216px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><h3 id="tables"><a name="header-c60" class="md-header-anchor "></a>Tables</h3><p>Input <code>| First Header  | Second Header |</code> and press <code>return</code> key will create a table with two column.</p><p>After table is created, focus on that table will pop up a toolbar for table, where you can resize, align, or delete table. You can also use context menu to copy and add/delete column/row.</p><p>Following descriptions can be skipped, as markdown source code for tables are generated by typora automatically.</p><p>In markdown source code, they look like:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>4</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=" cm-table-row "><span style="padding-right: 0.1px;">| First Header  | Second Header |</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=" cm-table-row "><span style="padding-right: 0.1px;">| ------------- | ------------- |</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">3</div></div><pre class=" cm-table-row "><span style="padding-right: 0.1px;">| Content Cell  | Content Cell  |</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">4</div></div><pre class=" cm-table-row "><span style="padding-right: 0.1px;">| Content Cell  | Content Cell  |</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 96px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>You can also include inline Markdown such as links, bold, italics, or strikethrough.</p><p>Finally, by including colons : within the header row, you can define text to be left-aligned, right-aligned, or center-aligned:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>5</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=" cm-table-row "><span style="padding-right: 0.1px;">| Left-Aligned  | Center Aligned  | Right Aligned |</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=" cm-table-row "><span style="padding-right: 0.1px;">| :------------ |:---------------:| -----:|</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">3</div></div><pre class=" cm-table-row "><span style="padding-right: 0.1px;">| col 3 is &nbsp; &nbsp;  | some wordy text | $1600 |</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">4</div></div><pre class=" cm-table-row "><span style="padding-right: 0.1px;">| col 2 is &nbsp; &nbsp;  | centered &nbsp; &nbsp; &nbsp;  | &nbsp; $12 |</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">5</div></div><pre class=" cm-table-row "><span style="padding-right: 0.1px;">| zebra stripes | are neat &nbsp; &nbsp; &nbsp;  | &nbsp;  $1 |</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 120px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>A colon on the left-most side indicates a left-aligned column; a colon on the right-most side indicates a right-aligned column; a colon on both sides indicates a center-aligned column.</p><h3 id="footnotes"><a name="header-c77" class="md-header-anchor "></a>Footnotes</h3><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>3</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;">You can create footnotes like this[^footnote].</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-link">[^footnote]:</span> <span class="cm-string">Here</span> is the <span class="cm-em">*text*</span> of the <span class="cm-strong">**footnote**</span>.</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 72px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>will produce:</p><p>You can create footnotes like this<sup><a href="#dfref-footnote-1" name="ref-footnote-1">1</a></sup>.</p><p>Mouse on the ‘footnote’ superscript to see content of the footnote.</p><h3 id="horizontal-rules"><a name="header-c86" class="md-header-anchor "></a>Horizontal Rules</h3><p>Input <code>***</code> or <code>---</code> on a blank line and press <code>return</code> will draw a horizontal line.</p><hr><h3 id="yaml-front-matter"><a name="header-c90" class="md-header-anchor "></a>YAML Front Matter</h3><p>Typora support <a href="http://jekyllrb.com/docs/frontmatter/">YAML Front Matter</a> now. Input <code>---</code> at the top of the article and then press <code>Enter</code> will introduce one. Or insert one metadata block from the menu.</p><h3 id="table-of-contents-toc"><a name="header-c93" class="md-header-anchor "></a>Table of Contents (TOC)</h3><p>Input <code>[toc]</code> then press <code>Return</code> key will create a section for “Table of Contents” extracting all headers from one’s writing, its contents will be updated automatically. </p><h3 id="diagrams-sequence-flowchart-and-mermaid"><a name="header-c96" class="md-header-anchor "></a>Diagrams (Sequence, Flowchart and Mermaid)</h3><p>Typora supports, <a href="https://bramp.github.io/js-sequence-diagrams/">sequence</a>, <a href="http://flowchart.js.org/">flowchart</a> and <a href="https://knsv.github.io/mermaid/#mermaid">mermaid</a>, after this feature is enabled from preference panel.</p><p>See this <a href="http://support.typora.io/Draw-Diagrams-With-Markdown/">document</a> for detail.</p><h2 id="span-elements"><a name="header-c101" class="md-header-anchor "></a>Span Elements</h2><p>Span elements will be parsed and rendered right after your typing. Moving cursor in middle of those span elements will expand those elements into markdown source. Following will explain the syntax of those span element.</p><h3 id="links"><a name="header-c104" class="md-header-anchor "></a>Links</h3><p>Markdown supports two style of links: inline and reference.</p><p>In both styles, the link text is delimited by [square brackets].</p><p>To create an inline link, use a set of regular parentheses immediately after the link text’s closing square bracket. Inside the parentheses, put the URL where you want the link to point, along with an optional title for the link, surrounded in quotes. For example:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>3</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;">This is <span class="cm-link">[an example]</span><span class="cm-string">(http://example.com/ "Title")</span> inline link.</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-link">[This link]</span><span class="cm-string">(http://example.net/)</span> has no title attribute.</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 96px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>will produce:</p><p>This is <a href="http://example.com/" title="Title">an example</a> inline link. (<code>&lt;p&gt;This is &lt;a href=&quot;http://example.com/&quot; title=&quot;Title&quot;&gt;</code>)</p><p><a href="http://example.net/">This link</a> has no title attribute. (<code>&lt;p&gt;&lt;a href=&quot;http://example.net/&quot;&gt;This link&lt;/a&gt; has no</code>)</p><h4 id="internal-links"><a name="header-c118" class="md-header-anchor "></a>Internal Links</h4><p><strong>You can set the href to headers</strong>, which will create a bookmark that allow you to jump to that section after clicking. For example:</p><p>Command(on Windows: Ctrl) + Click <a href="#header-c15">This link</a> will jump to header <code>Block Elements</code>. To see how to write that, please move cursor or click that link with <code>⌘</code> key pressed to expand the element into markdown source.</p><h4 id="reference-links"><a name="header-c123" class="md-header-anchor "></a>Reference Links</h4><p>Reference-style links use a second set of square brackets, inside which you place a label of your choosing to identify the link:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>5</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;">This is <span class="cm-link">[an example]</span><span class="cm-string">[id]</span> reference-style link.</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;">Then, anywhere in the document, you define your link label like this, on a line by itself:</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">4</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">5</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-link">[id]:</span> <span class="cm-string">http://example.com/  "Optional Title Here"</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 144px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>In typora, they will be rendered like:</p><p>This is <a href="http://example.com/" target="_blank" title="Optional Title Here">an example</a> reference-style link.</p><p>The implicit link name shortcut allows you to omit the name of the link, in which case the link text itself is used as the name. Just use an empty set of square brackets — e.g., to link the word “Google” to the google.com web site, you could simply write:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>4</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-link">[Google]</span><span class="cm-string">[]</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;">And then define the link:</span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">4</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-link">[Google]:</span> <span class="cm-string">http://google.com/</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 96px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>In typora click link will expand it for editing, command+click will open the hyperlink in web browser.</p><h3 id="urls"><a name="header-c137" class="md-header-anchor "></a>URLs</h3><p>Typora allows you to insert urls as links, wrapped by <code>&lt;</code>brackets<code>&gt;</code>.</p><p><code>&lt;i@typora.io&gt;</code> becomes <a href="mailto:i@typora.io" target="_blank">i@typora.io</a>.</p><p>Typora will aslo auto link standard URLs. e.g: <a href="www.google.com" target="_blank">www.google.com</a>.</p><h3 id="images"><a name="header-c144" class="md-header-anchor "></a>Images</h3><p>Image looks similar with links, but it requires an additional <code>!</code> char before the start of link. Image syntax looks like this:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>3</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-tag">![Alt text]</span><span class="cm-string">(/path/to/img.jpg)</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-tag">![Alt text]</span><span class="cm-string">(/path/to/img.jpg "Optional title")</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 72px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>You are able to use drag &amp; drop to insert image from image file or we browser. And modify the markdown source code by clicking on the image. Relative path will be used if image is in same directory or sub-directory with current editing document when drag &amp; drop.</p><p>For more tips on images, please read <a href="http://support.typora.io//Images/" target="_blank">http://support.typora.io//Images/</a></p><h3 id="emphasis"><a name="header-c152" class="md-header-anchor "></a>Emphasis</h3><p>Markdown treats asterisks (<code>*</code>) and underscores (<code>_</code>) as indicators of emphasis. Text wrapped with one <code>*</code> or <code>_</code> will be wrapped with an HTML <code>&lt;em&gt;</code> tag. E.g:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>3</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-em">*single asterisks*</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-em">_single underscores_</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 72px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>output: </p><p><em>single asterisks</em></p><p><em>single underscores</em></p><p>GFM will ignores underscores in words, which is commonly used in code and names, like this:</p><blockquote><p>wow_great_stuff</p><p>do_this_and_do_that_and_another_thing.</p></blockquote><p>To produce a literal asterisk or underscore at a position where it would otherwise be used as an emphasis delimiter, you can backslash escape it:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>1</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;">\*this text is surrounded by literal asterisks\*</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 24px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>Typora recommends to use <code>*</code> symbol.</p><h3 id="strong"><a name="header-c174" class="md-header-anchor "></a>Strong</h3><p>double *’s or _’s will be wrapped with an HTML <code>&lt;strong&gt;</code> tag, e.g:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>3</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-strong">**double asterisks**</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 18px;">2</div></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><div style="position: relative;"><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">3</div></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-strong">__double underscores__</span></span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 72px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>output:</p><p><strong>double asterisks</strong></p><p><strong>double underscores</strong></p><p>Typora recommends to use <code>**</code> symbol.</p><h3 id="code"><a name="header-c186" class="md-header-anchor "></a>Code</h3><p>To indicate a span of code, wrap it with backtick quotes (`). Unlike a pre-formatted code block, a code span indicates code within a normal paragraph. For example:</p><pre class="md-fences md-end-block md-fences-with-lineno" lang="markdown"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 30px;"></div><div class="CodeMirror-hscrollbar" style="left: 26px; min-height: 18px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar" style="min-width: 18px;"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 26px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre><div class="CodeMirror-linenumber CodeMirror-gutter-elt"><div>1</div></div></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-wrapper" style="position: absolute; left: -26px;"><div class="CodeMirror-linenumber CodeMirror-gutter-elt CodeMirror-linenumber-show" style="left: 0px; width: 18px;">1</div></div><pre class=""><span style="padding-right: 0.1px;">Use the <span class="cm-comment">`printf()`</span> function.</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="height: 24px;"><div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 26px;"></div></div></div></div></pre><p>will produce:</p><p>Use the <code>printf()</code> function.</p><h3 id="strikethrough"><a name="header-c194" class="md-header-anchor "></a>Strikethrough</h3><p>GFM adds syntax to create strikethrough text, which is missing from standard Markdown.</p><p><code>~~Mistaken text.~~</code> becomes <del>Mistaken text.</del></p><h3 id="underline"><a name="header-c199" class="md-header-anchor "></a>Underline</h3><p>Underline is powered by raw HTML.</p><p><code>&lt;u&gt;Underline&lt;/u&gt;</code> becomes <u>Underline</u>.</p><h3 id="emoji"><a name="header-c204" class="md-header-anchor "></a>Emoji 😆</h3><p>Input emoji with syntax <code>:smile:</code>. </p><p>User can trigger auto-complete suggestions for emoji by pressing <code>ESC</code> key, or trigger it automatically after enable it on preference panel. Also, input UTF8 emoji char directly from <code>Edit</code> -&gt; <code>Emoji &amp; Symbols</code> from menu bar is also supported. </p><h3 id="html"><a name="header-c209" class="md-header-anchor "></a>HTML</h3><p>Typora cannot render html fragments. But typora can parse and render very limited HTML fragments, as an extension of Markdown, including:</p><ul><li>Underline: <code>&lt;u&gt;underline&lt;/u&gt;</code></li><li>Image: <code>&lt;img src=&quot;http://www.w3.org/html/logo/img/mark-word-icon.png&quot; width=&quot;200px&quot; /&gt;</code> (And <code>width</code>, <code>height</code> attribute in HTML tag, and <code>width</code>, <code>height</code>, <code>zoom</code> style in <code>style</code> attribute will be applied.)</li><li>Comments: <code>&lt;!-- This is some comments --&gt;</code></li><li>Hyperlink: <code>&lt;a href=&quot;http://typora.io&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;</code>.</li></ul><p>Most of their attributes, styles, or classes will be ignored. For other tags, typora will render them as raw HTML snippets. </p><p>But those HTML will be exported on print or export.</p><h3 id="inline-math"><a name="header-c229" class="md-header-anchor "></a>Inline Math</h3><p>To use this feature, first, please enable it in <code>Preference</code> Panel -&gt; <code>Markdown</code> Tab. Then use <code>$</code> to wrap TeX command, for example: <code>$\lim_{x \to \infty} \exp(-x) = 0$</code> will be rendered as LaTeX command. </p><p>To trigger inline preview for inline math: input “$”, then press <code>ESC</code> key, then input TeX command, a preview tooltip will be visible like below:</p><p><img src="http://typora.io/img/inline-math.gif" style="zoom:50%;"></p><h3 id="subscript"><a name="header-c236" class="md-header-anchor "></a>Subscript</h3><p>To use this feature, first, please enable it in <code>Preference</code> Panel -&gt; <code>Markdown</code> Tab. Then use <code>~</code> to wrap subscript content, for example: <code>H~2~O</code>, <code>X~long\ text~</code>/</p><h3 id="superscript"><a name="header-c239" class="md-header-anchor "></a>Superscript</h3><p>To use this feature, first, please enable it in <code>Preference</code> Panel -&gt; <code>Markdown</code> Tab. Then use <code>^</code> to wrap superscript content, for example: <code>X^2^</code>.</p><h3 id="highlight"><a name="header-c242" class="md-header-anchor "></a>Highlight</h3><p>To use this feature, first, please enable it in <code>Preference</code> Panel -&gt; <code>Markdown</code> Tab. Then use <code>==</code> to wrap superscript content, for example: <code>==highlight==</code>. </p><div class="footnotes-area"><hr>
<div class="footnote-line"><span class="md-fn-count">1</span> Here is the <em>text</em> of the <strong>footnote</strong>.<a name="dfref-footnote-1" href="#ref-footnote-1" title="back to document" class="reversefootnote">↩</a></div></div></div>
</body>
</html>]]></content>
    
    <summary type="html">
    
      &lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width initial-scale=1&quot;&gt;
&lt;title&gt;Markdown Refe
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title>Andrew Ng&#39;s Machine learning first day of the second week</title>
    <link href="https://blaceman.github.io/2017/03/13/Andrew-Ng-s-Machine-learning-first-day-of-the-second-week/"/>
    <id>https://blaceman.github.io/2017/03/13/Andrew-Ng-s-Machine-learning-first-day-of-the-second-week/</id>
    <published>2017-03-13T07:23:49.000Z</published>
    <updated>2017-05-19T01:22:02.000Z</updated>
    
    <summary type="html">
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title>Andrew Ng&#39;s 机器学习day three</title>
    <link href="https://blaceman.github.io/2017/03/09/Andrew-Ng-s-%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0day-three/"/>
    <id>https://blaceman.github.io/2017/03/09/Andrew-Ng-s-机器学习day-three/</id>
    <published>2017-03-09T09:16:54.000Z</published>
    <updated>2017-03-09T12:47:29.000Z</updated>
    
    <content type="html"><![CDATA[<h3 id="paramater-learning参数学习"><a href="#Paramater-Learning-参数学习" class="headerlink" title="Paramater Learning(参数学习)"></a>Paramater Learning(参数学习)</h3><h4 id="1gradient-descent梯度下降"><a href="#1-Gradient-Descent-梯度下降" class="headerlink" title="1.Gradient Descent(梯度下降)"></a>1.Gradient Descent(梯度下降)</h4><h5 id="假定我们有一个hypothesis函数我们有一个方法测量合适的数据现在我们需要估计hypothesis函数的参数这时梯度下降派上用场"><a href="#假定我们有一个hypothesis函数-我们有一个方法测量合适的数据-现在我们需要估计hypothesis函数的参数-这时梯度下降派上用场" class="headerlink" title="假定我们有一个hypothesis函数,我们有一个方法测量合适的数据,现在我们需要估计hypothesis函数的参数,这时梯度下降派上用场"></a>假定我们有一个hypothesis函数,我们有一个方法测量合适的数据,现在我们需要估计hypothesis函数的参数,这时<code>梯度下降</code>派上用场</h5><h5 id="假设我们要画出基于θ0和θ1的假设函数hypothesis实际上我们把代价函数绘制为参数估值函数-我们不是绘制x和y本身而是我们的假设函数的参数范围和由选择特定参数集所产生的代价"><a href="#假设我们要画出基于θ0和θ1的假设函数-hypothesis-实际上我们把代价函数绘制为参数估值函数-我们不是绘制x和y本身，而是我们的假设函数的参数范围和由选择特定参数集所产生的代价" class="headerlink" title="假设我们要画出基于θ0和θ1的假设函数(hypothesis)(实际上我们把代价函数绘制为参数估值函数) 我们不是绘制x和y本身，而是我们的假设函数的参数范围和由选择特定参数集所产生的代价"></a>假设我们要画出基于θ0和θ1的假设函数(hypothesis)(实际上我们把代价函数绘制为参数估值函数) 我们不是绘制x和y本身，而是我们的假设函数的参数范围和由选择特定参数集所产生的代价</h5><h5 id="我们把θ0放在x轴上把θ1放在y轴上成本函数放在垂直z轴上-我们的图上的点将是使用具有那些特定θ参数的我们的假设的代价函数的结果-下图描绘了这样的设置"><a href="#我们把θ0放在x轴上，把θ1放在y轴上，成本函数放在垂直z轴上。-我们的图上的点将是使用具有那些特定θ参数的我们的假设的代价函数的结果。-下图描绘了这样的设置" class="headerlink" title="我们把θ0放在x轴上，把θ1放在y轴上，成本函数放在垂直z轴上。 我们的图上的点将是使用具有那些特定θ参数的我们的假设的代价函数的结果。 下图描绘了这样的设置"></a>我们把θ0放在x轴上，把θ1放在y轴上，成本函数放在垂直z轴上。 我们的图上的点将是使用具有那些特定θ参数的我们的假设的代价函数的结果。 下图描绘了这样的设置</h5><p><img src="/2017/03/09/Andrew-Ng-s-机器学习day-three/1.png" alt="1"></p>
<h5 id="我们知道当我们的成本函数在图中的凹坑的最底部时即当它的值是最小值时我们已经成功-红色箭头显示图中的最小点"><a href="#我们知道，当我们的成本函数在图中的凹坑的最底部时，即当它的值是最小值时，我们已经成功。红色箭头显示图中的最小点。" class="headerlink" title="我们知道，当我们的成本函数在图中的凹坑的最底部时，即当它的值是最小值时，我们已经成功。红色箭头显示图中的最小点。"></a>我们知道，当我们的成本函数在图中的凹坑的最底部时，即当它的值是最小值时，我们已经成功。红色箭头显示图中的最小点。</h5><h5 id="我们这样做的方式是通过我们的代价函数的导数一个函数的切线-切线的斜率是在该点的导数它将给我们移动的方向-我们在具有最陡下降的方向上逐步降低代价函数-每个步骤的大小由参数α确定其被称为学习速率"><a href="#我们这样做的方式是通过我们的代价函数的导数（一个函数的切线）。切线的斜率是在该点的导数，它将给我们移动的方向。我们在具有最陡下降的方向上逐步降低代价函数。每个步骤的大小由参数α确定，其被称为学习速率。" class="headerlink" title="我们这样做的方式是通过我们的代价函数的导数（一个函数的切线）。切线的斜率是在该点的导数，它将给我们移动的方向。我们在具有最陡下降的方向上逐步降低代价函数。每个步骤的大小由参数α确定，其被称为学习速率。"></a>我们这样做的方式是通过我们的代价函数的导数（一个函数的切线）。切线的斜率是在该点的导数，它将给我们移动的方向。我们在具有最陡下降的方向上逐步降低代价函数。每个步骤的大小由参数α确定，其被称为学习速率。</h5><h5 id="例如上图中每个星之间的距离表示由我们的参数α确定的步长-较小的α将导致较小的阶跃较大的α导致较大的阶跃-步进的方向由jθ0θ1的偏导数确定-根据图表上的起始位置可以在不同的点结束-上图显示了两个不同的起点分别位于两个不同的地方"><a href="#例如，上图中每个“星”之间的距离表示由我们的参数α确定的步长。较小的α将导致较小的阶跃，较大的α导致较大的阶跃。步进的方向由J（θ0，θ1）的偏导数确定。根据图表上的起始位置，可以在不同的点结束。上图显示了两个不同的起点，分别位于两个不同的地方。" class="headerlink" title="例如，上图中每个“星”之间的距离表示由我们的参数α确定的步长。较小的α将导致较小的阶跃，较大的α导致较大的阶跃。步进的方向由J（θ0，θ1）的偏导数确定。根据图表上的起始位置，可以在不同的点结束。上图显示了两个不同的起点，分别位于两个不同的地方。"></a>例如，上图中每个“星”之间的距离表示由我们的参数α确定的步长。较小的α将导致较小的阶跃，较大的α导致较大的阶跃。步进的方向由J（θ0，θ1）的偏导数确定。根据图表上的起始位置，可以在不同的点结束。上图显示了两个不同的起点，分别位于两个不同的地方。</h5><h5 id="梯度下降算法是"><a href="#梯度下降算法是：" class="headerlink" title="梯度下降算法是："></a>梯度下降算法是：</h5><h5 id="重复直到收敛"><a href="#重复直到收敛：" class="headerlink" title="重复直到收敛："></a>重复直到收敛：</h5><h5 id="θj-θj-α-θj-jθ0θ1"><a href="#θj-θj-−-α-∂-∂θj-J-θ0-θ1" class="headerlink" title="θj:= θj − α ∂/∂θj J(θ0,θ1)"></a>θj:= θj − α ∂/∂θj J(θ0,θ1)</h5><h5 id="j-01表示特征索引号"><a href="#j-0-1表示特征索引号。" class="headerlink" title="j = 0,1表示特征索引号。"></a>j = 0,1表示特征索引号。</h5><h5 id="在每次迭代j时应该同时更新参数θ1θ2θn-在第j次迭代计算另一个参数之前更新特定参数将导致错误的实现"><a href="#在每次迭代j时，应该同时更新参数θ1，θ2，…，θn。-在第j次迭代计算另一个参数之前更新特定参数将导致错误的实现" class="headerlink" title="在每次迭代j时，应该同时更新参数θ1，θ2，…，θn。 在第j次迭代计算另一个参数之前更新特定参数将导致错误的实现"></a>在每次迭代j时，应该同时更新参数θ1，θ2，…，θn。 在第j次迭代计算另一个参数之前更新特定参数将导致错误的实现</h5><p><img src="/2017/03/09/Andrew-Ng-s-机器学习day-three/2.png" alt="2"></p>
<h4 id="2gradient-descent-intuition"><a href="#2-Gradient-Descent-Intuition" class="headerlink" title="2.Gradient Descent Intuition"></a>2.Gradient Descent Intuition</h4><h5 id="在这个视频中我们探索了一个场景其中我们使用一个参数θ1并绘制其代价函数来实现梯度下降-我们对单个参数的公式是"><a href="#在这个视频中，我们探索了一个场景，其中我们使用一个参数θ1，并绘制其代价函数来实现梯度下降。-我们对单个参数的公式是：" class="headerlink" title="在这个视频中，我们探索了一个场景，其中我们使用一个参数θ1，并绘制其代价函数来实现梯度下降。 我们对单个参数的公式是："></a>在这个视频中，我们探索了一个场景，其中我们使用一个参数θ1，并绘制其代价函数来实现梯度下降。 我们对单个参数的公式是：</h5><h5 id="重复直到收敛θ1θ1-α-ddθ1-jθ1"><a href="#重复直到收敛：θ1：-θ1-α-d-dθ1-J-θ1）" class="headerlink" title="重复直到收敛：θ1：=θ1 - α d/dθ1 J(θ1）"></a>重复直到收敛：θ1：=θ1 - α d/dθ1 J(θ1）</h5><h5 id="无论ddθ1-jθ1的斜率符号如何θ1最终收敛到其最小值-下图表示当斜率为负时θ1的值增加而当其为正时θ1的值减小"><a href="#无论d-dθ1-J-θ1）的斜率符号如何，θ1最终收敛到其最小值。-下图表示当斜率为负时，θ1的值增加，而当其为正时，θ1的值减小。" class="headerlink" title="无论d/dθ1 J(θ1）的斜率符号如何，θ1最终收敛到其最小值。 下图表示当斜率为负时，θ1的值增加，而当其为正时，θ1的值减小。"></a>无论d/dθ1 J(θ1）的斜率符号如何，θ1最终收敛到其最小值。 下图表示当斜率为负时，θ1的值增加，而当其为正时，θ1的值减小。</h5><p><img src="/2017/03/09/Andrew-Ng-s-机器学习day-three/3.png" alt="3"></p>
<h5 id="另一方面我们应该调整参数α以确保梯度下降算法在合理的时间内收敛-不收敛或太多的时间来获得最小值意味着我们的步长是错误的"><a href="#另一方面，我们应该调整参数α，以确保梯度下降算法在合理的时间内收敛。-不收敛或太多的时间来获得最小值意味着我们的步长是错误的。" class="headerlink" title="另一方面，我们应该调整参数α，以确保梯度下降算法在合理的时间内收敛。 不收敛或太多的时间来获得最小值意味着我们的步长是错误的。"></a>另一方面，我们应该调整参数α，以确保梯度下降算法在合理的时间内收敛。 不收敛或太多的时间来获得最小值意味着我们的步长是错误的。</h5><p><img src="/2017/03/09/Andrew-Ng-s-机器学习day-three/4.png" alt="4"></p>
<h5 id="梯度下降如何以固定步长α收敛"><a href="#梯度下降如何以固定步长α收敛？" class="headerlink" title="梯度下降如何以固定步长α收敛？"></a>梯度下降如何以固定步长α收敛？</h5><h5 id="收敛后面的直觉是当我们接近我们的凸函数的底部时ddθ1-jθ1接近0-至少导数将始终为0因此我们得到"><a href="#收敛后面的直觉是当我们接近我们的凸函数的底部时，d-dθ1-J-θ1）接近0。-至少，导数将始终为0，因此我们得到" class="headerlink" title="收敛后面的直觉是当我们接近我们的凸函数的底部时，d/dθ1 J(θ1）接近0。 至少，导数将始终为0，因此我们得到:"></a>收敛后面的直觉是当我们接近我们的凸函数的底部时，d/dθ1 J(θ1）接近0。 至少，导数将始终为0，因此我们得到:</h5><h5 id="θ1θ1α0"><a href="#θ1-θ1−α∗0" class="headerlink" title="θ1:=θ1−α∗0"></a><code>θ1:=θ1−α∗0</code></h5><p><img src="/2017/03/09/Andrew-Ng-s-机器学习day-three/5.png" alt="5"></p>
<h4 id="gradient-descent-for-linear-regression"><a href="#Gradient-Descent-For-Linear-Regression" class="headerlink" title="Gradient Descent For Linear Regression"></a>Gradient Descent For Linear Regression</h4><h5 id="note-at-615-hx-900-01x-should-be-hx-900-01x"><a href="#Note-At-6-15-“h-x-900-0-1x”-should-be-“h-x-900-0-1x”" class="headerlink" title="Note: [At 6:15 “h(x) = -900 - 0.1x” should be “h(x) = 900 - 0.1x”]"></a>Note: [At 6:15 “h(x) = -900 - 0.1x” should be “h(x) = 900 - 0.1x”]</h5><h5 id="当具体应用于线性回归的情况下可以导出梯度下降方程的新形式-我们可以替换我们的实际代价函数和我们的实际假设函数并将公式修改为"><a href="#当具体应用于线性回归的情况下，可以导出梯度下降方程的新形式。我们可以替换我们的实际代价函数和我们的实际假设函数，并将公式修改为：" class="headerlink" title="当具体应用于线性回归的情况下，可以导出梯度下降方程的新形式。我们可以替换我们的实际代价函数和我们的实际假设函数，并将公式修改为："></a>当具体应用于线性回归的情况下，可以导出梯度下降方程的新形式。我们可以替换我们的实际代价函数和我们的实际假设函数，并将公式修改为：</h5><p><img src="/2017/03/09/Andrew-Ng-s-机器学习day-three/6.png" alt="6"></p>
<h5 id="其中m是训练集的大小θ0是将与θ1同时改变的常数xiyi是给定训练集数据的值"><a href="#其中m是训练集的大小，θ0是将与θ1同时改变的常数，xi，yi是给定训练集（数据）的值" class="headerlink" title="其中m是训练集的大小，θ0是将与θ1同时改变的常数，xi，yi是给定训练集（数据）的值"></a>其中m是训练集的大小，θ0是将与θ1同时改变的常数，xi，yi是给定训练集（数据）的值</h5><h5 id="注意我们已经将θj的两种情况分离为θ0和θ1的单独方程并且对于θ1由于导数我们在末端乘以xi-以下是单个示例的θj-jθ的推导"><a href="#注意，我们已经将θj的两种情况分离为θ0和θ1的单独方程-并且对于θ1，由于导数，我们在末端乘以xi。以下是单个示例的∂-∂θj-J-θ）的推导：" class="headerlink" title="注意，我们已经将θj的两种情况分离为θ0和θ1的单独方程;并且对于θ1，由于导数，我们在末端乘以xi。以下是单个示例的∂/∂θj J(θ）的推导："></a>注意，我们已经将θj的两种情况分离为θ0和θ1的单独方程;并且对于θ1，由于导数，我们在末端乘以xi。以下是单个示例的∂/∂θj J(θ）的推导：</h5><p><img src="/2017/03/09/Andrew-Ng-s-机器学习day-three/7.png" alt="7"></p>
<h5 id="所有这一切的点是如果我们开始猜测我们的假设然后重复应用这些梯度下降方程我们的假设将变得越来越准确"><a href="#所有这一切的点是，如果我们开始猜测我们的假设，然后重复应用这些梯度下降方程，我们的假设将变得越来越准确。" class="headerlink" title="所有这一切的点是，如果我们开始猜测我们的假设，然后重复应用这些梯度下降方程，我们的假设将变得越来越准确。"></a>所有这一切的点是，如果我们开始猜测我们的假设，然后重复应用这些梯度下降方程，我们的假设将变得越来越准确。</h5><h5 id="因此这是对原始成本函数j的简单梯度下降-该方法查看每个步骤的整个训练集中的每个示例并且称为批量梯度下降-注意虽然梯度下降一般易受局部最小值的影响我们在这里提出的用于线性回归的优化问题只有一个全局的没有其他局部的最优的因此梯度下降总是收敛假设学习速率α不太大到全局最小值-实际上j是凸二次函数-这里是梯度下降的例子因为它运行以最小化二次函数"><a href="#因此，这是对原始成本函数J的简单梯度下降。该方法查看每个步骤的整个训练集中的每个示例，并且称为批量梯度下降。注意，虽然梯度下降一般易受局部最小值的影响，我们在这里提出的用于线性回归的优化问题只有一个全局的，没有其他局部的最优的-因此梯度下降总是收敛（假设学习速率α不太大）到全局最小值。实际上，J是凸二次函数。这里是梯度下降的例子，因为它运行以最小化二次函数。" class="headerlink" title="因此，这是对原始成本函数J的简单梯度下降。该方法查看每个步骤的整个训练集中的每个示例，并且称为批量梯度下降。注意，虽然梯度下降一般易受局部最小值的影响，我们在这里提出的用于线性回归的优化问题只有一个全局的，没有其他局部的最优的;因此梯度下降总是收敛（假设学习速率α不太大）到全局最小值。实际上，J是凸二次函数。这里是梯度下降的例子，因为它运行以最小化二次函数。"></a>因此，这是对原始成本函数J的简单梯度下降。该方法查看每个步骤的整个训练集中的每个示例，并且称为批量梯度下降。注意，虽然梯度下降一般易受局部最小值的影响，我们在这里提出的用于线性回归的优化问题只有一个全局的，没有其他局部的最优的;因此梯度下降总是收敛（假设学习速率α不太大）到全局最小值。实际上，J是凸二次函数。这里是梯度下降的例子，因为它运行以最小化二次函数。</h5><p><img src="/2017/03/09/Andrew-Ng-s-机器学习day-three/8.png" alt="8"></p>
<h5 id="上面显示的椭圆是二次函数的轮廓-还示出了由梯度下降采取的轨迹其在4830处被初始化-图中的x用直线连接标记了梯度下降经过的连续值因为它收敛到最小值"><a href="#上面显示的椭圆是二次函数的轮廓。还示出了由梯度下降采取的轨迹，其在（48-30）处被初始化。图中的x（用直线连接）标记了梯度下降经过的连续值，因为它收敛到最小值。" class="headerlink" title="上面显示的椭圆是二次函数的轮廓。还示出了由梯度下降采取的轨迹，其在（48,30）处被初始化。图中的x（用直线连接）标记了梯度下降经过的连续值，因为它收敛到最小值。"></a>上面显示的椭圆是二次函数的轮廓。还示出了由梯度下降采取的轨迹，其在（48,30）处被初始化。图中的x（用直线连接）标记了梯度下降经过的连续值，因为它收敛到最小值。</h5>]]></content>
    
    <summary type="html">
    
      &lt;h3 id=&quot;paramater-learning参数学习&quot;&gt;&lt;a href=&quot;#Paramater-Learning-参数学习&quot; class=&quot;headerlink&quot; title=&quot;Paramater Learning(参数学习)&quot;&gt;&lt;/a&gt;Paramater Learnin
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title>Andrew Ng&#39;s 机器学习day one</title>
    <link href="https://blaceman.github.io/2017/03/05/Andrew-Ng-s-%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0day-one/"/>
    <id>https://blaceman.github.io/2017/03/05/Andrew-Ng-s-机器学习day-one/</id>
    <published>2017-03-05T09:11:56.000Z</published>
    <updated>2017-03-05T09:12:46.000Z</updated>
    
    <content type="html"><![CDATA[<h5 id="前言-什么是机器学习-ng老师举了几个例子谷歌网页搜索脸书或苹果的照片程序认出你的朋友电子邮件中过滤垃圾邮件的反垃圾邮件有一种科学能让计算机学习却不需要好高深的程序"><a href="#前言-什么是机器学习-NG老师举了几个例子-谷歌网页搜索-脸书或苹果的照片程序认出你的朋友-电子邮件中过滤垃圾邮件的反垃圾邮件…有一种科学能让计算机学习却不需要好高深的程序" class="headerlink" title="前言: 什么是机器学习? NG老师举了几个例子.谷歌网页搜索,脸书或苹果的照片程序认出你的朋友,电子邮件中过滤垃圾邮件的反垃圾邮件…有一种科学能让计算机学习却不需要好高深的程序"></a>前言: 什么是机器学习? NG老师举了几个例子.谷歌网页搜索,脸书或苹果的照片程序认出你的朋友,电子邮件中过滤垃圾邮件的反垃圾邮件…有一种科学能让计算机学习却不需要好高深的程序</h5><h5 id="机器学习定义-a-computer-program-is-said-to-learn-from-experience-e-with-respect-to-some-class-of-tasks-t-and-performance-measure-p-if-its-performance-at-tasks-in-t-as-measured-by-p-improves-with-experience-e"><a href="#机器学习定义-A-computer-program-is-said-to-learn-from-experience-E-with-respect-to-some-class-of-tasks-T-and-performance-measure-P-if-its-performance-at-tasks-in-T-as-measured-by-P-improves-with-experience-E-”" class="headerlink" title="机器学习定义: A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E.”()"></a>机器学习定义: A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E.”()</h5><p>Example: playing checkers.</p>
<p>E = the experience of playing many games of checkers</p>
<p>T = the task of playing checkers.</p>
<p>P = the probability that the program will win the next game.</p>
<h4 id="机器学习的分类-supervised-learning-and-unsupervised-learning监督学习-无监督学习"><a href="#机器学习的分类-Supervised-learning-and-Unsupervised-learning-监督学习-无监督学习" class="headerlink" title="机器学习的分类: Supervised learning and Unsupervised learning.(监督学习 无监督学习)"></a>机器学习的分类: Supervised learning and Unsupervised learning.(监督学习 无监督学习)</h4><h5 id="监督学习we-are-given-a-data-set-and-already-know-what-our-correct-output-should-look-like-having-the-idea-that-there-is-a-relationship-between-the-input-and-the-output我们已经有了一个数据集并且已经知道正确的输出应该是怎样的得到一个输出与输入的关系"><a href="#监督学习-we-are-given-a-data-set-and-already-know-what-our-correct-output-should-look-like-having-the-idea-that-there-is-a-relationship-between-the-input-and-the-output-我们已经有了一个数据集-并且已经知道正确的输出应该是怎样的-得到一个输出与输入的关系" class="headerlink" title="监督学习:we are given a data set and already know what our correct output should look like, having the idea that there is a relationship between the input and the output.(我们已经有了一个数据集,并且已经知道正确的输出应该是怎样的,得到一个输出与输入的关系)"></a>监督学习:we are given a data set and already know what our correct output should look like, having the idea that there is a relationship between the input and the output.(我们已经有了一个数据集,并且已经知道正确的输出应该是怎样的,得到一个输出与输入的关系)</h5><h5 id="监督学习分为regression回归问题和classification分类问题"><a href="#监督学习分为-Regression-回归问题-和Classification-分类问题" class="headerlink" title="监督学习分为:Regression(回归问题)和Classification(分类问题)"></a>监督学习分为:Regression(回归问题)和Classification(分类问题)</h5><h5 id="回归问题我们试图预测连续输出的结果这意味着我们试图将输入变量映射到一些连续函数"><a href="#回归问题-我们试图预测连续输出的结果，这意味着我们试图将输入变量映射到一些连续函数" class="headerlink" title="回归问题:我们试图预测连续输出的结果，这意味着我们试图将输入变量映射到一些连续函数."></a>回归问题:我们试图预测连续输出的结果，这意味着我们试图将输入变量映射到一些连续函数.</h5><h5 id="分类问题我们试图预测离散输出的结果-换句话说我们试图将输入变量映射到离散类别"><a href="#分类问题-我们试图预测离散输出的结果。换句话说，我们试图将输入变量映射到离散类别。" class="headerlink" title="分类问题:我们试图预测离散输出的结果。换句话说，我们试图将输入变量映射到离散类别。"></a>分类问题:我们试图预测离散输出的结果。换句话说，我们试图将输入变量映射到离散类别。</h5><p>Example 1:</p>
<p>Given data about the size of houses on the real estate market, try to predict their price. Price as a function of size is a continuous output, so this is a regression problem.<br><br> </p>
<p>We could turn this example into a classification problem by instead making our output about whether the house “sells for more or less than the asking price.” Here we are classifying the houses based on price into two discrete categories.<br><br><br>                   </p>
<p>Example 2:</p>
<p>(a) Regression - Given a picture of a person, we have to predict their age on the basis of the given picture(给定一个人的图片，我们必须根据给定的图片预测他们的年龄)<br><br> </p>
<p>(b) Classification - Given a patient with a tumor, we have to predict whether the tumor is malignant or benign(给定患有肿瘤的患者，我们必须预测肿瘤是恶性的还是良性的)</p>
<h5 id="无监督学习-unsupervised-learning-allows-us-to-approach-problems-with-little-or-no-idea-what-our-results-should-look-like-we-can-derive-structure-from-data-where-we-dont-necessarily-know-the-effect-of-the-variables无监督学习允许我们在不知道看起来的结果是什么的前提下可以从不知道变量的影响的数据中导出结构"><a href="#无监督学习-Unsupervised-learning-allows-us-to-approach-problems-with-little-or-no-idea-what-our-results-should-look-like-We-can-derive-structure-from-data-where-we-don’t-necessarily-know-the-effect-of-the-variables-无监督学习允许我们在不知道看起来的结果是什么的前提下-可以从不知道变量的影响的数据中导出结构" class="headerlink" title="无监督学习: Unsupervised learning allows us to approach problems with little or no idea what our results should look like. We can derive structure from data where we don’t necessarily know the effect of the variables.(无监督学习允许我们在不知道看起来的结果是什么的前提下,可以从不知道变量的影响的数据中导出结构)"></a>无监督学习: Unsupervised learning allows us to approach problems with little or no idea what our results should look like. We can derive structure from data where we don’t necessarily know the effect of the variables.(无监督学习允许我们在不知道看起来的结果是什么的前提下,可以从不知道变量的影响的数据中导出结构)</h5><h5 id="我们可以通过基于数据中的变量之间的关系对数据进行聚类clustering来导出此结构"><a href="#我们可以通过基于数据中的变量之间的关系对数据进行聚类-clustering-来导出此结构。" class="headerlink" title="我们可以通过基于数据中的变量之间的关系对数据进行聚类(clustering)来导出此结构。"></a>我们可以通过基于数据中的变量之间的关系对数据进行聚类(clustering)来导出此结构。</h5><h5 id="对于无监督学习没有基于预测结果的反馈"><a href="#对于无监督学习，没有基于预测结果的反馈。" class="headerlink" title="对于无监督学习，没有基于预测结果的反馈。"></a>对于无监督学习，没有基于预测结果的反馈。</h5><p>Example:<br><br></p>
<p>Clustering: Take a collection of 1,000,000 different genes, and find a way to automatically group these genes into groups that are somehow similar or related by different variables, such as lifespan, location, roles, and so on.(获取100万个不同基因的集合，并找到一种方法来自动将这些基因分组到不同变量（如寿命，位置，角色等）中相似或相关的组中) <br></p>
<p>Non-clustering: The “Cocktail Party Algorithm”, allows you to find structure in a chaotic environment. (i.e. identifying individual voices and music from a mesh of sounds at a cocktail party).(“鸡尾酒会算法”，允许你在混乱的环境中找到结构（即，在鸡尾酒会上从声音网中识别单个声音和音乐）)</p>
]]></content>
    
    <summary type="html">
    
      &lt;h5 id=&quot;前言-什么是机器学习-ng老师举了几个例子谷歌网页搜索脸书或苹果的照片程序认出你的朋友电子邮件中过滤垃圾邮件的反垃圾邮件有一种科学能让计算机学习却不需要好高深的程序&quot;&gt;&lt;a href=&quot;#前言-什么是机器学习-NG老师举了几个例子-谷歌网页搜索-脸书或苹果的照片程
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title>Andrew Ng&#39;s 机器学习 day two</title>
    <link href="https://blaceman.github.io/2017/03/02/Andrew-Ng-s-%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0-day-two/"/>
    <id>https://blaceman.github.io/2017/03/02/Andrew-Ng-s-机器学习-day-two/</id>
    <published>2017-03-02T10:10:21.000Z</published>
    <updated>2017-03-03T17:12:36.000Z</updated>
    
    <content type="html"><![CDATA[<h3 id="model-and-cost-function模型与代价函数"><a href="#Model-and-Cost-Function-模型与代价函数" class="headerlink" title="Model and Cost Function(模型与代价函数)"></a>Model and Cost Function(模型与代价函数)</h3><h4 id="1model-representation模型表示"><a href="#1-Model-Representation-模型表示" class="headerlink" title="1.Model Representation(模型表示):"></a>1.Model Representation(模型表示):</h4><p><img src="/2017/03/02/Andrew-Ng-s-机器学习-day-two/3.png" alt="3"></p>
<h5 id="为了建立将来使用的符号我们将使用-xi-来表示输入变量也称为输入特征并且yi表示我们试图预测的输出或目标变量价格-一对x-iy-i称为训练集符号中的上标i仅仅是训练集中的索引并且与求幂无关-我们还将使用x表示输入值的空间y表示输出值的空间"><a href="#为了建立将来使用的符号，我们将使用-x-i-来表示“输入”变量，也称为输入特征，并且y-i）表示我们试图预测的“输出”或目标变量（价格）。一对（x-（i）-，y-（i）-称为训练集，符号中的上标“（i）”仅仅是训练集中的索引，并且与求幂无关。我们还将使用X表示输入值的空间，Y表示输出值的空间" class="headerlink" title="为了建立将来使用的符号，我们将使用 x^(i) 来表示“输入”变量，也称为输入特征，并且y^(i）表示我们试图预测的“输出”或目标变量（价格）。一对（x ^ {（i）}，y ^ {（i）}称为训练集，符号中的上标“（i）”仅仅是训练集中的索引，并且与求幂无关。我们还将使用X表示输入值的空间，Y表示输出值的空间."></a>为了建立将来使用的符号，我们将使用 x^(i) 来表示“输入”变量，也称为输入特征，并且y^(i）表示我们试图预测的“输出”或目标变量（价格）。一对（x ^ {（i）}，y ^ {（i）}称为训练集，符号中的上标“（i）”仅仅是训练集中的索引，并且与求幂无关。我们还将使用X表示输入值的空间，Y表示输出值的空间.</h5><h5 id="为了更正式地描述监督学习问题我们的目标是给定一个训练集学习函数hxy使得hx是对于y的对应值的好预测器-由于历史原因该函数h称为hypothesis假设-从图像上看过程是这样的"><a href="#为了更正式地描述监督学习问题，我们的目标是，给定一个训练集，学习函数h：X→Y，使得h（x）是对于y的对应值的“好”预测器。由于历史原因，该函数h称为hypothesis-假设-。从图像上看，过程是这样的" class="headerlink" title="为了更正式地描述监督学习问题，我们的目标是，给定一个训练集，学习函数h：X→Y，使得h（x）是对于y的对应值的“好”预测器。由于历史原因，该函数h称为hypothesis(假设)。从图像上看，过程是这样的"></a>为了更正式地描述监督学习问题，我们的目标是，给定一个训练集，学习函数h：X→Y，使得h（x）是对于y的对应值的“好”预测器。由于历史原因，该函数h称为hypothesis(假设)。从图像上看，过程是这样的</h5><h5 id="当我们试图预测的目标变量是连续的例如在我们的住房示例中我们将学习问题称为回归问题-当y可以只取少量离散值时例如如果给定居住面积我们想预测住宅是房子还是公寓我们称之为分类问题"><a href="#当我们试图预测的目标变量是连续的，例如在我们的住房示例中，我们将学习问题称为回归问题。当y可以只取少量离散值时（例如，如果给定居住面积，我们想预测住宅是房子还是公寓，我们称之为分类问题）。" class="headerlink" title="当我们试图预测的目标变量是连续的，例如在我们的住房示例中，我们将学习问题称为回归问题。当y可以只取少量离散值时（例如，如果给定居住面积，我们想预测住宅是房子还是公寓，我们称之为分类问题）。"></a>当我们试图预测的目标变量是连续的，例如在我们的住房示例中，我们将学习问题称为回归问题。当y可以只取少量离散值时（例如，如果给定居住面积，我们想预测住宅是房子还是公寓，我们称之为分类问题）。</h5><h5 id="如下图所示其中m为数据集的个数"><a href="#如下图所示-其中m为数据集的个数" class="headerlink" title="如下图所示:(其中m为数据集的个数)"></a>如下图所示:(其中m为数据集的个数)</h5><p><img src="/2017/03/02/Andrew-Ng-s-机器学习-day-two/2.png" alt="2"></p>
<h4 id="2cost-function"><a href="#2-Cost-Function" class="headerlink" title="2.Cost Function"></a>2.Cost Function</h4><p><img src="/2017/03/02/Andrew-Ng-s-机器学习-day-two/4.png" alt="4"></p>
<h4 id="我们有一个训练集-可能就像我在这里绘制的-我们要做的就是-得出θ0-θ1这两个参数的值-来让假设函数表示的直线-尽量地与这些数据点很好的拟合-也许就像这里的这条线一样-那么我们如何得出θ0-θ1的值-来使它很好地拟合数据的呢我们的想法是-我们要选择-能使hx-也就是-输入x时我们预测的值-最接近该样本对应的y值的参数θ0-θ1-所以-在我们的训练集中我们会得到一定数量的样本-我们知道x表示卖出哪所房子-并且知道这所房子的实际价格-所以-我们要尽量选择参数值-使得-在训练集中-给出训练集中的x值-我们能合理准确地预测y的值-让我们给出标准的定义-在线性回归中-我们要解决的是一个最小化问题-所以我要写出关于θ0-θ1的最小化-而且-我希望这个式子极其小-是吧"><a href="#我们有一个训练集-可能就像我在这里绘制的-我们要做的就是-得出θ0-θ1这两个参数的值-来让假设函数表示的直线-尽量地与这些数据点很好的拟合-也许就像这里的这条线一样-那么我们如何得出θ0-θ1的值-来使它很好地拟合数据的呢？我们的想法是-我们要选择-能使h-x-也就是-输入x时我们预测的值-最接近该样本对应的y值的参数θ0-θ1-所以-在我们的训练集中我们会得到一定数量的样本-我们知道x表示卖出哪所房子-并且知道这所房子的实际价格-所以-我们要尽量选择参数值-使得-在训练集中-给出训练集中的x值-我们能合理准确地预测y的值-让我们给出标准的定义-在线性回归中-我们要解决的是一个最小化问题-所以我要写出关于θ0-θ1的最小化-而且-我希望这个式子极其小-是吧" class="headerlink" title="我们有一个训练集 可能就像我在这里绘制的 我们要做的就是 得出θ0 θ1这两个参数的值 来让假设函数表示的直线 尽量地与这些数据点很好的拟合 也许就像这里的这条线一样 那么我们如何得出θ0 θ1的值 来使它很好地拟合数据的呢？我们的想法是 我们要选择 能使h(x) 也就是 输入x时我们预测的值 最接近该样本对应的y值的参数θ0 θ1 所以 在我们的训练集中我们会得到一定数量的样本 我们知道x表示卖出哪所房子 并且知道这所房子的实际价格 所以 我们要尽量选择参数值 使得 在训练集中 给出训练集中的x值 我们能合理准确地预测y的值 让我们给出标准的定义 在线性回归中 我们要解决的是一个最小化问题 所以我要写出关于θ0 θ1的最小化 而且 我希望这个式子极其小 是吧"></a>我们有一个训练集 可能就像我在这里绘制的 我们要做的就是 得出θ0 θ1这两个参数的值 来让假设函数表示的直线 尽量地与这些数据点很好的拟合 也许就像这里的这条线一样 那么我们如何得出θ0 θ1的值 来使它很好地拟合数据的呢？我们的想法是 我们要选择 能使h(x) 也就是 输入x时我们预测的值 最接近该样本对应的y值的参数θ0 θ1 所以 在我们的训练集中我们会得到一定数量的样本 我们知道x表示卖出哪所房子 并且知道这所房子的实际价格 所以 我们要尽量选择参数值 使得 在训练集中 给出训练集中的x值 我们能合理准确地预测y的值 让我们给出标准的定义 在线性回归中 我们要解决的是一个最小化问题 所以我要写出关于θ0 θ1的最小化 而且 我希望这个式子极其小 是吧</h4><p><img src="/2017/03/02/Andrew-Ng-s-机器学习-day-two/7.png" alt="7"></p>
<h5 id="我们可以通过使用代价函数来测量我们的假设函数的准确性-这需要使用来自x的输入和实际输出y的假设的所有结果的平均差实际上是平均的更好的版本"><a href="#我们可以通过使用代价函数来测量我们的假设函数的准确性。-这需要使用来自x的输入和实际输出y的假设的所有结果的平均差（实际上是平均的更好的版本）。" class="headerlink" title="我们可以通过使用代价函数来测量我们的假设函数的准确性。 这需要使用来自x的输入和实际输出y的假设的所有结果的平均差（实际上是平均的更好的版本）。"></a>我们可以通过使用代价函数来测量我们的假设函数的准确性。 这需要使用来自x的输入和实际输出y的假设的所有结果的平均差（实际上是平均的更好的版本）。</h5><h5 id="为了将它分开它是12-其中-x是hθxi-yi的平方的平均值或者是预测值和实际值之间的差"><a href="#为了将它分开，它是1-2-×，其中-x是hθ（xi）-yi的平方的平均值，或者是预测值和实际值之间的差。" class="headerlink" title="为了将它分开，它是1/2 -×，其中-x是hθ（xi）-yi的平方的平均值，或者是预测值和实际值之间的差。"></a>为了将它分开，它是1/2 -×，其中-x是hθ（xi）-yi的平方的平均值，或者是预测值和实际值之间的差。</h5><h5 id="该函数另外称为平方误差函数或均方误差-为了方便计算梯度下降平均值被减半12因为平方函数的导数项将抵消12-下图总结了代价函数的作用"><a href="#该函数另外称为“平方误差函数”或“均方误差”。-为了方便计算梯度下降，平均值被减半（1-2），因为平方函数的导数项将抵消1-2。-下图总结了代价函数的作用：" class="headerlink" title="该函数另外称为“平方误差函数”或“均方误差”。 为了方便计算梯度下降，平均值被减半（1/2），因为平方函数的导数项将抵消1/2。 下图总结了代价函数的作用："></a>该函数另外称为“平方误差函数”或“均方误差”。 为了方便计算梯度下降，平均值被减半（1/2），因为平方函数的导数项将抵消1/2。 下图总结了代价函数的作用：</h5><p><img src="/2017/03/02/Andrew-Ng-s-机器学习-day-two/6.png" alt="6"></p>
<h4 id="3cost-function-intuition-itheta0-为0"><a href="#3-Cost-Function-Intuition-I-theta0-为0" class="headerlink" title="3.Cost Function - Intuition I(theta0 为0)"></a>3.Cost Function - Intuition I(theta0 为0)</h4><h5 id="直观的表示我们将建立xy坐标用一条尽可能通过所有数据集的直线"><a href="#直观的表示-我们将建立-x-y-坐标-用一条尽可能通过所有数据集的直线" class="headerlink" title="直观的表示,我们将建立(x,y)坐标,用一条尽可能通过所有数据集的直线"></a>直观的表示,我们将建立(x,y)坐标,用一条尽可能通过所有数据集的直线</h5><h5 id="我们的目标是获得最好的线-最佳可能的线将是这样的使得散射点与线的平均平方垂直距离将是最小的-理想情况下线应该通过我们训练数据集的所有点-在这种情况下-j-theta_0-theta_1的值将为0以下示例显示了我们的代价函数为0的理想情况"><a href="#我们的目标是获得最好的线。-最佳可能的线将是这样的，使得散射点与线的平均平方垂直距离将是最小的。-理想情况下，线应该通过我们训练数据集的所有点。-在这种情况下，-J（-theta-0，-theta-1）-的值将为0-以下示例显示了我们的代价函数为0的理想情况。" class="headerlink" title="我们的目标是获得最好的线。 最佳可能的线将是这样的，使得散射点与线的平均平方垂直距离将是最小的。 理想情况下，线应该通过我们训练数据集的所有点。 在这种情况下，$$ J（\ theta_0，\ theta_1）$$的值将为0.以下示例显示了我们的代价函数为0的理想情况。"></a>我们的目标是获得最好的线。 最佳可能的线将是这样的，使得散射点与线的平均平方垂直距离将是最小的。 理想情况下，线应该通过我们训练数据集的所有点。 在这种情况下，$$ J（\ theta_0，\ theta_1）$$的值将为0.以下示例显示了我们的代价函数为0的理想情况。</h5><p><img src="/2017/03/02/Andrew-Ng-s-机器学习-day-two/8.png" alt="8"></p>
<h5 id="当-theta_1-1-时我们得到的斜率为1它通过模型中的每个数据点-相反当-theta_1-05-时我们看到从我们的拟合到数据点的垂直距离增加"><a href="#当-theta-1-1-时，我们得到的斜率为1，它通过模型中的每个数据点。-相反，当-theta-1-0-5-时，我们看到从我们的拟合到数据点的垂直距离增加。" class="headerlink" title="当$$ \ theta_1 = 1 $$时，我们得到的斜率为1，它通过模型中的每个数据点。 相反，当$$ \ theta_1 = 0.5 $$时，我们看到从我们的拟合到数据点的垂直距离增加。"></a>当$$ \ theta_1 = 1 $$时，我们得到的斜率为1，它通过模型中的每个数据点。 相反，当$$ \ theta_1 = 0.5 $$时，我们看到从我们的拟合到数据点的垂直距离增加。</h5><p><img src="/2017/03/02/Andrew-Ng-s-机器学习-day-two/9.png" alt="9"></p>
<h5 id="这将我们的代价函数增加到-058-绘制其他几个点可得到以下图表"><a href="#这将我们的代价函数增加到-0-58。-绘制其他几个点可得到以下图表：" class="headerlink" title="这将我们的代价函数增加到 0.58。 绘制其他几个点可得到以下图表："></a>这将我们的代价函数增加到 0.58。 绘制其他几个点可得到以下图表：</h5><p><img src="/2017/03/02/Andrew-Ng-s-机器学习-day-two/10.png" alt="10"></p>
<h4 id="4-cost-function-intuition-iitheta_0-不为0"><a href="#4-Cost-Function-Intuition-II-theta-0-不为0" class="headerlink" title="4. Cost Function - Intuition II(theta_0 不为0)"></a>4. Cost Function - Intuition II(theta_0 不为0)</h4><h5 id="等高线图是包含许多轮廓线的图-两个可变函数的轮廓线在同一线的所有点处具有恒定值-这样的图的示例是下面的一个"><a href="#等高线图是包含许多轮廓线的图。-两个可变函数的轮廓线在同一线的所有点处具有恒定值。-这样的图的示例是下面的一个。" class="headerlink" title="等高线图是包含许多轮廓线的图。 两个可变函数的轮廓线在同一线的所有点处具有恒定值。 这样的图的示例是下面的一个。"></a>等高线图是包含许多轮廓线的图。 两个可变函数的轮廓线在同一线的所有点处具有恒定值。 这样的图的示例是下面的一个。</h5><p><img src="/2017/03/02/Andrew-Ng-s-机器学习-day-two/11.png" alt="11"></p>
<h5 id="任何颜色沿着圆人们将获得都是相同的代价函数值-例如在上面的绿线上找到的三个绿点对于-j-theta_0-theta_1具有相同的值因此它们沿着相同的线找到-当-theta_0-800和-theta_1-015时圆圈x显示左侧图形的成本函数的值-取另一个hx并绘制其等值线图得到以下图表"><a href="#任何颜色沿着“圆”，人们将获得都是相同的代价函数值。-例如，在上面的绿线上找到的三个绿点对于-J（-theta-0，-theta-1）-具有相同的值，因此，它们沿着相同的线找到。-当-theta-0-800和-theta-1-0-15时，圆圈x显示左侧图形的成本函数的值。-取另一个h（x）并绘制其等值线图，得到以下图表：" class="headerlink" title="任何颜色沿着“圆”，人们将获得都是相同的代价函数值。 例如，在上面的绿线上找到的三个绿点对于$$ J（\ theta_0，\ theta_1）$$具有相同的值，因此，它们沿着相同的线找到。 当$$ \ theta_0 $$ = 800和$$ \ theta_1 $$ = -0.15时，圆圈x显示左侧图形的成本函数的值。 取另一个h（x）并绘制其等值线图，得到以下图表："></a>任何颜色沿着“圆”，人们将获得都是相同的代价函数值。 例如，在上面的绿线上找到的三个绿点对于$$ J（\ theta_0，\ theta_1）$$具有相同的值，因此，它们沿着相同的线找到。 当$$ \ theta_0 $$ = 800和$$ \ theta_1 $$ = -0.15时，圆圈x显示左侧图形的成本函数的值。 取另一个h（x）并绘制其等值线图，得到以下图表：</h5><p><img src="/2017/03/02/Andrew-Ng-s-机器学习-day-two/12.png" alt="12"></p>
<h5 id="当-theta_0-360和-theta_1-0时轮廓图中的-j-theta_0-theta_1的值更接近中心从而降低代价函数误差-现在给我们的假设函数稍微正的斜率导致更好的数据拟合"><a href="#当-theta-0-360和-theta-1-0时，轮廓图中的-J（-theta-0，-theta-1）-的值更接近中心，从而降低代价函数误差。-现在给我们的假设函数稍微正的斜率导致更好的数据拟合。" class="headerlink" title="当$$ \ theta_0 $$ = 360和$$ \ theta_1 $$ = 0时，轮廓图中的$$ J（\ theta_0，\ theta_1）$$的值更接近中心，从而降低代价函数误差。 现在给我们的假设函数稍微正的斜率导致更好的数据拟合。"></a>当$$ \ theta_0 $$ = 360和$$ \ theta_1 $$ = 0时，轮廓图中的$$ J（\ theta_0，\ theta_1）$$的值更接近中心，从而降低代价函数误差。 现在给我们的假设函数稍微正的斜率导致更好的数据拟合。</h5><p><img src="/2017/03/02/Andrew-Ng-s-机器学习-day-two/13.png" alt="13"></p>
<h5 id="上面的图表尽可能最小化了代价函数因此-theta_1-和-theta_0-的结果分别趋向于大约012和250-在右边的图形上绘制这些值似乎将我们的点放在最内圈的中心"><a href="#上面的图表尽可能最小化了代价函数，因此，-theta-1-和-theta-0-的结果分别趋向于大约0-12和250。-在右边的图形上绘制这些值似乎将我们的点放在最内圈的中心。" class="headerlink" title="上面的图表尽可能最小化了代价函数，因此，$$ \ theta_1 $$和$$ \ theta_0 $$的结果分别趋向于大约0.12和250。 在右边的图形上绘制这些值似乎将我们的点放在最内圈的中心。"></a>上面的图表尽可能最小化了代价函数，因此，$$ \ theta_1 $$和$$ \ theta_0 $$的结果分别趋向于大约0.12和250。 在右边的图形上绘制这些值似乎将我们的点放在最内圈的中心。</h5>]]></content>
    
    <summary type="html">
    
      &lt;h3 id=&quot;model-and-cost-function模型与代价函数&quot;&gt;&lt;a href=&quot;#Model-and-Cost-Function-模型与代价函数&quot; class=&quot;headerlink&quot; title=&quot;Model and Cost Function(模型与代价函数
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title>runtimr之动态添加属性</title>
    <link href="https://blaceman.github.io/2017/02/09/runtimr%E4%B9%8B%E5%8A%A8%E6%80%81%E6%B7%BB%E5%8A%A0%E5%B1%9E%E6%80%A7/"/>
    <id>https://blaceman.github.io/2017/02/09/runtimr之动态添加属性/</id>
    <published>2017-02-09T07:01:44.000Z</published>
    <updated>2017-02-09T07:12:06.000Z</updated>
    
    <content type="html"><![CDATA[<p>在很多时候,当我们创建类别的时候,想为类别添加属性,但由于苹果不支持直接为类别添加属性,为此我们感到烦恼~</p>
]]></content>
    
    <summary type="html">
    
      &lt;p&gt;在很多时候,当我们创建类别的时候,想为类别添加属性,但由于苹果不支持直接为类别添加属性,为此我们感到烦恼~&lt;/p&gt;

    
    </summary>
    
    
  </entry>
  
  <entry>
    <title>iOS 宏定义那些事情</title>
    <link href="https://blaceman.github.io/2017/01/03/iOS-%E5%AE%8F%E5%AE%9A%E4%B9%89/"/>
    <id>https://blaceman.github.io/2017/01/03/iOS-宏定义/</id>
    <published>2017-01-03T03:49:37.000Z</published>
    <updated>2017-01-06T11:45:56.000Z</updated>
    
    <content type="html"><![CDATA[<h5 id="一直以来用宏定义只用了些基本的东西例如常量定义最多也就是定义一个函数很少关注宏定义高级的用法今天就说一下摸索一下高级用法~"><a href="#一直以来用宏定义只用了些基本的东西-例如常量定义-最多也就是定义一个函数-很少关注宏定义高级的用法-今天就说一下摸索一下高级用法" class="headerlink" title="一直以来用宏定义只用了些基本的东西,例如常量定义,最多也就是定义一个函数,很少关注宏定义高级的用法,今天就说一下摸索一下高级用法~"></a>一直以来用宏定义只用了些基本的东西,例如常量定义,最多也就是定义一个函数,很少关注宏定义高级的用法,今天就说一下摸索一下高级用法~</h5><h3 id="这篇文章主要说"><a href="#这篇文章主要说" class="headerlink" title="这篇文章主要说"></a>这篇文章主要说</h3><ul>
<li>宏定义的基本用法</li>
<li>高级用法</li>
<li>常用的宏定义</li>
</ul>
<p>C中的宏分为两类，对象宏(object-like macro)和函数宏(function-like macro)。</p>
<h3 id="宏定义的基本用法"><a href="#宏定义的基本用法" class="headerlink" title="宏定义的基本用法"></a>宏定义的基本用法</h3><h5 id="1定义一个圆周率对象宏"><a href="#1-定义一个圆周率-对象宏" class="headerlink" title="1.定义一个圆周率(对象宏)"></a>1.定义一个圆周率(对象宏)</h5><pre><code>//This defines PI
#define M_PI    3.14159265358979323846264338327950288
</code></pre><h5 id="2定义一个平方函数函数宏"><a href="#2-定义一个平方函数-函数宏" class="headerlink" title="2.定义一个平方函数(函数宏)"></a>2.定义一个平方函数(函数宏)</h5><pre><code>#define SQUARE(A) ((A) * (A))
</code></pre><p>其实这并不是正确的写法,正确的写法应该使用GUN C 扩展来避免参数带运算符所带来的错误等</p>
<pre><code>#define SQUARE(A) ({ __typeof__(A) __a = (A); __a * __a;})
</code></pre><h3 id="高级用法"><a href="#高级用法" class="headerlink" title="高级用法"></a>高级用法</h3><h5 id="1首先看看系统minab"><a href="#1-首先看看系统MIN-A-B" class="headerlink" title="1.首先看看系统MIN(A,B)"></a>1.首先看看系统<code>MIN(A,B)</code></h5><pre><code>#define __NSX_PASTE__(A,B) A##B
#if !defined(MIN)
    #define __NSMIN_IMPL__(A,B,L) ({ __typeof__(A) __NSX_PASTE__(__a,L) = (A); __typeof__(B) __NSX_PASTE__(__b,L) = (B); (__NSX_PASTE__(__a,L) &lt; __NSX_PASTE__(__b,L)) ? __NSX_PASTE__(__a,L) : __NSX_PASTE__(__b,L); })
    #define MIN(A,B) __NSMIN_IMPL__(A,B,__COUNTER__)
#endif
</code></pre><p>这<code>MIN(A,B)</code>分为三部分,第一部分是<code>#define __NSX_PASTE__(A,B) A##B</code>,##的意思是将A和B连接起来的意思,而第二部分是带三个参数<code>#define __NSMIN_IMPL__(A,B,L)</code>参数A,B自然是输入参数,而L则是<code>__NSX_PASTE__(__a,L)</code>定义的连接<code>__a</code>和<code>L</code>的参数名,再看第三部分<code>#define MIN(A,B) __NSMIN_IMPL__(A,B,__COUNTER__)</code>,<code>__COUNTER__</code>是一个预定义的宏，这个值在编译过程中将从0开始计数，每次被调用时加1。明显这是保证构造独立的变量名称,大大避免了变量名相同而导致问题的可能性。<br><br>我们把上诉自己定义的<code>SQUARE(A)</code>变成最接近系统那样的写法</p>
<pre><code>#define __SQUARE_IMPL__(A,L) ({ __typeof__(A) __NSX_PASTE__(__a,L) = (A); __NSX_PASTE__(__a,L) * __NSX_PASTE__(__a,L);})
#define SQUARE(A) __square_IMPL__(A,__COUNTER__)
</code></pre><h5 id="2使用-宏定义macros-__vaargs"><a href="#2-使用-宏定义macros-（-，-，…，-VAARGS" class="headerlink" title="2.使用 宏定义macros （#，##，…，__VAARGS)"></a>2.使用 宏定义macros （#，##，…，__VA<em>ARGS</em>)</h5><ul>
<li>使用”#“预处理操作符来实现将宏中的参数转化为字符串</li>
</ul>
<pre><code>#define WARN_IF(EXP) \  
do { if (EXP) \  
        fprintf (stderr, &quot;Warning: &quot; #EXP &quot;\n&quot;); } \  
while (0)  
WARN_IF (x == 0);  
     ==&gt; do { if (x == 0)  
           fprintf (stderr, &quot;Warning: &quot; &quot;x == 0&quot; &quot;\n&quot;); } while (0);
</code></pre><ul>
<li>使用”##”操作符可以实现宏中token的连接。 刚才也用过</li>
</ul>
<pre><code>#define __NSX_PASTE__(A,B) A##B
</code></pre><ul>
<li>多参数宏（Variadic Macros)</li>
</ul>
<pre><code>#define eprintf(...) fprintf (stderr, __VA_ARGS__)  
eprintf (&quot;%s:%d: &quot;, input_file, lineno)  
     ==&gt;  fprintf (stderr, &quot;%s:%d: &quot;, input_file, lineno)
</code></pre><p>使用标识符__VA<em>ARGS</em>来表示多个参数，在宏的名称中则使用(…)</p>
<ul>
<li>“##”的特殊用法：</li>
</ul>
<pre><code>#define eprintf(format, ...) fprintf (stderr, format, ##__VA_ARGS__)  
eprintf (&quot;success!\n&quot;)  
     ==&gt; fprintf(stderr, &quot;success!\n&quot;);
</code></pre><p>将”##”放在”,”和参数之间，那么如果参数留空的话，那么”##”前面的”,”就会删掉，从而防止编译错误。</p>
<ul>
<li>例如:log 重定义</li>
</ul>
<pre><code>//Another wrong version of NSLog
#define NSLog(format, ...)   {
                               fprintf(stderr, &quot;&lt;%s : %d&gt; %s\n&quot;,                                           \
                               [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String],  \
                               __LINE__, __func__);                                                        \
                               (NSLog)((format), ##__VA_ARGS__);                                           \
                               fprintf(stderr, &quot;-------\n&quot;);                                               \
                             }
</code></pre><p>这里用到了三个预定义宏，和刚才的<code>__COUNTER__</code>类似，预定义宏的行为是由编译器指定的。<code>__FILE__</code>返回当前文件的绝对路径，<code>__LINE__</code>返回展开该宏时在文件中的行数，<code>__func__</code>是改宏所在scope的函数名称。我们在做Log输出时如果带上这这三个参数，便可以加快解读Log，迅速定位</p>
<h3 id="常用的宏定义"><a href="#常用的宏定义" class="headerlink" title="常用的宏定义"></a>常用的宏定义</h3><h5 id="输出rectsize和point的宏"><a href="#输出rect，size和point的宏" class="headerlink" title="输出rect，size和point的宏"></a>输出rect，size和point的宏</h5><pre><code>#define NSLogRect(rect) NSLog(@&quot;%s x:%.4f, y:%.4f, w:%.4f, h:%.4f&quot;, #rect, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)
#define NSLogSize(size) NSLog(@&quot;%s w:%.4f, h:%.4f&quot;, #size, size.width, size.height)
#define NSLogPoint(point) NSLog(@&quot;%s x:%.4f, y:%.4f&quot;, #point, point.x, point.y)
</code></pre><h5 id="获取屏幕-宽度-高度"><a href="#获取屏幕-宽度、高度" class="headerlink" title="获取屏幕 宽度、高度"></a>获取屏幕 宽度、高度</h5><pre><code>#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREENH_HEIGHT ([UIScreen mainScreen].bounds.size.height)
</code></pre><h5 id="系统版本"><a href="#系统版本" class="headerlink" title="系统版本"></a>系统版本</h5><pre><code>#define IOS10_OR_LATER        ( [[[UIDevice currentDevice] systemVersion] floatValue] &gt;= 10.0 )
#define IOS9_OR_LATER        ( [[[UIDevice currentDevice] systemVersion] floatValue] &gt;= 9.0  )
#define IOS8_OR_LATER        ( [[[UIDevice currentDevice] systemVersion] floatValue] &gt;= 8.0 )
</code></pre><h5 id="尺寸"><a href="#尺寸" class="headerlink" title="尺寸"></a>尺寸</h5><pre><code>#define IS_SCREEN_55_INCH    ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#define IS_SCREEN_47_INCH    ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#define IS_SCREEN_4_INCH    ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define IS_SCREEN_35_INCH    ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
</code></pre><h5 id="颜色"><a href="#颜色" class="headerlink" title="颜色"></a>颜色</h5><pre><code>//带有RGBA的颜色设置
#define COLOR(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
#define RandomColor [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]
</code></pre><h5 id="强弱引用"><a href="#强弱引用" class="headerlink" title="强弱引用"></a>强弱引用</h5><pre><code>#define LRWeakSelf(type)  __weak typeof(type) weak##type = type;
#define LRStrongSelf(type)  __strong typeof(type) type = weak##type;
</code></pre><h5 id="圆角边框"><a href="#圆角边框" class="headerlink" title="圆角边框"></a>圆角边框</h5><pre><code>#define LRViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]
</code></pre><h5 id="模拟器真机"><a href="#模拟器真机" class="headerlink" title="模拟器真机"></a>模拟器真机</h5><pre><code>// 判断是不是iOS系统，如果是iOS系统在真机和模拟器输出都是YES
#if TARGET_OS_IPHONE  
#endif  

#if (TARGET_IPHONE_SIMULATOR)    
          // 在模拟器的情况下
#else
         // 在真机情况下
#endif
</code></pre><h5 id="沙河目录"><a href="#沙河目录" class="headerlink" title="沙河目录"></a>沙河目录</h5><pre><code>//获取temp
#define kPathTemp NSTemporaryDirectory() 

//获取沙盒 Document
#define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] 

//获取沙盒 Cache
#define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
</code></pre><p>主要参考链接:<a href="https://onevcat.com/2014/01/black-magic-in-macro/">宏定义的黑魔法</a>, <a href="http://blog.csdn.net/songrotek/article/details/8929963">iOS开发 高级：使用 宏定义macros （#，##，…，__VA<em>ARGS</em>)</a></p>
]]></content>
    
    <summary type="html">
    
      &lt;h5 id=&quot;一直以来用宏定义只用了些基本的东西例如常量定义最多也就是定义一个函数很少关注宏定义高级的用法今天就说一下摸索一下高级用法~&quot;&gt;&lt;a href=&quot;#一直以来用宏定义只用了些基本的东西-例如常量定义-最多也就是定义一个函数-很少关注宏定义高级的用法-今天就说一下摸索一
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title>wifi密码破解</title>
    <link href="https://blaceman.github.io/2016/12/29/wifi%E5%AF%86%E7%A0%81%E7%A0%B4%E8%A7%A3/"/>
    <id>https://blaceman.github.io/2016/12/29/wifi密码破解/</id>
    <published>2016-12-29T05:54:23.000Z</published>
    <updated>2017-01-05T10:52:54.000Z</updated>
    
    <content type="html"><![CDATA[<p>那天回了老家,没有网络,真是回归自然~今天就来说说mac电脑如何如何破解wifi~让没有网络的你,可以偷别人家的wifi,想想就激动~</p>
<h5 id="首先来首歌"><a href="#首先来首歌" class="headerlink" title="首先来首歌"></a>首先来首歌</h5><iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="330" height="86" src="https://music.163.com/outchain/player?type=2&id=116352&auto=1&height=66"></iframe>


<h3 id="文章说了以下几个方面"><a href="#文章说了以下几个方面" class="headerlink" title="文章说了以下几个方面"></a>文章说了以下几个方面</h3><ul>
<li>安装aircrack</li>
<li>利用aircrack 进行wifi抓包</li>
<li>配合字典开始wifi破解</li>
</ul>
<h3 id="安装aircrack"><a href="#安装aircrack" class="headerlink" title="安装aircrack"></a>安装aircrack</h3><h5 id="1首先安装homebrew"><a href="#1-首先安装homebrew" class="headerlink" title="1.首先安装homebrew"></a>1.首先安装homebrew</h5><pre><code>/usr/bin/ruby -e &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&quot;
</code></pre><h5 id="2用homebrew安装aircrack"><a href="#2-用homebrew安装aircrack" class="headerlink" title="2.用homebrew安装aircrack"></a>2.用homebrew安装aircrack</h5><pre><code>brew install aircrack-ng
</code></pre><h3 id="利用aircrack-进行wifi抓包"><a href="#利用aircrack-进行wifi抓包" class="headerlink" title="利用aircrack 进行wifi抓包"></a>利用aircrack 进行wifi抓包</h3><h5 id="1airport-监测到的附近-wifi-信息"><a href="#1-airport-监测到的附近-wifi-信息" class="headerlink" title="1.airport 监测到的附近 wifi 信息"></a>1.airport 监测到的附近 wifi 信息</h5><pre><code>airport -s
</code></pre><p>然后就能看到一下的信息</p>
<p><img src="/2016/12/29/wifi密码破解/1.png" alt="wifi"></p>
<p>SSID 是 wifi名称，RSSI 是信号强度，CHANNEL 是信道。</p>
<h5 id="2接着挑一个信号强的进行抓包"><a href="#2-接着挑一个信号强的进行抓包" class="headerlink" title="2.接着挑一个信号强的进行抓包"></a>2.接着挑一个信号强的进行抓包</h5><pre><code>sudo airport en1 sniff  1
</code></pre><p>其中en1是电脑的网卡,大部分就是en1 或en0,等待几分钟~</p>
<h5 id="3接着前往tmp文件夹查看生成后缀为cap的包然后再桌面新建一个文件夹假设我新建的文件夹名字为wifi把抓到的后缀cap的问价放进文件夹里面重新命名为01cap"><a href="#3-接着前往-tmp文件夹查看生成后缀为-cap的包-然后再桌面新建一个文件夹-假设我新建的文件夹名字为wifi-把抓到的后缀-cap的问价放进文件夹里面-重新命名为01-cap" class="headerlink" title="3.接着前往/tmp文件夹查看生成后缀为.cap的包,然后再桌面新建一个文件夹(假设我新建的文件夹名字为wifi),把抓到的后缀.cap的问价放进文件夹里面,重新命名为01.cap."></a>3.接着前往<code>/tmp</code>文件夹查看生成后缀为.cap的包,然后再桌面新建一个文件夹(假设我新建的文件夹名字为wifi),把抓到的后缀.cap的问价放进文件夹里面,重新命名为01.cap.</h5><h3 id="配合字典开始wifi破解"><a href="#配合字典开始wifi破解" class="headerlink" title="配合字典开始wifi破解"></a>配合字典开始wifi破解</h3><h5 id="1谷歌百度找到密码字典"><a href="#1-谷歌-百度-找到密码字典" class="headerlink" title="1.谷歌(百度)找到密码字典"></a>1.谷歌(百度)找到密码字典</h5><h5 id="2把字典也放进上述所创建的wifi文件夹中重命名为01text"><a href="#2-把字典也放进上述所创建的wifi文件夹中-重命名为01-text" class="headerlink" title="2.把字典也放进上述所创建的wifi文件夹中,重命名为01.text"></a>2.把字典也放进上述所创建的wifi文件夹中,重命名为01.text</h5><h5 id="3终端cd-到这个文件夹里然后查看wifi抓包情况"><a href="#3-终端cd-到这个文件夹里-然后查看wifi抓包情况" class="headerlink" title="3.终端cd 到这个文件夹里,然后查看wifi抓包情况"></a>3.终端cd 到这个文件夹里,然后查看wifi抓包情况</h5><pre><code>cd ~/Desktop/wifi
aircrack-ng -w 01.txt 01.cap
</code></pre><p><img src="/2016/12/29/wifi密码破解/4.png" alt="4"></p>
<p>其中,Encryption中（0 handshake）是抓包失败，（1 handshake）则是抓包成功。看到第几行抓包成功，则在「Index number of target network ?」后敲回车：第几行 例如(11) <br><br>如果cap文件内全是（0 handshake），就按 command + c 组合键退出。重新回到「sudo airport en1 sniff 1」这步进行监听抓包。抓包成功率受到 wifi 信号强弱、电脑与路由器距离远近、路由器是否正处在收发数据状态的影响。总之多试几次、监听时间适当延长些，可以大大提高成功率。<br><br>如果可以的话,会进入</p>
<p><img src="/2016/12/29/wifi密码破解/2.png" alt="2"></p>
<p>接下来等待破解结果就行了，中断破解过程可以直接按 command + c 组合键退出。破解过程所需时间长短受电脑硬件配置、字典体积大小的影响。如果01.txt字典破解失败，则可以换其它字典进行破解，直到破解成功。<br>使用一个好的字典是很重要的，一个9位的纯数字字典大概1G多，结果经过几个小时的破解，如果密码是987654321就很令人郁闷了，所以最好准备几个常用的wifi密码字典，可以大大提高成功率和节省时间。常用字典可以直接百度Google搜索下载。<br><br>如果成功了就会出现</p>
<p><img src="/2016/12/29/wifi密码破解/3.jpg" alt="3"></p>
<p>然而我却一直卡在抓包那里,一直没成功过,心塞~</p>
<p>主要参考是<a href="http://chaishiwei.com/blog/562.html">这里</a></p>
]]></content>
    
    <summary type="html">
    
      &lt;p&gt;那天回了老家,没有网络,真是回归自然~今天就来说说mac电脑如何如何破解wifi~让没有网络的你,可以偷别人家的wifi,想想就激动~&lt;/p&gt;
&lt;h5 id=&quot;首先来首歌&quot;&gt;&lt;a href=&quot;#首先来首歌&quot; class=&quot;headerlink&quot; title=&quot;首先来首歌&quot;&gt;
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title>说说Object-C Runtime</title>
    <link href="https://blaceman.github.io/2016/12/15/%E8%AF%B4%E8%AF%B4Object-C-Runtime/"/>
    <id>https://blaceman.github.io/2016/12/15/说说Object-C-Runtime/</id>
    <published>2016-12-15T04:49:58.000Z</published>
    <updated>2017-01-06T04:33:05.000Z</updated>
    
    <content type="html"><![CDATA[<h5 id="今天照着文档来说说runtime看到一半看不下去了怪自己英文不好先写下来慢慢理解然后在看下半部分~"><a href="#今天照着文档来说说runtime-看到一半看不下去了-怪自己英文不好-…先写下来慢慢理解-然后在看下半部分" class="headerlink" title="今天照着文档来说说runtime,看到一半看不下去了(怪自己英文不好)…先写下来慢慢理解,然后在看下半部分~"></a>今天照着文档来说说runtime,看到一半看不下去了(怪自己英文不好)…先写下来慢慢理解,然后在看下半部分~</h5><p>首先还是来首歌</p>
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="330" height="86" src="https://music.163.com/outchain/player?type=2&id= 234252&auto=1&height=66"></iframe>

<p>还是建议大家看<a href="https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008048-CH1-SW1">官方文档</a></p>
<p>不想看文档的朋友,推荐一篇比较好的<a href="http://yulingtianxia.com/blog/2014/11/05/objective-c-runtime/">博客</a></p>
<h3 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h3><p>Object-C 语言延迟了许多从编译链接到运行时的许多决策,尽可能让这门语言动态化.这就意味着这门语言仅需要编译器是不够的,还需要运行系统来执行编译代码.运行时系统作为Object-C语言的操作系统,使它工作.</p>
<p>文档大概说了NSObject class和Object-C程序如何runtime系统进行交互.尤其是检查动态加载新类,和消息转发给其它对象的范式.文档还提供一些有关于运行时你的程序怎么寻找一些有关对象的information</p>
<p>读这篇文章,你该明白Object-C runtime 系统怎样工作和可以如何利用它.一般情况下,就算你不了解它,也不影响你编写的应用程序.</p>
<h5 id="文档目录"><a href="#文档目录" class="headerlink" title="文档目录"></a>文档目录</h5><p>这篇文章有以下章节</p>
<ul>
<li>Runtime Versions and Platforms(运行时版本与平台)</li>
<li>Interacting with the Runtime(与运行时交互)</li>
<li>Messaging(消息)</li>
<li>Dynamic Method Resolution(动态方法解析)</li>
<li>Message Forwarding(消息转发)</li>
<li>Type Encodings(类型编码)</li>
<li>Declared Properties(声明属性)</li>
</ul>
<h5 id="也可以参考"><a href="#也可以参考" class="headerlink" title="也可以参考"></a>也可以参考</h5><p><a href="https://developer.apple.com/reference/objectivec/1657527-objective_c_runtime">Objective-C Runtime Reference</a>描述运行时支持库的数据结构和函数.你的程序可以使用这些和Object-C runtime系统进行交互.例如,你可以增加一些类和方法或者获得加载类的所有类定义列表</p>
<p><a href="https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011210">Programming with Objective-C</a>描述了Object-C语言</p>
<p><a href="https://developer.apple.com/library/content/releasenotes/Cocoa/RN-ObjectiveC/index.html#//apple_ref/doc/uid/TP40004309">Objective-C Release Notes</a>描述了Object-C 运行时在最近OS X版本的一些变化</p>
<h3 id="runtime-versions-and-platforms运行时版本与平台"><a href="#Runtime-Versions-and-Platforms-运行时版本与平台" class="headerlink" title="Runtime Versions and Platforms(运行时版本与平台)"></a>Runtime Versions and Platforms(运行时版本与平台)</h3><p>在不同的平台中有不同的Object-C runtime 版本.</p>
<h5 id="legacy-and-modern-versions过时与现在版本"><a href="#Legacy-and-Modern-Versions-过时与现在版本" class="headerlink" title="Legacy and Modern Versions(过时与现在版本)"></a>Legacy and Modern Versions(过时与现在版本)</h5><p>在Object-C中有两个runtime版本,分别是”modern”(现在)和”legacy”(过时).modern版本是从Object-C 2.0开始到现在.Objective-C 1运行时参考中描述了运行时的legacy版本的编程接口;现在的Object-C运行时参考中描述了运行时的modern版本的编程接口.</p>
<p>modern运行时最显著的新特征是实例变量是”non-fragile”(非脆)</p>
<ul>
<li>在legacy runtime,如果你在类中改变了实例变量的布局,你必须重新编译继承于它的类</li>
<li>在modern runtime,则不需要</li>
</ul>
<h5 id="platforms平台"><a href="#Platforms-平台" class="headerlink" title="Platforms(平台)"></a>Platforms(平台)</h5><p>iPhone 应用程序和在OS X v10.5和以后的64-bit 使用modern 运行时版本.其它则使用legacy运行时版本.</p>
<h3 id="interacting-with-the-runtime与运行时交互"><a href="#Interacting-with-the-Runtime-与运行时交互" class="headerlink" title="Interacting with the Runtime(与运行时交互)"></a>Interacting with the Runtime(与运行时交互)</h3><p>Object-C编程与运行时系统交互主要是以下三个方面:1.通过Object源代码,通过NSObject类方法和直接通过runttime函数</p>
<h5 id="objective-c-source-codeobjective-c-源代码"><a href="#Objective-C-Source-Code-Objective-c-源代码" class="headerlink" title="Objective-C Source Code(Objective-c 源代码)"></a>Objective-C Source Code(Objective-c 源代码)</h5><p>大多数情况下,runtime系统通过自动的在幕后工作.你只需要写和编译Object-C源代码即可.</p>
<p>当你编译包含Object类和方法代码时,编译器会创建实现这门语言的动态特性的数据结构和函数调用.数据结构会捕获关于类、类别定义和协议声明的信息;包括在Object-C编程语言中定义类和协议中类和协议对象,也包括方法选择器(method selector)实例变量模板,和其它从源代码提取的信息.运行时最主要的是消息发送,像消息的描述.它由源代码表达式发送.</p>
<h5 id="nsobject-methodsnsobject-方法"><a href="#NSObject-Methods-NSObject-方法" class="headerlink" title="NSObject Methods(NSObject 方法)"></a>NSObject Methods(NSObject 方法)</h5><p>在Cocoa中大部分对象是NSObject子类,所以大部分对象是继承它定义的方法(NSProxy例外),因此建立了每个实例和每个对象固有的行为.然而，在少数情况下，NSObject类只定义了一个模板，用于如何做一些事情; 它不提供所有必要的代码.</p>
<p>例如,NSObject 类定义了一个description 返回字符串描述类内容实例方法.这主要用于调试 -这个CDB print-object命令打印字符串从这个方法返回.这个方法的NSObject’s实现,不知道这个类包含什么内容,所以他返回一个对象名字和地址的字符串.Object子类可以可以实现这个方法来返回更多的细节.例如，Foundation类NSArray返回它包含的对象的描述列表.</p>
<p>一些NSObject方法只是查询运行时系统的信息,这些方法允许对象执行自省.例如一些类方法,要求识别其类;<code>isKindOfClass:</code>和<code>isMemberOfClass:</code>测试对象在继承层次结构中的位置;<code>respondsToSelector:</code>指示对象是否可以接受特定消息;<code>conformsToProtocol:</code>指示对象是否宣称去实现在特定的协议中被定义的方法和<code>methodForSelector:</code>提供一个方法实现的地址.等能够自省的方法.</p>
<h5 id="runtime-functions运行时函数"><a href="#Runtime-Functions-运行时函数" class="headerlink" title="Runtime Functions(运行时函数)"></a>Runtime Functions(运行时函数)</h5><p>运行时系统是一个动态共享库，其公共接口由位于目录/ usr / include / objc中的头文件中的一组函数和数据结构组成。 许多这些函数允许你使用纯C来重新使用编译器在编写Objective-C代码时所做的工作。 其他通过NSObject类的方法导出的功能的基础。 这些功能使得可以开发到运行时系统的其他接口，并产生增强开发环境的工具; 当在Objective-C中编程时不需要它们。 但是，编写Objective-C程序时，一些运行时函数有时会很有用。 所有这些函数都记录在<a href="https://developer.apple.com/reference/objectivec/1657527-objective_c_runtime">Objective-C Runtime Reference.</a>。</p>
<h3 id="messaging消息"><a href="#Messaging-消息" class="headerlink" title="Messaging(消息)"></a>Messaging(消息)</h3><p>本章节描述的是如何将信息表达式转化为obj_msgSend函数调用,以及怎样按名称查找方法.怎样利用object_msgSend和怎样绕过动态绑定.</p>
<h5 id="the-objc_msgsend-functionobjc_msgsend函数"><a href="#The-objc-msgSend-Function-objc-msgSend函数" class="headerlink" title="The objc_msgSend Function(objc_msgSend函数)"></a>The objc_msgSend Function(objc_msgSend函数)</h5><p>在Objective-C中，消息在运行时之前不绑定到方法实现.编译器转换消息表达式</p>
<pre><code>[receiver message]
</code></pre><p>转成换objc_msgSend消息函数,这个函数有接收者和被提到的方法名称-就是selector函数,作为主要的两个参数</p>
<pre><code>objec_msgSend(receiver,selector)
</code></pre><p>在消息传递中,参数也是通过也是传递给objc_msgSend</p>
<pre><code>objc_msgSend(receiver, selector, arg1, arg2, ...)
</code></pre><p>消息传递函数为动态绑定做任何事情</p>
<ul>
<li>首先找到selector的引用过程(方法的实现),相同的方法可以被不同的类实现,其精确查找依赖于receiver的类</li>
<li>然后它调用该过程，将其传递给接收对象（指向其数据的指针）以及为该方法指定的任何参数</li>
<li>最后，它传递过程的返回值作为它自己的返回值</li>
</ul>
<p>注意：编译器生成对消息传递函数的调用。 你不应该直接在你写的代码中调用它。</p>
<p>消息转发的关键在于编译器为每个类和对象构建结构。 每个类结构包括这两个基本元素：</p>
<ul>
<li>指向超类的指针。</li>
<li>类调度表。 此表具有将方法选择器与其标识的方法的类特定地址相关联的条目。 setOrigin ::方法的选择器与（实现的过程）setOrigin ::的地址相关联，显示方法的选择器与显示地址相关联，依此类推。</li>
</ul>
<p>创建新对象时，将分配其内存，并初始化其实例变量。 第一个对象的变量是一个指向它的类结构的指针。 这个指针，称为isa，给对象访问它的类，并通过类，到它继承的所有类。</p>
<p><img src="/2016/12/15/说说Object-C-Runtime/messaging1.gif" alt="message"></p>
<p>当消息发送給对象,这个消息转发函数会随着对象的isa指针到调度表寻找的方法选择器(selector)类结构.如果没有发现selector,objc_msgSend会随着指针到超类调度表寻找selector,直到NSObject.一旦找到selector,就进入表调用这个方法和传递它给接收对象的数据结构</p>
<p>这就是方法runtime方法实现的方式,或者用术语来说,方法动态绑定.</p>
<p>为了加快消息转发的过程,当它们被调用,运行时系统缓存了selector和方法的地址.而且为每个类分开做缓存.它包含继承的的方法和在类中定义的方法.在查找总调度表之前,首先查找缓存调度表.如果是在缓存找到selector,消息转发仅比函数调用略微耗时.</p>
<h5 id="using-hidden-argument使用隐藏参数"><a href="#Using-Hidden-Argument-使用隐藏参数" class="headerlink" title="Using Hidden Argument(使用隐藏参数)"></a>Using Hidden Argument(使用隐藏参数)</h5><p>在消息转发中,当objc_msgSend找到方法实现的过程,它会调用这个过程和传递它所有的参数,它也传递两个隐藏的参数:</p>
<ul>
<li>接收对象</li>
<li>方法选择器</li>
</ul>
<p>这些参数给有关引用这两个信息表达式的每一个方法实现详细的信息.它们称之为”hidden”(隐藏)是因为在方法定义的源代码没有声明.它们在代码被编译的时候被插入到实现中.</p>
<p>尽管这些参数没有明确的声明,源代码仍然可以引用它们(仅能引用接受对象的实例变量).方法引用接收对象称为self,和用用它自己的selector称为_cmd.在下面就例子中,_cmd引用了strange方法,self引用收到strange消息的对象</p>
<pre><code>- strange
{
    id  target = getTheReceiver();
    SEL method = getTheMethod();

    if ( target == self || method == _cmd )
        return nil;
    return [target performSelector:method];
}
</code></pre><p>self是更有用的参数,事实上,接收对象的实例变量是可以获得方法的定义.</p>
<h5 id="getting-a-method-address获得方法地址"><a href="#Getting-a-Method-Address-获得方法地址" class="headerlink" title="Getting a Method Address(获得方法地址)"></a>Getting a Method Address(获得方法地址)</h5><p>规避动态绑定的唯一方法是获取方法的地址，并直接调用它，就像它是一个函数。 这在极少情况下可能是适当的，当特定方法将被连续执行多次，并且希望避免每次执行该方法时消息的开销。</p>
<p>使用NSObject类<code>methodForSelector</code>中定义的方法，可以要求指向实现方法的过程的指针，然后使用指针调用过程. <code>methodForSelector：</code>返回的指针必须小心地转换为正确的函数类型。 返回和参数类型都应包含在转换中。</p>
<p>下面的示例显示了如何调用实现setFilled：方法的过程：</p>
<pre><code>void (*setter)(id, SEL, BOOL);
int i;

setter = (void (*)(id, SEL, BOOL))[target
    methodForSelector:@selector(setFilled:)];
for ( i = 0 ; i &lt; 1000 ; i++ )
    setter(targetList[i], @selector(setFilled:), YES);
</code></pre><p>传递给过程的前两个参数是接收对象（self）和方法选择器（_cmd）。 这些参数隐藏在方法语法中，但是当方法作为函数调用时必须显式。</p>
<p>使用methodForSelector：规避动态绑定可以节省消息传递所需的大部分时间。 然而，仅当特定消息被重复多次时，节省将是显着的，如在上面所示的for循环中。</p>
<p>注意，methodForSelector：由Cocoa运行时系统提供; 它不是Objective-C语言本身的一个特性。</p>
<h3 id="dynamic-method-resolution动态派发"><a href="#Dynamic-Method-Resolution-动态派发" class="headerlink" title="Dynamic Method Resolution(动态派发)"></a>Dynamic Method Resolution(动态派发)</h3><p>本章介绍如何动态提供方法的实现。</p>
<h5 id="dynamic-method-resolution-动态派发"><a href="#Dynamic-Method-Resolution-动态派发-1" class="headerlink" title="Dynamic Method Resolution (动态派发)"></a>Dynamic Method Resolution (动态派发)</h5><p>某些情况下，您可能需要动态提供方法的实现。 例如，Objective-C声明的属性特性,包括@dynamic指令：</p>
<pre><code>@dynamic propertyName;
</code></pre><p>它告诉编译器与属性相关联的方法将被动态提供。</p>
<p>您可以实现方法<code>resolveInstanceMethod：</code>和<code>resolveClassMethod：</code>分别为实例和类方法动态提供给定选择器的实现。</p>
<p>Objective-C方法只是一个C函数，至少需要两个参数 - self和_cmd。 您可以使用函数class_addMethod将函数添加到类作为方法。 因此，给定以下函数：</p>
<pre><code>void dynamicMethodIMP(id self, SEL _cmd) {
    // implementation ....
}
</code></pre><p>你可以使用<code>resolveInstanceMethod</code>动态地将它添加到一个类作为一个方法（称为resolveThisMethodDynamically）：像这样：</p>
<pre><code>@implementation MyClass
+ (BOOL)resolveInstanceMethod:(SEL)aSEL
{
    if (aSEL == @selector(resolveThisMethodDynamically)) {
          class_addMethod([self class], aSEL, (IMP) dynamicMethodIMP, &quot;v@:&quot;);
          return YES;
    }
    return [super resolveInstanceMethod:aSEL];
}
@end
</code></pre><p>转发方法（如消息转发描述）和动态方法解析是，在很大程度上，正交。 类有机会在转发机制开始之前动态地解析方法。如果调用了<code>responsesToSelector：</code>或<code>instancesRespondToSelector：</code>，动态方法解析器被给予为选择器提供IMP的机会。 如果实现<code>resolveInstanceMethod：</code>但希望特定的选择器实际上通过转发机制转发，则对这些选择器返回NO。</p>
<h5 id="dynamic-loading动态加载"><a href="#Dynamic-Loading-动态加载" class="headerlink" title="Dynamic Loading(动态加载)"></a>Dynamic Loading(动态加载)</h5><p>Objective-C程序可以在运行时加载和链接新的类和类别。新代码被合并到程序中，并且与开始时加载的类和类别完全相同。</p>
<p>动态加载可以用来做很多不同的事情。例如，系统首选项应用程序中的各个模块都是动态加载的。</p>
<p>在Cocoa环境中，通常使用动态加载来允许自定义应用程序。其他人可以编写程序在运行时加载的模块，就像Interface Builder加载自定义调色板和OS X系统首选项应用程序加载自定义首选项模块一样。可加载模块扩展了应用程序可以做什么。他们以你允许，但不能预期或定义自己的方式贡献它。你提供的框架，但其他人提供的代码。</p>
<p>虽然有一个运行时函数在Mach-O文件（objc_loadModules，在objc / objc-load.h中定义）中执行Objective-C模块的动态加载，Cocoa的NSBundle类为动态加载提供了一个非常方便的界面 - 定向和集成相关服务。有关NSBundle类及其使用的信息，请参阅Foundation框架参考中的NSBundle类规范。有关Mach-O文件的信息，请参见OS X ABI Mach-O文件格式参考</p>
<h3 id="messag-forwarding消息转发"><a href="#Messag-Forwarding-消息转发" class="headerlink" title="Messag Forwarding(消息转发)"></a>Messag Forwarding(消息转发)</h3><p>向不处理该消息的对象发送消息是一个错误。 然而，在报错之前，运行时系统给接收对象第二次处理消息的机会。</p>
<h5 id="forwarding转发"><a href="#Forwarding-转发" class="headerlink" title="Forwarding(转发)"></a>Forwarding(转发)</h5><p>如果您向不处理该消息的对象发送消息，则在发布错误之前，运行时将对象发送一个<code>forwardInvocation：</code>消息，并将<code>NSInvocation</code>对象作为其唯一参数，NSInvocation对象封装原始消息和传递的参数。</p>
<p>您可以实现<code>forwardInvocation</code>方法以给予消息默认响应，或以某种其他方式避免错误。顾名思义，<code>forwardInvocation：</code>通常用于将消息转发到另一个对象。</p>
<p>想要看看转发的范围和意图，想象以下场景：假设，首先，你设计一个对象，可以响应一个消息，称为<code>negotiate</code>，并且你想要另一对象的响应。你可以通过传递一个<code>negotiate</code>消息到你实现的<code>negotiate</code>方法的主体中的其他对象轻松地实现这一点。</p>
<p>再进一步，假设您希望对象对协商消息的响应正是在另一个类中实现的响应。实现这一点的一种方法是让你的类从另一个类继承该方法。但是，可能不可能这样安排。可能有很好的理由为什么你的类和实现协商的类在继承层次结构的不同分支。</p>
<p>即使你的类不能继承negotiate方法，你仍然可以通过实现一个版本的方法，只是将消息传递给另一个类的实例“借”它：</p>
<pre><code>- (id)negotiate
{
    if ( [someOtherObject respondsTo:@selector(negotiate)] )
        return [someOtherObject negotiate];
    return self;
}
</code></pre><p>这种做事的方式可能会有点麻烦，特别是如果有一些消息，你想让你的对象传递给另一个对象。你必须实现一个方法来覆盖你想从另一个类借用的每个方法。此外，它是不可能处理的情况下，你不知道，在你写代码的时候，你可能要转发的完整的消息集。该集合可能取决于运行时的事件，并且可能随着新方法和类在将来实现而改变。</p>
<p><code>forwardInvocation：</code>message提供的第二次机会为这个问题提供了一个不太特别的解决方案，动态解决的而不是静态的。它的工作原理是这样的：当对象不能响应消息，因为它没有匹配消息中的选择器的方法，运行时系统通过发送一个<code>forwardInvocation：</code>消息通知对象。每个对象从NSObject类继承<code>forwardInvocation：</code>方法。然而，NSObject的版本的方法只是调用doesNotRecognizeSelector：。通过重写NSObject的版本并实现自己的，你可以利用<code>forwardInvocation：</code>message提供的将消息转发给其他对象的机会。</p>
<p>要转发消息，所有forwardInvocation：方法需要做的是：</p>
<ul>
<li>确定消息应该到哪里，和</li>
<li>发送它的原始参数。</li>
</ul>
<p>消息可以使用<code>invokeWithTarget：</code>方法发送：</p>
<pre><code>- (void)forwardInvocation:(NSInvocation *)anInvocation
{
    if ([someOtherObject respondsToSelector:
            [anInvocation selector]])
        [anInvocation invokeWithTarget:someOtherObject];
    else
        [super forwardInvocation:anInvocation];
}
</code></pre><p>被转发消息的返回值被返回到原来的Sender(发送发),所有类型的返回值都可以传递给发送方，包括ids，double和双精度浮点数。</p>
<p><code>forwardInvocation：</code>方法可以充当未识别消息的分发中心，将它们分解到不同的接收方。 或者它可以是转移站，将所有消息发送到相同的目的地。 它可以将一个消息转换为另一个消息，或者简单地“吞下”一些消息，所以没有响应和没有错误。 <code>forwardInvocation：</code>方法还可以将多个消息合并为单个响应。 <code>forwardInvocation：</code>做的事情给实现者。 然而，它提供用于在转发链中链接对象的机会为程序设计打开了可能性。</p>
<p>注意：<code>forwardInvocation：</code>方法仅在它们不调用名义接收器中的现有方法时才处理消息。 例如，如果您希望对象将negotiate消息转发给另一个对象，则它不能具有自己的negotiate方法。 如果有，消息将永远不会到达<code>forwardInvocation：</code>。<br>有关转发和调用的更多信息，请参阅Foundation框架参考中的NSInvocation类规范。</p>
<h5 id="forwarding-and-multiple-inheritance转发和多继承"><a href="#Forwarding-and-Multiple-Inheritance-转发和多继承" class="headerlink" title="Forwarding and Multiple Inheritance(转发和多继承)"></a>Forwarding and Multiple Inheritance(转发和多继承)</h5><p>转发模拟继承，可用于将多重继承的一些影响借给Objective-C程序，通过转发消息来响应消息的对象似乎借用或“继承”另一个类中定义的方法实现。</p>
<p><img src="/2016/12/15/说说Object-C-Runtime/forwarding.gif" alt="forwarding"></p>
<p>在此图中，Warrior类的实例将negotiate消息转发到Diplomat类的实例。Warrior就像像Diplomat调用negotiate。Warrior似乎对negotiate的信息作出反应，并且为了所有实际目做出回应（它就像真的是一个Diplomat(外交官)，正在做的工作）。</p>
<p>转发消息的对象因此从继承层次结构的两个分支“继承”方法 - 它自己的分支和响应消息的对象的分支。在上面的例子中，Warrior类继承自Diplomat以及它自己的超类。</p>
<p>转发提供了您通常希望从多重继承的大多数功能。但是，这两者之间有一个重要的区别：多重继承将单个对象中的不同能力组合在一起。它倾向于大，多面的对象。另一方面，转发为不同的对象分配单独的职责。它将问题分解为较小的对象，但以对消息发送方透明的方式关联这些对象</p>
<h5 id="surrogate-objects代替对象"><a href="#Surrogate-Objects-代替对象" class="headerlink" title="Surrogate Objects(代替对象)"></a>Surrogate Objects(代替对象)</h5><p>转发不仅模仿多重继承，还使得开发表示或“覆盖”更实质对象的轻量级对象成为可能。</p>
<p>在Objective-C编程语言的“远程消息”中讨论的代理是这样的surrogate(代理)。代理负责将消息转发到远程接收器的管理细节，确保在连接上复制和检索参数值，等等。但它不试图做许多其他;它不重复远程对象的功能，而只是给远程对象一个本地地址，它可以在另一个应用程序中接收消息。</p>
<p>其他类型的替代对象也是可能的。假设，例如，你有一个对象操纵大量的数据 - 或许它创建一个复杂的图像或读取磁盘上的文件的内容。将此对象设置为向上可能是耗时的，所以你更喜欢做它懒惰 - 当它真的需要或当系统资源暂时空闲时。同时，您至少需要一个此对象的占位符，以便应用程序中的其他对象正常工作。</p>
<p>在这种情况下，你最初可以创建，不是完整的对象，是一个轻量级的代理。这个对象可以自己做一些事情，例如回答有关数据的问题，但大多数情况下，它只是为较大的对象保存一个地方，当时间到来时，转发消息给它。当代理的<code>forwardInvocation：</code>方法首先接收到目的地为另一个对象的消息时，它将确保该对象存在，并且如果它不存在则将创建它。对于较大对象的所有消息通过代理，因此，就程序的其余部分而言，代理和较大对象将是相同的。</p>
<h5 id="forwarding-and-inheritance转发和继承"><a href="#Forwarding-and-Inheritance-转发和继承" class="headerlink" title="Forwarding and Inheritance(转发和继承)"></a>Forwarding and Inheritance(转发和继承)</h5><p>虽然转发模仿继承，NSObject类从不混淆两者。 像<code>responsesToSelector：</code>和<code>isKindOfClass</code>这样的方法：只看继承层次结构，从不看转发链。 例如，如果一个Warrior对象被询问是否响应negotiate消息，</p>
<pre><code>if ( [aWarrior respondsToSelector:@selector(negotiate)] )
    ...
</code></pre><p>答案是否定的，即使它可以无误地接收negotiate消息，并在某种意义上通过将它们转发给Diplomat来对它们作出响应。</p>
<p>在许多情况下，NO是正确的答案。 但它可能不是。 如果使用转发来设置代理对象或扩展类的功能，则转发机制应该像继承一样透明。 如果你想让对象的行为好像真的继承了他们转发消息的对象的行为，你需要重新实现<code>responsesToSelector：</code>和<code>isKindOfClass：</code>方法来包含你的转发算法：</p>
<pre><code>- (BOOL)respondsToSelector:(SEL)aSelector
{
    if ( [super respondsToSelector:aSelector] )
        return YES;
    else {
        /* Here, test whether the aSelector message can     *
         * be forwarded to another object and whether that  *
         * object can respond to it. Return YES if it can.  */
    }
    return NO;
}
</code></pre><p>除了<code>responsesToSelector：</code>和<code>isKindOfClass：</code>，<code>instancesRespondToSelector：</code>方法也应该镜像转发算法。 如果使用协议，那么也应该将<code>conformsToProtocol：</code>方法添加到列表中。 类似地，如果一个对象转发它接收的任何远程消息，它应该有一个版本的<code>methodSignatureForSelector：</code>它可以返回最终响应转发消息的方法的准确描述; 例如，如果对象能够将消息转发到其代理，则可以实现<code>methodSignatureForSelector：</code>如下所示</p>
<pre><code>- (NSMethodSignature*)methodSignatureForSelector:(SEL)selector
{
    NSMethodSignature* signature = [super methodSignatureForSelector:selector];
    if (!signature) {
       signature = [surrogate methodSignatureForSelector:selector];
    }
    return signature;
}
</code></pre><p>你可能会考虑把转发算法放在私人代码中，并由<code>forwardInvocation：included</code>，调用它。</p>
<p>注意：这是一种高级技术，仅适用于没有其他解决方案的情况。 它不是作为继承的替代。 如果你必须使用这种技术，请确保你完全理解类的行为做转发和你转发的类。</p>
<p>本节中提到的方法在Foundation框架参考中的NSObject类规范中进行了描述。 有关invokeWithTarget：的信息，请参阅Foundation框架参考中的<a href="https://developer.apple.com/reference/foundation/nsinvocation">NSInvocation</a>类规范。</p>
<h3 id="declared-properties声明属性"><a href="#Declared-Properties-声明属性" class="headerlink" title="Declared Properties(声明属性)"></a>Declared Properties(声明属性)</h3><p>当编译器遇到属性声明（请参阅Objective-C编程语言中的声明属性）时，它会生成与封闭类，类别或协议相关联的描述性元数据。 您可以使用支持按类名或协议的名称查找属性的@encode字符串获取属性的类型，以及将属性属性的列表复制为C字符串数组的函数来访问此元数据。 每个类和协议都有一个声明的属性列表。</p>
<h5 id="property-type-and-functions属性类型和函数"><a href="#Property-Type-and-Functions-属性类型和函数" class="headerlink" title="Property Type and Functions(属性类型和函数)"></a>Property Type and Functions(属性类型和函数)</h5><p>Property结构定义了属性描述符的不透明句柄</p>
<pre><code>typedef struct objc_property *Property;
</code></pre><p>您可以使用函数<code>class_copyPropertyList</code>和<code>protocol_copyPropertyList</code>来检索与类（包括加载的类别）和协议相关联的属性的数组：</p>
<pre><code>objc_property_t *class_copyPropertyList(Class cls, unsigned int *outCount)
objc_property_t *protocol_copyPropertyList(Protocol *proto, unsigned int *outCount)
</code></pre><p>例如，给定以下类声明</p>
<pre><code>@interface Lender : NSObject {
    float alone;
}
@property float alone;
@end
</code></pre><p>您可以使用以下方式获取属性列表：</p>
<pre><code>id LenderClass = objc_getClass(&quot;Lender&quot;);
unsigned int outCount;
objc_property_t *properties = class_copyPropertyList(LenderClass, &amp;outCount);
</code></pre><p>您可以使用property_getName函数来发现属性的名称：</p>
<pre><code>const char *property_getName(objc_property_t property)
</code></pre><p>您可以使用函数class_getProperty和protocol_getProperty来获取对类和协议中给定名称的属性的引用：</p>
<pre><code>objc_property_t class_getProperty(Class cls, const char *name)
objc_property_t protocol_getProperty(Protocol *proto, const char *name, BOOL isRequiredProperty, BOOL isInstanceProperty)
</code></pre><p>您可以使用property_getAttributes函数来发现属性的名称和@encode类型字符串。</p>
<pre><code>const char *property_getAttributes(objc_property_t property)
</code></pre><p>将这些组合在一起，您可以使用以下代码打印与类关联的所有属性的列表：</p>
<pre><code>id LenderClass = objc_getClass(&quot;Lender&quot;);
unsigned int outCount, i;
objc_property_t *properties = class_copyPropertyList(LenderClass, &amp;outCount);
for (i = 0; i &lt; outCount; i++) {
    objc_property_t property = properties[i];
    fprintf(stdout, &quot;%s %s\n&quot;, property_getName(property), property_getAttributes(property));
}
</code></pre><h5 id="property-type-string属性类型字符串"><a href="#Property-Type-String-属性类型字符串" class="headerlink" title="Property Type String(属性类型字符串)"></a>Property Type String(属性类型字符串)</h5><p>您可以使用property_getAttributes函数来发现名称，属性的@encode类型字符串和属性的其他属性。</p>
<p>该字符串以一个T开头，后面跟着@encode类型和一个逗号，最后是一个V，后面跟着背景实例变量的名字。 在这些属性之间，属性由以下描述符指定，用逗号分隔</p>
]]></content>
    
    <summary type="html">
    
      &lt;h5 id=&quot;今天照着文档来说说runtime看到一半看不下去了怪自己英文不好先写下来慢慢理解然后在看下半部分~&quot;&gt;&lt;a href=&quot;#今天照着文档来说说runtime-看到一半看不下去了-怪自己英文不好-…先写下来慢慢理解-然后在看下半部分&quot; class=&quot;headerlin
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title>个人博客的创建</title>
    <link href="https://blaceman.github.io/2016/12/06/%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E7%9A%84%E5%88%9B%E5%BB%BA/"/>
    <id>https://blaceman.github.io/2016/12/06/个人博客的创建/</id>
    <published>2016-12-06T10:46:03.000Z</published>
    <updated>2016-12-27T07:03:10.000Z</updated>
    
    <content type="html"><![CDATA[<h4 id="最近失业有点无聊折腾一下博客然后把自己所折腾的事记录下来加深印象~"><a href="#最近失业-有点无聊-折腾一下博客-然后把自己所折腾的事记录下来-加深印象" class="headerlink" title="最近失业,有点无聊,折腾一下博客,然后把自己所折腾的事记录下来,加深印象~"></a>最近失业,有点无聊,折腾一下博客,然后把自己所折腾的事记录下来,加深印象~</h4><h4 id="首先来首歌"><a href="#首先来首歌" class="headerlink" title="首先来首歌"></a>首先来首歌</h4><iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="330" height="86" src="https://music.163.com/outchain/player?type=2&id=32507038&auto=1&height=66"></iframe>


<h4 id="这篇文章大概说了以下这几个方面"><a href="#这篇文章大概说了以下这几个方面" class="headerlink" title="这篇文章大概说了以下这几个方面"></a>这篇文章大概说了以下这几个方面</h4><ol>
<li>为mac电脑安装<a href="https://hexo.io/zh-cn/docs/">Hexo</a></li>
<li>基于github安装静态页面的Hexo博客</li>
<li>MarkDown常见的用法</li>
</ol>
<h3 id="1为mac电脑安装hexo"><a href="#1-为mac电脑安装Hexo" class="headerlink" title="1.为mac电脑安装Hexo"></a>1.为mac电脑安装<a href="https://hexo.io/zh-cn/docs/">Hexo</a></h3><h4 id="首先hexo一款基于nodejs的静态博客框架可以生成静态文件并且一键部署到github-pages上并且他可以使用markdown来编写文章十分简单-所以安装hexo的前提必须是要安装nodejs和git而nodejs的最佳安装方式是使用nvmnode的管理工具"><a href="#首先Hexo一款基于Node-js的静态博客框架，可以生成静态文件并且一键部署到github-pages上，并且他可以使用markdown来编写文章，十分简单。所以安装Hexo的前提必须是要安装Node-JS和Git而Node-JS的最佳安装方式是使用nvm-Node的管理工具" class="headerlink" title="首先Hexo一款基于Node.js的静态博客框架，可以生成静态文件并且一键部署到github pages上，并且他可以使用markdown来编写文章，十分简单。所以安装Hexo的前提必须是要安装Node.JS和Git而Node.JS的最佳安装方式是使用nvm(Node的管理工具)"></a>首先<a href="https://hexo.io/zh-cn/docs/">Hexo</a>一款基于Node.js的静态博客框架，可以生成静态文件并且一键部署到github pages上，并且他可以使用markdown来编写文章，十分简单。所以安装Hexo的前提必须是要安装Node.JS和Git而Node.JS的最佳安装方式是使用nvm(Node的管理工具)</h4><p>1.安装Git</p>
<pre><code>// 安装 HomeBrew(一款软件包管理工具)
 $ /usr/bin/ruby -e &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&quot;
 $ brew install git   // 安装Git
</code></pre><p>这里给出来HomeBrew的基本用法方便像我这样的小白阅读了解<a href="http://www.cnblogs.com/TankXiao/p/3247113.html#brewother">http://www.cnblogs.com/TankXiao/p/3247113.html#brewother</a></p>
<p>2.安装nvm</p>
<pre><code> 1. Homebrew 安装方式，此安装方式无需重启
 $ brew install nvm  
 $ mkdir ~/.nvm
 $ export NVM_DIR=~/.nvm
 $ . $(brew --prefix nvm)/nvm.sh
 2. curl安装方式
 $ curl https://raw.github.com/creationix/nvm/master/install.sh | sh
</code></pre><p>同样这里也列出来nvm的基本用法<a href="http://weizhifeng.net/node-version-management-via-n-and-nvm.html">http://weizhifeng.net/node-version-management-via-n-and-nvm.html</a></p>
<p>3.安装Node.JS</p>
<p><code>$ nvm install 4</code></p>
<p>4.最后一步安装Hexo</p>
<p> <code>$ sudo npm install hexo-cli -g</code></p>
<p> 至此,为创建博客做了基础的准备~顺便也给出Hexo的文档参考,参考<a href="https://hexo.io/zh-cn/docs/">Hexo</a></p>
<h3 id="2创建个人博客"><a href="#2-创建个人博客" class="headerlink" title="2.创建个人博客"></a>2.创建个人博客</h3><p>1.Hexo安装完后,创建一个Github仓库,命名为<code>username</code>.github.io <strong>username是username/username.github.io的名字</strong>如果没有不懂Github,就谷歌一下吧,详细就不说</p>
<p>2.hexo 一个文件夹,文件夹名字是可以随便起的…ok,这个文件夹就是管理和发布我们的博客的,我们只需要这里面配置好我们需要的东西</p>
<p><code>hexo init username.github.io</code> </p>
<p>3.打开_config.yml,配置里面的参数的参数 简单说一下这里面的配置,还有许多设置请看<a href="http://www.jianshu.com/p/2b9f202c13fd">这里</a></p>
<pre><code>title: blaceman  //博客名字
subtitle: 懵懂 前进 憧憬 //副标题
description: 黄昏,一天最美丽的谢幕~ //描述
author: blaceman //名字
language: zh-Hans //语言
url: https://blaceman.github.io //url
root: /
theme: new-vno //主题
deploy:
  type: git //git 发布
  repo: https://github.com/blaceman/blaceman.github.io.git  //Git源
</code></pre><p>4.配置好之后,如果觉得主题丑的话,就换一下主题吧,默认是landscape hexo的众多主题<a href="https://hexo.io/themes/">在这</a>,而我的主题是<a href="https://github.com/monniya/hexo-theme-new-vno">这</a></p>
<pre><code>$ cd username.github.io
$ git clone https://github.com/iissnan/hexo-theme-next themes/next //next主题
</code></pre><p>clone好之后 修改博客的_config.yml中的主题<code>theme: new-vno</code>然后在修改主题里面的_config.yml,next主题的教程<a href="http://theme-next.iissnan.com/getting-started.html#theme-settings">在这</a></p>
<p>5.测试</p>
<p><code>$ hexo s</code></p>
<p> 测试服务启动，你可以在浏览器中输入<a href="https://localhost:4000">https://localhost:4000</a> 访问了。觉得没问题后就可以发布了</p>
<p>6.安装hexo-deployer-git自动部署发布工具</p>
<p><code>$ npm install hexo-deployer-git --save</code></p>
<p>7.发布</p>
<p><code>$ hexo clean &amp;&amp; hexo g &amp;&amp; hexo d</code></p>
<p>到这一步在浏览器输入<a href="https://username.github.io">https://username.github.io</a> 就可以看到你创建的博客了…</p>
<p>8.编写文章</p>
<p><code>hexo new &quot;文章名字&quot;</code></p>
<p>就在~/source/_post创建了你的.md之后你就可以用MarkDown大肆发挥了,写完后记得再次发布<br><code>$ hexo clean &amp;&amp; hexo g &amp;&amp; hexo d</code> </p>
<p>好了,创建博客的步骤差不多就结束了,你还可以为博客添加<strong>百度统计 谷歌统计 多说 disqueue 等第三方的东西</strong>至于怎么弄,百度一下就好~</p>
<h3 id="3markdown常见的用法"><a href="#3-MarkDown常见的用法" class="headerlink" title="3.MarkDown常见的用法"></a>3.MarkDown常见的用法</h3><p>1.常见<a href="http://www.csdn.net/article/2014-05-05/2819623">MarkDowm编辑器</a>挑一个自己喜欢的就好</p>
<p>2.基本用法,我就不在写一次了,入门<a href="http://www.jianshu.com/p/q81RER">在这</a>详细<a href="http://wowubuntu.com/markdown/">在这</a></p>
<h3 id="完"><a href="#完…" class="headerlink" title="完…"></a>完…</h3>]]></content>
    
    <summary type="html">
    
      &lt;h4 id=&quot;最近失业有点无聊折腾一下博客然后把自己所折腾的事记录下来加深印象~&quot;&gt;&lt;a href=&quot;#最近失业-有点无聊-折腾一下博客-然后把自己所折腾的事记录下来-加深印象&quot; class=&quot;headerlink&quot; title=&quot;最近失业,有点无聊,折腾一下博客,然后把自己所
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title>Hello world</title>
    <link href="https://blaceman.github.io/2016/11/29/12345/"/>
    <id>https://blaceman.github.io/2016/11/29/12345/</id>
    <published>2016-11-29T09:29:34.000Z</published>
    <updated>2016-12-27T06:48:52.000Z</updated>
    
    <content type="html"><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="quick-start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><pre><code class="bash">$ hexo new &quot;My New Post&quot;
</code></pre>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><pre><code class="bash">$ hexo server
</code></pre>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><pre><code class="bash">$ hexo generate
</code></pre>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><pre><code class="bash">$ hexo deploy
</code></pre>
<p>More info: <a href="https://hexo.io/docs/deployment.html">Deployment</a></p>
]]></content>
    
    <summary type="html">
    
      &lt;p&gt;Welcome to &lt;a href=&quot;https://hexo.io/&quot;&gt;Hexo&lt;/a&gt;! This is your very first post. Check &lt;a href=&quot;https://hexo.io/docs/&quot;&gt;documentation&lt;/a&gt; for
    
    </summary>
    
    
  </entry>
  
  <entry>
    <title>2018总结</title>
    <link href="https://blaceman.github.io/2001/01/02/2018%E6%80%BB%E7%BB%93/"/>
    <id>https://blaceman.github.io/2001/01/02/2018总结/</id>
    <published>2001-01-01T22:23:44.000Z</published>
    <updated>2001-01-01T22:23:44.000Z</updated>
    
    <summary type="html">
    
    </summary>
    
    
  </entry>
  
</feed>
