display.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:data-analysis 作者: ymohanty 项目源码 文件源码
def generateRandomData(self, event=None):
        print "X-Direction:", self.distribution[0]
        print "Y-Direction:", self.distribution[1]
        dx = 3
        dy = 3
        for i in range(int(self.num_pts.get())):
            if self.distribution[0] == "Uniform":
                x = random.randint(dx, self.canvas.winfo_width() - dx)
            else:
                # According to Adam Carlson, there's 99.8% chance that data in a normal distribution is within 3 standard deviations of the mean.
                # mu = mean, sigma = standard deviation. Look and infer.
                x = random.gauss(mu=(self.canvas.winfo_width() - dx) / 2, sigma=self.canvas.winfo_width() / 6)
            if self.distribution[1] == "Uniform":
                y = random.randint(dy, self.canvas.winfo_height() - dy)
            else:
                y = random.gauss(mu=(self.canvas.winfo_height() - dy) / 2, sigma=self.canvas.winfo_height() / 6)

            # make sure that the coords are not out of bounds!
            x %= self.canvas.winfo_width() - dx / 2
            y %= self.canvas.winfo_height() - dy / 2

            pt = self.canvas.create_oval(x - dx, y - dy, x + dx, y + dy, fill=self.colorOption.get(), outline='')
            self.objects.append(pt)

    # handle the clear command
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号