Mobile payments | 移动支付

This weekend’s financial math class is all about payments, in particular, mobile payments and mobile wallet💰.

Mobile wallet 移动钱包 are digital forms of wallet that people carry (or used to carry) in their pockets.  As we do not tend to carry large amounts of money in wallets, mobile wallets are convenient for small payments (as opposed to payments in larger businesses).

📳 They hold digital information about payments including credit and/or debit card, bank account, pre-paid card, virtual currency information, coupons and loyalty membership, and wallet holder identifications.📟

A mobile wallet is a software application (app) 💻that does the following:

  • Secure enrollment of the holder (application download, identification)
  • Securely store user information such as phone number, email address, and mailing address

The flow chart below summarizes the history of technology and events that evolve over the last eighty years.

copyright (C) Magic Math Mandarin

In China and many places around the world 🌎, mobile payment is accounting for most of the retail payments.   So you should know about how it works.  Next class we will talk about the math that goes into making mobile payment secure.

Learning Swift | 学习Swift

This weekend we started our first lesson on Swift. Swift is the language used by Apple across its products.

The class first tried using XCode, which is Apple’s IDE for Swift. But not every child is familiar with the Mac. So we switched to a learn Swift phone app, which worked well. But the class really love Swift Playground.  It is like Scratch to them.  The difference is that: we are going to make an app in two months using Swift.

The kids enjoyed programming a lot!  They didn’t want to stop.

The only minor issue is that it only works on iPads.

Credit and debt in the world | 信贷和债务 xìn dài hé zhài wù

This weekend’s financial math class started big: we looked at all the credit (money lend out as loans) or debt (money borrowed) from around the world.🌎🌏🌍

At any given moment, there are hundreds of trillions of debt or credit. You can “have a look” at All of the World’s Money and Markets in One Visualization from Visual Capitalist.  The information was from 2017, but you get the sense.

Debt (or credit) can be categorized in 4 groups: government, household💳, financial sector and non-financial companies.💰💶💴💷💵💸

We looked at the United States government debt in previous classes.   You can check the numbers from the Treasury Department.  The link is easy to remember too: treasurydirect.gov/NP/debt/current

You can get the numbers of other countries from IMF (International Monetary Fund), the World Bank, and some other organizations.

A company called Visual Capitalist summed up the government debts from all the countries, the number is $63 Trillion!😲🤑

This means that the US government debt is one third of the world’s grand total government debt.🗽

World Government Debt -Visual Capitalist

Ipython Shell Keyboard shortcuts 键盘快捷键 (Kuàijié jiàn)

In this past weekend’s coding class we practice keyboard ⌨ shortcuts in the interactive Python shell (Ipython).

Since most of the students are learning typing ⌨, practicing these keyboard shortcuts actually help them learn typing by reinforcing memory of where the keys are.

The keyboard shortcuts allows you to minimize finger movements on the keyboard, which means you don’t even have to lift your hand ✋ for the “Backspace”, ‘Home’, ‘End’ or arrow keys (most of the time).    Spend 15 minutes per day practicing these.  Pretty soon, you will be a fast coder.

🚕Navigation

keystroke Action
Ctrl-a Move cursor to the beginning of the line
Ctrl-e Move cursor to the end of the line
Ctrl-b or the left arrow key Move cursor back one character
Ctrl-f or the right arrow key Move cursor forward one character

👦Text Entry

Keystroke Action
Backspace key Delete previous character in line
Ctrl-d Delete next character in line
Ctrl-k Cut text from cursor to end of line
Ctrl-u Cut text from beginning of line to cursor
Ctrl-y Yank (i.e. paste) text that was previously cut
Ctrl-t Transpose (i.e., switch) previous two characters

🐞Command History

Keystroke Action
Ctrl-p (or the up arrow key) Access previous command in history
Ctrl-n (or the down arrow key) Access next command in history
Ctrl-r Reverse-search through command history

🐳Miscellaneous

Keystroke Action
Ctrl-l Clear terminal screen
Ctrl-c Interrupt current Python command
Ctrl-d Exit IPython session

The shortcuts are referenced from  Python Data Science Handbook.   As its author Jake Vanderplas says, these shortcuts are not inherent in Ipython shell itself, but are based on GNU Readline library.

Wealth distribution | 财富分配 💲

We went onto a journey of wealth discovery in this weekend’s math class.  We played with real world data from the Federal Reserve .

We spent the first five minutes just looking quietly at the chart below, and tried to understand its meaning.  Hint: read legends and labels.

Magic Math Mandarin

The area chart shows the time series of total wealth of 4 buckets of US population.

The buckets are defined as 1st percentile, 90th – 99th percentile, 50th – 90th percentile, and the bottom 50% percentile of population by wealth.   In other words, if all the people in the US are ranked by wealth, the top 1%, and the top 90% to 99%, …, and the last 50%.

Source: Federal Reserve

The remainder of the class is discussion on what the chart means.

Kudos to Emily.  She was quick to point out that the red area of the chart is as thin as a line, and that’s all the wealth of the bottom 50% of Americans.

While the rest of the people are having more and more wealth overtime, the bottom 50% seem to have less and less, relative to the rest.

So is the world fair place?  No.

Some questions for the class to think about:

  1. How to make the world more fair?
  2.  Can the world be more fair?
  3.  Should the world be more fair?
  4.  What does fair mean?

Use snippets to code faster | snippet 加速编程

Today’s weekend programming lesson we covered how to save code snippets in a code editor, such as Sublime Test 3 (ST) and Visual Studio Code (code).

