Get probabilities.
161106
def get_probs(self, sampler=None, rerun=None, store=True):
        """"""
        if rerun is None:
            rerun = sampler is not None
        if self._probs is not None and not rerun:
            return self._probs
        if sampler is None:
            sampler = self.vqe.sampler
        probs = sampler(self.circuit, range(self.circuit.n_qubits))
        if store:
            self._probs = probs
        return probs
215050
def _updateEmissionProbabilities(self):
        
        observations_by_state = [self.model.collect_observations_in_state(self.observations, state)
                                 for state in range(self.model.nstates)]
        self.model.output_model.sample(observations_by_state)
996357
def _sample(probability_vec):
    """"""
    return map(int,
               numpy.random.random(probability_vec.size) <= probability_vec)
71724
def _chance(solution, pdf):
    
    # 1.0 - abs(bit - p) gives probability of bit given p
    return _prod([1.0 - abs(bit - p) for bit, p in zip(solution, pdf)])
1158227
def m_probs(self):
        """"""
        log_m = self.kernel.feature_log_prob_[self._match_class_pos()]

        return self._prob_inverse_transform(numpy.exp(log_m))
69949
def _compute_probabilities(miner_data, wait_blocks, sample_size):
    
    miner_data_by_price = tuple(sorted(
        miner_data,
        key=operator.attrgetter('low_percentile_gas_price'),
        reverse=True,
    ))
    for idx in range(len(miner_data_by_price)):
        low_percentile_gas_price = miner_data_by_price[idx].low_percentile_gas_price
        num_blocks_accepting_price = sum(m.num_blocks for m in miner_data_by_price[idx:])
        inv_prob_per_block = (sample_size - num_blocks_accepting_price) / sample_size
        probability_accepted = 1 - inv_prob_per_block ** wait_blocks
        yield Probability(low_percentile_gas_price, probability_accepted)
985371
def get_applicable_values(self):
        """"""
        return [v for v in self._values if v.is_active and not v.is_all_results]
1343768
private static int chooseWithProbability(double[] distances,
                                             double sum,
                                             double probability) {
        for (int j = 0; j < distances.length; ++j) {
            double probOfDistance = Math.pow(distances[j], 2) / sum;
            probability -= probOfDistance;
            if (probability <= EPSILON) {
                return j;
            }
        }
        return distances.length-1;
    }
335450
def sample_prob(probs, rand):
    
    return tf.nn.relu(tf.sign(probs - rand))
577953
def call
      probability = 1.0

      graders.each do |lambda|
        instance = lambda.call(description)
        probability *= instance.call.to_f ** instance.weight
      end

      probability
    end
108041
def _calculate_options(self):
        """"""
        _options = self._default_options.copy()
        _options.update(self.options)
        if self.options_param:
            _options.update(self.options_param)
        return _options
877883
def generator(self, random, args):
        """"""
        locations = [i for i in range(len(self.weights))]
        random.shuffle(locations)
        return locations
1320038
def get_selected_values(self, selection):
        """"""
        return [v for b, v in self._choices if b & selection]
534978
def print_probabilities(state: State, ndigits: int = 4,
                        file: TextIO = None) -> None:
    
    prob = bk.evaluate(state.probabilities())
    for index, prob in np.ndenumerate(prob):
        prob = round(prob, ndigits)
        if prob == 0.0:
            continue
        ket = "".join([str(n) for n in index])
        print(ket, ":", prob, file=file)
578920
def predict_proba(self, L):
        
        n = L.shape[0]
        Y_p = np.random.rand(n, self.k)
        Y_p /= Y_p.sum(axis=1).reshape(-1, 1)
        return Y_p
1368856
def _probs(state: np.ndarray, indices: List[int],
           num_qubits: int) -> List[float]:
    """"""
    # Tensor of squared amplitudes, shaped a rank [2, 2, .., 2] tensor.
    tensor = np.reshape(state, [2] * num_qubits)

    # Calculate the probabilities for measuring the particular results.
    probs = [
        np.linalg.norm(
                tensor[linalg.slice_for_qubits_equal_to(indices, b)]) ** 2
        for b in range(2 ** len(indices))]

    # To deal with rounding issues, ensure that the probabilities sum to 1.
    probs /= sum(probs) # type: ignore
    return probs
978102
def get(self):
        """"""
        return {k:v for k,v in list(self.options.items()) if k in self._allowed_graphics}