Wednesday, December 26, 2012

Quantum Circuit Simulator

All I wanted for Christmas was a quantum circuit simulator. So I wrote one in Javascript using NumericJS.

Check it out:

For a good "Hello world" circuit, here's the diagram for a Bell State...
Try evaluating it yourself and see that |00> or |11> are the only possible outcomes.

You can even compile your own circuits into gates to use in other circuits.

Construct a circuit that transforms a single qubit into |0> with 75% probability and |1> with 25% probability, such as:
Then compile that into gate "F" and use it to create a superposition of |00> with 75% prob and |11> with 25% prob, like this:
Let me know if you find any use out of this. And definitely let me know if you find any bugs.

Saturday, November 17, 2012

NumericJS Logistic Regression Classifier

The other day I posted about numericjs and provided a simple PCA implementation using it. Today I rewrote my logistic regression classifer using numericjs. Below is the commented sourcecode and demo in jsFiddle.

For the demo, you click on the large square (in the "Result" panel) to add a point. The dropdown box labeled "group" allows you to select the color of point to add. You can change the learning rate (alpha) and the regularization parameter (lambda) to see how it changes the classification.

In case you're using a feed reader and can't see the box below, click here.

Thursday, November 15, 2012

Numeric Javascript

I just recently found this javascript library. So far it's looking pretty good. I've always wanted some sort of Javascript equivalent to NumPy and while this isn't anywhere near that extreme, it does offer some pretty handy features.

Here's a jsFiddle I put together to show it performing a simple implementation of PCA (Principle Component Analysis) on a fictional dataset. The first component should have a slope of approximately 0.357

Here's a quick snippet, the actual PCA function using numericjs...

function pca(X{
        Return matrix of all principle components as column vectors
    var X.length;
    var sigma numeric.div(;
    return numeric.svd(sigma).U;

Wednesday, March 14, 2012

Pi Day Part 1

We've decided to celebrate a two part Pi day this year (to honor 3 . 14 and 15). It began with egg*pi (quiche)...

And ended with pot*pi...

Tomorrow should conclude with apple*pi and pizza*pi.

Friday, February 10, 2012

Today, Astro-Phys got a new JSON API for querying ephemerides. Enjoy!

Can now return planetary states in various units of measure and coefficients as either chebyshev or polynomial (also in various units).