🙂 You can save these chunks of code so next time you wouldn’t have to type it again.

Until NeuralLink or other developments that can help us bypass typing all together, we want to find ways to save ourselves time from typing code.   Using snippet is a must for children, who may not be great at typing.   Here is how to do it in Sublime Test 3 (ST) and Visual Studio Code (code).

😎Sublime Test:
Tools – > Developer -> New Snippet.

😎VS Code:
Shift + Control + p

😎 Shift + Control + F: to search for a string in your folder (perhaps the name of the snippet you saved).

💡Write the snippet that can be used by the code editor:

Snippets are json files. Use this ➡ web app, or some packages, or write json if you prefer to put the code into the json format.

Explaining .json snippet in VS Code:

  • The first set of “” encloses the name of the snippet (call it anything you like).
  • Prefix defines a prefix used in the IntelliSense drop down. For example, if you have a snippet for plotting, you may want to prefix it with “plot”.
  • body is the snippet content.
  • Note that: $1, $2 for tab stops
  • Description is the description.  When you start typing the prefix of a snippet, its description will come up.

By the way, to quickly see what are the keyboard shortcuts are available in VS Code:

Ctrl + Shift + p

Digital currency | 数字货币

Today in class we talked about money and how they are transacted.

Two acronyms we introduced are “DC” and “EP”, meaning Digital Currency and Electronic Payment.

An important piece of recent financial news that you might have missed is that the Chinese central bank (央行) has issued its own digital currency, saying that its design is similar to Facebook’s proposed cryptocurrency Libra.

❗Digital currency is a big deal.

It not only affects how people go about their daily lives, but also world politics.

For example, we know that the United States sanctions certain countries by blocking them from the banking system.

❓ But what if these countries and the rest of the world start to use digital currency as the world currency instead of relying on the US dollar?

That would be really bad for the US, unless we become the leader in this space and catch up where we have fallen behind.

ChineseCentralBankDigitalCurrenyDesgin

For the young, it is time to learn how DC and EP work.  

Decision trees | 决策树 jué cè shù

Today, we focused our class on decision tree. Decision tree is a way to organize data.   You can look at it this way: you ask a bunch of questions and make a bunch of decisions, and organize data based on these decisions.

For example, if our data consists of colors and shapes of 3 pieces of fruits. We have 1 yellow apple, 1 red apple and a yellow banana. We have two features: shape and color.

By organizing our data, we can identify types of fruit. We go through our data on shape and color one by one. If we first organize our data by color, we know that will incorrectly group the yellow apple with the yellow banana. But if we first organize our data by shape, that will right away group apples and banana separately. So we organize this data by shape, and then by color (if we want to make a distinction between yellow apple and red apple).
Magic Math Mandarin
The way to organize data may be (highly likely) different for another dataset of fruits. But you get the point: we organize data to best group things. In each step of the way, our data gets more organized. The “energy distribution” has become lower entropy.

That was a classification tree model.

When we have lots of decision trees for different random parts of a larger data, we have the so-called “random forest” 随机森林 model, originated by Leo Breiman.

We showed in class how to code a decision tree from scratch.  Here is a shorter version using Python sklearn library.

 

Entropy | 熵 shāng

Nothing is lost, nothing is created, everything is transformed.
― Antoine Lavoisier (August 1743 – 8 May 1794)

Unlike before, we started the class today with a quote. This is because it is really difficult to talk about entropy, and we made many analogies (such as water flows from high to low, a mirror broken never, or almost never, returns to whole again) to bring our attention to how things work in daily life that we have taken for granted.

Some theory/hypothesis says that the universe started with Big Bang, a state with very low entropy. There are many states of high entropy than low entropy (imagine 10…000 to 1). So we will have to cycle through lots of high entropy states before it is low again. Well, we only have barely touched the topic. Whereas our true goal is to talk about the so-called decision tree model, which we will cover tomorrow.

To help you remember the word “entropy” and its meaning (as if we knew!), “en” comes from “energy”.  “tropy” means “transfom”, and comes from Latin.

Entropy is a measure of the number of possible ways energy can be distributed in a system.

By the way, Lavoisier 拉瓦锡 was a great chemist.

Tycho Brahe and Johannes Kepler | 第谷·布拉赫 和 约翰尼斯·开普勒

In today’s class we deviated from our normal computer work and went in further on one of the stories told by Terence Tao in the “Cosmic Distance Ladder” video.  This particular story was about Tycho Brahe and Johannes Kepler.

Statue of Johannes Kepler (left) and Tycho Brahe (right) in Prague

It was a very important story of data and analysis.

Tycho Brahe and Johannes Kepler had totally disparate backgrounds and temperaments.

In spite of this, Tycho’s painstaking and detailed observational data of the planet Mars, combined with Kepler’s mathematical genius, allowed Kepler to derive the three laws of planetary motion. Both Tycho Kepler’s 3 Laws of Planetary Motion and Kepler made significant contributions to the change in the prevailing world view of a geocentric universe. It was the beginning of a systematic study that transformed Medieval thinking – alchemy became chemistry and astrology led to astronomy.

https://chandra.harvard.edu/edu/formal/icecore/The_Astronomers_Tycho_Brahe_and_Johannes_Kepler.pdf

Link for those students who can read in Chinese:
https://baike.baidu.com/item/约翰尼斯·开普勒/973574?fromtitle=%E5%BC%80%E6%99%AE%E5%8B%92&fromid=158768