Show HN: Quantum JavaScript
This site has such a pleasant UI, and the text output formatting is so beautiful and meticulous. It seems like a lot of small details at work here too, like the micro-UX with hover effects on a lot of these elements.Quantum anything is over my head, so I have no idea what I'm looking at, but it's really pretty at least.---Looking through the source, a few things pop out:- Wow, this thing was made entirely in Vanilla JS + CSS, no frameworks of anything. Not a SINGLE dependency in the whole library or site. You don't see that everyday.- In the code, maybe this is my not understanding, but it seems like the "quantum" bit is probabilities based on Math.random() calls?    const outcomes = matrix.rows.reduce(function (outcomes, row, i) {
      outcomes.push({
        state:
          "|" + parseInt(i, 10).toString(2).padStart(circuit.bandwidth, "0") + "⟩",
        probability: Math.pow(row[0].absolute(), 2),
      });
      return outcomes;
    }, []);

    //  We need to “stack” our probabilities from 0..1.

    const outcomesStacked = new Array(this.results.length);
    this.results.reduce(function (sum, outcome, i) {
      sum += outcome.probability;
      outcomesStacked[i] = sum;
      return sum;
    }, 0);

    //  Now we can pick a random number
    //  and return the first outcome
    //  with a probability equal to or greater than
    //  that random number.

    const randomNumber = Math.random(),
      randomIndex = outcomesStacked.findIndex(function (index) {
        return randomNumber <= index;
      });

Is this how quantum works "under the hood" so to speak?