基本符号

小写希腊字母

注:部分希腊字母在数学公式中常以变量形式出现,例如 ϵ \epsilon ϵ在数学中一般写法为 ε \varepsilon ε ϕ \phi ϕ在数学中通常写作 φ \varphi φ

符号语法符号语法符号语法
α \alpha α\alpha β \beta β\beta γ \gamma γ\gamma
θ \theta θ\theta ε \varepsilon ε\varepsilon δ \delta δ\delta
μ \mu μ\mu ν \nu ν\nu η \eta η\eta
ζ \zeta ζ\zeta λ \lambda λ\lambda ψ \psi ψ\psi
σ \sigma σ\sigma ξ \xi ξ\xi τ \tau τ\tau
ϕ \phi ϕ\phi φ \varphi φ\varphi ρ \rho ρ\rho
χ \chi χ\chi ω \omega ω\omega π \pi π\pi

大写希腊字母

大写希腊字母通常是小写希腊字母的LATEX语法第一个字母改为大写,见下表

符号语法符号语法符号语法
Σ \Sigma Σ\Sigma Π \Pi Π\Pi Δ \Delta Δ\Delta
Γ \Gamma Γ\Gamma Ψ \Psi Ψ\Psi Θ \Theta Θ\Theta
Λ \Lambda Λ\Lambda Ω \Omega Ω\Omega Φ \Phi Φ\Phi
Ξ \Xi Ξ\Xi

常用字体

默认的字体为 A B C d e f ABCdef ABCdef,也就是\mathnormal{ABCdef}(当然,打公式的时候不需要加上这个\mathnormal,直接打字母就是这个效果)

字体语法字体语法
A B C d e f \mathrm{ABCdef} ABCdef\mathrm{ABCdef} A B C d e f \mathbf{ABCdef} ABCdef\mathbf{ABCdef}
A B C d e f \mathit{ABCdef} ABCdef\mathit{ABCdef} A B C d e f \pmb{ABCdef} ABCdef\pmb{ABCdef}
A B C d e f \mathscr{ABCdef} ABCdef\mathscr{ABCdef} A B C d e f \mathcal{ABCdef} ABCdef\mathcal{ABCdef}
A B C d e f \mathfrak{ABCdef} ABCdef\mathfrak{ABCdef} A B C d e f \mathbb{ABCdef} ABCdef\mathbb{ABCdef}

常见运算符

运算符语法运算符语法运算符语法
+ + ++ − - - × \times ×\times
± \pm ±\pm ⋅ \cdot \cdot ∗ \ast \ast
∪ \cup \cup ∩ \cap \cap ∘ \circ \circ
∨ \lor \lor或\vee ∧ \land \land或\wedge ¬ \lnot ¬\lnot
⊕ \oplus \oplus ⊖ \ominus \ominus ⊗ \otimes \otimes
⊙ \odot \odot ⊘ \oslash \oslash ∙ \bullet \bullet
x \sqrt{x} x \sqrt{x} x n \sqrt[n]{x} nx \sqrt[n]{x}

大尺寸运算符

运算符语法运算符语法运算符语法
∑ \sum \sum ∏ \prod \prod ∫ \int \int
⋃ \bigcup \bigcup ⋂ \bigcap \bigcap ∮ \oint \oint
⋁ \bigvee \bigvee ⋀ \bigwedge \bigwedge ∬ \iint \iint
∐ \coprod \coprod ⨆ \bigsqcup \bigsqcup ∯ \oiint \oiint

常见关系符号

符号语法符号语法符号语法
< < << > > >> = = ==
≤ \leq \leq ≥ \geq \geq ≠ \neq =\neq
≪ \ll \ll ≫ \gg \gg ≡ \equiv \equiv
⊂ \subset \subset ⊃ \supset \supset ≈ \approx \approx
⊆ \subseteq \subseteq ⊇ \supseteq \supseteq ∼ \sim \sim
∈ \in \in ∋ \ni \ni ∝ \propto \propto
⊢ \vdash \vdash ⊣ \dashv \dashv ⊨ \models \models
∣ \mid \mid ∥ \parallel \parallel ⊥ \perp \perp
∉ \notin /\notin ⋈ \Join \Join ≁ \nsim \nsim
⊊ \subsetneq \subsetneq ⊋ \supsetneq \supsetneq

数学模式重音符

