text:
C++

# A Boomerang Proof

## Introduction

My mother is a teacher at a primary school where she often works with the gifted kids that yearn for an extra challenge. One of the challenges she provided them was called the Boomerang Problem1. The goal of the challenge is to find the largest number that cannot be represented as the sum of multiples of two given numbers (called the boomerangs). So for example, given the number 4 and 5, you can construct 17 as $$3 * 4 + 1 * 5$$. However, the number 11 cannot be represented that way. In fact, it turns out to be the largest number for which that holds given boomerangs 4 and 5.

Impressed with the speed with which some kids were able to answer the question she also wanted to test me. And so, after doing a bunch of arithmetic to solve the problem I naturally wanted to find an easier, lazier, and more elegant way to generate an answer.

In this post we will try to formulate a generic method for finding this largest number given any two boomerangs. We do this for entertainment, to aid with sleeping now that one more question in the universe is answered, and unbeknownst to most people: because proofing is a creative process. In the final paragraph I will shed a few words on what makes the process so interesting and worthwhile.

## Euclid would like to interject for a moment

Before we try to answer the question of the largest number we must asks ourselves first: does such a number always exist? And in fact, this happens to not always be the case. The easiest counter example that you can think of is when the two boomerangs are even numbers. After all, both the sum and a multiple of even numbers remain even. As a result, two even boomerangs will never be able to express an odd number, making the question "What is the largest number that cannot be expressed?", rather nonsensical.

Even numbers carry with them a property that troubles the water in the same way that 6 and 9 are two boomerangs for which the question becomes nonsensical. Namely, they are both a multiple of a number other than 1. This number is known as the Greatest Common Divider (Or GCD for short). We know that if the GCD of two numbers is some number $$z$$, that $$k * z+1$$ can never be expressed for the following reason:

1. Given 2 boomerangs $$x$$ and $$y$$ such that $$GCD(x,y) = z$$.
2. We can rewrite $$y = n1 * z$$ and $$x = n2 * z$$ for some $$n1, n2 \in \mathbb{N}$$
3. Our construction expression then becomes $$a * n2 * z + b * n1 * z$$
4. Which can be factorized as $$(a * n1 + b * n2) * z$$
5. This implies that only multiples of $$z$$ can be constructed.
6. Finally we can conclude that there is no such thing as the largest inexpressible number if $$z > 1$$

What we have learned is that before we start asking the question we first calculate the GCD to check if it is in fact 1. Luckily there is a relatively simple method for determining the GCD which is known as the Euclidean Algorithm2.

## Developing an intuition by force: throwing a computer against it.

While it is not always necessary, usually a proof attempts to verify an already developed idea or hypothesis. Furthermore, it forms a great excuse to include some computer science concepts in the mix regarding solving puzzles algorithmically.

In essence, what we want is a program that given a number z and two boomerangs x and y, will return an a and b that satisfies our puzzle, or tell us that it is impossible of course. Then we will run this program for any number between 1 and say 100000. More than likely, no new solutions will pop up after a while and we can reasonable assume that we have found the highest number. Note that this does not yet constitute a proof, but it can give us a good understanding and new insights that will help us get there eventually.

Now this is the part where we will dive into some computer science, if you are here just for the math, don't worry, it won't affect our proof. The thing is, we want to construct a program that is able to find a solution in a reasonable amount of time. To do this, we will use a concept known as dynamic programming3 (or DP for short). What this method helps us do, is create an efficient algorithm for problems that can be expressed as a sub problem:

$$T(x,y,0) = True \\ T(x,y,z) = z > 0 \wedge (T(x,y,z-x) \vee T(x,y,z-y))$$

What this says is that the number z can be expressed if either $$z-x$$ or $$z-y$$ can be expressed. As base case we also state that the number 0 can always be expressed. In haskell, the mathematical notation translates quite well:

test :: Int -> Int -> Int -> Bool
test x y z
| z < 0 = False
| z == 0 = True
| otherwise = test x y (z-x) || test x y (z-y)

However, this implementation can run out of hand quite quickly since it can require up to 2 recursive calls per iteration, meaning that the execution stack grows exponentially. But this is where the concept of DP kicks in, now that we have stated our problem in terms of the solution to a smaller version we can start to attack it from the other side, eliminating recursion and ensuring that we never have to calculate something twice. Furthermore, we also save the information needed to actually reconstruct a and b once we know that the answer has been yes. For this we will employ c++:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>

int main(int argc, char** argv) {
// x and y are our boomerangs, we can vary these to test
int x = 28;
int y = 19;
int z = 114;

// Allocate space to save the answers for the sub problems
int* data = (int*)malloc((z+1) * sizeof(int));
// Initialize the memory to 0
memset(data, 0, (z+1)*sizeof(int));

// base case
data[0] = 1;

// solve all the problems up to and including z
for(int i = 1; i<z+1; ++i) {
if (i >= x && data[i-x] ==1)      data[i] = 1;
else if (i >= y && data[i-y] ==1) data[i] = 1;
}

if (data[z] == 0) {
return 0;
}

// Reconstruct a and b
// Start from the target number
int i = z;
int a = 0;
int b = 0;
while(i>0) {
// the number minus x can be expressed (thus add an x)
if (i >= x && data[i-x] == 1) {
a++;
i -= x;
}
// the number minus y can be expressed (thus add a y)
else if (i >= y && data[i-y] == 1) {
b++;
i -= y;
}
}
printf("%i = %i * %i + %i * %i\n", z, a, x, b, y);
}

Now, let's run this for a number of boomerangs and see what the largest number is for which the program outputs NO ANSWER.

x y largest z
4 5 11
5 6 19
7 10 53
28 19 485

Admittedly, it takes either luck or time to spot the pattern, but eventually it can be done. I was sitting in the garden, thinking about what these numbers might mean and where they came from and then it suddenly hit me: the formula for the largest number is a follows. $$L(x,y) = x * y - x - y$$ It seems we have found a simple and elegant formula that can tell us the answer right away; No programming languages, no sub problems, often not even a calculator is needed. But where does this formula come from? And it is always correct? Perhaps some number in the billions is waiting out there to show our hypothesis is wrong... Clearly, sleep is not yet an option.

If you want to play around yourself with some numbers I've taken that same c++ code and converted it to javascript for you to play with:

## Proof that the formula always produces an inexpressible number

1. Let us define $$z = x * y$$
2. Because $$GCD(x,y) = 1$$ we know that there are exactly 2 ways to express $$z$$:
$$z = y * x + 0 * y$$
$$z = 0 * x + x * y$$
3. If we then subtract $$x$$ from $$z$$ we can only fix the first expression to remain true:
$$z-x = (y-1) * x + 0 * y$$
4. If we then again subtract $$y$$ from $$z$$ we cannot fix the expression, concluding that for $$z = x*y-x-y$$ there exists no solution.

## Proof that any larger number can be expressed

Let's first think about how someone might proof such a thing. Our computer program was not a valid proof because we could never evaluate every single number. What we have to come up with is something known as an induction proof. We aren't going to proof that it holds for some number, we are instead going to proof that we can always increment a number by 1 and still express the number of the sum of the two boomerangs. That way, our statement suddenly holds for all numbers to the stars and beyond!

1. Given numbers x,y,z,a,b such that $$z = a * x + b * y$$
2. We can decrement a by n such that $$n*x \mod y = y-1$$, leading to the following expression: $$(a-n) * x + (b - \frac{n*x}{y} + 1) * y = z + 1$$
3. Similarly we can decrement b by n such that $$n*y \mod x = x-1$$, leading to the following expression: $$(a - \frac{n*y}{x} + 1) * x + (b-n)*y = z + 1$$
4. Now, it is not possible to always find such an n. But since $$GCD(x,y)=1$$ we know that
$$n*x \mod y = 0 \Rightarrow n = k * y$$
$$n*y \mod x = 0 \Rightarrow n = k * x$$
In other words, the sequence of rests always ends with 0 and only when n is a multiple of the divider
5. We also know that the sequences of rests cannot contain a loop for any $$n < x$$ or $$n < y$$ respectively
6. From 4. and 5. we can conclude that $$y-1$$ and $$x-1$$ must always appear in the sequences of rests when we increment n to $$x-1$$ or $$y-1$$ in step 2 and 3 respectively.
7. From step 6. we can conclude that we can always rearrange the expression to become 1 more iff $$a ≥ y-1$$ and/or $$b ≥ x-1$$. The smallest number for this holds is $$x*y-x-y$$.
8. Finally, after we have applied either of these rules we will always have enough x's and y's left to apply the other rule at the next iteration.
9. Therefore we can express every number above $$x*y-x-y$$ as a boomerang number.

## An example

To highlight the rewrite rules we have conjured up in our proof let us walk through an example with 4 and 5 as a boomerangs. We already know now that 11 is the largest number that cannot be expressed, but we can start with the rewrite rule from there.

z a b elaboration
11 - - -
12 3 0 -
13 2 1 $$n*4 \mod 5 = (5-1)$$ holds for $$n=1)$$ since $$4 \mod 5=4)$$. Now we can subtract a by 1 and increment b by $$\frac{4}{5} + 1 = 1$$
14 1 2 $$n*4 \mod 5 = (5-1)$$ holds for $$n=1)$$ since $$4 \mod 5=4)$$. Now we can subtract a by 1 and increment b by $$\frac{4}{5} + 1 = 1$$
15 0 3 $$n*4 \mod 5 = (5-1)$$ holds for $$n=1)$$ since $$4 \mod 5=4)$$. Now we can subtract a by 1 and increment b by $$\frac{4}{5} + 1 = 1$$
16 4 0 $$n*4 \mod 5 = (5-1)$$ holds for $$n=1)$$ since $$4 \mod 5=4)$$. But, $$1 > 0$$ so we proceed to rewrite rule 2. $$n*5 \mod 4 = (4-1)$$ holds for $$n=3$$ since $$15 \mod 4 = 3$$. So we decrement b by 3 and increment a by $$\frac{15}{4}+1=4$$.

## Summarizing

And there we have it! Proof! First we created a computer program to gain some intuition about what the solution might be. Then we proved that the number produced by our solution would at least never be a expressible by our boomerangs. Finally, using induction we proved that after that number we could always rewrite the expression to make the total 1 more, thereby proving that we can express any number up to infinity larger than $$x*y-x-y$$!.

## Math as a creative process, why computers can't do everything

I don't think proofs like this interest most people and I think for a large part that has to do with not realizing that math is a fundamentally creative process. In school you usually experience a cycle in which the teacher explains a concept, rule, or formula after which you go ahead and apply this newfound knowledge to a number of examples.

While this is of course very necessary to teach everyone the basics of math it often fails to highlight the fact that those rules and concepts were not carved in stone by a deity and gifted to us; Instead we discovered them! And this is were things get ironic since the word discovery implies some sort of unspecified human process, which most people do not associated with a field like math that is often crowned with the virtue of being precise and unambiguous.

In fact, it is precisely because developing new theories in math requires human creativity that it attracts people. Mathematicians don't view themselves as efficient computers, but as creative beings that are almost creating art, albeit under very strict rules.

It is true that computer programs exist that can tell you whether certain conjectures are true or not (SAT solvers for example) but they are currently quite limited. It seems that every time we try to create a magical auto proofer, we stumble upon some missing information that requires creativity to solve.

All this leads to the most existential question in math: 'Is math something you discover or something you create?'

## References

1. Boomerang Problem by Erik van Haren's MathPlay (Dutch)


text:
# Find the value of

Question:

Find the value of $(1296)^{0.17} \times(1296)^{0.08}$.

Solution:

$(1296)^{0.17} \times(1296)^{0.08}$

$=(1296)^{0.17+0.08}$

$=(1296)^{0.25}$

$=(1296)^{\frac{1}{4}}$

