text:
# Glossary

## Genetic code

The genetic code is the term applied to the encoding process by which RNA is translated into peptide chains of amino acids. Every RNA codon (triplet of nucleotides) becomes translated into precisely one amino acid, regardless of species.

Attempting to translate length 2 RNA substrings could only encode $4^2 = 16$ amino acids, yet 20 amino acids commonly appear in almost every species, which accounts for the need to translate codons.

The precise details of how the genetic code translates RNA codons into the 20-symbol alphabet for protein strings are shown in the figure below. Codons are formed by moving from the inside to the outside of the inner wheel, choosing one symbol in each spoke. For this information in table form, consult the RNA codon table (or the DNA codon table if we wish to view transcription and translation as a single step).

format: plain


text:
## Results (1-50 of 70927 matches)

Label Class Base field Conductor norm Rank Torsion CM Weierstrass equation
16.1-CMa1 16.1-CMa $$\Q(\sqrt{-7})$$ $$2^{4}$$ $0$ $\Z/2\Z\oplus\Z/4\Z$ $-7$ ${y}^2+a{x}{y}={x}^{3}+\left(-a-1\right){x}^{2}+{x}$
16.1-CMa2 16.1-CMa $$\Q(\sqrt{-7})$$ $$2^{4}$$ $0$ $\Z/4\Z$ $-28$ ${y}^2+a{x}{y}={x}^{3}+\left(-a-1\right){x}^{2}+\left(-15a+11\right){x}-7a+26$
16.5-CMa1 16.5-CMa $$\Q(\sqrt{-7})$$ $$2^{4}$$ $0$ $\Z/2\Z\oplus\Z/4\Z$ $-7$ ${y}^2+\left(a+1\right){x}{y}+\left(a+1\right){y}={x}^{3}+{x}^{2}$
16.5-CMa2 16.5-CMa $$\Q(\sqrt{-7})$$ $$2^{4}$$ $0$ $\Z/4\Z$ $-28$ ${y}^2+\left(a+1\right){x}{y}+\left(a+1\right){y}={x}^{3}+{x}^{2}+\left(15a-5\right){x}+22a+14$
28.2-a1 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/2\Z\oplus\Z/2\Z$ ${y}^2+{x}{y}+{y}={x}^{3}-171{x}-874$
28.2-a2 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/6\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+a{x}^{2}+\left(-10a+15\right){x}-5a-16$
28.2-a3 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/6\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}+\left(-a+1\right){x}^{2}+\left(9a+6\right){x}+4a-20$
28.2-a4 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/6\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}+\left(-a+1\right){x}^{2}+\left(-a+1\right){x}-a+1$
28.2-a5 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/6\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+a{x}^{2}$
28.2-a6 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/2\Z\oplus\Z/6\Z$ ${y}^2+{x}{y}+{y}={x}^{3}-{x}$
28.2-a7 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/2\Z\oplus\Z/6\Z$ ${y}^2+{x}{y}+{y}={x}^{3}+4{x}-6$
28.2-a8 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+a{x}^{2}+\left(30a-40\right){x}-30a-154$
28.2-a9 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}+\left(-a+1\right){x}^{2}+\left(-31a-9\right){x}+29a-183$
28.2-a10 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/6\Z$ ${y}^2+{x}{y}+{y}={x}^{3}-36{x}-70$
28.2-a11 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/6\Z$ ${y}^2+{x}{y}+{y}={x}^{3}-11{x}+12$
28.2-a12 28.2-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 7$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}+{y}={x}^{3}-2731{x}-55146$
44.3-a1 44.3-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/4\Z$ ${y}^2+{x}{y}={x}^{3}+a{x}^{2}+\left(-55a+91\right){x}+87a+359$
44.3-a2 44.3-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+{x}^{2}+\left(-4a+40\right){x}+135a+83$
44.3-a3 44.3-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/12\Z$ ${y}^2+{x}{y}={x}^{3}+a{x}^{2}+{x}+1$
44.3-a4 44.3-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}+{y}={x}^{3}+\left(-a+1\right){x}^{2}+\left(14a-17\right){x}-19a+5$
44.3-a5 44.3-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/2\Z\oplus\Z/6\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+{x}^{2}+a{x}+1$
44.3-a6 44.3-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/2\Z\oplus\Z/2\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+{x}^{2}+\left(-14a-10\right){x}+27a-9$
44.3-a7 44.3-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/6\Z$ ${y}^2+{x}{y}+{y}={x}^{3}+\left(-a+1\right){x}^{2}+\left(-a+3\right){x}-3a+1$
44.3-a8 44.3-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/6\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+{x}^{2}+21a{x}+20a+57$
44.4-a1 44.4-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/4\Z$ ${y}^2+{x}{y}={x}^{3}+\left(-a+1\right){x}^{2}+\left(55a+36\right){x}-87a+446$
44.4-a2 44.4-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}+{x}^{2}+\left(3a+37\right){x}-136a+219$
44.4-a3 44.4-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/12\Z$ ${y}^2+{x}{y}={x}^{3}+\left(-a+1\right){x}^{2}+{x}+1$
44.4-a4 44.4-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}+{y}={x}^{3}+a{x}^{2}+\left(-14a-3\right){x}+19a-14$
44.4-a5 44.4-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/2\Z\oplus\Z/6\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}+{x}^{2}+\left(-2a+2\right){x}-a+2$
44.4-a6 44.4-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/2\Z\oplus\Z/2\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}+{x}^{2}+\left(13a-23\right){x}-28a+19$
44.4-a7 44.4-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/6\Z$ ${y}^2+{x}{y}+{y}={x}^{3}+a{x}^{2}+\left(a+2\right){x}+3a-2$
44.4-a8 44.4-a $$\Q(\sqrt{-7})$$ $$2^{2} \cdot 11$$ $0$ $\Z/6\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}+{x}^{2}+\left(-22a+22\right){x}-21a+78$
46.2-a1 46.2-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/4\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+\left(-a-1\right){x}^{2}-4{x}-1$
46.2-a2 46.2-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/2\Z\oplus\Z/2\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}-a{x}^{2}+\left(-6a+10\right){x}+2a+8$
46.2-a3 46.2-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}-a{x}^{2}+\left(-a+10\right){x}-8a+30$
46.2-a4 46.2-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/2\Z\oplus\Z/4\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}-a{x}^{2}-a{x}$
46.2-a5 46.2-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/8\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+\left(a-1\right){x}^{2}+\left(-a-2\right){x}-a+1$
46.2-a6 46.2-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}-a{x}^{2}+\left(-91a+170\right){x}+240a+618$
46.3-a1 46.3-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/4\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+\left(a+1\right){x}^{2}+\left(a-4\right){x}-a-4$
46.3-a2 46.3-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/2\Z\oplus\Z/2\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+\left(a-1\right){x}^{2}+\left(5a+4\right){x}-3a+10$
46.3-a3 46.3-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+\left(a-1\right){x}^{2}+9{x}+7a+22$
46.3-a4 46.3-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/2\Z\oplus\Z/4\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+\left(a-1\right){x}^{2}-{x}-a$
46.3-a5 46.3-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/8\Z$ ${y}^2+{x}{y}+a{y}={x}^{3}-a{x}^{2}-2{x}+1$
46.3-a6 46.3-a $$\Q(\sqrt{-7})$$ $$2 \cdot 23$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}+\left(a+1\right){y}={x}^{3}+\left(a-1\right){x}^{2}+\left(90a+79\right){x}-241a+858$
49.1-CMa1 49.1-CMa $$\Q(\sqrt{-7})$$ $$7^{2}$$ $0$ $\Z/2\Z\oplus\Z/2\Z$ $-7$ ${y}^2+{x}{y}={x}^{3}-{x}^{2}-2{x}-1$
49.1-CMa2 49.1-CMa $$\Q(\sqrt{-7})$$ $$7^{2}$$ $0$ $\Z/2\Z$ $-28$ ${y}^2+{x}{y}={x}^{3}-{x}^{2}-37{x}-78$
63.1-a1 63.1-a $$\Q(\sqrt{-7})$$ $$3^{2} \cdot 7$$ $0$ $\Z/2\Z$ ${y}^2+{x}{y}={x}^{3}-34{x}-217$
63.1-a2 63.1-a $$\Q(\sqrt{-7})$$ $$3^{2} \cdot 7$$ $0$ $\Z/2\Z\oplus\Z/4\Z$ ${y}^2+{x}{y}={x}^{3}+{x}$
63.1-a3 63.1-a $$\Q(\sqrt{-7})$$ $$3^{2} \cdot 7$$ $0$ $\Z/2\Z\oplus\Z/4\Z$ ${y}^2+{x}{y}={x}^{3}-4{x}-1$
63.1-a4 63.1-a $$\Q(\sqrt{-7})$$ $$3^{2} \cdot 7$$ $0$ $\Z/8\Z$ ${y}^2+{x}{y}={x}^{3}-39{x}+90$


text:
# Distance between two time-dependent distribution

In my research, I want to use a meaningful and computationally tractable distance between two time-dependent probability distributions. For stationary distributions, several distance measures are used, such as KL divergence, JS divergence, Wasserstein distance, and so on.

Is anyone aware of a similar thing for two time-dependent distributions p1(x,t) and p2(x,t)?

In my problem, both distributions are the solutions of non-stationary Fokker-Planck equation,

dp1/dt = (-d/dx F1(x) + d2/dx2 D1(x) ) p1(x,t),  p1(0,t)=p10(x)
dp1/dt = (-d/dx F2(x) + d2/dx2 D2(x) ) p2(x,t),  p2(0,t)=p20(x)

Where the drift forces F1(x), F2(x), diffusion coefficients D1 and D2, and initial probability distributions p10(x) and p20(x) are computed from data. So, ideally, I want some kind of norm that can be expressed through the parameters of the Langevin equation.


text:
This website requires JavaScript.

On The Doubly Stochastic Realization Of Spectra

CAS-4 JCR-Q2 SCIE
Banach Journal of Mathematical Analysis
Oct 2013