符号语法符号语法符号语法
a ^ \hat{a} a^\hat{a} a ˉ \bar{a} aˉ\bar{a} a ~ \tilde{a} a~\tilde{a}
a ⃗ \vec{a} a \vec{a} a ˙ \dot{a} a˙\dot{a} a ¨ \ddot{a} a¨\ddot{a}
a b c ^ \widehat{abc} abc \widehat{abc} a b c ~ \widetilde{abc} abc \widetilde{abc} a b c ‾ \overline{abc} abc\overline{abc}

箭头

如果需要长箭头,只需要在语法前面加上\long,例如\longleftarrow即为 ⟵ \longleftarrow ,如果加上\Long则变为双线长箭头,例如\Longleftarrow即为 ⟸ \Longleftarrow

符号语法符号语法符号语法
← \leftarrow \leftarrow → \rightarrow \rightarrow ↔ \leftrightarrow \leftrightarrow
⇐ \Leftarrow \Leftarrow ⇒ \Rightarrow \Rightarrow ⇔ \Leftrightarrow \Leftrightarrow
↑ \uparrow \uparrow ↓ \downarrow \downarrow ↕ \updownarrow \updownarrow
⇑ \Uparrow \Uparrow ⇓ \Downarrow \Downarrow ⇕ \Updownarrow \Updownarrow
↼ \leftharpoonup \leftharpoonup ↽ \leftharpoondown \leftharpoondown ⇀ \rightharpoonup \rightharpoonup
⇁ \rightharpoondown \rightharpoondown ⇌ \rightleftharpoons \rightleftharpoons ⇋ \leftrightharpoons \leftrightharpoons
   ⟺    \iff \iff ↦ \mapsto \mapsto

括号

括号语法括号语法括号语法
( ) () ()() [ ] [] [][] { } \{\} {}\{\}
⌊ ⌋ \lfloor\rfloor \lfloor\rfloor ⌈ ⌉ \lceil\rceil \lceil\rceil ⟨ ⟩ \langle\rangle \langle\rangle

大尺寸括号

括号语法括号语法
( ) \left(\right) ()\left( \right) [ ] \left[ \right] []\left[ \right]
x 1 x 2 … x n ⏞ n \overbrace{x_1x_2\ldots x_n}^{n} x1x2xn n\overbrace{x_1x_2\ldots x_n}^{n} x 1 x 2 … x n ⏟ n \underbrace{x_1x_2\ldots x_n}_{n} n x1x2xn\underbrace{x_1x_2\ldots x_n}_{n}

注:大尺寸的()和[]是可以根据公式的高度自动调节的,例如

\arg\min_{\theta}
\left[
    -\sum_{i=1}^{n}
    \left[
        \mathbf{y}^{(i)}\ln(h_{\theta}(\mathbf{x}^{(i)})) +
        (1-\mathbf{y}^{(i)})\ln(1-h_{\theta}(\mathbf{x}^{(i)}))
    \right]
\right]

arg ⁡ min ⁡ θ [ − ∑ i = 1 n [ y ( i ) ln ⁡ ( h θ ( x ( i ) ) ) + ( 1 − y ( i ) ) ln ⁡ ( 1 − h θ ( x ( i ) ) ) ] ] \arg\min_{\theta} \left[ -\sum_{i=1}^{n} \left[ \mathbf{y}^{(i)}\ln(h_{\theta}(\mathbf{x}^{(i)})) + (1-\mathbf{y}^{(i)})\ln(1-h_{\theta}(\mathbf{x}^{(i)})) \right] \right] argθmin[i=1n[y(i)ln(hθ(x(i)))+(1y(i))ln(1hθ(x(i)))]]

可以看出,括号高度可以框住整个公式

因此在这种大型的公式中,使用大尺寸括号视觉效果更美观

其他常见符号

符号语法符号语法符号语法
∀ \forall \forall ∃ \exist \exist ∠ \angle \angle
∅ \emptyset \emptyset ∂ \partial \partial ∞ \infty \infty
… \ldots \ldots ⋯ \cdots \cdots … \dots \dots
⋮ \vdots \vdots ⋱ \ddots \ddots ′ \prime \prime
∵ \because \because ∴ \therefore \therefore □ \Box \Box
△ \triangle \triangle § \S §\S

数学公式写法

上下标

  • ^:上标
  • _:下标

