Exemple #1
0
    def distributionPlot(mode, median, maximum, color):
        """
        Plot data from a randomly generated LogNornal distribution.

        @param mode: distribution mode
        @type mode: L{float}
        @param median: distribution median
        @type median: L{float}
        @param maximum: highest x-value to allow
        @type maximum: L{float}
        @param color: color to use for line in plot
        @type color: L{str}
        """
        distribution = LogNormalDistribution(mode=mode,
                                             median=median,
                                             maximum=maximum)
        result = defaultdict(int)
        for _ignore in range(1000000):
            s = int(distribution.sample()) + 0.5
            result[s] += 1

        x, y = zip(*sorted(result.items()))
        plt.plot(x, y, color=color)

        peak_y = LogNormal.fn(distribution._scale, distribution._mu,
                              distribution._sigma, distribution._scale, 1.0)
        scale_y = sum(sorted(y, reverse=True)[0:100]) / 100.0 / peak_y

        return (
            x,
            y,
            LogNormal.Params(distribution._mu, distribution._sigma,
                             distribution._scale, scale_y),
        )
Exemple #2
0
 def setParameters(
     self,
     enabled=True,
     sendInvitationDistribution=NormalDistribution(600, 60),
     inviteeDistribution=UniformDiscreteDistribution(range(-10, 11)),
     inviteeClumping=True,
     inviteeCountDistribution=LogNormalDistribution(1.2, 1.2),
     eventStartDistribution=NearFutureDistribution(),
     eventDurationDistribution=UniformDiscreteDistribution([
         15 * 60, 30 * 60,
         45 * 60, 60 * 60,
         120 * 60
     ]),
     recurrenceDistribution=RecurrenceDistribution(False),
     fileAttachPercentage=30,
     fileSizeDistribution=NormalDistribution(1024, 1),
     inviteeLookupPercentage=50,
 ):
     self.enabled = enabled
     self._sendInvitationDistribution = sendInvitationDistribution
     self._inviteeDistribution = inviteeDistribution
     self._inviteeClumping = inviteeClumping
     self._inviteeCountDistribution = inviteeCountDistribution
     self._eventStartDistribution = eventStartDistribution
     self._eventDurationDistribution = eventDurationDistribution
     self._recurrenceDistribution = recurrenceDistribution
     self._fileAttachPercentage = fileAttachPercentage
     self._fileSizeDistribution = fileSizeDistribution
     self._inviteeLookupPercentage = inviteeLookupPercentage