@staticmethod
    def randomChoice(V, n=1):
        Parameter.checkClass(V, numpy.ndarray)

        if V.shape[0]==0:
            return -1 

        if V.ndim == 1:
            cumV = numpy.cumsum(V)
            p = numpy.random.rand(n)*cumV[-1]
            return numpy.searchsorted(cumV, p)
        elif V.ndim == 2:
            cumV = numpy.cumsum(V, 1)
            P = numpy.random.rand(V.shape[0], n)*numpy.array([cumV[:, -1]]).T

            inds = numpy.zeros(P.shape, numpy.int)
            for i in range(P.shape[0]):
                inds[i, :] = numpy.searchsorted(cumV[i, :], P[i, :])

            return inds
        else:
            raise ValueError("Invalid number of dimensions")
Decode extra event data from an alert or log
dataset/ETHPy150Open charanpald/APGL/apgl/util/Util.py/Util.randomChoice--crossover with--dataset/ETHPy150Open openstack/pyghmi/pyghmi/ipmi/events.py/decode_eventdata