例如:

  • \sum_{i=1}^{n}X_n表示 ∑ i = 1 n X n \sum_{i=1}^{n}X_n i=1nXn
  • \int_{0}^{\infty}x^2dx表示 ∫ 0 ∞ x 2 d x \int_{0}^{\infty}x^2dx 0x2dx
  • \prod_{i=1}^{n}X_n表示 ∏ i = 1 n X n \prod_{i=1}^{n}X_n i=1nXn

分数

使用\frac{}{}即可,例如\frac{a}{b}表示 a b \frac{a}{b} ba

插入文字

使用\text,例如\text{hello,world!}表示 hello,world! \text{hello,world!} hello,world!

常见函数

函数语法函数语法函数语法
log ⁡ ( ) \log() log()\log() ln ⁡ ( ) \ln() ln()\ln() lg ⁡ ( ) \lg() lg()\lg()
max ⁡ \max max\max min ⁡ \min min\min lim ⁡ x → ∞ \lim_{x \to \infty} limx\lim_{x \to \infty}
arg ⁡ max ⁡ c ∈ C \arg\max_{c \in C} argmaxcC\arg\max_{c \in C} arg ⁡ min ⁡ c ∈ C \arg\min_{c \in C} argmincC\arg\min_{c \in C} exp ⁡ \exp exp\exp

矩阵、行列式

&表示分隔元素,\\表示换行

A=
\begin{pmatrix}
a_{11} & a_{12} \\
a_{21} & a_{22}
\end{pmatrix}

A = ( a 11 a 12 a 21 a 22 ) A= \begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix} A=(a11a21a12a22)

A=
\begin{bmatrix}
a_{11} & a_{12} \\
a_{21} & a_{22}
\end{bmatrix}

A = [ a 11 a 12 a 21 a 22 ] A= \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} A=[a11a21a12a22]

A=
\begin{Bmatrix}
a_{11} & a_{12} \\
a_{21} & a_{22}
\end{Bmatrix}