An $n$-list $\lambda:=\left(r; \lambda_2, \ldots, \lambda_n\right)$ of complex numbers with $r>0,$ is said to be realizable if $\lambda$ is the spectrum of $n\times n$ nonnegative matrix $A$ and in this case $A$ is said to be a nonnegative realization of $\lambda$. If, in addition, each row and column sum of $A$ equals $r$, then $\lambda$ is said to be doubly stochastically realizable and in such case $A$ is said to be a doubly stochastic realization for $\lambda$. In 1997, Guo proved that if $\left(\lambda_2,\ldots, \lambda_n\right)$ is any list of complex numbers which is closed under complex conjugation then there exists a least real number $\lambda_0$ with $\max\limits_{2\leq j\leq n}|\lambda_j|\leq\lambda_0\leq 2n\max\limits_{2\leq j\leq n}|\lambda_j|$ such that the list of complex numbers $\{ \lambda_1,\lambda_2,...,\lambda_n\}$ is realizable if and only if $\lambda_1\geq \lambda_0$. In 2020, Julio and Soto showed that the upper bound may be reduced to $(n-1)\max\limits_{2\leq j\leq n}|\lambda_j|$ in the case when at least one of the $\lambda_i$ is real. In this paper, we first describe an algorithm for passing from a nonnegative realization to a doubly stochastic realization. As applications, we give a new sufficient condition for a stochastic matrix $A$ to be cospectral to a doubly stochastic matrix $B$ and in this case $B$ is shown to be the unique closest doubly stochastic matrix to $A$ with respect to the Frobenius norm. Then, our next results slightly improve the upper bound for the nonnegative realization presented by Julio and Soto and in the case when none of the $\lambda_i$ is real, we also give an improvement of Guo's bound. Then, for doubly stochastic realizations, we obtain an upper bound that improves Guo's bound as well. Finally, for certain particular cases, we give a further improvement of our last bound for doubly stochastic realization.

Q1论文试图解决什么问题？
Q2这是否是一个新的问题？
Q3这篇文章要验证一个什么科学假设？
0


text:
# Domain of a Function

Given a function, $$f(x)$$, there may be some values of $$x$$ for which the function isn't well defined.
For instance, if we were asked to calculate the value of the function $$f(x) = \frac{2}{3x+6}$$ when $$x = -2$$ we would have some trouble.
Indeed, if we replace $$x$$ by $$-2$$ in the expression for $$f(x)$$ we obtain: \begin{aligned} f(-2) & = \frac{2}{3\times (-2) + 6} \\ & = \frac{2}{-6+6} \\ f(-2) & = \frac{2}{0} \end{aligned} Since it is impossible to divide by zero, it is impossible to calculate the value of $$f(x)$$ when $$x = -2$$.
This highlights the importance of defining the domain of a function.

## Definition - Domain of a Function

Given a function, its domain is the set, or interval, of numbers for which the function is well defined.
For the function we saw in the intriduction, $$f(x) = \frac{2}{3x+6}$$, the domain would be all real numbers other than $$-2$$.
We write this: $\text{Domain} = \left \{ x \in \mathbb{R} | x \neq -2 \right \}$

### How to Find the Domain

To find a function's domain we should ask ourselves:

Are there any values of $$x$$ at which this function can't be calculated (isn't well defined)?

To answer this question we must always remember:

• Denominators cannot equal $$0$$.

• Expressions inside square roots (radicands) cannot be negative.
Once this question is answered then we can take the values of $$x$$, at which the function isn't well defined, away from the set of real numbers $$\mathbb{R}$$ to define the domain.

## Tutorial

In the following tutorial we review the method for findng the formula for the $$n^{\text{th}}$$ term of a linear sequence. Watch it now.

## Exercise

Find the domain of each of the following functions:

1. $$f(x) = \frac{3}{2x-4}$$

2. $$f(x) = \sqrt{x+5}$$

3. $$f(x) = \sqrt{3x-9}$$

4. $$f(x) = \frac{7}{9-x}$$

5. $$f(x) = \frac{x}{x^2-4}$$

6. $$f(x) = \frac{2x}{x^2+4}$$


text:
Draft

Draft of 2017.05.24

May include: combinatoricspuzzlemathrecreation&c.

A few disparate-feeling things conspire to make me write this today.

This last weekend (18–20 May, 2017) was the fifteenth annual Genetic Programming Theory and Practice workshop in Ann Arbor. I spent a lot of time admonishing my colleagues in the field (which is a fancy-ass way of saying “wishing I could make time for myself”) to extend the reach of genetic programming away from the traditional numerical symbolic regression problems that have been so handily claimed by Deep Learning models, and towards software synthesis and algorithmic discovery. GP is good at finding algorithms and rules, and it is (in some sense) better at explaining them than neural networks tend to be. After all, if the code one evolves is human-readable, then it’s a bit more likely to be human-understandable.

I’ve been gearing up for my promised series of Computer Etudes (or “puzzles” or “recreations” or something, but to be honest I think “Etudes” is best… unless we end up at “Experiments”). These are similar to the sketches I’ve been posting for a few years now, but organized and stuff. The inspirations are people like Martin Gardner and Ian Stewart and A. K. Dewdney and so forth: open questions with some leading examples and “isn’t that weird?” leading questions along the way, on topics in “complexology” or emergent systems or machine learning. Stuff slightly more towards the “isn’t that weird” part of the computational/mathematical spectrum, and not so much “practice on your professional skills” stuff you see in many “kata” and “dojo” practices for software developers.

Puzzles with no answers. Puzzling things, more like.

Then there’s the fact that I hit the interlibrary loan a bit heavy some nights back. I was reminded of a book I had checked out several months ago, and which I remembered with interest but hadn’t had enough time to read in detail: Old and New Unsolved Problems in Plane Geometry and Number Theory. In this last round I ordered copies of a few other books like those: Unsolved Problems in Geometry and Erdős on graphs: his legacy of unsolved problems and Unsolved Problems in Number Theory and so forth. Quite a few, as it happens, since there are a lot of arXiv preprints I run across in combinatorics and number theory and enumeration and graph theory that seem to revolve around these sometimes-little, sometimes-hugely-important “open problems” and their penumbra of variations.

And I was just poking around with my own GP system the other day, and wondering what sorts of problems were most amenable to evolutionary search and discovery. So this is in large part a self-serving “puzzle”. I find in posing GP problems and benchmarks and “puzzles” that it’s a good rule of thumb that a reasonably astute programmer can make some progress on them, and can maybe even write a brute-force thing that will eventually get the “answer”… but in a frustrating way.

So let’s talk about subset sums.

## So here’s the thing

Suppose you have a set of $N$ distinct integers. These numbers don’t need to be positive, and the set can include $0$ if you like. But they should (for this part1) be a proper set, with no duplicates.

Consider all nonempty subsets of those numbers. That is, the subsets that contain one number each, and all the subsets that contain two different numbers (from that set), and so on up to the $N$ subsets that are missing one number each, and of course the whole set itself. There are $(2^{N}-1)$ of those, in case you’re wondering2. Lots of subsets.

Now for each subset, add up all the elements. This produces a single integer sum for each subset.

Finally, count the frequencies of each sum of elements in each subset.

For example, if the numbers are $\{-1, 1, 3, 4\}$, then we have these subsets and sums:

• $\{-1\}$, with sum $-1$
• $\{1\}$, with sum $1$
• $\{3\}$, with sum $3$
• $\{4\}$, with sum $4$
• $\{-1,1\}$, with sum $0$
• $\{-1,3\}$, with sum $2$
• $\{-1,4\}$, with sum $3$
• $\{1,3\}$, with sum $4$
• $\{1,4\}$, with sum $5$
• $\{3,4\}$, with sum $7$
• $\{-1,1,3\}$, with sum $3$
• $\{-1,1,4\}$, with sum $4$
• $\{-1,3,4\}$, with sum $6$
• $\{1,3,4\}$, with sum $8$
• $\{-1,1,3,4\}$, with sum $7$

And when I count the frequencies of those sums, I get something like this:

 sum  count
-1     1
0     1
1     1
2     1
3     3
4     3
5     1
6     1
7     2
8     1

The most common subset sums are $3$ and $4$. Counting over all possible non-empty subsets, three of those fifteen subsets add up to each one of those two values, and fewer subsets add to the other observed values. $3$ and $4$ are “tied winners” when it comes to how often they are the sums of subset values for this set.

## So what’s the problem?

A lot of the Number Theory and Combinatorics work I’ve encountered so far in this space is about the sums of pairs of numbers. Erdős for example posed several problems in which one is curious about whether any of the sums of subsets (often of a particular size) “hits” a given target value. There’s some kind of twisted relation tucked in there with the Goldbach conjecture, too, since that also has to do with sums and stuff. There is the 3SUM problem, in which one is asked whether a set of integers has any triplet that sums to zero exactly, and the more general Subset Problem, where we want to determine whether there’s any subset that sum to zero.

But while they may be interesting and informative, those aren’t the problem here.

Here, I’m asking about the frequency of sums of subsets. Specifically: can we tell, just by “looking at” a set of $N$ integers, whether there will be one clear winner or not, among its sums?

By “clear winner” I mean: some single sum which appears with higher frequency than all the other sums.

In the example I gave above, $\{-1, 1, 3, 4\}$, the sums $3$ and $4$ are tied for the “winning frequency”. That’s not the case for all sets of integers, it turns out. The set $\{0, 1, 2, 3\}$ has a clear winner among the subset sums: the sum $3$ occurs four times, while $1$, $2$, $4$, $5$, and $6$ occur only twice each (and $0$ only once). So $\{0,1,2,3\}$ has a clear winner subset sum ($3$), but $\{-1,1,3,4\}$ does not.

## Some observations

The first thing I did when I started playing with these things was write a program. It was a particularly bad Ruby program. What you might call a “design sketch”, really. But it let me poke around and explore some sets of numbers and how their subsets sum up.

For example, to explore one aspect of the question I’m asking, you might look at sets of integers of the form $\{0,1,2,\dots,N\}$. Among those, I find that the trivial set $\{0\}$ has a clear winning sum, and $\{0,1\}$ (with the sum $1$ winning), and also $\{0,1,2,3\}$, and $\{0,1,2,\dots,n\}$ when $n=8, 11, 12, 15, 16, 19, 20, 23$. But not the sets when $N=\{2,4,5,6,7,9,10,13,14,17,18,21,22\}$. Above $N=23$ I got bored, and my laptop was over-taxed because I didn’t bother to write an efficient (or lazy) algorithm.

