text:
# Why does Churchill say they will be able to defend the English Channel and North Sea

###### Question:

why does Churchill say they will be able to defend the English Channel and North Sea

### What part of the bacteriophage attaches and anchors itself to the bacteria?

What part of the bacteriophage attaches and anchors itself to the bacteria?...

### What is the distance between points A(-3, 4) and B(1, -2) ? Round to the nearest tenth if necessary.

What is the distance between points A(-3, 4) and B(1, -2) ? Round to the nearest tenth if necessary. ...

### Consider these long-term investment data: ∙ The price of a 10-year $100 par value zero-coupon inflation-indexed bond is$84.49. ∙ A real-estate property is expected to yield 2% per quarter (nominal) with a SD of the (effective) quarterly rate of 10%. a. Compute the annual rate of return on the real (i.e., inflation-indexed) bond. b. Compute the continuously compounded annual risk premium on the real-estate investment. c. Use the formula in footnote 17 and Excel’s Solver or Goal Seek to find the

Consider these long-term investment data: ∙ The price of a 10-year $100 par value zero-coupon inflation-indexed bond is$84.49. ∙ A real-estate property is expected to yield 2% per quarter (nominal) with a SD of the (effective) quarterly rate of 10%. a. Compute the annual rate of return on the r...

### A pedestrian moves 6.00 km east and then 13.0 km north. Find the magnitude and direction of the resultant?

A pedestrian moves 6.00 km east and then 13.0 km north. Find the magnitude and direction of the resultant?...

### Based on the details in The Riddle of the Rosetta Stone, how did the career of Jean-Baptiste Fourier differ from that of Jacques-Joseph Champollion?

Based on the details in The Riddle of the Rosetta Stone, how did the career of Jean-Baptiste Fourier differ from that of Jacques-Joseph Champollion?...

### A written pledge by a lender to lend a certain amount of money to a qualified borrower on a particular piece of real estate for a specified time under specific terms is a:_____________

A written pledge by a lender to lend a certain amount of money to a qualified borrower on a particular piece of real estate for a specified time under specific terms is a:_____________...

### TEST 2Et1FAIpQLSdWVOGRsM60AngluhTh1xudoKlfwj6JyhWY4112j3QldQ6Spw/formResponse24. Which of the following phrases serves as the prepositional phrase in thefollowing sentence: "In the morning, my friend misplaced his phone at the shopa. His phoneO b. At the shopO c. The morningO d. His phone

TEST 2Et1FAIpQLSdWVOGRsM60AngluhTh1xudoKlfwj6JyhWY4112j3QldQ6Spw/formResponse24. Which of the following phrases serves as the prepositional phrase in thefollowing sentence: "In the morning, my friend misplaced his phone at the shopa. His phoneO b. At the shopO c. The morningO d. His phone...

### The lowest elevation in vermont is 95 feet above sea level. the lowest elevation in louisiana is 8 feet below sea level. what integer represents the lowest elevation in vermont

the lowest elevation in vermont is 95 feet above sea level. the lowest elevation in louisiana is 8 feet below sea level. what integer represents the lowest elevation in vermont...

### The quadratic equation is y = x^2 - 4x -5 how do i find the vertex and do the number line ?

the quadratic equation is y = x^2 - 4x -5 how do i find the vertex and do the number line ?...

### An art teacher has 40 paintbrushes. She divides them equally among her 4 students. She finds 8 more brushes and divides these equally among the students, as well. How many brushes does each student receive?

An art teacher has 40 paintbrushes. She divides them equally among her 4 students. She finds 8 more brushes and divides these equally among the students, as well. How many brushes does each student receive?...

### PLEASE HELP! WILL MARK BRAINLIEST 1. Solve The Inequality & Graph The Solution: v-6≥4 2. Solve The Inequality & Graph The Solution: -5x<15 3. Solve The Inequality & Graph The Solution: 3k>5k+12 5. Solve The Compound Inequality: 2t≤-4 or 7t≥49 6. Solve The Equation. If There Is No Solution, Write No Solution (Show Work): |n+2|=4 7. Solve The Equation. If There Is No Solution, Write No Solution (Show Work): |2x-7|>1 8. Given A={1,2,3,4,5,6,7,8,9} & B={2,4,6,8}, What Is AuB

PLEASE HELP! WILL MARK BRAINLIEST 1. Solve The Inequality & Graph The Solution: v-6≥4 2. Solve The Inequality & Graph The Solution: -5x<15 3. Solve The Inequality & Graph The Solution: 3k>5k+12 5. Solve The Compound Inequality: 2t≤-4 or 7t≥49 6. Solve The Equation. If There I...

### What was the name of the group of men led by Oliver Cromwell who fought against the Royalist in the English Civil War A. Jacobins B. Cavaliers C. Loyalist D. New Model Army

What was the name of the group of men led by Oliver Cromwell who fought against the Royalist in the English Civil War A. Jacobins B. Cavaliers C. Loyalist D. New Model Army...

### A. Complete the description of their day. If the word in parenthesis is a verb, conjugate that verb in the present tense, however if the word/phrase in parenthesis is in English, translate that word into Spanish. Each item is worth 2 points. Todos los días, mi papá, Nicolás, 1. Desperate (despertarse) a las siete y toma café inmediatamente. No le gustan las mañanas pero mis hermanos, Mateo y Miguel 2. Levantais (levantarse) muy temprano 3. a las 7:30AM (at 7:30am). Entonces, papá va al baño y 4.

A. Complete the description of their day. If the word in parenthesis is a verb, conjugate that verb in the present tense, however if the word/phrase in parenthesis is in English, translate that word into Spanish. Each item is worth 2 points. Todos los días, mi papá, Nicolás, 1. Desperate (despert...

### Does anyone know the answers to the Australia and the Pacific test? Here is one of the questions: "Which is the correct order of events related to the history of Australia and New Zealand? Place the earliest event at the top and the last event at the bottom." 1. Australia and New Zealand become dominions. 2. World War 1 occurs. 3. Australia and New Zealand become independent countries. 4. British recognizes Australia and New Zealand as equals to Britain under the British crown. Please, I need

Does anyone know the answers to the Australia and the Pacific test? Here is one of the questions: "Which is the correct order of events related to the history of Australia and New Zealand? Place the earliest event at the top and the last event at the bottom." 1. Australia and New Zealand become do...

### Write the formula two atom of iron and three atoms of oxygen

write the formula two atom of iron and three atoms of oxygen...

### Convert the given measurements to the new units to be 37cm

convert the given measurements to the new units to be 37cm...

### Use the give triangles to evaluate the expression. Rationalize all denominators. Csc 60 degrees - Cos 45 degrees

Use the give triangles to evaluate the expression. Rationalize all denominators. Csc 60 degrees - Cos 45 degrees...


text:
# A particle moves with velocity v=6t from time t=0 to t=10. How do you find the average velocity with respect to a) time and b) distance?

Jun 14, 2018

bb( a) ) 30

bb( b) ) 40

No units quoted or stated

#### Explanation:

a)

With respect to time , with $v \left(t\right) = 6 t$:

${v}_{\text{ave}} = \frac{{\int}_{\boldsymbol{\Delta t}} \setminus \boldsymbol{\mathrm{dt}} q \quad v \left(t\right)}{\boldsymbol{\Delta t}}$

$\therefore {v}_{\text{ave}} = \frac{{\int}_{0}^{10} \setminus \mathrm{dt} q \quad 6 t}{10}$

$= \frac{1}{10} {\left[3 {t}^{2}\right]}_{0}^{10} \boldsymbol{= 30}$

b)

With respect to distance :

${v}_{\text{ave}} = \frac{{\int}_{\boldsymbol{\Delta x}} \setminus \boldsymbol{\mathrm{dx}} q \quad v \left(x\right)}{\boldsymbol{\Delta x}}$

Now:

• $\frac{\mathrm{dv}}{\mathrm{dx}} = \frac{\mathrm{dv}}{\mathrm{dt}} \frac{\mathrm{dt}}{\mathrm{dx}} = \frac{6}{v}$, variable $t$ has been eliminated

Separating out:

$v \setminus \mathrm{dv} = 6 \setminus \mathrm{dx}$

And integrating:

${v}^{2} / 2 = 6 x + C$

The IV:

• $v \left(t = 0\right) = 0 , x \left(t = 0\right) = 0$

• $\implies v \left(x = 0\right) = 0 \implies C = 0$

So: $\boldsymbol{v = \sqrt{12 x}}$

And, eg, from the $v - t$ graph:

• $x \left(t = 10\right) = 300$

$\therefore {v}_{\text{ave}} = \frac{{\int}_{0}^{300} \setminus \mathrm{dx} q \quad \sqrt{12 x}}{300} q \quad \triangle$

ASIDE :

• $\int \setminus \mathrm{dx} \setminus \sqrt{12 x} = \int \setminus d \left(\frac{u}{12}\right) \setminus \sqrt{u}$

$= \frac{1}{12} {\left(u\right)}^{\frac{3}{2}} / \left(\frac{3}{2}\right) + C = \frac{1}{18} {\left(u\right)}^{\frac{3}{2}} + C$

Evaluating:

$\implies \triangle = \frac{1}{300} {\left({\left(12 x\right)}^{\frac{3}{2}} / 18\right)}_{0}^{300}$

$\boldsymbol{= 40}$

format: plain


text:
# Recursive block matrix

I am currently writing a document in which I need to create a matrix that looks like the picture below. What is the shortest and easiest way to do so?

-

Here I created the base image called \basefig. It is a box that has been manually centered with a \raisebox so that it will work smoothly in math mode. Then I inset two images relative to the left-top corner. The insets were scaled down versions of the original. Finally the third inset was the LL in the upper left corner.

EDITED to insert upper left element

\documentclass{article}
\usepackage{scalerel}
\usepackage[usestackEOL]{stackengine}
\setstackgap{S}{0pt}
\def\sqs{5ex}
\newsavebox\basebox
\def\bsfig{%
\sffamily%
\Shortstack{%
\makebox[\sqs]{}\rule[-1.7ex]{.2pt}{\sqs}\makebox[\sqs]{HL}\\%
\rule{9ex}{.2pt}\\%
\makebox[\sqs]{LH}\rule[-1.7ex]{.2pt}{\sqs}\makebox[\sqs]{HH}\\%
}%
}
\sbox\basebox{\bsfig}
\def\basefig{\raisebox{-.45\ht\basebox}{\usebox{\basebox}}}
\begin{document}
$\left[ \stackinset{l}{3pt}{t}{3.25pt}{\scalerel*{$\sffamily LL$}{\rule{.2pt}{0.3ex}}}{% \stackinset{l}{2pt}{t}{2pt}{\scalerel*{$\basefig$}{\rule[-.7ex]{.2pt}{1.8ex}}}{% \stackinset{l}{1pt}{t}{1pt}{\scalerel*{$\basefig$}{\rule[-1.75ex]{.2pt}{4.5ex}}}{% \basefig% }}}% \right]$
\end{document}

