<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://eric15342335.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://eric15342335.github.io/" rel="alternate" type="text/html" /><updated>2026-02-26T21:31:41+08:00</updated><id>https://eric15342335.github.io/feed.xml</id><title type="html">Eric15342335 \| HKU AppliedAI Year 3</title><subtitle>Webpage of eric15342335</subtitle><author><name>Cheng Ho Ming, Eric</name><email>eric310@connect.hku.hk</email></author><entry xml:lang="en"><title type="html">OpenMP on Windows stack overflow when using large stack</title><link href="https://eric15342335.github.io/blog/2026/02/26/openmp-on-windows-stack-overflow.html" rel="alternate" type="text/html" title="OpenMP on Windows stack overflow when using large stack" /><published>2026-02-26T20:58:30+08:00</published><updated>2026-02-26T20:58:30+08:00</updated><id>https://eric15342335.github.io/blog/2026/02/26/openmp-on-windows-stack-overflow</id><content type="html" xml:base="https://eric15342335.github.io/blog/2026/02/26/openmp-on-windows-stack-overflow.html"><![CDATA[<p>On Windows, when we compile an OpenMP program with large stack usage using mingw-w64 by default, it will throw a stack overflow error (0xc00000fd):</p>

<pre><code class="language-shell">123er@eric310  /d/Personal Data/Repositories/personal-repo/APAI4013/Assignment-1
$ gcc -fopenmp task2.c -static -g
</code></pre>

<pre><code class="language-shell">123er@eric310  /d/Personal Data/Repositories/personal-repo/APAI4013/Assignment-1
$ strace ./a
--- Process 6256 created
--- Process 6256 loaded C:\Windows\System32\ntdll.dll at 00007fffbfd20000
--- Process 6256 loaded C:\Windows\System32\kernel32.dll at 00007fffbe720000
--- Process 6256 loaded C:\Windows\System32\KernelBase.dll at 00007fffbc810000
--- Process 6256 loaded C:\Windows\System32\ucrtbase.dll at 00007fffbd970000
--- Process 6256 thread 5832 created
--- Process 6256, exception c00000fd at 00007ff761779226
--- Process 6256 thread 17792 exited with status 0xc00000fd
--- Process 6256 exited with status 0xc00000fd
</code></pre>

<p>Adding the <code>-Wl,--stack,1000000000</code> flag to GCC can resolve this issue by increasing the stack size used by the program:</p>

<pre><code class="language-shell">123er@eric310  /d/Personal Data/Repositories/personal-repo/APAI4013/Assignment-1
$ gcc -fopenmp task2.c -static -g -Wl,--stack,10000000000 
</code></pre>

<pre><code class="language-shell">123er@eric310  /d/Personal Data/Repositories/personal-repo/APAI4013/Assignment-1
$ strace ./a
--- Process 20596 created
--- Process 20596 loaded C:\Windows\System32\ntdll.dll at 00007fffbfd20000
--- Process 20596 loaded C:\Windows\System32\kernel32.dll at 00007fffbe720000
--- Process 20596 loaded C:\Windows\System32\KernelBase.dll at 00007fffbc810000
--- Process 20596 loaded C:\Windows\System32\ucrtbase.dll at 00007fffbd970000
--- Process 20596 thread 1092 created
--- Process 20596 thread 5492 created
// ... more threads created
--- Process 20596 loaded C:\Windows\System32\kernel.appcore.dll at 00007fffbb4c0000
--- Process 20596 loaded C:\Windows\System32\msvcrt.dll at 00007fffbf020000
Time taken: 0.898000 seconds
41
6334
15724
24464
9961
32391
18716
19912
17673
20037
 18467
 26500  19169
 11478  29358  26962
  5705  28145  23281  16827
   491   2995  11942   4827   5436
 14604   3902    153    292  12382  17421
 19718  19895   5447  21726  14771  11538   1869
 25667  26299  17035   9894  28703  23811  31322  30333
  4664  15141   7711  28253   6868  25547  27644  32662  32757
 12859   8723   9741  27529    778  12316   3035  22190   1842    288
757147
122502946
610374658
956230507
379002193
722484005
1299818353
-1370045995
-743873488
1826067517
--- Process 20596 thread 21820 exited with status 0x0
--- Process 20596 thread 15588 exited with status 0x0
// ... more threads exited
--- Process 20596 exited with status 0x0
</code></pre>

<p>The program:</p>

<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;omp.h&gt;
#include &lt;stdlib.h&gt;

#define n 16000
int main(void) {
    int L[n][n];
    int X[n];
    int Y[n];
    double start_time, end_time;

    omp_set_num_threads(16);

    start_time = omp_get_wtime();
    // init fixed seed
    srand(1);

    // init L, X
    for (int i = 0; i &lt; n; i++) {
        X[i] = rand();
        for (int j = 0; j &lt;= i; j++) {
            L[i][j] = rand();
        }
        Y[i] = 0;
    }

    #pragma omp parallel for schedule(static)
    for (int i = 0; i &lt; n; i++) {
        for (int j = 0; j &lt;= i; j++) {
            Y[i] += L[i][j] * X[j];
        }
    }

    end_time = omp_get_wtime();
    printf("Time taken: %f seconds\n", end_time - start_time);

    // Visualize the result
    for (int i = 0; i &lt; 10; i++) {
        printf("%d\n", X[i]);
    }
    for (int i = 0; i &lt; 10; i++) {
        for (int j = 0; j &lt;= i; j++) {
            printf("%6d ", L[i][j]);
        }
        printf("\n");
    }
    for (int i = 0; i &lt; 10; i++) {
        printf("%d\n", Y[i]);
    }
    return 0;
}
</code></pre>

<h2 id="appendix">Appendix</h2>

<p>Compiler version:</p>

<pre><code class="language-shell">$ gcc -v
Using built-in specs.
COLLECT_GCC=D:\Personal Data\Repositories\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=D:/Personal\ Data/Repositories/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/15.2.0/lto-wrapper.exe
OFFLOAD_TARGET_NAMES=nvptx-none
Target: x86_64-w64-mingw32
Configured with: ../configure --prefix=/R/winlibs_staging_ucrt64/inst_gcc-15.2.0/share/gcc --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-offload-targets=nvptx-none --with-pkgversion='MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r5' --with-tune=generic --enable-checking=release --enable-threads=posix --disable-sjlj-exceptions --disable-libunwind-exceptions --disable-serial-configure --disable-bootstrap --enable-host-shared --enable-plugin --disable-default-ssp --disable-rpath --disable-libstdcxx-debug --disable-version-specific-runtime-libs --disable-symvers --enable-languages=c,c++,fortran,lto,objc,obj-c++ --disable-gold --disable-nls --disable-stage1-checking --disable-win32-registry --disable-multilib --enable-ld --enable-libquadmath --enable-libada --enable-libssp --enable-libstdcxx --enable-lto --enable-fully-dynamic-string --enable-libgomp --enable-graphite --enable-mingw-wildcard --enable-libstdcxx-time --enable-libstdcxx-pch --with-mpc=/c/Prog/winlibs_staging_ucrt/custombuilt64 --with-mpfr=/c/Prog/winlibs_staging_ucrt/custombuilt64 --with-gmp=/c/Prog/winlibs_staging_ucrt/custombuilt64 --with-isl=/c/Prog/winlibs_staging_ucrt/custombuilt64 --disable-libstdcxx-backtrace --enable-install-libiberty --enable-__cxa_atexit --without-included-gettext --with-diagnostics-color=auto --enable-clocale=generic --enable-libgdiagnostics --with-libiconv --with-system-zlib --with-build-sysroot=/R/winlibs_staging_ucrt64/gcc-15.2.0/build_mingw/mingw-w64 CFLAGS='-I/c/Prog/winlibs_staging_ucrt/custombuilt64/include/libdl-win32   -march=nocona -msahf -mtune=generic -O2 -Wno-error=format' CXXFLAGS='-Wno-int-conversion  -march=nocona -msahf -mtune=generic -O2' LDFLAGS='-pthread -Wl,--no-insert-timestamp -Wl,--dynamicbase -Wl,--high-entropy-va -Wl,--nxcompat -Wl,--tsaware' LD=/c/Prog/winlibs_staging_ucrt/custombuilt64/share/binutils/bin/ld.exe
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.2.0 (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r5)
</code></pre>

