MATLAB Workbook.doc
上传人:sy****28 上传时间:2024-09-12 格式:DOC 页数:16 大小:118KB 金币:16 举报 版权申诉
预览加载中,请您耐心等待几秒...

MATLAB Workbook.doc

MATLABWorkbook.doc

预览

免费试读已结束,剩余 6 页请下载文档后查看

16 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

.........MATLABWorkbookENGR155CMathematicalandComputationalMethodsforEngineersFirstEditionVadimKhaymsTableofContentsTOC\o"1-3"\n\h\zHYPERLINK\l"_Toc498446528"1.RandomNumberGenerationHYPERLINK\l"_Toc498446529"2.ProbabilityDistributionsHYPERLINK\l"_Toc498446530"3.ParameterEstimationHYPERLINK\l"_Toc498446531"4.HypothesisTesting(singlepopulation)HYPERLINK\l"_Toc498446532"5.HypothesisTesting(twopopulations)HYPERLINK\l"_Toc498446533"6.RegressionandCorrelationAnalysesProbability&Statistics1.RandomNumberGenerationCommands:unidrndGeneratesadiscreterandomnumberorarandomvectorunifrndGeneratesarandomnumberoravectorfromauniformdistributionhistCreatesafrequencyplot(histogram)WewillattempttosolveoneofthehomeworkproblemsnumericallybyperformingavirtualexperimentusingMATLAB’srandomnumbergenerator.Theproblemisasfollows.Twopointsaandbareselectedatrandomalongthex-axissuchthatand.Findtheprobabilitythatthedistancebetweenaandbisgreaterthan3byperformingonemilliontrials.Makeahistogramofthegenerateddistancesbetweenxandy.SOLUTIONTwovectorsofrandomnumberseachwithonemillionelementswillbedrawnfromauniformdistributionandthedistancebetweenthecorrespondingelementscomparedto3.Seecodebelow.clear;x=unifrnd(-2,0,1,1000000);y=unifrnd(0,3,1,1000000);s=0;d=abs(x-y);fori=1:1000000ifd(i)>3s=s+1;elseendendhist(d,100)Probability=s/1000000Runningthecode:Probability=0.3345%Theexactanalyticalsolutionis1/3Hint:generatingavectorofrandomnumbersallatonceiscomputationallymoreefficientthangeneratingrandomvaluesoneatatimewithinaforloop!YOURTURNUsingMATLAB,verifyyouranswertooneotherhomeworkproblem,whichfollows.Apointisselectedatrandominsideacircle.Findtheprobabilitythatthepointisclosertothecenterofthecirclethantoitscircumference.Hint:generatearandomvectorofxandycoordinatesfirst,thenconsideronlythosepoints,whichareinsidethecircle2.ProbabilityDistributionsCommands:binopdfPDFforthebinominaldistribu