Posts tagged with mappings

hi-res

## How I Got to Gobbledegook

A perlmonk asked for a “custom random number generator”. This is a non-maths person’s word for a probability distribution.

It was a slightly unusual case, but not hard. After I’d finished several easy steps, though, the final formula looked like it had been scrivened by a wizard:

$\large \dpi{200} \bg_white f(\mathtt{num},x,y) = \begin{cases} e ^ { x \over \; 1 \, + \, y \, \cdot \, (1 - \mathtt{num}) \; }, \ \mathtt{num} \leq 0 \\ 1 - e^{\, x \, \cdot \, (1 + \mathtt{num} \cdot y) }, \ \mathtt{num} > 0 \end{cases}$

Of course, I’m not a wizard; I’m not even an acolyte. The steps I took just involved (1) a certain viewpoint on probability distributions, and (2) puzzles that an 11-year-old could solve.

This is how formulas in textbooks get to look so daunting.

 —skippable interlude—

I guess I figured this out years ago, when I first saw the Black-Scholes-Merton formula in business school.

The BSM is just a continuous-time limit of “Did the stock go up or down in the last 5 minutes?” But the BSM is dressed up with such frightening language that it seems much more inscrutable than “A tree generated from two alternatives which are repeated”.

For example in the Wikipedia article on BSM the subheads include: Greeks (), elliptic PDE’s, derivation, interpretation, criticism, extensions of the model, notation, assumptions, references. It’s 24 pagedowns long. From this pretence of sophistication follows:

I’ve seen it in biology, chemistry, and physics textbooks as well. A convoluted formula encodes the results of a simple model. Because of scientism the students commit it to memory as well as more derived results. Hopefully they come to find that it was not so complicated only a professors could understand it.

But I don’t think that’s common knowledge, so formulæ retain an impenetrable mysticism and the rituals of uncomprehending repetition continue.

 —back to the main idea—

It needn’t be so enigmatic. I can demonstrate that by showing how the ugly beast above looks if you break it into steps. It’s simpler as several lines of code than as one formula.

Client Request

Anonymous Monk wanted a probability distribution like this:

with the median at x and equal probability masses between [x/y,x] and [x, x•y]

Drawrings

I’m going to take a Gaussian and map the endpoints to what the client wants.

The result will tend to the centre a “normal” amount of the time and yet will be squashed onto the domain the client wants.

Match up the Endpoints

I know that exp maps (−∞,0] onto (0,1]

To follow that, I need a transformation that will match (0,1) to (x/y, x). So 1 ⟼ x and 0 ⟼ x/y.

0 ⟼ x and 1 ⟼ xy

as 6 lines of Code

my $random = ...; #Gaussians, however you fry them up if ($random <= 0) {
$random = exp($random); #map (−∞,0) → (0,1)
$random = ; #map (0,1) → (x, x•y) } else { #map (0, +∞) → (0,1)$random = 1 − exp(−$random); #map (0, +∞) → (0,1) ... which is the same problem as above except backwards$random =     ; #map (0,1) → (x/y, x)


Lessons:

1. use paper first, write code second
2. draw a picture
3. if necessary, break it into a simpler picture
4. compose the answers to the parts
5. code the pieces in separate lines

The equation at the top does decompose into the sequence of steps I just outlined. But even though it looks simple as a sequence of steps, the one-line formula is scary.

[Alexander] Grothendieck expanded our … conception of geometry … by noticing that a geometric object 𝑿 can be … understood in terms of … maps from other objects into 𝑿.
Kevin Lin (@sqrtnegative1)

(Source: quora.com)

Here’s a physically intuitive reason that rotations ↺

(which seem circular) are in fact linear maps.

If you have two independent wheels that can only roll straight forward and straight back, it is possible to turn the luggage. By doing both linear maps at once (which is what a matrix
$\large \dpi{300} \bg_white \begin{pmatrix} a \rightsquigarrow a & | & a \rightsquigarrow b & | & a \rightsquigarrow c \\ \hline b \rightsquigarrow a & | & b \rightsquigarrow b & | & b \rightsquigarrow c \\ \hline c \rightsquigarrow a & | & c \rightsquigarrow b & | & c \rightsquigarrow c \end{pmatrix}$

or Lie action does) and opposite each other, two straights ↓↑ make a twist ↺.