<pre><code class="language-shell">$ gcc --version
gcc.exe (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r5) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
</code></pre>]]></content><author><name>Cheng Ho Ming, Eric</name><email>eric310@connect.hku.hk</email></author><category term="blog" /><summary type="html"><![CDATA[On Windows, when we compile an OpenMP program with large stack usage using mingw-w64 by default, it will throw a stack overflow error (0xc00000fd):]]></summary></entry><entry xml:lang="en"><title type="html">Future Data Leakage in (subset of) MIMIC-IV Readmission EHR Dataset</title><link href="https://eric15342335.github.io/blog/2025/12/08/Future-Data-Leakage.html" rel="alternate" type="text/html" title="Future Data Leakage in (subset of) MIMIC-IV Readmission EHR Dataset" /><published>2025-12-08T03:00:00+08:00</published><updated>2025-12-08T03:00:00+08:00</updated><id>https://eric15342335.github.io/blog/2025/12/08/Future-Data-Leakage</id><content type="html" xml:base="https://eric15342335.github.io/blog/2025/12/08/Future-Data-Leakage.html"><![CDATA[<p>It has been a long time that I don’t write any blogs.</p>

<p>Note: This is a cross-post from my Kaggle competition discussion. It is private right now but the professor/TA could make it public if they want to.</p>

<p>Anyway, lets talk about our main topic: Future Data Leakage.</p>

<p>In Electronic Health Records (abbr: EHR) datasets, we (usually) have variable number of rows per patient admission, and one label (corresponding to that admission) as our base prediction unit. Unfortunately (and logically), some admissions are correlated, as they could come from the same patient (obviously), or there was an public incident (disasters), pandemic outbreak, or annual events, etc.</p>

<p>We are going to talk about the <em>Readmission Prediction</em> task. Our job is given a list (time series within 1 admission) of patient vitals (E.g. blood pressure, heart rate, laboratory test results), medicine adminstrated, patient demographics (age, ethnicity, gender), etc., to predict whether the patient will be readmitted within 30 days after his hospital discharge (aka. come back within 30 days after he leaves the hospital).</p>

<p>There was one particular flaw (or, a feature?) in the subset of dataset we received (the professor gave us in <a href="https://webapp.science.hku.hk/sr4/servlet/enquiry?Type=Course&amp;course_code=STAT3612">HKU STAT3612</a>), in which, if the patient only appear once in the dataset, then we can successfully infer that he didn’t come back hospital after his only recorded admission in our database.</p>

<p>This approach has two problems:</p>

<ol>
  <li>It won’t work for patient databases that are incomplete. E.g. we don’t have all the admissions of a patient, or the patient moved to another hospital after his first admission.</li>
  <li>The model is biased when predicting patients with only one admission in the dataset (e.g. predict <code>False</code> for most of them). While it might work well in this particular dataset, it won’t generalize well to real-life data, especially if the real-life patient admission is diverse enough. For example, under a pandemic situation, many patients might only have one admission (the first time they got infected), but they might come back again later (e.g. due to complications). In this case, a model focusing on patient vitals and demographics would be more robust (in terms of distribution shift) than a model relying on admission counts.</li>
</ol>

<p>But apparently, with a simple logic like this, we were able to boost our AUROC (Area Under Receiver Operating Characteristic curve) score from 0.5 (basically means the model is guessing randomly) to 0.617:</p>

<pre><code class="language-python">import pandas as pd
from sklearn.metrics import roc_auc_score

label = "readmitted_within_30days"

train = pd.read_csv("train.csv").drop_duplicates(subset="id")
valid = pd.read_csv("valid.csv").drop_duplicates(subset="id")

train_visit_counts = train["subject_id"].value_counts()
valid_visit_counts = valid["subject_id"].value_counts()

def predict(row, visit_counts):
    patient_only_visit_once = visit_counts.get(row["subject_id"], 1) == 1
    if patient_only_visit_once:
        return 0
    return 1

train["prediction"] = train.apply(lambda row: predict(row, train_visit_counts), axis=1)
valid["prediction"] = valid.apply(lambda row: predict(row, valid_visit_counts), axis=1)

print(f"Train AUROC: {roc_auc_score(train[label], train["prediction"]):.4f}")
print(f"Valid AUROC: {roc_auc_score(valid[label], valid["prediction"]):.4f}")
</code></pre>

<p>Which is pretty amazing. And we were able to obtain AUROC of <code>0.95</code> on the public leaderboard (50%, ~1000 test data) and secure the top 1 (on Public LB). For private leaderboard, that is another story.</p>

<p>Anyway, the professor banned this technique which is totally reasonable given that this is an severe data leakage (this could harm your model performance when being feed with real-life data). But I think this is quite interesting, and I would like to share it here.</p>

<p>A sample codebase implementing a complete machine learning pipeline on this dataset can be found here: <a href="https://github.com/eric15342335/STAT3612-MIMIC-IV-Readmission-Prediction-Demo">https://github.com/eric15342335/STAT3612-MIMIC-IV-Readmission-Prediction-Demo</a>. Note that this is just a demo codebase which was created separately after the competition.</p>

<p>Good luck with everyone!</p>]]></content><author><name>Cheng Ho Ming, Eric</name><email>eric310@connect.hku.hk</email></author><category term="blog" /><summary type="html"><![CDATA[It has been a long time that I don’t write any blogs.]]></summary></entry><entry xml:lang="en"><title type="html">How to enable RTX Virtual Super Resolution (VSR) or HDR in VLC</title><link href="https://eric15342335.github.io/blog/2025/05/17/vlc-rtx-enable.html" rel="alternate" type="text/html" title="How to enable RTX Virtual Super Resolution (VSR) or HDR in VLC" /><published>2025-05-17T20:00:00+08:00</published><updated>2025-05-17T20:00:00+08:00</updated><id>https://eric15342335.github.io/blog/2025/05/17/vlc-rtx-enable</id><content type="html" xml:base="https://eric15342335.github.io/blog/2025/05/17/vlc-rtx-enable.html"><![CDATA[<p>If you are coming here because you have a relatively new desktop/laptop, with a recent GPU like the 30 or 40 series (e.g. RTX 4050 Laptop), and you want to improve the video quality when you watch videos using VLC, then yes I did exactly the same thing. Here is how.</p>

<p>The first Google search probably brings you to <a href="https://downloads.videolan.org/testing/vlc-rtx-upscaler/">here, the official VLC webpage with version 3.0.19</a>. In fact, when I use the version, it sometimes crashes, and in some scenarios that I cannot reproduce, I cannot use Virtual Super Resolution (VSR) and the SDR-to-HDR mapping feature (powered by AI) at the same time. Therefore, I suggest you use the latest (which is 3.0.21) version of VLC, and manually enable the settings (very quick) so that you can enjoy a stable viewing experience (Note that this version also has some bugs, like fullscreen resolution is not really upscaled (black bars around the video), but the RTX features work).</p>

<p>Tools -&gt; Preferences -&gt; Video -&gt; Show Settings (All) -&gt; Search “3D11” (which is Direct3D 11) -&gt; Output Modules - Direct3D 11 -&gt; Change “Video Upscaling Mode” to “Super Resolution”, Change “HDR Output Mode” to “Generate HDR from SDR”. -&gt; (You usually don’t need to) Go back to “Output Module”, change “Automatic” to “Direct3D 11”.</p>

<p>Don’t forget to:</p>

<ol>
  <li>Set the “vlc.exe” to “High Performance GPU (NVIDIA RTX …)” in your Windows settings.</li>
  <li>Enable VSR and HDR features in the NVIDIA App or NVIDIA Control Panel.</li>
  <li>Install latest drivers, Windows Update, general advice, etc.</li>
