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 <- rnorm(100) collection_2 <- rnorm(100) collection_3 <- rnorm(100) collection_4 <- rnorm(100) collection_5 <- rnorm(100) collection_6 <- rnorm(100) collection_7 <- rnorm(100) collection_8 <- rnorm(100) collection_9 <- rnorm(100) which we can conveniently regroup into a larger collection of random numbers: larger_collection <- c( collection_1, collection_2, collection_3, collection_4, collection_5, collection_6, collection_7, collection_8, collection_9 ) Alternatively, we can use the rerun shorthand to define that the aforementioned collection: list_of_numbers <- rerun(9, rnorm(100)) Each of the vector $$\mathbf{x}^{(d)} = \begin{pmatrix}x_1^{(d)} & x_2^{(d)} & \ldots &a

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 <- '2020-6-29 11:00' stop_clock <- '2020-6-29 12:00' s1 <- sugar_mas

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