A = { a 11 a 12 a 21 a 22 } A= \begin{Bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{Bmatrix} A={a11a21a12a22}

A=
\begin{vmatrix}
a_{11} & a_{12} \\
a_{21} & a_{22}
\end{vmatrix}

A = ∣ a 11 a 12 a 21 a 22 ∣ A= \begin{vmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{vmatrix} A= a11a21a12a22

A=
\begin{Vmatrix}
a_{11} & a_{12} \\
a_{21} & a_{22}
\end{Vmatrix}

A = ∥ a 11 a 12 a 21 a 22 ∥ A= \begin{Vmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{Vmatrix} A= a11a21a12a22

A=
\begin{matrix}
a_{11} & a_{12} \\
a_{21} & a_{22}
\end{matrix}

A = a 11 a 12 a 21 a 22 A= \begin{matrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{matrix} A=a11a21a12a22

多行公式对齐

使用\begin{split} \end{split},在需要对齐的地方添加&符号,注意需要用\\来换行。

例如:

\begin{split}
L(\theta)
&=	\arg\max_{\theta}\ln(P_{All})\\
&=	\arg\max_{\theta}\ln\prod_{i=1}^{n}
    \left[
        (h_{\theta}(\mathbf{x}^{(i)}))^{\mathbf{y}^{(i)}}\cdot
        (1-h_{\theta}(\mathbf{x}^{(i)}))^{1-\mathbf{y}^{(i)}}
    \right]\\
&=	\arg\max_{\theta}\sum_{i=1}^{n}
	\left[
		\mathbf{y}^{(i)}\ln(h_{\theta}(\mathbf{x}^{(i)})) +
		(1-\mathbf{y}^{(i)})\ln(1-h_{\theta}(\mathbf{x}^{(i)}))
	\right]\\
&=	\arg\min_{\theta}
	\left[
        -\sum_{i=1}^{n}
        \left[
            \mathbf{y}^{(i)}\ln(h_{\theta}(\mathbf{x}^{(i)})) +
            (1-\mathbf{y}^{(i)})\ln(1-h_{\theta}(\mathbf{x}^{(i)}))
        \right]
	\right]\\
&=	\arg\min_{\theta}\mathscr{l}(\theta)
\end{split}

L ( θ ) = arg ⁡ max ⁡ θ ln ⁡ ( P A l l ) = arg ⁡ max ⁡ θ ln ⁡ ∏ i = 1 n [ ( h θ ( x ( i ) ) ) y ( i ) ⋅ ( 1 − h θ ( x ( i ) ) ) 1 − y ( i ) ] = arg ⁡ max ⁡ θ ∑ i = 1 n [ y ( i ) ln ⁡ ( h θ ( x ( i ) ) ) + ( 1 − y ( i ) ) ln ⁡ ( 1 − h θ ( x ( i ) ) ) ] = arg ⁡ min ⁡ θ [ − ∑ i = 1 n [ y ( i ) ln ⁡ ( h θ ( x ( i ) ) ) + ( 1 − y ( i ) ) ln ⁡ ( 1 − h θ ( x ( i ) ) ) ] ] = arg ⁡ min ⁡ θ l ( θ ) \begin{split} L(\theta) &= \arg\max_{\theta}\ln(P_{All})\\ &= \arg\max_{\theta}\ln\prod_{i=1}^{n} \left[ (h_{\theta}(\mathbf{x}^{(i)}))^{\mathbf{y}^{(i)}}\cdot (1-h_{\theta}(\mathbf{x}^{(i)}))^{1-\mathbf{y}^{(i)}} \right]\\ &= \arg\max_{\theta}\sum_{i=1}^{n} \left[ \mathbf{y}^{(i)}\ln(h_{\theta}(\mathbf{x}^{(i)})) + (1-\mathbf{y}^{(i)})\ln(1-h_{\theta}(\mathbf{x}^{(i)})) \right]\\ &= \arg\min_{\theta} \left[ -\sum_{i=1}^{n} \left[ \mathbf{y}^{(i)}\ln(h_{\theta}(\mathbf{x}^{(i)})) + (1-\mathbf{y}^{(i)})\ln(1-h_{\theta}(\mathbf{x}^{(i)})) \right] \right]\\ &= \arg\min_{\theta}\mathscr{l}(\theta) \end{split} L(θ)=argθmaxln(PAll)=argθmaxlni=1n[(hθ(x(i)))y(i)(1hθ(x(i)))1y(i)]=argθmaxi=1n[y(i)ln(hθ(x(i)))+(1y(i))ln(1hθ(x(i)))]=argθmin[i=1n[y(i)ln(hθ(x(i)))+(1y(i))ln(1hθ(x(i)))]]=argθminl(θ)

上例中,在=前添加了&,因此实现等号对齐

\begin{split} \end{split}语法默认为右对齐,也就是说如果不在任何地方添加&符号,则公式默认右侧对齐,例如:

\begin{split}
L(\theta)
=	\arg\max_{\theta}\ln(P_{All})\\
=	\arg\max_{\theta}\ln\prod_{i=1}^{n}
    \left[
        (h_{\theta}(\mathbf{x}^{(i)}))^{\mathbf{y}^{(i)}}\cdot
        (1-h_{\theta}(\mathbf{x}^{(i)}))^{1-\mathbf{y}^{(i)}}
    \right]\\
=	\arg\max_{\theta}\sum_{i=1}^{n}
	\left[
		\mathbf{y}^{(i)}\ln(h_{\theta}(\mathbf{x}^{(i)})) +
		(1-\mathbf{y}^{(i)})\ln(1-h_{\theta}(\mathbf{x}^{(i)}))
	\right]\\
=	\arg\min_{\theta}
	\left[
        -\sum_{i=1}^{n}
        \left[
            \mathbf{y}^{(i)}\ln(h_{\theta}(\mathbf{x}^{(i)})) +
            (1-\mathbf{y}^{(i)})\ln(1-h_{\theta}(\mathbf{x}^{(i)}))
        \right]
	\right]\\
=	\arg\min_{\theta}\mathscr{l}(\theta)
\end{split}

上述LATEX代码没有添加&符号,则公式右对齐:
L ( θ ) = arg ⁡ max ⁡ θ ln ⁡ ( P A l l ) = arg ⁡ max ⁡ θ ln ⁡ ∏ i = 1 n [ ( h θ ( x ( i ) ) ) y ( i ) ⋅ ( 1 − h θ ( x ( i ) ) ) 1 − y ( i ) ] = arg ⁡ max ⁡ θ ∑ i = 1 n [ y ( i ) ln ⁡ ( h θ ( x ( i ) ) ) + ( 1 − y ( i ) ) ln ⁡ ( 1 − h θ ( x ( i ) ) ) ] = arg ⁡ min ⁡ θ [ − ∑ i = 1 n [ y ( i ) ln ⁡ ( h θ ( x ( i ) ) ) + ( 1 − y ( i ) ) ln ⁡ ( 1 − h θ ( x ( i ) ) ) ] ] = arg ⁡ min ⁡ θ l ( θ ) \begin{split} L(\theta) = \arg\max_{\theta}\ln(P_{All})\\ = \arg\max_{\theta}\ln\prod_{i=1}^{n} \left[ (h_{\theta}(\mathbf{x}^{(i)}))^{\mathbf{y}^{(i)}}\cdot (1-h_{\theta}(\mathbf{x}^{(i)}))^{1-\mathbf{y}^{(i)}} \right]\\ = \arg\max_{\theta}\sum_{i=1}^{n} \left[ \mathbf{y}^{(i)}\ln(h_{\theta}(\mathbf{x}^{(i)})) + (1-\mathbf{y}^{(i)})\ln(1-h_{\theta}(\mathbf{x}^{(i)})) \right]\\ = \arg\min_{\theta} \left[ -\sum_{i=1}^{n} \left[ \mathbf{y}^{(i)}\ln(h_{\theta}(\mathbf{x}^{(i)})) + (1-\mathbf{y}^{(i)})\ln(1-h_{\theta}(\mathbf{x}^{(i)})) \right] \right]\\ = \arg\min_{\theta}\mathscr{l}(\theta) \end{split} L(θ)=argθmaxln(PAll)=argθmaxlni=1n[(hθ(x(i)))y(i)(1hθ(x(i)))1y(i)]=argθmaxi=1n[y(i)ln(hθ(x(i)))+(1y(i))ln(1hθ(x(i)))]=argθmin[i=1n[y(i)ln(hθ(x(i)))+(1y(i))ln(1hθ(x(i)))]]=argθminl(θ)

如果希望左对齐,例如

\begin{split}
&\ln h_{\theta}(\mathbf{x}^{(i)})
=	\ln\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}}
= 	-\ln(1+e^{\theta^T \mathbf{x}^{(i)}})\\
&\ln(1-h_{\theta}(\mathbf{x}^{(i)}))
=	\ln(1-\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}})
= 	-\theta^T \mathbf{x}^{(i)}-\ln(1+e^{\theta^T \mathbf{x}^{(i)}})
\end{split}