</ol>]]></content><author><name>Cheng Ho Ming, Eric</name><email>eric310@connect.hku.hk</email></author><category term="blog" /><summary type="html"><![CDATA[If you are coming here because you have a relatively new desktop/laptop, with a recent GPU like the 30 or 40 series (e.g. RTX 4050 Laptop), and you want to improve the video quality when you watch videos using VLC, then yes I did exactly the same thing. Here is how.]]></summary></entry><entry xml:lang="en"><title type="html">AI is Going to Replace Most Work</title><link href="https://eric15342335.github.io/blog/2025/04/11/Some-thoughts-about-AI.html" rel="alternate" type="text/html" title="AI is Going to Replace Most Work" /><published>2025-04-11T00:42:00+08:00</published><updated>2025-04-11T00:42:00+08:00</updated><id>https://eric15342335.github.io/blog/2025/04/11/Some-thoughts-about-AI</id><content type="html" xml:base="https://eric15342335.github.io/blog/2025/04/11/Some-thoughts-about-AI.html"><![CDATA[<h4 id="clickbait-not-really">Clickbait (not really)</h4>

<h2 id="background">Background</h2>

<p>Here are just my thoughts on AI (in particular <strong>Large Language Models</strong>, since it is currently the most impactful AI system for normal people). I do write them in point-form, so don’t expect coherence here :(</p>

<h2 id="requirements-for-ai-replacement">Requirements for AI Replacement</h2>

<ol>
  <li>A lot of people did the same/similar work previously</li>
  <li>Examples were readily available online</li>
</ol>

<blockquote>
  <p><strong>Statement</strong>: No matter how powerful LLMs are (reasoning, agents, long context retrieval, etc.), they still require previously seen knowledge and cannot solely rely on their “hallucination”.</p>

  <p><strong>Hypothesis</strong>: AI with significant reasoning ability cannot complete a task flawlessly if it is completely new to either humans or AI systems in general.</p>
</blockquote>

<h2 id="result">Result</h2>

<p>AI is able to train on and remember these examples, letting anyone do the same thing with minimal prior knowledge.</p>

<h2 id="solution">Solution</h2>

<p>Go to fields that have minimal examples:</p>

<ul>
  <li><strong>Fields with few practitioners</strong>
    <ul>
      <li>Relatively unused fields like certain historical niches
        <ul>
          <li>(Though I likely won’t study these fields)</li>
        </ul>
      </li>
      <li>Useful fields that require significant knowledge and research (e.g., <em>SOTA</em>)</li>
    </ul>
  </li>
  <li><strong>Fields with no patterns</strong>
    <ul>
      <li>Fields that are purely random in nature
        <ul>
          <li>(I likely won’t succeed in these fields due to their indeterministic nature)</li>
        </ul>
      </li>
    </ul>
  </li>
  <li><strong>Fields that constantly generate new examples</strong>
    <ul>
      <li>Faster than what AI can learn</li>
      <li>Question: <em>As AI scales up every year, what fields can really keep pace?</em></li>
    </ul>
  </li>
</ul>

<hr />

<h2 id="what-ai-have-i-been-using-recently">What AI have I been using recently?</h2>

<h3 id="chatgpt-4o-on-chatgptcom"><a href="https://chatgpt.com">ChatGPT 4o</a> (on chatgpt.com)</h3>

<ul>
  <li><strong>Image generation ability</strong> (as of Apr 11, 2025)
    <ul>
      <li>Native generation is really impressive and is able to form correct, clean text such as banners or blackboards, etc. However, there are still some issues with the geometric understanding.</li>
    </ul>
  </li>
</ul>

<h3 id="gemini-25-pro-preview-on-aistudiogooglecom"><a href="https://aistudio.google.com">Gemini 2.5 Pro Preview</a> (on aistudio.google.com)</h3>

<ul>
  <li><strong>Really impressive long context retrieval and reasoning ability</strong>
    <ul>
      <li>It is able to perform calculation <em>step by step</em> (not skipping steps unlike other AI models when they receive 10 math questions and told to do all at once). It is able to make best informed decision according to the context provided. TL;DR, it is <em>attentive to details</em> (Yes K.P. Wat!)</li>
    </ul>
  </li>
  <li>Unlimited usage and free, can’t demand more, right?</li>
</ul>

<h3 id="gemini-deepresearch-on-geminigooglecom"><a href="https://gemini.google.com">Gemini DeepResearch</a> (on gemini.google.com)</h3>

<ul>
  <li>This is really impressive. I used it for several purposes:
    <ul>
      <li>Finding scholarly published papers and using them as my APA citations for my essay assignments and other stuff</li>
      <li>Performing in-depth broad range analysis and investigation on one particular field or topic
        <ul>
          <li>It is able to consider almost all aspects of the topic (primarily due to the mass amount of information it receives on the internet, and its reasoning ability) and generate a detailed report. If my prompt is detailed, then I would expect more than 10 pages, 5000+ words report (including references).</li>
        </ul>
      </li>
      <li>I almost built a workflow for this:
        <ol>
          <li>(This should be step 0) Come up with an interesting topic that I want to read about and spend time on it</li>
          <li>Ask <a href="https://aistudio.google.com">Gemini 2.5 Pro</a>, or other AI models to understand what I don’t know, and to provide me with a detailed prompt which covers various aspects of the topic to be explored on</li>
          <li>Throw the prompt into <a href="https://gemini.google.com">Gemini DeepResearch</a></li>
          <li>In the meantime, generate a $\LaTeX{}$ template using either <a href="https://aistudio.google.com">Gemini 2.5 Pro</a> or <a href="https://claude.ai">Claude 3.7 Sonnet</a> (you may ask why I use this? It is because I bought Claude Pro, so not using it feels like wasting money 😅)</li>
          <li>Wait until the <a href="https://gemini.google.com">Gemini DeepResearch</a> finishes</li>
          <li>Throw the entire report into <a href="https://chatgpt.com">ChatGPT 4o</a> and let it generate a cover page image (using its native image generation ability)</li>
          <li>Ask any of the LLM models mentioned above to amend the $\LaTeX{}$ template in order to adjust the section, subsection and other stuff that the DeepResearch-generated report gave us</li>
          <li>Copy respective sections from the report and paste them into the $\LaTeX{}$ template</li>
          <li>Fix the errors that arise, this step should take around 5-10 trials depending on luck</li>
          <li>$\cdots$</li>
          <li>Done!</li>
        </ol>
      </li>
      <li>In fact, you can see one of my <a href="/assets/A24_Consultancy_Research_AIGenReport.pdf">previously generated report samples here</a></li>
    </ul>
  </li>
</ul>

<h3 id="claude-37-sonnet-thinking-on-claudeai-via-my-claude-pro-subscription"><a href="https://claude.ai">Claude 3.7 Sonnet</a> (thinking) (on claude.ai via my Claude Pro subscription)</h3>

<ul>
  <li>Before the <a href="https://chatgpt.com">GPT-4o</a> image generation ability was released, I thought this was the best decision (of subscribing to an AI service) because Claude was the strongest LLM model at (web development specifically) programming and I have a web development course (<a href="https://www.cs.hku.hk/index.php/programmes/course-offered?infile=2024/comp3322.html">COMP3322</a>)</li>
  <li>It turns out <a href="https://chatgpt.com">GPT-4o</a> native image output released few days after</li>
  <li><a href="https://aistudio.google.com">Gemini 2.5 Pro</a> followed next
    <ul>
      <li>So it was kind of not a good time to buy a subscription lol</li>
    </ul>
  </li>
  <li>UI is generally good, with support of React artifacts (I primarily use it for data visualization since I don’t need to run it on my python lol)</li>
  <li>In terms of the <em>attention to details</em> ability, it is not as good as <a href="https://aistudio.google.com">Gemini 2.5 Pro</a> (which is able to perform step by step calculation). Claude 3.7 Sonnet (thinking) would just summarize everything if I didn’t explicitly ask it to explore every step in-depth</li>
</ul>]]></content><author><name>Cheng Ho Ming, Eric</name><email>eric310@connect.hku.hk</email></author><category term="blog" /><summary type="html"><![CDATA[Clickbait (not really)]]></summary></entry><entry xml:lang="en"><title type="html">chatgpt.hku.hk does not render LaTeX: how to fix</title><link href="https://eric15342335.github.io/blog/2025/04/01/chatgpt-hku-lacking-mathjax.html" rel="alternate" type="text/html" title="chatgpt.hku.hk does not render LaTeX: how to fix" /><published>2025-04-01T23:45:00+08:00</published><updated>2025-04-01T23:45:00+08:00</updated><id>https://eric15342335.github.io/blog/2025/04/01/chatgpt-hku-lacking-mathjax</id><content type="html" xml:base="https://eric15342335.github.io/blog/2025/04/01/chatgpt-hku-lacking-mathjax.html"><![CDATA[<h2 id="update">Update</h2>

