如何使用矩陣使頂部和底部空間相同

如何使用矩陣使頂部和底部空間相同

我嘗試過:

\documentclass{article}
\usepackage{amsmath}%amssymb,
\usepackage{bm}
\begin{document}

Outputs to machine learning models are also often represented as vectors. For instance, consider an object recognition model that takes an image as input and emits a set of numbers indicating the probabilities that the image contains a  dog, human, or cat, respectively.  The output of such a model is a three element vector $\vec{y} = \begin{bmatrix}y_{0}\\y_{1}\\y_{2}\\\dfrac{1}{2}\end{bmatrix}$, where the number $y_{0}$ denotes the probability that the image contains a dog, $y_{1}$ denotes the~probability that the image contains a human, and $y_{2}$ denotes the probability that the image contains a cat. Figure~\ref{fig:vec_out} shows some possible input images and corresponding output vectors.
\begin{align*}
p\left( x \right)
&= \overbrace{ \pi_{1}}^{0.33}\mathcal{N}\left( \vec{x}; \, \overbrace{ \vec{\mu}_{1} }^{\begin{bmatrix}
152\\55
\end{bmatrix}} \overbrace{ \bm{\Sigma}_{1}}^{ \begin{bmatrix}
20 &0\\0 &28
\end{bmatrix} } \right)
+ \overbrace{ \pi_{2} }^{0.33} \mathcal{N}\left(\vec{x}; \, \overbrace{ \vec{\mu}_{2}  }^{  \begin{bmatrix}
175\\70
\end{bmatrix}  }, \overbrace{ \bm{\Sigma}_{2}}^{ \begin{bmatrix}
35 & 39\\39 & 51
\end{bmatrix} } \right)\\
&+ \overbrace{ \pi_{3} }^{0.33} \mathcal{N}\left(\vec{x}; \, \overbrace{ \vec{\mu}_{3} }^{  \begin{bmatrix}
135\\40
\end{bmatrix} }, \overbrace{ \bm{\Sigma}_{3}}^{ \begin{bmatrix}
10 & 0\\0 & 10
\end{bmatrix} } \right)
\end{align*}

\end{document}

產生的輸出為:

在此輸入影像描述

如何使矩陣頂部和底部的空間相等?請指教

另外,如果有人解釋為什麼會發生這種情況,那就更有幫助了。

答案1

我不確定這是否是您想要的,但您可以將每個部分的內容用\vcenter{\hbox{$ ... $}}.

在此輸入影像描述

\documentclass{article}
\usepackage{amsmath}%amssymb,
\usepackage{bm}
\begin{document}

\begin{align*}
p\left( x \right)
&= \overbrace{ \pi_{1}}^{0.33}\mathcal{N}\left(\vcenter{\hbox{$ \vec{x}; \, \overbrace{ \vec{\mu}_{1} }^{\begin{bmatrix}
152\\55
\end{bmatrix}} \overbrace{ \bm{\Sigma}_{1}}^{ \begin{bmatrix}
20 &0\\0 &28
\end{bmatrix} } $}}\right)
+ \overbrace{ \pi_{2} }^{0.33} \mathcal{N}\left(\vcenter{\hbox{$ \vec{x}; \, \overbrace{ \vec{\mu}_{2}  }^{  \begin{bmatrix}
175\\70
\end{bmatrix}  }, \overbrace{ \bm{\Sigma}_{2}}^{ \begin{bmatrix}
35 & 39\\39 & 51
\end{bmatrix} } $}}\right)\\
&+ \overbrace{ \pi_{3} }^{0.33} \mathcal{N}\left(\vcenter{\hbox{$ \vec{x}; \, \overbrace{ \vec{\mu}_{3} }^{  \begin{bmatrix}
135\\40
\end{bmatrix} }, \overbrace{ \bm{\Sigma}_{3}}^{ \begin{bmatrix}
10 & 0\\0 & 10
\end{bmatrix} } $}}\right)
\end{align*}

\end{document}

答案2

您已經收到了一個很好的答案,但我強烈建議您不要這樣做\overbrace

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}

\begin{document}