Similarly, for sets like $\{1,2,\dots,N\}$ (without the $0$), there are clear winning sums for the sets of size $3$, $8$, $11$, $12$, $15$, $16$, $19$, $20$ and $23$. Which is where I got burned (literally) by the brute-force algorithm I sketched, since my laptop CPU got really hot. Same numbers as one sees with the $0$-based sets of consecutive integers, which in hindsight may not be surprising.

This raises the question: Is it the case that adding $0$ doesn’t change the result? Maybe, but I’m not convinced that’s universally true, especially in cases with negative entries where $0$ may actually be the most common sum.

Then I started playing with small sets of numbers sampled from $[-m,m]$. For example, here are some sets with clear winning sums, for seven integers in the range $[-20,20]$:

• $\{-15, -1, 0, 5, 10, 12, 13\}$, winning sum $12$
• $\{-19, -17, -16, -12, -7, -1, 0\}$, winning sum $-36$
• $\{-16, -12, -5, -1, 4, 7, 11\}$, winning sum $-6$
• $\{-14, -13, 0, 3, 4, 16, 18\}$, winning sum $7$
• $\{-19, -17, -8, -6, 6, 11, 17\}$, winning sum $-8$
• $\{-20, -18, -12, 0, 6, 8, 12\}$, winning sum $-12$
• $\{-16, -10, -9, -3, 9, 10, 19\}$, winning sum $0$

For each of those sets with a clear winning subset sum, there were many (but not an intolerable fraction) with no clear winning sums. So there’s another, more Number Theoryish question in there I suppose:

For sets of $N$ integers taken from the range $[-m,m]$, how does the fraction of sets with clear winning subset sums scale with respect to $N$ and $m$?

I don’t know, but I poked around a bit with larger values of what I’m calling $m$, and noticed that for $m=1000$ there were way fewer sets with clear winning sums. Or at least that’s what it felt like.

There’s also something else worth noticing in the winning sums listed above. In some cases, those sums appear in the original set, but in other cases they don’t appear there at all. That feels salient somehow, and one wonders about this bit of Probability Theory, too:

For sets of $N$ integers taken from the range $[-m,m]$, how does the fraction of sets with clear winning subset sum that does not appear in the original set scale with respect to $N$ and $m$?

## Winning by a head: gaps between first and second place

Another interesting thing I noticed—mainly because the sketchy exploratory Ruby program I wrote sort of dumped a lot of numbers to STDOUT for me to stare at—was the gap between the frequency of a clear winning sum, and the next-most-common sum. For example, here’s the sort of information my program dumps to the screen when I run it for randomly-sampled sets of seven numbers from the range $[-20,20]$:

