麻省理工matlab课件-MIT6_094IAP10_lec04.pdf

所需积分/C币:16 2019-08-12 23:19:16 317KB PDF
5
收藏 收藏
举报

麻省理工matlab课件-MIT6_094IAP10_lec04.pdf 本帖最后由 sunchy11 于 2012-2-8 15:46 编辑 分享个MIT的matlab 教程,属于初级入门,希望对大家有帮助哈。
Outline (1 Probability and statistics (2)Data Structures (3) Images and Animation (4) Debugging (5) Online Resources Statistics Whenever analyzing data, you have to compute statistics >>scores s 100*rand (1, 100)i ●Bui|t- in functions mean median, mode To group data into a histogram )hist(scores, 5: 10:95) makes a histogram with bins centered at 5,15 ,25..95 )N=hist (scores, 0: 10: 100) returns the number of occurrences between the specified bin edges o to <10, 10 to <20.90 to <100. you can plot these manually: 》bar(0:10:100,N,"r1) Random Numbers Many probabilistic processes rely on random numbers matlab contains the common distributions built in 》and draws from the uniform distribution from o to 1 》andn draws from the standard normal distribution(Gaussian 》 andom can give random numbers from many more distributions see doc random for help the docs also list other specific functions You can also seed the random number generators )rand(stateo) rand(1) rand (1) rand(state0)i rand (1) Changing mean and variance We can alter the given distributions y=rand(1;100)*10+5; gives 100 uniformly distributed numbers between 5 and 15 y=f1oor(rand(1,100)*10+6); 15 floor or ceil is better to use here than roung 10 and gives 100 uniformly distributed integers betweer >>y=randn(1, 1000) y2=y*5+8 increases std to 5 and makes the mean 8 o 10505101520 Exercise: Probability We will simulate Brownian motion in 1 dimension. Call the script brown Make a 10,000 element vector of zeros Write a loop to keep track of the particle's position at each time Start at 0. To get the new position pick a random number, and if it's <0. 5 go left if it's >0.5 go right. Store each new position in the kth position in the vector Plot a 50 bin histogram of the positions Exercise: Probability We will simulate Brownian motion in 1 dimension. Call the script brown Make a 10,000 element vector of zeros Write a loop to keep track of the particle's position at each time Start at 0. To get the new position pick a random number, and if it's <0. 5 go left if it's >0.5 go right. Store each new position in the kth position in the vector Plot a 50 bin histogram of the positions 》x=zey。s(10000,1) 》forn=2:10000 i£rand<0.5 》》》》》 x(n)=x(n-1)-1; else x(n)=x(n-1)+1 end 》ena )figure; )hist(x, 50) Outline (1 Probability and Statistics (2)Data Structures (3) Images and Animation (4) Debugging (5) Online Resources Advanced Data structures ee have used 2D matrices Can have n-dimensions Every element must be the same type(ex integers doubles characters. Matrices are space-efficient and convenient for calculation Large matrices with many zeros can be made sparse: a= zeros(100);a(1,3)=10;a(21,5)=pi;b= sparse(a); Sometimes, more complex data structures are more appropriate Cell array: it's like an array but elements don t have to be the same type Structs: can bundle variable names and values into one structure Like object oriented programming in Matlab

...展开详情
试读 34P 麻省理工matlab课件-MIT6_094IAP10_lec04.pdf
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
weixin_39840650 你的留言是对我莫大的支持
2019-08-12
  • 至尊王者

    成功上传501个资源即可获取
关注 私信 TA的资源
上传资源赚积分or赚钱
    最新推荐
    麻省理工matlab课件-MIT6_094IAP10_lec04.pdf 16积分/C币 立即下载
    1/34
    麻省理工matlab课件-MIT6_094IAP10_lec04.pdf第1页
    麻省理工matlab课件-MIT6_094IAP10_lec04.pdf第2页
    麻省理工matlab课件-MIT6_094IAP10_lec04.pdf第3页
    麻省理工matlab课件-MIT6_094IAP10_lec04.pdf第4页
    麻省理工matlab课件-MIT6_094IAP10_lec04.pdf第5页
    麻省理工matlab课件-MIT6_094IAP10_lec04.pdf第6页
    麻省理工matlab课件-MIT6_094IAP10_lec04.pdf第7页

    试读结束, 可继续读4页

    16积分/C币 立即下载 >