JsLatex Awesomeness

In need of being able to write \LaTeX on my blog, I was looking for a quick and easy solution. JsLatex to the rescue!

You can find it at JsLatex. It requires JQuery. Just add it to your page, then add a bit of javascript like the following in your document.ready() function:


Then all you have to do is add a span with the class of “latex” with some latex in the middle, and they all get converted on the fly. It’s not a perfect solution, I’d like to implement some caching at some point, but seen as I’m doing a full time job and 1\frac{1}{4} full time degrees, I may postpone that for a while.

Here's something in \LaTeX that I learned today - there are so many things that I was taught at school that I'm revisiting from the perspective of calculus, and they make a hell of a lot more sense. One of these is that of expected value:

E[f(x)] = \int_{-\infty}^{\infty} \! f(x)P(x) \, \mathrm{d}x

The above makes total sense.

If you take the case where f(x) = x, you get the mean, which is just the sum of all the possible values of x times the probability of the respective value.

For a discrete variable, this can be related to the standard school method of "add up all the values and divide by the number of values", by making the function P:

P(x) = \begin{cases} \frac{1}{N}\ if\ x \in values\\\ 0\ otherwise \end{cases}

It's easy to see that this leaves us with a sum of all the discrete values divided by the number of values. Taking the division outside of the sum, it's just the sum of the values divided by the number of values!

Also, for the standard deviation, we get:

\sqrt{E[(x \- \mu)^2]} = \sqrt{\int_{-\infty}^{\infty} \! (x \- \mu)^2P(x) \, \mathrm{d}x}