-
+1 I like the simplicity of this approach using your packages! –  Gonzalo Medina Jan 30 at 15:32


text:
Search by Topic

Filter by: Content type:
Age range:
Challenge level:

There are 28 results

Broad Topics > Numbers and the Number System > Number theory

How Much Can We Spend?

Age 11 to 14 Challenge Level:

A country has decided to have just two different coins, 3z and 5z coins. Which totals can be made? Is there a largest total that cannot be made? How do you know?

Always Perfect

Age 14 to 16 Challenge Level:

Show that if you add 1 to the product of four consecutive numbers the answer is ALWAYS a perfect square.

Number Rules - OK

Age 14 to 16 Challenge Level:

Can you convince me of each of the following: If a square number is multiplied by a square number the product is ALWAYS a square number...

Where Can We Visit?

Age 11 to 14 Challenge Level:

Charlie and Abi put a counter on 42. They wondered if they could visit all the other numbers on their 1-100 board, moving the counter using just these two operations: x2 and -5. What do you think?

Differences

Age 11 to 14 Challenge Level:

Can you guarantee that, for any three numbers you choose, the product of their differences will always be an even number?

There's a Limit

Age 14 to 18 Challenge Level:

Explore the continued fraction: 2+3/(2+3/(2+3/2+...)) What do you notice when successive terms are taken? What happens to the terms if the fraction goes on indefinitely?

A Little Light Thinking

Age 14 to 16 Challenge Level:

Here is a machine with four coloured lights. Can you make two lights switch on at once? Three lights? All four lights?

An Introduction to Number Theory

Age 16 to 18

An introduction to some beautiful results of Number Theory

Data Chunks

Age 14 to 16 Challenge Level:

Data is sent in chunks of two different sizes - a yellow chunk has 5 characters and a blue chunk has 9 characters. A data slot of size 31 cannot be exactly filled with a combination of yellow and. . . .

The Public Key

Age 16 to 18 Challenge Level:

Find 180 to the power 59 (mod 391) to crack the code. To find the secret number with a calculator we work with small numbers like 59 and 391 but very big numbers are used in the real world for this.

Ordered Sums

Age 14 to 16 Challenge Level:

Let a(n) be the number of ways of expressing the integer n as an ordered sum of 1's and 2's. Let b(n) be the number of ways of expressing n as an ordered sum of integers greater than 1. (i) Calculate. . . .

A One in Seven Chance

Age 11 to 14 Challenge Level:

What is the remainder when 2^{164}is divided by 7?

2^n -n Numbers

Age 16 to 18

Yatir from Israel wrote this article on numbers that can be written as $2^n-n$ where n is a positive integer.

Age 16 to 18

What is the relationship between the arithmetic, geometric and harmonic means of two numbers, the sides of a right angled triangle and the Golden Ratio?

More Sums of Squares

Age 16 to 18

Tom writes about expressing numbers as the sums of three squares.

Sums of Squares and Sums of Cubes

Age 16 to 18

An account of methods for finding whether or not a number can be written as the sum of two or more squares or as the sum of two or more cubes.

Modulus Arithmetic and a Solution to Differences

Age 16 to 18

Peter Zimmerman, a Year 13 student at Mill Hill County High School in Barnet, London wrote this account of modulus arithmetic.

Really Mr. Bond

Age 14 to 16 Challenge Level:

115^2 = (110 x 120) + 25, that is 13225 895^2 = (890 x 900) + 25, that is 801025 Can you explain what is happening and generalise?

Strange Numbers

Age 11 to 14 Challenge Level:

All strange numbers are prime. Every one digit prime number is strange and a number of two or more digits is strange if and only if so are the two numbers obtained from it by omitting either. . . .

Never Prime

Age 14 to 16 Challenge Level:

If a two digit number has its digits reversed and the smaller of the two numbers is subtracted from the larger, prove the difference can never be prime.

More Marbles

Age 11 to 14 Challenge Level:

I start with a red, a blue, a green and a yellow marble. I can trade any of my marbles for three others, one of each colour. Can I end up with exactly two marbles of each colour?

Marbles

Age 11 to 14 Challenge Level:

I start with a red, a green and a blue marble. I can trade any of my marbles for two others, one of each colour. Can I end up with five more blue marbles than red after a number of such trades?

Helen's Conjecture

Age 11 to 14 Challenge Level:

Helen made the conjecture that "every multiple of six has more factors than the two numbers either side of it". Is this conjecture true?

Novemberish

Age 14 to 16 Challenge Level:

a) A four digit number (in base 10) aabb is a perfect square. Discuss ways of systematically finding this number. (b) Prove that 11^{10}-1 is divisible by 100.

Mod 7

Age 16 to 18 Challenge Level:

Find the remainder when 3^{2001} is divided by 7.

Diophantine N-tuples

Age 14 to 16 Challenge Level:

Can you explain why a sequence of operations always gives you perfect squares?

Pythagorean Golden Means

Age 16 to 18 Challenge Level:

Show that the arithmetic mean, geometric mean and harmonic mean of a and b can be the lengths of the sides of a right-angles triangle if and only if a = bx^3, where x is the Golden Ratio.

Euler's Squares

Age 14 to 16 Challenge Level:

Euler found four whole numbers such that the sum of any two of the numbers is a perfect square...


text:
# Find the Hamiltonian given $\dot p$ and $\dot q$

I have these equations:

$$\dot p=ap+bq,$$ $$\dot q=cp+dq,$$

and I have to find the conditions such as the equations are canonical. Then, I have to find the Hamiltonian $H$.

To answer to the first question, I have imposed that $$\frac{\partial}{\partial q}(\frac{\partial H}{\partial p})+\frac{\partial }{\partial p}(-\frac{\partial H}{\partial q})=0$$

$$\frac{\partial}{\partial q}(cp+dq)+\frac{\partial }{\partial p}(ap+bq)=0$$ $$\Rightarrow d+a=0.$$

And so I have that the canonical equations are in the form:

$$\dot p=ap+bq,$$ $$\dot q=cp-aq.$$

But how can I find the Hamiltonian? The result must be $H=-apq-\frac{1}{2}bq^2+\frac{1}{2}cp^2$. The general expression $H=\sum p_i \dot q_i-L$ doesn't help me.

-
You yourself identify $\partial H/\partial p$ with $c\ p+d\ q$ etc. Why not just integrate that? Also, as your system reads $\dot\pi=A\pi$, with constant $A=((a,b),(c,d))$, I guess that the quadratic ansatz $H=x\ p^2/2+y\ q^2/2+z\ pq$ might be worth a try. – NikolajK Feb 11 '13 at 14:40
@NickKidman: I'm sorry, but I haven't understand.. I have added (in the question) the result that I have to obtain.. In particular I haven't understand the reasoning about A: what's A? – sunrise Feb 11 '13 at 15:19
If $\pi = (p, q)$ is a (phase space) vector and $A=\left((a,b), (c,d)\right)$ is a $2\times2$ matrix then your equations of motion read $\dot{\pi}=A\pi$. If that doesn't help you don't worry about it. You can integrate a partial derivative: if you know $\partial H/\partial p = f(p,q)$ then $H = \int f \mathrm{d}p + g(q)$, where $g(q)$ is some function of $q$ you'll have to determine by using the other Hamilton equation. Check this result by taking the derivative $\partial/\partial p$ to make sure you understand it. – Michael Brown Feb 11 '13 at 15:26
@MichaelBrown thanks for your help! but how can I find $g(q)$ using the first eq? – sunrise Feb 11 '13 at 15:42
@MichaelBrown Oh, fantastic! I got it! :D Can I follow these steps everytime I have to make an exercise like this? (If you would write an answer, I'll mark your answer as accepted answer!!) – sunrise Feb 11 '13 at 16:29

I) OP is given a problem of the form

$$\tag{1} \dot{q}~=~f(q,p), \qquad \dot{p}~=~g(q,p),$$

where $f$ and $g$ are two given smooth functions. OP is asked to derive the integrability condition for the eqs. (1) to be Hamilton's eqs.

$$\tag{2} \dot{q}~=~\frac{\partial H}{\partial p}, \qquad \dot{p}~=~-\frac{\partial H}{\partial q}.$$

OP correctly deduces that

$$\tag{3} f~=~\frac{\partial H}{\partial p}, \qquad g~=~-\frac{\partial H}{\partial q},$$

and that the integrability condition is the Maxwell-type relation

$$\tag{4} \frac{\partial f}{\partial q}+\frac{\partial g}{\partial p}~=~0.$$

Michael Brown in a comment then explains that if

$$\tag{5} F(q,p)~=~\int^{p}\!dp^{\prime}~f(q,p^{\prime})$$

is some antiderivative/primitive integral/indefinite integral of the given $f$ function, so that

$$\tag{6} \frac{\partial F}{\partial p}~=~f,$$

then eqs. (3a) and (6) imply that

$$\tag{7} \frac{\partial (H-F)}{\partial p}~=~0.$$

In other words, the difference $H-F$ cannot depend on the $p$ variable. It could be an arbitrary function $G(q)$ of the $q$ variable only. So the Hamiltonian is of the form

$$\tag{8} H(q,p)~=~F(q,p)+G(q).$$

Finally, one gets restrictions on the $G$ function by plugging eq. (8) into eq. (3b). This should answer OP's question (v4), and we are in principle done.

II) However, we cannot resist making the following general point about the existence of a Hamiltonian formulation. OP's title question is a bit academic if one a priori insists that the variables $q$ and $p$ should play the role of canonical variables. Why would one insist on that? The goal is, after all, just to get a Hamiltonian formulation, whatever it takes. So a more realistic question is the following more general problem.

Suppose that one is given a two-dimensional first-order problem $$\tag{9} \dot{x}~=~f(x,y), \qquad \dot{y}~=~g(x,y),$$ where $f$ and $g$ are two given smooth functions. Is eq. (9) a Hamiltonian system $$\tag{10} \dot{x}~=~\{x,H\}, \qquad \dot{y}~=~\{y,H\},$$ with a symplectic structure $\{\cdot,\cdot\}$ and Hamiltonian $H(x,y)$?