Or if you could get a car | luggage | segway with split (= independent = disconnected) axles

to roll the right wheel(s) independently and opposite to the left wheel(s)

, then you would spin around in place.

Discontinuities  in the 2-D level sets and how they might look one dimension higher.

(Draw)

(Defile)

(Couloir)

(Gully)

(Gulch)

(Gorge)

(Coulee)

(Moraine)

(Channel)

(Canal)

(Source: Wikipedia)

hi-res

## What is group theory?

Further along my claim that what separates mathematicians from everyone else is:

and that learning 20th-century geometry might expand your imagination beyond the usual impoverished shapes of taxonomies.



Here are some calisthenics you can do with a pen and paper that I hope give you a feel for what a (mathematical) group is. (It’s a shame that “group”, “set”, “class”, “category”, “bundle” all have distinct meanings within mathematics. Another part of the language barrier.)

Think of “a group” this way. A group catalogues the relationships between “verbs”.

That is: think of a function as a “verb” and the thing it operates on as a “noun”. One of the tricks of abstraction is that these can be interchanged. Maybe what that might mean will already come clear from this example.



Starting with a pentagon, which I’ll just represent with five numbers for the points. (So: whatever works here might work on other “circles of five”—or "decks of 52"—or … something else you come up with!) That will be the one “thing” or “noun” and in the group exploration you’ll see that the “structure of the verbs” is more interesting than whatever they’re acting on. (This is why in group theory the name of the object is usually omitted and people just list the operations/verbs.)

In John Baez’s week62 you can read about reflection groups. I picked two “axes” in my pentagon ⬟ arbitrarily. If you’re writing along you can draw a different -gon or different axes. Reflection is going to mean interchanging numbers across the axis (“mirror”).

It’s the same as reflecting the Mona Lisa except you don’t have to re paint the portrait every time. The same 2-dimensional plane can be indexed by the numbers more easily than by the whole image. (Unless you’re following along with computer tools and you’ve chosen “the square” as your shape. Then transforming Mona is probably more interesting.)

Without my saying so it’s probably obvious that reflecting twice would bring you back to the start. Flip Mona upside-down, flip the pentagon ⬟ along a, then repeat.

If you wanted to give “starting point of noun" a verb-name you could just say 1•noun.

What that establishes, formulaically, is that ƒ(ƒ(X))=X (where X is Mona or ⬟). Where ƒ is “flip”. We’ve also established that ƒ=ƒ⁻¹. Trivial observation, maybe-not-trivial in formula form! After all, suppose you had some science problem and it included a long sequence of ƒ(g(ƒ(ƒ(ƒ(h(g(X))))))) type stuff. You could make it shorter (and maybe the resulting formula or computation easier) if you could cancel ƒƒ’s like that.

That works for either of my pentagon ⬟ reflections a(⬟) or b(⬟).

• a(a(⬟))=⬟ and
• b(b(⬟))=⬟.



What group theory is going to talk about is how the two verbs interact. What happens when I do a(a(b(a(b(⬟))))) ? Well I can already simplify it by reducing any trains of a∘a∘a∘a's or b∘b∘b's.

Above are the first few results of a∘b∘a[⬟]. (NB: “The first” operation is on the right since the thing it’s acting on only appears all the way to the right. So in group theory we have to read right-to-left ←.) I’ll write a bit more text for those who want to continue the chain on their own to give you time to look away. You could also try doing b∘a∘b[⬟] where I did a∘b∘a[⬟] (read right to left! ←).

Just like it’s “sort of amazing” in some sense that

1. •••—•••—•••—••• (four groups of three…um, regular meaning of “group”!) is the same as ••••—••••—•••• (three groups of four)…and that not only in this specific case but we could make a “law” out of it

So is it also a bit amazing that maybe these reflection laws will be order-invariant in some sense as well.