[-19, -10, -9, -1, 14, 15, 18]
clearance: 1
[[4, 6], [-5, 5], [13, 5], [-10, 4], [9, 4], [5, 4], [14, 4]...
{4=>6}
1 / 127

[-18, -14, -13, -12, -9, -1, 1]
clearance: 0
[[-39, 5], [-26, 5], [-27, 5], [-40, 5], [-35, 4], [-13, 4],...
{-40=>5, -39=>5, -27=>5, -26=>5}
4 / 127

[-18, -9, -8, 1, 8, 9, 17]
clearance: 1
[[0, 11], [-9, 10], [9, 10], [-8, 8], [8, 8], [17, 7], [1, 7...
{0=>11}
1 / 127

[-11, -10, -3, 0, 4, 5, 17]
clearance: 0
[[4, 4], [5, 4], [11, 4], [2, 4], [1, 4], [12, 4], [-2, 4], ...
{-10=>4, -9=>4, -7=>4, -6=>4, -5=>4, -4=>4, -3=>4, -2=>4, 1=>4, 2=>4, 4=>4, 5=>4, 6=>4, 7=>4, 8=>4, 9=>4, 11=>4, 12=>4}
18 / 127

[-20, -15, -7, -2, 2, 9, 13]
clearance: 1
[[-20, 7], [2, 6], [-7, 6], [-13, 6], [-22, 6], [0, 6], [-11...
{-20=>7}
1 / 127

[-15, -3, 6, 7, 10, 11, 13]
clearance: 0
[[16, 5], [13, 5], [8, 4], [19, 4], [21, 4], [23, 4], [6, 4]...
{13=>5, 16=>5}
2 / 127

[-9, -7, -5, -3, -2, 0, 5]
clearance: 0
[[-7, 10], [-12, 10], [-14, 10], [-9, 10], [-16, 8], [-5, 8]...
{-14=>10, -12=>10, -9=>10, -7=>10}
4 / 127

[-10, -3, 0, 3, 14, 16, 20]
clearance: 2
[[20, 8], [23, 6], [17, 6], [33, 4], [7, 4], [6, 4], [4, 4],...
{20=>8}
1 / 127

[-19, -14, -11, -7, -1, 1, 12]
clearance: 0
[[-7, 5], [-25, 5], [-21, 5], [-20, 5], [-19, 5], [-18, 5], ...
{-32=>5, -25=>5, -21=>5, -20=>5, -19=>5, -18=>5, -14=>5, -7=>5}
8 / 127

[-20, -13, -3, 0, 1, 3, 11]
clearance: 0
[[-12, 6], [-22, 6], [-19, 6], [1, 6], [-2, 6], [-9, 6], [-2...
{-22=>6, -19=>6, -12=>6, -9=>6, -2=>6, 1=>6}
6 / 127

That’s just ten randomly-sampled sets, but it shows the sorts of features I’ve been looking into. The first line of each block is the set itself. Then the clearance line indicates how much of a gap exists between the largest and second-largest frequencies in the histogram (which is “0” if there is no clear winning sum). Then I print the first few entries in the sorted list of [sum, count], and finally I explicitly say what proportion of the $2^{N}-1$ sums are “most frequent” (or tied for that).

## Some edge cases

As I was discussing this with some friends on social media, Ed Vielmetti pointed a few edge cases which are interesting to consider, too. For example, if the set of numbers we start with (call it $S$) is something like $\{1,10,100,1000,10000,100000\}$, there can never be a clear winning sum among the subsets. Indeed, the subsets sums will be unique numbers in the range $[1,\sum_{S}]$—there will only ever be one subset that can possibly sum any given value!

Further, that’s true for any set of equivalent numbers in any base, and there will never be any duplicate sums regardless of whether we start later in the sequence. For example, $\{1,2,4,8,16,32\}$ will produce subsets with sums hitting every integer in the range $[1,63]$, and the subsets of the set $S = \{3, 81,243,729\}$ (all various powers of $3$) will produce no duplicate sums.

Ed also points out, “1,2,3,4,8,12 has a lot of 15s, which would make it a good cribbage hand.”

## Some hints and guesses and a goal or two

Ultimately, I don’t know the “answers” to the questions I’ve posed above.

It feels as though there are clues in the values and relationships between the numbers in the starting set, which one should be able to use to predict whether there is only one clear winner or not. Something about those $\{1,10,100,1000,\dots\}$ sets also seems to point towards a “feature” we could consider as a heuristic. Then there’s the observation that in at least a few of the sets with clear winners, the winner is a number in the original set, and there are also pairs of numbers that sum to $0$ and that winning number.

But what specifically is it about $\{1,10,100,1000,\dots\}$ and $\{1,3,9,27,\dots\}$ that makes those “flat”? It’s not clear that those are the only sets of values that will be flat in that way, and in fact it’s quite possible (seems to me) that Erdős has some proofs or conjectures or open problems of his own regarding whether there exists sets of integers for which no sums repeat. I haven’t scoured the literature, since to be honest I’m not in the literature business.

In poking around at this problem, one of the things I considered was whether those sequences I mentioned above (the number of clear winners for sets of the form $\{1,2,\dots,N\}$) might have some clues buried in it. Most of the sequences of observations I collected for the first few values of $N$ don’t produce results when I paste them into the search box at OEIS.org, but one did: 1,2,2,3,5,8,14,23,40,70,124,221,397,722,1314,2410, which is the sequence of frequencies for the most common subset sums. That is, this is the count of the winner (or winners) for $N=1,2,3\dots$, whether they tie or not.

That turns up this sequence, which is an interesting one. The match isn’t exact, since there are a couple of terms different at the start, but the comment on the OEIS entry is salient: "a(n) is the maximal number of subsets of {1,2,...,n} that share the same sum". Is that a clue? Feels like it, though I note that the cited papers seem to be talking about something else entirely. Then again, that’s my common experience with number theory and combinatorics papers; I’m not trained in the fields, so there are counterintuitive “leaps” in many of the citation trees I have tried to traverse through the years.

The mathematicians among you may not be interested in rules of thumb and heuristics, and will probably be thinking more about existence proofs and asymptotic proportions and stuff. And that’s fine, but those aren’t my questions.

Rather, as I said right from start, I’m interested in algorithms, and how people find them. This suite of relatively simple-to-describe problems has that “smell” I can only call “potential”—it could be interesting. It feels as if, if one were to start to try to build algorithms that searched for patterns and tendencies among sets of numbers, after staring at enough examples for long enough, you’d start to maybe get a sense of the problem. Like Ed Vielmetti’s observation on powers of ten, there are no doubt other subtle patterns down in there that one could stumble across, tease apart, and cumulatively and in an exploratory fashion piece together just what it is Tozier means by this puzzle.

There’s leverage here for machine learning to have a go. I framed this as a problem for program synthesis, and I think that could be pretty sweet. But I have no doubt some (possibly obscure) Deep Learning system might be able to work in an integer number world, and the results would be no less interesting and/or confusing than those from genetic programming or other semi-automated approaches.

Here, let’s pare the open questions down into something simpler.

Suppose we were to build a training set of, say, eleven integers from the range $[-20,20]$. Those will be the input values or arguments of our desired algorithm. We should make a few thousand training cases. We are looking for something like these as outputs:

• Is there a clear winner subset sum or not? (classification)
• What is the (approximate) winning gap between the first and second most frequent subset sums? This could be $0$ (if there’s no clear winner) or higher. (prediction)
• How many different subset sums will tie for “winner”? This should possibly be represented as a proportion, as I’ve done in my sketchy code output, above.
• How do these observations scale in various ways? What will happen if the integers are taken from an increasingly wider range (for example, if the values are in $[-10000,10000]$)? What happens as more or less of the possible range is sampled? For example, you might compare the expectations for there being a clear winner when your initial set of integers represents 10%, 50%, or 90% of the sampling range from $[-20,20]$.
• What’s the largest gap by which a clear winner can win? That is, what’s the biggest difference between the first- and second-largest counts? Does this depend on $N$ (yes!). Does it depend on $m$? (probably) How?

## On Beyond Zebra

I warned you this was one of my open problems, and it surely is.

• What, if anything, will be different if we start with a multiset of integers rather than simple set? That is, what if we allow multiple copies of the same integers? For example, are there clear winning subset sums for $\{1,1,1,1\}$? (Yes!) Note that by “subset” here I mean “subset of elements of the multiset”, so in this example we can construct four different “subsets” of elements that look like $\{1\}$. But does this result in something qualitatively different from the case where we only permit a single copy of each value in the starting set?
• What, if anything, is different if we start with a set of (unique) numbers, but instead of subsets of arbitrary size we examine the possible multisets of a fixed size $k$ that can be constructed out of those elements? For example, if we start with $\{-1,2,13\}$ and build all possible $k=4$ multisets, those would be $\{-1,-1,-1,-1\}$, $\{-1,-1,-1,2\}$, and so on up to $\{13,13,13,13\}$. Same problem, but a different combinatorial… thingie. You probably know the word better than I do. Again, is this a qualitatively different thing? Are there different features in the original set that might affect whether there is a clear winning sum over these fixed-size words on the alphabet defined in the original set?
• Is the basic clear winning sum question “easier” if we limit ourselves to counting the frequencies of sums over subsets of a fixed size $k$? So for example if I ask you to look at a set of $N$ integers, and tell me whether there will be one clear winning sum over all possible subsets of size $3$, will that be simpler in some sense?
• Are there examples of initial integer sets where the presence of $0$ makes a difference in the outcome? You’ll recall in the quick exploration of sets that contain only the first $N$ integers that I described above, the winners were identical whether zero was included or not. But I wonder whether, especially in sets containing negative values, that may change. For example, in cases where there’s only a one-point “lead” for the clear winner, and either that winner or the next rank includes $0$. A little switch up or down might affect the balance, at least in some rare cases. Or is that even possible?
• Are there visualization methods that could make it intuitive to discover patterns in these sets? I have the sense that Combinatorics people like to make a jump from numbers to points on a line or plane. Or there may be some benefits in plotting the pairwise sums of the numbers in the set. Or in looking at how fast the sets of sums (or histograms of sums) grow as you move from one to two to three elements in the subsets. I don’t know. But again it feels like there’s something there….

There are more of these conjectures and questions and exercises and games to play, of course. There are always more. That’s the beauty of little abstract puzzles: there’s room at the edges to grow.

You could think about these as programming exercises. Learn a new language, or brush up your development skills and mindful practices in a language you already know.

You could think of them as open questions in mathematics. Hit the literature and see if there’s an “obvious” (if possibly obscure) Hungarian paper on the topic from the 1980s. Odds are good, seems to me. Play with it that way, if you prefer.

You could think of them as a target for machine learning. What would a neural network need to be like to be able to classify sets of integers into “has a clear winner or not”? What would a genetic programming representation have to include, whether you tried to evolve an explicit brute-force algorithm for counting, or searched for heuristics and simpler features?

What can you make of it? Let me know.

1. Later, we might come back and look at multisets.

2. It would be $2^N$ if we also counted the empty subset, but we’re not, so it’s $(2^N-1)$. You can think of this as being equivalent to counting all the numbers you can build with exactly $N$ binary “digits”: for each subset, every number either is or is not an element, so we can think of the “first” subset which contains only the first element as being "1000...0", the “next” subset containing only the second element as being "0100...0", the subsets with two items being "1100...0" and "10100...0" and so on, until eventually we reach "111...1", which contains every element. The only subset we’re not considering—and after all this, I’m not sure why exactly, except I haven’t done so until now—is "000...0", the empty subset.


text:
# Simple PDE

1. Oct 17, 2011

### Aidyan

Simple PDE....

I'm trying to solve the PDE:

$\frac{\partial^2 f(x,t)}{\partial x^2}=\frac{\partial f(x,t)}{\partial t}$ with $x \in [-1,1]$ and boundary conditions f(1,t)=f(-1,t)=0.

Thought that $e^{i(kx-\omega t)}$ would work, but that obviously does not fit with the boundary conditions. Has anyone an idea?

2. Oct 17, 2011

### Hootenanny

Staff Emeritus
Re: Simple PDE....

Your equation is the 1D heat equation, the solutions of which are very well known and understood. A google search should yield what you need.

P.S. You will also need some kind of initial condition.

3. Oct 17, 2011

### Aidyan

Re: Simple PDE....

Hmm... looks like it isn't just a simple solution, however. It seems I'm lacking the basics ... I thought this is sufficeint data to solve it uniquely, what is the difference between boundary and initial conditions?

4. Oct 17, 2011

### Hootenanny

Staff Emeritus
Re: Simple PDE....

Afraid not, without knowing the temperature distribution at a specific time you aren't going to obtain a (non-trivial) unique solution.
The former specifies the temperature on the spatial boundaries of the domain (in this case x=-1 and x=1). The latter specifies the temperature distribution at a specific point in time (usually t=0, hence the term initial condition).


text:
Here we compute derivatives of products and quotients of functions

### The product rule

Consider the product of two simple functions, say where $f(x)=x^2+1$ and $g(x)=x^3-3x$. An obvious guess for the derivative of $f(x)g(x)$ is the product of the derivatives:

Is this guess correct? We can check by rewriting $f$ and $g$ and doing the calculation in a way that is known to work. Write with me

Hence so we see that So the derivative of $f(x)g(x)$ is not as simple as $f'(x)g'(x)$. Never fear, we have a rule for exactly this situation.

Let’s return to the example with which we started.

Now that we are pros, let’s try one more example.

### The quotient rule

We’d like to have a formula to compute This brings us to our next derivative rule.

It is often possible to calculate derivatives in more than one way, as we have already seen. Since every quotient can be written as a product, it is always possible to use the product rule to compute the derivative, though it is not always simpler.


text:
Collections and Data Structures¶

Iteration¶

Sequential iteration is implemented by the methods start(), done(), and next(). The general for loop:

for i = I   # or  "for i in I"
# body
end

is translated into:

state = start(I)
while !done(I, state)
(i, state) = next(I, state)
# body
end

The state object may be anything, and should be chosen appropriately for each iterable type. See the manual section on the iteration interface for more details about defining a custom iterable type.

start(iter) → state

Get initial iteration state for an iterable object

done(iter, state) → Bool

Test whether we are done iterating

next(iter, state) → item, state

For a given iterable object and iteration state, return the current item and the next iteration state

zip(iters...)

For a set of iterable objects, returns an iterable of tuples, where the ith tuple contains the ith component of each input iterable.

Note that zip() is its own inverse: collect(zip(zip(a...)...)) == collect(a).

enumerate(iter)

An iterator that yields (i, x) where i is an index starting at 1, and x is the ith value from the given iterator. It’s useful when you need not only the values x over which you are iterating, but also the index i of the iterations.

julia> a = ["a", "b", "c"];

julia> for (index, value) in enumerate(a)
println("$index$value")
end
1 a
2 b
3 c

rest(iter, state)

An iterator that yields the same elements as iter, but starting at the given state.

countfrom(start=1, step=1)

An iterator that counts forever, starting at start and incrementing by step.

take(iter, n)

An iterator that generates at most the first n elements of iter.

drop(iter, n)

An iterator that generates all but the first n elements of iter.

cycle(iter)

An iterator that cycles through iter forever.

repeated(x[, n::Int])

An iterator that generates the value x forever. If n is specified, generates x that many times (equivalent to take(repeated(x), n)).

Fully implemented by:

• Range
• UnitRange
• NDRange
• Tuple
• Number
• AbstractArray
• IntSet
• ObjectIdDict
• Dict
• WeakKeyDict
• EachLine
• AbstractString
• Set
• Task

General Collections¶

isempty(collection) → Bool

Determine whether a collection is empty (has no elements).

julia> isempty([])
true

julia> isempty([1 2 3])
false

empty!(collection) → collection

Remove all elements from a collection.

length(collection) → Integer

For ordered, indexable collections, the maximum index i for which getindex(collection, i) is valid. For unordered collections, the number of elements.

endof(collection) → Integer

Returns the last index of the collection.

julia> endof([1,2,4])
3

Fully implemented by:

• Range
• UnitRange
• Tuple
• Number
• AbstractArray
• IntSet
• Dict
• WeakKeyDict
• AbstractString
• Set

Iterable Collections¶

in(item, collection) → Bool
∈(item, collection) → Bool
∋(collection, item) → Bool
∉(item, collection) → Bool
∌(collection, item) → Bool

Determine whether an item is in the given collection, in the sense that it is == to one of the values generated by iterating over the collection. Some collections need a slightly different definition; for example Sets check whether the item isequal() to one of the elements. Dicts look for (key,value) pairs, and the key is compared using isequal(). To test for the presence of a key in a dictionary, use haskey() or k in keys(dict).

eltype(type)

Determine the type of the elements generated by iterating a collection of the given type. For associative collection types, this will be a Pair{KeyType,ValType}. The definition eltype(x) = eltype(typeof(x)) is provided for convenience so that instances can be passed instead of types. However the form that accepts a type argument should be defined for new types.

indexin(a, b)

Returns a vector containing the highest index in b for each value in a that is a member of b . The output vector contains 0 wherever a is not a member of b.

findin(a, b)

Returns the indices of elements in collection a that appear in collection b

unique(itr[, dim])

Returns an array containing only the unique elements of the iterable itr, in the order that the first of each set of equivalent elements originally appears. If dim is specified, returns unique regions of the array itr along dim.

reduce(op, v0, itr)

Reduce the given collection ìtr with the given binary operator op. v0 must be a neutral element for op that will be returned for empty collections. It is unspecified whether v0 is used for non-empty collections.

Reductions for certain commonly-used operators have special implementations which should be used instead: maximum(itr), minimum(itr), sum(itr), prod(itr), any(itr), all(itr).

The associativity of the reduction is implementation dependent. This means that you can’t use non-associative operations like - because it is undefined whether reduce(-,[1,2,3]) should be evaluated as (1-2)-3 or 1-(2-3). Use foldl or foldr instead for guaranteed left or right associativity.

Some operations accumulate error, and parallelism will also be easier if the reduction can be executed in groups. Future versions of Julia might change the algorithm. Note that the elements are not reordered if you use an ordered collection.

reduce(op, itr)

Like reduce(op, v0, itr). This cannot be used with empty collections, except for some special cases (e.g. when op is one of +, *, max, min, &, |) when Julia can determine the neutral element of op.

foldl(op, v0, itr)

Like reduce(), but with guaranteed left associativity. v0 will be used exactly once.

foldl(op, itr)

Like foldl(op, v0, itr), but using the first element of itr as v0. In general, this cannot be used with empty collections (see reduce(op, itr)).

foldr(op, v0, itr)

Like reduce(), but with guaranteed right associativity. v0 will be used exactly once.

foldr(op, itr)

Like foldr(op, v0, itr), but using the last element of itr as v0. In general, this cannot be used with empty collections (see reduce(op, itr)).

maximum(itr)

Returns the largest element in a collection.

maximum(A, dims)

Compute the maximum value of an array over the given dimensions.

maximum!(r, A)

Compute the maximum value of A over the singleton dimensions of r, and write results to r.

minimum(itr)

Returns the smallest element in a collection.

minimum(A, dims)

Compute the minimum value of an array over the given dimensions.

minimum!(r, A)

Compute the minimum value of A over the singleton dimensions of r, and write results to r.

extrema(itr)

Compute both the minimum and maximum element in a single pass, and return them as a 2-tuple.

indmax(itr) → Integer

Returns the index of the maximum element in a collection.

indmin(itr) → Integer

Returns the index of the minimum element in a collection.

findmax(itr) -> (x, index)

Returns the maximum element and its index.

findmax(A, dims) -> (maxval, index)

For an array input, returns the value and index of the maximum over the given dimensions.

findmin(itr) -> (x, index)

Returns the minimum element and its index.

findmin(A, dims) -> (minval, index)

For an array input, returns the value and index of the minimum over the given dimensions.

findmax!(rval, rind, A, [init=true]) -> (maxval, index)

Find the maximum of A and the corresponding linear index along singleton dimensions of rval and rind, and store the results in rval and rind.

findmin!(rval, rind, A, [init=true]) -> (minval, index)

Find the minimum of A and the corresponding linear index along singleton dimensions of rval and rind, and store the results in rval and rind.

maxabs(itr)

Compute the maximum absolute value of a collection of values.

maxabs(A, dims)

Compute the maximum absolute values over given dimensions.

maxabs!(r, A)

Compute the maximum absolute values over the singleton dimensions of r, and write values to r.

minabs(itr)

Compute the minimum absolute value of a collection of values.

minabs(A, dims)

Compute the minimum absolute values over given dimensions.

minabs!(r, A)

Compute the minimum absolute values over the singleton dimensions of r, and write values to r.

sum(itr)

Returns the sum of all elements in a collection.

sum(A, dims)

Sum elements of an array over the given dimensions.

sum!(r, A)

Sum elements of A over the singleton dimensions of r, and write results to r.

sum(f, itr)

Sum the results of calling function f on each element of itr.

sumabs(itr)

Sum absolute values of all elements in a collection. This is equivalent to sum(abs(itr)) but faster.

sumabs(A, dims)

Sum absolute values of elements of an array over the given dimensions.

sumabs!(r, A)

Sum absolute values of elements of A over the singleton dimensions of r, and write results to r.

sumabs2(itr)

Sum squared absolute values of all elements in a collection. This is equivalent to sum(abs2(itr)) but faster.

sumabs2(A, dims)

Sum squared absolute values of elements of an array over the given dimensions.

sumabs2!(r, A)

Sum squared absolute values of elements of A over the singleton dimensions of r, and write results to r.

prod(itr)

Returns the product of all elements of a collection.

prod(A, dims)

Multiply elements of an array over the given dimensions.

prod!(r, A)

Multiply elements of A over the singleton dimensions of r, and write results to r.

any(itr) → Bool

Test whether any elements of a boolean collection are true.

any(A, dims)

Test whether any values along the given dimensions of an array are true.

any!(r, A)

Test whether any values in A along the singleton dimensions of r are true, and write results to r.

all(itr) → Bool

Test whether all elements of a boolean collection are true.

all(A, dims)

Test whether all values along the given dimensions of an array are true.

all!(r, A)

Test whether all values in A along the singleton dimensions of r are true, and write results to r.

count(p, itr) → Integer

Count the number of elements in itr for which predicate p returns true.

any(p, itr) → Bool

Determine whether predicate p returns true for any elements of itr.

all(p, itr) → Bool

Determine whether predicate p returns true for all elements of itr.

julia> all(i->(4<=i<=6), [4,5,6])
true

map(f, c...) → collection

Transform collection c by applying f to each element. For multiple collection arguments, apply f elementwise.

julia> map((x) -> x * 2, [1, 2, 3])
3-element Array{Int64,1}:
2
4
6

julia> map(+, [1, 2, 3], [10, 20, 30])
3-element Array{Int64,1}:
11
22
33

map!(function, collection)

In-place version of map().

map!(function, destination, collection...)

Like map(), but stores the result in destination rather than a new collection. destination must be at least as large as the first collection.

mapreduce(f, op, v0, itr)

Apply function f to each element in itr, and then reduce the result using the binary function op. v0 must be a neutral element for op that will be returned for empty collections. It is unspecified whether v0 is used for non-empty collections.

mapreduce() is functionally equivalent to calling reduce(op, v0, map(f, itr)), but will in general execute faster since no intermediate collection needs to be created. See documentation for reduce() and map().

julia> mapreduce(x->x^2, +, [1:3;]) # == 1 + 4 + 9
14

The associativity of the reduction is implementation-dependent. Additionally, some implementations may reuse the return value of f for elements that appear multiple times in itr. Use mapfoldl() or mapfoldr() instead for guaranteed left or right associativity and invocation of f for every value.

mapreduce(f, op, itr)

Like mapreduce(f, op, v0, itr). In general, this cannot be used with empty collections (see reduce(op, itr)).

mapfoldl(f, op, v0, itr)

Like mapreduce(), but with guaranteed left associativity. v0 will be used exactly once.

mapfoldl(f, op, itr)

Like mapfoldl(f, op, v0, itr), but using the first element of itr as v0. In general, this cannot be used with empty collections (see reduce(op, itr)).

mapfoldr(f, op, v0, itr)

Like mapreduce(), but with guaranteed right associativity. v0 will be used exactly once.

mapfoldr(f, op, itr)

Like mapfoldr(f, op, v0, itr), but using the first element of itr as v0. In general, this cannot be used with empty collections (see reduce(op, itr)).

first(coll)

Get the first element of an iterable collection. Returns the start point of a Range even if it is empty.

last(coll)

Get the last element of an ordered collection, if it can be computed in O(1) time. This is accomplished by calling endof() to get the last index. Returns the end point of a Range even if it is empty.

step(r)

Get the step size of a Range object.

collect(collection)

Return an array of all items in a collection. For associative collections, returns Pair{KeyType, ValType}.

collect(element_type, collection)

Return an array of type Array{element_type,1} of all items in a collection.

issubset(a, b)
⊆(a, b) → Bool
⊈(a, b) → Bool
⊊(a, b) → Bool

Determine whether every element of a is also in b, using in().

filter(function, collection)

Return a copy of collection, removing elements for which function is false. For associative collections, the function is passed two arguments (key and value).

filter!(function, collection)

Update collection, removing elements for which function is false. For associative collections, the function is passed two arguments (key and value).

Indexable Collections¶

getindex(collection, key...)

Retrieve the value(s) stored at the given key or index within a collection. The syntax a[i,j,...] is converted by the compiler to getindex(a, i, j, ...).

setindex!(collection, value, key...)

Store the given value at the given key or index within a collection. The syntax a[i,j,...] = x is converted by the compiler to (setindex!(a, x, i, j, ...); x).

Fully implemented by:

• Array
• BitArray
• AbstractArray
• SubArray
• ObjectIdDict
• Dict
• WeakKeyDict
• AbstractString

Partially implemented by:

• Range
• UnitRange
• Tuple

Associative Collections¶

Dict is the standard associative collection. Its implementation uses hash() as the hashing function for the key, and isequal() to determine equality. Define these two functions for custom types to override how they are stored in a hash table.

ObjectIdDict is a special hash table where the keys are always object identities.

WeakKeyDict is a hash table implementation where the keys are weak references to objects, and thus may be garbage collected even when referenced in a hash table.

Dicts can be created by passing pair objects constructed with =>() to a Dict constructor: Dict("A"=>1, "B"=>2). This call will attempt to infer type information from the keys and values (i.e. this example creates a Dict{ASCIIString, Int64}). To explicitly specify types use the syntax Dict{KeyType,ValueType}(...). For example, Dict{ASCIIString,Int32}("A"=>1, "B"=>2).

As with Arrays, Dicts may be created with comprehensions. For example, [i => f(i) for i = 1:10].

Given a dictionary D, the syntax D[x] returns the value of key x (if it exists) or throws an error, and D[x] = y stores the key-value pair x => y in D (replacing any existing value for the key x). Multiple arguments to D[...] are converted to tuples; for example, the syntax D[x,y] is equivalent to D[(x,y)], i.e. it refers to the value keyed by the tuple (x,y).

Dict([itr])

Dict{K,V}() constructs a hash table with keys of type K and values of type V.

Given a single iterable argument, constructs a Dict whose key-value pairs are taken from 2-tuples (key,value) generated by the argument.

julia> Dict([("A", 1), ("B", 2)])
Dict{ASCIIString,Int64} with 2 entries:
"B" => 2
"A" => 1

Alternatively, a sequence of pair arguments may be passed.

julia> Dict("A"=>1, "B"=>2)
Dict{ASCIIString,Int64} with 2 entries:
"B" => 2
"A" => 1

haskey(collection, key) → Bool

Determine whether a collection has a mapping for a given key.

get(collection, key, default)

Return the value stored for the given key, or the given default value if no mapping for the key is present.

get(f::Function, collection, key)

Return the value stored for the given key, or if no mapping for the key is present, return f(). Use get!() to also store the default value in the dictionary.

This is intended to be called using do block syntax:

get(dict, key) do
# default value calculated here
time()
end

get!(collection, key, default)

Return the value stored for the given key, or if no mapping for the key is present, store key => default, and return default.

get!(f::Function, collection, key)

Return the value stored for the given key, or if no mapping for the key is present, store key => f(), and return f().

This is intended to be called using do block syntax:

get!(dict, key) do
# default value calculated here
time()
end

getkey(collection, key, default)

Return the key matching argument key if one exists in collection, otherwise return default.

delete!(collection, key)

Delete the mapping for the given key in a collection, and return the collection.

pop!(collection, key[, default])

Delete and return the mapping for key if it exists in collection, otherwise return default, or throw an error if default is not specified.

keys(collection)

Return an iterator over all keys in a collection. collect(keys(d)) returns an array of keys.

values(collection)

Return an iterator over all values in a collection. collect(values(d)) returns an array of values.

merge(collection, others...)

Construct a merged collection from the given collections. If necessary, the types of the resulting collection will be promoted to accommodate the types of the merged collections. If the same key is present in another collection, the value for that key will be the value it has in the last collection listed.

julia> a = Dict("foo" => 0.0, "bar" => 42.0)
Dict{ASCIIString,Float64} with 2 entries:
"bar" => 42.0
"foo" => 0.0

julia> b = Dict(utf8("baz") => 17, utf8("bar") => 4711)
Dict{UTF8String,Int64} with 2 entries:
"bar" => 4711
"baz" => 17

julia> merge(a, b)
Dict{UTF8String,Float64} with 3 entries:
"bar" => 4711.0
"baz" => 17.0
"foo" => 0.0

julia> merge(b, a)
Dict{UTF8String,Float64} with 3 entries:
"bar" => 42.0
"baz" => 17.0
"foo" => 0.0

merge!(collection, others...)

Update collection with pairs from the other collections

sizehint!(s, n)

Suggest that collection s reserve capacity for at least n elements. This can improve performance.

keytype(collection)

For associative collection types, this will be the type of the Key, This is not defined for non-associative collections

valtype(collection)

For associative collection types, this will be the type of the Value, This is not defined for non-associative collections

Fully implemented by:

• ObjectIdDict
• Dict
• WeakKeyDict

Partially implemented by:

• IntSet
• Set
• EnvHash
• Array
• BitArray

Set-Like Collections¶

Set([itr])

Construct a Set of the values generated by the given iterable object, or an empty set. Should be used instead of IntSet for sparse integer sets, or for sets of arbitrary objects.

IntSet([itr])

Construct a sorted set of positive Ints generated by the given iterable object, or an empty set. Implemented as a bit string, and therefore designed for dense integer sets. Only Ints greater than 0 can be stored. If the set will be sparse (for example holding a few very large integers), use Set instead.

union(s1, s2...)
∪(s1, s2...)

Construct the union of two or more sets. Maintains order with arrays.

union!(s, iterable)

Union each element of iterable into set s in-place.

intersect(s1, s2...)
∩(s1, s2)

Construct the intersection of two or more sets. Maintains order and multiplicity of the first argument for arrays and ranges.

setdiff(s1, s2)

Construct the set of elements in s1 but not s2. Maintains order with arrays. Note that both arguments must be collections, and both will be iterated over. In particular, setdiff(set,element) where element is a potential member of set, will not work in general.

setdiff!(s, iterable)

Remove each element of iterable from set s in-place.

symdiff(s1, s2...)

Construct the symmetric difference of elements in the passed in sets or arrays. Maintains order with arrays.

symdiff!(s, n)

The set s is destructively modified to toggle the inclusion of integer n.

symdiff!(s, itr)

For each element in itr, destructively toggle its inclusion in set s.

symdiff!(s1, s2)

Construct the symmetric difference of sets s1 and s2, storing the result in s1.

complement(s)

Returns the set-complement of IntSet s.

complement!(s)

Mutates IntSet s into its set-complement.

intersect!(s1, s2)

Intersects sets s1 and s2 and overwrites the set s1 with the result. If needed, s1 will be expanded to the size of s2.

issubset(A, S) → Bool
⊆(A, S) → Bool

Return true if A is a subset of or equal to S.

Fully implemented by:

• IntSet
• Set

Partially implemented by:

• Array

Dequeues¶

push!(collection, items...) → collection

Insert one or more items at the end of collection.

julia> push!([1, 2, 3], 4, 5, 6)
6-element Array{Int64,1}:
1
2
3
4
5
6

Use append!() to add all the elements of another collection to collection. The result of the preceding example is equivalent to append!([1, 2, 3], [4, 5, 6]).

pop!(collection) → item

Remove the last item in collection and return it.

julia> A=[1, 2, 3, 4, 5, 6]
6-element Array{Int64,1}:
1
2
3
4
5
6

julia> pop!(A)
6

julia> A
5-element Array{Int64,1}:
1
2
3
4
5

unshift!(collection, items...) → collection

Insert one or more items at the beginning of collection.

julia> unshift!([1, 2, 3, 4], 5, 6)
6-element Array{Int64,1}:
5
6
1
2
3
4

shift!(collection) → item

Remove the first item from collection.

julia> A = [1, 2, 3, 4, 5, 6]
6-element Array{Int64,1}:
1
2
3
4
5
6

julia> shift!(A)
1

julia> A
5-element Array{Int64,1}:
2
3
4
5
6

insert!(collection, index, item)

Insert an item into collection at the given index. index is the index of item in the resulting collection.

julia> insert!([6, 5, 4, 2, 1], 4, 3)
6-element Array{Int64,1}:
6
5
4
3
2
1

deleteat!(collection, index)

Remove the item at the given index and return the modified collection. Subsequent items are shifted to fill the resulting gap.

julia> deleteat!([6, 5, 4, 3, 2, 1], 2)
5-element Array{Int64,1}:
6
4
3
2
1

deleteat!(collection, itr)

Remove the items at the indices given by itr, and return the modified collection. Subsequent items are shifted to fill the resulting gap. itr must be sorted and unique.

julia> deleteat!([6, 5, 4, 3, 2, 1], 1:2:5)
3-element Array{Int64,1}:
5
3
1

julia> deleteat!([6, 5, 4, 3, 2, 1], (2, 2))
ERROR: ArgumentError: indices must be unique and sorted
in deleteat! at array.jl:546

splice!(collection, index[, replacement]) → item

Remove the item at the given index, and return the removed item. Subsequent items are shifted down to fill the resulting gap. If specified, replacement values from an ordered collection will be spliced in place of the removed item.

julia> A = [6, 5, 4, 3, 2, 1]; splice!(A, 5)
2

julia> A
5-element Array{Int64,1}:
6
5
4
3
1

julia> splice!(A, 5, -1)
1

julia> A
5-element Array{Int64,1}:
6
5
4
3
-1

julia> splice!(A, 1, [-1, -2, -3])
6

julia> A
7-element Array{Int64,1}:
-1
-2
-3
5
4
3
-1

To insert replacement before an index n without removing any items, use splice!(collection, n:n-1, replacement).

splice!(collection, range[, replacement]) → items

Remove items in the specified index range, and return a collection containing the removed items. Subsequent items are shifted down to fill the resulting gap. If specified, replacement values from an ordered collection will be spliced in place of the removed items.

To insert replacement before an index n without removing any items, use splice!(collection, n:n-1, replacement).

julia> splice!(A, 4:3, 2)
0-element Array{Int64,1}

julia> A
8-element Array{Int64,1}:
-1
-2
-3
2
5
4
3
-1

resize!(collection, n) → collection

Resize collection to contain n elements. If n is smaller than the current collection length, the first n elements will be retained. If n is larger, the new elements are not guaranteed to be initialized.

julia> resize!([6, 5, 4, 3, 2, 1], 3)
3-element Array{Int64,1}:
6
5
4

julia> resize!([6, 5, 4, 3, 2, 1], 8)
8-element Array{Int64,1}:
6
5
4
3
2
1
0
0

append!(collection, collection2) → collection.

Add the elements of collection2 to the end of collection.

julia> append!([1],[2,3])
3-element Array{Int64,1}:
1
2
3

julia> append!([1, 2, 3], [4, 5, 6])
6-element Array{Int64,1}:
1
2
3
4
5
6

Use push!() to add individual items to collection which are not already themselves in another collection. The result is of the preceding example is equivalent to push!([1, 2, 3], 4, 5, 6).

prepend!(collection, items) → collection

Insert the elements of items to the beginning of collection.

julia> prepend!([3],[1,2])
3-element Array{Int64,1}:
1
2
3

Fully implemented by:

• Vector (a.k.a. 1-dimensional Array)
• BitVector (a.k.a. 1-dimensional BitArray)

PriorityQueue¶

The PriorityQueue type is available from the Collections module. It provides a basic priority queue implementation allowing for arbitrary key and priority types. Multiple identical keys are not permitted, but the priority of existing keys can be changed efficiently.

PriorityQueue(K, V[, ord])

Construct a new PriorityQueue, with keys of type K and values/priorites of type V. If an order is not given, the priority queue is min-ordered using the default comparison for V.

enqueue!(pq, k, v)

Insert the a key k into a priority queue pq with priority v.

dequeue!(pq)

Remove and return the lowest priority key from a priority queue.

peek(pq)

Return the lowest priority key from a priority queue without removing that key from the queue.

PriorityQueue also behaves similarly to a Dict in that keys can be inserted and priorities accessed or changed using indexing notation.

julia> # Julia code
pq = Collections.PriorityQueue();

julia> # Insert keys with associated priorities
pq["a"] = 10; pq["b"] = 5; pq["c"] = 15; pq
Base.Collections.PriorityQueue{Any,Any,Base.Order.ForwardOrdering} with 3 entries:
"c" => 15
"b" => 5
"a" => 10

julia> # Change the priority of an existing key
pq["a"] = 0; pq
Base.Collections.PriorityQueue{Any,Any,Base.Order.ForwardOrdering} with 3 entries:
"c" => 15
"b" => 5
"a" => 0

Heap Functions¶

Along with the PriorityQueue type, the Collections module provides lower level functions for performing binary heap operations on arrays. Each function takes an optional ordering argument. If not given, default ordering is used, so that elements popped from the heap are given in ascending order.

heapify(v[, ord])

Return a new vector in binary heap order, optionally using the given ordering.

heapify!(v[, ord])

In-place heapify().

isheap(v[, ord])

Return true iff an array is heap-ordered according to the given order.

heappush!(v, x[, ord])

Given a binary heap-ordered array, push a new element x, preserving the heap property. For efficiency, this function does not check that the array is indeed heap-ordered.

heappop!(v[, ord])

Given a binary heap-ordered array, remove and return the lowest ordered element. For efficiency, this function does not check that the array is indeed heap-ordered.


text:
# How To Find Radius Of A Cone?

## What is the formula for radius?

The two formulas that are useful for finding the radius of a circle are C=2*pi*r and A=pi*r^2.

We use algebra skills in solving for our variable r.

We know that the constant pi is always 3.14.

Another word related to the radius is diameter, which is always twice the radius.

## How does the radius of a cone change with height?

When only the radius is changed – the surface area increases when the radius increases, and decreases when the radius decreases. When the height AND radius are both changed – the surface area will change when the height and radius of the cone change.

## How do you find radius from volume?

Finding the radius of a sphere given the volume –

## What is radius of a circle?

A radius is a straight line from the center of a circle to the circumference of a circle. If you have two or more of them, they are referred to as radii. All radii in a circle will be the same length. The circumference is the outside perimeter of a circle.

## How do you get rid of radius?

To calculate the radius of a circle by using the circumference, take the circumference of the circle and divide it by 2 times π. For a circle with a circumference of 15, you would divide 15 by 2 times 3.14 and round the decimal point to your answer of approximately 2.39. Be sure to include the units in your answer.

## How do you find the radius of a frustum of a cone?

The total increase in radius is r2−r1. So when you are zh of the way from the top to the bottom (as indicated in the figure), the radius has increased by zh times the total increase in radius, i.e., by (r2−r1)hz. Adding this to the initial radius tells you that the radius is r1+(r2−r1)hz at a distance z from the top.

## What is the formula for finding a cone?

equation of the cone. Let the equation of the cone be, ax2 + by2 + cz2 + 2fyz + 2gzx + 2hxy = 0. The coordinates of any point on the line are (lt, mt, nt), where t ∈ R.

## What is the formula for finding the surface area of a cone?

The surface area of a cone is equal to the curved surface area plus the area of the base: π r 2 + π L r , \pi r^2 + \pi L r, πr2+πLr, where r denotes the radius of the base of the cone, and L denotes the slant height of the cone. The curved surface area is also called the lateral area.

## How do you find the missing radius of a sphere?

Finding the radius of a sphere given the volume –

## How do you find the total surface area of a sphere?

To find the surface area of a sphere, use the equation 4πr2, where r stands for the radius, which you will multiply by itself to square it. Then, multiply the squared radius by 4. For example, if the radius is 5, it would be 25 times 4, which equals 100.

## How do you find the center and radius of a sphere?

How To Find The Equation of a Sphere, Center, & Radius Given The


text:
# How to partial out a covariate in logistic regression

I was performing logistic regression on some data, and I realised that I need to remove or partial out the effects of another covariate.

If $x$ is the predictor of interest, the model is:

$$y \sim \mathbf{logit}^{-1}(ax+b)$$

One option would be to include the covariate $z$ as another regressor:

$$y \sim \mathbf{logit}^{-1}(ax+b + cz)$$

But in general $z$ might be correlated with $x$. So for my purposes, it is important to first regress out $z$. I don't want the parameter of interest $a$ to reflect any variance that could be explained by $z$.

If this were linear regression, I'd take the residuals from the regression $y\sim cz+b$, then regress these residuals against $x$: $(y-\hat{y})\sim x$ to obtain the parameter of interest. (By the way, is there a name for this process, of regressing out a variable that is not of interest?)

But for a logistic regression, I am not sure how to treat the residuals from the first regression. Say I do $\hat{y}=cz+b$. Can I attempt a logistic regression on the (non-binary) residuals $(y-\hat{y})$? Or perhaps perform a linear regression on some transformed function of the residuals? I am thinking of something like:

$$\log\bigg(\frac{\hat{y}-y}{y-\hat{y}}\bigg)$$

You don't do this. You shouldn't do what you are describing in a linear regression context either. All you need to do is include both variables in a multiple regression (multiple logistic regression) model. That will take care of this for you. Moreover, it won't matter if $x$ is correlated with $z$. If they are, then the standard errors will be larger (appropriately), but the estimated coefficients will be correct.

You may be interested in reading:

• Dear Gung, thank you very much for the reading list. I can see now that the topic is complex. Two of the answers suggested the residual method, but further reading demonstrates that this is not always good when you don't know the underlying causal model. Simpson's paradox was particularly relevant. In my case, I know for certain that the confounder has a simple and strong causal effect upon the measurable. Therefore I considered Gram-Schmidt orthogonalisation, putting the confounder $z$ first. Now the $x$ coefficient reflects only its independent contribution. Does this sound reasonable? – Sanjay Manohar Nov 17 '16 at 17:44
• @SanjayManohar, having ortogonal input variables will make it easier for the model to identify their unique effects, but the point here is that all you need to do is fit a multiple logistic regression model. – gung - Reinstate Monica Nov 17 '16 at 17:51
• Great thank you. Yes, I guess my original question was really about how to identify the unique effects, because the basic multiple logistic regression was not attributing the coefficients as I had intended. So I will go with orthogonalised predictors. – Sanjay Manohar Nov 17 '16 at 18:05
• Gung you are not correct in saying that one can completely partial out the effect of one predictor simply by including it in a multiple regression with the other predictor of interest. When the predictors are correlated, the shared variance can be allocated to either predictor in the regression equation without affecting overall prediction. This means the fitted weights do not have a unique interpretation unless the predictors are orthogonal. See this article by JA Jones and NG Waller (2016) "Fungible weights in logistic regression", Psychological Methods, 21(2), 241. There is an R package "fu – Geoff Stuart Apr 2 '19 at 23:36


text:
# Exact formula for $\sum_{n=0}^{+\infty}\frac1{n^2+1}$

Actually, as the corresponding integral $\frac{\ln(\cos x)}{1-x}$ or something like that) cannot be expressed in closed form by Liouville theorem, this shouldn't exist, but I believe I have seen it shown somewhere using Fourier series. By the way, the result : $$\sum_{n=0}^{\infty}\frac{1}{n^2+1}= \frac{1+ \pi\coth\pi}{2}$$ is known by WolframAlpha. But my question is : does there exists a general theory of similar results (something like exact formulas for $\sum_{n=0}^{+\infty}\frac{1}{an^2+bn+c}$, at least when $a$, $b$ and $c$ are integers)?

• Yes. We may interpret $f(n)$ as a residue of function $f(x)\cot (\pi x)$ in a point $n$. Then note that sum of residues of this function equals to 0 as integral over appropriate large circuit tends to 0. – Fedor Petrov Nov 30 '15 at 15:13
• There is no relation between existence of closed form for $\int f(x)\;dx$ and closed form for $\sum f(n)$. – Gerald Edgar Nov 30 '15 at 15:15
• Integral not of f(x), but of $f(x)\cot \pi x$ – Fedor Petrov Nov 30 '15 at 15:30
• Your "Wolfram Alpha answer is incorrect". See my answer. – Alexandre Eremenko Dec 1 '15 at 0:18
• WolframAlpha does accurately evaluate this series; however, the value was initially mis-recorded here. (Hence the edit.) – Benjamin Dickman Dec 1 '15 at 6:55

To do $\sum\frac{1}{an^2+bn+c}$, factor the denominator and get a digamma answer. $$\sum_{n=0}^\infty \frac{1}{(x+p)(x+q)} = \frac{\psi(p)-\psi(q)}{p-q}$$ And note that digamma of a rational can be evaluated in terms of logarithms and trig functions (Gauss's digamma theorem). $$\sum_{n=0}^\infty\frac{1}{(n+\frac{1}{4})(n+\frac{1}{3})} = 36\log 2+6\pi-2\pi\sqrt{3}-18\log 3 .$$

This is a standard exercise on residue theory. If $f$ is a rational function with zero of order $\geq 2$ at infinity and no poles at integers, then $$\sum_{-\infty}^\infty f(n)=-\sum{\mathrm{res}}_af(z)\pi\cot\pi z,$$ where the summation is over all poles of $f$. For $f(z)=1/(1+z^2)$ we obtain $$\sum_0^\infty\frac{1}{1+n^2}=1+\sum_{1}^\infty\frac{1}{1+n^2}=(\pi\coth\pi+1)/2,$$ so you copied the result from Wolfram incorrectly.

• Mmm ; sorry, but Wolfram (and Maple) gives the sum equals to 2.07417717505..., while (π coth π+1)/2 is 2.07667404... – Feldmann Denis Nov 30 '15 at 21:05
• @FeldmannDenis this anser 2.0766704 is correct, and when I ask Wolframalpha it confirms this wolframalpha.com/input/… – Fedor Petrov Nov 30 '15 at 22:02

Alternatively, you may use expansion of cotangent $$\pi\cot \pi x=\frac1x+\sum_{n=1}^{\infty}\frac{2x}{x^2-n^2}$$ as a blackbox (after all, complex residues are not the only way to obtain this formula: say, there is Herglotz trick, explained, for instance, in Proofs from the Book).

Just substitute $x=i$, for the sum $S=\sum_{n=0}^{\infty} \frac1{n^2+1}$ we get $\pi \cot \pi i=-i-2i(S-1)$, $2iS=i-\pi \cot \pi i=i(1+\pi\cot \pi)$, $S=(1+\pi \cot \pi)/2$.

For arbitrary rational function $f(z)$, we may find on this way the principal value of $\sum_{n\in \mathbb{Z}} f(n)$. If $f(z)=\sum_k c_k/(z_k-z)$, for each summand we have $$\sum_{j=-n}^n\frac1{z_k-j}=\frac1{z_k}+\sum_{k=1}^n\frac{2z_k}{z_k^2-j^2}\rightarrow \frac{\pi\cot \pi z_k}2,$$ thus principal value of $\sum_{n\in \mathbb{Z}} f(n)$ equals $$\sum_k c_k \frac{\pi\cot \pi z_k}2.$$ This works whenever $f$ has only simple poles and $f(z)=O(1/z)$ for large $z$. If additionally $f(z)=O(1/z^2)$, principal value is the same as ordinary sum. If $f$ has multiple poles, we may perturbate $f$ a bit and take a limit. Yes, this is one of approaches to residues.

If you need a sum not over integers, but over positive integers (it looks like it is the case), you instead of cotangent use the digamma $\psi$-function $$\psi(z)=-\gamma+\sum_{n=0}^{\infty} \left(\frac1{n+1}-\frac1{n+z}\right).$$ This is the essence of Gerald Edgard's answer.

• Yes, but he asked to sum $f(n)$ with a more general class of functions $f$. – Alexandre Eremenko Dec 1 '15 at 0:14
• Indeed, but this works for all rational functions. – Fedor Petrov Dec 1 '15 at 5:59
• Just to complete the picture, the expansion of the cotangent can be obtained by logarithmic differentiation from the infinite product for $\sin(\pi x)$, and the infinite product for $\sin(\pi x)$ can be obtained as dominated limit on the (easily computed) complete factorization of the polynomials $(1+iz/n)^n-(1-iz/n)^n$, that converge to $e^{iz}-e^{-iz}=2i\sin(z)$ (Is this Herglotz' proof?) – Pietro Majer Dec 1 '15 at 11:24
• (no: I've just found Herglotz trick on line) – Pietro Majer Dec 1 '15 at 11:32
• oh, I did not know this trick with polynomial – Fedor Petrov Dec 1 '15 at 12:07


text:
# Scoring model performance with the solaris python API¶

This tutorial describes how to run evaluation of a proposal (CSV or .geojson) for a single chip against a ground truth (CSV or .geojson) for the same chip.

## CSV Eval¶

### Steps¶

1. Imports

4. Perform evaluation

### Imports¶

For this test case we will use the eval submodule within solaris.

[1]:

# imports
import os
import solaris as sol
from solaris.data import data_dir
import pandas as pd  # just for visualizing the outputs

We will first instantiate an Evaluator() object, which is the core class eval uses for comparing predicted labels to ground truth labels. Evaluator() takes one argument - the path to the CSV or .geojson ground truth label object. It can alternatively accept a pre-loaded GeoDataFrame of ground truth label geometries.

[4]:

ground_truth_path = os.path.join(data_dir, 'sample_truth.csv')

evaluator = sol.eval.base.Evaluator(ground_truth_path)
evaluator

[4]:

Evaluator sample_truth.csv

At this point, evaluator has the following attributes:

• ground_truth_fname: the filename corresponding to the ground truth data. This is simply 'GeoDataFrame' if a GDF was passed during instantiation.

• ground_truth_GDF: GeoDataFrame-formatted geometries for the ground truth polygon labels.

• ground_truth_GDF_Edit: A deep copy of eval_object.ground_truth_GDF which is edited during the process of matching ground truth label polygons to proposals.

• ground_truth_sindex: The RTree/libspatialindex spatial index for rapid spatial referencing.

• proposal_GDF: An empty GeoDataFrame instantiated to hold proposals later.

Next we will load in the proposal CSV file. Note that the proposalCSV flag must be set to true for CSV data. If the CSV contains confidence column(s) that indicate confidence in proprosals, the name(s) of the column(s) should be passed as a list of strings with the conf_field_list argument; because no such column exists in this case, we will simply pass conf_field_list=[]. There are additional arguments available (see the method documentation) which can be used for multi-class problems; those will be covered in another recipe. The defaults suffice for single-class problems.

[5]:

proposals_path = os.path.join(data_dir, 'sample_preds.csv')

### Perform evaluation¶

Evaluation iteratively steps through the proposal polygons in eval_object.proposal_GDF and determines if any of the polygons in eval_object.ground_truth_GDF_Edit have IoU overlap > miniou (see the method documentation) with that proposed polygon. If one does, that proposal polygon is scored as a true positive. The matched ground truth polygon with the highest IoU (in case multiple had IoU > miniou) is removed from eval_object.ground_truth_GDF_Edit so it cannot be matched against another proposal. If no ground truth polygon matches with IoU > miniou, that proposal polygon is scored as a false positive. After iterating through all proposal polygons, any remaining ground truth polygons in eval_object.ground_truth_GDF_Edit are scored as false negatives.

There are several additional arguments to this method related to multi-class evaluation which will be covered in a later recipe. See the method documentation for usage.

The prediction outputs a list of dicts for each class evaluated (only one dict in this single-class case). The dict(s) have the following keys:

• 'class_id': The class being scored in the dict, 'all' for single-class scoring.

• 'iou_field': The name of the column in eval_object.proposal_GDF for the IoU score for this class. See the method documentation for more information.

• 'TruePos': The number of polygons in eval_object.proposal_GDF that matched a polygon in eval_object.ground_truth_GDF_Edit.

• 'FalsePos': The number of polygons in eval_object.proposal_GDF that had no match in eval_object.ground_truth_GDF_Edit.

• 'FalseNeg': The number of polygons in eval_object.ground_truth_GDF_Edit that had no match in eval_object.proposal_GDF.

• 'Precision': The precision statistic for IoU between the proposals and the ground truth polygons.

• 'Recall': The recall statistic for IoU between the proposals and the ground truth polygons.

• 'F1Score': Also known as the SpaceNet Metric, the F1 score for IoU between the proposals and the ground truth polygons.

[6]:

evaluator.eval_iou(calculate_class_scores=False)

151it [00:00, 153.44it/s]

[6]:

[{'class_id': 'all',
'iou_field': 'iou_score_all',
'TruePos': 151,
'FalsePos': 0,
'FalseNeg': 0,
'Precision': 1.0,
'Recall': 1.0,
'F1Score': 1.0}]

In this case, the score is perfect because the polygons in the ground truth CSV and the proposal CSV are identical. At this point, a new proposal CSV can be loaded (for example, for a new nadir angle at the same chip location) and scoring can be repeated.

## GeoJSON Eval¶

The same operation can be completed with .geojson-formatted ground truth and proposal files. See the example below, and see the detailed explanation above for a description of each step’s operations.

[7]:

ground_truth_geojson = os.path.join(data_dir, 'gt.geojson')
proposal_geojson = os.path.join(data_dir, 'pred.geojson')

evaluator = sol.eval.base.Evaluator(ground_truth_geojson)
evaluator.eval_iou(calculate_class_scores=False)

28it [00:00, 76.20it/s]

[7]:

[{'class_id': 'all',
'iou_field': 'iou_score_all',
'TruePos': 8,
'FalsePos': 20,
'FalseNeg': 20,
'Precision': 0.2857142857142857,
'Recall': 0.2857142857142857,
'F1Score': 0.2857142857142857}]

(Note that the above comes from a different chip location and different proposal than the CSV example, hence the difference in scores)


text:
# Assuming $H \unlhd G$, construct the quotient group $G/H$

How do I go about doing this? I know that the definition of a quotient group is that it is the set of left cosets (aH) equipped with the following opeation:

$$(aH)(bH) = (ab)H$$

Where the identity is $(1_G \cdot H) = H$.

How do I construct the group from here though? Or is this all the question is asking?

-
I'd erase that second question about orbit, which isn't related at all to the first one, and would open a second thread for it. – DonAntonio Dec 7 '12 at 17:06

You need to make (state) the connection between the hypothesis that $H\unlhd G$ and the conclusion that your $H/G$ is indeed a quotient group.

$$(aH)(bH) = (ab)H, \;\text {where the identity is}\;\; (1_G \cdot H) = H$$

You've got the pieces; you just need to connect them and verify that you do have a quotient group.

That is, simply verify that $(aH)(bH) = abH$ is well-defined, and that the operation defines a "group structure", to show that it is indeed a group.

This is easily established using the premise that $H\unlhd G$. For any old subgroup $H$ of $G$, it does not necessarily hold that $(aH)(bH) = abH,\;\; a, b \in G.\;\;$ It holds iff $H\unlhd G.$

Note: If you haven't learned that left coset multiplication on a subgroup $H$ is well defined if and only if $H$ is a normal subgroup of a group $G$, you should prove that. And if you haven't learned that the left (right) cosets of a normal subgroup $H$ of $G$ form a group $G/H$, then you need to prove that as well.

-
Is that all I would say for the proof then? – Kaish Dec 7 '12 at 17:40
Yes, given that $H\unlhd G$, you know that $aHbH = abH$, which satisfies one requirement of a quotient group. Likewise, you know that $(1_G\cdot H = H)$. Hence, G/H is your desired quotient group! – amWhy Dec 7 '12 at 17:42

That's is, you've constructed it! Now prove

(1) the operation is well defined, meaning

$$aH=a'H\,\,,\,\,\,bH=b'H\Longrightarrow (ab)H=(a'b')H$$

and

(2) the operation actually gives you a group structure on the set of (left or right, it doesn't matter) cosets of H.

-
Is this important for the OP that he should care about the operation in abelian and non-abelian groups? I mean $aH$ and $a+H$. – Babak S. Dec 7 '12 at 17:08
Do I need to prove it if they're just asking for the construction? – Kaish Dec 7 '12 at 17:19
@Kaish, I think you must do that. – DonAntonio Dec 7 '12 at 17:31
@Babak, I don't think so. That'll come later. – DonAntonio Dec 7 '12 at 17:31
@Thanks, Don. Yes, it comes later. – Babak S. Dec 7 '12 at 17:45


text:
How do I test Online Contribution Receipts?

How do I test the edits I make to online contribution receipts? Is making a test contribution using the online form the only way, or recommended way?

I would recommend you only TEST LIVE; Just delete the contribution that you have created afterwards; a $1 LIVE transaction that you can follow all the way though into your Payment Processor - will guarantee you that things are working as expected. Added: You'll have tokens for total_amount etc, right? This is how you test it. You can also plug in TEST credentials for your payment Processor in LIVE payment processor config. Then you can test LIVE CiviCRM pathways with fake VISA cards. • Totally agree. a real$1 test proves way more. – petednz - fuzion Aug 8 '17 at 6:29