$=\sqrt[4]{1296}$

$=6$

format: plain


text:
basics_handouts.tex 5.04 KB
 Jeroen F.J. Laros committed Oct 11, 2013 1 2 \documentclass{article}  Mihai committed Sep 05, 2017 3 4 \usepackage[hidelinks]{hyperref}  Jeroen F.J. Laros committed Apr 24, 2016 5 \providecommand{\handoutsTitle}{Git Basics}  Jeroen F.J. Laros committed Oct 11, 2013 6   Mihai committed Mar 28, 2018 7 8 9 10 \usepackage{multicol} \usepackage{enumitem} \usepackage{xcolor} \usepackage{graphicx}  Jeroen F.J. Laros committed Apr 24, 2016 11 \usepackage{handouts}  Mihai committed Mar 28, 2018 12   Jeroen F.J. Laros committed Apr 24, 2016 13 \input{../shared/shared}  Jeroen F.J. Laros committed Oct 11, 2013 14   Mihai committed Mar 28, 2018 15 16   Jeroen F.J. Laros committed Apr 24, 2016 17 18 \begin{document} \makeHeader  Jeroen F.J. Laros committed Oct 11, 2013 19   Mihai committed Sep 05, 2017 20 21 \subsubsection*{Connect to the education server}  Mihai committed Dec 06, 2018 22 23 Open \url{http://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html} in your browser. It may be faster to google for putty.  Mihai committed Mar 28, 2018 24 \medskip  Mihai committed Sep 05, 2017 25   Mihai committed Mar 14, 2019 26 27 28 Download and run \href{https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe}{\textbf{putty.exe}}, the standalone executable and not the installer (Alternative binary files, the SSH and Telnet client itself).  Mihai committed Sep 05, 2017 29 30 31 32 33 \medskip Introduce the education server IP address \textbf{145.88.35.11} as destination. \medskip  Mihai committed Dec 06, 2018 34 35 36 Make sure that the \textbf{port number} is set to \textbf{22} and that \textbf{SSH} is selected as \textbf{connection type} and press \textbf{Open}'' to start the connection.  Mihai committed Sep 05, 2017 37 38 39 40 41 42 43 44 45 46 47 \medskip Press Yes'' if the security alert pops up. \medskip Introduce your provided \textbf{username} and press enter. \medskip Introduce your provided \textbf{password} and press enter. \medskip  Mihai committed Mar 28, 2018 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 \section{General questions} \begin{enumerate} \item How can you check your local git repository state? \vspace{-0.2cm} \begin{multicols}{3} \begin{enumerate}[label=(\alph*)] \item git state \item git repository \item git commit \item git status \item git show \item git log \end{enumerate} \end{multicols} \vspace{-0.3cm} \item What command is used to stage a file? \vspace{-0.2cm} \begin{multicols}{3} \begin{enumerate}[label=(\alph*)] \item git stage \item git checkout \item git add \item git status \item git diff \item git log \end{enumerate} \end{multicols} \vspace{-0.3cm} \item How do you tell git what files to ignore? \vspace{-0.2cm} \begin{multicols}{2} \begin{enumerate}[label=(\alph*)] \item git ignore \{file-name\} \item add the file paths to a file named .gitignore'' \item it is not possible \item git not track \{file-name\} \end{enumerate} \end{multicols} \vspace{-0.3cm} \item The \gitcmd\ \cmd{commit}\ command: \vspace{-0.2cm} \begin{multicols}{2} \begin{enumerate}[label=(\alph*)] \item stages all the modified files \item saves the staged files changes into the repository database'' \item retrieves old files into the working directory \item shows a repository history and lets the user pick what commits to discard \end{enumerate} \end{multicols} \vspace{-0.3cm} \item A file is brought into the modified state when: \vspace{-0.2cm} \begin{multicols}{2} \begin{enumerate}  Mihai committed Sep 12, 2018 107 108  \item[[ ]] it is staged \item[[ ]] it has been edited by the user  Mihai committed Mar 28, 2018 109 110 111 112 113 114 115 116 117  \item[[ ]] the user checks out a previous version of it \item[[ ]] the file is committed \end{enumerate} \end{multicols} \vspace{-0.3cm} \end{enumerate} \section{Practical exercises}  Mihai committed Sep 05, 2017 118 119 \subsubsection*{Local configuration} First, let Git know what your name and e-mail address is:  Mihai committed Dec 06, 2018 120 121 122 123 124 \medskip \prompt\ \gitcmd\ \cmd{config} \cmdopt{--global user.name "Your Name"}\\ \prompt\ \gitcmd\ \cmd{config} \cmdopt{--global user.email "your@email.address"}\\ \prompt\ \cmd{cat} $\sim$\cmdopt{/.gitconfig}  Mihai committed Sep 05, 2017 125 126 \bigskip  Jeroen F.J. Laros committed Apr 24, 2016 127 \subsubsection*{Create a repository}  Mihai committed Dec 06, 2018 128 129 First, create an empty directory inside your home directory and use \gitcmd\ \cmd{init}'' in that  bow committed Nov 17, 2017 130 newly-created directory to make a new repository.  Jeroen F.J. Laros committed Oct 11, 2013 131 \begin{itemize}  bow committed Nov 17, 2017 132  \item \emph{Hint:} Use a short and descriptive name for the directory.  Jeroen F.J. Laros committed Oct 11, 2013 133 134 135 136 137  \item \emph{Question:} How can you see that you are working in a Git repository? \end{itemize} \bigskip  Mihai committed Nov 21, 2017 138 Check the status of your repository.  Jeroen F.J. Laros committed Oct 11, 2013 139   Jeroen F.J. Laros committed Apr 24, 2016 140 \subsubsection*{Your first commit}  Jeroen F.J. Laros committed Oct 11, 2013 141 Create a new file named README'' (with an editor, or by using the  Mihai committed Dec 06, 2018 142 \cmd{touch}'' command).  Jeroen F.J. Laros committed Oct 11, 2013 143 144 145 \begin{itemize} \item \emph{Question:} What is the status of this new file? \end{itemize}  Mihai committed Mar 14, 2019 146 \medskip  Jeroen F.J. Laros committed Oct 11, 2013 147   Mihai committed Dec 06, 2018 148 Stage this file for the next commit using \gitcmd\ \cmd{add}''.  Jeroen F.J. Laros committed Oct 11, 2013 149 150 151 \begin{itemize} \item \emph{Question:} What is the status of this file now? \end{itemize}  Mihai committed Mar 14, 2019 152 \medskip  Jeroen F.J. Laros committed Oct 11, 2013 153 154 155 156 157 158  Commit your changes. \begin{itemize} \item \emph{Question:} What happened to the status? \end{itemize}  Jeroen F.J. Laros committed Apr 24, 2016 159 \subsubsection*{Manipulation in the staging area}  Mihai committed Mar 14, 2019 160 161 Edit your file. Check the repository status. \medskip  Jeroen F.J. Laros committed Oct 11, 2013 162   Mihai committed Mar 14, 2019 163 164 Stage your modified file. Check the repository status. \medskip  Jeroen F.J. Laros committed Oct 11, 2013 165   Mihai committed Mar 14, 2019 166 167 168 169 170 171 172 Now remove the file from the staging area. Check the repository status. \medskip Discard the changes performed to the file. Check the repository status. \medskip Edit again the file, stage it, and commit.  Mihai committed Dec 06, 2018 173   Jeroen F.J. Laros committed Apr 24, 2016 174 \subsubsection*{Working with versions}  Mihai committed Mar 14, 2019 175 Edit your file again and commit one more time.  Jeroen F.J. Laros committed Oct 11, 2013 176 177 \bigskip  Mihai committed Dec 06, 2018 178 179 Now you change your mind and you want to restore the version stored in the previous commit.  Jeroen F.J. Laros committed Oct 11, 2013 180 \begin{itemize}  Mihai committed Dec 06, 2018 181  \item \emph{Hint:} Use \gitcmd\ \cmd{log}'' to see a list of all your  Jeroen F.J. Laros committed Oct 11, 2013 182 183 184 185 186 187 188 189 190 191 192  versions. \end{itemize} \bigskip Edit your file again and check the differences with your last commit. \begin{itemize} \item \emph{Question:} What is the difference with your first commit? \end{itemize} \bigskip Make a file that you do not want to track.  Jeroen F.J. Laros committed Apr 24, 2016 193   Jeroen F.J. Laros committed Oct 11, 2013 194 \end{document}


text:
# How will SpaceX's Starship accommodate its 100 passengers from the effects of micro-gravity?

According to this Wikipedia article, Starship will take on average 115 days (3.8 months) to get to Mars and 150 days maximum (4.9 months).

with an average trip time to Mars of approximately 115 days (for the nine synodic periods occurring between 2020 and 2037).

And according to this NASA article, an astronaut in one month in orbit loses the same amount of bone mass as an elderly women does in one year. Furthermore, a few months in space leads to an increased risk of bone fractures when load is applied to their bodies. And surely colonists on Mars will be doing a lot of physical work.

Although healthy astronauts did not develop osteoporosis during their four- to six-month stays on the space station, the levels of bone loss documented were still enough to raise the concern for an increased risk for fracture when astronauts’ skeletons are subjected to applied loads with working, lifting or falling.

After astronauts return from the ISS, they feel dizzy and nauseous. So the passengers of Starship will feel the same way returning to an environment with 1/3 of Earth's gravity after a 4 month journey in micro-gravity. This is a passage from this article.

Even after a ten-to-fourteen-day mission to space, the return is dramatic. Your balance system is turned upside down, and you feel very dizzy. When you stand up for the first time, you feel about five times heavier than you expect. All of this can be unsettling, and nausea is not unusual.

Of course they are returning to Earth which has stronger gravity than Mars but the side-effects are the same nonetheless.

Even with exercise, micro-gravity is a big concern that leads to many health problems and the fact that their are 100 people on-board makes it an even bigger concern.

So my question: How will SpaceX accommodate its passengers from the harmful effects of micro-gravity?

Side Note: I don't expect a proper answer with professional citations, any source where Elon Musk or the SpaceX team bring up this topic is sufficient.

• There are really only two answers - rotation, or oughing it out and allowing a fairly lengthy period after landing to adjust. Two Starships attached tail to tail is one way to tackle this. – Chris B. Behrens Jul 24 '19 at 22:53
• Why not exercise? That's what the ISS crews do. – Organic Marble Jul 25 '19 at 1:05
• @OrganicMarble Even with exercise, the effects of micro-gravity is still very harmful. – Star Man Jul 25 '19 at 14:04
• It's my understanding that the 100 passengers are for a intercontinental ballistic flight, and that missions to Mars will have much of that space taken up by supplies, life support, etc., so will have fewer than 100 passengers. – Ghedipunk Sep 24 '19 at 23:58
• An authoritative answer from SpaceX may have to wait until the mainstream press badgers them into doing so. The question has been floated for years. (And even then, the answer will change six times before launch.) – Camille Goudeseune Sep 29 '19 at 23:05

## 3 Answers

How will Starship ... accommodate micro-gravity?

As of today, it won't.

Making non-micro gravity by spinning about its long axis is impractical because the ship's radius is only 15 feet.

Others have made detailed calculations for spinning about other axes. This is the kind of thing that helps SpaceX cultivate its bonkers-but-works reputation, but SpaceX hasn't exploited it.

SpaceX's press kits mention topics like exercise and bone density and microgravity only in the context of experiments on ISS, which Dragon visits to resupply. So they're aware of the issue, but they're not yet announcing anything. No word about how to stow a dozen NordicTracks into three cubic feet.

They might not announce anything until they hire someone in that field. None of SpaceX's hundreds of job offers cover this topic. The closest they come is Radiation Effects Engineer (whoops, the effects on avionics, not on humans) and Environmental Health & Safety Technician (whoops, OSHA compliance for work sites, not in-flight).

But here's what is needed, from the literature.

To avoid bone loss, its occupants will need mechanical shock loading during exercise. This 1998 Acta Astronautica article reports:

... By applying an external impulsive load for a short period each day, which is intended to mimic the heel strike transient, to the lower limb of an astronaut during a long term space flight (5 months), this study tests the hypothesis that the bone cells can be activated by an appropriate external mechanical stimulus to maintain bone mass throughout prolonged periods of weightlessness.

... During the EUROMIR95 mission, an astronaut used this device for a short period daily [on only one heel]. ... Bone mineral density was maintained [on that heel], while it was reduced by up to 7% on the [other one].

To maintain muscle, exercise suffices.

We don't yet know how to avoid dizziness and nausea upon leaving microgravity.

A partial answer: according to Garret Erin Reisman, professor of astronautical engineering and former SpaceX human spaceflight developer, the current state of knowledge is that you can get around a loss of bone mass almost entirely by proper exercise.

The key to this is that bone loss is basically an issue of a lack of stimulation, and not a lack of exercise per se. So, the state of the art is to exercise with high intensity and low repetitiveness. Then, bone loss is very low, even in microgravity.

He said that almost literally at some point during the linked Space Show. Sorry I don't have the exact time at hand atm.

• Also former shuttle astronaut. – Organic Marble Oct 2 '19 at 11:12

Spacex does not know it is going to do that. It actually is delaying a crewed Mars landing for NASA and will soon be for Spacex.

$$`$$

• I had to downvote you because your source is almost 5 years making it totally inapplicable, and your point is inaccurate and speculative. NASA has no schedule or plans for any Mars landings because as yet it has no launch systems or interplanetary vessels capable of delivering humans to the surface and back. The answer to bone density loss is exercise, which has been proven to work well on ISS. – SafeFastExpressive Apr 24 at 23:49


text:
## A community for students. Sign up today

Here's the question you clicked on:

## anonymous 4 years ago If the rate of decomposition of NOBr is 4.60*10^-4M.s^-1. What is the rate of formation of Br2 gas? Seriously i'm getting more confused about tis question.. A little help please..

• This Question is Closed
1. JFraser

What's the balanced equation for the reaction? The coefficients should give you the biggest help with this kind of question.

2. anonymous

for the value of 4.60*10^-4M.s^-1... is it the value for change of [NOBr] or is it the value at the x?? Refering to the "lovely" equation i've drawn.. :p quite confused at tat part..

3. anonymous

wait2..

4. anonymous

|dw:1332247375165:dw|

5. JFraser

the balanced reaction is$2NOBr \rightarrow 2NO + Br_{2}$ when NOBr is being used, the Br2 is being formed at half the amount, so half the rate.

6. anonymous

the rate which is concentration per time??

7. anonymous

owh!! got the answer!! thank you!! ^^

#### Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy


text:
### Reminder

Let $\hat{\theta}$ be an unbiased estimator of $\theta$, $S$ a sample on which we compute the estimation of $\theta$ and $\hat{\theta}_S$ the estimation of $\theta$ on $S$ with $\hat{\theta}$.
By definition, the confidence interval for a threshold of $\alpha$, noted \begin{align*} CI_{1-\alpha}(\theta;\hat{\theta},S) = CI(\theta;\hat{\theta},S,1-\alpha) &= \left[\hat{\theta}_S - z ; \hat{\theta}_S + z \right] \\ &= \left[\hat{\theta}_S \pm z \right] \end{align*} is defined by $\Pr(-z < \hat{\theta} < z) = 1 - \alpha$ Then, for computing a confidence interval for $\hat{\theta}_S$ we need to know the distribution of $\hat{\theta}$.

General case: $\hat{\theta}$ normally distributed

If $\hat{\theta}$ is distributed as a (non-standard) normal law, $\hat{\theta} \sim N(E[\hat{\theta}] = \theta,V[\hat{\theta}])$, we perform a variable change to come down to a standard distribution: $P\left(\mu - z_{1-\frac{\alpha}{2}}\sqrt{\frac{\sigma^2}{n}} < Z < \mu + z_{1-\frac{\alpha}{2}}\sqrt{\frac{\sigma^2}{n}}\right) = 1 - \alpha$ And then the confidence interval is given by $CI(\theta;\hat{\theta},S,1-\alpha) = \left[\hat{\theta}_S \pm z_{1 - \frac{\alpha}{2}}\sqrt{\frac{\sigma^2}{n}}\right]$ Furthermore $P(-z < Z < z) = 1 - \alpha$ Which is equivalent to $\displaystyle P(Z < z) = 1 - \frac{\alpha}{2}$.
For $\alpha = 0.05$, we have $z_{1 - \frac{\alpha}{2}} = 1.96$. (see: Z table)
For $\alpha = 0.10$, we have $z_{1 - \frac{\alpha}{2}} = 1.64$.

And the confidence interval is given by $CI(\theta;\hat{\theta},S,1-\alpha) = \left[\hat{\theta}_S \pm z_{1 - \frac{\alpha}{2}}\right]$

If $\hat{\theta}$ is distributed as a non-standard normal law, $\hat{\theta} \sim N(E[\hat{\theta}] = \theta,V[\hat{\theta}])$, we perform a variable change $P\left(\mu - z_{1-\frac{\alpha}{2}}\sqrt{\frac{\sigma^2}{n}} < Z < \mu + z_{1-\frac{\alpha}{2}}\sqrt{\frac{\sigma^2}{n}}\right) = 1 - \alpha$ And then the confidence interval is given by $CI(\theta;\hat{\theta},S,1-\alpha) = \left[\hat{\theta}_S \pm z_{1 - \frac{\alpha}{2}}\sqrt{\frac{\sigma^2}{n}}\right]$ Note: the standard deviation of an estimator is called the standard error. In the case of the estimator $\displaystyle \bar{X} = \sum_{i=1}^n X_i$, the
Total number of exercises available: 34


text:
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The present tutorial analyses the Tennis Grand Slam tournaments main results from the statistical point of view. Specifically, I try to answer the following questions:

– How to fit the distribution of the Grand Slam tournaments number of victories across players?
– How to compute the probability of having player’s victories greater than a specific number?
– How the number of Grand Slam tournaments winners increases along with time?
– How can we assign a metric to the tennis players based on the number of Grand Slam tournaments they won?

Our dataset is provided within ref. [1], whose content is based on what reported by the ESP site at: ESPN site tennis history table.

### Packages

suppressPackageStartupMessages(library(fitdistrplus))
suppressPackageStartupMessages(library(extremevalues))
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(knitr))
suppressPackageStartupMessages(library(ggplot2))

## Analysis

The analysis within the present tutorial is organized as follows:

• a basic data exploration is run
• log-normal distribution is fit against the Grand Slam tournaments victories data
• regression analysis is presented in order to evaluate the increase of tennis Grand Slam champions along with time
• population statistical dispersion is evaluated to determine a Tennis Quotient assigned to tournaments’ winners

### Basic Data Exploration

Loading the Tennis Grand Slam tournaments dataset and running a basic data exploration.

url_file <- "https://datascienceplus.com/wp-content/uploads/2017/12/tennis-grand-slam-winners_end2017.txt"
slam_win <- read.delim(url(url_file), sep="\t", stringsAsFactors = FALSE)
dim(slam_win)
[1] 489   4

| YEAR|TOURNAMENT      |WINNER        |RUNNER.UP      |
|----:|:---------------|:-------------|:--------------|
| 2017|U.S. Open       |Rafael Nadal  |Kevin Anderson |
| 2017|Wimbledon       |Roger Federer |Marin Cilic    |
| 2017|French Open     |Rafael Nadal  |Stan Wavrinka  |
| 2017|Australian Open |Roger Federer |Rafael Nadal   |
| 2016|U.S. Open       |Stan Wawrinka |Novak Djokovic |
| 2016|Wimbledon       |Andy Murray   |Milos Raonic   |

kable(tail(slam_win), row.names=FALSE)
| YEAR|TOURNAMENT |WINNER           |RUNNER.UP          |
|----:|:----------|:----------------|:------------------|
| 1881|U.S. Open  |Richard D. Sears |William E. Glyn    |
| 1881|Wimbledon  |William Renshaw  |John Hartley       |
| 1880|Wimbledon  |John Hartley     |Herbert Lawford    |
| 1879|Wimbledon  |John Hartley     |V. St. Leger Gould |
| 1878|Wimbledon  |Frank Hadow      |Spencer Gore       |
| 1877|Wimbledon  |Spencer Gore     |William Marshall   |

nr <- nrow(slam_win)
start_year <- slam_win[nr, "YEAR"]
end_year <- slam_win[1, "YEAR"]
(years_span <- end_year - start_year + 1)
[1] 141

(total_slam_winners <- length(unique(slam_win[,"WINNER"])))
[1] 166

So we have 166 winners spanning over 141 years of Tennis Grand Slam tournaments. We observe that during first and second World Wars, a reduced number of Grand Slam tournaments were played for obvious reasons.

slam_win_df <- as.data.frame(table(slam_win[,"WINNER"]))
slam_win_df =  slam_win_df %>% arrange(desc(Freq))
pos <- rep(0, nrow(slam_win_df))
pos[1] <- 1
for(i in 2:nrow(slam_win_df)) {
pos[i] <- ifelse(slam_win_df$Freq[i] != slam_win_df$Freq[i-1], i, pos[i-1])
}
last_win_year = sapply(slam_win_df$Var1, function(x) {slam_win %>% filter(WINNER == x) %>% dplyr::select(YEAR) %>% max()}) # creating and showing leaderboard dataframe slam_winners <- data.frame(RANK = pos, PLAYER = slam_win_df$Var1,
WINS = slam_win_df$Freq, LAST_WIN_YEAR = last_win_year) kable(slam_winners) | RANK|PLAYER | WINS| LAST_WIN_YEAR| |----:|:---------------------------|----:|-------------:| | 1|Roger Federer | 19| 2017| | 2|Rafael Nadal | 16| 2017| | 3|Pete Sampras | 14| 2002| | 4|Novak Djokovic | 12| 2016| | 4|Roy Emerson | 12| 1967| ...  The WINS and log(WINS) distribution density are shown. par(mfrow=c(1,2)) plot(density(slam_winners$WINS), main = "Wins Density")
plot(density(log(slam_winners$WINS)), main = "Log Wins Density")  Gives this plot: You may want to arrange the same dataframe ordering by the champions’ last win year. par(mfrow=c(1,1)) slam_winners_last_win_year = slam_winners %>% arrange(LAST_WIN_YEAR) kable(slam_winners %>% arrange(desc(LAST_WIN_YEAR))) | RANK|PLAYER | WINS| LAST_WIN_YEAR| |----:|:---------------------------|----:|-------------:| | 1|Roger Federer | 19| 2017| | 2|Rafael Nadal | 16| 2017| | 4|Novak Djokovic | 12| 2016| | 43|Andy Murray | 3| 2016| ...  We may want to visualize the timeline of the number of Tennis Grand Slam champions. df_nwin = data.frame() for (year in start_year : end_year) { n_slam_winners = slam_win %>% filter(YEAR <= year) %>% dplyr::select(WINNER) %>% unique %>% nrow df_nwin = rbind(df_nwin, data.frame(YEAR = year, N_WINNERS = n_slam_winners)) } plot(x = df_nwin$YEAR, y = df_nwin$N_WINNERS, type ='s', xlab = "year", ylab = "no_winners") grid()  Gives this plot: We may want to visualize the timeline of the Grand Slam tournaments wins record. df2_nwin = data.frame() for (year in start_year : end_year) { slam_win_years = slam_win %>% filter(YEAR <= year) slam_win_record = as.data.frame(table(slam_win_years[,"WINNER"])) df2_nwin = rbind(df2_nwin, data.frame(YEAR = year, RECORD_WINS = max(slam_win_record$Freq)))
}
plot(x = df2_nwin$YEAR, y = df2_nwin$RECORD_WINS, type ='s', xlab = "year", ylab = "record_wins")
grid()

Gives this plot:

It is interesting to have a look at the number of wins frequency.

wins_frequency <- as.data.frame(table(slam_winners[,"WINS"]))
colnames(wins_frequency) <- c("WINS", "FREQUENCY")
kable(wins_frequency)
|WINS | FREQUENCY|
|:----|---------:|
|1    |        80|
|2    |        25|
|3    |        19|
|4    |        12|
|5    |         5|
|6    |         3|
|7    |         6|
|8    |         8|
|10   |         1|
|11   |         2|
|12   |         2|
|14   |         1|
|16   |         1|
|19   |         1|

summary(slam_winners[,"WINS"])
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
1.000   1.000   2.000   2.946   3.750  19.000

### Probabilistic Distribution Fit

We now take advantage of the fitdist() function within the fitdistr package to fit a lognormal distribution for our Grand Slam wins data.

fw <- fitdist(slam_winners$WINS, "lnorm") summary(fw) Fitting of the distribution ' lnorm ' by maximum likelihood Parameters : estimate Std. Error meanlog 0.7047927 0.06257959 sdlog 0.8062817 0.04425015 Loglikelihood: -316.7959 AIC: 637.5918 BIC: 643.8158 Correlation matrix: meanlog sdlog meanlog 1 0 sdlog 0 1  Then we can plot the distribution fit results. plot(fw)  Gives this plot: # left outliers quantile left_thresh <- 0.05 # right outliers quantile right_thresh <- 0.95 # determining the outliers slam_outlier <- getOutliersI(as.vector(slam_winners$WINS),
FLim = c(left_thresh, right_thresh),
distribution = "lognormal")
# outliers are plotted in red color
outlierPlot(slam_winners$WINS, slam_outlier, mode="qq")  Gives this plot: The outliers are: slam_winners[slam_outlier$iRight,]
RANK        PLAYER WINS LAST_WIN_YEAR
1    1 Roger Federer   19          2017
2    2  Rafael Nadal   16          2017

The mean and standard deviation associated to the log-normal fit are:

(mean_log <- fw$estimate["meanlog"]) meanlog 0.7047927 (sd_log <- fw$estimate["sdlog"])
sdlog
0.8062817

Now we compute the probability associated with 19 and 16 wins.

# clearing names
names(mean_log) <- NULL
names(sd_log) <- NULL
# probability associated to 19 wins performance or more
(lnorm_19 <- plnorm(19, mean_log, sd_log, lower.tail=FALSE))
[1] 0.002736863

# probability associated to 16 wins performance or more
(lnorm_16 <- plnorm(16, mean_log, sd_log, lower.tail=FALSE))
[1] 0.005164628

However, if a random variable follows a log-normal distribution, its logarithm follows a normal distribution. Hence we fit the logarithm of the variable under analysis using a normal distribution and compare the results with above log-normal fit.

fw_norm <- fitdist(log(slam_winners$WINS), "norm") summary(fw_norm) Fitting of the distribution ' norm ' by maximum likelihood Parameters : estimate Std. Error mean 0.7047927 0.06257959 sd 0.8062817 0.04425015 Loglikelihood: -199.8003 AIC: 403.6006 BIC: 409.8246 Correlation matrix: mean sd mean 1 0 sd 0 1  Similarly, we plot the fit results. plot(fw_norm)  Gives this plot: # left outliers quantile left_thresh <- 0.05 # right outliers quantile right_thresh <- 0.95 slam_outlier <- getOutliersI(log(as.vector(slam_winners$WINS)),
FLim = c(left_thresh, right_thresh),
distribution = "normal")
outlierPlot(slam_winners$WINS, slam_outlier, mode="qq")  Gives this plot: The outliers are: slam_winners[slam_outlier$iRight,]
RANK        PLAYER WINS LAST_WIN_YEAR
1    1 Roger Federer   19          2017
2    2  Rafael Nadal   16          2017

The mean and standard deviation values are:

# mean and standard deviation of the fitted lognormal distribution
(mean_norm <- fw_norm$estimate["mean"]) mean 0.7047927 (sd_norm <- fw_norm$estimate["sd"])
sd
0.8062817

As we can see above, same fitting parameters result from the two approaches, even though with different log-likelihood, AIC and BIC metrics. Now we compute the probability associated to 19 and 16 wins together with their distance from the mean in terms of multiples of the standard deviation.

# clearing names
names(mean_norm) <- NULL
names(sd_norm) <- NULL
# probability associated to the 19 wins performance or better
(norm_19 <- pnorm(log(19), mean_norm, sd_norm, lower.tail=FALSE))
[1] 0.002736863

# standard deviation times from the mean associated to 19 wins
(deviation_19 <- (log(19) - mean_norm)/sd_norm)

[1] 2.777747

# probability associated to the 16 wins performance or better
(norm_16 <- pnorm(log(16), mean_norm, sd_norm, lower.tail=FALSE))

[1] 0.005164628

# standard deviation times from the mean associated to 16 wins
(deviation_16 <- (log(16) - mean_norm)/sd_norm)

[1] 2.564608

As we can see above, we also obtained the same probability value as resulting from the log-normal distribution fit. In the following, we consider the second fitting approach (the one which takes the log of the original variable) for easing the computation of the distance from the mean in terms of multiples of the standard deviation.

## Regression Analysis

Let us see again the plot of the number of tennis Grand Slam winners against their timeline.

year <- df_nwin $YEAR winners <- df_nwin$N_WINNERS
plot(x = year, y = winners, type ='l')
grid()

Gives this plot:

It is visually evident the linear relationship between the variables. Hence, a linear regression would help in understanding how many newbie Grand Slam winners we may have each year.

year_lm <- lm(winners ~ year)
summary(year_lm)
Call:
lm(formula = winners ~ year)

Residuals:
Min      1Q  Median      3Q     Max
-9.8506 -1.9810 -0.4683  2.6102  6.2866

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.388e+03  1.220e+01  -195.8   <2e-16 ***
year         1.270e+00  6.264e-03   202.8   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.027 on 139 degrees of freedom
Multiple R-squared:  0.9966,	Adjusted R-squared:  0.9966
F-statistic: 4.113e+04 on 1 and 139 DF,  p-value: < 2.2e-16

Coefficients are reported as significant and the R-squared value is very high. On average each year, 1.27 Grand Slam tournaments newbie winners show up. Residuals analysis has not been reported for brevity. Similarly, we can regress the year against the number of winners.

n_win_lm <- lm(year ~ winners)
summary(n_win_lm)
Call:
lm(formula = year ~ winners)

Residuals:
Min      1Q  Median      3Q     Max
-4.8851 -1.9461  0.3268  1.4327  7.9641

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.880e+03  3.848e-01  4886.4   <2e-16 ***
winners     7.846e-01  3.868e-03   202.8   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.379 on 139 degrees of freedom
Multiple R-squared:  0.9966,	Adjusted R-squared:  0.9966
F-statistic: 4.113e+04 on 1 and 139 DF,  p-value: < 2.2e-16

Coefficients are reported as significant and the R-squared value is very high. On average, each new Grand Slam tournaments winner appears every 0.7846 fraction of year. Residuals analysis has not been reported for brevity. Such model can be used to predict the year when a given number of Grand Slam winners may show up. For example, considering Federer, Nadal and Sampras wins, we obtain:

# probability associated to the 14 wins performance or better
(norm_14 <- pnorm(log(14), mean_norm, sd_norm, lower.tail=FALSE))
[1] 0.008220098

# standard deviation times from the mean associated to 14 wins
(deviation_14 <- (log(14) - mean_norm)/sd_norm)
[1] 2.398994

# average number of Grand Slam winners to expect for a 19 Grand Slam wins champion
(x_19 <- round(1/norm_19))
[1] 365

# average number of Grand Slam winners to expect for a 16 Grand Slam wins champion
(x_16 <- round(1/norm_16))
[1] 194

# average number of Grand Slam winners to expect for a 14 Grand Slam wins champion
(x_14 <- round(1/norm_14))
[1] 122

The x_19, x_16 and x_14 values can be interpreted as the average size of Grand Slam tournaments winners population to therein find a 19, 16, 14 times winner respectively. As a consequence, the prediction of the calendar years to see players capable to win 19, 16, 14 times is:

predict(n_win_lm, newdata = data.frame(winners = c(x_19, x_16, x_14)), interval = "p")
fit      lwr      upr
1 2166.732 2161.549 2171.916
2 2032.573 2027.779 2037.366
3 1976.084 1971.355 1980.813

The table above shows the earliest year when, on average, to expect a Grand Slam tournament winner capable to win 19, 16, 14 times (fit column), together with lower (lwr) and upper (upr) bound predicted values. In the real world, 14 wins champion showed up a little bit later than expected by our linear regression model, whilst 16 and 19 win champions did much earlier than expected by the same model.

### Population Statistical Dispersion Analysis

In our previous analysis, we computed the distance from the mean for 19, 16 and 14 Grand Slam tournaments win probabilities, distance expressed in terms of multiples of the standard deviation.

deviation_19
[1] 2.777747

deviation_16
[1] 2.564608

deviation_14
[1] 2.398994

Based on above values, we can compute the probability to have a 19, 16 and 14 times winner. As we saw before, we resume up such result using the pnorm() function.

(prob_19 <- pnorm(mean_norm+deviation_19*sd_norm, mean_norm, sd_norm, lower.tail = FALSE))
[1] 0.002736863

(prob_16 <- pnorm(mean_norm+deviation_16*sd_norm, mean_norm, sd_norm, lower.tail = FALSE))
[1] 0.005164628

(prob_14 <- pnorm(mean_norm+deviation_14*sd_norm, mean_norm, sd_norm, lower.tail = FALSE))
[1] 0.008220098

Similarly to the Intellectual Quotient (IQ) assigning a value equal to 100 at the mean and +/- 15 points for each standard deviation of distance from the mean itself, we can figure out a Tennis Quotient (TQ).

Here in below, we show a plot to remember how the IQ is computed:

We notice that the median of our player’s population scores a TQ equal to 100.

(median_value <- median(slam_winners\$WINS))
[1] 2

(deviation_median <- (log(median_value) - mean_norm)/sd_norm)
[1] -0.01444343

round(100 + 15*deviation_median)
[1] 100

We now compute the Tennis Quotients (TQ) for leading champions.

(Federer_TQ <- round(100 + 15*deviation_19))
[1] 142

[1] 138

(Sampras_TQ <- round(100 + 15*deviation_14))
[1] 136

And what about for example 7 times Grand Slam tournament winner?

(deviation_7 <- (log(7) - mean_norm)/sd_norm)
[1] 1.53931

TQ_7wins <- round(100 + 15*deviation_7)
[1] 123

Let us then compute the Tennis Quotients (TQ) for all our tennis Grand Slam tournaments winners.

tq_compute <- function(x) {
deviation_x <- (log(x) - mean_norm)/sd_norm
round(100 + 15*deviation_x)
}
slam_winners = slam_winners %>% mutate(TQ = tq_compute(WINS))
kable(slam_winners)
| RANK|PLAYER                      | WINS| LAST_WIN_YEAR|  TQ|
|----:|:---------------------------|----:|-------------:|---:|
|    1|Roger Federer               |   19|          2017| 142|
|    2|Rafael Nadal                |   16|          2017| 138|
|    3|Pete Sampras                |   14|          2002| 136|
|    4|Novak Djokovic              |   12|          2016| 133|
....

We then visualize the top twenty Grand Slam tournaments champions.

ggplot(data=slam_winners[1:20,], aes(x=reorder(PLAYER, TQ), y=TQ, fill = TQ)) +
geom_bar(stat ="identity") + coord_flip() +
scale_y_continuous(breaks = seq(0,150,10), limits = c(0,150)) +
xlab("PLAYER")

Gives this plot.

## Conclusions

The answers to our initial questions:

– The log-normal distribution
– Based upon the fitted distribution and taking advantage of plnorm() or pnorm() stats package functions, probabilities have been computed
– A linear increase is a very good fit for that, resulting in significative regression coefficients and high R-squared values
– Yes, we defined the Tennis Quotient similarly to the Intellectual Quotient and show the resulting leaderboard. Federer is confirmed “genius” in that respect, however, a few other very talented players are not that far from him.

If you have any questions, please feel free to comment below.

References

Related Post


text:
Plot Decision Boundaries Using Python and Scikit-Learn

# Plot Decision Boundaries Using Python and Scikit-Learn

Tree-based models have become a popular choice for Machine Learning, not only due to their results, and the need for fewer transformations when working with data (due to robustness to input and scale invariance), but also because there is a way to take a peek inside of them to see what is going on with the data.

We'll assume you have just trained a tree-based classifier using a Decision Tree model, and you want to take a look at how the tree is handling the data. You want to see what decisions were made when classifying a point as belonging to a class!

Advice: If you want to get more familiar with tree-based models, you can read our in-depth "Guide to Decision Trees in Python with Scikit-Learn!".

This means you want to look at the decision boundaries of the tree. Fortunately, Scikit-Learn already has a DecisionBoundaryDisplay in the sklearn.inspection module.

First, we'll load a toy wine dataset and divide it into train and test sets:

from sklearn.datasets import load_wine
from sklearn.model_selection import train_test_split

SEED = 42

X = data.data
y = data.target

X_train, X_test, y_train, y_test = train_test_split(X, y,
random_state=SEED)

After splitting the data, we can choose two data columns to plot the decision boundary, fit the tree classifier on them, and generate the plot:

# Importing necessary libraries
import matplotlib.pyplot as plt
from sklearn.inspection import DecisionBoundaryDisplay
from sklearn.tree import DecisionTreeClassifier

# Choosing the first 2 columns for the plot
X_train_cols = X_train[:, :2]

# Creating and fitting the tree classifier
classifier = DecisionTreeClassifier(max_depth=4,
random_state=SEED).fit(X_train_cols, y_train)

# Plotting the tree boundaries
disp = DecisionBoundaryDisplay.from_estimator(classifier,
X_train_cols,
response_method="predict",
xlabel=data.feature_names[0], ylabel=data.feature_names[1],
alpha=0.5,
cmap=plt.cm.coolwarm)

# Plotting the data points
disp.ax_.scatter(X_train[:, 0], X_train[:, 1],
c=y_train, edgecolor="k",
cmap=plt.cm.coolwarm)

plt.title(f"Decision surface for tree trained on {data.feature_names[0]} and {data.feature_names[1]}
")
plt.show()

The resulting plot is the following:

## Get free courses, guided projects, and more

The original wine dataset has 13 columns, notice that we have chosen only 2 columns - alcohol and malic_acid, so the data could be plotted using two dimensions instead of 13. And that's it - you've just plotted the decision boundaries using Python and Scikit-Learn! But, if you are interested to take a look at a few more examples - continue reading!

Note: You can also reduce the data dimensions to 2 with a method such as PCA and then plot the model's decision boundary. Doing this would result in the same code as the previous one, just substituting X_train_cols for the resulting principal components.

### Plotting Decision Boundaries - Additional Example

If it is interesting to take a look at more feature combinations, below is a way of plotting the combinations for the first 5 columns of the wine dataset.

The initial step is to generate all the unique combinations of features:

from itertools import combinations
import numpy as np

# Generating all pairs of numbers from 0 to 5
comb = combinations(np.arange(0, 6), 2)

# Using sets to obtain all unique combinations from 0 to 5 pairs
unique_combinations = set(comb)
# Results in {(0, 1), (2, 4), (1, 2), (0, 4), (3, 4), (1, 5), (0, 3), (1, 4), (2, 3), (0, 2), (4, 5), (0, 5), (2, 5), (1, 3), (3, 5)}

The unique_combinations will be the columns for which the decision boundaries will be plotted:

# Setting some parameters that will be used in the plot
n_classes = 3
color_palette = plt.cm.coolwarm
plot_colors = "bwr" # blue, white and red, same as the coolwarm palette
plot_step = 0.02

plt.figure(figsize=(25, 12))

for pair_idx, pair in enumerate(sorted(unique_combinations)):
# Only two corresponding features are taken each time
X_train_cols = X_train[:, pair]

# Creating and fitting the classifier to train data
classifier = DecisionTreeClassifier(max_depth=4,
random_state=SEED).fit(X_train_cols, y_train)

# Defining a grid of 5 columns and 3 rows
ax = plt.subplot(3, 5, pair_idx + 1)
# Plotting the pairs decision boundaries
DecisionBoundaryDisplay.from_estimator(classifier,
X_train_cols,
cmap=color_palette,
response_method="predict",
ax=ax,
xlabel=data.feature_names[pair[0]],
ylabel=data.feature_names[pair[1]],
alpha = 0.5)

# Plotting the training points according to y_train class colors
for i, color in zip(range(n_classes), plot_colors):
idx = np.where(y_train == i)
plt.scatter(X_train_cols[idx, 0],
X_train_cols[idx, 1],
c=color,
label=data.target_names[i],
cmap=color_palette,
edgecolor="black",
s=15)

plt.suptitle("Decision surface of decision trees trained on pairs of features", fontsize=14)
plt.legend(loc="lower right");

This code displays the following plot:

Both decision plots have lots of customizations, such as the color palettes, opacity, space between the plot and the labels, etc. Try to play around with changing some of the values to better understand each part of the code!

Note: The DecisionBoundaryDisplay isn't limited to tree-based models, you can use it with other estimators in Scikit-learn, read the documentation to know more about other uses.

Last Updated: November 21st, 2022

### You might also like...

Cássia SampaioAuthor

Data Scientist, Research Software Engineer, and teacher. Cassia is passionate about transformative processes in data, technology and life. She is graduated in Philosophy and Information Systems, with a Strictu Sensu Master's Degree in the field of Foundations Of Mathematics.

Project

### Bank Note Fraud Detection with SVMs in Python with Scikit-Learn

# python# machine learning# scikit-learn# data science

Can you tell the difference between a real and a fraud bank note? Probably! Can you do it for 1000 bank notes? Probably! But it...

Details
Project

### Hands-On House Price Prediction - Machine Learning in Python

# python# machine learning# scikit-learn# tensorflow

If you've gone through the experience of moving to a new house or apartment - you probably remember the stressful experience of choosing a property,...

Details


text:
# Receptor (biochemistry)

Last updated

In biochemistry and pharmacology, receptors are chemical structures, composed of protein, that receive and transduce signals that may be integrated into biological systems. [1] These signals are typically [nb 1] chemical messengers, which bind to a receptor, they cause some form of cellular/tissue response, e.g. a change in the electrical activity of a cell. There are three main ways the action of the receptor can be classified: relay of signal, amplification, or integration. [2] Relaying sends the signal onward, amplification increases the effect of a single ligand, and integration allows the signal to be incorporated into another biochemical pathway. [2] In this sense, a receptor is a protein-molecule that recognizes and responds to endogenous chemical signals. For example, an acetylcholine receptor recognizes and responds to its endogenous ligand, acetylcholine. However, sometimes in pharmacology, the term is also used to include other proteins that are drug targets, such as enzymes, transporters, and ion channels.[ citation needed ]

Biochemistry, sometimes called biological chemistry, is the study of chemical processes within and relating to living organisms. Biochemical processes give rise to the complexity of life.

Pharmacology is the branch of biology concerned with the study of drug or medication action, where a drug can be broadly defined as any man-made, natural, or endogenous molecule which exerts a biochemical or physiological effect on the cell, tissue, organ, or organism. More specifically, it is the study of the interactions that occur between a living organism and chemicals that affect normal or abnormal biochemical function. If substances have medicinal properties, they are considered pharmaceuticals.

Proteins are large biomolecules, or macromolecules, consisting of one or more long chains of amino acid residues. Proteins perform a vast array of functions within organisms, including catalysing metabolic reactions, DNA replication, responding to stimuli, providing structure to cells and organisms, and transporting molecules from one location to another. Proteins differ from one another primarily in their sequence of amino acids, which is dictated by the nucleotide sequence of their genes, and which usually results in protein folding into a specific three-dimensional structure that determines its activity.

## Contents

Receptor proteins can be classified by their location. Transmembrane receptors include ion channel-linked (ionotropic) receptors, G protein-linked (metabotropic) hormone receptors, and enzyme-linked hormone receptors. [1] Intracellular receptors are those found inside the cell, and include cytoplasmic receptors and nuclear receptors. [1] A molecule that binds to a receptor is called a ligand, and can be a protein or peptide (short protein), or another small molecule such as a neurotransmitter, hormone, pharmaceutical drug, toxin, or parts of the outside of a virus or microbe. The endogenously designated -molecule for a particular receptor is referred to as its endogenous ligand. E.g. the endogenous ligand for the nicotinic acetylcholine receptor is acetylcholine but the receptor can also be activated by nicotine [3] [4] and blocked by curare. [5] Receptors of a particular type are linked to a specific cellular biochemical pathways that correspond to the signal. While numerous receptors are found in most cells, each receptor will only bind with ligands of a particular structure. This has been analogously compared to how locks will only accept specifically shaped keys. When a ligand binds to a corresponding receptor, it activates or inhibits the receptor's associated biochemical pathway.

Ligand-gated ion channels (LICs, LGIC), also commonly referred to as ionotropic receptors, are a group of transmembrane ion-channel proteins which open to allow ions such as Na+, K+, Ca2+, and/or Cl to pass through the membrane in response to the binding of a chemical messenger (i.e. a ligand), such as a neurotransmitter.

G protein-coupled receptors (GPCRs), also known as seven-(pass)-transmembrane domain receptors, 7TM receptors, heptahelical receptors, serpentine receptor, and G protein–linked receptors (GPLR), constitute a large protein family of receptors that detect molecules outside the cell and activate internal signal transduction pathways and, ultimately, cellular responses. Coupling with G proteins, they are called seven-transmembrane receptors because they pass through the cell membrane seven times.

A hormone receptor is a receptor molecule that binds to a specific hormone. Hormone receptors are a wide family of proteins made up of receptors for thyroid and steroid hormones, retinoids and Vitamin D, and a variety of other receptors for various ligands, such as fatty acids and prostaglandins. There are two main classes of hormone receptors. Receptors for peptide hormones tend to be cell surface receptors built into the plasma membrane of cells and are thus referred to as trans membrane receptors. An example of this is insulin. Receptors for steroid hormones are usually found within the cytoplasm and are referred to as intracellular or nuclear receptors, such as testosterone. Upon hormone binding, the receptor can initiate multiple signaling pathways, which ultimately leads to changes in the behavior of the target cells.

## Structure

The structures of receptors are very diverse and include the following major categories, among others:

• Type 1: Ligand-gated ion channels (ionotropic receptors) – These receptors are typically the targets of fast neurotransmitters such as acetylcholine (nicotinic) and GABA; and, activation of these receptors results in changes in ion movement across a membrane. They have a heteromeric structure in that each subunit consists of the extracellular ligand-binding domain and a transmembrane domain where the transmembrane domain in turn includes four transmembrane alpha helices. The ligand-binding cavities are located at the interface between the subunits.
• Type 2: G protein-coupled receptors (metabotropic receptors) – This is the largest family of receptors and includes the receptors for several hormones and slow transmitters e.g. dopamine, metabotropic glutamate. They are composed of seven transmembrane alpha helices. The loops connecting the alpha helices form extracellular and intracellular domains. The binding-site for larger peptide ligands is usually located in the extracellular domain whereas the binding site for smaller non-peptide ligands is often located between the seven alpha helices and one extracellular loop. [6] The aforementioned receptors are coupled to different intracellular effector systems via G proteins. [7]
• Type 3: Kinase-linked and related receptors (see "Receptor tyrosine kinase" and "Enzyme-linked receptor") – They are composed of an extracellular domain containing the ligand binding site and an intracellular domain, often with enzymatic-function, linked by a single transmembrane alpha helix. The insulin receptor is an example.
• Type 4: Nuclear receptors – While they are called nuclear receptors, they are actually located in the cytoplasm and migrate to the nucleus after binding with their ligands. They are composed of a C-terminal ligand-binding region, a core DNA-binding domain (DBD) and an N-terminal domain that contains the AF1(activation function 1) region. The core region has two zinc fingers that are responsible for recognizing the DNA sequences specific to this receptor. The N terminus interacts with other cellular transcription factors in a ligand-independent manner; and, depending on these interactions, it can modify the binding/activity of the receptor. Steroid and thyroid-hormone receptors are examples of such receptors. [8]

The alpha helix (α-helix) is a common motif in the secondary structure of proteins and is a right hand-helix conformation in which every backbone N−H group donates a hydrogen bond to the backbone C=O group of the amino acid located three or four residues earlier along the protein sequence.

Receptor tyrosine kinases (RTKs) are the high-affinity cell surface receptors for many polypeptide growth factors, cytokines, and hormones. Of the 90 unique tyrosine kinase genes identified in the human genome, 58 encode receptor tyrosine kinase proteins. Receptor tyrosine kinases have been shown not only to be key regulators of normal cellular processes but also to have a critical role in the development and progression of many types of cancer. Mutations in receptor tyrosine kinases lead to activation of a series of signalling cascades which have numerous effects on protein expression. Receptor tyrosine kinases are part of the larger family of protein tyrosine kinases, encompassing the receptor tyrosine kinase proteins which contain a transmembrane domain, as well as the non receptor tyrosine kinases which do not possess transmembrane domains.

An enzyme-linked receptor, also known as a catalytic receptor, is a transmembrane receptor, where the binding of an extracellular ligand causes enzymatic activity on the intracellular side. Hence a catalytic receptor is an integral membrane protein possessing both enzymatic catalytic and receptor functions.

Membrane receptors may be isolated from cell membranes by complex extraction procedures using solvents, detergents, and/or affinity purification.

The structures and actions of receptors may be studied by using biophysical methods such as X-ray crystallography, NMR, circular dichroism, and dual polarisation interferometry. Computer simulations of the dynamic behavior of receptors have been used to gain understanding of their mechanisms of action.

Nuclear magnetic resonance spectroscopy of proteins is a field of structural biology in which NMR spectroscopy is used to obtain information about the structure and dynamics of proteins, and also nucleic acids, and their complexes. The field was pioneered by Richard R. Ernst and Kurt Wüthrich at the ETH, and by Ad Bax, Marius Clore, and Angela Gronenborn at the NIH, among others. Structure determination by NMR spectroscopy usually consists of several phases, each using a separate set of highly specialized techniques. The sample is prepared, measurements are made, interpretive approaches are applied, and a structure is calculated and validated.

Circular dichroism (CD) is dichroism involving circularly polarized light, i.e., the differential absorption of left- and right-handed light. Left-hand circular (LHC) and right-hand circular (RHC) polarized light represent two possible spin angular momentum states for a photon, and so circular dichroism is also referred to as dichroism for spin angular momentum. This phenomenon was discovered by Jean-Baptiste Biot, Augustin Fresnel, and Aimé Cotton in the first half of the 19th century. It is exhibited in the absorption bands of optically active chiral molecules. CD spectroscopy has a wide range of applications in many different fields. Most notably, UV CD is used to investigate the secondary structure of proteins. UV/Vis CD is used to investigate charge-transfer transitions. Near-infrared CD is used to investigate geometric and electronic structure by probing metal d→d transitions. Vibrational circular dichroism, which uses light from the infrared energy region, is used for structural studies of small organic molecules, and most recently proteins and DNA.

Computer simulation is the reproduction of the behavior of a system using a computer to simulate the outcomes of a mathematical model associated with said system. Since they allow to check the reliability of chosen mathematical models, computer simulations have become a useful tool for the mathematical modeling of many natural systems in physics, astrophysics, climatology, chemistry, biology and manufacturing, human systems in economics, psychology, social science, health care and engineering. Simulation of a system is represented as the running of the system's model. It can be used to explore and gain new insights into new technology and to estimate the performance of systems too complex for analytical solutions.

## Binding and activation

Ligand binding is an equilibrium process. Ligands bind to receptors and dissociate from them according to the law of mass action in the following equation, for a ligand L and receptor, R. The brackets around chemical species denote their concentrations.

In a chemical reaction, chemical equilibrium is the state in which both reactants and products are present in concentrations which have no further tendency to change with time, so that there is no observable change in the properties of the system. Usually, this state results when the forward reaction proceeds at the same rate as the reverse reaction. The reaction rates of the forward and backward reactions are generally not zero, but equal. Thus, there are no net changes in the concentrations of the reactant(s) and product(s). Such a state is known as dynamic equilibrium.

In chemistry, the law of mass action is the proposition that the rate of a chemical reaction is directly proportional to the product of the activities or concentrations of the reactants. It explains and predicts behaviors of solutions in dynamic equilibrium. Specifically, it implies that for a chemical reaction mixture that is in equilibrium, the ratio between the concentration of reactants and products is constant.

${\displaystyle {[{\ce {L}}]+[{\ce {R}}]{\ce {<=>[{K_{d}}]}}[{\text{LR}}]}}$

One measure of how well a molecule fits a receptor is its binding affinity, which is inversely related to the dissociation constant Kd. A good fit corresponds with high affinity and low Kd. The final biological response (e.g. second messenger cascade, muscle-contraction), is only achieved after a significant number of receptors are activated.

Affinity is a measure of the tendency of a ligand to bind to its receptor. Efficacy is the measure of the bound ligand to activate its receptor.

### Agonists versus antagonists

Not every ligand that binds to a receptor also activates that receptor. The following classes of ligands exist:

• (Full) agonists are able to activate the receptor and result in a strong biological response. The natural endogenous ligand with the greatest efficacy for a given receptor is by definition a full agonist (100% efficacy).
• Partial agonists do not activate receptors with maximal efficacy, even with maximal binding, causing partial responses compared to those of full agonists (efficacy between 0 and 100%).
• Antagonists bind to receptors but do not activate them. This results in a receptor blockade, inhibiting the binding of agonists and inverse agonists. Receptor antagonists can be competitive (or reversible), and compete with the agonist for the receptor, or they can be irreversible antagonists that form covalent bonds (or extremely high affinity non-covalent bonds) with the receptor and completely block it. The proton pump inhibitor omeprazole is an example of an irreversible antagonist. The effects of irreversible antagonism can only be reversed by synthesis of new receptors.
• Inverse agonists reduce the activity of receptors by inhibiting their constitutive activity (negative efficacy).
• Allosteric modulators : They do not bind to the agonist-binding site of the receptor but instead on specific allosteric binding sites, through which they modify the effect of the agonist. For example, benzodiazepines (BZDs) bind to the BZD site on the GABAA receptor and potentiate the effect of endogenous GABA.

Note that the idea of receptor agonism and antagonism only refers to the interaction between receptors and ligands and not to their biological effects.

### Constitutive activity

A receptor which is capable of producing a biological response in the absence of a bound ligand is said to display "constitutive activity". [9] The constitutive activity of a receptor may be blocked by an inverse agonist. The anti-obesity drugs rimonabant and taranabant are inverse agonists at the cannabinoid CB1 receptor and though they produced significant weight loss, both were withdrawn owing to a high incidence of depression and anxiety, which are believed to relate to the inhibition of the constitutive activity of the cannabinoid receptor.

The GABAA receptor has constitutive activity and conducts some basal current in the absence of an agonist. This allows beta carboline to act as an inverse agonist and reduce the current below basal levels.

Mutations in receptors that result in increased constitutive activity underlie some inherited diseases, such as precocious puberty (due to mutations in luteinizing hormone receptors) and hyperthyroidism (due to mutations in thyroid-stimulating hormone receptors).

## Theories of drug-receptor interaction

### Occupation

The central dogma of receptor pharmacology is that a drug effect is directly proportional to the number of receptors that are occupied.[ citation needed ] Furthermore, a drug effect ceases as a drug-receptor complex dissociates.

Ariëns & Stephenson introduced the terms "affinity" & "efficacy" to describe the action of ligands bound to receptors. [10] [11]

• Affinity: The ability of a drug to combine with a receptor to create a drug-receptor complex.
• Efficacy: The ability of a drug-receptor complex to initiate a response.

### Rate

In contrast to the accepted Occupation Theory, Rate Theory proposes that the activation of receptors is directly proportional to the total number of encounters of a drug with its receptors per unit time. Pharmacological activity is directly proportional to the rates of dissociation and association, not the number of receptors occupied: [12]

• Agonist: A drug with a fast association and a fast dissociation.
• Partial-agonist: A drug with an intermediate association and an intermediate dissociation.
• Antagonist: A drug with a fast association & slow dissociation

### Induced-fit

As a drug approaches a receptor, the receptor alters the conformation of its binding site to produce drug—receptor complex.

### Spare Receptors

In some receptor systems (e.g. acetylcholine at the neuromuscular junction in smooth muscle), agonists are able to elicit maximal response at very low levels of receptor occupancy (<1%). Thus, that system has spare receptors or a receptor reserve. This arrangement produces an economy of neurotransmitter production and release. [8]

## Receptor-regulation

Cells can increase (upregulate) or decrease (downregulate) the number of receptors to a given hormone or neurotransmitter to alter their sensitivity to different molecule. This is a locally acting feedback mechanism.

• Change in the receptor conformation such that binding of the agonist does not activate the receptor. This is seen with ion channel receptors.
• Uncoupling of the receptor effector molecules is seen with G-protein couple receptor.
• Receptor sequestration (internalization). [13] e.g. in the case of hormone receptors.

## Examples and Ligands

The ligands for receptors are as diverse as their receptors. GPCRs (7TMs) are a particularly vast family, with at least 810 members. There are also LGICs for at least a dozen endogenous ligands, and many more receptors possible through different subunit compositions. Some common examples of ligands and receptors include: [14]

### Ion channels and G protein coupled receptors

Some example ionitropic (LGIC) and metabotropic (GPCRs) receptors are shown in the table below. The chief neurotransmitters are glutamate and GABA; other neurotransmitters are neuromodulatory. This list is by no means exhaustive.

Endogenous Ligand Ion channel receptor (LGIC) G protein coupled receptor (GPCR)
Receptors Ion current [nb 2] Exogenous LigandReceptors G protein Exogenous Ligand
Glutamate iGluRs: NMDA,
AMPA, and Kainate receptors
Na+, K+, Ca2+ [14] Ketamine Glutamate receptors: mGluRs Gq or Gi/o-
GABA GABAA
(including GABAA-rho)
Cl > HCO3 [14] Benzodiazepines GABAB receptor Gi/o Baclofen
Acetylcholine nAChR Na+, K+, Ca2+ [14] Nicotine mAChR Gq or Gi Muscarine
Glycine Glycine receptor (GlyR)Cl > HCO3 [14] Strychnine ---
Serotonin 5-HT3 receptor Na+, K+ [14] Cereulide 5-HT1-2 or 4-7 Gs, Gi/o or Gq-
ATP P2X receptors Ca2+, Na+, Mg2+ [14] BzATP[ citation needed ] P2Y receptors Gs, Gi/o or Gq-
Dopamine No ion channels[ citation needed ]-- Dopamine receptor Gs or Gi/o-

Enzyme linked receptors include receptor tyrosine kinases (RTK), serine/threonine-specific protein kinase, as in bone morphogenetic protein and guanylate cyclase, as in atrial natriuretic factor receptor. Of the RTKs, 20 classes have been identified, with 58 different RTKs as members. Some examples are shown below:

RTK Class/Receptor FamilyMemberEndogenous LigandExogenous Ligand
I EGFR EGF Gefitinib
II Insulin Receptor Insulin Chaetochromin
IV VEGFR VEGF Lenvatinib

### Intracellular Receptors

Receptors may be classed based on their mechanism or on their position in the cell. 4 examples of intracellular LGIC are shown below:

ReceptorLigandIon current
cyclic nucleotide-gated ion channels cGMP (vision), cAMP and cGTP (olfaction)Na+, K+ [14]
IP3 receptor IP3 Ca2+ [14]
Intracellular ATP receptors ATP (closes channel) [14] K+ [14]
Ryanodine receptor Ca2+Ca2+ [14]

## Role in genetic disorders

Many genetic disorders involve hereditary defects in receptor genes. Often, it is hard to determine whether the receptor is nonfunctional or the hormone is produced at decreased level; this gives rise to the "pseudo-hypo-" group of endocrine disorders, where there appears to be a decreased hormonal level while in fact it is the receptor that is not responding sufficiently to the hormone.

## In the immune system

The main receptors in the immune system are pattern recognition receptors (PRRs), toll-like receptors (TLRs), killer activated and killer inhibitor receptors (KARs and KIRs), complement receptors, Fc receptors, B cell receptors and T cell receptors. [15]

## Notes

1. In the case of the Rhodopsin receptor, the input is a photon, not a chemical
2. Different LGICs conduct currents of different ions. This is accomplished with selectivity filters, as with the selectivity filter of the K+ channel

## Related Research Articles

Signal transduction is the process by which a chemical or physical signal is transmitted through a cell as a series of molecular events, most commonly protein phosphorylation catalyzed by protein kinases, which ultimately results in a cellular response. Proteins responsible for detecting stimuli are generally termed receptors, although in some cases the term sensor is used. The changes elicited by ligand binding in a receptor give rise to a biochemical cascade, which is a chain of biochemical events as a signaling pathway.

An acetylcholine receptor is an integral membrane protein that responds to the binding of acetylcholine, a neurotransmitter.

A neurotransmitter receptor is a membrane receptor protein that is activated by a neurotransmitter. Chemicals on the outside of the cell, such as a neurotransmitter, can bump into the cell's membrane and along the membrane we can find receptors. If a neurotransmitter bumps into its corresponding receptor, they will bind and can trigger other events to occur inside the cell. Therefore, a membrane receptor is part of the molecular machinery that allows cells to communicate with one another. A neurotransmitter receptor is a class of receptors that specifically binds with neurotransmitters as opposed to other molecules.

An agonist is a chemical that binds to a receptor and activates the receptor to produce a biological response. Whereas an agonist causes an action, an antagonist blocks the action of the agonist, and an inverse agonist causes an action opposite to that of the agonist.

An excitatory synapse is a synapse in which an action potential in a presynaptic neuron increases the probability of an action potential occurring in a postsynaptic cell. Neurons form networks through which nerve impulses travel, each neuron often making numerous connections with other cells. These electrical signals may be excitatory or inhibitory, and, if the total of excitatory influences exceeds that of the inhibitory influences, the neuron will generate a new action potential at its axon hillock, thus transmitting the information to yet another cell.

A receptor antagonist is a type of receptor ligand or drug that blocks or dampens a biological response by binding to and blocking a receptor rather than activating it like an agonist. They are sometimes called blockers; examples include alpha blockers, beta blockers, and calcium channel blockers. In pharmacology, antagonists have affinity but no efficacy for their cognate receptors, and binding will disrupt the interaction and inhibit the function of an agonist or inverse agonist at receptors. Antagonists mediate their effects by binding to the active site or to the allosteric site on a receptor, or they may interact at unique binding sites not normally involved in the biological regulation of the receptor's activity. Antagonist activity may be reversible or irreversible depending on the longevity of the antagonist–receptor complex, which, in turn, depends on the nature of antagonist–receptor binding. The majority of drug antagonists achieve their potency by competing with endogenous ligands or substrates at structurally defined binding sites on receptors.

Pharmacodynamics (PD) is the study of the biochemical and physiologic effects of drugs. The effects can include those manifested within animals, microorganisms, or combinations of organisms. Pharmacodynamics is the study of how a drug affects an organism, whereas pharmacokinetics is the study of how the organism affects the drug. Both together influence dosing, benefit, and adverse effects. Pharmacodynamics is sometimes abbreviated as PD and pharmacokinetics as PK, especially in combined reference.

In pharmacology, an inverse agonist is a drug that binds to the same receptor as an agonist but induces a pharmacological response opposite to that of the agonist.

β-Endorphin is an endogenous opioid neuropeptide and peptide hormone that is produced in certain neurons within the central nervous system and peripheral nervous system. It is one of three endorphins that are produced in humans, the others of which include α-endorphin and γ-endorphin.

The GABAA receptor (GABAAR) is an ionotropic receptor and ligand-gated ion channel. Its endogenous ligand is γ-aminobutyric acid (GABA), the major inhibitory neurotransmitter in the central nervous system. Upon activation, the GABAA receptor selectively conducts Cl through its pore. Cl- will flow out of the cell if the internal voltage is less than resting potential and Cl- will flow in if it is more than resting potential. This causes an inhibitory effect on neurotransmission by diminishing the chance of a successful action potential occurring. The reversal potential of the GABAA-mediated inhibitory postsynaptic potential (IPSP) in normal solution is −70 mV, contrasting the GABAB IPSP (-100 mV).

Neuropharmacology is the study of how drugs affect cellular function in the nervous system, and the neural mechanisms through which they influence behavior. There are two main branches of neuropharmacology: behavioral and molecular. Behavioral neuropharmacology focuses on the study of how drugs affect human behavior (neuropsychopharmacology), including the study of how drug dependence and addiction affect the human brain. Molecular neuropharmacology involves the study of neurons and their neurochemical interactions, with the overall goal of developing drugs that have beneficial effects on neurological function. Both of these fields are closely connected, since both are concerned with the interactions of neurotransmitters, neuropeptides, neurohormones, neuromodulators, enzymes, second messengers, co-transporters, ion channels, and receptor proteins in the central and peripheral nervous systems. Studying these interactions, researchers are developing drugs to treat many different neurological disorders, including pain, neurodegenerative diseases such as Parkinson's disease and Alzheimer's disease, psychological disorders, addiction, and many others.

Second messengers are intracellular signaling molecules released by the cell in response to exposure to extracellular signaling molecules—the first messengers. Second messengers trigger physiological changes such as proliferation, differentiation, migration, survival, and apoptosis.

The action of drugs on the human body is called pharmacodynamics, and what the body does with the drug is called pharmacokinetics. The drugs that enter the human tend to stimulate certain receptors, ion channels, act on enzymes or transporter proteins. As a result, they cause the human body to react in a specific way.

In biochemistry and pharmacology, a ligand is a substance that forms a complex with a biomolecule to serve a biological purpose. In protein-ligand binding, the ligand is usually a molecule which produces a signal by binding to a site on a target protein. The binding typically results in a change of conformational isomerism (conformation) of the target protein. In DNA-ligand binding studies, the ligand can be a small molecule, ion, or protein which binds to the DNA double helix. The relationship between ligand and binding partner is a function of charge, hydrophobicity, and molecular structure. The instance of binding occurs over an infinitesimal range of time and space, so the rate constant is usually a very small number.

In the field of molecular biology, nuclear receptors are a class of proteins found within cells that are responsible for sensing steroid and thyroid hormones and certain other molecules. In response, these receptors work with other proteins to regulate the expression of specific genes, thereby controlling the development, homeostasis, and metabolism of the organism.

A nicotinic agonist is a drug that mimics the action of acetylcholine (ACh) at nicotinic acetylcholine receptors (nAChRs). The nAChR is named for its affinity for nicotine.

Receptor theory is the application of receptor models to explain drug behavior. Pharmacological receptor models preceded accurate knowledge of receptors by many years. John Newport Langley and Paul Ehrlich introduced the concept of a receptor that would mediate drug action at the beginning of the 20th century. A J Clark was the first to quantify drug-induced biological responses (using an equation described f-mediated receptor activation. So far, nearly all of the quantitative theoretical modelling of receptor function has centred on ligand-gated ion channels and GPCRs.

Cell surface receptors are receptors that are embedded in the plasma membrane of cells. They act in cell signaling by receiving extracellular molecules. They are specialized integral membrane proteins that allow communication between the cell and the extracellular space. The extracellular molecules may be hormones, neurotransmitters, cytokines, growth factors, cell adhesion molecules, or nutrients; they react with the receptor to induce changes in the metabolism and activity of a cell. In the process of signal transduction, ligand binding affects a cascading chemical change through the cell membrane.

## References

1. Hall, JE (2016). Guyton and Hall Textbook of Medical Physiology. Philadelphia, PA: Elsevier Saunders. pp. 930–937. ISBN   978-1-4557-7005-2.
2. Alberts B, Bray D, Hopkin K, Johnson A, Lewis J, Raff M, Roberts K, Walter P (2014). Essential Cell Biology (Fourth ed.). New York, NY, USA: Garland Science. p. 534. ISBN   978-0-8153-4454-4.
3. Malenka RC, Nestler EJ, Hyman SE (2009). "Chapter 9: Autonomic Nervous System". In Sydor A, Brown RY (eds.). Molecular Neuropharmacology: A Foundation for Clinical Neuroscience (2nd ed.). New York: McGraw-Hill Medical. p. 234. ISBN   9780071481274. Nicotine ... is a natural alkaloid of the tobacco plant. Lobeline is a natural alkaloid of Indian tobacco. Both drugs are agonists are nicotinic cholinergic receptors ...
4. Congreve M, Marshall F (March 2010). "The impact of GPCR structures on pharmacology and structure-based drug design". British Journal of Pharmacology. 159 (5): 986–96. doi:10.1111/j.1476-5381.2009.00476.x. PMC  . PMID   19912230.
5. Qin K, Dong C, Wu G & Lambert NA (August 2011). "Inactive-state preassembly of G(q)-coupled receptors and G(q) heterotrimers". Nature Chemical Biology. 7 (10): 740–7. doi:10.1038/nchembio.642. PMC  . PMID   21873996.
6. Rang HP, Dale MM, Ritter JM, Flower RJ, Henderson G (2012). Rang & Dale's Pharmacology (7th ed.). Elsevier Churchill Livingstone. ISBN   978-0-7020-3471-8.
7. Milligan G (December 2003). "Constitutive activity and inverse agonists of G protein-coupled receptors: a current perspective". Molecular Pharmacology. 64 (6): 1271–6. doi:10.1124/mol.64.6.1271. PMID   14645655.
8. Ariens EJ (September 1954). "Affinity and intrinsic activity in the theory of competitive inhibition. I. Problems and theory". Archives Internationales De Pharmacodynamie Et De Therapie. 99 (1): 32–49. PMID   13229418.
9. Stephenson RP (December 1956). "A modification of receptor theory". British Journal of Pharmacology and Chemotherapy. 11 (4): 379–93. doi:10.1111/j.1476-5381.1956.tb00006.x. PMC  . PMID   13383117.
10. Silverman RB (2004). "3.2.C Theories for Drug—Receptor Interactions". The Organic Chemistry of Drug Design and Drug Action (2nd ed.). Amsterdam: Elsevier Academic Press. ISBN   0-12-643732-7.
11. Boulay G, Chrétien L, Richard DE, Guillemette G (November 1994). "Short-term desensitization of the angiotensin II receptor of bovinde adrenal glomerulosa cells corresponds to a shift from a high to low affinity state". Endocrinology. 135 (5): 2130–6. doi:10.1210/en.135.5.2130.
12. Boulpaep EL, Boron WF (2005). Medical physiology: a cellular and molecular approach. St. Louis, Mo: Elsevier Saunders. p. 90. ISBN   1-4160-2328-3.
13. Waltenbaugh C, Doan T, Melvold R, Viselli S (2008). Immunology. Philadelphia: Wolters Kluwer Health/Lippincott Williams & Wilkins. p. 20. ISBN   0-7817-9543-5.


text:
# tikz coordinate calculations gone wild

I'm quite a bit baffled why my coordinate calculations are coming out so differently. All coordinates are where I expect them to be, except coordinate Z.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\begin{document}

%% Attempt 01
\begin{tikzpicture}[x=0.25cm,y=0.25cm]
%% why does this draw a 5 by 5 grid when I don't specify "step=1"???
\draw[help lines,blue!20,step=1] (0,0) grid (20,20);
%% quarter circle
\draw[blue]  (  0:20)  arc(0:90:20);

%% Coordinates "B", "Bn", "Bl", "Br" all come out where I expect
%% Coordinate  "Z" is not where I expected it.
\path  [draw,line width=2pt,red]
(0,0)                 coordinate [label=135:P] (Q)
-- +( 90:20)   coordinate (B)  -- +( $(B) !-1em! (Q)$ )  coordinate (Bn) node {$Bn$}
(B) -- +(0:20)     coordinate (Bl) -- +( $(B) !0.5! (Bl)$ )  coordinate [label=90:Z] (Z)
-- +(180:20)   coordinate (Br)
;

%% Coordinate "X" goes where I thought coordinate "Z" would have gone too
\draw ( $(B) !0.5!(Bl)$ ) coordinate [label=90:X] (X) circle (2pt);

\end{tikzpicture}

\vspace{1cm}

Same as example above except that $B$ is defined by \verb=(30:20)=
instead of \verb=(90:20)= relative to \verb=(0,0)=.  Also, I omitted
\verb!step=1! from the \verb=help lines=.

%% Attempt 02---same as attempt 01 except for (1) the placement definition
%% of coordinate "B" and (2) not "step=1" for the "help lines".
\begin{tikzpicture}[x=0.25cm,y=0.25cm]
%% why does this draw a 5 by 5 grid when I don't specify "step=1"???
\draw[help lines,blue!20] (0,0) grid (20,20);
%% quarter circle
\draw[blue]  (  0:20)  arc(0:90:20);

%% Coordinates "B", "Bn", "Bl", "Br" all come out where I expect
%% Coordinate  "Z" is not where I expected it.
\path  [draw,line width=2pt,red,opacity=0.50]
(0,0)                 coordinate [label=135:P] (Q)
-- +( 30:20)   coordinate (B)  -- +( $(B) !-1em! (Q)$ )  coordinate (Bn) node {$Bn$}
(B) -- +(0:20)     coordinate (Bl) -- +( $(B) !0.5! (Bl)$ )  coordinate [label=90:Z] (Z)
-- +(180:20)   coordinate (Br)
;

%% Coordinate "X" goes where I thought coordinate "Z" would have gone too
\draw ( $(B) !0.5!(Bl)$ ) coordinate [label=90:X] (X) circle (2pt);

\end{tikzpicture}

\end{document}

Why are the coordinate calculations---for what seems to me to be the same thing---turning out so differently?

Minor question

Why must I specify "step=1" to get my help lines to look correctly? Without step=1, I only get a five-by-five grid.

-
About the minor question: The default setting of step is 1cm, that's why you get a 5x5 grid if your unit vectors are 0.2cm long. –  Jake Feb 16 '13 at 17:26
@jake. Doesn't that seem buggy that step is not set relative to the units I've specified? –  A.Ellett Feb 16 '13 at 17:27
@jldiaz. I expect Z to be where X is. It's exactly the same coordinate calculation. –  A.Ellett Feb 16 '13 at 17:28
@A.Ellett: I wouldn't call it buggy, you're just expecting something it doesn't do. It behaves exactly as it's specified in the manual. –  Jake Feb 16 '13 at 17:29
You are at the second row moving the path to (B) and then everything with +(...) becomes relative to (B). –  percusse Feb 16 '13 at 17:33

The difference between the line which places the X node and the one which places the Z node is that in the first one you are using absolute coordinates, while in the second one you are using relative coordinates because you preceded the coordinates with a + sign.

The + is not required since you are not giving the new coordinate as a displacement with respect other, but instead you are computing the new coordinates using a calc expression. You can remove the + in all your paths (at least in this case):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\begin{document}

%% Attempt 01
\begin{tikzpicture}[x=0.25cm,y=0.25cm]
%% why does this draw a 5 by 5 grid when I don't specify "step=1"???
\draw[help lines,blue!20,step=1] (0,0) grid (20,20);
%% quarter circle
\path  (  0:20)   coordinate (A);
\draw[blue]  (A) arc(0:90:20);

%% Coordinates "B", "Bn", "Bl", "Br" all come out where I expect
%% Coordinate  "Z" is not where I expected it.
\path  [draw,line width=2pt,red]
(0,0)                 coordinate [label=135:P] (Q)
-- +( 90:20)   coordinate (B)  -- ( $(B) !-1em! (Q)$ )  coordinate (Bn) node {$B$}
(B) -- +(0:20)     coordinate (Bl) -- ( $(B) !0.5! (Bl)$ )  coordinate [label=90:Z] (Z)
-- +(180:20)   coordinate (Br)
;

%% Coordinate "X" goes where I thought coordinate "Z" would have gone too
\draw ( $(B) !0.5!(Bl)$ ) coordinate [label=90:X] (X) circle (2pt);

\end{tikzpicture}

\vspace{1cm}

Same as example above except that $B$ is defined by \verb=(30:20)=
instead of \verb=(90:20)= relative to \verb=(0,0)=.  Also, I omitted
\verb!step=1! from the \verb=help lines=.

%% Attempt 02---same as attempt 01 except for (1) the placement definition
%% of coordinate "B" and (2) not "step=1" for the "help lines".
\begin{tikzpicture}[x=0.25cm,y=0.25cm]
%% why does this draw a 5 by 5 grid when I don't specify "step=1"???
\draw[help lines,blue!20] (0,0) grid (20,20);
%% quarter circle
\path  (  0:20)   coordinate (A);
\draw[blue]  (A) arc(0:90:20);

%% Coordinates "B", "Bn", "Bl", "Br" all come out where I expect
%% Coordinate  "Z" is not where I expected it.
\path  [draw,line width=2pt,red,opacity=0.50]
(0,0)                 coordinate [label=135:P] (Q)
-- +( 30:20)   coordinate (B)  -- ( $(B) !-1em! (Q)$ )  coordinate (Bn) node {$B$}
(B)   -- +(0:20)     coordinate (Bl) -- ( $(B) !0.5! (Bl)$ )  coordinate [label=90:Z] (Z)
-- +(180:20)   coordinate (Br)
;

%% Coordinate "X" goes where I thought coordinate "Z" would have gone too
\draw ( $(B) !0.5!(Bl)$ ) coordinate [label=90:X] (X) circle (2pt);

\end{tikzpicture}
\end{document}

# Update

Based on the comments and on a better understanding of the intended output, I suggest to completely eliminate relative coordinates (those beginning with +) in your path, and replacing those for explicit calculations (which can involve polar coordinates). So, for example, to get a point 20 units to the right of (B), use ($(B)+(0:20)$), instead of moving the origin to (B) and then write +(0:20).

Mixing absolute and relative coordinates make difficult to guess and control the result. Use explicit calculations to a better understanding and control. With this approach your code would be:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\begin{document}

%% Attempt 01
\begin{tikzpicture}[x=0.25cm,y=0.25cm]
%% why does this draw a 5 by 5 grid when I don't specify "step=1"???
\draw[help lines,blue!20,step=1] (0,0) grid (20,20);
%% quarter circle
\path  (  0:20)   coordinate (A);
\draw[blue]  (A) arc(0:90:20);

%% Coordinates "B", "Bn", "Bl", "Br" all come out where I expect
%% Coordinate  "Z" is not where I expected it.
\path  [draw,line width=2pt,red]
(0,0)                        coordinate [label=135:P] (Q)
-- ($(Q)+(90:20)$)   coordinate (B)  -- ( $(B) !-1em! (Q)$ )  coordinate (Bn) node {$B$}
(B) -- ($(B)+(0:20)$)    coordinate (Bl) -- ( $(B) !0.5! (Bl)$ )  coordinate [label=90:Z] (Z)
-- ($(B)+(180:20)$)  coordinate (Br)
;

%% Coordinate "X" goes where I thought coordinate "Z" would have gone too
\draw ( $(B) !0.5!(Bl)$ ) coordinate [label=90:X] (X) circle (2pt);

\end{tikzpicture}
\vspace{1cm}

Same as example above except that $B$ is defined by \verb=(30:20)=
instead of \verb=(90:20)= relative to \verb=(0,0)=.  Also, I omitted
\verb!step=1! from the \verb=help lines=.

%% Attempt 02---same as attempt 01 except for (1) the placement definition
%% of coordinate "B" and (2) not "step=1" for the "help lines".
\begin{tikzpicture}[x=0.25cm,y=0.25cm]
%% why does this draw a 5 by 5 grid when I don't specify "step=1"???
\draw[help lines,blue!20] (0,0) grid (20,20);
%% quarter circle
\path  (  0:20)   coordinate (A);
\draw[blue]  (A) arc(0:90:20);

%% Coordinates "B", "Bn", "Bl", "Br" all come out where I expect
%% Coordinate  "Z" is not where I expected it.
\path  [draw,line width=2pt,red,opacity=0.50]
(0,0)                 coordinate [label=135:P] (Q)
-- ($(Q)+(30:20)$)    coordinate (B)  -- ( $(B) !-1em! (Q)$ )   coordinate (Bn) node {$B$}
(B)  -- ($(B)+(0:20)$)     coordinate (Bl) -- ( $(B) !0.5! (Bl)$ )  coordinate [label=90:Z] (Z)
-- ($(B)+(180:20)$)   coordinate (Br)
;

%% Coordinate "X" goes where I thought coordinate "Z" would have gone too
\draw ( $(B) !0.5!(Bl)$ ) coordinate [label=90:X] (X) circle (2pt);

\end{tikzpicture}
\end{document}

And the result (I hope I got it right this time):

-
Almost! :) But now Bl is not placed 20 "units" to the left of B. This is really just a boiled down version of something much bigger. Most of the relative coordinates are needed because I'm placing "most" coordinates relative to the center of a circle. Z is the one exception. But, I can draw that absolutely on its own, though I have to do that after I've completed drawing all the other relative coordinates. Thanks though. –  A.Ellett Feb 16 '13 at 17:57
Actually, it's Z, Bl, and Br that are the exceptions. But from this snippet I can see your point about the apparent lack of a need for all the relative coordinates. –  A.Ellett Feb 16 '13 at 18:00
I appreciate your feedback. But I disagree with making all the calculations absolute. The point of the relative coordinates is that I can change where I place Q and the whole picture will move with Q. Your method will work, but only through a fair amount of convoluted calculations when tikz already provides a means to relativizing coordinates with respect to a given one. My mistake was to forget that my anchoring coordinate was Q and not B. –  A.Ellett Feb 16 '13 at 18:58