Outputs to machine learning models are also often represented as vectors. 
For instance, consider an object recognition model that takes an image as 
input and emits a set of numbers indicating the probabilities that the 
image contains a  dog, human, or cat, respectively.  The output of such 
a model is a three element vector
$\vec{y} = [\begin{matrix}y_{0} & y_{1} & y_{2} & \frac{1}{2}\end{matrix}]^T$, 
where the number $y_{0}$ denotes the probability that the image contains a dog, 
$y_{1}$ denotes the~probability that the image contains a human, and $y_{2}$ 
denotes the probability that the image contains a cat. Figure~\ref{fig:vec_out} 
shows some possible input images and corresponding output vectors.
\begin{gather*}
p(x) = \pi_{1} \mathcal{N} ( \vec{x}; \, \vec{\mu}_{1}, \bm{\Sigma}_{1})
     + \pi_{2} \mathcal{N} ( \vec{x}; \, \vec{\mu}_{2}, \bm{\Sigma}_{2})
     + \pi_{3} \mathcal{N} ( \vec{x}; \, \vec{\mu}_{3}, \bm{\Sigma}_{3})
\\[1ex]
\begin{aligned}
\pi_1&=0.33 & \pi_2&=0.33 & \pi_3&=0.33
\\
\vec{\mu}_{1}&=\begin{bmatrix} 152 \\ 55 \end{bmatrix}, &
\vec{\mu}_{2}&=\begin{bmatrix} 175 \\ 70 \end{bmatrix}, &
\vec{\mu}_{3}&=\begin{bmatrix} 135 \\ 40 \end{bmatrix}
\\
\bm{\Sigma}_{1}&=\begin{bmatrix} 20 &  0 \\  0 & 28 \end{bmatrix}, &
\bm{\Sigma}_{2}&=\begin{bmatrix} 35 & 39 \\ 39 & 51 \end{bmatrix}, &
\bm{\Sigma}_{3}&=\begin{bmatrix} 10 &  0 \\  0 & 10 \end{bmatrix}
\end{aligned}
\end{gather*}

\end{document}

請注意,列向量被寫為行向量的轉置,這避免了行之間的間隙。

在此輸入影像描述

使用替代對齊方式

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}

\begin{document}

Outputs to machine learning models are also often represented as vectors. 
For instance, consider an object recognition model that takes an image as 
input and emits a set of numbers indicating the probabilities that the 
image contains a  dog, human, or cat, respectively.  The output of such 
a model is a three element vector
$\vec{y} = [\begin{matrix}y_{0} & y_{1} & y_{2} & \frac{1}{2}\end{matrix}]^T$, 
where the number $y_{0}$ denotes the probability that the image contains a dog, 
$y_{1}$ denotes the~probability that the image contains a human, and $y_{2}$ 
denotes the probability that the image contains a cat. Figure~\ref{fig:vec_out} 
shows some possible input images and corresponding output vectors.
\begin{alignat*}{3}
p(x) = \pi_{1} &\mathcal{N} ( \vec{x}; \, \vec{\mu}_{1}, \bm{\Sigma}_{1})
     &{}+ \pi_{2} &\mathcal{N} ( \vec{x}; \, \vec{\mu}_{2}, \bm{\Sigma}_{2})
     &{}+ \pi_{3} &\mathcal{N} ( \vec{x}; \, \vec{\mu}_{3}, \bm{\Sigma}_{3})
\\[1ex]
\pi_1&=0.33 & \pi_2&=0.33 & \pi_3&=0.33
\\
\vec{\mu}_{1}&=\begin{bmatrix} 152 \\ 55 \end{bmatrix}, &
\vec{\mu}_{2}&=\begin{bmatrix} 175 \\ 70 \end{bmatrix}, &
\vec{\mu}_{3}&=\begin{bmatrix} 135 \\ 40 \end{bmatrix}
\\
\bm{\Sigma}_{1}&=\begin{bmatrix} 20 &  0 \\  0 & 28 \end{bmatrix}, &
\bm{\Sigma}_{2}&=\begin{bmatrix} 35 & 39 \\ 39 & 51 \end{bmatrix}, &
\bm{\Sigma}_{3}&=\begin{bmatrix} 10 &  0 \\  0 & 10 \end{bmatrix}
\end{alignat*}

\end{document}

在此輸入影像描述

為了完整起見,以下是完成建議任務的方法。我留下了一個大的內聯列向量,以展示為什麼它真的很糟糕。

比較輸出我毫無疑問。

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{delarray}

\begin{document}

