Jekyll2021-12-09T21:04:42+00:00https://mtaung.github.io/feed.xmlMT AungA data scientist interested in biosignal modelling, behavioural analytics, programming, video games, and statistics.MT AungYet another guide for adding Mathjax 3 to Jekyll (in 2021)2021-06-16T23:57:49+01:002021-06-16T23:57:49+01:00https://mtaung.github.io/maths-example<p>There are various guides floating around on the internet about adding MathJax to a jekyll template, and I’m adding to that list for two reasons: <label for="lol" class="margin-toggle sidenote-number"></label><input type="checkbox" id="lol" class="margin-toggle" /><span class="sidenote"><a href="https://zjuwhw.github.io/2017/06/04/MathJax.html">Seriously</a>, <a href="https://alanduan.me/random/mathjax/">there</a>. <a href="https://github.crookster.org/Adding-MathJAX-LaTeX-MathML-to-Jekyll/">are</a>. <a href="https://www.bodunhu.com/blog/posts/add-mathjax-v3-support-to-jekyll-and-hugo/">so</a>. <a href="https://stackoverflow.com/questions/10987992/using-mathjax-with-jekyll">many</a>… </span></p>
<ul>
<li>Some of the minutiae of the steps have changed since then, namely the CDN.</li>
<li>I could not find a guide replete with information regarding inline maths.</li>
</ul>
<p>I won’t go into why I chose mathjax over katex, but I will say that mathjax is more flexible with compatibility, and that’s what I care about here<label for="comparison" class="margin-toggle sidenote-number"></label><input type="checkbox" id="comparison" class="margin-toggle" /><span class="sidenote">Go read <a href="https://gendignoux.com/blog/2020/05/23/katex.html">this</a>, because I am no authority on the subject but this article is. </span> .</p>
<h4 id="installation">Installation</h4>
<p>The particular theme I’m using for this is klise<label for="klise" class="margin-toggle sidenote-number"></label><input type="checkbox" id="klise" class="margin-toggle" /><span class="sidenote">You can find the repo <a href="https://github.com/mtaung/jekyll-klise">here</a> </span>, but in theory this should hold for any jekyll template.</p>
<p>In our template of choice, there will be an <code class="language-plaintext highlighter-rouge">_layouts</code> directory, with a <code class="language-plaintext highlighter-rouge">header.html</code> file. Within that, you’ll want to insert the code below into the <code class="language-plaintext highlighter-rouge"><head><\head></code>:</p>
<figure class="highlight"><pre><code class="language-html" data-lang="html"> {% if page.usemathjax %}
<span class="nt"><script </span><span class="na">type=</span><span class="s">"text/x-mathjax-config"</span><span class="nt">></span>
<span class="nx">MathJax</span><span class="p">.</span><span class="nx">Hub</span><span class="p">.</span><span class="nx">Config</span><span class="p">({</span>
<span class="na">TeX</span><span class="p">:</span> <span class="p">{</span> <span class="na">equationNumbers</span><span class="p">:</span> <span class="p">{</span> <span class="na">autoNumber</span><span class="p">:</span> <span class="dl">"</span><span class="s2">AMS</span><span class="dl">"</span> <span class="p">}},</span>
<span class="p">});</span>
<span class="nt"></script></span>
<span class="nt"><script </span><span class="na">type=</span><span class="s">"text/javascript"</span> <span class="na">async</span> <span class="na">src=</span><span class="s">"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js?config=TeX-AMS-MML_HTMLorMML"</span><span class="nt">></script></span>
{% endif %}
</code></pre></figure>
<p>and as mentioned by infinite guides before me, you will also need to make sure that you’re using <strong>kramdown</strong> for your markdown renderer. You can find that setting in your root folder at <code class="language-plaintext highlighter-rouge">_config.yml</code>. You should have something that looks like this:</p>
<figure class="highlight"><pre><code class="language-html" data-lang="html"> # Build settings
markdown: kramdown
</code></pre></figure>
<p>Note that one reason why this guide exists is because that mathjax cdn is constantly changing, and it’s likely that by the time you read this, you may need to find yourself an updated cdn link. As of writing, this is one that works.</p>
<h4 id="usage">Usage</h4>
<p>Below is an example of maths using mathjax.</p>
<p>Any page needing maths should start with the frontmatter:</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="ss">usemathjax: </span><span class="kp">true</span></code></pre></figure>
<p>and to insert maths, you would do as with Typora<label for="Typora" class="margin-toggle sidenote-number"></label><input type="checkbox" id="Typora" class="margin-toggle" /><span class="sidenote"><a href="https://typora.io/">Typora</a> has been a godsend for me during covid, for taking notes as well as answering my statistics exam with it. </span>/pandoc/TeX, with the <code class="language-plaintext highlighter-rouge">$$</code> markers.</p>
<figure class="highlight"><pre><code class="language-html" data-lang="html">$$
\begin{align*}
y = y(x,t) <span class="err">&</span>= A e^{i\theta} \\
<span class="err">&</span>= A (\cos \theta + i \sin \theta) \\
<span class="err">&</span>= A (\cos(kx - \omega t) + i \sin(kx - \omega t)) \\
<span class="err">&</span>= A\cos(kx - \omega t) + i A\sin(kx - \omega t) \\
<span class="err">&</span>= A\cos \Big(\frac{2\pi}{\lambda}x - \frac{2\pi v}{\lambda} t \Big) + i A\sin \Big(\frac{2\pi}{\lambda}x - \frac{2\pi v}{\lambda} t \Big) \\
<span class="err">&</span>= A\cos \frac{2\pi}{\lambda} (x - v t) + i A\sin \frac{2\pi}{\lambda} (x - v t)
\end{align*}
$$
</code></pre></figure>
<p>which would then produce the following maths:</p>
\[\begin{align*}
y = y(x,t) &= A e^{i\theta} \\
&= A (\cos \theta + i \sin \theta) \\
&= A (\cos(kx - \omega t) + i \sin(kx - \omega t)) \\
&= A\cos(kx - \omega t) + i A\sin(kx - \omega t) \\
&= A\cos \Big(\frac{2\pi}{\lambda}x - \frac{2\pi v}{\lambda} t \Big) + i A\sin \Big(\frac{2\pi}{\lambda}x - \frac{2\pi v}{\lambda} t \Big) \\
&= A\cos \frac{2\pi}{\lambda} (x - v t) + i A\sin \frac{2\pi}{\lambda} (x - v t)
\end{align*}\]
<p>Inline maths can be written with the <code class="language-plaintext highlighter-rouge">\\(</code> and <code class="language-plaintext highlighter-rouge">\\)</code> characters, producing inline maths
such as \(\delta(t) \xrightarrow{\mathscr{F}} 1\).</p>
<p>Hope that helps, it’s what I’m doing here and it works alright <label for="creds" class="margin-toggle sidenote-number"></label><input type="checkbox" id="creds" class="margin-toggle" /><span class="sidenote">Most of the above is accomplished with thanks to guides by <a href="https://alanduan.me/random/mathjax/">Alan Duan</a> and <a href="https://webdocs.cs.ualberta.ca/~zichen2/blog/coding/setup/2019/02/17/how-to-add-mathjax-support-to-jekyll.html.">Zichen Vincent Zhang</a> </span>.</p>MT AungThere are various guides floating around on the internet about adding MathJax to a jekyll template, and I’m adding to that list for two reasons: Seriously, there. are. so. many…Sufficient Analysis, or “How to do statistics with lost data”2021-04-15T00:00:00+01:002021-04-15T00:00:00+01:00https://mtaung.github.io/sufficient_analysis<p>This post is pertaining <a href="https://github.com/mtaung/sufficient_analysis">one of my github repositories</a> about doing statistics when you’ve lost all your data, and only have aggregates/results to work with. If you ever need to do anything like this, may the gods bless your endeavours, because somewhere along the line things really got fucked up. If you’re in a pinch and just want the how-to and good stuff, <strong>skip all my rambling</strong> and go to the repo, which is all you need to do this. The subject is also likely more relevant for students in applied fields like Psychology, or undergraduates just starting to study statistics with more rigour.</p>
<p>Despite the lack of novelty, it’s an incredibly efficient technique. Lehman<label for="lehman" class="margin-toggle sidenote-number"></label><input type="checkbox" id="lehman" class="margin-toggle" /><span class="sidenote">Richard Lehman provided some additional <a href="https://go.gale.com/ps/anonymous?id=GALE%7CA13838424&sid=googleScholar&v=2.1&it=r&linkaccess=abs&issn=00031305&p=AONE&sw=w">commentary</a> to Larson, whom I refer to below. </span> has credited this method with allowing him to reanalyse textbook examples or published results where the raw data is not available, optimising large datasets by computing sufficient statistics only once, and catching out publication errors in a manner similar to Heathers & Quintana’s data thugging <label for="datathugs" class="margin-toggle sidenote-number"></label><input type="checkbox" id="datathugs" class="margin-toggle" /><span class="sidenote">Great article about them <a href="https://www.sciencemag.org/news/2018/02/meet-data-thugs-out-expose-shoddy-and-questionable-research">here</a>, if you are not aware of their work. </span> that was a big part of raising awareness of the replication crisis.</p>
<h4 id="our-particular-scenario">Our Particular Scenario</h4>
<p>In 2018, as part of an AI bootcamp I participated in a small hackathon where we trained agents using a rolling horizon evolutionary algorithm<label for="rhea" class="margin-toggle sidenote-number"></label><input type="checkbox" id="rhea" class="margin-toggle" /><span class="sidenote">A collection of papers on RHEA by the original authors can be found <a href="https://gaigresearch.github.io/projects/rhea">here</a>. </span>. It was the tail end of a pretty gruelling week due to the time constraint, so everyone was tired. At the end of the final testing session, a working model was produced but with everyone burning out the comprehensive data for the agent was not correctly recorded. Mistakes like this happen all the time, especially among fraught and tired students during their studies, as it did to us. By the time we realised our error, it was too late to amend the code and compute more runs, and we just wanted to be done with it all so I was asked to salvage what we could.</p>
<p>All we had were some aggregate results, and one question we had to answer was “How well did the agent perform?”.</p>
<h4 id="working-with-nothing-but-means--variances">Working with nothing but means & variances</h4>
<p>The best I could come up with at the time was to try and salvage the dataset by fabricating a surrogate dataset with the same sample statistics as our observed results.</p>
<p>I suspected that I wasn’t the first person to come up with this, so I searched on google and found one paper <label for="larson" class="margin-toggle sidenote-number"></label><input type="checkbox" id="larson" class="margin-toggle" /><span class="sidenote">Larson actually authored two papers on this approach, this is specifically from Larson, D. A. (1992). Analysis of variance with just summary statistics as input. The American Statistician, 46(2), 151-152. </span> on this. It’s something that anyone with a background in maths and statistics would be able to work out themselves, but there’s a source to show my banality.</p>
<p>The paper opened with a quote that made us feel especially guilty.</p>
<blockquote>
<p>“More times than I care to recount, I have been asked how to use various statistical software packages to perform a one-way analysis of variance (ANOVA) and appropriate multiple comparison procedures on summary statistics for which the original data have been discarded.”</p>
</blockquote>
<p>If, like us, you still managed to record your mean and variance/standard deviation, then you’re in luck because you have what’s called the <em>sufficient statistics</em>, which are the minimally required values to compute a given test or model. With that, you can compute a surrogate sample:</p>
\[\begin{align*}
y_i = x\bar + \frac{s}{\sqrt{n}}, i = 1, 2, ..., n-1 \\
y_n = nx - y_i (n-1) \\
\end{align*}\]
<p>where you have a sample of size \(n\), mean \(\bar{x}\), and sample variance \(s^2\), which the surrogate samples of \(y_i\) all possess.</p>
<p>This means that you should also have some idea about the underlying structure of your samples, such as your \(n\) number of observations and \(k\) groups.</p>
<p>In other words, you end up with \(n\) number of observations (per group) with a value of \(\bar{x}\), and just one observation (per group) with a value of \(nx - y_i (n-1)\), that is used to retain the original variance.</p>
<p>Once you have this sample, it is possible to compute your desired test (in our case a one-way ANOVA). On my repo from a few years back, there’s some rough example code showing how to do this for both an <a href="https://github.com/mtaung/sufficient_analysis/blob/master/ANOVA%20from%20sufficient%20statistics.ipynb">ANOVA</a> and a <a href="https://github.com/mtaung/sufficient_analysis/blob/master/Independent%20Samples%20t-test%20from%20sufficient%20statistics.ipynb">T test</a>, though it is not very thorough and only sits as a proof of concept. With some additional effort, it’s also possible to do this for an n-way ANOVA. The original papers display how to conduct this method in Excel, and SAS.</p>
<h4 id="but-its-not-really-sufficient-for-real-work">But it’s not <em>really</em> sufficient for real work</h4>
<p>It shouldn’t be necessary to say, but this isn’t at all close enough to what could be accomplished were the full data intact. You will miss out on very essential parts of doing real research, like exploratory graphing and statistics. You have a very rough idea of how your sample looks if you compute the confidence intervals for your sample statistics, or your test, but you don’t have certainty about any outliers, nor can you examine for violations of critical assumptions like homogeneity of variance<label for="robustness" class="margin-toggle sidenote-number"></label><input type="checkbox" id="robustness" class="margin-toggle" /><span class="sidenote">Linear models are generally more robust than some undergrad psych/stats classes would lead you to believe. Ideally it is always better to meet assumptions, but <a href="https://psycnet.apa.org/record/2010-18785-001">monte carlo simulations have shown</a> that they can withstand a lot. <strong>However, I do not think this lenience should be held for violations about homogeneity of variance.</strong> If your sample exhibits heteroskedasticity, you really ought to use another test. </span>. You also don’t get to do any bootstrapping (or resampling in general), which is a real shame because they’re great fun.</p>
<p>It really is a last ditch effort to salvage <em>something</em> at all, and it shouldn’t be relied upon unless absolutely needed.</p>MT AungThis post is pertaining one of my github repositories about doing statistics when you’ve lost all your data, and only have aggregates/results to work with. If you ever need to do anything like this, may the gods bless your endeavours, because somewhere along the line things really got fucked up. If you’re in a pinch and just want the how-to and good stuff, skip all my rambling and go to the repo, which is all you need to do this. The subject is also likely more relevant for students in applied fields like Psychology, or undergraduates just starting to study statistics with more rigour.Talk - Game Design for Biosignal Experiments2019-09-08T00:00:00+01:002019-09-08T00:00:00+01:00https://mtaung.github.io/biosignal-game-design<p>I presented a talk at IGGI Conference 2019 on designing a game for use as an experimental paradigm in biosignal research. The project was cancelled due to various circumstances (including the damn plague) but the things I discuss are more general than the specific game we were making.</p>
<iframe src="https://drive.google.com/file/d/10vdTtjaYZqtwY2FpAY_MatyN7EPMUDMC/preview" width="640" height="360" allow="autoplay" frameborder="0"></iframe>MT AungI presented a talk at IGGI Conference 2019 on designing a game for use as an experimental paradigm in biosignal research. The project was cancelled due to various circumstances (including the damn plague) but the things I discuss are more general than the specific game we were making.Talk - Predicting Skill Learning in League of Legends2018-08-17T00:00:00+01:002018-08-17T00:00:00+01:00https://mtaung.github.io/cig-maastrict-talk<p>I published a paper with Valerio Bonometti at the IEEE Conference on Computational Intelligence and Games, titled “Predicting skill learning outcomes in a large, longitudinal MOBA dataset”. Below is a recording of my talk.</p>
<iframe src="https://drive.google.com/file/d/1RVP86Nwj_h_U_HMzlqIxDxm5Mjdombeu/preview" width="640" height="360" allow="autoplay" frameborder="0"></iframe>MT AungI published a paper with Valerio Bonometti at the IEEE Conference on Computational Intelligence and Games, titled “Predicting skill learning outcomes in a large, longitudinal MOBA dataset”. Below is a recording of my talk.