3

I'm using Oveleaf and LaTeX for the first time at the moment for a uni assignment.

As you can see from my code I have each subsection in there once but when I look at the PDF output the subsections are duplicated and I have no idea why? I've tried googling but have had no success in figuring out why :/

Does anyone have any ideas of what I"m doing wrong?


\documentclass{article} \usepackage{amsmath} \usepackage{amssymb} \newcommand{\var}{\operatorname{Var}} \newcommand{\sd}{\operatorname{SD}} \newcommand{\bin}{\operatorname{Bin}} \newcommand{\geo}{\operatorname{Geo}} \newcommand{\bern}{\operatorname{Bern}} \newcommand{\nb}{\operatorname{NB}} \newcommand{\gam}{\operatorname{Gamma}} \newcommand{\Exp}{\operatorname{Exp}} \begin{document} \begingroup \centering \LARGE STM4PSD-T5\\ \LARGE Assignment 2 - Part 1\\[0.5em] \large \today\\[0.5em] \large Ace Taylor\par \large 22812081\par \endgroup \section{ Question 1A A fake, weighted coin has a 56 chance of flipping heads. The coin is flipped exactly 25 times. What is the expected number of tails, and what is the probability that at least 10 tails are flipped? } \section{Distribution needed: Binomial distribution Formula: $X \sim \bin(25,0.44)$ - this is because there's 0.56 chance of being heads therefore the probability of tails is 1 - probability of being heads or $1 - 0.56$ which comes to 0.44 $n = 25$ $p = 0.44$ $k = 10$ } \section{The expected number of tails = $E(X) = np$ $E(X) = 25 \times 0.44$ $E(X) = 11$ You can therefore expect 11 out of the 25 flips to land on tails} \section{Let a Successful attempt be when a tails is flipped Find: $P (X \ge 10)$ OR $1 - P(X < 10)$ Probability mass function: $P(X = k) = \binom{n}{k}p^k(1-p)^{n-k}$ Step 1. Calculate $P (X = K) for k = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9$ \[ P(X = k) = \binom{25}{k}0.44^k \times 0.56^{25 - k} \] \subsection{ For $k = 0$ $P(X = 0) = \binom{25}{0} \times 0.44 ^ 0 \times (1 - 0.44) ^ {25}$ $= \frac{25!}{25! \times 0!} \times 0.44 ^ 0 \times 0.56 ^ {25}$ $=1 \times 1 \times 0.56^{25}$ $= 0.000032$} \subsection{ for $k = 1$ $P(X = 1) = \binom{25}{1} \times 0.44 ^ 1 \times (1 - 0.44) ^ {25 - 1}$ $= \frac{25!}{24! \times 1!} \times 0.44^1 \times 0.56^{24}$ $25 \times 0.44 \times 0.000057$ $=0.000397$ } \subsection{ for $k = 2$ $P(X = 2) = \binom{25}{2} \times 0.44 ^ 2 \times (1 - 0.44) ^ {25 - 2}$ $\frac{25!}{23! \times 2!} \times 0.44 ^2 \times 0.56 ^ {23}$ $300 \times 0.1936 \times 0.000098 $ $=0.003037$ } \subsection{ for $k = 3$ $P(X = 3) = \binom{25}{3} \times 0.44 ^ 3 \times (1 - 0.44) ^ {25 - 3}$ $\frac{25!}{22! \times 3!} \times 0.44 ^ 3 \times 0.56 ^ {22}$ $2300 \times 0.085184 \times 0.00000288493$ $0.00056522642$ } } \subsection{ for $k = 4$ $P(X = 4) = \binom{25}{4} \times 0.44 ^ 4 \times (1 - 0.44) ^ {25 - 4}$ $\frac{25!}{21! \times 4!} \times 0.44 ^ 4 \times 0.56 ^ {21}$ $12650 \times 0.03748096 \times 0.00000515167$ $0.00244258264$ } \subsection{ for $k = 5$ $P(X = 5) = \binom{25}{5} \times 0.44 ^ 5 \times (1 - 0.44) ^ {25 - 5}$ $\frac{25!}{20! \times 5!} \times 0.44 ^ 5 \times 0.56 ^ {20}$ $53130 \times 0.0164916224 \times 0.00000919942$ $0.00806053086$ } \subsection{ For $k = 6$ $P(X = 6) = \binom{25}{6} \times 0.44 ^ 6 \times (1 - 0.44)^{25 - 6}$ $\frac{25!}{19! \times 6!} \times 0.44 ^ 6 \times 0.56 ^ {19}$ $177100 \times 0.00725631385 \times 0.00001642753$ $0.02111090681$ } \subsection{ for $K = 7$ $P(X = 7) = \binom{25}{7} \times 0.44 ^7 \times (1 - 0.44) ^ {25 - 7}$ $\frac{25!}{18! \times 7!} \times 0.44 ^ 7 \times 0.56 ^ {18}$ $480700 \times 0.00319277809 \times 0.00002933489$ $0.045022263$ } \end{document} 
5
  • 4
    \section should just have the title of the section in the argument, not the whole section Commented Oct 4 at 11:08
  • 4
    never ignore error messages. You get ! Paragraph ended before \@sect was complete because of the blank lines in the argument to \section. Commented Oct 4 at 11:09
  • 1
    Welcome, BTW. // As a strategy, start simple with your document, add gradually, with frequent compiles in between. This way you capture trouble early, like this one: tex.stackexchange.com/questions/752015/…. And have a good introduction to LaTeX within reach. Commented Oct 4 at 11:10
  • 1
    you also have two } rather than one, but that may or may not be picked up given the number of errors encountered by that point. Commented Oct 4 at 12:01
  • 1
    note that overleaf tries to produce a pdf no matter what. it shows you a red box with a number to indicate errors. the output is not reliable after any error. Commented Oct 4 at 12:03