Outputs to machine learning models are also often represented as vectors. 
For instance, consider an object recognition model that takes an image as 
input and emits a set of numbers indicating the probabilities that the 
image contains a  dog, human, or cat, respectively.  The output of such 
a model is a three element vector
$\vec{y} = \begin{bmatrix}y_{0} \\ y_{1} \\ y_{2} \\ \dfrac{1}{2}\end{bmatrix}$, 
where the number $y_{0}$ denotes the probability that the image contains a dog, 
$y_{1}$ denotes the~probability that the image contains a human, and $y_{2}$ 
denotes the probability that the image contains a cat. Figure~\ref{fig:vec_out} 
shows some possible input images and corresponding output vectors.
\begin{equation*}
\begin{aligned}
p(x)
&= \overbrace{ \pi_{1}}^{0.33}\mathcal{N}
\begin{array}[b]({c})
\vec{x}; \, \overbrace{ \vec{\mu}_{1} }^{\begin{bmatrix}
152\\55
\end{bmatrix}} \overbrace{ \bm{\Sigma}_{1}}^{ \begin{bmatrix}
20 &0\\0 &28
\end{bmatrix} }
\end{array}
+ \overbrace{ \pi_{2} }^{0.33} \mathcal{N}
\begin{array}[b]({c})
\vec{x}; \, \overbrace{ \vec{\mu}_{2}  }^{  \begin{bmatrix}
175\\70
\end{bmatrix}  }, \overbrace{ \bm{\Sigma}_{2}}^{ \begin{bmatrix}
35 & 39\\39 & 51
\end{bmatrix} }
\end{array}\\
&+ \overbrace{ \pi_{3} }^{0.33} \mathcal{N}
\begin{array}[b]({c})\vec{x}; \, \overbrace{ \vec{\mu}_{3} }^{  \begin{bmatrix}
135\\40
\end{bmatrix} }, \overbrace{ \bm{\Sigma}_{3}}^{ \begin{bmatrix}
10 & 0\\0 & 10
\end{bmatrix} }
\end{array}
\end{aligned}
\end{equation*}

\end{document}

在此輸入影像描述

答案3

\left( ... \right)將的三個實例替換為 就足夠了\bigl( ... \bigr)。請注意,由於較大\overbrace結構的第二個參數是解釋性的而不是定義性的,因此它們不需要包含在(現在不再很高)括號中。

哦,除非您想特別關注環境\vec{y}前面段落中的定義align*,否則我會將其寫為行向量而不是列向量。

在此輸入影像描述

\documentclass{article}
\usepackage{amsmath,amssymb,bm}
\begin{document}

Outputs to machine learning models are also often represented as vectors. For instance, consider an object recognition model that takes an image as input and emits a set of numbers indicating the probabilities that the image contains a  dog, human, or cat, respectively.  The output of such a model is a three element vector
$\vec{y} = \begin{bmatrix} y_{0} & y_{1} & y_{2} \end{bmatrix}'$, 
where the number $y_{0}$ denotes the probability that the image contains a dog, $y_{1}$ denotes the~probability that the image contains a human, and $y_{2}$ denotes the probability that the image contains a cat. Figure~\ref{fig:vec_out} shows some possible input images and corresponding output vectors.
\begin{align*}
p(x)
&=\overbrace{ \pi_{1}\mathstrut}^{0.33}\mathcal{N}
  \bigl( \vec{x};  
  \overbrace{ \vec{\mu}_{1} }^{
      \begin{bmatrix} 152\\55 \end{bmatrix}} ,
  \overbrace{ \bm{\Sigma}_{1}}^{ 
      \begin{bmatrix} 20 &0\\0 &28 \end{bmatrix} } 
  \bigr)
 +\overbrace{ \pi_{2}\mathstrut}^{0.33} \mathcal{N}
  \bigl(\vec{x};  
  \overbrace{ \vec{\mu}_{2}  }^{  
      \begin{bmatrix} 175\\70 \end{bmatrix}  }, 
  \overbrace{ \bm{\Sigma}_{2}}^{ 
      \begin{bmatrix} 35 & 39\\39 & 51 \end{bmatrix} } 
  \bigr) 
  \\[2\jot] % insert a bit more vertical whitespace
&\quad+\overbrace{ \pi_{3}\mathstrut}^{0.33} \mathcal{N}
 \bigl(\vec{x};  
 \overbrace{ \vec{\mu}_{3} }^{  
     \begin{bmatrix} 135\\40 \end{bmatrix} }, 
 \overbrace{ \bm{\Sigma}_{3}}^{ 
     \begin{bmatrix} 10 & 0\\0 & 10 \end{bmatrix} } 
 \bigr)
\end{align*}

\end{document}

相關內容