function probabilityStatTexture(ketTexture, controlTexture, rangeOffset, rangeLength) {
    let trader = new WglTextureTrader(ketTexture);
    trader.dontDeallocCurrentTexture();
    let n = currentShaderCoder().vec2.arrayPowerSizeOfTexture(ketTexture);

    trader.shadeAndTrade(tex => amplitudesToProbabilities(tex, controlTexture), WglTexturePool.takeVecFloatTex(n));
    trader.shadeAndTrade(tex => GateShaders.cycleAllBitsFloat(tex, -rangeOffset));

    while (n > rangeLength) {
        n -= 1;
        trader.shadeHalveAndTrade(Shaders.sumFoldFloat);
    }

    if (currentShaderCoder().float.needRearrangingToBeInVec4Format) {
        trader.shadeQuarterAndTrade(Shaders.packFloatIntoVec4);
    }
    return trader.currentTexture;
}
Derives conditional computational basis measurement probabilities from the state vector.

@param {!WglTexture} ketTexture The texture storing the wavefunction.
@param {!WglTexture} controlTexture A precomputed texture storing a control mask set to 1 for satisfying states.
@param {!int} rangeOffset Which wire the probability display starts on.
@param {!int} rangeLength How many wires the probability display covers.
@returns {!WglTexture} Texture storing the probabilities. Not normalized.