That may seem like less big of a deal if you think “Everything in maths is commutative and symmetrical”—but it’s not! And most things in life are not commutative or symmetrical. Try to drink your milk and then pour it into the glass or don your underwear after your pants.

It’s also not so obvious (if nobody had told you the answer first and you just had to figure it out yourself) that b∘a∘b∘a∘b∘a∘b∘a∘b∘a[⬟] = ⬟.



Another fairly easy shape to explore its groups is the square. (And what goes for the square, goes for the plane 𝔸²—or for 1-dimensional complex numbers ℂ.)

That’s the end of what a group is. Next: looking ahead to put them in context.



All of these activities amount to exploring the building blocks of a particular group.

But someone (Arthur Cayley) has also come up with a good way to look at the entire structure of the verbs.

Which is ultimately where this theory wants to go: to help us compare & contrast verb-structures. (Look up “group homomorphism”.) Or to notice that two natural phenomena exhibit the same verb-structure.

You can download a free program called Group Explorer to look at various Cayley diagrams.

In an upcoming post called The Shape of Logic, the Logic of Shape I’ll talk about the relationship between groups and manifolds.

Where I’ll ultimately want to go with this is to call groups a “periodic table of elements” for logic. That may not be exact but it’s a gist. Given that semigroups, groups, Lie groups, and other assumption-swapped variations on the group concept usually turn out to be “Factorable” into simple components (Jordan-Hölder, Krohn-Rhodes, etc.)—and assuming that the Universe somehow builds itself out of primitives sufficiently determined or governed by mathematics—or at the least, that normal people can learn this periodic table and expand their imagination with powers of 20th century geometry.

## Automorphisms

