使用python学线性代数_二项式过程| 使用Python的线性代数
使用python學線性代數
When we flip a coin, there are two possible outcomes as head or tail. Each outcome has a fixed probability of occurrence. In the case of fair coins, heads and tails each have the same probability of 1/2. In addition, there are cases in which the coin is biased, so that heads and tails have different probabilities of occurrence. Coin toss experiment for number of n trails can be called as a binomial distribution.
當我們擲硬幣時,有兩個結果可能是正面還是反面。 每個結果都有固定的發生概率。 對于公平硬幣,正面和反面的概率分別為1/2。 此外,在某些情況下,硬幣會有偏差,因此正面和反面的出現概率不同。 n次追蹤的硬幣折騰實驗可以稱為二項分布 。
As per Wikipedia Definition: In probability theory and statistics, the binomial distribution with parameters n and p is the discrete probability distribution of the number of successes in a sequence of n independent experiments, each asking a yes–no question, and each with its own boolean-valued outcome: success/yes/true/one (with probability p) or failure/no/false/zero (with probability q = 1 ? p). A single success/failure experiment is also called a Bernoulli trial or Bernoulli experiment and a sequence of outcomes is called a Bernoulli process; for a single trial, i.e., n = 1, the binomial distribution is a Bernoulli distribution. The binomial distribution is the basis for the popular binomial test of statistical significance.
根據Wikipedia的定義 : 在概率論和統計學中,參數n和p的二項式分布是n個獨立實驗序列中成功次數的離散概率分布,每個獨立實驗詢問一個是非問題,每個實驗都有其自己的布爾值結果:成功/是/正確/一個(概率為p)或失敗/否/錯誤/零(概率為q = 1-p)。 一個成功/失敗的實驗也稱為伯努利試驗或伯努利實驗,一系列結果稱為伯努利過程。 對于單項試驗,即n = 1,二項式分布是伯努利分布。 二項式分布是流行的具有統計意義的二項式檢驗的基礎。
Here, we will learn to create a binomial distribution using python with Probability parameter p = 0.1.
在這里,我們將學習使用概率參數p = 0.1的 python創建二項分布。
二項式過程的Python代碼 (Python code for Binomial Process)
# Linear Algebra Learning Sequence # Binomial Processimport pylab as pl# defining factorial function k = 0 def fact(num):facto = 1while num>0:facto = facto*numnum = num - 1return facto # print(fact(5)) #// for checking# Defining power function def exp(num,po):ex = 1while po>0:ex = ex*numpo = po - 1return ex # print(exp(2,8)) #// for checking# Implementation of Binomial Process # Probability of K arrivals with # probability of arrival as pr # not arrival probability is 1-pr # P = n!/(n-r)!*r! * p^r * (1-p)^n-r # r = kdef Binomial(N,k,pr):BinCoef = (fact(N)/(fact(N-k)*fact(k)))ProRatio = (exp(pr,k)*exp(1-pr,N-k))Probability = BinCoef*ProRatioreturn ProbabilityN = 1 n = 1 k = 1 pr = 0.1 prn = 0.9# Use of Vector to save data and # further algebric manipulation x = [] y = []while n<40:x.append(n)y.append(Binomial(n,k,pr))n = n + 1pl.plot(x,y)print('Binomial Process Vector : ', y)Output:
輸出:
Binomial Process Vector : [0.1, 0.18000000000000002, 0.24300000000000005, 0.2916, 0.32805000000000006, 0.3542940000000001, 0.37200870000000014, 0.3826375200000001, 0.38742048900000015, 0.3874204890000002, 0.3835462841100002, 0.37657271530800024, 0.36715839742530026, 0.3558612159660602, 0.3431518868244152, 0.32942581135143856, 0.3150134321048131, 0.3001892705939984, 0.2851798070642985, 0.27017034353459857, 0.25531097464019564, 0.24072177608932738, 0.22649730750223074, 0.2127105148716602, 0.19941610769218143, 0.18665347679988184, 0.17444921100912034, 0.16281926360851232, 0.1517708135779347, 0.14130386091738747, 0.13141259065317037, 0.1220865358326228, 0.11331156606965304, 0.10507072490095098, 0.09734493630529284, 0.09011359817975681, 0.08335507831627505, 0.07704712644369205, 0.07116721416246292]翻譯自: https://www.includehelp.com/python/binomial-process.aspx
使用python學線性代數
總結
以上是生活随笔為你收集整理的使用python学线性代数_二项式过程| 使用Python的线性代数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 优化的交换排序(冒泡排序)_C程序实现优
- 下一篇: python 寻找数组的中心索引_Lee