Report likelihoods, not p-values

[summary: If scientists reported likelihood functions instead of p-values, this could help science avoid [https://en.wikipedia.org/wiki/Data_dredging p-hacking], [https://en.wikipedia.org/wiki/Publication_bias publication bias], [https://en.wikipedia.org/wiki/Decline_effect the decline effect], and other hazards of standard statistical techniques. Furthermore, it could help make it easier to combine results from multiple studies and perfrom meta-analyses, while making statistics intuitively easier to understand. (This is a bold claim, but a claim which is largely supported by [-1bv].)]

This page advocates for a change in the way that statistics is done in standard scientific journals. The key idea is to report [56s likelihood functions] instead of p-values, and this could have many benefits.

_(Note: This page is a personal [60p opinion page].)_

[toc:]

## What's the difference?

The status quo across scientific journals is to test data for "[statistically_significant statistical significance]" using functions such as [p_value p-values]. A p-value is a number calculated from a hypothesis (called the "null hypothesis"), an experiment, a result, and a [-summary_statistic]. For example, if the null hypothesis is "this coin is fair," and the experiment is "flip it 6 times", and the result is HHHHHT, and the summary statistic is "the sequence has at least five H values," then the p-value is 0.11, which means "if the coin were fair, and we did this experiment a lot, then only 11% of the sequences generated would have at least five H values."%%note:This does _not_ mean that the coin is 89% likely to be biased! For example, if the only alternative is that the coin is biased towards tails, then HHHHHT is evidence that it's fair. This is a common source of confusion with p-values.%% If the p-value is lower than an arbitrary threshold (usually $p < 0.05$) then the result is called "statistically significant" and the null hypothesis is "rejected."

This page advocates that scientific articles should report _likelihood functions_ instead of p-values. A likelihood function for a piece of evidence $e$ is a function $\mathcal L$ which says, for each hypothesis $H$ in some set of hypotheses, the probability that $H$ assigned to $e$, written [51n $\mathcal L_e(H)$].%%note: Many authors write $\mathcal L(H \mid e)$ instead. We think this is confusing, as then $\mathcal L(H \mid e) = \mathbb P(e \mid H),$ and it's hard enough for students of statistics to keep "probability of $H$ given $e$" and "probability of $e$ given $H$" straight as it is if the notation _isn't_ swapped around every so often.%% For example, if $e$ is "this coin, flipped 6 times, generated HHHHHT", and the set of hypotheses are $H_{0.25} =$ "the coin only produces heads 25% of the time" and $H_{0.5}$ = "the coin is fair", then $\mathcal L_e(H_{0.25})$ $=$ $0.25^5 \cdot 0.75$ $\approx 0.07\%$ and $\mathcal L_e(H_{0.5})$ $=$ $0.5^6$ $\approx 1.56\%,$ for a [1rq likelihood ratio] of about $21 : 1$ in favor of the coin being fair (as opposed to biased 75% towards tails).

In fact, with a single likelihood function, we can report the amount of support $e$ gives to _every_ hypothesis $H_b$ of the form "the coin has bias $b$ towards heads":%note:To learn how this graph was generated, see [1zj Bayes' rule: Functional form].%

![](http://i.imgur.com/UwwxmCe.png)

Note that this likelihood function is _not_ telling us the probability that the coin is actually biased, it is _only_ telling us how much the evidence supports each hypothesis. For example, this graph says that HHHHHT provides about 3.8 times as much evidence for $H_{0.75}$ over $H_{0.5}$, and about 81 times as much evidence for $H_{0.75}$ over $H_{0.25}.$

Note also that the likelihood function doesn't necessarily contain the _right_ hypothesis; for example, the function above shows the support of $e$ for every possible bias on the coin, but it doesn't consider hypotheses like "the coin alternates between H and T". Likelihood functions, like p-values, are essentially a mere summary of the raw data — there is no substitute for the raw data when it comes to allowing people to test hypotheses that the original researchers did not consider. (In other words, even if you report likelihoods instead of p-values, it's still virtuous to share your raw data.)

Where p-values let you measure (roughly) how well the data supports a _single_ "null hypothesis", with an arbitrary 0.05 "not well enough" cutoff, the likelihood function shows the support of the evidence for lots and lots of different hypotheses at once, without any need for an arbitrary cutoff.

## Why report likelihoods instead of p-values?

__1. Likelihood functions are less arbitrary than p-values.__ To report a likelihood function, all you have to do is pick which hypothesis class to generate the likelihood function for. That's your only degree of freedom. This introduces one source of arbitrariness, and if someone wants to check some other hypothesis they still need access to the raw data, but it is better than the p-value case, where you only report a number for a single "null" hypothesis.

Furthermore, in the p-value case, you have to pick not only a null hypothesis but also an experiment and a summary statistic, and these degrees of freedom can have a huge impact on the final report. These extra degrees of freedom are both unnecessary ([1lz to carry out a probabilistic update, all you need are your own personal beliefs and a likelihood function]) and exploitable, and empirically, they're actively harming scientific research.

__2. Reporting likelihoods would solve p-hacking.__ If you're using p-values, then you can game the statistics via your choice of experiment and summary statistics. In the example with the coin above, if you say your experiment and summary statistic are "flip the coin 6 times and count the number of heads" then the p-value of HHHHHT with respect to $H_{0.5}$ is 0.11, whereas if you say your experiment and summary statistic are "flip the coin until it comes up tails and count the number of heads" then the p-value of HHHHHT with respect to $H_{0.5}$ is 0.03, which is "significant." This is called "[https://en.wikipedia.org/wiki/Data_dredging p-hacking]", and it's a serious problem in modern science.

In a likelihood function, _the amount of support an evidence gives to a hypothesis does not depend on which experiment the researcher had in mind._ Likelihood functions depend only on the data you actually saw, and the hypotheses you chose to report. The only way to cheat a likelihood function is to lie about the data you collected, or refuse to report likelihoods for a particular hypothesis.

If your paper fails to report likelihoods for some obvious hypotheses, then (a) that's precisely analogous to you choosing the wrong null hypothesis to consider; (b) it's just as easily noticeable as when your paper considers the wrong null hypothesis; and (c) it can be easily rectified given access to the raw data. By contrast, p-hacking can be subtle and hard to detect after the fact.

__3. Likelihood functions are very difficult to game.__ There is no analog of p-hacking for likelihood functions. This is a theorem of probability theory known as [-conservation_of_expected_evidence], which says that likelihood functions can't be gamed unless you're falsifying or omitting data (or screwing up the likelihood calculations).%note:Disclaimer: the theorem says likelihood functions can't be gamed, but we still shouldn't underestimate the guile of dishonest researchers struggling to make their results look important. Likelihood functions have not been put through the gauntlet of real scientific practice; p-values have. That said, when p-values were put through that gauntlet, they [https://en.wikipedia.org/wiki/Data_dredging failed] in a [https://en.wikipedia.org/wiki/Replication_crisis spectacular fashion]. When rebuilding, it's probably better to start from foundations that provably cannot be gamed.%

__4. Likelihood functions would help stop the "vanishing effect sizes" phenomenon.__ The [https://en.wikipedia.org/wiki/Decline_effect decline effect] occurs when studies which reject a null hypothesis $H_0$ have effect sizes that get smaller and smaller and smaller over time (the more someone tries to replicate the result). This is [http://slatestarcodex.com/2014/04/28/the-control-group-is-out-of-control/ usually evidence] that there is no actual effect, and that the initial "large effects" were a result of publication bias.

Likelihood functions help avoid the decline effect by _treating different effect sizes differently._ The likelihood function for coins of different biases shows that the evidence HHHHHT gives a different amount of support to $H_{0.52},$ $H_{0.61}$, and $H_{0.8}$ (which correspond to small, medium, and large effect sizes, respectively). If three different studies find low support for $H_{0.5},$ and one of them gives all of its support to the large effect, another gives all its support to the medium effect, and the third gives all of its support to the smallest effect, then likelihood functions reveal that something fishy is going on (because they're all peaked in different places).

If instead we only use p-values, and always decide whether or not to "keep" or "reject" the null hypothesis (without specifying how much support goes to different alternatives), then it's hard to notice that the studies are actually contradictory (and that something very fishy is going on). Instead, it's very tempting to exclaim "3 out of 3 studies reject $H_{0.5}$!" and move on.

__5. Likelihood functions would help stop publication bias.__ When using p-values, if the data yields a p-value of 0.11 using a null hypothesis $H_0$, the study is considered "insignificant," and many journals have a strong bias towards positive results. When reporting likelihood functions, there is no arbitrary "significance" threshold. A study that reports a relative likelihoods of $21 : 1$ in favor of $H_a$ vs $H_0,$ that's exactly the same _strength of evidence_ as a study that reports $21 : 1$ odds against $H_a$ vs $H_0.$ It's all just evidence, and it can all be added to the corpus, there's no arbitrary "significance" threshold.

__6. Likelihood functions make it trivially easy to combine studies.__ When combining studies that used p-values, researchers have to perform complex meta-analyses with dozens of parameters to tune, and they often find [https://en.wikipedia.org/wiki/Confirmation_bias exactly what they were expecting to find]. By contrast, the way you combine multiple studies that reported likelihood functions is... (drumroll)
...you just multiply the likelihood functions together. If study A reports that $H_{0.75}$ was favored over $H_{0.5}$ with a [-1rq] of $3.8 : 1$, and study B reports that $H_{0.75}$ was favored over $H_{0.5}$ at $5 : 1$, then the combined likelihood functions of both studies favors $H_{0.75}$ over $H_{0.5}$ at $(3.8 \cdot 5) : 1$ $=$ $19 : 1.$

Want to combine a hundred studies on the same subject? Multiply a hundred functions together. Done. No parameter tuning, no degrees of freedom through which bias can be introduced — just multiply.

__7. Likelihood functions make it obvious when something has gone wrong.__ If, when you multiply all the likelihood functions together, _all_ hypotheses have extraordinarily low likelihoods, then something has gone wrong. Either a mistake has been made somewhere, or fraud has been committed, or the true hypothesis wasn't in the hypothesis class you're considering.

The actual hypothesis that explains all the data will have decently high likelihood across all the data. If none of the hypotheses fit that description, then either you aren't considering the right hypothesis yet, or some of the studies went wrong. (Try looking for one study that has a likelihood function _very very different_ from all the other studies, and investigate that one.)

Likelihood functions won't do your science for you — you still have to generate good hypotheses, and be honest in your data reporting — but they _do_ make it obvious when something went wrong. (Specifically, [227 each hypothesis can tell you how low its likelihood is expected to be on the data], and if _every_ hypothesis has a likelihood far lower than expected, then something's fishy.)

---

A scientific community using likelihood functions would produce scientific research that's easier to use. If everyone's reporting likelihood functions, then all you personally need to do in order to figure out what to believe is take your own personal (subjective) prior probabilities and multiply them by all the likelihood functions in order to get your own personal (subjective) posterior probabilities.

For example, let's say you personally think the coin is probably fair, with $10 : 1$ odds of being fair as opposed to 75% biased in favor of heads. Now let's say that study A reports a likelihood function which favors $H_{0.75}$ over $H_{0.5}$ with a likelihood ratio of $3.8 : 1.$, and study B reports a $5 : 1$ likelihood ratio in the same direction. Multiplying all these together, your personal posterior beliefs should be $19 : 10$ in favor of $H_{0.75}$ over $H_{0.5}$. This is simply [1lz Bayes' rule]. Reporting likelihoods instead of p-values lets science remain objective, while allowing everyone to find their own personal posterior probabilities via a simple application of Bayes' theorem.

## Why should we think this would work?

This may all sound too good to be true. Can one simple change really solve that many problems in modern science?

First of all, you can be assured that reporting likelihoods instead of p-values would not "solve" all the problems above, and it would surely not solve all problems with modern experimental science. Open access to raw data, preregistration of studies, a culture that rewards replication, and many other ideas are also crucial ingredients to a scientific community that zeroes in on truth.

However, reporting likelihoods would _help_ solve lots of different problems in modern experimental science. This may come as a surprise. Aren't likelihood functions just one more statistical technique, just another tool for the toolbox? Why should we think that one single tool can solve that many problems?

The reason lies in [-1bv]. According to the axioms of probability theory, there is only one good way to account for evidence when updating your beliefs, and that way is via likelihood functions. Any other method is subject to inconsistencies and pathologies, as per the [probability_coherence_theorems coherence theorems of probability theory].

If you're manipulating equations like $2 + 2 = 4,$ and you're using methods that may or may not let you throw in an extra 3 on the right hand side (depending on the arithmetician's state of mind), then it's no surprise that you'll occasionally get yourself into trouble and deduce that $2 + 2 = 7.$ The laws of arithmetic show that there is only one correct set of tools for manipulating equations if you want to avoid inconsistency.

Similarly, the laws of probability theory show that there is only one correct set of tools for manipulating _uncertainty_ if you want to avoid inconsistency. According to [1lz those rules], the right way to represent evidence is through likelihood functions.

These laws (and a solid understanding of them) are younger than the experimental science community, and the statistical tools of that community predate a modern understanding of probability theory. Thus, it makes a lot of sense that the existing literature uses different tools. However, now that humanity _does_ possess a solid understanding of probability theory, it should come as no surprise that many diverse pathologies in statistics can be cleaned up by switching to a policy of reporting likelihoods instead of p-values.

## What are the drawbacks?

The main drawback is inertia. Experimental science today reports p-values almost entirely across the board. Modern statistical toolsets have built-in support for p-values (and other related statistical tools) but very little support for reporting likelihood functions. Experimental scientists are trained mainly in [-frequentist_statistics], and thus most are much more familiar with p-value-type tools than likelihood-function-type tools. Making the switch would be painful.

Barring the switching costs, though, making the switch could well be a strict improvement over modern techniques, and would help solve some of the biggest [http://slatestarcodex.com/2014/04/28/the-control-group-is-out-of-control/ problems] [http://www.stat.columbia.edu/~gelman/research/published/asa_pvalues.pdf facing] [https://en.wikipedia.org/wiki/Data_dredging science] [https://en.wikipedia.org/wiki/Publication_bias today].

See also the [505 Likelihoods not p-values FAQ] and [4xx].


Cyclic Group Intro (Math 0)

[summary: Every [-finite] **cyclic [-3gd group]** can be thought of like a clock (except maybe with more or less numbers than twelve). Every [-infinite] cyclic group can be thought of as the [48l integers].]

##Clocks##
Say we had a clock. We decide that we can "add" two numbers on the clock starting at the first number, then moving by the number of steps given by the second number. For example the sum of $5$ and $6$ is given by starting at $5$, and then moving by $6$ spaces, and ending up at $11$. But the sum of $7$ and $9$ is given by starting at $7$ and moving $9$ spaces to end up at $4$. This number can be calculated by just adding the numbers normally, then if you end up at more than $12$, subtract $12$. For example, $7+9 = 16$, and $16- 12 = 4$.

Notice that if you add $12$ to anything, you just go once around the clock, and so ending up not doing anything. You can calculate it with $4$ as $4 + 12 = 16$, and $16 - 12 = 4$. Hence $12$ is the [-54p] for our clock. Hmm, usually the identity should be something like $0$. More on this in a moment.

Also, notice that no matter where you are on the clock, there's always an amount by which you can turn to end up at $12$. For example, if you are at $5$, you can add $7$ to get to $12$. This is called the [-inverse_mathematics inverse]. This number can easily be calculated by subtracting your number from $12$. For example, $12 - 5 = 7$ so the inverse of $5$ is $7$. Now what if we calculate the inverse of $12$? Then we get $0$. In fact, $12$ and $0$ are the same thing on our clock. Actually, we may as well scratch the $12$ off of our clock-face and just write $0$. It makes things a lot easier. Now, instead of considering $12$ the identity, we can consider $0$ the identity instead. If we are at any number, and we step $0$ times (in other words, we don't step at all), then we stay at the number we were.

Notice now that instead of saying when we add $5$  and $7$ on our clock we get $12$, we actually want to say we get $0$. So now we change our rule at the top a little bit. To calculate the sum of two numbers, we add them, and if we get $12$ *or more* we subtract $12$. So now $4$ plus $2$ is still $6$, and $7$ plus $9$ is still obtained by calculating $7+9 = 16$ and $16-12 = 4$. But now, instead of calculating that $7 +5 = 12$ we now further calculate that $12 - 12 = 0$ and so say that $7$ plus $5$ is $0$ on our clock.

Our clock is [-3gy closed] under its addition, it has an [-54p] and [-inverse_mathematics inverses]. Hence, our clock is a [-3gd group]. From here on out we can write our group [-operation_mathematics operation] as $\bullet$. So $7 \bullet 9 = 4$.

Now, there is no reason our clock needs to have $12$ numbers. We could do exactly the same with, say, $15$ numbers. Then our operation is defined by adding the numbers, and if they add up to at least $15$, we subtract $15$. Now $5 \bullet 7 = 12$ but $7 \bullet 9 = 1$ since $7 + 9 = 16$ and $16 - 15 = 1$. Notice that now the inverse of $5$ is not $7$, but is instead found by calculating $15 - 5 = 10$. So the inverse of $5$ is $10$ (since $5 + 10 = 15$, so $5 \bullet 10 = 0$).

We can write our inverses by adding a negative sign to the front of the number. So on our $15$ number clock, the inverse of $5$ is written $-5$ and so $-5 = 10$, but on our normal clock, the inverse of $5$ is $7$ so $-5 = 7$.

##Cyclic Groups##

This motivates the term **cyclic**; if we go far enough, we get back to where we started. In fact, a group is called cyclic if it has a singe [-generator_mathematics generator]. This is an element that can be used to generate all the other elements by being added to itself enough times. On any  clock, the generator is $1$. We can get any number by going $1 \bullet 1 \bullet 1 \bullet \cdots \bullet 1$ the right number of times.

Technically, for mathematical reasons, we actually want to require that we can get every element even if we combine the generator with itself a *negative* number of times. What does this mean? Well, the generator $1$ has an inverse $-1$. In our normal clock $-1 = 11$. In our $15$ number clock $-1 = 14$. The point is that we could just as well get all the numbers by adding $-1$ to itself a bunch of times.

We can also get $0$ by "not adding $1$ to itself at all" or, put another way "adding $1$ to itself $0$ times". This may seem strange, but if you think of taking $1$, and then adding $-1$ once, it's like not taking $1$ at all and you get $0$. Don't worry too much about this. The point is that you can technically get $0$ from $1$.

In fact, the [-finite_group finite groups] that you can get from adding one number to itself a bunch of times are all [-4f4 isomorphic] to some clock. That is to say, no matter what group you took that has this property, if you just renamed the elements, you would end up with something that looked like a clock in the way described above.

Take for example a coin. It has two sides: heads and tails. Call them $h$ and $t$ for short. We can define an operation on the sides as follows, which we're going to refer to as "adding" sides: if you add heads to anything, you flip the coin. If you add tails to anything, you leave the coin alone. So, if you are on the heads side, and you "add heads", you flip the coin to tails. If you are on the heads side and you "add tails" you leave the coin on the heads side. If you are on the tails side and you "add heads", you flip the coin to heads, and if you are on the tails side and you "add tails" you just stay where you are. We can write the operation of 'adding" the sides as "$\bullet$" and then say $h \bullet h = t$, and $h \bullet t = h$, and $t \bullet h = h$, and $t \bullet t = t$. But hey! This is exactly the same we'd get if we called the head side $1$ and the tails side $0$, and considered a clock with just two numbers. Then $1 \bullet 1 = 0$, and $1 \bullet 0 = 1$, and $0 \bullet 1 = 1$ and $0 \bullet 0 = 0$. If you just had heads, you could get tails by just adding heads to itself, so the coin group is cyclic.

For any finite group where you can get every element starting from a single one, you can write it as a clock by relabeling the elements. Try it!

##Infinite Cyclic Groups##
However, things change if we allow our group to be [-infinity infinite]. Then we still require that every element can be obtained by adding $1$ to itself some amount of times, either positive or negative or zero. But maybe there is no way to wrap around. Consider all the [-48l integers], that is to say, every number, positive, negative and zero. These actually do form a group. Then every number you can think of, you can get to by adding $1$ a bunch of times. But no matter how many $1$s you add on the positive side, you can never wrap around and get a negative number. However, the integers are still called a cyclic group, even though it's not really cyclic (I know, not a great name) because the official definition is that every element can be obtained by adding a specific something a bunch of times.

Again, the only infinite cyclic group that you get, up to [-4f4 relabeling], is the integers.

So the only cyclic groups are the clocks and the integers!


Orbit-Stabiliser theorem: External Resources

[summary: [arbital_resources External resources] about the [4l8].]

**[1r5]**

* [Group actions II: the orbit-stabilizer theorem](https://gowers.wordpress.com/2011/11/09/group-actions-ii-the-orbit-stabilizer-theorem) (Tim Gowers) - How many rotational symmetries does a cube have?


Uncountability (Math 3)

A [-3jz] $X$ is *uncountable* if there is no [499 bijection] between $X$ and  [45h $\mathbb{N}$]. Equivalently, there is no [4b7 injection] from $X$ to $\mathbb{N}$.

## Foundational Considerations ##

In set theories without the [69b axiom of choice], such as [ZF Zermelo Frankel set theory] without choice (ZF), it can be [5km consistent] that there is a [-cardinal_number] $\kappa$ that is incomparable to $\aleph_0$. That is, there is no injection from $\kappa$ to $\aleph_0$ nor from $\aleph_0$ to $\kappa$. In this case, cardinality is not a [540 total order], so it doesn't make sense to think of uncountability as "larger" than $\aleph_0$. In the presence of choice, [5sh cardinality is a total order], so an uncountable set can be thought of as "larger" than a countable set.

Countability in one [-model] is not necessarily countability in another. By [skolems_paradox Skolem's Paradox], there is a model of set theory $M$ where its [6gl power set] of the naturals, denoted $2^\mathbb N_M \in M$ is countable when considered outside the model. Of course, it is a [6fk theorem] that $2^\mathbb N _M$ is uncountable, but that is within the model. That is, there is a bijection $f : \mathbb N \to 2^\mathbb N_M$ that is not inside the model $M$ (when $f$ is considered as a set, its graph), and there is no such bijection inside $M$. This means that (un)countability is not [absoluteness absolute].

## See also

If you enjoyed this explanation, consider exploring some of [3d Arbital's] other [6gg featured content]!

Arbital is made by people like you, if you think you can explain a mathematical concept then consider [-4d6]!


Rational number

[summary(Technical): A rational number is a number which may be written as $\frac{a}{b}$, where $a$ is an [-48l] and $b$ is a nonzero integer.]

The rational numbers are either whole numbers or fractions of whole numbers, like $0,$ $1$, $2$, $\frac{1}{2}$, $\frac{97}{3}$, $-17$, $\frac{-85}{1993},$ and so on. The [3jz set] of rational numbers is written $\mathbb Q.$

[54z Irrational numbers] like [49r $\pi$] and [e $e$] are _not_ included in $\mathbb Q;$ the rational numbers are only those numbers which can be written as $\frac{a}{b}$ for integers $a$ and $b$ (where $b \neq 0$).

Formally, $\mathbb{Q}$ is the [-3gz] of the [-field_of_fractions] of $\mathbb{Z}$ (the [3gq ring] of [48l integers]).
That is, each $q \in \mathbb Q$ is an expression $\frac{a}{b}$, where $b$ is a nonzero integer and $a$ is an integer, together with certain rules for addition and multiplication.
The rational numbers are the last intermediate stage on the way to constructing the [4bc real numbers], but they are also very interesting and important in their own right.

One intuition about the rational numbers is that once we've created the [4bc real numbers], then a real number $x$ is a rational number if and only if it may be written as $\frac{a}{b}$, where $a, b$ are integers and $b$ is not $0$.
[todo: add division as a requisite]

# Examples

- The integer $1$ is a rational number, because it may be written as $\frac{1}{1}$ (or, indeed, as $\frac{2}{2}$ or $\frac{-1}{-1}$, or $\frac{a}{a}$ for any nonzero integer $a$).
- The number [49r $\pi$] is not rational ([513 proof]).
- The number $\sqrt{2}$ (being the unique positive real which, when multiplied by itself, yields $2$) is not rational ([548 proof]).

# Properties

- There are infinitely many rationals. (Indeed, every integer is rational, because the integer $n$ may be written as $\frac{n}{1}$, and there are infinitely many integers.)
- There are countably many rationals ([511 proof]). Therefore, because there are [2w0 uncountably] many real numbers, [-almost_all] real numbers are not rational.
- The rationals are [dense_metric_space dense] in the reals.
- The rationals form a [481 field] ([4zr proof]). Indeed, they are a subfield of the real numbers.

# Construction

Instead of taking the reals and selecting a certain collection which we label the "rationals", [construction_of_complexes_from_naturals it is possible to construct the rationals] given access only to the natural numbers; and from the rationals we may construct the reals.
In some sense, this approach is cleaner than starting with the reals and producing the rationals, because the natural numbers are very intuitive objects but the real numbers are less so.
We can be closer to satisfying some deep existential unease if we can build the reals out of the much-simpler naturals.

As an analogy, being able to produce a block of wood given access to a wooden table is much less satisfying than the other way round, and we run into blocks of wood "in the wild" so we are pretty convinced that there actually are such things as blocks of wood.
On the other hand, we almost never see wooden tables in nature, so we can't be quite as sure that they're real until we've built one ourselves.

Similarly, everyone recognises broadly what a counting number is, and they're out there in the wild, but the rational numbers are somewhat less "natural" and their existence is less intuitive.

[todo: add simpler lenses]


The rationals form a field

The set $\mathbb{Q}$ of [4zq rational numbers] is a [481 field].

# Proof

$\mathbb{Q}$ is a ([3jb commutative]) [3gq ring] with additive identity $\frac{0}{1}$ (which we will write as $0$ for short) and multiplicative identity $\frac{1}{1}$ (which we will write as $1$ for short): we check the axioms individually.

- $+$ is commutative: $\frac{a}{b} + \frac{c}{d} = \frac{ad+bc}{bd}$, which by commutativity of addition and multiplication in $\mathbb{Z}$ is $\frac{cb+da}{db} = \frac{c}{d} + \frac{a}{b}$
- $0$ is an identity for $+$: have $\frac{a}{b}+0 = \frac{a}{b} + \frac{0}{1} = \frac{a \times 1 + 0 \times b}{b \times 1}$, which is $\frac{a}{b}$ because $1$ is a multiplicative identity in $\mathbb{Z}$ and $0 \times n = 0$ for every integer $n$.
- Every rational has an additive inverse: $\frac{a}{b}$ has additive inverse $\frac{-a}{b}$.
- $+$ is [3h4 associative]: $$\left(\frac{a_1}{b_1}+\frac{a_2}{b_2}\right)+\frac{a_3}{b_3} = \frac{a_1 b_2 + b_1 a_2}{b_1 b_2} + \frac{a_3}{b_3} = \frac{a_1 b_2 b_3 + b_1 a_2 b_3 + a_3 b_1 b_2}{b_1 b_2 b_3}$$
which we can easily check is equal to $\frac{a_1}{b_1}+\left(\frac{a_2}{b_2}+\frac{a_3}{b_3}\right)$. [todo: actually do this]
- $\times$ is associative, trivially: $$\left(\frac{a_1}{b_1} \frac{a_2}{b_2}\right) \frac{a_3}{b_3} = \frac{a_1 a_2}{b_1 b_2} \frac{a_3}{b_3} = \frac{a_1 a_2 a_3}{b_1 b_2 b_3} = \frac{a_1}{b_1} \left(\frac{a_2 a_3}{b_2 b_3}\right) = \frac{a_1}{b_1} \left(\frac{a_2}{b_2} \frac{a_3}{b_3}\right)$$
- $\times$ is commutative, again trivially: $$\frac{a}{b} \frac{c}{d} = \frac{ac}{bd} = \frac{ca}{db} = \frac{c}{d} \frac{a}{b}$$
- $1$ is an identity for $\times$: $$\frac{a}{b} \times 1 = \frac{a}{b} \times \frac{1}{1} = \frac{a \times 1}{b \times 1} = \frac{a}{b}$$ by the fact that $1$ is an identity for $\times$ in $\mathbb{Z}$.
- $+$ distributes over $\times$: $$\frac{a}{b} \left(\frac{x_1}{y_1}+\frac{x_2}{y_2}\right) = \frac{a}{b} \frac{x_1 y_2 + x_2 y_1}{y_1 y_2} = \frac{a \left(x_1 y_2 + x_2 y_1\right)}{b y_1 y_2}$$
while $$\frac{a}{b} \frac{x_1}{y_1} + \frac{a}{b} \frac{x_2}{y_2} = \frac{a x_1}{b y_1} + \frac{a x_2}{b y_2} = \frac{a x_1 b y_2 + b y_1 a x_2}{b^2 y_1 y_2} = \frac{a x_1 y_2 + a y_1 x_2}{b y_1 y_2}$$
so we are done by distributivity of $+$ over $\times$ in $\mathbb{Z}$.

So far we have shown that $\mathbb{Q}$ is a ring; to show that it is a field, we need all nonzero fractions to have inverses under multiplication.
But if $\frac{a}{b}$ is not $0$ (equivalently, $a \not = 0$), then $\frac{a}{b}$ has inverse $\frac{b}{a}$, which does indeed exist since $a \not = 0$.

This completes the proof.


Complex number

A complex number is a number of the form $z = a + b\textrm{i}$, where $\textrm{i}$ is the imaginary unit defined as $\textrm{i}=\sqrt{-1}$.

Doesn't make sense? Let's backtrack a little.

## Motivation - expanding the definition of numbers##
Say we start with a child's understanding of numbers as counting numbers, or [45h natural numbers]. Using only natural numbers we can add and multiply whichever numbers we want, but there are some restrictions on subtraction: ask a child to subtract 5 from 3 and they'll say "you can't do that!".

In order to allow the computation of numbers like $5-3$, we need to define a new kind of number: negative numbers. The set of natural numbers, negative numbers and $0$ is called whole numbers, or [48l integers]. Unlike natural numbers, with integers we can add and subtract whatever we want. (In math terms, we say the set of integers is [3gy closed] to addition.)

We still have a problem, though: what about division? Going back to our child analogy, say we're talking to a third grader. If you ask them to divide 8 by 2, no problem. But what if you as them to divide 2 by 8? "You can't do that!"

Just like with negative numbers, we need to define a new kind of number: fractions, like $\frac{1}{2}, \frac{5}{3}$ or $-\frac{6}{7}$. By adding fractions to the integers, we get a more general set of numbers - [4zq rational numbers]. With rational numbers we can multiply and divide however we want - the set of rational numbers is closed to multiplication. Well, except dividing by zero. No one has figured out how to do that without breaking mathematics, so that's awkward.

Now say our child is a seventh grader, so they know about square roots. They can apply the square root operation to any perfect square, no problem - $\sqrt{9}=3$. But what if you ask them to find the square root of a non-perfect square, like $\sqrt{2}$? "You can't do that!"

Once again, we need to expand our set of numbers to include a new kind of number: irrational numbers. Unlike we discussed with negative numbers or fractions, irrationals can do a whole lot more that just define square roots. In fact, irrationals are so cool that according to some sources the Pythagoreans couldn't deal with their existence and ended up killing [https://en.wikipedia.org/wiki/Hippasus the guy who invented them].

Adding irrational numbers to our set of rational numbers, we get the [4bc real numbers]. Mathematically, we say that the reals are a [real_number_completeness complete] [540 ordered] [481 field], which is actually one of the ways of defining them.

However, there's still one problem: the real numbers are not an [-algebraically_closed_field]. In a practical sense, this means we still don't have closure under the square root operation $\sqrt{}$, because we can't define the square roots of negative numbers.

By now you've probably noticed the pattern, though: any time someone says "you can't do that!", mathematicians invent a new kind of number to prove them wrong.

## Introducing: imaginary numbers ##
In order to allow using the square root operation on negative numbers, we once again have to define a new kind of number: imaginary numbers.

Actually, we have to define just one number - the imaginary unit, $\textrm{i}$. $\textrm{i}$ is defined as a solution to the quadratic equation $x^2+1=0$. In other words, we can define $\textrm{i}$ as equaling $\sqrt{-1}$.

All the other imaginary numbers (square roots of negatives) follow directly from this definition of $\textrm{i}$: for any negative number $-a$, we can define $\sqrt{-a}=\textrm{i}\sqrt{a}$.

##To be continued...##
This article is unfinished, and will later include an explanation of the complex plane as well as the algebraic properties of complex numbers.

[todo: Finish article by adding explanations of the complex plane and the algebraic properties of complex numbers.]


Rational numbers: Intro (Math 0)

[summary: The rational numbers are "fractions". While the [45h natural numbers] measure the answer to the question "how many apples?" when we have some apples, the rationals measure the answer to the question "how much apple?" when we can cut the apples up in different ways and remove pieces before counting them. ]

*In order to get the most out of this page, you probably want a good grasp of the [53r integers] first.*

"Rational number" is a phrase mathematicians use for the idea of a "fraction".
Here, we'll go through what a fraction is and why we should care about them.

# What is a fraction?

So far, we've met the [48l integers]: whole numbers, which can be either bigger than $0$ or less than $0$ (or the very special $0$ itself).
The [45h natural numbers] can count the number of cows I have in my possession; the integers can also count the number of cows I have after I've given away cows from having nothing, resulting in anti-cows.

In this article, though, we'll stop talking about cows and start talking about apples instead. The reason will become clear in a moment.

Suppose I have two apples. %%note:I'm terrible at drawing, so my apples look suspiciously like circles.%%

![Two apples](http://i.imgur.com/ZqYDkEX.png)

What if I chopped one of the apples into two equally-sized pieces? (And now you know why we stopped talking about cows.)

Now what I have is a whole apple, and… another apple which is in two pieces.

![Two apples, one halved](http://i.imgur.com/pdUyIQe.png)

Let's imagine now that I chop one of the pieces itself into two pieces, and for good measure I chop my remaining whole apple into three pieces.

![Two apples, formed as two quarters, one half, three thirds](http://i.imgur.com/Zv1Y7EP.png)

I still have the same amount of apple as I started with - I haven't eaten any of the pieces or anything - but now it's all in funny-sized chunks.

Now I'll eat one of the smallest chunks. How many apples do I have now?

![Two apples, with a quarter eaten from one](http://i.imgur.com/Bh0ekJQ.png)

I certainly don't just have one apple, because three of the chunks I've got in front of me will together make an apple; and I've also got some chunks left over once I've done that.
But I can't have two apples either, because I *started* with two and then I ate a bit.
Mathematicians like to be able to compare things, and if I forced you to make a comparison, you could say that I have "more than one apple" but "fewer than two apples".

If you're happy with that, then it's a reasonable thing to ask: "exactly how much apple do I have?".
And the mathematician will give an answer of "one apple and three quarters".
"One and three quarters" is an example of a **rational number** or **fraction**: it expresses a quantity that came from dividing some number of things into some number of equal parts, then possibly removing some of the parts.
%%note:I've left out the point that just as you moved from the [45h counting numbers] to the [48l integers], thereby allowing you to owe someone some apples, so we can also have a negative rational number of apples. We'll get to that in time.%%

# The basic building block

From a certain point of view, the building block of the *natural* numbers is just the number $1$: all natural numbers can be made by just adding together the number $1$ some number of times. (If I have a heap of apples, I can build it up just from single apples.)
The building block of the integers is also the number $1$, because if you gave me some apples %%note:which perhaps I've now eaten%% so that I owe you some apples, you might as well have given them to me one by one.

Now the *rationals* have building blocks too, but this time there are lots and lots of them, because if you give me any kind of "building block" - some quantity of apple - I can always just chop it into two pieces and make a smaller "building block".
(This wasn't true when we were confined just to whole apples, as in the natural numbers! If I can't divide up an apple, then I can't make any quantity of apples smaller than one apple. %%note:Except no apples at all.%%)

It turns out that a good choice of building blocks is "one piece, when we divide an apple into several equally-sized pieces".
If we took our apple, and divided it into five equal pieces, then the corresponding building-block is "one fifth of an apple": five of these building blocks makes one apple.
To a mathematician, we have just made the rational number which is written $\frac{1}{5}$.

Similarly, if we divided our apple instead into six equal pieces, and take just one of the pieces, then we have made the rational number which is written $\frac{1}{6}$.

The (positive) rational numbers are just whatever we could make by taking lots of copies of building blocks.

# Examples

- $1$ is a rational number. It can be made with the building block that is just $1$ itself, which is what we get if we take an apple and divide it into just one piece - that is, making no cuts at all. Or, if you're a bit squeamish about not making any cuts, $1$ can be made out of two halves: two copies of the building block that results when we take an apple and cut it into two equal pieces, taking just one of the pieces. (We write $\frac{1}{2}$ for that half-sized building block.)
- $2$ is a rational number: it can be made out of two lots of the $1$-building-block, or indeed out of four lots of the $\frac{1}{2}$-building-block.
- $\frac{1}{2}$ is a rational number: it is just the half-sized building block itself.
- If we took the apple and instead cut it into three pieces, we obtain a building block which we write as $\frac{1}{3}$; so $\frac{1}{3}$ is a rational number.
- Two copies of the $\frac{1}{3}$-building-block makes the rational number which we write $\frac{2}{3}$.
- Five copies of the $\frac{1}{3}$-building-block makes somewhat more than one apple. Indeed, three of the building blocks can be put together to make one full apple, and then we've got two building blocks left over. We write the rational number represented by five $\frac{1}{3}$-building-blocks as $\frac{5}{3}$.

# Notation

Now you've seen the notation $\frac{\cdot}{\cdot}$ used a few times, where there are numbers in the places of the dots.
You might be able to guess how this notation works in general now: if we take the blocks resulting when we divide an apple into "dividey-number"-many pieces, and then take "lots" of those pieces, then we obtain a rational number which we write as $\frac{\text{lots}}{\text{dividey-number}}$.
Mathematicians use the words "numerator" and "denominator" for what I called "lots" and "dividey-number"; so it would be $\frac{\text{numerator}}{\text{denominator}}$ to a mathematician.

# Exercises

Can you give some examples of how we can make the number $3$ from smaller building blocks? (There are lots and lots of ways you could correctly answer this question.)
%%hidden(Show a possible solution):
You already know about one way from when we talked about the natural numbers: just take three copies of the $1$-block. (That is, three apples is three single apples put together.)

Another way would be to take six half-sized blocks: $\frac{6}{2}$ is another way to write $3$.

Yet another way is to take fifteen fifth-sized blocks: $\frac{15}{5}$ is another way to write $3$.

If you want to mix things up, you could take four half-sized blocks and three third-sized blocks: $\frac{4}{2}$ and $\frac{3}{3}$ together make $3$.
![Three apples: four halves and three thirds](http://i.imgur.com/JBpqyko.png)
%%

If you felt deeply uneasy about the last of my possible solutions above, there is a good and perfectly valid reason why you might have done; we will get to that eventually. If that was you, just forget I mentioned that last one for now.
If you were comfortable with it, that's also normal.

How about making the number $\frac{1}{2}$ from smaller blocks?
%%hidden(Show a possible solution):
Of course, you could start by taking just one $\frac{1}{2}$ block.

For a more interesting answer, you could take three copies of the sixth-sized block: $\frac{3}{6}$ is the same as $\frac{1}{2}$.

![A half, expressed in sixths](http://i.imgur.com/5OBeBRE.png)

Alternatively, five copies of the tenth-sized block: $\frac{5}{10}$ is the same as $\frac{1}{2}$.

![A half, expressed in tenths](http://i.imgur.com/IfOm2xH.png)
%%

The way I've drawn the pictures might be suggestive: in some sense, when I've given different answers just now, they all look like "the same answer" but with different lines drawn on.
That's because the rational numbers ("fractions", remember) correspond to answers to the question "how much?".
While there is always more than one way to build a given rational number out of the building blocks, the way that we build the number doesn't affect the ultimate answer to the question "how much?".
$\frac{5}{10}$ and $\frac{1}{2}$ and $\frac{3}{6}$ are all simply different ways of writing the same underlying quantity: the number which represents the fundamental concept of "chop something into two equal pieces".
They each express different ways of making the same amount (for instance, out of five $\frac{1}{10}$-blocks, or one $\frac{1}{2}$-block), but the amount itself hasn't changed.

# Going more general

Remember, from when we treated the integers using cows, that I can give you a cow (even if I haven't got one) by creating a cow/anti-cow pair and then giving you the cow, leaving me with an anti-cow.
We count the number of anti-cows that I have by giving them a *negative* number.

We can do the same here with chunks of apple.
If I wanted to give you half an apple, but I didn't have any apples, I could create a half-apple/half-anti-apple pair, and then give you the half-apple; this would leave me with a half-anti-apple.

We count anti-apples in the same way as we count anti-cows: they are *negative*.

See the page on [56x subtraction] for a much more comprehensive explanation; this page is more of a whistle-stop tour.

# Limitations

We've had the idea of building-blocks: as $\frac{1}{n}$, where $n$ was a natural number.
Why should $n$ be just a natural number, though?
We've already seen the integers; why can't it be one of those? %%note:That is, why not let it be negative?%%

As it turns out, we *can* let $n$ be an integer, but we don't actually get anything new if we do.
We're going to pretend for the moment that $n$ has to be positive, because it gets a bit weird trying to divide things into three anti-chunks; this approach doesn't restrict us in any way, but if you are of a certain frame of mind, it might just look like a strange and artificial boundary to draw.

However, you must note that $n$ cannot be $0$ (whatever your stance on dividing things into anti-chunks).
While there is a way to finesse the idea of an anti-chunk %%note: And if you sit and think really hard for a long time, you might even come up with it yourself!%%, there is simply no way to make it possible to divide an apple into $0$ equal pieces.
That is, $\frac{1}{0}$ is not a rational number (and you should be very wary of calling it anything that suggests it's like a number - like "infinity" - and under no account may you do arithmetic on it).

# Summary

So far, you've met what a rational number is! We haven't gone through how to do things with them yet, but hopefully you now understand vaguely what they're there for: they express the idea of "dividing something up into parts", or "sharing things out among people" (if I have two apples to split fairly among three people, I can be fair by chopping each apple into three $\frac{1}{3}$-sized building blocks, and then giving each person two of the blocks).

[514 Next up], we will see how we can combine rational numbers together, eventually making a very convenient shorthand. %%note:The study of this shorthand is known as "arithmetic".%%


Report likelihoods not p-values: FAQ

This page answers frequently asked questions about the [4zd] proposal for experimental science.

_(Note: This page is a personal [60p opinion page].)_

[toc:]

### What does this proposal entail?

Let's say you have a coin and you don't know whether it's biased or not. You flip it six times and it comes up HHHHHT.

To report a [p_value p-value], you have to first declare which experiment you were doing — were you flipping it six times no matter what you saw and counting the number of heads, or were you flipping it until it came up tails and seeing how long it took? Then you have to declare a "null hypothesis," such as "the coin is fair." Only then can you get a p-value, which in this case, is either 0.11 (if you were going to toss the coin 6 times regardless) or 0.03 (if you were going to toss until it came up heads). The p-value of 0.11 means "if the null hypothesis _were_ true, then data that has as many H values as the observed data would only occur 11% of the time, if the declared experiment were repeated many many times."

To report a [bayes_likelihood likelihood], you don't have to do any of that "declare your experiment" stuff, and you don't have to single out one special hypothesis. You just pick a whole bunch of hypotheses that seem plausible, such as the set of hypotheses $H_b$ = "the coin has a bias of $b$ towards heads" for $b$ between 0% and 100%. Then you look at the actual data, and report how likely that data is according to each hypothesis. In this example, that yields a graph which looks like this:

![L(e|H)](http://i.imgur.com/UwwxmCe.png)

This graph says that HHHHHT is about 1.56% likely under the hypothesis $H_{0.5}$ saying that the coin is fair, and about 5.93% likely under the hypothesis $H_{0.75}$ that the coin comes up heads 75% of the time, and only 0.17% likely under the hypothesis $H_{0.3}$ that the coin only comes up tails 30% of the time.

That's all you have to do. You don't need to make any arbitrary choice about which experiment you were going to run. You don't need to ask yourself what you "would have seen" in other cases. You just look at the actual data, and report how likely each hypothesis in your hypothesis class said that data should be.

(If you want to compare how well the evidence supports one hypothesis or another, you just use the graph to get a [1rq likelihood ratio] between any two hypotheses. For example, this graph reports that the data HHHHHT supports the hypothesis $H_{0.75}$ over $H_{0.5}$ at odds of $\frac{0.0593}{0.0156}$ = 3.8 to 1.)

For more of an explanation, see [4zd].

### Why would reporting likelihoods be a good idea?

Experimental scientists reporting likelihoods instead of p-values would likely help address many problems facing modern science, including [https://en.wikipedia.org/wiki/Data_dredging p-hacking], [http://slatestarcodex.com/2014/04/28/the-control-group-is-out-of-control/ the vanishing effect size problem], and [https://en.wikipedia.org/wiki/Publication_bias publication bias].

It would also make it easier for scientists to combine the results from multiple studies, and it would make it much much easier to conduct meta-analyses.

It would also make scientific statistics more intuitive, and easier to understand.

### Likelihood functions are a Bayesian tool. Aren't Bayesian statistics subjective? Shouldn't science be objective?

Likelihood functions are purely objective. In fact, there's only one degree of freedom in a likelihood function, and that's the choice of hypothesis class. This choice is no more arbitrary than the choice of a "null hypothesis" in standard statistics, and indeed, it's significantly less arbitrary (you can pick a large class of hypotheses, rather than just one; and none of them needs to be singled out as subjectively "special").

This is in stark contrast with p-values, which require that you pick an "experimental design" in advance, or that you talk about what data you "could have seen" if the experiment turned out differently. Likelihood functions only depend on the hypothesis class that you're considering, and the data that you actually saw. (This is one of the reasons why likelihood functions would solve p-hacking.)

Likelihood functions are often used by Bayesian statisticians, and Bayesian statisticians do indeed use [4vr subjective probabilities], which has led some people to believe that reporting likelihood functions would somehow allow hated subjectivity to seep into the hallowed halls of science.

However, it's the [1rm priors] that are subjective in Bayesian statistics, not likelihood functions. In fact, according to the [1lz laws of probability theory], likelihood functions are precisely that-which-is-left-over when you factor out all subjective beliefs from an observation of evidence. In other words, probability theory tells us that likelihoods are the best summary there is for capturing the objective evidence that a piece of data provides (assuming your goal is to help make people's beliefs more accurate).

### How would reporting likelihoods solve p-hacking?

P-values depend on what experiment the experimenter says they had in mind. For example, if the data is HHHHHT and the experimenter says "I was planning to flip it six times and count the number of Hs" then the p-value (for the fair coin hypothesis) is 0.11, which is not "significant." If instead the experimenter says "I was planing to flip it until I got a T" then the p-value is 0.03, which _is_ "significant." Experimenters can ([http://amstat.tandfonline.com/doi/pdf/10.1080/00031305.2016.1154108 and do!]) misuse or abuse this degree of freedom to make their results appear more significant than they actually are. This is known as "p-hacking."

In fact, when running complicated experiments, this can (and does!) happen to honest well-meaning researchers. Some experimenters are dishonest, and many others simply lack the time and patience to understand the subtleties of good experimental design. We don't need to put that burden on experimenters. We don't need to use statistical tools that depend on which experiment the experimenter had in mind. We can instead report the likelihood that each hypothesis assigned to the actual data.

Likelihood functions don't have this "experiment" degree of freedom. They don't care what experiment you thought you were doing. They only care about the data you actually saw. To use likelihood functions correctly, all you have to do is look at stuff and then not lie about what you saw. Given the set of hypotheses you want to report likelihoods for, the likelihood function is completely determined by the data.

### But what if the experimenter tries to game the rules by choosing how much data to collect?

That's a problem if you're reporting p-values, but it's not a problem if you're reporting likelihood functions.

Let's say there's a coin that you think is fair, that I think might be biased 55% towards heads. If you're right, then every toss is going to (in [-4b5]) provide more evidence for "fair" than "biased." But sometimes (rarely), even if the coin is fair, you will flip it and it will generate a sequence that supports the "bias" hypothesis more than the "fair" hypothesis.

How often will this happen? It depends on how exactly you ask the question. If you can flip the coin at most 300 times, then there's about a 1.4% chance that at some point the sequence generated will support the hypothesis "the coin is biased 55% towards heads" 20x more than it supports the hypothesis "the coin is fair." (You can verify this yourself, and tweak the parameters, using [https://gist.github.com/Soares/941bdb13233fd0838f1882d148c9ac14 this code].)

This is an objective fact about coin tosses. If you look at a sequence of Hs and Ts generated by a fair coin, then some tiny fraction of the time, after some number $n$ of flips, it will support the "biased 55% towards heads" hypothesis 20x more than it supports the "fair" hypothesis. This is true no matter how or why you decided to look at those $n$ coin flips. It's true if you were always planning to look at $n$ coin flips since the day you were born. It's true if each coin flip costs $1 to look at, so you decided to only look until the evidence supported one hypothesis at least 20x better than the other. It's true if you have a heavy personal desire to see the coin come up biased, and were planning to keep flipping until the evidence supports "bias" 20x more than it supports "fair". It doesn't _matter_ why you looked at the sequence of Hs and Ts. The amount by which it supports "biased" vs "fair" is objective. If the coin really is fair, then the more you flip it the more the evidence will push towards "fair." It will only support "bias" a small unlucky fraction of the time, and that fraction is completely independent from your thoughts and intentions .

Likelihoods are objective. They don't depend on your state of mind.

P-values, on the other hand, run into some difficulties. A p-value is about a single hypothesis (such as "fair") in isolation. If the coin is fair, then [fair_coin_equally_likely all sequences of coin tosses are equally likely], so you need something more than the data in order to decide whether the data is "significant evidence" about fairness one way or the other. Which means you have to choose a "reference class" of ways the coin "could have come up." Which means you need to tell us which experiment you "intended" to run. And down the rabbit hole we go.

The p-value you report depends on how many coin tosses you say you were going to look at. If you lie about where you intended to stop, the p-value breaks. If you're out in the field collecting data, and the data just subconsciously begins to feel overwhelming, and so you stop collecting evidence (or if the data just subconsciously feels insufficient and so you collect more) then the p-value breaks. How badly to p-values break? If you can toss the coin at most 300 times, then by choosing when to stop looking, you can get a p < 0.05 significant result _21% of the time,_ and that's assuming you are required to look at at least 30 flips. If you're allowed to use small sample sizes, the number is more like 25%. You can verify this yourself, and tweak the parameters, using [https://gist.github.com/Soares/4955bb9268129476262b28e32b8ec979 this code].

It's no wonder that p-values are so often misused! To use p-values correctly, an experimenter has to meticulously report their intentions about the experimental design before collecting data, and then has to hold utterly unfaltering to that experiment design as the data comes in (even if it becomes clear that their experimental design was naive, and that there were crucial considerations that they failed to take into account). Using p-values correctly requires good intentions, constant vigilance, and inflexibility.

Contrast this with likelihood functions. Likelihood functions don't depend on your intentions. If you start collecting data until it looks overwhelming and then stop, that's great. If you start collecting data and it looks underwhelming so you keep collecting more, that's great too. Every new piece of data you do collect will support the true hypothesis more than any other hypothesis, in expectation — that's the whole point of collecting data. Likelihood functions don't depend upon your state of mind.

### What if the experimenter uses some other technique to bias the result?

They can't. Or, at least, it's a theorem of [-1bv] that they can't. This law is known as [-conservation_expected_evidence conservation of expected evidence], and it says that for any hypothesis $H$ and any piece of evidence $e$, $\mathbb P(H) = \mathbb P(H \mid e) \mathbb P(e) + \mathbb P(H \mid \lnot e) \mathbb P(\lnot e),$ where $\mathbb P$ stands for my personal subjective probabilities.

Imagine that I'm going to take your likelihood function $\mathcal L$ and blindly combine it with my personal beliefs using [1lz Bayes' rule]. The question is, can you use $\mathcal L$ to manipulate my beliefs? The answer is clearly "yes" if you're willing to lie about what data you saw. But what if you're honestly reporting all the data you _actually_ saw? Then can you manipulate my beliefs, perhaps by being strategic about what data you look at and how long you look at it?

Clearly, the answer to that question is "sort of." If you have a fair coin, and you want to convince me it's biased, and you toss it 10 times, and it (by sheer luck) comes up HHHHHHHHHH, then that's a lot of evidence in favor of it being biased. But you can't use the "hope the coin comes up heads 10 times in a row by sheer luck" strategy to _reliably_ bias my beliefs; and if you try just flipping the coin 10 times and hoping to get lucky, then on average, you're going to produce data that convinces me that the coin is fair. The real question is, can you bias my beliefs _in expectation?_

If the answer is "yes," then there will be times when I should ignore $\mathcal L$ even if you honestly reported what you saw. If the answer is "no," then there will be no such times — for every $e$ that would shift my beliefs heavily towards $H$ (such that you could say "Aha! How naive! If you look at this data and see it is $e$, then you will believe $H$, just as I intended"), there is an equal and opposite chance of alternative data which would push my beliefs _away_ from $H.$ So, can you set up a data collection mechanism that pushes me towards $H$ in expectation?

And the answer to that question is _no,_ and this is a trivial theorem of probability theory. No matter what subjective belief state $\mathbb P$ I use, if you honestly report the objective likelihood $\mathcal L$ of the data you actually saw, and I update $\mathbb P$ by [1lz multiplying it by $\mathcal L$], there is no way (according to $\mathbb P$) for you to bias my probability of $H$ on average — no matter how strategically you decide which data to look at or how long to look. For more on this theorem and its implications, see [conservation_expected_evidence Conservation of Expected Evidence].

There's a difference between metrics that can't be exploited in theory and metrics that can't be exploited in practice, and if a malicious experimenter really wanted to abuse likelihood functions, they could probably find some clever method. (At the least, they can always lie and make things up.) However, p-values aren't even provably inexploitable — they're so easy to exploit that sometimes well-meaning honest researchers exploit them _by accident_, and these exploits are already commonplace and harmful. When building better metrics, starting with metrics that are provably inexploitable is a good start.

### What if you pick the wrong hypothesis class?

If you don't report likelihoods for the hypotheses that someone cares about, then that person won't find your likelihood function very helpful. The same problem exists when you report p-values (what if you pick the wrong null and alternative hypotheses?). Likelihood functions make the problem a little better, by making it easy to report how well the data supports a wide variety of hypotheses (instead of just ~2), but at the end of the day, there's no substitute for the raw data.

Likelihoods are a summary of the data you saw. They're a useful summary, especially if you report likelihoods for a broad set of plausible hypotheses. They're a much better summary than many other alternatives, such as p-values. But they're still a summary, and there's just no substitute for the raw data.

### How does reporting likelihoods help prevent publication bias?

When you're reporting p-values, there's a stark difference between p-values that favor the null hypothesis (which are deemed "insignificant") and p-values that reject the null hypothesis (which are deemed "significant"). This "significance" occurs at arbitrary thresholds (e.g. p < 0.05), and significance is counted only in one direction (to be significant, you must reject the null hypothesis). Both these features contribute to publication bias: Journals only want to accept experiments that claim "significance" and reject the null hypothesis.

When you're reporting [56s likelihood functions], a 20 : 1 [1rq ratio] is a 20 : 1 ratio is a 20 : 1 ratio. It doesn't matter if your likelihood function is peaked near "the coin is fair" or whether it's peaked near "the coin is biased 82% towards heads." If the ratio between the likelihood of one hypothesis and the likelihood of another hypothesis is 20 : 1 then the data provides the same strength of evidence either way. Likelihood functions don't single out one "null" hypothesis and incentivize people to only report data that pushes away from that null hypothesis; they just talk about the relationship between the data and _all_ the interesting hypotheses.

Furthermore, there's no arbitrary significance threshold for likelihood functions. If you didn't have a ton of data, your likelihood function will be pretty spread out, but it won't be useless. If you find $5 : 1$ odds in favor of $H_1$ over $H_2$, and I independently find $6 : 1$ odds in favor of $H_1$ over $H_2$, and our friend independently finds $3 : 1$ odds in favor of $H_1$ over $H_2,$ then our studies as a whole constitute evidence that favors $H_1$ over $H_2$ by a factor of $90 : 1$ — hardly insignificant! With likelihood ratios (and no arbitrary "significance" cutoffs) progress can be made in small steps.

Of course, this wouldn't solve the problem of publication bias in full, not by a long shot. There would still be incentives to report cool and interesting results, and the scientific community might still ask for results to pass some sort of "significance" threshold before accepting them for publication. However, reporting likelihoods would be a good start.

### How does reporting likelihoods help address vanishing effect sizes?

In a field where an effect does not actually exist, we will often observe an initial study that finds a very large effect, followed by a number of attempts at replication that find smaller and smaller and smaller effects (until someone postulates that the effect doesn't exist, and does a meta-analysis to look for p-hacking and publication bias). This is known as the [https://en.wikipedia.org/wiki/Decline_effect decline effect]; see also [http://slatestarcodex.com/2014/04/28/the-control-group-is-out-of-control/ _The control group is out of control_].

The decline effect is possible in part because p-values look only at whether the evidence says we should "accept" or "reject" a special null hypothesis, without any consideration for what that evidence says about the alternative hypotheses. Let's say we have three studies, all of which reject the null hypothesis "the coin is fair." The first study rejects the null hypothesis with a 95% confidence interval of [0.7, 0.9] bias in favor of heads, but it was a small study and some of the experimenters were a bit sloppy. The second study is a bit bigger and a bit better organized, and rejects the null hypothesis with a 95% confidence interval of [0.53, 0.62]. The third study is high-powered, long-running, and rejects the null hypothesis with a 95% confidence interval of [0.503, 0.511]. It's easy to say "look, three separate studies rejected the null hypothesis!"

But if you look at the likelihood functions, you'll see that _something very fishy is going on_ — none of the studies actually agree with each other! The effect sizes are incompatible. Likelihood functions make this phenomenon easy to detect, because they tell you how much the data supports _all_ the relevant hypotheses (not just the null hypothesis). If you combine the three likelihood functions, you'll see that _none_ of the confidence intervals fare very well. Likelihood functions make it obvious when different studies contradict each other directly, which makes it much harder to summarize contradictory data down to "three studies rejected the null hypothesis".

### What if I want to reject the null hypothesis without needing to have any particular alternative in mind?

Maybe you don't want to report likelihoods for a large hypothesis class, because you are pretty sure you can't generate a hypothesis class that contains the correct hypothesis. "I don't want to have to make up a bunch of alternatives," you protest, "I just want to show that the null hypothesis is _wrong,_ in isolation."

Fortunately for you, that's possible using likelihood functions! The tool you're looking for is the notion of [227 strict confusion]. A hypothesis $H$ will tell you how low its likelihood is supposed to get, and if its likelihood goes a lot lower than that value, then you can be pretty confident that you've got the wrong hypothesis.

For example, let's say that your one and only hypothesis is $H_{0.9}$ = "the coin is biased 90% towards heads." Now let's say you flip the coin twenty times, and you see the sequence THTTHTTTHTTTTHTTTTTH. The [log_likelihood log-likelihood] that $H_{0.9}$ _expected_ to get on a sequence of 20 coin tosses was about -9.37 [evidence_bit bits],%%note: According to $H_{0.9},$ each coin toss carries $0.9 \log_2(0.9) + 0.1 \log_2(0.1) \approx -0.469$ bits of evidence, so after 20 coin tosses, $H_{0.9}$ expects about $20 \cdot 0.469 \approx 9.37$ bits of [bayes_surprise surprise]. For more on why log likelihood is a convenient tool for measuring "evidence" and "surprise," see [1zh Bayes' rule: log odds form].%% for a likelihood score of about $2^{-9.37} \approx$ $1.5 \cdot 10^{-3},$ on average. The likelihood that $H_{0.9}$ actually gets on that sequence is -50.59 bits, for a likelihood score of about $5.9 \cdot 10^{-16},$ which is _thirteen orders of magnitude less likely than expected._ You don't need to be clever enough to come up with an alternative hypothesis that explains the data in order to know that $H_{0.9}$ is not the right hypothesis for you.

In fact, likelihood functions make it easy to show that _lots_ of different hypotheses are strictly confused — you don't need to have a good hypothesis in your hypothesis class in order for reporting likelihood functions to be a useful service.

### How does reporting likelihoods make it easier to combine multiple studies?

Want to combine two studies that reported likelihood functions? Easy! Just multiply the likelihood functions together. If the first study reported 10 : 1 odds in favor of "fair coin" over "biased 55% towards heads," and the second study reported 12 : 1 odds in favor of "fair coin" over "biased 55% towards heads," then the combined studies support the "fair coin" hypothesis over the "biased 55% towards heads" hypothesis at a likelihood ratio of 120 : 1.

Is it really that easy? Yes! That's one of the benefits of using a representation of evidence supported by a large edifice of [-1bv] — they're trivially easy to compose. You have to ensure that the studies are independent first, because otherwise you'll double-count the data. (If the combined likelihood ratios get really extreme, you should be suspicious about whether they were actually independent.) This isn't exactly a new problem in experimental science; we can just add it to the list of reasons why replication studies had better be independent of the original study. Also, you can only multiply the likelihood functions together on places where they're both defined: If one study doesn't report the likelihood for a hypothesis that you care about, you might need access to the raw data in order to extend their likelihood function. But if the studies are independent and both report likelihood functions for the relevant hypotheses, then all you need to do is multiply.

(Don't try this with p-values. A p < 0.05 study and a p < 0.01 study don't combine into anything remotely like a p < 0.0005 study.)

### How does reporting likelihoods make it easier to conduct meta-analyses?

When studies report p-values, performing a meta-analysis is a complicated procedure that requires dozens of parameters to be finely tuned, and (lo and behold) bias somehow seeps in, and meta-analyses often find whatever the analyzer set out to find. When studies report likelihood functions, performing a meta-analysis is trivial and doesn't depend on you to tune a dozen parameters. Just multiply all the likelihood functions together.

If you want to be extra virtuous, you can check for anomalies, such as one likelihood function that's tightly peaked in a place that disagrees with all the other peaks. You can also check for [227 strict confusion], to get a sense for how likely it is that the correct hypothesis is contained within the hypothesis class that you considered. But mostly, all you've got to do is multiply the likelihood functions together.

### How does reporting likelihood functions make it easier to detect fishy studies?

With likelihood functions, it's much easier to find the studies that don't match up with each other — look for the likelihood function that has its peak in a different place than all the other peaks. That study deserves scrutiny: either those experimenters had something special going on in the background of their experiment, or something strange happened in their data collection and reporting process.

Furthermore, likelihoods combined with the notion of [227 strict confusion] make it easy to notice when something has gone seriously wrong. As per the above answers, you can combine multiple studies by multiplying their likelihood functions together. What happens if the likelihood function is super small everywhere? That means that either (a) some of the data is fishy, or (b) you haven't considered the right hypothesis yet.

When you _have_ considered the right hypothesis, it will have decently high likelihood under _all_ the data. There's only one real world underlying all our data, after all — it's not like different experimenters are measuring different underlying universes. If you multiply all the likelihood functions together and _all_ the hypotheses turn out looking wildly unlikely, then you've got some work to do — you haven't yet considered the right hypothesis.

When reporting p-values, contradictory studies feel like the norm. Nobody even _tries_ to make all the studies fit together, as if they were all measuring the same world. With likelihood functions, we could actually aspire towards a world where scientific studies on the same topic are _all_ combined. A world where people try to find hypotheses that fit _all_ the data at once, and where a single study's data being out of place (and making all the hypotheses currently under consideration become [-227]) is a big glaring "look over here!" signal. A world where it feels like studies are _supposed_ to fit together, where if scientists haven't been able to find a hypothesis that explains all the raw data, then they know they have their work cut out for them.

Whatever the right hypothesis is, it will almost surely not be strictly confused under the actual data. Of course, when you come up with a completely new hypothesis (such as "the coin most of us have been using is fair but study #317 accidentally used a different coin") you're going to need access to the raw data of some of the previous studies in order to extend their likelihood functions and see how well they do on this new hypothesis. As always, there's just no substitute for raw data.

### Why would this make statistics easier to do and understand?

p < 0.05 does not mean "the null hypothesis is less than 5% likely" (though that's what young students of statistics often _want_ it to mean). What the null hypothesis means is "given a particular experimental design (e.g., toss the coin 100 times and count the heads) and the data (e.g., the sequence of 100 coin flips), if the null hypothesis _were_ true, then data that matches my chosen statistic (e.g., the number of heads) would only occur 5% of the time, if we repeated this experiment over and over and over."

Why the complexity? Statistics is designed to keep subjective beliefs out of the hallowed halls of science. Your science paper shouldn't be able to conclude "and, therefore, I personally believe that the coin is very likely to be biased, and I'd bet on that at 20 : 1 odds." Still, much of this complexity is unnecessary. Likelihood functions achieve the same goal of objectivity, but without all the complexity.

[51n $\mathcal L_e(H)$] $< 0.05$ _also_ doesn't mean "$H$ is less than 5% likely", it means "H assigned less than 0.05 probability to $e$ happening." The student still needs to learn to keep "probability of $e$ given $H$" and "probability of $H$ given $e$" distinctly separate in their heads. However, likelihood functions do have a _simpler_ interpretation: $\mathcal L_e(H)$ is the probability of the actual data $e$ occurring if $H$ were in fact true. No need to talk about experimental design, no need to choose a summary statistic, no need to talk about what "would have happened." Just look at how much probability each hypothesis assigned to the actual data; that's your likelihood function.

If you're going to report p-values, you need to be meticulous in considering the complexities and subtleties of experiment design, on pain of creating p-values that are broken in non-obvious ways (thereby contributing to the [https://en.wikipedia.org/wiki/Replication_crisis replication crisis]). When reading results, you need to take the experimenter's intentions into account. None of this is necessary with likelihoods.

To understand $\mathcal L_e(H),$ all you need to know is how likely $e$ was according to $H.$ Done.

### Isn't this just one additional possible tool in the toolbox? Why switch entirely away from p-values?

This may all sound too good to be true. Can one simple change really solve that many problems in modern science?

First of all, you can be assured that reporting likelihoods instead of p-values would not "solve" all the problems above, and it would surely not solve all problems with modern experimental science. Open access to raw data, preregistration of studies, a culture that rewards replication, and many other ideas are also crucial ingredients to a scientific community that zeroes in on truth.

However, reporting likelihoods would help solve lots of different problems in modern experimental science. This may come as a surprise. Aren't likelihood functions just one more statistical technique, just another tool for the toolbox? Why should we think that one single tool can solve that many problems?

The reason lies in [-1bv]. According to the axioms of probability theory, there is only one good way to account for evidence when updating your beliefs, and that way is via likelihood functions. Any other method is subject to inconsistencies and pathologies, as per the [probability_coherence_theorems coherence theorems of probability theory].

If you're manipulating equations like $2 + 2 = 4,$ and you're using methods that may or may not let you throw in an extra 3 on the right hand side (depending on the arithmetician's state of mind), then it's no surprise that you'll occasionally get yourself into trouble and deduce that $2 + 2 = 7.$ The laws of arithmetic show that there is only one correct set of tools for manipulating equations if you want to avoid inconsistency.

Similarly, the laws of probability theory show that there is only one correct set of tools for manipulating _uncertainty_ if you want to avoid inconsistency. According to [1lz those rules], the right way to represent evidence is through likelihood functions.

These laws (and a solid understanding of them) are younger than the experimental science community, and the statistical tools of that community predate a modern understanding of probability theory. Thus, it makes a lot of sense that the existing literature uses different tools. However, now that humanity _does_ possess a solid understanding of probability theory, it should come as no surprise that many diverse pathologies in statistics can be cleaned up by switching to a policy of reporting likelihoods instead of p-values.

### If it's so great why aren't we doing it already?

[1bv Probability theory] (and a solid understanding of all that it implies) is younger than the experimental science community, and the statistical tools of that community predate a modern understanding of probability theory. In particular, modern statistical tools were designed in an attempt to keep subjective reasoning out of the hallowed halls of science. You shouldn't be able to publish a scientific paper which concludes "and therefore, I personally believe that this coin is biased towards heads, and would bet on that at 20 : 1 odds." Those aren't the foundations upon which science can be built.

Likelihood functions are strongly associated with Bayesian statistics, and Bayesian statistical tools tend to manipulate subjective probabilities. Thus, it wasn't entirely clear how to use tools such as likelihood functions without letting subjectivity bleed into science.

Nowadays, we have a better understanding of how to separate out subjective probabilities from objective claims, and it's known that likelihood functions don't carry any subjective baggage with them. In fact, they carry _less_ subjective baggage than p-values do: A likelihood function depends only on the data that you _actually saw,_ whereas p-values depend on your experimental design and your intentions.

There are good historical reasons why the existing scientific community is using p-values, but now that humanity _does_ possess a solid theoretical understanding of probability theory (and how to factor subjective probabilities out from objective claims), it's no surprise that a wide array of diverse problems in modern statistics can be cleaned up by reporting likelihoods instead of p-values.

### Has this ever been tried?

No. Not yet. To our knowledge, most scientists haven't even considered this proposal — and for good reason! There are a lot of big fish to fry when it comes to addressing the [https://en.wikipedia.org/wiki/Replication_crisis replication crisis], [https://en.wikipedia.org/wiki/Data_dredging p-hacking], [http://slatestarcodex.com/2014/04/28/the-control-group-is-out-of-control/ the problem of vanishing effect sizes], [https://en.wikipedia.org/wiki/Publication_bias publication bias], and other problems facing science today.  The scientific community at large is huge, decentralized, and has a lot of inertia. Most activists who are trying to shift it already have their hands full advocating for very important policies such as open access journals and pre-registration of trials. So it makes sense that nobody's advocating hard for reporting likelihoods instead of p-values — yet.

Nevertheless, there are good reasons to believe that reporting likelihoods instead of p-values would help solve many of the issues in modern experimental science.


Real number (as Cauchy sequence)

[summary: If we want to construct the real numbers in terms of simpler objects (such as the rationals), one way to do it is to take our putative real number and consider sequences of rational numbers which in some sense "get closer and closer" to the real number.]

[summary(Technical): The real numbers can be constructed as a field consisting of all Cauchy sequences of rationals, quotiented by the equivalence relation given by "two sequences are equivalent if and only if they eventually get arbitrarily close to each other".]

Consider the set of all [53b Cauchy sequences] of [4zq rational numbers]: concretely, the set $$X = \{ (a_n)_{n=1}^{\infty} : a_n \in \mathbb{Q}, (\forall \epsilon \in \mathbb{Q}^{>0}) (\exists N \in \mathbb{N})(\forall n, m \in \mathbb{N}^{>N})(|a_n - a_m| < \epsilon) \}$$

Define an [-53y] on this set, by $(a_n) \sim (b_n)$ if and only if, for every rational $\epsilon > 0$, there is a [-45h] $N$ such that for all $n \in \mathbb{N}$ bigger than $N$, we have $|a_n - b_n| < \epsilon$.
This is an equivalence relation (exercise).
%%hidden(Show solution):
- It is symmetric, because $|a_n - b_n| = |b_n - a_n|$.
- It is reflexive, because $|a_n - a_n| = 0$ for every $n$, and this is $< \epsilon$.
- It is transitive, because if $|a_n - b_n| < \frac{\epsilon}{2}$ for sufficiently large $n$, and $|b_n - c_n| < \frac{\epsilon}{2}$ for sufficiently large $n$, then $|a_n - b_n| + |b_n - c_n| < \frac{\epsilon}{2} + \frac{\epsilon}{2} = \epsilon$ for sufficiently large $n$; so by the [-triangle_inequality], $|a_n - c_n| < \epsilon$ for sufficiently large $n$.
%%

Write $[a_n]$ for the equivalence class of $(a_n)_{n=1}^{\infty}$. (This is a slight abuse of notation, omitting the brackets that indicate that $a_n$ is actually a sequence rather than a rational number.)

The set of *real numbers* is the set of equivalence classes of $X$ under this equivalence relation, endowed with the following [540 totally ordered] [481 field] structure:

- $[a_n] + [b_n] := [a_n + b_n]$
- $[a_n] \times [b_n] := [a_n \times b_n]$
- $[a_n] \leq [b_n]$ if and only if $[a_n] = [b_n]$ or there is some $N$ such that for all $n > N$, $a_n \leq b_n$.

This field structure is well-defined ([51h proof]).

# Examples

- Any rational number $r$ may be viewed as a real number, being the class $[r]$ (formally, the equivalence class of the sequence $(r, r, \dots)$).
- The real number $\pi$ is indeed a real number under this definition; it is represented by, for instance, $(3, 3.1, 3.14, 3.141, \dots)$. It is also represented as $(100, 3, 3.1, 3.14, \dots)$, along with many other possibilities.


Real number (as Dedekind cut)

[summary: The real numbers can be defined using [dedekind_cut Dedekind cuts], which are [set_partition partitions] of the rational numbers into two sets where every element in one set is less than every element in the other set. Each real number is uniquely defined by a one-sided Dedekind cut.]

%%comment: Mnemonics for defined macros: \Ql = Q left, \Qr = Q right, \Qls = Q left strict, \Qrs = Q right strict.%%

The rational numbers have a problem that makes them unsuitable for use in calculus — they have "gaps" in them. This may not be obvious or even make sense at first, because between any two rational numbers you can always find infinitely many other rational numbers. How could there be *gaps* in a set like that? $\newcommand{\rats}{\mathbb{Q}} \newcommand{\Ql}{\rats^\le} \newcommand{\Qr}{\rats^\ge} \newcommand{\Qls}{\rats^<} \newcommand{\Qrs}{\rats^>}$
$\newcommand{\set}[1]{\left\{#1\right\}} \newcommand{\sothat}{\ |\ }$

But using the construction of [dedekind_cut Dedekind cuts], we can suss out these gaps into plain view. A Dedekind cut of a [-540] $S$ is a pair of sets $(A, B)$ such that:

1. Every element of $S$ is in exactly one of $A$ or $B$. (That is, $(A, B)$ is a [set_partition partition] of $S$.)
2. Every element of $A$ is less than every element of $B$.
3. Neither $A$ nor $B$ is [empty_set empty]. (We'll see why this restriction matters in a moment.)

One example of such a cut might be the set where $A$ is the negative rational numbers and $B$ is the nonnegative rational numbers (positive or zero). We see that it satisfies the three properties of a Dedekind cut:

1. Every rational number is either negative or nonnegative, but not both.
2. Every rational number which is negative is less than a rational number that is nonnegative.
3. There exists at least one negative rational number (e.g. $-1$) and one nonnegative rational number (e.g. $1$).

In fact, Dedekind cuts are intended to represent sets of rational numbers that are less than or greater than a specific real number (once we've defined them). To represent this, let's call them $\Ql$ and $\Qr$.

Knowing this, why does it matter that neither set in a Dedekind cut is empty?

%%hidden(Show solution):
If $\Ql$ were empty, then we'd have a real number less than _all_ the rational numbers, which is $-\infty$, which we don't want to define as a real number. Similarly, if $\Qr$ were empty, then we'd get $+\infty$.
%%

## Completion of a space

If a space is [ complete] (doesn't have any gaps in it), then in any Dedekind cut $(\Ql, \Qr)$, either $\Ql$ will have a greatest element or $\Qr$ will have a least element. (We can't have both at the same time — why?)

%%hidden(Show solution):
Suppose $\Ql$ had a greatest element $q_u$ and $\Qr$ had a least element $q_v$. We can't have $q_u = q_v$, because the same number would be in both sets. So then because the rational numbers are a dense space, there must exist a rational number $r$ so that $q_u < r < q_v$. Then $r$ is not in either $\Ql$ or $\Qr$, contradicting property 1 of a Dedekind cut.
%%

But in the rational numbers, we can find a Dedekind cut where neither $\Ql$ nor $\Qr$ have a greatest or least element respectively.

Consider the pair of sets $(\Ql, \Qr)$ where $\Ql = \set{x \in \rats \mid x^3 \le 2}$ and $\Qr = \set{x \in \rats \mid x^3 \ge 2}$.

1. Every rational number has a cube either greater than 2 or less than 2,
2. Because $f(x) = x^3$ is a [ monotonically increasing] function, we have that $p < q \iff p^3 < q^3$, which means that every element in $\Ql$ is less than every element in $\Qr$.

So $(\Ql, \Qr)$ is a Dedekind cut. However, there is no rational number whose cube is *equal to* $2$, so $\Ql$ has no greatest element and $\Qr$ has no least element.

This represents a gap in the numbers, because we can invent a new number to place in that gap (in this case $\sqrt[3]{2}$), which is "between" any two numbers in $\Ql$ and $\Qr$.

## Definition of real numbers

Before we move on, we will define one more structure that makes the construction more elegant. Define a *one-sided Dedekind cut* as any Dedekind cut $(\Ql, \Qr)$ with the additional property that the set $\Ql$ has no greatest element (in which case we now call it $\Qls$). The case where $\Ql$ has a greatest element $q_g$ can be trivially transformed into the equivalent case on the other side by moving $q_g$ to $\Qr$ where it is automatically the least element due to being less than any other element in $\Qr$.

Then we define the real numbers as the set of one-sided Dedekind cuts of the rational numbers.

* A rational number $r$ is mapped to itself by the Dedekind cut where $r$ itself is the least element of $\Qr$. (If the cuts weren't one-sided, $r$ would also be mapped to the set where $r$ was the greatest element of $\Ql$, which would make the mapping non-unique.)
* An irrational number $q$ is newly defined by the Dedekind cut where all the elements of $\Qls$ are less than $q$ and all the elements of $\Qr$ are (strictly) greater than $q$.

Now we can define the [549 total order] $\le$ for two real numbers $a = (\Qls_a, \Qr_a)$ and $b = (\Qls_b, \Qr_b)$ as follows: $a \le b$ when $\Qls_a \subseteq \Qls_b$.

Using this, we can show that unlike in the [50d Cauchy sequence definition], we don't need to define any equivalence classes — every real number is uniquely defined by a one-sided Dedekind cut.

%%hidden(Proof):
If $a = b$, then $a \le b$ and $b \le a$. By the definition of the order, we have that $\Qls_a \subseteq \Qls_b$ and $\Qls_b \subseteq \Qls_a$, which means that $\Qls_a = \Qls_b$, which means that the Dedekind cuts corresponding to $a$ and $b$ are also equal.
%%

[todo: Proof of the field structure of Dedekind cuts.]


Currying

Currying converts a [-3jy] of N [input inputs] into a function of a single input, which returns a function that takes a second input, which returns a function that takes a third input, and so on, until N functions have been evaluated and N inputs have been taken, at which point the original function is evaluated on the given inputs and the result is returned.

For example:

Consider a function of four parameters, $F:(X,Y,Z,N)→R$.

The curried version of the function, $curry(F)$ would have the type signature $X→(Y→(Z→(N→R)))$, and $curry(F)(4)(3)(2)(1)$ would equal $F(4,3,2,1)$.

Currying is named after the logician Haskell Curry. If you can't remember this derivation and need a mnemonic, you might like to imagine a function being cooked in a curry so thoroughly that it breaks up into small, bite-sized pieces, just as functional currying breaks a function up into smaller functions. (It might also help to note that there is a programming language also named after Haskell Curry (Haskell), that features currying prominently. All functions in Haskell are pre-curried by convention. This often makes [partially applying](https://wiki.haskell.org/Partial_application) functions effortless.)


Proof

Proof pages provide [proof formal proofs] about a statement, but don't motivate or explain them.


External resources

This lens links out to other great resources across the web. External resources lenses should never be the main lens, Arbital should always have at least a [-72] with a popover [1kl summary].


The set of rational numbers is countable

The set $\mathbb{Q}$ of [4zq rational numbers] is countable: that is, there is a [499 bijection] between $\mathbb{Q}$ and the set $\mathbb{N}$ of [45h natural numbers].

# Proof

By the [cantor_schroeder_bernstein_theorem Schröder-Bernstein theorem], it is enough to find an [4b7 injection] $\mathbb{N} \to \mathbb{Q}$ and an injection $\mathbb{Q} \to \mathbb{N}$.

The former is easy, because $\mathbb{N}$ is a subset of $\mathbb{Q}$ so the identity injection $n \mapsto \frac{n}{1}$ works.

For the latter, we may define a function $\mathbb{Q} \to \mathbb{N}$ as follows.
Take any rational in its lowest terms, as $\frac{p}{q}$, say. %%note:That is, the [greatest_common_divisor GCD] of the numerator $p$ and denominator $q$ is $1$.%%
At most one of $p$ and $q$ is negative (if both are negative, we may just cancel $-1$ from the top and bottom of the fraction); by multiplying by $\frac{-1}{-1}$ if necessary, assume without loss of generality that $q$ is positive.
If $p = 0$ then take $q = 1$.

Define $s$ to be $1$ if $p$ is positive, and $2$ if $p$ is negative.

Then produce the natural number $2^p 3^q 5^s$.

The function $f: \frac{p}{q} \mapsto 2^p 3^q 5^s$ is injective, because [fundamental_theorem_of_arithmetic prime factorisations are unique] so if $f\left(\frac{p}{q}\right) = f \left(\frac{a}{b} \right)$ (with both fractions in their lowest terms, and $q$ positive) then $|p| = |a|, q=b$ and the sign of $p$ is equal to the sign of $a$.
Hence the two fractions were the same after all.


Pi is irrational

The number [49r $\pi$] is not [4zq rational].

# Proof

For any fixed real number $q$, and any [-45h] $n$, let $$A_n = \frac{q^n}{n!} \int_0^{\pi} [x (\pi - x)]^n \sin(x) dx$$
where $n!$ is the [-5bv] of $n$, $\int$ is the [-definite_integral], and $\sin$ is the [-sin_function].

## Preparatory work

Exercise: $A_n = (4n-2) q A_{n-1} - (q \pi)^2 A_{n-2}$.
%%hidden(Show solution):
We use [-integration_by_parts].

[todo: show this]
%%

Now, $$A_0 = \int_0^{\pi} \sin(x) dx = 2$$
so $A_0$ is an integer.

Also $$A_1 = q \int_0^{\pi} x (\pi-x) \sin(x) dx$$ which by a simple calculation is $4q$.
%%hidden(Show calculation):
Expand the integrand and then integrate by parts repeatedly:
$$\frac{A_1}{q} = \int_0^{\pi} x (\pi-x) \sin(x) dx = \pi \int_0^{\pi} x \sin(x) dx - \int_0^{\pi} x^2 \sin(x) dx$$

The first integral term is $$[-x \cos(x)]_0^{\pi} + \int_0^{\pi} \cos(x) dx = \pi$$

The second integral term is $$[-x^2 \cos(x)]_{0}^{\pi} + \int_0^{\pi} 2x \cos(x) dx$$
which is $$\pi^2 + 2 \left( [x \sin(x)]_0^{\pi} - \int_0^{\pi} \sin(x) dx \right)$$
which is $$\pi^2 -4$$

Therefore $$\frac{A_1}{q} = \pi^2 - (\pi^2 - 4) = 4$$
%%

Therefore, if $q$ and $q \pi$ are integers, then so is $A_n$ [5fz inductively], because $(4n-2) q A_{n-1}$ is an integer and $(q \pi)^2 A_{n-2}$ is an integer.

But also $A_n \to 0$ as $n \to \infty$, because $\int_0^{\pi} [x (\pi-x)]^n \sin(x) dx$ is in modulus at most $$\pi \times \max_{0 \leq x \leq \pi} [x (\pi-x)]^n \sin(x) \leq \pi \times \max_{0 \leq x \leq \pi} [x (\pi-x)]^n = \pi \times \left[\frac{\pi^2}{4}\right]^n$$
and hence $$|A_n| \leq \frac{1}{n!} \left[\frac{\pi^2 q}{4}\right]^n$$

For $n$ larger than $\frac{\pi^2 q}{4}$, this expression is getting smaller with $n$, and moreover it gets smaller faster and faster as $n$ increases; so its limit is $0$.
%%hidden(Formal treatment):
We claim that $\frac{r^n}{n!} \to 0$ as $n \to \infty$, for any $r > 0$.

Indeed, we have $$\frac{r^{n+1}/(n+1)!}{r^n/n!} = \frac{r}{n+1}$$
which, for $n > 2r-1$, is less than $\frac{1}{2}$.
Therefore the ratio between successive terms is less than $\frac{1}{2}$ for sufficiently large $n$, and so the sequence must shrink at least geometrically to $0$.
%%

## Conclusion

Suppose (for [46z contradiction]) that $\pi$ is rational; then it is $\frac{p}{q}$ for some integers $p, q$.

Now $q \pi$ is an integer (indeed, it is $p$), and $q$ is certainly an integer, so by what we showed above, $A_n$ is an integer for all $n$.

But $A_n \to 0$ as $n \to \infty$, so there is some $N$ for which $|A_n| < \frac{1}{2}$ for all $n > N$; hence for all sufficiently large $n$, $A_n$ is $0$.
We already know that $A_0 = 2$ and $A_1 = 4q$, neither of which is $0$; so let $N$ be the first integer such that $A_n = 0$ for all $n \geq N$, and we can already note that $N > 1$.

Then $$0 = A_{N+1} = (4N-2) q A_N - (q \pi)^2 A_{N-1} = - (q \pi)^2 A_{N-1}$$
whence $q=0$ or $\pi = 0$ or $A_{N-1} = 0$.

Certainly $q \not = 0$ because $q$ is the denominator of a fraction; and $\pi \not = 0$ by whatever definition of $\pi$ we care to use.
But also $A_{N-1}$ is not $0$ because then $N-1$ would be an integer $m$ such that $A_n = 0$ for all $n \geq m$, and that contradicts the definition of $N$ as the *least* such integer.

We have obtained the required contradiction; so it must be the case that $\pi$ is irrational.


Arithmetic of rational numbers (Math 0)

[summary: We can take two [4zq rational numbers] and [addition add] them together, just as we can take two [45h *natural* numbers] and add them together; and all the other operations of the integers can be viewed in the rationals too.]

Now that we've seen [4zx what the rational numbers are], we'll move on to working out how to combine them.

There are four main ways to combine rational numbers, and collectively they are called "arithmetic":

- [55m Addition]
- [56x Subtraction]
- [59s Multiplication]
- [5jd Division]

Additionally, we can *[5pk compare]* rational numbers with each other; and we can show that all of these operations [5pm play nicely together] in a certain sense.

This page is the start of an arc which will go through all of these ideas.
In the process, we'll get you familiar with the notation that we use for rational numbers; it's a very convenient shorthand once you've learnt [5q5 the conventions].


Field structure of rational numbers

The [4zq rational numbers], being the [-field_of_fractions] of the [48l integers], have the following [481 field] structure:

- Addition is given by $\frac{a}{b} + \frac{p}{q} = \frac{aq+bp}{bq}$
- Multiplication is given by $\frac{a}{b} \frac{c}{d} = \frac{ac}{bd}$
- The identity under addition is $\frac{0}{1}$
- The identity under multiplication is $\frac{1}{1}$
- The additive inverse of $\frac{a}{b}$ is $\frac{-a}{b}$
- The multiplicative inverse of $\frac{a}{b}$ (where $a \not = 0$) is $\frac{b}{a}$.

It additionally inherits a [540 total ordering] which respects the field structure: $0 < \frac{c}{d}$ if and only if $c$ and $d$ are both positive or $c$ and $d$ are both negative.
All other information about the ordering can be derived from this fact: $\frac{a}{b} < \frac{c}{d}$ if and only if $0 < \frac{c}{d} - \frac{a}{b}$.