使用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 Process
import pylab as pl
# defining factorial function
k = 0
def fact(num):
facto = 1
while num>0:
facto = facto*num
num = num - 1
return facto    
# print(fact(5)) #// for checking
# Defining power function
def exp(num,po):
ex = 1
while po>0:
ex = ex*num
po = po - 1
return 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 = k
def Binomial(N,k,pr):
BinCoef = (fact(N)/(fact(N-k)*fact(k)))
ProRatio = (exp(pr,k)*exp(1-pr,N-k))
Probability = BinCoef*ProRatio
return Probability
N = 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 + 1
pl.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]

binomial process output

翻译自: https://www.includehelp.com/python/binomial-process.aspx

使用python学线性代数

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/543963.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

工作中常见的 6 种设计模式,你用过几种?

前言 哈喽&#xff0c;大家好。平时我们写代码呢&#xff0c;多数情况都是流水线式写代码&#xff0c;基本就可以实现业务逻辑了。如何在写代码中找到乐趣呢&#xff0c;我觉得&#xff0c;最好的方式就是&#xff1a;使用设计模式优化自己的业务代码。今天跟大家聊聊日常工作中…

c#抽象属性_C#中的抽象属性

c#抽象属性C&#xff03;抽象属性 (C# Abstract properties) An abstract may contain some abstract properties. That can be implemented in derived class. Here we use abstract and override keywords. 抽象可能包含一些抽象属性。 可以在派生类中实现 。 在这里&#xf…

这12款idea插件,能让你代码飞起来!

前言基本上每个程序员都会写代码&#xff0c;但写代码的速度不尽相同。为什么有些人&#xff0c;一天只能写几百行代码&#xff1f;而有些人&#xff0c;一天可以写几千行代码&#xff1f;有没有办法&#xff0c;可以提升开发效率&#xff0c;在相同的时间内&#xff0c;写出更…

node js 开发网站_使用Node JS开发网站

node js 开发网站You will have your own fully functional website running on "localhost" after going through this article. 阅读完本文后&#xff0c;您将在“ localhost”上运行自己的功能齐全的网站 。 Basic knowledge of JavaScript and HTML is a prereq…

hdu 1166 敌兵布阵

Problem DescriptionC国的死对头A国这段时间正在进行军事演习&#xff0c;所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段&#xff0c;所以每个工兵营地…

Java:LocalDate / LocalDateTime加减时间

在线API参考&#xff1a;LocalTime (Java Platform SE 8 ) 方法介绍 方法1方法1说明plusYears(long years) minusYears(long years) 返回增加/减少了年数的副本plusMonths(long months) minusMonths(long months)返回增加/减少了月数的副本plusWeeks(long weeks) minusWeeks(…

集合 List 分片的 5 种实现

作者 | 磊哥来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;前些天在实现 MyBatis 批量插入时遇到了一个问题&#xff0c;当批量插入的数据量比较大时&#xff0c;会导致程序执行报错&a…

消失的死锁

问题描述 如果java层面发生了死锁&#xff0c;当我们使用jstack命令的时候其实是可以将死锁的信息给dump出来的&#xff0c;在dump结果的最后会有类似Found one Java-level deadlock:的关键字&#xff0c;接着会把发生死锁的线程的堆栈及对应的同步锁给打印出来&#xff0c;这次…

ruby 新建对象_Ruby中的面向对象编程

ruby 新建对象Before getting into understanding how Object-oriented programming is implemented in Ruby, let us first understand what Object Oriented means. 在了解如何在Ruby中实现面向对象的编程之前&#xff0c;让我们首先了解面向对象的含义。 Object-oriented p…

使用它给 ​xxl-job 添加任务,太爽了

xxl-job是一款非常优秀的任务调度中间件&#xff0c;轻量级、使用简单、支持分布式等优点&#xff0c;让它广泛应用在我们的项目中&#xff0c;解决了不少定时任务的调度问题。我们都知道&#xff0c;在使用过程中需要先到xxl-job的任务调度中心页面上&#xff0c;配置执行器ex…

dubboSPI机制浅谈

2019独角兽企业重金招聘Python工程师标准>>> &#xfeff;&#xfeff;&#xfeff;本文重点讲述SPI机制&#xff0c;从jdk和dubbo 1、jdk spi机制 2、dubbo spi实现 首先spi是什么&#xff1f; SPI是为某个接口寻找服务实现的机制。为了实现在模块装配的时候能不在…

python 类中静态变量_Python中的类或静态变量

python 类中静态变量Python类/静态变量 (Python Class / Static Variables) Class or Static variables are class-related variables that are shared among all objects but the instance or non-static variable is unique for each object. In Python, there is no need fo…

彻底搞懂 SpringBoot 中的 starter 机制

前言我们都知道&#xff0c;Spring的功能非常强大&#xff0c;但也有些弊端。比如&#xff1a;我们需要手动去配置大量的参数&#xff0c;没有默认值&#xff0c;需要我们管理大量的jar包和它们的依赖。为了提升Spring项目的开发效率&#xff0c;简化一些配置&#xff0c;Sprin…

android四大组件之Service 注册广播接收者

广播的注册一共有两种&#xff0c;一种就是用清单文件注册&#xff0c;还有另外一种就是用代码注册&#xff0c;代码注册比较灵活&#xff0c;可以在需要的时候注册&#xff0c;不需要的时候解除注册 用服务注册广播首先要开启服务&#xff0c; 然后在服务oncreate方法里注册广…

c ++向量库_将向量复制到C ++中的另一个向量

c 向量库The ways that we are using to copy vectors in C, are: 我们用于在C 中复制向量的方法是&#xff1a; Copy one vectors elements to another (Simple approach) 将一个向量的元素复制到另一个(简单方法) Copy vector by using an assignment operator 通过使用赋值…

Java 中验证时间格式的 4 种方法

大家好&#xff0c;今天咱们来讲一下&#xff0c;Java 中如何检查一个字符串是否是合法的日期格式&#xff1f;为什么要检查时间格式&#xff1f;后端接口在接收数据的时候&#xff0c;都需要进行检查。检查全部通过后&#xff0c;才能够执行业务逻辑。对于时间格式&#xff0c…

FreeSWITCH的TLS加密

听着很高大上&#xff08;实际也很实用&#xff09;的加密机制&#xff0c;在FreeSWITCH里配置支持竟然这么简单&#xff01; Greate FreeSWITCH and Greate Programmer&#xff01; ① cd /usr/local/freeswitch/bin&#xff08;以默认的安装路径为例&#xff09; ② 产生root…

kotlin 查找id_Kotlin程序查找Sphere的体积

kotlin 查找idFormula to find volume of Sphere: volume (4/3)*PI*r^3 查找球体体积的公式&#xff1a; volume (4/3)* PI * r ^ 3 Given the value of radius, we have to find the volume of Sphere. 给定半径的值&#xff0c;我们必须找到球体的体积。 Example: 例&#…

Redis 实现分布式锁的 7 种方案

前言日常开发中&#xff0c;秒杀下单、抢红包等等业务场景&#xff0c;都需要用到分布式锁。而Redis非常适合作为分布式锁使用。本文将分七个方案展开&#xff0c;跟大家探讨Redis分布式锁的正确使用方式。如果有不正确的地方&#xff0c;欢迎大家指出哈&#xff0c;一起学习一…

css复选框样式_使用CSS样式复选框

css复选框样式Introduction: 介绍&#xff1a; Sometimes we want to develop a website or web page that would contain a form and through that form, we want to get some information from the user. Now that information could be of any type depending on the kind …