1 Answer 1

2

Never ignore error messages.

Your document produces

Runaway argument? { ! Paragraph ended before \@sect was complete. <to be read again> \par l.28 ...lity that at least 10 tails are flipped? } ? 

because there are blank lines (paragraph ends) inside \section. Overleaf tries to scroll past errors and show a final pdf but any such document is only for debugging, it is not intended to be usable.

\section (and \subsection etc) take the section heading as argument, not the whole section. I am not sure you really want sections here, perhaps simply a list, but I minimised the changes and kept the sectioning, but just using the single line heading in each case. Also make use of the amsmath package that you are loading to make multi-line math displays, rather than just paragraphs with unaligned inline math.

enter image description here

\documentclass{article} \usepackage{amsmath} \usepackage{amssymb} \newcommand{\var}{\operatorname{Var}} \newcommand{\sd}{\operatorname{SD}} \newcommand{\bin}{\operatorname{Bin}} \newcommand{\geo}{\operatorname{Geo}} \newcommand{\bern}{\operatorname{Bern}} \newcommand{\nb}{\operatorname{NB}} \newcommand{\gam}{\operatorname{Gamma}} \newcommand{\Exp}{\operatorname{Exp}} \begin{document} \begingroup \centering \LARGE STM4PSD-T5\\ \LARGE Assignment 2 - Part 1\\[0.5em] \large \today\\[0.5em] \large Ace Taylor\par \large 22812081\par \endgroup \section*{Question 1A} A fake, weighted coin has a 56 chance of flipping heads. The coin is flipped exactly 25 times. What is the expected number of tails, and what is the probability that at least 10 tails are flipped? \subsection*{Distribution needed: Binomial distribution} Formula: $X \sim \bin(25,0.44)$ - this is because there's 0.56 chance of being heads therefore the probability of tails is 1 - probability of being heads or $1 - 0.56$ which comes to $0.44$ \begin{align*} n &= 25\\ p &= 0.44\\ k&= 10 \end{align*} \section*{The expected number of tails = $E(X) = np$} $E(X) = 25 \times 0.44$ $E(X) = 11$ You can therefore expect 11 out of the 25 flips to land on tails \section{*Let a Successful attempt be when a tails is flipped} Find: $P (X \ge 10)$ OR $1 - P(X < 10)$ Probability mass function: $P(X = k) = \binom{n}{k}p^k(1-p)^{n-k}$ Step 1. Calculate $P (X = K) for k = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9$ \[ P(X = k) = \binom{25}{k}0.44^k \times 0.56^{25 - k} \] \subsection*{For $k = 0$} \begin{align*} P(X = 0) &= \binom{25}{0} \times 0.44 ^ 0 \times (1 - 0.44) ^ {25}\\ &= \frac{25!}{25! \times 0!} \times 0.44 ^ 0 \times 0.56 ^ {25}\\ &=1 \times 1 \times 0.56^{25}\\ &= 0.000032 \end{align*} \subsection*{for $k = 1$} \begin{align*} P(X = 1) &= \binom{25}{1} \times 0.44 ^ 1 \times (1 - 0.44) ^ {25 - 1}\\ &= \frac{25!}{24! \times 1!} \times 0.44^1 \times 0.56^{24}\\ &=25 \times 0.44 \times 0.000057\\ &=0.000397 \end{align*} \subsection*{for $k = 2$} \begin{align*} P(X = 2) &= \binom{25}{2} \times 0.44 ^ 2 \times (1 - 0.44) ^ {25 - 2}\\ &=\frac{25!}{23! \times 2!} \times 0.44 ^2 \times 0.56 ^ {23}\\ &=300 \times 0.1936 \times 0.000098\\ &=0.003037 \end{align*} \subsection*{for $k = 3$} \begin{align*} P(X = 3) &= \binom{25}{3} \times 0.44 ^ 3 \times (1 - 0.44) ^ {25 - 3}\\ &=\frac{25!}{22! \times 3!} \times 0.44 ^ 3 \times 0.56 ^ {22}\\ &=2300 \times 0.085184 \times 0.00000288493\\ &=0.00056522642 \end{align*} \subsection*{for $k = 4$} \begin{align*} P(X = 4) &= \binom{25}{4} \times 0.44 ^ 4 \times (1 - 0.44) ^ {25 - 4}\\ &=\frac{25!}{21! \times 4!} \times 0.44 ^ 4 \times 0.56 ^ {21}\\ &=12650 \times 0.03748096 \times 0.00000515167\\ &=0.00244258264 \end{align*} \subsection*{for $k = 5$} \begin{align*} P(X = 5) &= \binom{25}{5} \times 0.44 ^ 5 \times (1 - 0.44) ^ {25 - 5}\\ &=\frac{25!}{20! \times 5!} \times 0.44 ^ 5 \times 0.56 ^ {20}\\ &=53130 \times 0.0164916224 \times 0.00000919942\\ &=0.00806053086 \end{align*} \subsection*{For $k = 6$} \begin{align*} P(X = 6) &= \binom{25}{6} \times 0.44 ^ 6 \times (1 - 0.44)^{25 - 6}\\ &=\frac{25!}{19! \times 6!} \times 0.44 ^ 6 \times 0.56 ^ {19}\\ &=177100 \times 0.00725631385 \times 0.00001642753\\ &=0.02111090681 \end{align*} \subsection*{for $K = 7$} \begin{align*} P(X = 7) &= \binom{25}{7} \times 0.44 ^7 \times (1 - 0.44) ^ {25 - 7}\\ &=\frac{25!}{18! \times 7!} \times 0.44 ^ 7 \times 0.56 ^ {18}\\ &=480700 \times 0.00319277809 \times 0.00002933489\\ &=0.045022263 \end{align*} \end{document} 
1
  • Thank you! Appreciate the help Commented Oct 5 at 0:21

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.