ImageVerifierCode 换一换
格式:DOCX , 页数:21 ,大小:172.34KB ,
资源ID:7009673      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7009673.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(MATLAB函数和命令的用法.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

MATLAB函数和命令的用法.docx

1、MATLAB函数和命令的用法Binocdf二项式累积分布函数语法格式Y = binocdf(X,N,P)函数功能Y = binocdf(X,N,P) 计算X中每个X(i)的二项式累积分布函数,其中,N中对应的N(i)为试验数,P中对应的P(i)为每次试验成功的概率。Y, N, 和 P 的大小类型相同,可以是向量、矩阵或多维数组。输入的标量将扩展成一个数组,使其大小类型与其它输入相一致。The values in N must all be positive integers, the values in X must lie on the interval 0,N, and the value

2、s in P must lie on the interval 0, 1.The binomial cdf for a given value x and a given pair of parameters n and p is The result, y, is the probability of observing up to x successes in n independent trials, where the probability of success in any given trial is p. The indicator function I(0,1,.,n)(i)

3、ensures that x only adopts values of 0,1,.,n.示例若一个棒球队在一个赛季要比赛162场,每场比赛取胜的机会是50-50,则该队取胜超过100 场的概率为: 1-binocdf(100,162,0.5)ans = 0.0010433相关函数binofit | binoinv | binopdf | binornd | binostat | cdf附:二项式分布(binomial distribution )定义二项分布的概率密度函数为where k is the number of successes in n trials of a Bernoull

4、i process with probability of success p.The binomial distribution is discrete, defined for integers k = 0, 1, 2, . n, where it is nonzero.背景The binomial distribution models the total number of successes in repeated trials from an infinite population under the following conditions:Only two outcomes a

5、re possible on each of ntrials.The probability of success for each trial is constant.All trials are independent of each other.The binomial distribution is a generalization of the Bernoulli distribution; it generalizes to the multinomial distribution.参数Suppose you are collecting data from a widget ma

6、nufacturing process, and you record the number of widgets within specification in each batch of100. You might be interested in the probability that an individual widget is within specification. Parameter estimation is the process of determining the parameter, p, of the binomial distribution that fit

7、s this data best in some sense.One popular criterion of goodness is to maximize the likelihood function. The likelihood has the same form as the binomial pdf above. But for the pdf, the parameters (nandp) are known constants and the variable isx. The likelihood function reverses the roles of the var

8、iables. Here, the sample values (the xs) are already observed. So they are the fixed constants. The variables are the unknown parameters. MLE involves calculating the value of p that give the highest likelihood given the particular set of data.The function binofit returns the MLEs and confidence int

9、ervals for the parameters of the binomial distribution. Here is an example using random numbers from the binomial distribution with n=100 and p=0.9. r = binornd(100,0.9)r = 85 phat, pci = binofit(r,100)phat = 0.85pci = 0.76469 0.91355The MLE for parameterp is0.8800, compared to the true value of0.9.

10、 The 95% confidence interval forp goes from 0.7998 to0.9364, which includes the true value. In this made-up example you know the true value ofp. In experimentation you do not.示例The following commands generate a plot of the binomial pdf for n = 10 and p = 1/2.x = 0:10;y = binopdf(x,10,0.5);plot(x,y,+

11、) 相关内容Discrete Distributions附:二项式分布(网上)定义若某事件概率为p,现重复试验n次,该事件发生k次的概率为:P=C(k,n)pk(1-p)(n-k)C(k,n)表示组合数,即从n个事物中拿出k个的方法数。二项分布的概念考虑只有两种可能结果的随机试验,当成功的概率()是恒定的,且各次试验相互独立,这种试验在统计学上称为贝努里试验(Bernoullitrial)。如果进行n次贝努里试验,取得成功次数为X(X=0,1,n)的概率可用下面的二项分布概率公式来描述:P=C(X,n) X(1-)(n-X)式中的n为独立的贝努里试验次数,为成功的概率,(1-)为失败的概率,X

12、为在n次贝努里试验中出现成功的次数,C(X,n)表示在n次试验中出现X的各种组合情况,在此称为二项系数(binomialcoefficient)。内容简介二项分布,伯努里分布:进行一系列试验,如果1. 在每次试验中只有两种可能的结果,而且是互相对立的;2. 每次实验是独立的,与其它各次试验结果无关;3. 结果事件发生的概率在整个系列试验中保持不变,则这一系列试验称为伯努力试验。在这试验中,事件发生的次数为一随机事件,它服从二次分布。二项分布可以用于可靠性试验。可靠性试验常常是投入n个相同的式样进行试验T小时,而只允许k个式样失败,应用二项分布可以得到通过试验的概率。一个事件必然出现,就说它10

13、0%要出现。100%=1,所以100%出现的含义就是出现的概率P=1。即必然事件的出现概率为1。若掷一枚硬币,正面向上的结果的概率为0.5。反面向上的结果的概率也是0.5。则出现正面向上事件或者反面向上事件的概率就是0.5+0.5=1,即二者必居其一。若掷两次硬币,由独立事件的概率乘法定理那么两次都是正面(反面)向上的概率是0.50.5=0.25。另外第一个是正第二个是反的出现概率也是0.50.5=0.25。同理第一个反第二个正的出现概率也是0.50.5=0.25。于是一正一反的概率是前面两个情况的和,即0.25+0.25=20.25=0.5。它们的合计值仍然是1。binopdf二项分布的概率

14、密度函数语法格式Y = binopdf(X,N,P)函数功能Y = binopdf(X,N,P) 计算X中每个X(i)的概率密度函数,其中,N中对应的N(i)为试验数,P中对应的P(i)为每次试验成功的概率。Y, N, 和 P 的大小类型相同,可以是向量、矩阵或多维数组。输入的标量将扩展成一个数组,使其大小类型与其它输入相一致。N中的值必须是正整数,0 P 1 。对于给出的x和两个参数n和p,二项分布概率密度函数为其中 q = 1 p。 y为n次独立试验中成功x次的概率,其中,每次试验成功的概率为p。指示器函数 I(0,1,.,n)(x) 确保x 取值为 0, 1, ., n。 示例一个质量检

15、查技术员一天能测试200块电路板。假设有 2% 的电路板有缺陷,该技术员在一天的测试中没有发现有缺陷的电路板的概率是多少?binopdf(0,200,0.02)ans =0.0176质量检查技术员一天中最大可能检测出有缺陷的电路板是多少块?defects=0:200;y = binopdf(defects,200,.02);x,i=max(y);defects(i) ans =4相关函数binocdf | binofit | binoinv | binornd | binostat | pdfdlmread将以ASCII码分隔的数值数据文件读入到矩阵中语法格式M = dlmread(filen

16、ame)M = dlmread(filename, delimiter)M = dlmread(filename, delimiter, R, C)M = dlmread(filename, delimiter, range)函数功能M = dlmread(filename)读取有分隔符的ASCII数值数据文件filename,并把数据给到矩阵M中。文件名(filename)以字符串形式用单引号括起来。 dlmread 从文件的格式中推断分隔符。M = dlmread(filename, delimiter)指定分隔符delimiter。使用 t 代表制表符 tab 作为分隔。M = dlmr

17、ead(filename, delimiter, R, C)R和C指定了数据读取数据,其左上角的值位于文件中的第R行,第C列。R和C从0开始,所以R=0, C=0 指向文件中的第一个值。M = dlmread(filename, delimiter, range)读取由range = R1 C1 R2 C2指定的区域块, (R1,C1)是左上角,(R2,C2)是右下角。也可以使用电子表格表示法来指定,如range = A1.B7。备注 All data in the input file must be numeric. dlmread does not read files that con

18、tain nonnumeric data, even if the specified rows and columns contain only numeric data. 若没有指定分隔符,当从文件格式中推断分隔符时,连续的空格符当作一个分隔符对待。若指定了分隔符,则重复的分隔符将分别作为单独的分隔符对待。 If you want to specify an R, C, or range input, but not a delimiter, set the delimiter argument to the empty string, (two consecutive single qu

19、otes with no spaces in between, ). For example,M = dlmread(myfile.dat, , 5, 2)In this case, dlmread treats repeated white spaces as a single delimiter. Dlmread将用0填充没有边界的区域。有多行的数据文件,若以非空格分隔符结束,例如分号,则导入后会多产生全0的一列在最后。 Dlmread在导入任何复数时,将其作为一个整体导入到一个复数单元中。下面是有效的复数格式:i|j Example: 5.7-3.1ii|j Example: -7j嵌入

20、了空格的复数是不正确的格式,空格将被认为是分隔符。示例例1Export a 5-by-8 test matrix M to a file, and read it with dlmread, first with no arguments other than the filename:M = gallery(integerdata, 100, 5 8, 0); dlmwrite(myfile.txt, M, delimiter, t)dlmread(myfile.txt)ans = 96 77 62 41 6 21 2 42 24 46 80 94 36 20 75 85 61 2 93 9

21、2 82 61 45 53 49 83 74 42 1 28 94 21 90 45 18 90 14 20 47 68Now read a portion of the matrix by specifying the row and column of the upper left corner:dlmread(myfile.txt, t, 2, 3)ans = 92 82 61 45 53 42 1 28 94 21 90 14 20 47 68This time, read a different part of the matrix using a range specifier:d

22、lmread(myfile.txt, t, C1.G4)ans = 62 41 6 21 2 80 94 36 20 75 93 92 82 61 45 74 42 1 28 94例2Export matrix M to a file, and then append an additional matrix to the file that is offset one row below the first:M = magic(3);dlmwrite(myfile.txt, M*5 M/5, )dlmwrite(myfile.txt, M/3, -append, . roffset, 1,

23、delimiter, )type myfile.txt40 5 30 1.6 0.2 1.215 25 35 0.6 1 1.420 45 10 0.8 1.8 0.4 2.6667 0.33333 21 1.6667 2.33331.3333 3 0.66667When dlmread imports these two matrices from the file, it pads the smaller matrix with zeros:dlmread(myfile.txt) 40.0000 5.0000 30.0000 1.6000 0.2000 1.2000 15.0000 25.

24、0000 35.0000 0.6000 1.0000 1.4000 20.0000 45.0000 10.0000 0.8000 1.8000 0.4000 2.6667 0.3333 2.0000 0 0 0 1.0000 1.6667 2.3333 0 0 0 1.3333 3.0000 0.6667 0 0 0替代作为dlmread的替代,可使用导入向导。选择菜单 “File | Import Data” 激活导入向导。相关函数dlmwrite | textscanfprintf写数据到文本文件或输出到命令窗口语法格式fprintf(fileID, format, A, .)fprint

25、f(format, A, .)count = fprintf(.)函数功能fprintf(fileID, format, A, .) fileID为文件句柄,指定要写入的文件;format是用来控制所写数据格式的格式符;A是用来存放数据的矩阵。applies the format to all elements of array A and any additional array arguments in column order, and writes the data to a text file. fprintf uses the encoding scheme specified i

26、n the call to fopen.fprintf(format, A, .) 将A中的数据按格式format输出到命令窗口。count = fprintf(.) 返回fprintf写的字节数。输入参数fileID取值为下面中的一种: 从文件打开时所得到的文件句柄,为一个整数值。 1 为标准输出设备(屏幕)。 2 for standard error.fileID缺省时,输出到屏幕,即1为默认值。format单引号括起来的是 “转换控制字符串 ”,指定输出的格式。由下面给出的各部分的组合而成: 百分号后紧跟的格式字符,如%s 。 输出区域的宽度,精度,和其它选项(附加格式说明符)。 要原样

27、输出的文本(普通字符)。 转义字符,包括: 单引号% 百分号 反斜线a 响铃b 退格符f Form feedn 换行r 回车t 水平制表符v 垂直制表符xN 十六进制数, NN 八进制数, N转换字符和可选的操作符按以下顺序排列(包括空格):下表列出可用的转换字符和限定类型字符。数据类型转换说 明Integer, signed%d 或 %i十进制整数%ld 或 %li64-bit base 10 values%hd 或 %hi16-bit base 10 valuesInteger, unsigned%u十进制整数%o八进制整数(octal)%x十六进制整数 (hexadecimal), 使用

28、字母 af%X十六进制整数 (hexadecimal), 使用字母AF%lu%lo%lx or %lX64-bit values, 十、八、十六进制整数%hu%ho%hx or %hX16-bit values, 十、八、十六进制整数Floating-point number%f定点表示法%e指数表示法,如 3.141593e+00%E同 %e,但用E,如 3.141593E+00%g%e 或 %f的紧凑格式,没有尾部的0%G%E 或 %f的紧凑格式,没有尾部的0%bx or %bX%bo%bu双精度的十六、八、十进制数值如:%bx prints pi as 400921fb54442d18%

29、tx or %tX%to%tu单精度的十六、八、十进制数值如:%tx prints pi as 40490fdbCharacters%c单个字符%s字符串附加格式说明符,包括: 字段宽度Minimum number of characters to print. Can be a number, or an asterisk (*) to refer to an argument in the input list. For example, the input list (%12d, intmax) is equivalent to (%*d, 12, intmax). 精度For %f,

30、%e, or %E: Number of digits to the right of the decimal point.Example: %6.4f prints pi as 3.1416For %g or %G Number of significant digits.Example: %6.4g prints pi as 3.142Can be a number, or an asterisk (*) to refer to an argument in the input list. For example, the input list (%6.4f, pi) is equivalent to (%*.*f, 6, 4, pi). FlagsActionFlagExampleLeft-justify.%-5.2fPrint sign character (+ or ).+%+5.2fInsert a space before the value. % 5.2fPad with zeros.0%05.2fMo

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1