<p>I’ve emailed HKU ITS and they shipped this feature (seeing $\LaTeX$ in chatgpt.hku.hk) within a week. Now the issue is rather whether the LLM model is adhering to outputting math symbols in the correct $\LaTeX$ format e.g. <code>$</code> or <code>$$</code> etc.</p>

<h2 id="background">Background</h2>

<p>If you’re studying in HKU, you would know that the University provides access to <a href="https://deepseek.com/">DeepSeek-r1</a> at <a href="https://chatgpt.hku.hk">chatgpt.hku.hk</a> (with no restrictions or rate limits, unlike previous models like <a href="https://openai.com/index/gpt-4o-system-card/">GPT-4o</a>, which billed 500,000 tokens monthly). However, as of when this blog was written, the web UI does not render $\LaTeX{}$, which is a major drawback for students who are studying mathematics or related subjects.</p>

<h2 id="solution">Solution</h2>

<p>Follow these steps:</p>

<ol>
  <li>
    <p>Include the following in your prompt:</p>

    <pre><code class="language-txt"> Enclose LaTeX in $ (inline math) or $$ (multi-line math). Use appropriate delimiters for your equations.
</code></pre>
  </li>
  <li>
    <p>Simply paste this code into your browser console:</p>

    <p class="encircled-text">Update: I made a Chrome extension to automate this process. <a href="https://github.com/eric15342335/mathjax-injector-extension">Check it out here!</a></p>

    <pre><code class="language-javascript"> // Create and load MathJax
 var script = document.createElement("script");
 script.src = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js";

 // Configure MathJax with all needed delimiters
 window.MathJax = {
     tex: {
         inlineMath: [["$", "$"], ["\\(", "\\)"]],
         displayMath: [["$$", "$$"], ["\\[", "\\]"]],
         packages: ['base', 'ams', 'noerrors', 'noundefined', 'autoload', 'require']
     },
     startup: {
         typeset: false
     }
 };

 // Add script to document
 document.head.appendChild(script);

 // Set up observer to detect new messages
 script.onload = function () {
     // Initial typeset
     MathJax.typeset();

     // Debounce function to limit typeset calls
     let timeoutId = null;
     const debounceTypeset = function () {
         if (timeoutId) {
             clearTimeout(timeoutId);
         }
         timeoutId = setTimeout(function () {
             MathJax.typeset();
             timeoutId = null;
         }, 10); // Wait ?ms before processing to batch changes
     };

     // Create observer for new content
     new MutationObserver(function (mutations) {
         let hasNewNodes = false;

         // Check if any of the mutations contain new nodes
         for (let i = 0; i &lt; mutations.length; i++) {
             if (mutations[i].addedNodes.length &gt; 0) {
                 hasNewNodes = true;
                 break;
             }
         }

         if (hasNewNodes) {
             // Use debounced typeset
             debounceTypeset();
         }
     }).observe(document.body, {
         childList: true,
         subtree: true,
         characterData: false,
     });
 };
</code></pre>
  </li>
</ol>]]></content><author><name>Cheng Ho Ming, Eric</name><email>eric310@connect.hku.hk</email></author><category term="blog" /><summary type="html"><![CDATA[Update]]></summary></entry><entry xml:lang="en"><title type="html">Breaking VPL SQL Assignment</title><link href="https://eric15342335.github.io/blog/2025/03/18/Breaking-VPL-SQL-assignment.html" rel="alternate" type="text/html" title="Breaking VPL SQL Assignment" /><published>2025-03-18T21:10:00+08:00</published><updated>2025-03-18T21:10:00+08:00</updated><id>https://eric15342335.github.io/blog/2025/03/18/Breaking-VPL-SQL-assignment</id><content type="html" xml:base="https://eric15342335.github.io/blog/2025/03/18/Breaking-VPL-SQL-assignment.html"><![CDATA[<p><img src="/assets/images/2025-03-18-Breaking-VPL-SQL-assignment-demo-success.webp" alt="A quick demo photo of what is the main focus of this post" /></p>

<p>How do I find it?</p>

<h2 id="background">Background</h2>

<p>We got a question:</p>

<p><strong>Q6. [12%] Display <em>station_ID</em>, <em>station_name</em>, and <em>rental_income</em> for each of the charging stations in February 2024.</strong></p>

<ul>
  <li>Sort the results by <em>rental_income</em> in descending order, then <em>station_ID</em> in ascending order.</li>
  <li><em>rental_income</em> is the sum of the <em>payment_amount</em> in a given period.</li>
</ul>

<p>Normally, we’d answer this question using a (My)SQL statement:</p>

<pre><code class="language-sql">SELECT cs.station_ID, cs.name AS station_name,
    SUM(rt.payment_amount) AS rental_income
FROM ChargingStation cs
    INNER JOIN RentalTransaction rt ON cs.station_ID = rt.station_ID
WHERE rt.end_datetime &gt;= '2024-02-01 00:00:00' AND
    rt.end_datetime &lt; '2024-03-01 00:00:00' AND
    rt.status = 1 -- Completed transaction
GROUP BY cs.station_ID, cs.name
ORDER BY rental_income DESC, cs.station_ID ASC;
</code></pre>

<p>But someone on Moodle pointed out that the database is actually SQLite (In case if you’re wondering, he is <a href="https://skylee.xyz">skylee</a>). That sparked my curiosity and got me exploring ways to “complete” this question through alternate means.</p>

<p><img src="/assets/images/2025-03-18-Breaking-VPL-SQL-assignment-sqlite-discovered.webp" alt="The output of `.version`: which shows the SQLite database version installed on the VPL jail system." class="_75_percent_width" /></p>

<h2 id="information-gathering">Information Gathering</h2>

<p>By Googling, I learned we can execute shell commands inside an SQLite query. First, I listed the files in the current directory:</p>

<pre><code class="language-shell">.shell ls
</code></pre>

<p><img src="/assets/images/2025-03-18-Breaking-VPL-SQL-assignment-list-current-dir.webp" alt="Result of running `.shell ls` in SQLite" class="_75_percent_width" /></p>

<p>Obviously, we need to inspect each file to see what we’ve got:</p>

<pre><code class="language-shell">.shell cat *
</code></pre>

<p><img src="/assets/images/2025-03-18-Breaking-VPL-SQL-assignment-vpl-stuff.webp" alt="Result of running `.shell cat *` which prints the contents of all files in the current directory. On the screen, there’s one shell script used by VPL for judging purposes." class="_75_percent_width" /></p>

<p>Hmm. Most of the files aren’t related to the assignment or the test cases themselves. Let’s check the <code>*.txt</code> and <code>*.sql</code> files since I strongly suspect they’re tied to this particular question:</p>

<pre><code class="language-shell">.shell cat *.txt *.sql
</code></pre>

<p><img src="/assets/images/2025-03-18-Breaking-VPL-SQL-assignment-not-vpl-stuff.webp" alt="Result of running `.shell cat *.txt *.sql` which attempts to print out all files related to the above-mentioned SQL question." class="_75_percent_width" /></p>

<p>We can see that the text file is likely what we want—the desired output. So, simply printing it should be enough to score 100%.</p>

<p>Note that this probably won’t work against hidden test cases, where they might use a different text file name to differentiate between tests. But that’s it.</p>

<h2 id="fluff">Fluff</h2>

<p>If you want to make VSCode (and GitHub Copilot) work like Cursor Tab, make sure to enable this experimental setting (switch to a <code>pre-release</code> version of the extension first!):</p>

<p><img src="/assets/images/2025-03-18-Breaking-VPL-SQL-assignment-make-vscode-like-cursor.webp" alt="VSCode Copilot Tab setting location" class="_50_percent_width" /></p>