The answer is, perhaps surprisingly: Yes, always, at least locally.

Proof: In two dimensions, a Poisson bracket is completely specified by the fundamental Poisson bracket relations

$$\tag{11} \{x,y\} ~=~B(x,y)~=~-\{y,x\}, \qquad \{x,x\}~=~0~=~\{y,y\},$$

where $B$ is some function that doesn't take the value zero. [Exercise: Check that eqs. (11) automatically satisfy the Jacobi identity.] The Hamilton's eqs. (10) become

$$\tag{12} \dot{x}~=~B\frac{\partial H}{\partial y}, \qquad \dot{y}~=~-B\frac{\partial H}{\partial x}.$$

Next consider the one-form

$$\tag{13} \eta ~:=~ f{\rm d}y -g{\rm d}x,$$

which is possibly an inexact differential. However, it is known from the theory of PDE's, that there locally exists an integrating factor $\frac{1}{B}$, so that the one-form

$$\tag{14} \frac{1}{B}\eta~=~{\rm d}H$$

is locally an exact differential given by some function $H$. It is straightforward to check that one can use $B$ as the Poisson structure (11) and $H$ as the Hamiltonian.

Remark. The existence of a pair of canonical variables $q(x,y)$ and $p(x,y)$, with $\{q,p\}=1$, are, in turn, guaranteed locally by Darboux' Theorem.

-
Is this interesting result in a text book (e.g. Abraham and Marsden)? – Stephen Blake Feb 11 '13 at 21:55
@Stephen Blake: As far as I recall, I have not seen it in the literature, but the result must be old and well-known to experts. – Qmechanic Feb 11 '13 at 22:07
+1: Doubt this is at the OP's level but good answer nevertheless. – Michael Brown Feb 12 '13 at 1:11
+1 for being a great answer, but -1 for being an answer to a rather different question than the OP's one. IMHO it would be worth posting this as a new question, using the feature that lets you post an answer at the same time. I'd also like to know more about that "at least locally" caveat - what are the cases where it fails globally? – Nathaniel Feb 12 '13 at 1:51
@Nathaniel: Solutions to diff.eqs exist in general only locally. Example: Consider $f(q,p)=\frac{q}{q^2+p^2}$ and $g(q,p)=\frac{p}{q^2+p^2}$ in the domain $D=\mathbb{R}^2\backslash\{(0,0)\}.$ It is relatively straightforward to check that there doesn't exist a globally defined Hamiltonian $H$ on $D$ such that eq. (3) is satisfied. The best one can do is to put $H$ equal to a single-valued branch of ${\rm arg}(q+ip)$, which is not globally defined. – Qmechanic Feb 12 '13 at 16:58


text:
# Puzzle: “Yes colour of my hat is white.”

There are $n$ people in room each being put on hat from amongest at least $n$ white hats and $n-1$ black hats. They stand in a queue, so that everyone can see the colour of the hat of the person standing in front of him.

Starting from the back we ask the person in turn, "Do you know the what is the colour of your hat?" If the first $n-1$ person say no, prove that front person will say "Yes colour of my hat is white."

• A little clarification: "Each one can se the colour of the hat of the PERSON standing in front of him" or "Each one can se the colour of the hat of the PERSONS standing in front of him"? – Yiorgos S. Smyrlis Oct 30 '14 at 6:50
• If we assume that "Each one can see the colour of the hat of ALL the PERSONS standing in front of him", then there is an explanation. If instead we assume that "Each one can see the colour of the hat ONLY of the PERSON standing in front of him", then the last one can not know. Take for example the case $n=3$, where the 1st and 2nd guy would say I don't know, regardless of the colour of the hat of the guy in front of them. – Yiorgos S. Smyrlis Oct 30 '14 at 6:59
• I am still confused, if there are at least $n$ white hats in a room of $n$ people, how can there be a black hat? – IAmNoOne Oct 30 '14 at 7:02
• @Freddy, no I am asking all those questions because I don't understand the problem, that is I am trying to say there is something wrong with it. Unless I am completely reading this all wrong. – IAmNoOne Oct 30 '14 at 7:15
• @Freddy What book is this from? From the image you posted it seems that English is not the author's native language. Perhaps "person" was meant to be "persons". – bof Oct 30 '14 at 8:57

## Solution:

Let $$p(n)$$: If first $$(n-1)$$ people say no, the person in the first will say yes.

For $$n = 1$$ , there are no black hats$$(n-1=1-1=0)$$. Hence the first person will say “Yes colour of my hat is white.”

Suppose the statement is true for $$n=k$$.

Let $$n=k+1$$

See how the man standing in the front would think. Suppose my hatis black, then there are $$k$$ people with at least $$k$$ white hats and $$k-1$$ black hats.

By $$p(k)$$, since first $$(k-1)$$ person said no, the person behind me must say yes. "I know the colour of my hat is white"

If he says mo. So colour of my hat can not be black. Hence it is white.

So $$p(k)$$ is true

so, $$p(k)$$ is true $$\implies$$ $$p(k-1)$$ is true.

Hence by the principle of mathematical induction it is proved!

## Explanation:

IF $$n=2$$, there is 1 black hat and at least 2 white hats. If the last person sees a black cap is put on by the person in front on him, he would definitely say "yes colour of my hat is white" as there is only 1 black hat.

But if he not able to answer first person will logically thinks he has put white hat and person behind him might have out black or white hat.

• How does this work if $n=3$? Suppose #1 and #2 (from the front) have black hats and #3 has the white hat. We ask #3 first. He sees a black hat on #2, he can't see #1's hat, of course he doesn't know what color his own hat is. – bof Oct 30 '14 at 8:52
• It does not work for $n=3$! Think about @bof's comment! – Yiorgos S. Smyrlis Oct 30 '14 at 11:36
• @bof Yes you are right it doesn't work for that!! – Freddy Oct 30 '14 at 13:47

I'm supposing every person can see the color of all the hats in front of him.

If the last person in the queue says $no$, then every one hears his reponse and then knows that there is at least $1$ white hats on the head of the first $n-1$ persons. Because otherwise the last person can deduce his own hat is white.

Now for the second last person, if he sees no white hat in front of him, then he knows his own hat is white. But he says still $no$, which means there is at least a white hat in front of him. And his response is heard by everyone and everyone knows there is at least a white hat on the head of the first $n-2$ persons.

Similarly, if one person says $no$, this means there is at least a white hat in front of him and everyone knows that information after they hear the response.

So finally the first one knows his hat is white..

• If the first $n-1$ persons are all wearing black hats, how does that enable the last person to deduce his own hat is white, seeing as he can only see one hat, the hat of the person in front of him. – bof Oct 30 '14 at 9:00
• @bof I am not sure if it's possible in that case. I am supposing everyone can see all the hats in front of him. – Petite Etincelle Oct 30 '14 at 9:12

This is not an answer, as there is a serious problem in the formulation.

As I said in my comments, each of the persons has to be able to see the hats of all the persons in front of him/her. Not just the hat of the guy next to him/her.

Let me explain why with the current formulation, it does not work even for $n=3$.

The first one will say I don't know regardless of the colour of the hat of the second guy. So his answer DOES NOT provide any piece of information to the second and third guy. Similarly, the second guy will also answer no, regardless of what he sees on the head of the third guy, and this also does not provide any information to the third guy.

On the other hand, if the first could see the hats of the 2nd and 3rd guy, then by saying I don't know, the 2nd and 3rd guys obtain the information the the 1st guy does not see 2 black hats. So if the 2nd guy also says, I don't know, then the 3rd guy will know that his hat is not black, for if it were black, then the 2nd guy, knowing that the 1st does not see 2 black hat, his own hat would be white. This argument can be generalised using induction to $n$ white and $n-1$ black hats.


text:
# Need help with stoichiometry problem

I'm pretty new to chemistry and I've been stuck on it for hours.

Question: $\pu{10g}$ of the hydroxide of a metal on ignition gave $\pu{8g}$ of oxide. The equivalent weight of the metal is:
a) $\pu{136g}$
b) $\pu{40g}$
c) $\pu{56g}$
d) $\pu{28g}$

I used the law of equivalence but the answer I got was $\pu{3g}$. what am I doing wrong?

10/E=8/16;
E=20;
E=M(equivalent mass of metal)+16+1;
M=3

I found your numbers confusing, but I think the first equation you wrote is not correct. This is how I'd solve it:

Let's say we have $\mathrm{n}$ equivalents of metal in the sample, and let's call the equivalent weight of the metal $\mathrm{e}$. For the hydroxide sample, we have:

$n(e+17)=10$

where $\mathrm{e+17}$ is the molar mass of the hydroxide $\ce{MOH}$.

For the oxide, we have:

$n/2(2e+16)=8$

where $\mathrm{2e+16}$ is the molar mass of the oxide $\ce{M_2O}$. Note that $\mathrm{n}$ becomes $\mathrm{n/2}$ because of stoichiometry:

$\ce{2MOH->M2O + H2O}$

So you have a system of two equations with two unkowns ($\mathrm{n}$ and $\mathrm{e}$), which you can solve normally. For instance, if you divide the equations:

$\cfrac{n(e+17)}{n/2(2e+16)}=\cfrac{10}{8}$

$\cfrac{e+17}{e+8}=\cfrac{10}{8}$

$8e+136=10e+80$

$2e=56$

$e=28$

So the equivalent weight of the metal is 28g.

Makes sense?

