python 一般AP统计概率模拟脚本。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 一般AP统计概率模拟脚本。相关的知识,希望对你有一定的参考价值。

# Faizaan Datoo Pd3
# A very simple example of using technology to automate simulations :)
# I /could/ have made it more complicated, but that would defeat the point!

import random

print "Enter a range of digits."

# Get those numbers...
minVal = input("\tYour minimum value: ")
maxVal = input("\tYour maximum value: ")
repetitions = input("\tAmount of repetitions: ")
perRepetition = input("\tAmount of random numbers per repetition: ")
ignoreRepeats = raw_input("\tIgnore repeats? (y/n): ")

print "Okay, crunching some numbers..."
tries = []

for i in range(repetitions):
    print "=== Repetition #" + str(i + 1) + " ==="
    history = []
    
    for j in range(perRepetition):
        # Generate random values, print them out
        generated = random.randrange(minVal, maxVal)

        # Check for duplicates if we have to!
        if ignoreRepeats == "y":
            while (generated in history):
                generated = random.randrange(minVal, maxVal)
            history.append(generated)
            
        print str(generated) + " ",
       
print "Done. Enjoy!"

以上是关于python 一般AP统计概率模拟脚本。的主要内容,如果未能解决你的问题,请参考以下文章

概率论与数理统计python实验

干货书用于概率统计和机器学习的Python,288页pdf

蒙特卡洛模拟求解概率统计中的抽奖问题C语言实现

统计学入门级:常见概率分布+python绘制分布图

《统计思维程序员数学之概率统计第2版》中英文PDF+数据代码+《面向数据科学家的实用统计学》中英文PDF+源代码+学习总结

监控无线AP是否在线python脚本