<p><em>I recommend trying out other options too! I can’t say for sure, but some might surprise you!</em></p>]]></content><author><name>Cheng Ho Ming, Eric</name><email>eric310@connect.hku.hk</email></author><category term="blog" /><summary type="html"><![CDATA[]]></summary></entry><entry xml:lang="en"><title type="html">Talking about Emotional Crashes</title><link href="https://eric15342335.github.io/blog/2025/03/18/Talking-about-Emotional-Crashes.html" rel="alternate" type="text/html" title="Talking about Emotional Crashes" /><published>2025-03-18T20:22:00+08:00</published><updated>2025-03-18T20:22:00+08:00</updated><id>https://eric15342335.github.io/blog/2025/03/18/Talking-about-Emotional-Crashes</id><content type="html" xml:base="https://eric15342335.github.io/blog/2025/03/18/Talking-about-Emotional-Crashes.html"><![CDATA[<blockquote>
  <p>Quick note: I’m definitely not a psychologist. If you’re dealing with serious mental health issues or feel like talking to someone professionally, please reach out to a local clinical psychologist near you.</p>
</blockquote>

<h2 id="preliminary">Preliminary</h2>

<p>When it comes to emotional crashes, some of us might have experienced them before, while others maybe not yet. Some people might have had one without even realising it, while others could be worrying they’re about to have one anytime soon. Emotional crashes are a hot topic - especially for us university students - mainly because they can hit us pretty hard. I think it’s important that we talk openly about what an emotional crash is, how to spot one coming, and how to handle it. I hope this blog post helps you understand emotional crashes better.</p>

<h2 id="what-is-an-emotional-crash">What is an Emotional Crash</h2>

<p>Usually, when people haven’t been productive or haven’t studied for several days (or even a week or two), they might call this an “emotional crash.” Personally, I think those situations happen mostly because we don’t stick to a regular schedule or because stuff around us got pretty distracting. Not saying that doesn’t count as crasing, but when I say “emotional crash,” I’m talking about that sudden moment when a huge wave of negative feelings hits you out of nowhere. It makes you feel totally uncomfortable, wanting to stop everything you’re doing right at that moment, and making it almost impossible to be productive.</p>

<h2 id="when-will-you-crash">When Will You Crash</h2>

<p>Honestly speaking, we can’t really predict exactly when we’ll crash. But sometimes having a long, non-stop lecture (like those 4-hour ones…) might push you closer to a meltdown. Also, not getting enough sleep definitely doesn’t help either.</p>

<h2 id="am-i-really-crashing">Am I Really Crashing?</h2>

<p>Crashes are pretty subjective; different people feel them differently. But usually, when you’re crashing, you’ll focus more on short-term distractions rather than things that reward you later on. You might just keep scrolling social media (doomscroll alert!) or avoid all productive tasks. It’s sort of a cycle - doomscrolling can cause crashes, and crashes can lead to doomscrolling.</p>

<h2 id="some-important-facts-about-emotional-crashes">Some Important Facts About Emotional Crashes</h2>

<ol>
  <li>Sudden surge of emotions, difficult (or impossible) to handle.</li>
  <li>Becoming a “walking zombie.”</li>
</ol>

<h2 id="what-you-really-need-to-do-when-there-is-a-crash">What You Really Need to Do When There Is a Crash</h2>

<ol>
  <li>First thing to do: Take a deep breath, step away from your desk and walk around. From my own experience, I find that walking around HKU (from CYM Canteen all the way to Centennial Campus, a couple times at least) is great for clearing your mind, improving your mood, and reflecting a bit on life.</li>
  <li>Don’t immediately run away from your challenges or tasks - instead, use that walk to slow down your mind a bit and gain some perspective.</li>
  <li>Bargain with yourself. If you really need a break, ask yourself: would maybe a short 30-minute break be good enough? It’s likely better than spending the next four hours on Netflix or Instagram.</li>
</ol>

<h2 id="what-should-you-do-when-others-crash">What Should You Do When Others Crash</h2>

<p>We’ve probably all seen friends cancel plans or suddenly ditch important meetings and events. That kind of behaviour is pretty normal for people experiencing an emotional slump or “crash.” You shouldn’t feel good about it (although honestly, if you’re an introvert like me, cancelled plans can feel like a secret relief - except if it’s a study meeting!). But more importantly, when friends tell you they’re having a tough time, it usually means they really trust you enough to open up (seriously, you should feel honored).</p>

<h3 id="dont">Don’t</h3>

<ol>
  <li>Ignore the message.</li>
  <li>Reply with just “Okay” and leave it at that.</li>
  <li>Send something generic like “Hope you’ll feel better soon!” (I mean, it’s harmless, but it’s kind of too cliché to actually help.)</li>
</ol>

<h3 id="dos">Do’s</h3>

<ol>
  <li>If you sort of know what’s been going on in their life lately, that’s a great start! Connect your reply with what they’ve shared recently (maybe they’re stressed about exams, revision, or group projects?). This helps you better understand why they’ve messaged you about it.</li>
  <li>Try to really get a sense of what they actually need. Okay, I know this is pretty hard. One tip is to pay attention to what events/tasks they’re cancelling. If it’s something important and you’re involved, you could say something simple but helpful like, “Whenever you feel ready, just hit me up and I’ll be around!” Trust me, that’ll boost your emotional IQ points.</li>
</ol>

<h2 id="how-to-sense-others-having-a-crash">How to Sense Others Having a Crash</h2>

<p>Actually, I think sensing when someone’s crashing is easier if you already know that person pretty well. What’s harder, though, is paying enough attention to pick up on these signals - basically stopping yourself from casually brushing off their problems and instead genuinely thinking about what they might need at that moment.</p>

<h2 id="final-notes">Final Notes</h2>

<p>Life isn’t easy. It’s complicated and messy, and honestly, we’re probably never walking exactly the same path as anyone else in our lives - be it class schedules, skills, interests, or personal goals. It’s always worth remembering: Everyone’s unique in their own complicated way.</p>

<p>I really hope you found something helpful here!</p>

<h2 id="recent-updates">Recent Updates</h2>

<p>Midterms are coming real soon, and it’s pretty important for me right now to keep my study/sleep schedule steady.<br />
Anyway, some random life updates about me:</p>

<ul>
  <li>Got an offer from RTHK for a summer internship - feeling relieved and sort-of-secured now for my Year 2 summer break, even though the internship is just about 2 months.</li>
  <li>Recently I’ve noticed a huge flood of information coming in from classes. I’m kinda worried there’s NO WAY I’ll perfectly remember all lecture note details, especially since they might be asked in exams.</li>
  <li>Something odd I’ve noticed is that certain subjects stick better in my memory (like database/SQL - I find it easy to write MySQL queries). But other classes like STAT3600 Linear Statistical Analysis (this one’s quite serious), APAI3010 Computer Vision (mildly forgetful), and web development (same here, mild) seem to disappear from my memory very quickly, like within just a few days or a week. Probably because I haven’t practiced those key concepts enough?</li>
  <li>Oh, and seriously: taking six courses per semester? I don’t really recommend it… It’s a HUGE mental pressure test. Maybe it’s doable if you have already mastered like half the content for at least three courses beforehand. (Quick disclaimer: Not everyone is the same! Different people handle academic stress differently, totally depends on your learning style and stamina.)</li>
</ul>]]></content><author><name>Cheng Ho Ming, Eric</name><email>eric310@connect.hku.hk</email></author><category term="blog" /><summary type="html"><![CDATA[Quick note: I’m definitely not a psychologist. If you’re dealing with serious mental health issues or feel like talking to someone professionally, please reach out to a local clinical psychologist near you.]]></summary></entry><entry xml:lang="en"><title type="html">Prompt for learning statistics</title><link href="https://eric15342335.github.io/blog/2025/02/08/Prompt-for-learning-statistics.html" rel="alternate" type="text/html" title="Prompt for learning statistics" /><published>2025-02-08T19:00:00+08:00</published><updated>2025-02-08T19:00:00+08:00</updated><id>https://eric15342335.github.io/blog/2025/02/08/Prompt-for-learning-statistics</id><content type="html" xml:base="https://eric15342335.github.io/blog/2025/02/08/Prompt-for-learning-statistics.html"><![CDATA[<h2 id="prompt">Prompt</h2>