We want to take theories and turn them over and over in our hands, turn the pants inside out and look at the sewing; hold them upside down; see things from every angle; and sometimes, to quotient or equivalence-class over some property to either consider a subset of cases for which a conclusion can be drawn (e.g., “all fair economic transactions” (non-exploitive?) or “all supply-demand curveses such that how much you get paid is in proportion to how much you contributed” (how to define it? vary the S or the D and get a local proportionality of PS:TS? how to vary them?)

Consider abstractly a set like {a, b, c, d}. 4! ways to rearrange the letters. Since sets are unordered we could call it as well the quotient of all rearangements of quadruples of once-and-yes-used letters (b,d,c,a). /p>

Descartes’ concept of a mapping is “to assign” (although it’s not specified who is doing the assigning; just some categorical/universal ellipsis of agency) members of one set to members of another set.

• For example the Hash Map of programming.
{
'_why' => 'famous programmer',
'North Dakota' => 'cold place',
... }
• Or to round up ⌈num⌉: not injective because many decimals are written onto the same integer.

• Or to “multiply by zero” i.e. “erase” or “throw everything away”:

In this sense a bijection from the same domain to itself is simply a different—but equivalent—way of looking at the same thing. I could rename A=1,B=2,C=3,D=4 or rename A='Elsa',B='Baobab',C=√5,D=Hypathia and end with the same conclusion or “same structure”. For example. But beyond renamings we are also interested in different ways of fitting the puzzle pieces together. The green triangle of the wooden block puzzle could fit in three rotations (or is it six rotations? or infinity right-or-left-rotations?) into the same hole.

By considering all such mappings, dividing them up, focussing on the easier classes; classifying the types at all; finding (or imposing) order|pattern on what seems too chaotic or hard to predict (viz, economics) more clarity or at least less stupidity might be found.

The hope isn’t completely without support either: Quine explained what is a number with an equivalence class of sets; Tymoczko described the space of musical chords with a quotient of a manifold; PDE’s (read: practical engineering application) solved or better geometrically understood with bijections; Gauss added 1+2+3+...+99+100 in two easy steps rather than ninety-nine with a bijection; ….



It’s hard for me to speak to why we want groups and what they are both at once. Today I felt more capable of writing what they are.

So this is the concept of sameness, let’s discuss just linear planes (or, hyperplanes) and countable sets of individual things.

Leave it up to you or for me later, to enumerate the things from life or the physical world that “look like” these pure mathematical things, and are therefore amenable by metaphor and application of proved results, to the group theory.

But just as one motivating example: it doesn’t matter whether I call my coordinates in the mechanical world of physics (x,y,z) or (y,x,z). This is just a renaming or bijection from {1,2,3} onto itself.

Even more, I could orient the axis any way that I want. As long as the three are mutually perpendicular each to the other, the origin can be anywhere (invariance under an affine mapping — we can equivalence-class those together) and the rotation of the 3-D system can be anything. Stand in front of the class as the teacher, upside down, oriented so that one of the dimensions helpfully disappears as you fly straight forward (or two dimensions disappear as you run straight forward on a flat road). Which is an observation taken for granted by my 8th grade physics teacher. But in the language of group theory means we can equivalence-class over the special linear group of 3-by-3 matrices that leave volume the same. Any rotation in 3-D

Sameness-preserving Groups partition into:

• permutation groups, or rearrangements of countable things, and
• linear groups, or “trivial” “unimportant” “invariant” changes to continua (such as rescaling—if we added a “0” to the end of all your currency nothing would change)
• conjunctions of smaller groups

The linear groups—get ready for it—can all be represented as matrices! This is why matrices are considered mathematically “important”. Because we have already conceived this huge logical primitive that (in part) explains the Universe (groups) — or at least allows us to quotient away large classes of phenomena — and it’s reducible to something that’s completely understood! Namely, matrices with entries coming from corpora (fields).

So if you can classify (bonus if human beings can understand the classification in intuitive ways) all the qualitatively different types of Matrices,

then you not only know where your engineering numerical computation is going, but you have understood something fundamental about the logical primitives of the Universe!

Aaaaaand, matrices can be computed on this fantastic invention called a computer!



unf

## An Ugly Discontinuity II

Here’s another example of what mathematicians mean by an “ugly discontinuity”.

The Torus is the Cartesian product of circles ◯×◯. I.e. an abstract geometry in which concrete angular measurement pairs (or triples or quadruples or quintuples or …) are realised.

The Sphere is … not that.

It’s nontrivial to recognise that ◯×◯≠sphere. For example the people who wrote the Starfox battle mode drew the screen as a sphere but programmed the battle mode on a torus.

By the Hairy Ball Theorem we know that spheres are different to independent pairs of circles. Specifically: one circle “vanishes” at the top and bottom of the other, to make a sphere. Changing your latitude coordinate at the North Pole  leaves you in the same place. In other words “two” collapses to “one” at the poles which also implies that, for consistency, latitude needs to be close to collapse around 89°N—not at all like ◯×◯. where the two capstans spin freely independent of one another.

(This is half of the “joke” … or, “prank”, or “not-funny joke” in my twitter location. I designate myself at (−90,45) so you can imagine a person spinning around uselessly as they try to “walk in a circle” on the South Pole. OK … it’s only slightly funny even to me.)

This is like how globes can represent the Earth much better than maps on a flat sheet of paper. Since it’s impossible to map R² onto S², flat maps can never be perfect. (The fact that the difference is merely a point—that is R² does map onto S²\{0}—is a distraction from how distorted real maps get. Look how different Greenland looks from the North versus the European view

Furthermore the torus can’t be deformed into a sphere, and it’s difficult for mathematicians to see the relationships between high-dimensional and low-dimensional spheres. (And this has something to do with the story of what Grigory Perelman achieved in solving that Clay Prize.)

The savvy way of talking about this is to say that the sphere has ugly symmetries. How can I say that when the Sphere is a Platonically perfect elementary shape?! The Sphere is so perfect that mass in outer space likes to form itself into that most balanced of balanced shapes.

Basically because when you hold the globe with two fingers and your friend spins it, the antipodes where your two fingers are holding it don’t move. (Yes, neighbourhoods around them move—but "points" in the infinitely-deep-down-continuum-set-of-measure-zero sense are singularities (erm, singularities in the 1/z sense, not in the “black hole” sense).)

Tomorrow: a post on a statistical application of the humble circle.

(Source: )

## ∄ inverse

• I cheated on you. ∄ way to restore the original pure trust of our early relationship.
• The broken glass. Even with glue we couldn’t put it back to be the same original glass.
• I got old. ∄ potion to restore my lost youth.
• Adam & Eve ate from the tree of the knowledge of good & evil. They could not unlearn what they learned.
• “Be … careful what you put in that head because you will never, ever get it out.” ― Thomas Cardinal Wolsey
• We polluted the lake with our sewage runoff. The algal blooms choked off the fish. ∄ way to restore it.
• Phase change. And the phase boundary can only be traversed one direction (or the backwards direction costs vastly more energy). The marble rolls off the table, the leg poisoned by gangrene. The father dies at war. The unkind words can’t be unsaid.

#semigroups

## Derivative ≠ Slope

Saying derivative is “slope” is a nice pedant’s lie, like the Bohr atom

which misses out on a deeper and more interesting later viewpoint:



The “slope” viewpoint—and what underlies it: the “charts” or “plots” view of functions as ƒ(x)–vs–x—like training wheels, eventually need to come off. The “slope” metaphor fails

• for pushforwards,
• on surfaces,

• on curves γ that double back on themselves

• my vignettes about integrals,
• and, in my opinion, it’s harder to “see” derivatives or calculus in a statistical or business application, if you think of “derivative = slope”. Since you’re presented with reams of numbers rather than pictures of ƒ(x)–vs–x, where is the “slope” there?

"Really" it’s all about diff’s. Derivatives are differences (just zoomed in…this is what lim ∆x↓0 was for) and that viewpoint works, I think, everywhere.

I half-heartedly tried making these drawings in R with the barcode package but they came out ugly. Even uglier than my handwriting—so now enjoy the treat of my ugly handwriting.



Step back to Descartes definition of a function. It’s an association between two sets.

And the language we use sounds “backwards” to that of English. If I say “associate a temperature number to every point over the USA”

then that should be written as a function ƒ: surface → temp.,

(or we could say ƒ: ℝ²→ℝ with ℝ²=(lat,long) )

The \to arrow and the "maps to" phrasing are backwards of the way we speak.

• "Assign a temperature to the surface" —versus— "Map each surface point to a temperature element from the set of possible temperatures”.

{elf, book, Kraken, 4^π^e} … no, I’m not sure where that came from either. But I think we can agree that such a set is unstructured.

Great. I drew above a set “without other structure" as the source (domain) and a branched, partially ordered weirdy thing as the target (codomain). Now it’s possible with some work to come up with a calculus like the infinitesimal one on ℝ→ℝ functions that’s taught to many 19-year-olds, but that takes more work. But for right now my point is to make that look ridiculous and impossible. Newton’s calculus is something we do only with a specific kind of Cartesian mapping: where both the from and the to have Euclidean concepts of straight-line-ness and distance has the usual meaning from maths class. In other words the Newtonian derivative applies only to smooth mappings from ℝ to ℝ.



Let’s stop there and think about examples of mappings.

(Not from the real world—I’ll do another post on examples of functions from the real world. For now just accept that numbers describe the world and let’s consider abstractly some mappings that associate, not arbitrarily but in a describable pattern, some numbers to other numbers.)

(I didn’t have a calculator at the time but the circle values for [1,2,3,4,5,6,7] are [57°,114°,172°,229°,286°,344°,401°=41°].)

I want to contrast the “map upwards” pictures to both the Cartesian pictures for structure-less sets

and to the normal graphical picture of a “chart” or “plot”.

Notice what’s obscured and what’s emphasised in each of the picture types. The plots certainly look better—but we lose the Cartesian sense that the “vertical” axis is no more vertical than is the horizontal. Both ℝ’s in ƒ: ℝ→ℝ are just the same as the other.

And if I want to compose mappings? As in the parabola picture above (first the square function, then an affine recentering). I can only show the end result of g∘ƒ rather than the intermediate result.

Whereas I could line up a long vertical of successive transformations (like one might do in Excel except that would be column-wise to the right) and see the results of each “input-output program”.

(Además, I have a languishing draft post called “How I Got to Gobbledegook” which shows how much simpler a sequence of transforms can be rather than “a forbidding formula from a textbook”.)

Another weakness of the “charts” approach is that whereas "Stay the same" command ought to be the simplest one (it’s a null command), it gets mapped to the 45˚ line:

Here’s the familiar parabola / x² plot “my way”: with the numbers written out so as to equalise the target space and the source space.



Now the “new” tool is in hand let’s go back to the calculus. Now I’m going to say "derivative=pulse" and that’s the main point of this essay.

Considering both the source ℝ→ and the target →ℝ on the same footing, I’ll call the length of the arrows the “mapping strength”. In a convex mapping like square the diffs are going to increase as you go to the right.

OK now in the middle of the piece, here is the main point I want to make about derivatives and calculus and how looking at numbers written on the paper rather than plots makes understanding a push forward possible. And, in my opinion, since in business the gigantic databases of numbers are commoner than charts making themselves, and in life we just experience stimuli rather than someone making a chart to explain it to us, this perspective is the more practical one.

I’m deliberately alliding the concepts of diff as

• difference
• R's diff function
• differential (as in differential calculus or as in linear approximation)
because they’re all related.
In my example of an open set around Los Angeles, a surface diff could be you measure the temperature on your rooftop in Los Feliz, and then measure the temperature down the block. Or across the city. Or, if you want to be infinitesimal and truly calculus-ish about it, the difference between the temperature of one fraction of an atom in your room and its nearby neighbour. (How could that be coherent? There are ways, but let’s just stick with the cross-city differential and pretend you could zoom in for more detail if you liked.)


Linear

I’m still not quite done with the “my style of pictures” because there’s another insight you can get from writing these mappings as a bar code rather than as a “chart”. Indeed, this is exactly what a rug plot does when it shows histograms.

Here are some strip plots = rug plots = carpet plots = barcode plots of nonlinear functions for comparison.

The main conclusion of calculus is that nonlinear functions can be approximated by linear functions. The approximation only works “locally” at small scales, but still if you’re engineering the screws holding a plane together, it’s nice to know that you can just use a multiple (linear function) rather than some complicated nonlineary thingie to estimate how much the screws are going to shake and come loose.

For me, at least, way too many years of solving y=mx+b obscured the fact that linear functions are just multiples. You take the space and stretch or shrink it by a constant multiple. Like converting a currency: take pesos, divide by 8, get dollars. The multiple doesn’t change if you have 10,000 pesos or 10,000,000 pesos, it’s still the same conversion rate.

So in a neighborhood or locality a linear approximation is enough. That means that a collection of linear functions can approximate a nonlinear one to arbitrary precision.

That means we can use computers!



Square

I can’t use the example of self times self so many times without exploring the concept a bit. Squares to me seem so limited and boring. No squizzles, no funky shapes, just boring chalkboard and rulers.

But that’s probably too judgmental.

After all there’s something self-referential and almost recursive about repeated applications of the square function. And it serves as the basis for Euclidean distance (and standard deviation formula) via the Pythagorean theorem.

How those two are connected is a mystery I still haven’t wrapped my head around. But a cool connection I have come to understand is that between:

• a variety of inverse square laws in Nature
• a curve that is equidistant from a point and a line
• and the area of a rectangle which has both sides equal.

I guess first of all one has to appreciate that “parabola” shouldn’t necessarily have anything to do with x•x. Hopefully that’s become more obvious if you read the sections above where I point out that the target ℝ isn’t any more “vertical” than is the source ℝ.

The inverse-square laws show up everywhere because our universe is 3-dimensional. The surface of a 3-dimensional ball (like an expanding wave of gravitons, or an expanding wave of photons, or an expanding wave of sound waves) is 2-dimensional, which means that whatever “force” or “energy” is “painted on” the surface, will drop off as the square rate (surface area) when the radius increases at a constant rate. Oh. Thanks, Universe, for being 3-dimensional.

What’s most amazing about the parabola—gravity connection is that it’s a metaphor that spans across both space and time. The curvature that looks like a-plane-figure-equidistant-to-a-line-and-a-point is curving in time.