\section{Question1}\label{question1}\subsection{问题}\label{ux95eeux9898}\begin{quote}
The random variable \(X\) has the probability distribution shown in the
table.
\end{quote}\begin{longtable}[]{@{}llll@{}}\toprule\(x\)& 2 & 4 & 6\tabularnewline\midrule\endhead\(P\left( X = x \right)\)& 0.5 & 0.4 & 0.1\tabularnewline\bottomrule\end{longtable}
Two \emph{independent} values of \(X\) are chosen at random. The random
variable \(Y\) takes the value s of \(X\) are the same. Otherwise the
value of \(Y\) is the larger value of \(X\) minus the smaller value of
\(X\).
(i) Draw up the probability distribution table for \(Y\).
(ii) Find the expected value of \(Y\).
\subsection{关键字}\label{ux5173ux952eux5b57}\begin{quote}
独立 可能性 期待
\end{quote}\subsection{翻译}\label{ux7ffbux8bd1}\begin{quote}
随机变量X 可能的分布情况如下所示。
\end{quote}\subsection{选项}\label{ux9009ux9879}\begin{enumerate}\def\labelenumi{\Alph{enumi}.}\item
21+ \(f(x)\)\item
22
\item
23
\end{enumerate}\subsection{答案}\label{ux7b54ux6848}
A
\subsection{提示}\label{ux63d0ux793a}
参考统计学的平均数公式。
期望值公式。
\subsection{解析}\label{ux89e3ux6790}
(i)
\begin{longtable}[]{@{}llll@{}}\toprule\(r\)& 0 & 2 & 4\tabularnewline\midrule\endhead\(P(Y = r)\)& 0.42 & 0.48 & 0.1\tabularnewline\bottomrule\end{longtable}\(P\left( Y = 0 \right) = 0.5 \times 0.5 + 0.4 \times 0.4 + 0.1 \times 0.1 = 0.42\)\textbackslash{}\textbackslash{}\(P\left( Y = 2 \right) = 0.5 \times 0.4 \times 2 + 0.4 \times 0.1 \times 2 = 0.48\)\(P\left( Y = 4 \right) = 0.5 \times 0.1 \times 2 = 0.1\)
(ii) \(\left( Y \right) = 0 \times 0.42 + 2 \times 0.48 + 4 \times 0.1\)\textbackslash{}\textbackslash{}\(= 1.36\)\subsection{结束}\label{ux7ed3ux675f}
我在这里约定了一些格式,用来判定问题。最后提取的正则表达式为。
var regx = /\\subsection{问题}\\label.*\n?((\s|\S)*?)\\subsection{关键字}/;
var regxKey = /\\subsection{关键字}\\label.*\n?((\s|\S)*?)\\subsection{翻译}/;
var regxTrans = /\\subsection{翻译}\\label.*\n?((\s|\S)*?)\\subsection{选项}/;
var regxChoice =/\\subsection{选项}\\label.*\n?((\s|\S)*?)\\subsection{答案}/;
var regxAnswer = /\\subsection{答案}\\label.*\n?((\s|\S)*?)\\subsection{提示}/;
var regxHint = /\\subsection{提示}\\label.*\n?((\s|\S)*?)\\subsection{解析}/;
var regxStep = /\\subsection{解析}\\label.*\n?((\s|\S)*?)\\subsection{结束}/;
使用pandoc先转化docx文件。pandoc -f docx -t latex -o t33.txt testAp.docx提取出的txt格式是这样的\section{Question1}\label{question1}\subsection{问题}\label{ux95eeux9898}\begin{quote}The random variable \(X\) has the proba