<pre><code class="language-markdown">Please adopt a conversational style similar to a helpful and patient tutor specializing in mathematics and statistics, particularly for a university student studying Applied AI.  When responding to my questions, please try to incorporate the following elements:

*   **Patient and Step-by-Step Explanations:** Break down complex topics into smaller, manageable parts.  Assume I may not have a strong foundation in math and stats and need concepts explained gradually.
*   **Use Analogies and Intuitive Examples:**  Whenever possible, use real-world examples and analogies to make abstract mathematical and statistical concepts more concrete and easier to understand.  Feel free to use analogies like cooking, physics, or everyday scenarios.
*   **Address Hesitations and Doubts Directly:** Acknowledge when I express confusion, frustration, or feeling overwhelmed.  Validate these feelings and offer encouragement. Don't just gloss over points of difficulty.
*   **Balance Rigor with Accessibility:** Aim for mathematical accuracy and rigor, but prioritize clear and accessible explanations over overly technical jargon, especially at first. Gradually introduce more formal terms as understanding builds.
*   **Provide Encouragement and Positive Reinforcement:** Acknowledge good questions, insightful observations, and progress in understanding. Build confidence.
*   **Regularly Check for Understanding:** Ask questions like "Does this make sense?" "Is this clearer now?" "Let me know if you want to explore this further" to ensure I'm following along and to encourage me to ask more questions.
*   **Structure and Organize Responses Clearly:** Use headings, bullet points, numbered lists, and clear formatting to make information easier to read and digest.
*   **Provide Direct and Honest Answers:** Be direct in responses, even if it means acknowledging limitations or complexities.  Don't oversimplify to the point of inaccuracy.
*   **Be Iterative and Responsive:** Pay close attention to my questions and feedback, and adapt explanations accordingly.  Be prepared to revisit concepts from different angles if needed.
*   **Focus on "Why" and "Intuition" in Addition to "What" and "How":** Explain the underlying motivation, purpose, and intuition behind formulas and concepts, not just the mechanical steps or definitions.  Help me understand the "big picture."

Essentially, please act as a tutor who is knowledgeable, patient, encouraging, and focused on helping me build a deep and intuitive understanding of challenging mathematical and statistical topics relevant to my Applied AI studies.  I may ask very detailed and probing questions, and I appreciate thorough and thoughtful responses in this style.
</code></pre>

<h2 id="some-updates-about-google-ai-studio-in-general">Some updates about Google AI Studio in general</h2>

<p>It seems that the <a href="/blog/2025/01/27/How-to-fix-google-aistudio-latex-formatting.html">LaTeX formatting issue mentioned here</a> has been fixed from my trials. Also, I have discovered a potential bug with the ‘Code Execution’ feature, in which plots can fail to display if <code>plt.show()</code> is executed before a <code>print()</code> statement:</p>

<pre><code class="language-python">import matplotlib as plt
# Some code here
plt.show()
print(a_variable_storing_calculation_results)
</code></pre>

<p>The workaround would be to tell the AI to “Print stuff before showing the plot”.</p>]]></content><author><name>Cheng Ho Ming, Eric</name><email>eric310@connect.hku.hk</email></author><category term="blog" /><summary type="html"><![CDATA[Prompt]]></summary></entry><entry xml:lang="en"><title type="html">Purpose of learning Mathematics and Statistics</title><link href="https://eric15342335.github.io/blog/2025/02/07/Purpose-of-learning-Maths-and-Stats.html" rel="alternate" type="text/html" title="Purpose of learning Mathematics and Statistics" /><published>2025-02-07T15:40:00+08:00</published><updated>2025-02-07T15:40:00+08:00</updated><id>https://eric15342335.github.io/blog/2025/02/07/Purpose-of-learning-Maths-and-Stats</id><content type="html" xml:base="https://eric15342335.github.io/blog/2025/02/07/Purpose-of-learning-Maths-and-Stats.html"><![CDATA[<h2 id="self-reflection">Self reflection</h2>

<p>I began my Computer Science journey pretty early – almost around my entrance to secondary education. Hence, I am able to grasp a solid understanding of what CS is trying to do and what the ultimate goals are for CS. However, the same does not hold for mathematics and statistics: I can describe my learning in these two subjects as “stuffing a duck” – I digest knowledge without knowing why we need to study it (not the shallow application of each formula or rule I learned, but the ultimate purpose of what mathematics (the subject) wants to achieve. The same holds for statistics as well.) That’s why, after having three semesters in university, I feel increasingly bored by mathematics and statistics subjects and even question myself why I need to study them (I don’t want any answers involving real-life applications e.g., “To calculate areas for home renovation; predict future income;” but what I want is something philosophical and not influenced by society (aka not sticking to the “values” society wants us to have) – Why did we create mathematics in the first place?).</p>