Nothing wrong with Vic's answer. I'd solve it differently, but hopefully you are familiar enough with algebra to understand that there are various ways to correctly come up with the correct answer...
Here's how I did it: There is a loss of 2 grams of what we assume is water. Now since we know we started from M?(OH)? we assume the reaction was 2OH → H2O + O
meaning ~34 grams of OH would produce 18 g of water and 16 g of oxide oxygen. Since we know that ~2 grams were lost (assumed to be only water, and all of the water) then we know 2g of water must have come from (2/18)*34 grams of OH (2:18 as X:34), or 34/9 grams of OH. Since we started with 10 grams total, we started with 90/9 grams total and of that 34/9 is OH. Subtract to determine how much metal: (90-34)/9 = 56/9 grams of metal. So far, so good. But what is its oxidation state? Since the question is asking for equivalent weight, we need some way to pin down the equivalency. Well, for every 18 grams of water lost, the residue retained (we assume) 16 grams of oxide. So, 2:18 as X:16 or x= 16/9. So now, we have the whole enchilada: 90/9ths grams = 56/9 M + 16/9 O + 18/9 OH (as H2O - meaning this treats the OH lost during ignition as H2O rather than OH ) leaving us, after ignition with 56/9 M and 16/9 O. For each equivalent of O= there should be one equivalent of M. This means that since O has an equivalent weight of of 8 that 16/9 ÷ 8 = 2/9 Eq are present (after ignition) so that there must also be 2/9 equivalents of M. 56/9 grams ÷ 2/9 equivalents = 56/2 g/eq = 28 g/eq which is the eq. wt of the Metal. (A quick search of the periodic table indicates that Fe with an AtWt of 55.845 and assuming we're talking about Fe(OH)2 would produce 2.00 grams of water, theoretically. So, it checks out.)


text:
# Proof of Lévy's characerization of Brownian motion

There is a purely probability theoretical argument in the proof of Lévy's characterization of Brownian motion, which I do not completely understand. I think it is rather easy. Suppose we know $$E[e^{iu^{tr}(X_t-X_s)}|\mathcal{F}_s]=e^{-\frac{1}{2}|u|^2(t-s)}$$

for all $u\in\mathbb{R}^d$. From this it should follow, that $X_t-X_s$ is independent of $\mathcal{F}_s$ and normally distributed with mean $0$ and covariance matrix $(t-s)Id_{d\times d}$, hence the $X^k$ should be independent Brownian Motion ($^k$ denotes the k-th coordinate). My suggestion is to take expectation:

$$E[e^{iu^{tr}(X_t-X_s)}]=e^{-\frac{1}{2}|u|^2(t-s)}$$

Hence I know that $(X_t-X_s)$ has the right distribution. Furthermore, by the structure of the convariance matrix, I know $(X^i_t-X_s^i)(X^k_t-X^k_t)$ are uncorrelated for $k\not=i$. Why should the $X^k$ be independent. I have independence of the product of increments, how do I get independence for $X^k$? I guess, this uses, that every coordinate is a normal distributed r.v. and for normal distributed r.v. "uncorrelated implies independent". Even more, I do not see how independence of $\mathcal{F}_s$ should follow. So any help would be appreciated. Thanks in advance!

math

-
for normal distributed r.v. "uncorrelated implies independent" Hmmm... That depends very much on what you mean exactly by that. Note that there exists uncorrelated normal random variables that are not independent. – Did Jul 17 '12 at 13:20
@did: You're right, I should write jointly normal. – math Jul 17 '12 at 13:36

A very useful fact here is the following:

Lemma. Let $X,Y$ be random vectors, and consider the joint characteristic function $\phi(u,v) = E[e^{i u \cdot X + i v \cdot Y}]$. If we can factor $\phi$ as $\phi(u,v) = f(u) g(v)$, then $X,Y$ are independent.

Proof. Without loss of generality, assume $f(0) = g(0) = 1$. Then we see that $f(u) = \phi(u,0)$ is the chf of $X$, and likewise $g$ is the chf of $Y$. Thus $\phi$ is the joint chf of $(\tilde{X}, \tilde{Y})$ where $\tilde{X} \overset{d}{=} X$, $\tilde{Y} \overset{d}{=} Y$, and $\tilde{X}, \tilde{Y}$ are independent. Since the joint chf uniquely determines the joint distribution we have $(X,Y) \overset{d}{=} (\tilde{X}, \tilde{Y})$, which means $X,Y$ are independent.

Corollary. Let $X$ be a random vector, $\mathcal{G}$ a $\sigma$-field, and suppose the conditional chf $f(u) = E[e^{i u \cdot X} \mid \mathcal{G}]$ is deterministic. Then $X$ is independent of $\mathcal{G}$.

Proof. Let $Y$ be any $\mathcal{G}$-measurable random vector, with $g$ its chf. We compute the joint chf of $X,Y$: $$E[e^{i u \cdot X + iv \cdot Y}] = E[e^{i v \cdot Y} E[e^{i u \cdot X} \mid \mathcal{G}]] = E[e^{i v \cdot Y} f(u)] = g(v) f(u).$$ By the previous lemma, $X,Y$ are independent. $Y \in \mathcal{G}$ was arbitrary, so $X$ must be independent of $\mathcal{G}$.

Given what you know, this corollary tells us that $X_t - X_s$ is independent of $\mathcal{F}_s$.

-
Eldrege : Thanks for your answer! This is exactly what I was looking for. If you would add an argument why $X_t^k$ and $X_t^l$ are independent, I will accept your answer. However, I'm very thankful for your help! – math Jul 21 '12 at 8:40

The vector of increments are uncorrelated and the increments are multivariate normal and the covariance matrix for the increments is (t-s)I where I is a dxd identity matrix. So these coordinates are uncorrelated and normally distributed hence independent. Now if the increments from one coordinate are independent from the increments of the other by summing you will get that the coordinate sums are independent normal. summing the increments gives Xt$^k$ and Xt$^l$ for k not equal to l.

-
Thanks for your answer. Actually I do not see how this answer my question. As I wrote, I know that $(X^k_t-X^k_s)$ and $(X_t^l-X_s^l)$ are independent. Why is $X_t^k$ and $X_t^l$ independent? How do I get the independence of $\mathcal{F}_s$? – math Jul 17 '12 at 12:36
Sorry I misread. I think the answer is simple, just sum independent increments for one coordinate that are independent of the increments in the other coordinate and you get the answer. I will add it to my answer. – Michael Chernick Jul 17 '12 at 12:42
What do you mean by summing increments. Since $(X_t^k-X_s^t) +(X_t^l-X_s^l)\not= X_t^k$ or $X_t^l$. And again, how do I get independence of $\mathcal{F}_s$? Sorry, if I'm completely wrong. – math Jul 17 '12 at 12:50
Not obvious! Xt$^k$= (Xt$^k$-Xt-1$^k$)+(Xt-1$^k$ -Xt-2$^k$)+ ... and the same telescoping sum works for Xt$^l$. – Michael Chernick Jul 17 '12 at 13:13


text:
DEsubs problems with Mus musculus
0
0
Entering edit mode
Rtist • 0
@rtist-13256
Last seen 5.5 years ago

Hi everyone,

i used the DEsubs package to find subpathways related to a Mus Musculus RNA-Seq experiment. Using my differentially expressed genes, i get subpathways but when i use the "geneVisualization" function to view the topological measures concerning the genes, in the \$measures.topological object the rows names are all NA values instead of getting the entrezid/symbol, the same happens for the graph bars. I encounter this error when using the Mus musculus entrezids. Has anyone encountered this problem?

Thanks.

DEsubs • 588 views
0
Entering edit mode

After encountering a potential error, it would be helpful if you added the output of the function sessionInfo() to your question so we can more easily reproduce the problem.


text:
Timezone: »

Spotlight
Affine Invariant Analysis of Frank-Wolfe on Strongly Convex Sets
Thomas Kerdreux · Lewis Liu · Simon Lacoste-Julien · Damien Scieur

Tue Jul 20 07:40 PM -- 07:45 PM (PDT) @
It is known that the Frank-Wolfe (FW) algorithm, which is affine covariant, enjoys faster convergence rates than $\mathcal{O}\left(1/K\right)$ when the constraint set is strongly convex. However, these results rely on norm-dependent assumptions, usually incurring non-affine invariant bounds, in contradiction with FW's affine covariant property. In this work, we introduce new structural assumptions on the problem (such as the directional smoothness) and derive an affine invariant, norm-independent analysis of Frank-Wolfe. We show that our rates are better than any other known convergence rates of FW in this setting. Based on our analysis, we propose an affine invariant backtracking line-search. Interestingly, we show that typical backtracking line-searches using smoothness of the objective function present similar performances than its affine invariant counterpart, despite using affine dependent norms in the step size's computation.

#### Author Information

##### Simon Lacoste-Julien (Mila, University of Montreal & Samsung SAIL Montreal)

Simon Lacoste-Julien is an associate professor at Mila and DIRO from Université de Montréal, and Canada CIFAR AI Chair holder. He also heads part time the SAIT AI Lab Montreal from Samsung. His research interests are machine learning and applied math, with applications in related fields like computer vision and natural language processing. He obtained a B.Sc. in math., physics and computer science from McGill, a PhD in computer science from UC Berkeley and a post-doc from the University of Cambridge. He spent a few years as a research faculty at INRIA and École normale supérieure in Paris before coming back to his roots in Montreal in 2016 to answer the call from Yoshua Bengio in growing the Montreal AI ecosystem.


text:
Abstract

Let K be a knot or link in the 3-sphere. I will explain how one can count minimal surfaces in hyperbolic 4-space which have ideal boundary equal to K, and in this way obtain a link invariant. In other words the number of minimal surfaces doesn’t depend on the isotopy class of the link. These counts of minimal surfaces can be organised into a two-variable polynomial which is perhaps a known polynomial invariant of the link, such as HOMFLYPT. “Counting minimal surfaces” needs to be interpreted carefully here, similar to how Gromov-Witten invariants “count” J-holomorphic curves. Indeed I will explain how these minimal surface invariants can be seen as Gromov-Witten invariants for the twistor space of hyperbolic 4-space. Whilst Gromov-Witten theory suggests the overall strategy for defining the minimal surface link-invariant, there are significant differences in how to actually implement it. This is because the geometry of both hyperbolic space and its twistor space become singular at infinity. As a consequence, the PDEs involved (both the minimal surface equation and J-holomorphic curve equation) are degenerate rather than elliptic at the boundary. I will try and explain how to overcome these complications.

Details

Talk Number 22030106
Speaker Profile Joel Fine
Collection
Subject
Source Repository


text:
Earlier this year I launched my book on hacker news which resonated very positively with the hacker crowd.  This HN exposure landed me an  interview on the TechZing podcast  to discussed my textbook project. Even though it was an hour and a half long interview, there were a some things that we didn’t get to discuss. I want to take the moment now to write down my observations about the textbook business and the educational market.

This blog post is organized with the best stuff at the top so feel free to trail off at any point.

### Insights

1. Writing is tough, but writing down lecture notes after a lecture is easy.
2. Teaching students is gold. By interacting with your students 1-on-1 you get feedback on your explanations.
If you are lucky you will get a “Sorry, I didn’t get that”, which allows you to iterate.
3. People still appreciate the printed book. Some people are willing to pay good money for a PDF.

### Opportunities

Print-on-demand and eBook technology allow for everyone to publish and sell books. This is a revolution on a Gutenberg scale. One of the forefathers of the Internet/WWW, when asked about the motivation behind his inventions said he did it “so people will be able to earn a living from the fruits of their intellectual labour.”  We have now finally reached this moment where this idea is practical.  Could books be the missing monetization strategy for the Internet?

What have been traditionally two markets—the general audience and the educational market—are now becoming a single market of people who want to learn. Lord knows there are things to learn out there so there is an opportunity for knowledge products for people who want to learn. The key monetization routes will be through selling organized knowledge as textbooks, ebooks, or apps.

I used the term revolution above and I stand by this choice of wording because this is what we call it when a value chain collapses from six-plus levels to three levels. The value chain in the “book business” previously looked like this:

author
__editor
__copy-editor
__typesetter
__printer
__distributor[1..]
__book store
__client

With print-on-demand the new book business will look like this:

author -- printer -- shipping -- client
^^^^^^                           ^^^^^^

Let us call this “author centered” publishing. From now on, authors can expect to get up to 50% of the profits instead of 10% (which could be as low as 5% of the list price). Good times for authors. Incentive-giving-to-move-to-a-new-publisher times.

Even amazon looks like a dinosaur in this context:

author
__editor
__copy-editor
__typesetter
__printer
__amazon
__shipping
__client

Why do you need the warehouse to store all the books? Why not ship from the printer?

There is one element in the traditional publishing value chain that we must keep. Copy editing is actually very important because you really want someone to go through
your writing and fix mistakes in it. You can use your target audience (crowdsource copy-editing), but nothing beats professional services.

OK, so you want to see the future of publishing? Here it is:

 author -- (1) pub.srvc. -- (2) printer  -- shipping -- client
_ (3) booksite -- client

The opportunities are (1) for small publishing houses (copy editor + creative person for covers + latex guy) to really come-in and take over the entire market within a couple of years. You could also have larger publishers who focus on marketing the book to certain audiences etc.

Opportunity (2) is for new print-on-demand shoppes to come up (compete with lulu.com and lightning source). These giants have as their main advantage the established processes they have in place, but how difficult would it be to build an “Espresso Book Machine”-like system based on a quality BW laser printer (think buying toner in gallon tubes at costco 😉 and some automation. The competitive advantage of a small print shop would be that they offer pick up service (0\$shipping). Currently lulu charges you 6\$ for shipping to Canada (9\$for 2 books, 12\$ for three books, …, 3+3n.) Shipping within the states is \$5 which is better, but still not free. In particular for printing small books (100-200pp) it would not make sense to order from lulu. They would charge you 5\$ for the printing and another 6\$for the shipping. Your cost 11\$. If you go to a local print shoppe, they will charge you 7\$for printing. Same product, half price. The third opportunity is for high-level editorial services (think curation of content) which would collect book recommendations and let authors and readers interact. Ideally there should be independent “book blogs” for discovery of new content — not marketplaces. Something must be done about the current appstore monopoly. Every app you develop relying on Apple for your distribution is feeding the monster at 30%. Every web app you develop based on Google or FB apis could stop working tomorrow if the API is retired. Go get hosting somewhere and build your own website. Don’t depend on anyone. Okay sorry I got a little off the topic of textbooks. Let’s get back on topic. I was telling you guys about the book and stuff from the interview. One thing which we talked a lot about was the hacker news launch. ### The HN launch I told Jason how surprized I was when I got 30 000 visitors in one day and how I didn’t get up from my chair for one day. There were roughly 7000 people who clicked on one of the modals. Of these 300 people bought the book in print. By the evening of Jan 1st and into Jan 2nd there were also 100 PDFs purchased from gumroad. I still working out the numbers (conversion rates) and I don’t want to get too hyped up about them (ok ok, 7k –> 300 = 4.3%) because the HN audience is really VERY sympathetic to the product. I am not sure if everyone else on the internet will like it as much. (SIDENOTE: I am finding it hard to get the analytics I want for the book pageGA reports analytic en masse so I cannot see what individual visitors did when they came to the site. I have basic questions I need answers for and it seems like the current state of analytics is very unimpressive (relative to my expectations). Here is what I would like to know: 1. Which modal my visitors looked at before deciding to continue onto lulu.com/shop or gumroad? 2. Which of the 800 people who clicked through to lulu.com/shop are the 300 that actually ended up buying the book? 3. Which sections did they read (scroll to and stay for 4secs+)? 4. What “path” did each visitor follow through the modals? (subquestion: did anyone see the apg-get install mechanics? did anyone see the integral calculus modal? ) Are there solutions for these? I think the only way I can have end-to-end information is if I run the whole show. If I want to have information about converstions I must build my own shopping cart. Wait, we are on the Internet — I can just submit a feature request to lulu.com support and gumroad support. I am working on the full writeup of the launch experience here which will have more graphs and numbers. (/SIDENOTE) I got a lot of feedback from the discussion on hacker news. People really like the idea. The tech crowd of Hacker News is precisely the kind of crowd is interested in learning about advanced math and physics. Many programmers learn the about calculus in mechanics at University but never actually understood these subjects. This is way when the no bullshit guide to mass in physics the really wanted and the 29 dollars price range is definitely not an obstacle for them. Several people also asked for a PG 13 version cleaned up with out of cities in the references to park and alcohol. This is definitely something I will look into it because no told jokes need to be about these subjects. We can stick to the political stuff and the joke about the investment banker being dropped off a building. What is the goal of the book? The goal of the book and more generally of Minireference Co. is to teach. Teach students how to get rid of the exam stress when they’re doing their studies. If you know the material really well, then there is nothing tricky that the teacher can do on the final. Understanding trumps memorization any day of the week. A secondary goal is to teach math to adults, grown ups, so they can let go of their math complexes. There is no reason why a forty year old person should avoid conversations about math and feel uncomfortable when their teenage daughter or son asks them about the solutions to a quadratic equation. The third goal is to prevent the next generation of analytic reminded youth from going into the defence, pharmaceutical and finance sectors, which I consider to be detrimental to society. I grew up listening to Rage Against the Machine and I feel it is my duty to continue their work in educating the next generations about the system. By situating analytical knowledge in the context of the current world geopolitical situation, it is my hope that the next generation of Einsteins, Gates, Pages, and Zuckerbergs will make informed and moral choices. With knowledge comes responsibility, and I don’t want my students to think about the numbers without understanding what the numbers represent in the real world. ### Textbook market There are a couple of intrenched companies in the publishing world (the big five). Mainstream publishers in the educational market produce textbook that are so expensive, that we can talk about a textbook racket. The readers, subject to their teachers authority, are forced to buy specific textbooks, often at an exorbitant prices > \$100. Mainstream textbooks are also too long and full of fluff like full-page photos designed to pad the pages and impress the student with the “high endness” of the 1000-page publication.  Mainstream textbooks are the kind of product which is the signed by committee. They’re thick and boring.

On the other hand there are several positive things about textbooks.  Irrespective of the widened usage of electronic formats, the “book format” remains the primary medium of intellectual discourse, of which textbooks are a subset. Textbooks are old technology, but good technology. Textbook, as a mean for acquiring knowledge, are better than most educational resources produced for the web.  And it’s not just eBooks, print is here to stay because students don’t like the idea of ebooks replacing textbooks.  Having a PDF to go along with your printed textbook is definitely a feature, but not as a replacement.

The business model for Minireference Publishing Co. is quite simple: we sell math and science textbooks and PDFs. The specifics of the book “container” are not important. What is important and of value is that we offer an “information distillation” service: complicated science subjects are presented and explained in a concise coherent narrative, including all prerequisites. Instead of reading 100 wikipedia pages to learn about calculus in a month, students can read one chapter in the No BS guide and pick up the same material in a week.

Backstory

During the interview, I had a chance to give the full story about the genesis of the book. At 7min40sec in the interview, I say how I started from a collection of notes on advanced physics subjects and that at some point decided to make those notes into a book. Jason replies to this jokingly “Wow that is a big jump!” but I totally missed his joke and just kept on blabbing.

Pivot 1: TOO ADVANCED. There are not that many physicists. We need to go for something more mainstream. New product will be a mini-reference book of formulas for all of science.

Pivot 2: FORMULAS ARE NOT ENOUGH to learn. Let’s have the formulas, but add enough context and explanations to explain where the formulas come from and how they are used.

Once you have the idea… It took two years and 200 commits. It wasn’t high intensity work: I just wrote down lecture notes and my favourite explanations after teaching. During the summer of 2012, I worked intensely to tie together and organize all the material into a coherent story with a beginning (solving equations), a middle (use equations to predict the motion of objects in physics), and an end (learn where the equations of physics arise from calculus).

### Product

What is special about this book is the deed forms contains a complete dependency graph of topics. Each subject is explain along with all the prerequisite material.

Another thing special about the book is its conversational tone. The narration in the book switches from serious to joke mode and back to serious again, and is intended to keep the reader engaged.  Everyone needs a little brake after learning pages and pages of formulas…

### Technology used

During the interview, I didn’t get a chance to discuss the technology stack I used to generate the book. The book started as a bunch of text file in dokuwiki. I then used the dokutexit plugin to export the book as LaTeX.

Another important tool for the production of the book has been to use the text-to-speech tool in Mac OS X for proofreading. It allowed me to catch lots of mistakes and quickly.

I use lulu.com for print-on-demand and gumroad.com for the PDF distribution.

### Future

Some future directions for the development of the book are:

• Finish the linear algebra textbook
• Write Tome II on electricity and magnetism and vectors calculus
• Future plans: Write a book about probability and stats
• Future plans: Make a No BS guide to Python and JavaScript

Speaking of JavaScript I’m currently exploring the using khan-exercises framework so I could offer practice problems on the site.

The main challenges we face right now is marketing the book to a wide audience.

UPDATE: Since the publication of this post, the No Bullshit guide to math and physics has been improved and revised several times. Sales going Okay. Need more word of mouth


text:
# Bayesian Pythagorean Modeling – Part II

### Introduction

In Part I of this Bayesian modeling post, I introduced a Bayesian version of Bill James’ Pythagorean relationship. This model had two unknowns, the Pythagorean exponent k and the error standard deviation $\sigma$ and I described constructing a prior for (k, $\sigma$) that reflected one’s knowledge about the value of the power in James’ formula and how win/loss ratios can deviate from this formula. In this post, assuming we have a sampling model and a prior, I am going to discuss the mechanics of Bayesian learning about these parameters and predicting future response values.

Since one typically is interested in predicting wins instead of win/loss ratios, I am going to work with a slightly different version of the model where the number of team wins (in a 162-game season) follows a normal distribution where the mean is given by James’ formula, and $\sigma$ reflects the variation of the win totals about the mean.

For a prior, I will assume k is normal with mean 2 and standard deviation 0.5 and $\sigma$ is exponential with rate 1.

### Posterior

We now observe data, that is, the W and R/RA values for the 30 teams in the 2019 season, and by Bayes’ rule, we find the new or posterior probability distribution for (k, $\sigma$). The posterior density of (k, $\sigma$) is equal to (up to a proportionality constant) the product of the likelihood (the probability of the observed data viewed as a function of the parameters) and the prior. All types of inference are found by summarizing this bivariate probability distribution.

### Brute Force Calculation

A straightforward way to summarize the posterior is to find a grid of (k, $\sigma$) values that cover most of the probability. I have a R package LearnBayes that makes it easy to implement this brute-force method. One writes a function logpost2() that computes the logarithm of the posterior density of (k, $\sigma$). The arguments to this function are the vector of parameters theta and a data frame d that contains the data. Note that I’ve included both the likelihood and prior terms in this function.

logpost2 <- function(theta, d){
k <- theta[1]
sigma <- theta[2]
n_mean <- 162 * d$RR ^ k / (1 + d$RR ^ k)
sum(dnorm(d\$W, n_mean, sigma, log = TRUE)) +
dnorm(k, 2, 0.5, log = TRUE) +
dexp(sigma, 1, log = TRUE)
}

Next, by use of the gcontour() function, one finds a rectangle that covers the region where most of the probability falls. This function produces a contour plot where the contours are drawn at 10%, 1% and 0.1% of the largest posterior value and, by trial and error, I find a rectangle (specifically 1.6 < k < 2.3 and 2 < $\sigma$ < 6) that covers these three contour lines.

gcontour(logpost2, c(1.6, 2.3, 2, 6), d)

This contour graph is produced by computing the posterior density on a 50 by 50 grid. One way to summarize the posterior is to simulate a large number of values from the posterior computed on this grid and then summarize the simulated draws. I use the simcontour() function to do the simulation from this grid:

pts <- simcontour(logpost2, c(1.6, 2.3, 2, 6),
d, 5000)

Here I display 5000 simulated draws from the posterior on the contour plot.

If I am interested primarily in learning about the exponent value k, I collect those simulated values of k to perform inference. For example, here is a density estimate which represents the marginal posterior density of k. A 90% interval estimate for k (found from the simulated draws) is (1.81, 2.09).

### Simulation using Stan Software

Currently a popular and powerful way to perform Bayesian computations is to simulate from a Markov Chain that convergences in theory to the posterior distribution of interest. One particular type of simulation methodology is Hamiltonian MCMC sampling implemented by the Stan software. There are interfaces of Stan to other languages such as R or Python and the brms package provides a very attractive interface for fitting a large class of Bayesian models. I’ll illustrate using this package below.

First I specify the prior on (k, $\sigma$) by use of two applications of the prior() function.

prior1 <- c(prior(normal(2, 0.5), nlpar = "b1"),
prior(exponential(1), class = "sigma"))

Then I implement the Stan simulation by use of the brm() function in the brms package. Note that this function actually specifies this nonlinear model and the “family = gaussian” argument indicates that we are assuming normally distributed errors.

fit1 <- brm(bf(W ~ 0 +
162 * RR ^ b1 / (1 + RR ^ b1),
b1 ~ 1, nl = TRUE),
data = d, prior = prior1,
family = gaussian)

Below I show some output of this function. The right set of graphs show streams of simulated draws of the parameters k and $\sigma$ and the left set of graphs display density estimates of the simulated posterior draws of these parameters. One gets essentially the same estimates of the power parameter k as I got using the brute-force method. For example, the 90% interval estimate using Stan is (1.79, 2.12) which is very close to the interval (1.81, 2.09) using brute force. One advantage of the Stan software is that it can efficiently sample from very complicated Bayesian models with many parameters.

### Prediction of Wins

Actually, the objective here is not about learning about the parameters k and $\sigma$, but rather to predict the number of wins of a team who has a particular runs ratio.

We predict the number of wins by use of the (posterior) predictive distribution which can be simulated in a similar way that we simulated future data from the (prior) predictive distribution in Part I of my post. Specifically, we simulate a future number of wins by first simulating values of (k, $\sigma$) from the posterior distribution and then simulating a wins total from the normal sampling distribution using these simulated parameter values. Using the brms package this is done using the posterior_predict() function. The arguments are fit1 (the output of the posterior fitting) and a data frame containing the values of the runs ratio that we are interested in.

PP <- posterior_predict(fit1,
newdata = data.frame(
RR = seq(0.8, 1.2, by = 0.1)))

I use violin plots below to summarize the simulated number of wins from the predictive distributions for these five values of the runs ratio. For example, a team that scores the same number of runs as it allows (RR = 1) will likely win between 70 and 90 games in a 162-game season. The amount of variation in these win totals might be surprising — this tells us, that there is more to winning games than just having a good runs ratio.

### Summing Up

• All of the R code for this exercise is available on my Github gist site.
• In this study, we placed priors on the parameters and one general concern is the impact of these priors on the posterior analysis. This is easy to address by trying other priors and seeing if there is a change in the inferential summaries or predictions. If the predictions seem to depend on the choice of prior, then I’d think harder about the prior.
• When possible, it is good to check one’s work by trying different computational methods. We did this by showing both a brute-force method and a modern simulation approach — both methods gave very similar estimates at the parameter k and $\sigma$.
• The purpose of this two-part post was to illustrate Bayesian modeling for a small regression problem. But we can easily generalize this problem to a situation where there is a obvious grouping of the data, and one is interested in doing many regressions, one for each group. For example, suppose we are exploring this Pythagorean relationship for many seasons and we want to apply this regression model for each season. Or maybe we have data for different professional leagues, say minor league, MLB, Japanese professional baseball, etc. and we want to apply this model to each league. This motivates the consideration of Bayesian multilevel modeling (and fitting using Stan) which will be the subject for a future set of posts.


text:
# Probability and Expected value of $X_N$ where $N$ is also a random variable

Let $X_1, X_2....$ be independent exponential(1) distributed variables. Let $N=min[n: X_n>1]$ which I think is the random variable for the minimum number of RVs $X_i$ before getting a value greater than 1. The questions are:

Find $P(X_N>3|N=3)$

and

Find $E(X_N)$

For the first item, I interpreted it is find the probability that $X>3$ given that $X>1$ since this is what is implied by $N=3$ and the $X_i's$ are independent. Is this correct?

For the second question, I'm lost. I was thinking that $N\sim NB(1,e^{-1})$ where N is the trial in which the first success $(X_N>1)$, occurs.

Your answer for the first part is correct. As for the second, try to find the distribution of $X_N$,
\begin{align} \mathbb{P}(X_N > x) &= \sum\limits_{n=1}^{\infty}\mathbb{P}(X_N > x, N = n) \\ &= \begin{cases} \sum\limits_{n=1}^\infty(1-e^{-1})^{n-1}e^{-1} & 0 \leq x < 1\\ \sum\limits_{n=1}^\infty(1-e^{-1})^{n-1}e^{-x} & x > 1 \end{cases}\\ &= \begin{cases} 1 & 0 \leq x < 1\\ e^{-(x-1)} & x > 1 \end{cases}\end{align}
You can find the expectation from here either from direct computation, or noting that $X_N$ has a shifted exponential distribution, $X_N \sim 1 + Exp(1)$.
• Is a solution generalizing the procedure from the first question also correct? That is, $E(X_N) = E(X|N)$? I found that $Pr(X_N>x|N=n)=e^{-x+1}$ as well. – user164144 Aug 3 '17 at 23:07


text:
# Jazz minor scale

Jazz minor scale on A.
Jazz minor scale on A with notes related to G7 chord alterations.[1]
Minor major seventh chord on C.
i$_M^7$ in C harmonic or ascending melodic minor.[2]
A jazz minor scale over G7 resolving to C.[1]

The jazz minor scale is the ascending melodic minor scale used both ascending and descending. It may be produced from the major scale by flattening the third scale degree,[1] making it a synthetic scale, and features a dominant seventh on the fifth degree (V) like the harmonic minor scale.[3] Starting on A, 1 2 3 4 5 6 7 8:

A B C D E F G A

The scale may be considered to originate in the use of extensions beginning with the seventh in jazz and thus the necessity to, "chromatically raise the diatonic 7th to create a stable, tonic sound," rather than use a minor seventh chord, associated with ii, for tonic.[4]

The jazz minor scale contains all of the altered notes of the dominant seventh chord whose root is a semitone below the scale's tonic. "In other words to find the correct jazz minor scale for any dominant 7th chord simply use the scale whose tonic note is a half step higher than the root of the chord."[1] For example, the G7 chord and A jazz minor scale: the A scale contains the root, third, seventh, and the four most common alterations of G7. This scale may be used to resolve to C in the progression G7-C (over G7, which need not be notated G75599).[1]

It is used over a minor major seventh chord.[5] See: chord-scale system. The scale also easily allows diatonic chord progressions, for example:[5] |: C-Δ7 / A-75 | D-7 / G713 :|

a I−vi−ii−V progression.

Its modes also include Lydian 5, Lydian 7, Locrian 2, and the altered scale.


text:
### LaTeX to png

11 March 2008

Part of having a blog involving math is having the ability to easily convert like e^{\pi i} = -1 to . I had been using a wonderful tool over at math.b3co.com to do my scripted conversions (a PHP socket is a wonderful thing), but their backend dropped out one day and went who knows where.

The Internets are pretty short on tools to do conversion. Although there is a capable Perl script to solve the problem, those of us without console-capable servers are at a loss. Fortunately, there is a freely-available, fairly powerful tool available at ScienceSoft.at (credit where credit is due). Unfortunately, it's housed in a good deal of unnecessary filler — HTML formatting and the like — which make scripting a bit of a pain.

Enter a new layer of abstraction: LaTeX to png at 1.618034.com (with free hosting of the results). The script is accessible directly through the link above, but the key is that it readily accepts sockets. Pass ?xml to the page as a GET parameter, and then pass dpi=[int] and tex=[latex] through POST. The return is easily parseable, coming as

<?xml version="1.0"?>
<latexresult>
<lateximage location="_url_" source="sciencesoft.at" />
</latexresult>

It's no easier, technically, than socketing directly to the ScienceSoft.at script, but the output is nicer for sure. Now that I've got my own conversion scripts running on it, I'm only three (socketed) layers of abstraction from the actual software.

All included graphics are generated at LaTeX to png .


text:
The raw data behind the story "Dear Mona, Which State Has The Worst Drivers?" https://fivethirtyeight.com/features/which-state-has-the-worst-drivers/

bad_drivers

Format

A data frame with 51 rows representing the 50 states + D.C. and 8 variables:

state

State

num_drivers

Number of drivers involved in fatal collisions per billion miles

perc_speeding

Percentage of drivers involved in fatal collisions who were speeding

perc_alcohol

Percentage of drivers involved in fatal collisions who were alcohol-impaired

perc_not_distracted

Percentage of drivers involved in fatal collisions who were not distracted

perc_no_previous

Percentage of drivers involved in fatal collisions who had not been involved in any previous accidents

Car insurance premiums ($) losses Losses incurred by insurance companies for collisions per insured driver ($)


text:
Celestial age calculator

Our solar system has 8 planets, including earth. Our calendar has some very confusing concepts such as leap years, which I still don't fully understand. In fact, since where I live, we use a different solar calendar that is different from the Gregorian reforms of the Julian Western calendar, I think I'm born in March but I should be born in February! Anyways, I attempted to create a simple program that calculates any given age, subtracting the leap days of each four years, in any planet of our solar system except Pluto which I believe is not a planet. I'm not sure about it.

def calculate_days(age):
leap_days = 0 #holds number of leap days
leap_years_list = [i for i in range(age) if i % 4 == 0] #holds the essence of leap years

for j in leap_years_list:
if j % 4 == 0 or j % 400 == 0 and j % 100 != 0:
leap_days += 1 #if leap years are divisible by four and not divisible by a hundred, add to leap days

return (age * 365) - leap_days

def calculate_celestial_age(planet, age):
number_of_days = calculate_days(age) #calculate the days in age

assert str.islower(planet), "Planet name must be entered in lower case e.g. 'mercury'" #if planet name is in lowercase, give error

days_in_year = {"mercury": 88, "venus": 224, "earth": 365, "mars": 687, "jupiter": 4332, "saturn": 10759, "uranus": 30688,
"neptune": 60182} #days in each planet's year

if planet == "mercury":
return number_of_days / days_in_year["mercury"]
elif planet == "venus":
return number_of_days / days_in_year["venus"]
elif planet == "earth":
return number_of_days / days_in_year["earth"]
elif planet == "mars":
return number_of_days / days_in_year["mars"]
elif planet == "jupiter":
return number_of_days / days_in_year["jupiter"]
elif planet == "saturn":
return number_of_days / days_in_year["saturn"]
elif planet == "uranus":
return number_of_days / days_in_year["uranus"]
elif planet == "neptune":
return number_of_days / days_in_year["neptune"]
else:
raise Exception("Unknown Planet! Are you sure you've enter a planet?")

age = 23

planets = ["mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune"]

for planet in planets:
print("{0}: {1}".format(planet, calculate_celestial_age(planet, age)))

For my age, 23, I got these results:

mercury: 95.3409090909091

venus: 37.455357142857146

earth: 22.986301369863014

mars: 12.212518195050945

jupiter: 1.9367497691597415

saturn: 0.7798122502091273

uranus: 0.2733967674661105

neptune: 0.1394104549533083

According to this, my results are accurate.

1 Answer

Simplify the logic

It seems like:

if planet == "mercury":
return number_of_days / days_in_year["mercury"]
elif planet == "venus":
return number_of_days / days_in_year["venus"]
elif planet == "earth":
return number_of_days / days_in_year["earth"]
elif planet == "mars":
return number_of_days / days_in_year["mars"]
elif planet == "jupiter":
return number_of_days / days_in_year["jupiter"]
elif planet == "saturn":
return number_of_days / days_in_year["saturn"]
elif planet == "uranus":
return number_of_days / days_in_year["uranus"]
elif planet == "neptune":
return number_of_days / days_in_year["neptune"]

can be easily rewritten:

if planet in days_in_year:
return number_of_days / days_in_year[planet]
raise Exception("Unknown Planet! Are you sure you've enter a planet?")

Also, one could consider keeping it even more simple and use the fact that:

return number_of_days / days_in_year[planet]

will throw the relevant exception for an invalid value.

Do not repeat yourself

You can try to avoid duplicated values and have a single source of information. In your case, the list of planet is indirectly hardcoded twice :

days_in_year = {"mercury": 88, "venus": 224, "earth": 365, "mars": 687, "jupiter": 4332, "saturn": 10759, "uranus": 30688,
"neptune": 60182} #days in each planet's year

and

planets = ["mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune"]

Maybe you could define a constant like DAYS_IN_YEAR_PER_PLANET (corresponding to your actual days_in_year dictionnary) and use it where you are using the list of the planets (for planet in DAYS_IN_YEAR_PER_PLANET: for instance).

Do not perform more operations than required

number_of_days = calculate_days(age) is computed for every planet in the list. It would be better from a performance point of view to feed the function a number of days.

Useless list (or useless test)

You are creating a list with values divisible by 4. Then you iterate over it and check if the value is divisible by 4. It seems like a waste of effort. Let's get rid of the list creation. Code is based on the initial version of your code.

def calculate_days(age):
leap_days = 0 #holds number of leap days

for j in range(age):
if j % 4 == 0 and j % 100 != 0:
leap_days += 1 #if leap years are divisible by four and not divisible by a hundred, add to leap days

return (age * 365) - leap_days

Also, this can somehow be written by abusing the generator expression and the sum builtin:

def calculate_days(age):
leap_days = sum(1
for j in range(age)
if j % 4 == 0 and j % 100 != 0)
return (age * 365) - leap_days

Also, you could find mathematical expressions to compute the number of leap days in a more efficient way (constant time instead of linear time) but I'll keep this out of the review.

• How can I only use values, or only the keys, of a dictionary? – CodesInTheValley Jul 13 '16 at 15:25
• By default, it loops over keys. You have ways to iterate over (key, values) or over (values). More information here : stackoverflow.com/questions/3294889/… . – SylvainD Jul 13 '16 at 15:26
• @cat This comment is more relevant to OP's question than to my answer. – SylvainD Jul 13 '16 at 21:15
• I didn't notice that in the original code, now I see why it's an Exception and not a ValueError or something – cat Jul 13 '16 at 21:22


text:
Question

# 27 small spheres with radius 5cm are melted to form a new sphere. Find the radius of the new sphere.

Solution

## Given radius of small spheres = 5 cm ∴Volume=43πr3 volume of 27 small spheres = 27×43πr3=36πr3 Let R be the radius of big sphere ∴  Volume of 27  small sphers = Volume of big sphere ⇒36/πr3=43/πR3⇒36×34×r3=R3⇒R3=27×(5)3⇒R3=33×53⇒R=3×5=15cm

Suggest corrections


text:
# Methods for filling in your world - Political Entities

My world is, at a very high level, well populated. That being said, my focus has been on certain cities relevant to my story. These cities are detailed; they have government structures, leadership (people), armies/guards, cultural identity, racial make-up and more - essentially, they are completely fleshed-out.

Now, the surrounding world exists, cities are on the map, they have names and may be part of larger nation entities, but beyond that they are very hazy.

I frankly don't want to take the time to create an incredibly detailed back story, but I find that in my effort to set a grander international socio-political climate and conflict, I need to know how different entities would react to certain situations.

Question: Does anyone have a method for rapidly setting traits for cities and/or nations?

Traits I would like included in this process:

• Government type
• Racial tolerance (fantasy setting with elves dwarves humans etc)
• Culture
• Predisposition towards magic
• Economy type
• Military (standing/militia/guard only)

I am sure there are more traits that will come to mind but that list should be good to start with.

• Cities that are geographically (or politically, i.e. part of a nation) near one-another should be biased toward having a similar setup (bias yes, but not impossible for them to be very different)

Details of my world:

• Medieval technology
• Magic exists, but is an 'underground' practice and is generally frowned upon
• Races include Humans, Elves, Dwarves, Gnomes. No races are monolithic; the world is often tribal
• History is mixed on racial relations, sometimes humans and elves like each other . . . but there was that one World War that sunk a continent back in the day. . .
• Depends on how much you actually want to control these things. If you want the interactions between nations, and the ability for nations to co-exist right next door without being in constant war...then you're going to have to figure this out by hand, and it will be a bit more complex. If you are okay with allowing an RNG to make decisions for you, you can set Spreadsheets up to produce random results from a list. Or just make dice-rolling tables like a Tabletop DM might use. Sep 2, 2015 at 15:29
• Are you looking for a layout/template like this? : forgottenrealms.wikia.com/wiki/Thay Sep 2, 2015 at 15:32
• @guildsbounty that's why I am looking for a system that is random, but with bias. So of 12 cities in a nation maybe 2 don't quite look like the rest. This helps the history write itself too...maybe they were conquests once upon a time, leads to conflict, thats good! Sep 2, 2015 at 18:14
• @James yeah...I don't think a program to do that exists yet...or, at least, I have never found one. It's probably something that would have to be specially made for that exact purpose. Putting on my programmer hat for a minute, what you are asking for is definitely possible...but complicated both to program, and to configure for each use. Sep 2, 2015 at 19:25

# Government

I've generally viewed local government as a reflection of the government of the nation-state as a whole. For example, take medieval Europe. The feudal system allowed a caste of nobles who answered to the king to unilaterally rule over their lands and the people who lived in them. Major cities were the strongholds of the nobles; you could say that they were mayors with additional power, both in the cities and the lands around.

However, if you replaced the monarchy with a republic, then there would be a different system of government in the cities. Now the power is in the hands of the people, and they can rise up. They elect representatives who are against the nobility caste, and the nobles are overthrown, replaced by relatively impotent mayors or, more likely, councils made up of wealthy landowners (in this example medieval society). Alternatively, you could just chuck this system into place form the start, but that assumes a certain political evolution that somehow avoided a monarchy.

Your society is at a medieval technological level (by a coincidence; I wrote this part before seeing the edit), so it makes sense that a peasant/lord society will develop - a system of feudalism. The economic, political, and medieval power rests in the hands of the nobility, and so I would wager that you would have a stereotypical medieval political system. A larger monarchy might develop from warring kingdoms.

The one thing here that might change that is the fact that you have multiple races. If Tolkien is any indication of reality (and in this case, I think he is), this kind of one-case rulers will not gibe well with the different races. Each one will want to rule itself, probably because each race developed independently. This could make for an augmented nobility - more nobles representing different races - which eventually evolves into some sort of council, with nobles representing each race. The transition to a republic is already happening.

# Racial tolerance

I made the assumption above that the races evolved and developed independently of one another. I'll hold this assumption to remain true throughout the rest of the answer. There is nothing on Earth to back it up, but some logic should support it.

You mention a World War. This world is currently at a medieval technology level, so I'm currently imagining a disaster beyond all known proportions setting the world back in time technologically (and economically, culturally, etc.). That would involve massive devastation - hell, they sunk an entire continent! That type of thing is not easily forgiven. If I was to write a faux history book about that war, I would write one passage like this:

Sergeant Heysha would never forget the final mission. As the plane sank low over Valinshek, its engines screaming, the dirge mixed with the sound of thousands - no, millions upon millions upon millions - of anguished souls screaming out for mercy. The explosions were deafening, as the rest of the squadrons continued on with their runs. But Heysha's plane had been hit and hit hard, and it flew low over the edge of the once-peaceful forest, now scarred by fire and acid. The world was spinning - no that was the plane. Or was it? He looked back over his shoulder at Loujik, the land of the snow-elves, and saw a crack in the Earth open up. The screaming seemed to get louder and louder, and the ground rushed up to greet him, as Loujik seemed to disappear under the smoke and clouds and dust and fire.

The blackness swallowed him, and the pain, when he hit the ground, was as deafening as the screams.

That kind of thing - genocide on a massive scale, because destroying a continent will typically kill a lot of people - will not be forgiven easily. I find it hard to believe that there will be peace between the races for some time. Although your story may be set far enough in the future that the hatred has dissipated. A date for the war could help gauge how much still remains.

But races living together in cities? That seems rather tough.

# Culture

Culture is a tricky thing to define, and it is what always seems to stump me. It encompasses so much - so many years and so many people. I'll give it a go, though.

• Religion. This could go in a lot of different directions. I can see monotheism taking root, although there might be some bias in there because of its grip on the world today. The idea of a king bowing to a god and serving that god - and thereby his people, in an attempt to make the populace support him, and be even more subservient - is one that I always find tempting in a society like this.

There needs to be some religion, at the very least. The lives of most will be crappy, and they'll want to believe that there is something good in the future. You really need religion for that to happen.

• Art. Art might circle around religion and religious ideas (unless you take aniconism into account). In fact, I would call it a likely development path (although again, there is some bias).

• Music. Who doesn't like a good medieval tale? It might not be as silly as the tale of Sir Robin, but it might be story-centered. Story songs are, in general, my favorites in this type of society. They can be used to venerate kings and nobles, too, and their deeds.

# Magic

You say that magic is generally frowned upon. That's an interesting scenario because I would bet anything that even if, officially, magic should not be used, you can bet the farm that all the leaders will want to use it. Will it give them an advantage in battle? I would assume so. That means that they'll want it, and they'll want to use it better than anyone else. It will all be very hush-hush, though.

Who has the magic, though. Is it one of the species, members of all races? Who in particular gets it - all members of a race, or just some? These may play big roles in inter-race relations. If the elves have magic, then you can bet anything that some gnomes will want them on their side when fighting other gnomes.

That said, there's always the trope of people fearing magic and those who have it. 'Who's the weirdo with the wand?' 'I don't know, but he's a real creep. Don't go near him.' This could happen on an individual level or a race-to-race level.

This is even further complicated by the possibility that magic was used in the past. Was it used by Heysha's superiors to sink Loujik? If so, then the people who knew those who lived there (the snow-elves) will not want to associate with anyone who has this magic. After all, it killed most of (if not an entire) race!

I think this goes along pretty much with the government, but I suppose I can talk about the way the leader(s) behave(s). After all, in his heyday, Hitler behaved differently than present-day Fidel Castro, even though both had/have quite a lot of power.

In this feudal-ish society, I would expect that the rallying cry would be around the king, and it would be emphasized that people have a "duty" to help him, as he is their lord. It might focus on loyalty, and simply that. The peasants have negligible power, so it's not as if they need to be quelled or suppressed (yet!).

# Economy

I've so far stuck to the feudal system and the associated economic structure, and I see no reason to deviate from it now. We can stick with the peasants/nobles power structure, which comes down to the majority of people being fairly poor and farming or working in the fields for the few rich folk.

The major trade hubs will be cities (of course!), where merchants, artisans, and skilled tradespeople will make their homes. Inter-city trade will fall into the hands of the merchants, as most people will probably not go too far from their homes, being fairly powerless.

The nobles will want to protect themselves, so I anticipate a fair amount of technological development being devoted to the military (hey, that's just like today!). Better crossbows, guns, battering rams, and the like will be needed, and so there will be a thriving market for them. The tradespeople who can make them will gain some economic (and perhaps political) standing.

Whatever you choose, though, make sure that the cities are the trading hubs. There won't be much infrastructure outside of city-city trading routes, so the people will have to go to the cities in order to get goods.

# Military

Who has the power in this scenario? The king and the nobles. Therefore, they also hold control of the military. On a large scale, things can get complicated. On a small scale, they're easier to predict.

Each city will likely have:

• A guard positioned around the perimeter. I'm envisioning castle-like fortifications, which means guards on the ground and higher up on the walls. These guards will search any suspicions persons from the outside.
• A pseudo-police force that reports to the noble(s) in charge. They will arrest people that break any laws in place, and possibly go for political enemies, as well.
• A small-scale militia, with the noble(s) at its head. This will be responsible for attacking other cities and defending the city when it is under attack. They may also be deployed to the surrounding lands, but it is also likely that there will be a separate force for that.

The noble(s) will be the ultimate commanders of all of these groups.

• For reference they killed each other...both sides were pawns, blah blah blah, BAM! continent sinks. On a positive note the war ended, on a negative note it is because everyone died... Sep 2, 2015 at 15:45
• "Major cities were the strongholds of the nobles" - not necessarily. There are counterexamples where the nobles ruled the countryside (castles and the villages belonging to the castles) but the towns were ruled by guilds, and the lords had almost no authority there.
– vsz
Sep 2, 2015 at 16:47
• @vsz True, but I would argue that this model is more likely. Power will be consolidated where there are more people. Sep 2, 2015 at 16:50
• @HDE226868 having both can make things interesting as well, different nations work in different ways Sep 3, 2015 at 15:48
• @James That's a good point; I hadn't considered mixing it up like that. Sep 3, 2015 at 15:49

## Setting traits for cities and towns

General things to keep in mind:

• Humans love to clump together with people similar to themselves. Other races may have different preferences but any kind of social creature will want to be near other of its kind.
• The rate of change is greater in larger cities. This applies to technology, government, fashion, etc.
• You will need to figure out the culture of your main cities and the culture of your smallest town. All of the surrounding cities will fall somewhere along that spectrum with minor variations. (It is, of course, overly simplistic to say there is only one small-town culture. Adapt as needed.)
• Working out the interdependencies between traits before you start the below process will help eliminate rework considerably. For example, race, language and culture are all tightly integrated with each other. Predisposition towards magic and leadership style are less tightly correlated.
• The distribution of each trait isn't necessarily linear between the two destinations. Exponential distributions are also possible.
• Some traits can be modeled as continuous, such as preferences for/against magic, racial tolerance or culture. Some traits, such as government type, are better modeled as stepwise functions.

## General Process

1. Layout a map of your country/nation. The more geographically accurate it is, the better.
2. Start with your capital city then draw lines out to the various major cities and towns. Based on the speed of travel/communication, draw tick marks indicating a day or weeks travel. The farther away from a major city a small town becomes the more backward it becomes.
3. Make an ordered list of the traits that you want to map. The first item on the list should be the most basic trait, such as culture because many other traits depend on the culture of a place. Group similar traits together such as government and military because these will depend strong on each other.
4. Take a trait you want to map then walk each line drawn in step 2. These lines assume a distribution from Big-City characteristic to Little-Town characteristic. Distributions aren't always continuous such as language use at a border. One side may speak fluent Elvish while the other may speak Human Standard with very little overlap between the two.
5. Repeat step 3 for each trait you want to map. After a few iterations, you should have a pretty detailed map without too much work.
• Humans love to clump together with people similar to themselves... if they have a good supply and sewer system Sep 2, 2015 at 19:55

HDE and Green have provided ways to create detailed societies, so I'll present the simple method.

1. Create a list of traits.

Write down all the major traits you want to define for a given society. You've provided a number of examples already.

2. For each trait, create a list of possibilities.

For example, under Government Type, you can put Representative Democracy, Dictatorship, Constitutional Monarchy, etc. Number each entry from 1 to N.

For weighting, instead of using 1 to N, assign ranges to each entry. For example: Representative Democracy (01-09), Dictatorship (10-35), Constitutional Monarchy (36-40), etc. The greater the range, the higher the bias will be towards that entry.

3. Use a randomizer.

From here, you can just roll dice, use a random number generator, or any other nondeterministic method. If you're so inclined (and proficient in software development), you could write a small program to do this for you, which would greatly speed up the process in the future.

4. Tweak.

If you don't like the results from Step 3, feel free to alter them slightly or simply perform Step 3 again. At this point, you can also adjust results for adjacent regions so they have some traits in alignment.

• This is similar to what I would recommend, though if you could add a way to manage the bias I want better (without manual intervention each time) that would be awesome. Sep 2, 2015 at 15:44
• @James Well, if you want to eliminate bias...you just need a smarter program to handle the RNG. Something where you can weight certain traits, and have it track the results of prior 'saved' generated locations, and be able to tell the program which locations are adjacent. You could set for positive or negative weighting (where certain traits are likely to be similar in nearby locations...and others are likely to be different in nearby locations). And, if you wanted variety, you could have it negatively weight traits the more often they were randomly selected... Sep 2, 2015 at 15:51
• If you want something that has no weighting, but spits out random results...have a look here: chaoticshiny.com/civgen.php Sep 2, 2015 at 15:51
• @James See my edit for a weighted determination. Sep 2, 2015 at 16:12