public void sampleTable(int type, int table) {
        double d = discount.doubleVal();
        double c = concentration.doubleVal();
        int[] tsa = tableMap.get(type);
        int tt = 0;
        int tc = -1;

        for (int i = 0; i < tsa.length; i++) {
            tc += tsa[i];
            if (tsa[i] > 0) {
                tt++;
            }
        }

        int customersToSample = tsa[table];
        for (int iter = 0; iter < customersToSample; iter++) {
            int zeroInd = -1;

            tsa[table] -= 1;
            if (tsa[table] == 0) {
                zeroInd = table;
                parent.unseat(type);
                tables -= 1;
                tt--;
            }

            double r = RNG.nextDouble();
            double cuSum = 0.0;
            double pp = parent.predictiveProbability(type);
            double totalWeight = tc - tt * d + (tables * d + c) * pp;

            for (int i = 0; i < tsa.length; i++) {
                if (tsa[i] > 0) {
                    cuSum += (tsa[i] - d) / totalWeight;
                } else {
                    zeroInd = i;
                }
                if (cuSum > r) {
                    tsa[i] += 1;
                    break;
                }
            }

            if (cuSum <= r) {
                tables += 1;
                tt++;
                parent.seat(type);
                if (zeroInd > -1) {
                    tsa[zeroInd] += 1;
                } else {
                    int[] ntsa = new int[tsa.length + 1];
                    System.arraycopy(tsa, 0, ntsa, 0, tsa.length);
                    ntsa[tsa.length] = 1;
                    tableMap.put(type, ntsa);
                    tsa = ntsa;
                }
            }
        }
    }