Author Archives: ChefCouscous
Kotlin for both JVM & iOS
“Deep Learning” Online Book
Mind over Matter : Bruce Lipton
Key Points:
1. The Foundation of Science has changed since Newtonian Era, except Biology / Medicine and Psychology which don’t keep up:
Math => Fractal Math
Newton Physics (Matter)=> Quantum Physics (Energy)
(Organic) Chemistry => Electro-Chemistry
Energy = Field = 气 Chi / Qi
3. Environment -> Mind -> Perception -> Genetic Control
4. Consciousness (5%), Subconscious-ness (95%)
Examples:
- Driving car: inexperienced driver (consciousness), experienced driver (subconscious).
- Dating (conscious behavior)
Note: The successful Deeplearning AI is using the concept of Perception called “Perceptrons” by analysing the Environmental (BIG DATA) pattern with the help of Mathematics (Calculus : Gradient Descent, Statistics : Bayesian Probability, Algebraic Topology, etc).
Canadian mathematician Langlands wins Abel Prize
Choosing a Programming Language
Which Countries Produce Best Programmers
https://blog.hackerrank.com/which-country-would-win-in-the-programming-olympics/
The result is surprising … China, Russia, Poland are the top 3 countries based on the tests, not the usual expected countries such as USA, India, UK.
Reason: Mathematics ! China, Russia and Poland are strong in Advanced Math education in university. Functional Programming requires the Advanced Math eg. Category Theory.
Prime Number Theorems Conjectures Explained
1. Twin Primes Conjecture : there are infinitely many pairs of Twin Primes among the infinitely many prime numbers.
Note: 2013 Zhang YiTang proved the gap between the twin primes is no more than 70,000,000 [Terence Tao’s Polymath Project using Zhang’s method to further narrow the gap to 246 ]
3. Palindromic Primes (eg.11, 101, 16561)
https://www.sciencealert.com/prime-number-theorems-conjectures-explained
Crash course in Category Theory
Key Point:
Haskell & any FP compiler don’t check the Category Theory proof if your codes (eg. fmap) follow Functor’s Laws (eg. Preserve structure, identity) or Monad’s Laws !
Android Architecture Simplified with Kotlin
I hate Android Architecture since it is based on OO Java, Kotlin is FP cousin of Java, hopefully it could simplify the Android Architecture by getting rid of the complex OO architecture. Here Antonio attempts to simplify it with more terse Kotlin codes, albeit still in the OO architecture spirit.
Goodbye OO, Welcome FP
OO = Object-Oriented, eg. Smalltalk, C++, Java
FP = Functional Programming, aka “Mathematical” Programming Language eg. Lisp, Haskell, Scala (hybrid OO+FP), Kotlin (hybrid OO+FP).
Three “weaknesses” (also “strengths”) of OO :
1. Inheritance
2. Polymorphism
3. Encapsulation
The Best Job: Mathematician
The above survey was 2009 USA Job Market.
By 2018, Number 1 Job is AI / Data Scientist in USA / China / Europe high-tech market, which still needs Mathematics. eg.
- Linear Algebra (Matrix)
- Calculus (eg. Gradient descent, …)
- Bayesian Statistics (Probability),
- Algebraic Topology (eg. Homological Algebra, etc),
- Abstract Algebra (eg. Category Theory, etc…)
- etc.
French Math “Coniques” : ellipses, paraboles, hyperboles.
French Math is unique in treating these 3 conic curves: (ellipse, parabola, hyperbola), always starts from the first principle – a la the Cartesian Spirit “I think therefore I am” (我思故我在).
“Catersian” Analytical Geometry was co-invented by two 17CE French mathematicians René Déscartes and Pierre de Fermat.
Note: The “elliptic curve” is a powerful geometry tool used in Number Theory (proved the 350-year-old Fermat’s Last Theorem in 1994 by Andrew Wiles), also in the most advanced Encryption algorithm.
Why Math is so Sexy?
Cédric Villani (Field Medal 2010) the French mathematician becomes a deputé (equivalent to Member of Parliament) in President Emmanuel Macron’s new party “En Marche” consisting of 90% non politicians.
His new revolution in French Primary School Math Education is introducing “Singapore Math” : the 1960s Chinese Secondary School One Math (算术 Arithmetic) modified by the ex-Nantah (南大, now Nanyang Technological University) Prof Lee Peng Yee (李秉彝) with the Polya Problem Solving Method aided by visual Model diagrams.
France excels in Abstract (aka New / Modern / Bourbaki) Math but poor in Applied Math, while Asian countries (China, Singapore, Korea, Japan etc) are opposite. This demonstrates clearly in the Asian 15-year-old students scoring Top PISA Math Tests & Math Olympiad Championships (even in the USA teams), while the French young Mathematicians (< 40 years old) take 1/3 of the world’s Field Medals – “the Nobel Prize of Math”.
It is ideal to combine the Asian (applied) Math pedagogy for Primary school (from 7 to 13 years old) math and the French (abstract) Math (eg. Set, Group, Ring, Field, Vector Space, epsilon-delta Analysis…) in high-school math (from 15 to 18 years old).
The wise Cédric Villani is just doing this Ideal Combination of “East and West” for French Primary School Math Education .
Note: In the video (12:12 mins) Villani described his “Eureka discovery” inspiration at 4 am in Princeton Institute of Advanced Math. The same experience found by many mathematicians eg. Poincaré, Zhang Yitang, etc. Read Villani’s book where he called this “Strange Head Voice” (definitely not hallucination!!) experience as “The direct phone call from God “.
数学范畴化 Categorification
https://www.zhihu.com/question/31823394/answer/53592663?from=timeline
Key Points:
- Category and Functor are above the underlying algebraic structures (Set, Group, Ring, Vector Spaces, etc), study the relations between these structures.
- Early 19 CE mathematicians before “Category Theory” already knew there is 1:1 mapping between the Field Extension and Galois Group.
- Treat Structures and Relation between them (Functors) on equal footing.
Kotlin: Co-Variance, Contra-Variance, Invariance, Immutability
Kotlin is a functional programming (FP) language which has the Category concept of co-Variance, contra-Variance. Java is object-oriented not FP, it has only Invariance.
https://dzone.com/articles/variance-immutability-and-strictness
Note:
Covariance and contravariance are terms that refer to the ability to use a less derived (less specific = CoVariance eg. Apple instead of Fruit) or more derived type (more specific = ContraVariance, eg. Gala instead of Apple) than originally specified.
Generic type parameters support covariance and contravariance to provide greater flexibility in assigning and using generic types.
-
Invariance
Means that you can use only the type originally specified; so an invariant generic type parameter is neither covariant nor contravariant. (Java is always invariance.)
The Twins in Mobile World: Swift vs Kotlin
Kotlin+FP = Kategory
Tail Recursion in Kotlin:
The Cost of Kotlin:
“Gang of Four” Design Pattern with Kotlin
Free MIT AI DeepLearning Online Book
FP Style: Collection Pipeline
Higher Order Components
Functional Programming in Javascript:
https://medium.freecodecamp.org/higher-order-components-the-ultimate-guide-b453a68bb851
Learning Google AI
英国留学生带你回忆被数学支配的恐惧
这位中国留英数学专业的小伙子有很好的口才: 数学之美, 他的数学遗憾。
华威大学(The University of Warwick),famous for mathematics in UK.
Key Points:
Einstein用 Riemann Geometry 数学救了Newton 物理。
中国数学的没落: 自从明朝科举废除数学考试
3位大师救近代中国数学: 华罗庚, 陈省身, 苏步青
数学光明的未来: AI, Big Data, Cloud Computing
天才的崎岖道路: “扫地僧”张益唐
时代的”指数” exponential快脚步, 不要追风, 要一以贯之 : Prof. Andrew Wiles proved 350-year-old “Fermat’s Last Theorem” (FLT).
[纠正]: Andrew Wiles 超过40岁, 没赶上Fields Medal, 只得个”奖励”。他看到椭圆(Ellipse)气球, 得到突破 FLT “工具”的灵感 – “Elliptic Curve” 。
数学是什么: 爱情, 艺术, 音乐, 科技
The “Prime Number” of Group: “Simple Group”
Group :
Simple Group :
Monster Group: its “discoverer” Simon Norton is an eccentric Cambridge Trinity College Math genius (same class year as Singapore PM Lee Hsien Loong).
Learn Kotlin sans Java
Kotlin is Object-Oriented Java + Functional Programming.
Much as we hate Java, Kotlin can’t run away from the Java “ghost” especially in Android development using the Java API and OO design patterns.
This tutorial, however, teaches you Kotlin “sans Java“, a great news for novices without Java knowledge.
I like this Kotlin teaching approach for 2 reasons:
- No need to struggle with Java /Android OO architecture until later stage;
- No need to be intimated by the complicated “Android Studio” editor.
https://hackernoon.com/how-to-write-your-first-program-in-kotlin-8554cb526158
Google new O/S Fuchsia – Modular Lego
Kotlin Android Template Examples Repository
Reform in French Baccalaureat
Current Baccalaureat Drawback:
- Study too many subjects,
- High Drop out
New Reform:
- Specialised on 4 major subjects – include compulsory French Literature (penultimate year before Bac) & Philosophy.
- ala British A-level on 4 Advanced Subjects (eg. For Science stream: 1. Math, 2.Physics, 3.Chemistry /& Biology, 4.Economics) + 1 “Ordinary” Subject (English General Papers) + Project (Social / current affairs)
Programmer Dictionary
[16 Parts]
Part 1.
Delegation Pattern preferred over Inheritance : Why ?
eg. Rectangle (a, b) / Square(a, a)
- Inheritance: Square is a special case of Rectangle (b = a).
- Delegation: Square gets Rectangle to perform “Area” task …
https://blog.kotlin-academy.com/programmer-dictionary-delegation-vs-composition-3025d9e8ae3d
Tuppers Self Referential Equation draws itself
That is one of the many such typical British Math tricks, which we liked to play in Secondary school Math games or Math Olympiad Competitions. The Abstract-thinking French Mathematicians are not interested in it, saying it is not “rigorous”.
Android KTX extension library for shorter Android code in Kotlin
Android Police: Android KTX is an extension library for writing shorter and cleaner Android code in Kotlin. http://google.com/newsstand/s/CBIw1K7t0Dc
Google launches Android KTX preview, a set of Kotlin extensions for developers
Category Theory in Life
Category Theory can be approved from 2 directions: 1) Pure Math, 2) IT Functional Programming (FP) .
Dr. Eugenia Cheng doesn’t know 2), she comes from 1).
The second video (below) approaches Category Theory from 2): Scala – FP language.
CUSTOM ANNOTATIONS in Java
Quora: Functional Programming / Side Effect / Monads
《The Master Algorithm》
Main Point: One single “Master Algorithm” for all kinds of knowledge from chess to Go to Medicine to Stocks to …, only differ in ‘Data’ context, but the same One thinking “Mind”.
《The Master Algorithm》must have these 5 features:
- Evolving-structure-based(ala genetic),
- Learning parameters (connected) ,
- Probability-based (Baeysian),
- Symbolic (knowledge representation as symbols),
- Analogy-based (recognise similarities).
- Symbolic like “equation” used in Physics: F = ma => F – ma = 0 => general equation “U (X) = 0”
- Evolutionist: rules create new rules and discard old irrelevant rules, like the nature selection “survival the fittest “.
- Overfitting Data: Bias vs Variance. Eg. A clock aways late by 1 hour (high B, low V); if it tells almost the right time but alternate erractically between fast & slow (low B high V)
Induction is the inverse of Deduction: Deduction:
A is a, (A = Socrates, a = human) if a then b (b = mortal) Therefore A is b.
Induction:
The above is TRUE for A = {Plato, Aristotle, Confucius, …} who were Philosopher (P), Therefore (by Induction), P is b
Bayesian Theorem (Cause & Effect)
- Pastor Thomas Bayes (18CE) invented it.
- Pierre-Simon Laplace (19CE) codified it.
C: Cause
E: Effect
Prove:
suppose among 100 patients there are flu = 14 patients, Fever = 20, both = 11
flu = Cause, Fever = Effect
P (Fever |flu) = 11/14
P (flu) = 14/100
P (Fever) = 20/100
P (flu & Fever) = P (flu) x P (Fever |flu) …[1]
Also,
P (Fever & flu) =P (Fever) x P (flu | Fever) …[2]
[1] = [2]:
P(Fever) x P (flu | Fever) =P (flu) x P (Fever |flu)
Divide both sides by P (Fever),
P (flu | Fever)
= P (Fever|flu) x P(flu) / P(Fever)
= 11/14 x 14/100 / (20/100)
= 11/100 / (20 /100)
= 11/20
References :
- 《Probably Approximate Correct》 – Leslie Valiant, Harvard ( Turing Award)
Guide: Programming Language Papers
Text parsing with regex destructuring in Kotlin / Serialisation
Six books that have shaped my mathematical worldview
https://medium.com/@fjmubeen/six-books-that-have-shaped-my-mathematical-worldview-7adb5cdd147
First book: The 17th CE French Mathematician-cum-Judge Fermat is the name of my alma-mater French Engineering (undergraduate) University.
New Book 2015: 《Birth of a theorem : a mathematical adventure》
Mathematical Thoughts on Western versus Chinese (aka TCM) Medicine
TCM (Traditional Chinese Medicine) is a Continous Function (T) with 4 major “component” parameterized (pj) role-grouping:
T (p1, p2, p3, p4) :-> D
D being the disease treatment.
Let’s use the popular and simplest “Chinese Panadol” aka “Lonicera & Forsythia Cold Tablets” (银翘解毒片) as an illustration: (sold in both TCM & western pharmacies in Singapore.)
p1 : 君 King role – main drug(s), powerful but usually toxic.
eg. 金银花 (Flos Lonicera Japonicae) & 连翘 (Fructus Forsythiae)
p2: 臣 Lieutenant role – Counter the side-effect (eg. toxic) of the King, like his supporting officer.
eg. 薄荷 (Herba Menthae), 牛蒡子(Fructus Arctii)
p3: 佐 Assistant role – Assisting both p1 & p2.
eg. 竹叶 (Herba Laphatheri) & 桔梗 (Radix Platycodonis)
p4: 使 Envoy role– Smoothen the whole process. eg. 甘草 (Radix et Rhizome Glycyrrhizae)
Each group Pj may consist of 1 or more drugs {pj1, pj2…pjn} of the respective roles.
Western Medicine is a Discrete Function (W):
W (X) : -> D
A specific drug (X) is made into a discrete pill for particular disease D treatment.
eg. Beta-blocker “Atenolol” pill for Blood Pressure; “Pravix” (or “Aspirin”) pill for Blood Thinner. Western medicine deals with side-effect by giving a second pill to counter the first drug’s damaging effect ala TCM p2 “Lieutenant” (臣) role (eg. “Omeprazole” to suppress the side-effect of Pravix / Aspirin which might cause stomach / duodenal ulcer after long-term use).
W (X2) : -> D
W (X3) : -> D
…
Reflections:
- When a disease is uniquely identified by a specific cause, Western “discrete function” treatment is efficient and fast.
- However, certain disease is a “syndrome” (eg. hyper tension, diabetes, depression, rheumatism, cold, ‘ABS’: 大肠敏感群候症…) with no specific cause(s), TCM “continuous function” is more effective though takes longer time.
Conclusion:
“West” should meet “East” in this century by combining TCM and Western Treatments for better patient benefits.
Example: 2015 Nobel (Medicine) Prize was awarded to the Chinese TCM Lady Researcher Tu Youyou 屠呦呦 : https://theconversation.com/is-the-2015-nobel-prize-a-turning-point-for-traditional-chinese-medicine-48643
Inventor of Yin-qiao 银翘: Wu JuTong 吴鞠通 (1758 AD- 1836 AD, 清 – 乾隆)
AI – DeepLearning – Machine Learning
3 Waves of AI Evolution:
1st Wave (1950s) : Alan Turing “The Father of AI” and his Princeton Prof Alonzo Church (Lambda Calculus). MIT Prof Malvin Minksy’s “Lisp” Functional Programming (a.k.a. Symbolic or Declarative) Language.
2nd Wave (1980s – 1990s) : Knowledge-Based Rule Engine Expert Systems.
Failed because knowledge acquisition process is too difficult with limited rigid rules.
3rd Wave (2010s -): DeepLearning is the latest AI tool for Machine Learning, famous after 2016 “AlphaGo” game by a former Funan-center UK Kid Demis Hassabis (UK/Greek father & Singapore Chinese mom teacher) beat 2 “Go” World Champions (Korean Lee Sedol 李世乭 and China 柯洁).
Great Books Recommended –
1. Learn Everything in 《Deep Learning》:
- Math (eg. Gradient Descent – by French GrandMaster Cauchy 1847),
- Linear Algebra (eg. Matrix, Eigen-decomposition),
- Probability (eg. Bayesian, etc),
- Key Deep Learning techniques.
Note: Available at Singapore National Library (LKC Reference #006.31).
Order at Amazon: https://www.amazon.com/gp/aw/d/0262035618/ref=mp_s_a_1_3?ie=UTF8&qid=1516412628&sr=8-3&pi=AC_SX236_SY340_FMwebp_QL65&keywords=deep+learning
2. 《The Master Algorithm》 (Book or Audio)
http://catalogue.nlb.gov.sg/cgi-bin/spydus.exe/FULL/EXPNOS/BIBENQ/7400075/198909068,1
5 “Tribes” of Machine Learning, all with 3 layers (Representation, Evaluation/Scoring, Optimisation) :
- Connectionists (“Deep Learning”, Neural Network)
- Bayesians (Probability, Inference Rule)
- Analogizers (Similar Pattern)
- Symbolists (Logic)
- Evolutionaries (Survival the fittest )
Notes:
1. Bill Gates recommends this excellent book for 2018 reading, also found it on Chinese President’s Xi JingPing’s Office Bookshelf in 1 Jan 2018 New Year Speech.
http://www.chinadaily.com.cn/a/201801/15/WS5a5bf75aa3102c394518f26b.html
2. All available copies of this book in the Singapore National Library Board have been loaned out !! (Unusual in low-readership Singapore). Please reserve it via online queue.
3. Audio version (10 CDs) is excellent for in-car listening while driving, or travelling on plane/train/bus for busy persons.
Java 9
Pre-requisites For Abstract Algebra
The 2 important pre-requisites for Abstract Algebra are “abstract thinking”, namely :
- You must not think of “concrete” math objects (geometrical shapes, Integer, Real, complex numbers, polynomials, matrices…), but rather their “generalised” math objects (Group, Ring, Field, Vector Space…).
- Rigourous Proof-oriented rather than computation-oriented.
The foundation of Abstract Algebra is “Set Theory”, make effort to master the basic concepts : eg.
- Sub-Set,
- Equivalence Relation (reflexive, symmetric, transitive),
- Partitioning, Quotient Set, Co-Set
- Necessary condition (“=>”), Sufficient condition (“<=”). Both conditions (“<=>”, aka “if and only if”)
- Proof : “A = B” if and only if ∀a ∈ A, a ∈ B => A ⊂ B, and, ∀b ∈ B, b ∈ A =>B ⊂ A [我中有你, 你中有我 <=>你我合一]
- Check if a function is “well-defined”. (定义良好)
- These concepts / techniques repeat in every branch of Abstract Algebra which deals with all kinds of “Algebraic Structures”, from Group Theory to Ring Theory to Field Theory … to (Advanced PhD Math) Category Theory – aka “The Abstract Nonsense”.
Pizza Math
I order a 9-inch Pizza but out of stock, the shop gives me 2 Pizzas of 5-inch instead, still at the same price, saying the extra 1 inch is free of charge.
Do I gain or lose ?
[Hint]: Do not scroll further down, till you revise the Primary school Math.
Math Talent in Studying Math Easily
Kotlin Style Guide (Kotlin Plug-in 1.2.20)
Franco-Anglo Mathematics Research Cooperation
French people are rational (think before action), English people are imperative (action before think).
17CE French Mathematician & Philosopher René Descarte : “I think therefore I am” 我思故我在 。He invented Analytical Geometry (xyz cartesian geometry).
De Moivre Theorem:
http://www3.imperial.ac.uk/
newsandeventspggrp/imperialcollege/newssummary/news_10-1-2018-16-41-35
“Arrow “: Functional Kotlin
Λrrow
is a functional programming library for the Kotlin programming language born from the fusion of KΛTEGORY and funKTionale.
Kategory and Funktionale were the two most relevant FP libraries for Kotlin in 2017.
AI – 探寻人工智能
Functional Programming : Batch Data Processing
Mathematicians Find Wrinkle in Famed Fluid Equations | Quanta Magazine
Navier-Stokes Equation – $1 million Clay Prize and one of the 7 Millenium Problems.
This N.S. Equation predicts the movement of fluids (air current, water flow) as vector field (with value and direction), matches the physical experiment outcome, but not proven mathematically.
https://www.quantamagazine.org/mathematicians-find-wrinkle-in-famed-fluid-equations-20171221/