Posts

Showing posts from June, 2020

Purrrification of data: Some examples

Image
A First Example To generate a collection of 100 normally distributed random number, we use: rnorm(100) We can repeat this process indefinitely for \(n\) times, and when \(n = 9\), we have the following collections: collection_1 which we can conveniently regroup into a larger collection of random numbers: larger_collection Alternatively, we can use the rerun shorthand to define that the aforementioned collection: list_of_numbers Each of the vector $$\mathbf{x}^{(d)} = \begin{pmatrix}x_1^{(d)} & x_2^{(d)} & \ldots & x_{100}^{(d)}\end{pmatrix}, \quad d = 1, 2, \ldots, 9$$ is a collection of 100 normally distributed random numbers: $$ \ell = \{\mathbf{x}^{(1)}, \mathbf{x}^{(2)}, \ldots, \mathbf{x}^{(9)}\} = \left\{ \begin{pmatrix}x_1^{(1)}\\x_2^{(1)}\\\vdots\\x_{100}^{(1)}\end{pmatrix}, \begin{pmatrix}x_1^{(2)}\\x_2^{(2)}\\\vdots\\x_{100}^{(2)}\end{pmatrix}, \ldots, \begin{pmatrix}x_1^{(9)}\\x_2^{(9)}\\\vdots\\x_{100}^{(9)}\end{pmatrix}\...

Purrrification of factory time-series

Suppose \((t, \dot{s}_{\ell}(t))\) is the time series of liquid sugar mass flow measurement in Line \(\ell\) of a certain factory. To compute the liquid sugar mass for a given interval \(t \in [t_{\rm start}, t_{\rm stop}]\), we can integrate the time series numerically: $$s(t_{\rm start}, t_{\rm stop}, \ell)=\int_{t_{\rm start}}^{t_{\rm stop}} \dot{s}_{\ell}(t)\,dt$$ For instance, the following line totalizes the liquid sugar flow in Line 1 between 11:00 am to 12:00 pm on June 29. sugar_mass('2020-6-29 11:00', '2020-6-29 12:00', 'L1_sugar_massflow') where sugar_mass is totalizer function which parse the mass flow time series into a numerical value. Suppose you are given the task to compute the total sugar metered by flowmeters in Lines 1, 2, 4, and 6 for that same interval. A quick and dirty way would be to rewrite the original code like this: start_clock A slightly better approach is to use start_clock where all_sugar is a reusable function...

Quelling the rākṣasa in the Kingdom of Kadaknath

Image
The following is the concluding conversation between Sun Wukong and Mañjuśrī Bodhisattva in Chapter 39 of The Journey to the West. This is also the story told in the first test episode of TV-adaptation of the novel (Episode name: Quelling the rākṣasa in the Kingdom of Kadaknath 除妖烏雞國) screened by CCTV in 1982. Black chickens are artificially selected for their black appearance. They can be found in many parts of the world and are known by different names: Cemani (Java), Kadakhnath or Kali masi (India), Black H’Mong (Vietnam), Argentinean Tuzo (Latin America), and Svarthöna (Sweden), Silkie (China). See Anik Budhi Dharmayanthi, Yohei Terai, Sri Sulandari, M. Syamsul Arifin Zein, Toyoko Akiyama, Yoko Satta (2017) The origin and evolution of fibromelanosis in domesticated chickens: Genomic comparison of Indonesian Cemani and Chinese Silkie breeds , PLOS ONE. The conversation started with Sun Wukong reprimanding Mañjuśrī bodhisattva for not able to control his subordinates. Wuk...