<p>That’s why you see this post. It is a summary of what I have discussed with AI (Particularly, Google Gemini 2.0 Flash Thinking Experimental from <a href="https://aistudio.google.com">https://aistudio.google.com</a>) and I want to share with all the people who found lost in their life meaning while they enter university.</p>

<p>This post is inspired by <a href="https://thisisxxz.com/">ThisIsXXZ</a> posts:</p>

<ul>
  <li><a href="https://thisisxxz.com/2024/01/15/learning-review-1/">我的第一次反向传播</a>
    <ul>
      <li>He talked about the study method transition after graduated from secondary school and entered university, which I pretty much agree with him.</li>
      <li>Side note: He mentioned the new way of taking notes which I found pretty inspirational.</li>
    </ul>
  </li>
  <li><a href="https://thisisxxz.com/2024/01/19/ANTH2350/">Meanings of Life</a>
    <ul>
      <li>Literally, meaning of life. I have fallen into the “meaning of life” the society fabricated many times - and is not really what I want.</li>
    </ul>
  </li>
</ul>

<h2 id="mathematics-a-top-down-view-the-grand-system-chart">Mathematics: A Top-Down View (The Grand System Chart)</h2>

<p>Imagine mathematics as a vast, incredibly powerful, and deeply interconnected intellectual system.  Our goal is to understand its overall architecture and purpose.</p>

<h3 id="level-1-the-ultimate-purpose-of-mathematics-the-why-of-maths-existence">Level 1: The Ultimate Purpose of Mathematics (The “Why” of Math’s Existence)</h3>

<ul>
  <li><strong>Understanding and Modeling Reality (Both Abstract and Concrete):</strong> At the very highest level, mathematics is fundamentally about <strong>understanding the underlying structures and patterns of reality</strong>, both in the <em>physical world</em> and in the <em>realm of abstract ideas</em>. It’s about building precise, logical models to describe, explain, and predict phenomena.
    <ul>
      <li><strong>Think of it as:</strong>  Creating a universal language and toolkit for describing and reasoning about <em>anything</em> that can be quantified, structured, or logically analyzed.</li>
      <li><strong>Analogy:</strong> Like architecture, mathematics is about designing the <em>framework</em> upon which other disciplines (science, engineering, even parts of philosophy and economics) are built.</li>
    </ul>
  </li>
</ul>

<h3 id="level-2-major-branches-of-mathematical-activity-the-2nd-top---different-ways-math-is-done">Level 2: Major Branches of Mathematical Activity (The “2nd Top” - Different Ways Math is Done)</h3>

<p>To achieve this ultimate purpose, mathematical activity can be broadly categorized into these interconnected branches:</p>

<ul>
  <li><strong>Pure Mathematics (The Exploratory and Foundation-Building Branch):</strong>
    <ul>
      <li><strong>Focus:</strong> Exploring abstract mathematical structures, patterns, and relationships <em>for their own sake</em>, driven by curiosity, internal logic, and aesthetic principles.  This is where the “self-highing” feeling sometimes comes from, but it’s actually about deep exploration of the mathematical universe.</li>
      <li><strong>Motivation:</strong>  Intrinsic beauty, intellectual challenge, uncovering fundamental truths within mathematics itself.  Often, pure math discoveries later find unexpected applications (sometimes decades or centuries later!).</li>
      <li><strong>Examples:</strong> Number Theory, Abstract Algebra, Topology, Real and Complex Analysis, Set Theory, Logic.</li>
      <li><strong>Analogy:</strong> Like fundamental research in physics – exploring the deepest laws of nature, even without immediate practical applications, but these discoveries often become the basis for future technologies.</li>
    </ul>
  </li>
  <li><strong>Applied Mathematics (The Problem-Solving and Connection-Making Branch):</strong>
    <ul>
      <li><strong>Focus:</strong>  Using mathematical tools and techniques developed in pure math to solve <em>real-world problems</em> in science, engineering, technology, finance, social sciences, and many other fields.  This is where math becomes directly useful and impactful.</li>
      <li><strong>Motivation:</strong>  Practical problem-solving, creating new technologies, improving efficiency, understanding and predicting real-world phenomena.</li>
      <li><strong>Examples:</strong>  Mathematical Modeling, Numerical Analysis, Optimization, Statistics and Probability, Differential Equations, Operations Research, Financial Mathematics, Cryptography.</li>
      <li><strong>Analogy:</strong> Like engineering – taking the fundamental principles of physics and applying them to design bridges, airplanes, computers, etc.</li>
    </ul>
  </li>
  <li><strong>Mathematical Foundations (The Rigorous and Logical Bedrock):</strong>
    <ul>
      <li><strong>Focus:</strong>  Establishing the logical foundations, rigor, and consistency of mathematics itself.  Ensuring that mathematical reasoning is sound and free from contradictions.</li>
      <li><strong>Motivation:</strong>  Certainty, precision, avoiding logical fallacies, understanding the nature of mathematical truth.</li>
      <li><strong>Examples:</strong>  Mathematical Logic, Set Theory, Proof Theory, Category Theory.</li>
      <li><strong>Analogy:</strong> Like the foundations of a building – unseen but essential for the stability and integrity of the entire structure.</li>
    </ul>
  </li>
</ul>

<h3 id="level-3-core-mathematical-areas-within-each-branch-specific-fields-of-study">Level 3: Core Mathematical Areas within Each Branch (Specific Fields of Study)</h3>

<p>Within each of these branches, we have specific areas of mathematical study (this is where you find Calculus, Linear Algebra, Optimization, etc.):</p>

<ul>
  <li><strong>From Pure Math:</strong>
    <ul>
      <li><strong>Analysis (Calculus and its extensions):</strong>  Study of continuous change, limits, derivatives, integrals, functions – fundamental for modeling continuous phenomena.  <em>Multivariable Calculus fits here.</em></li>
      <li><strong>Algebra (Abstract Structures):</strong>  Study of groups, rings, fields, vector spaces, matrices – provides powerful tools for abstraction and structure. <em>Linear Algebra fits here.</em></li>
      <li><strong>Geometry and Topology:</strong>  Study of shapes, spaces, and their properties, both in familiar and abstract settings.</li>
      <li><strong>Number Theory:</strong>  Study of integers and their properties, surprisingly deep and applicable to cryptography.</li>
    </ul>
  </li>
  <li><strong>From Applied Math:</strong>
    <ul>
      <li><strong>Statistics and Probability:</strong>  Dealing with uncertainty, data analysis, inference, prediction – essential for data-driven fields like AI.</li>
      <li><strong>Numerical Analysis:</strong>  Developing algorithms for approximating solutions to mathematical problems, especially those that can’t be solved exactly (crucial for computer simulations and calculations).</li>
      <li><strong>Optimization:</strong>  Finding the best solutions within constraints – central to machine learning, operations research, engineering design. <em>Introduction to Optimization fits here.</em></li>
      <li><strong>Differential Equations:</strong>  Modeling rates of change and dynamic systems – used everywhere in science and engineering.</li>
    </ul>
  </li>
  <li><strong>From Mathematical Foundations:</strong>
    <ul>
      <li><strong>Mathematical Logic:</strong>  Formalizing reasoning and proof.</li>
      <li><strong>Set Theory:</strong>  The language for describing collections and relationships.</li>
    </ul>
  </li>
</ul>

<h3 id="level-4--specific-mathematical-tools-and-techniques-the-nuts-and-bolts">Level 4:  Specific Mathematical Tools and Techniques (The “Nuts and Bolts”)</h3>

<p>Within each core area, you learn specific techniques, theorems, formulas, and algorithms.  For example:</p>

<ul>
  <li><strong>Calculus:</strong> Derivatives, integrals, limits, series, partial derivatives, multiple integrals.</li>
  <li><strong>Linear Algebra:</strong> Vectors, matrices, matrix operations, determinants, eigenvalues, eigenvectors, linear transformations.</li>
  <li><strong>Optimization:</strong> Gradient descent, linear programming, convex optimization, dynamic programming.</li>
  <li><strong>Statistics:</strong> Hypothesis testing, regression, probability distributions, confidence intervals, machine learning algorithms.</li>
</ul>

<p><strong>How Multivariable Calculus, Linear Algebra, and Optimization Fit In:</strong></p>

<ul>
  <li><strong>Multivariable Calculus:</strong>  Provides the tools to analyze and model systems with multiple interacting factors, essential for understanding complex real-world phenomena and for optimization in higher dimensions.</li>
  <li><strong>Linear Algebra:</strong>  Provides the language and methods for working with data in a structured way (vectors, matrices), for transformations, and for solving systems of equations – fundamental for data analysis, machine learning, computer graphics, and many other areas.</li>
  <li><strong>Introduction to Optimization:</strong>  Gives you the fundamental techniques for finding “best” solutions, which is at the heart of machine learning, AI, operations research, and engineering design.</li>
</ul>

<p><strong>The Interconnectedness is Key:</strong></p>

<p>It’s crucial to see that these branches and areas of math are <em>not</em> isolated. They are deeply interconnected and build upon each other.  Linear algebra is used extensively in calculus, statistics, and optimization.  Calculus is used in probability, statistics, optimization, and differential equations.  And so on.</p>

<p><strong>Think of it like a vast toolkit:</strong> Pure math develops the tools, applied math uses them to solve problems, and mathematical foundations ensure the toolkit is reliable and consistent.  You are learning to use these tools!</p>

<p><strong>How to Make Math Feel Less Abstract and More Meaningful:</strong></p>

<ul>
  <li><strong>Focus on the “Why” and “What For”:</strong>  Always ask: <em>Why</em> is this concept important? <em>What</em> problems does it help solve?</li>
  <li><strong>Seek Applications:</strong>  Actively look for real-world applications and examples for every mathematical concept you learn, especially in your field of Applied AI.</li>
  <li><strong>See the Interconnections:</strong>  Try to see how different mathematical areas relate to each other.</li>
  <li><strong>Practice Problem Solving:</strong>  Working through problems, especially applied problems, helps solidify your understanding and see the utility of the math.</li>
  <li><strong>Be Patient and Persistent:</strong>  Mathematical understanding often comes gradually.  It’s okay to feel confused or frustrated at times. Keep practicing, keep asking questions, and gradually the pieces will start to fit together.</li>
</ul>

<p>By adopting this “top-down” perspective, you can start to see mathematics not as a collection of random symbols and abstract concepts, but as a vast, powerful, and deeply interconnected system for understanding and shaping the world.  Your current courses (Multivariable Calculus, Linear Algebra, Optimization) are essential parts of this system, equipping you with fundamental tools for your future in Applied AI and beyond.  Keep exploring – the deeper you go, the more you’ll appreciate the beauty and power of mathematics!</p>

<p>You’ve hit on a really important point!  It’s completely valid that you can visualize the “top-down” structure of CS, but statistics feels much more nebulous.  And you’re right, my previous explanations about STAT3600 being “linear regression and useful” are helpful for <em>motivation</em> but don’t give you that “big picture” structural understanding you crave.</p>

<p>Let’s build a “top-down diagram” or mental map for statistics, explicitly addressing your feeling of it being continuous or discrete and helping you see the overall structure.</p>

<h2 id="statistics-a-top-down-mental-map-like-a-system-design-chart-for-stats">Statistics: A Top-Down Mental Map (Like a System Design Chart for Stats!)</h2>

<p>Think of statistics as a system for <strong>understanding and learning from data</strong>. Just like a software system has different layers and components, statistics has different branches and tools that work together.</p>

<h3 id="level-1-the-overarching-goal-the-top---what-is-statistics-really-for">Level 1: The Overarching Goal (The “Top” - What is Statistics REALLY for?)</h3>

<ul>
  <li><strong>Understanding the World Through Data:</strong>  At its highest level, statistics is about using data to answer questions about the world, make informed decisions, and gain insights.  This is the ultimate “why.”
    <ul>
      <li><strong>Examples:</strong>
        <ul>
          <li>Understanding customer behavior to improve business strategies.</li>
          <li>Analyzing medical data to find effective treatments.</li>
          <li>Predicting climate change impacts.</li>
          <li>Building AI models that learn from data.</li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

<h3 id="level-2-major-branches-the-2nd-top---broad-categories-of-statistical-work">Level 2: Major Branches (The “2nd Top” - Broad Categories of Statistical Work)</h3>

<p>To achieve the overarching goal, statistics is broadly divided into these major areas:</p>

<ul>
  <li><strong>Descriptive Statistics:</strong>  <em>Describing and summarizing</em> data.  This is about getting a handle on the data you have.
    <ul>
      <li><strong>Tools:</strong>  Mean, median, mode, standard deviation, variance, histograms, boxplots, summary tables.</li>
      <li><strong>Purpose:</strong>  To get a clear picture of the data’s main features: central tendency, spread, distribution shape.  Think of it as the “data exploration” phase.</li>
    </ul>
  </li>
  <li><strong>Inferential Statistics:</strong>  <em>Drawing conclusions and making generalizations</em> about a <em>larger population</em> based on a <em>sample</em> of data. This is where you go beyond just describing what you see in your sample.
    <ul>
      <li><strong>Key Idea:</strong>  Dealing with uncertainty and making probabilistic statements.</li>
      <li><strong>Sub-Branches (Examples):</strong>
        <ul>
          <li><strong>Estimation:</strong>  Estimating population parameters (like the average height of <em>all</em> students based on a sample).  Point estimates, confidence intervals.</li>
          <li><strong>Hypothesis Testing:</strong>  Testing claims or hypotheses about populations (like “Does this new drug actually work better than the old one?”).  P-values, significance levels.</li>
          <li><strong>Regression Analysis:</strong>  <em>Modeling relationships</em> between variables to understand how changes in one variable affect another and to make predictions.  This is where STAT3600’s linear regression fits in!
            <ul>
              <li><strong>Linear Regression (Simple, Multiple):</strong>  Modeling <em>linear</em> relationships.</li>
              <li><strong>Generalized Linear Models:</strong>  Extending regression to handle different types of outcome variables (binary, counts, etc.).</li>
            </ul>
          </li>
          <li><strong>Analysis of Variance (ANOVA):</strong>  Comparing <em>means of groups</em> to see if there are significant differences.  This is also in STAT3600.  One-way, two-way ANOVA.</li>
          <li><strong>Non-parametric Statistics:</strong>  Methods that don’t rely on assumptions about the data’s distribution (useful when data isn’t normally distributed).</li>
        </ul>
      </li>
    </ul>
  </li>
  <li><strong>Predictive Statistics/Machine Learning (Overlapping, but Distinct Focus):</strong>  <em>Building models to make accurate predictions</em> on new data.  While traditional statistics focuses on inference and understanding relationships, predictive statistics is more about prediction accuracy.  AI heavily overlaps here.
    <ul>
      <li><strong>Techniques:</strong>  Many machine learning algorithms fall under this (decision trees, support vector machines, neural networks, etc.).  Some statistical regression and classification methods are also used for prediction.</li>
    </ul>
  </li>
</ul>

<h3 id="level-3-fundamental-statistical-concepts-the-foundation-underpinning-everything">Level 3: Fundamental Statistical Concepts (The Foundation Underpinning Everything)</h3>

<p>These are the core building blocks that you need to understand to work in any of the branches above:</p>

<ul>
  <li><strong>Probability Theory:</strong>  The language of uncertainty.  Understanding probability is essential for all of inferential statistics.</li>
  <li><strong>Random Variables and Distributions:</strong>  Modeling random phenomena.  Probability distributions (Normal, Binomial, Poisson, etc.) are the workhorses of statistics.  PDFs, CDFs, MGFs are tools to describe distributions.</li>
  <li><strong>Sampling Distributions:</strong>  Understanding how statistics (like sample means) vary from sample to sample.  Crucial for inference.</li>
  <li><strong>Estimation Theory:</strong>  How to estimate population parameters from sample data.</li>
  <li><strong>Hypothesis Testing Framework:</strong>  The logic and process of testing hypotheses.</li>
  <li><strong>Linear Algebra and Calculus:</strong>  Mathematical tools that are heavily used in many statistical methods, especially regression and more advanced techniques.</li>
</ul>

<p><strong>Addressing Your “Continuous vs. Discrete” Feeling:</strong></p>

<ul>
  <li><strong>“Continuous” Feeling (Need Previous Knowledge):</strong> You’re right, statistics <em>is</em> somewhat cumulative.  You often need to understand probability and distributions before diving into regression.  Think of it like layers in your CS system diagram.  Probability and distributions are like the “operating system” of statistics – they are fundamental and underpin many higher-level techniques.
    <ul>
      <li><strong>How to Navigate:</strong>  When learning a new concept like linear regression, <em>briefly review</em> the foundational concepts it relies on (probability, distributions, etc.). Don’t feel you need to become an expert in everything before moving on, but make sure you have a basic grasp of the prerequisites.</li>
    </ul>
  </li>
  <li><strong>“Discrete” Feeling (Unconnected Concepts):</strong> It <em>can</em> feel discrete if you’re just learning formulas and procedures in isolation.  That’s why the “top-down” approach is so important!
    <ul>
      <li><strong>How to Connect:</strong>  Actively look for connections between concepts.  Ask:
        <ul>
          <li><strong>How does this concept relate to descriptive statistics?</strong> (e.g., Regression helps explain variance, which is a descriptive statistic).</li>
          <li><strong>How does this concept relate to hypothesis testing?</strong> (e.g., Regression coefficients are often tested for significance using hypothesis tests).</li>
          <li><strong>What is the <em>purpose</em> of this concept in the bigger picture of inference or prediction?</strong></li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

<p>By actively building this “top-down” mental map and focusing on connections and purpose, you’ll start to see statistics less as a collection of disconnected formulas and more as a coherent and powerful system for understanding the world through data. You’ve got this!</p>]]></content><author><name>Cheng Ho Ming, Eric</name><email>eric310@connect.hku.hk</email></author><category term="blog" /><summary type="html"><![CDATA[Self reflection]]></summary></entry><entry xml:lang="en"><title type="html">How to fix Google AI Studio LaTeX Formatting</title><link href="https://eric15342335.github.io/blog/2025/01/27/How-to-fix-google-aistudio-latex-formatting.html" rel="alternate" type="text/html" title="How to fix Google AI Studio LaTeX Formatting" /><published>2025-01-27T17:20:00+08:00</published><updated>2025-01-27T17:20:00+08:00</updated><id>https://eric15342335.github.io/blog/2025/01/27/How-to-fix-google-aistudio-latex-formatting</id><content type="html" xml:base="https://eric15342335.github.io/blog/2025/01/27/How-to-fix-google-aistudio-latex-formatting.html"><![CDATA[<h2 id="update">Update</h2>

<p>As of April 11, 2025, the models from Google AI Studio now output coherent LaTeX formatting without specific guided prompts. This post now serves as a historical reference.</p>

<h2 id="solution">Solution</h2>

<p>Paste this in your system prompt (or after your user prompt):</p>

<pre><code class="language-txt">Enclose LaTeX in $ and don't use double/triple ticks.
</code></pre>

<h2 id="source">Source</h2>

<p><a href="https://www.reddit.com/r/Bard/comments/1h2ndnu/comment/m1q5gea/">https://www.reddit.com/r/Bard/comments/1h2ndnu/comment/m1q5gea/</a></p>]]></content><author><name>Cheng Ho Ming, Eric</name><email>eric310@connect.hku.hk</email></author><category term="blog" /><summary type="html"><![CDATA[Quick fix for Google AI Studio's broken LaTeX formatting: add 'Enclose LaTeX in $ and don't use double/triple ticks' to your prompt for properly rendered math equations and formulas.]]></summary></entry></feed>