ln ⁡ h θ ( x ( i ) ) = ln ⁡ 1 1 + e − θ T x ( i ) = − ln ⁡ ( 1 + e θ T x ( i ) ) ln ⁡ ( 1 − h θ ( x ( i ) ) ) = ln ⁡ ( 1 − 1 1 + e − θ T x ( i ) ) = − θ T x ( i ) − ln ⁡ ( 1 + e θ T x ( i ) ) \begin{split} &\ln h_{\theta}(\mathbf{x}^{(i)}) = \ln\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}} = -\ln(1+e^{\theta^T \mathbf{x}^{(i)}})\\ &\ln(1-h_{\theta}(\mathbf{x}^{(i)})) = \ln(1-\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}}) = -\theta^T \mathbf{x}^{(i)}-\ln(1+e^{\theta^T \mathbf{x}^{(i)}}) \end{split} lnhθ(x(i))=ln1+eθTx(i)1=ln(1+eθTx(i))ln(1hθ(x(i)))=ln(11+eθTx(i)1)=θTx(i)ln(1+eθTx(i))

除了\begin{split} \end{split},也可以用\begin{align} \end{align},用法与split相同,对齐方式也相同;

只有一点不同:采用align环境会默认为每一条公式编号(如下例),split则不会编号。

\begin{align}
&\ln h_{\theta}(\mathbf{x}^{(i)})
=	\ln\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}}
	= -\ln(1+e^{\theta^T \mathbf{x}^{(i)}})\\
&\ln(1-h_{\theta}(\mathbf{x}^{(i)}))
=	\ln(1-\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}})
	= -\theta^T \mathbf{x}^{(i)}-\ln(1+e^{\theta^T \mathbf{x}^{(i)}})
\end{align}

ln ⁡ h θ ( x ( i ) ) = ln ⁡ 1 1 + e − θ T x ( i ) = − ln ⁡ ( 1 + e θ T x ( i ) ) ln ⁡ ( 1 − h θ ( x ( i ) ) ) = ln ⁡ ( 1 − 1 1 + e − θ T x ( i ) ) = − θ T x ( i ) − ln ⁡ ( 1 + e θ T x ( i ) ) \begin{align} &\ln h_{\theta}(\mathbf{x}^{(i)}) = \ln\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}} = -\ln(1+e^{\theta^T \mathbf{x}^{(i)}})\\ &\ln(1-h_{\theta}(\mathbf{x}^{(i)})) = \ln(1-\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}}) = -\theta^T \mathbf{x}^{(i)}-\ln(1+e^{\theta^T \mathbf{x}^{(i)}}) \end{align} lnhθ(x(i))=ln1+eθTx(i)1=ln(1+eθTx(i))ln(1hθ(x(i)))=ln(11+eθTx(i)1)=θTx(i)ln(1+eθTx(i))

但可以在align后加一个*号,则align环境也可以取消公式自动编号,如下:
(也就是说align*split的用法完全相同)

\begin{align*}
&\ln h_{\theta}(\mathbf{x}^{(i)})
=	\ln\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}}
	= -\ln(1+e^{\theta^T \mathbf{x}^{(i)}})\\
&\ln(1-h_{\theta}(\mathbf{x}^{(i)}))
=	\ln(1-\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}})
	= -\theta^T \mathbf{x}^{(i)}-\ln(1+e^{\theta^T \mathbf{x}^{(i)}})
\end{align*}

ln ⁡ h θ ( x ( i ) ) = ln ⁡ 1 1 + e − θ T x ( i ) = − ln ⁡ ( 1 + e θ T x ( i ) ) ln ⁡ ( 1 − h θ ( x ( i ) ) ) = ln ⁡ ( 1 − 1 1 + e − θ T x ( i ) ) = − θ T x ( i ) − ln ⁡ ( 1 + e θ T x ( i ) ) \begin{align*} &\ln h_{\theta}(\mathbf{x}^{(i)}) = \ln\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}} = -\ln(1+e^{\theta^T \mathbf{x}^{(i)}})\\ &\ln(1-h_{\theta}(\mathbf{x}^{(i)})) = \ln(1-\frac{1}{1+e^{-\theta^T \mathbf{x}^{(i)}}}) = -\theta^T \mathbf{x}^{(i)}-\ln(1+e^{\theta^T \mathbf{x}^{(i)}}) \end{align*} lnhθ(x(i))=ln1+eθTx(i)1=ln(1+eθTx(i))ln(1hθ(x(i)))=ln(11+eθTx(i)1)=θTx(i)ln(1+eθTx(i))

方程组

使用\begin{cases} \end{cases}

例如:

\begin{cases}
    \begin{split}
        p &= P(y=1|\mathbf{x})=
        	\frac{1}{1+e^{-\theta^T\mathbf{X}}}\\
        1-p &= P(y=0|\mathbf{x})=1-P(y=1|\mathbf{x})=
        	\frac{1}{1+e^{\theta^T\mathbf{X}}}
    \end{split}
\end{cases}

{ p = P ( y = 1 ∣ x ) = 1 1 + e − θ T X 1 − p = P ( y = 0 ∣ x ) = 1 − P ( y = 1 ∣ x ) = 1 1 + e θ T X \begin{cases} \begin{split} p &= P(y=1|\mathbf{x})= \frac{1}{1+e^{-\theta^T\mathbf{X}}}\\ 1-p &= P(y=0|\mathbf{x})=1-P(y=1|\mathbf{x})= \frac{1}{1+e^{\theta^T\mathbf{X}}} \end{split} \end{cases} p1p=P(y=1∣x)=1+eθTX1=P(y=0∣x)=1P(y=1∣x)=1+eθTX1

注意LATEX语法可以嵌套使用,上例即为\begin{cases} \end{cases}下嵌套了begin{split} \end{split}

也可以将公式和文字结合起来,例如:

\text{Decision Boundary}=
\begin{cases}
    1\quad \text{if }\ \hat{y}>0.5\\
    0\quad \text{otherwise}
\end{cases}

Decision Boundary = { 1 if y ^ > 0.5 0 otherwise \text{Decision Boundary}= \begin{cases} 1\quad \text{if}\quad \hat{y}>0.5\\ 0\quad \text{otherwise} \end{cases} Decision Boundary={1ify^>0.50otherwise
注:\quad表示空格。

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