What I'm more interested in here than in the result of the simulation, is the process of creating it.
然后你们可以进行思考,我对这些过程,比对仿真程序的结果更感兴趣。
So the moral here, again, is whenever you're doing an implementation of a simulation, you do need to have some underlying theory about the model.
所以这里的寓意还是,不管你在做什么东西的仿真程序,你需要有一个,模型的底层程序。
When we did the spring, we had this theory of Hooke's Law that told us something, and we built a simulation, or built some tools around that theory.
当我们写弹簧程序的时候,我们有胡克定律来告诉我们原理,然后我们建立了一个仿真模型,或者说是在这个理论基础上建立了一些工具。
And so now we're going to try and see if we can write a simulation that will give us some insight as to which of these might be better or worse.
现在我们回来看看我们能否,写一个程序来看看,哪一种选择会更好。
After all, I'm going to try and build a simulation of the stock market, so I might as well have the notion of a market, and probably the notion of a stock.
不管怎样,我得建立一个股票市场的仿真程序,所以我最好要有股票的概念,和股市的概念。
And then we try and get our simulation to match the past, and hope that that will help it predict the future.
尝试让仿真程序能和这一部分实际数据相符,并且希望它能够帮我们对未来进行预测。
So in fact, it is the case, if you look at data, and by the way, that's the way I ended up setting a lot of these parameters and playing with it, was comparing what my simulation said to historical stock data.
所以实际上,在这个例子中,如果你看到数据,顺便说一下,这就是我设置很多变量,然后编程的方式,也就是把我的仿真程序得到的结果,和历史股票数据进行比较。
And as an added incentive for you to pay attention, I'm going to warn you that this particular simulation will appear in the final or a variant of it.
作为提高你们注意力的激励,我要警告你们,这个特殊的仿真程,或者它的变种会再期末考试出现。
And it would take at least an hour do a perfect simulation of the stock market.
而要做一个完美的股市仿真,至少要1个小时。
And when we do a simulation, we're pulling the samples from some distribution.
当我们写一个仿真程序的时候,我们就是从一些分布中进行了采样。
And let's think about how we're going to build the simulation.
让我们想想,我们怎样进行建模。
Instead I'm going to torture you with yet one more simulation.
我现在想用另一个仿真程序,来折磨你们了。
Now, as we know, and by the way we're not going to write a perfect simulation here, because we're going to try and do it in 40 minutes, or 30 minutes.
现在u,我们知道,我们并不是要写一个,完美的仿真程序,因为我们得,在40或者30分钟内完成它。
So it's got an internal procedure,internal function, local to the unit test, that runs the simulation.
它有内部过程,内部函数,它对unit,test来说是有本地环境,来支持股票仿真程序的运行。
I could do this, by the way, by running the code and putting print statements in various places as well, but the hand simulation is valuable, so let me just start it.
做了正确的更新,顺便说一句,我可以通过在很多地方,放置print声明来达到这个目的,但是手工模拟也很有用。
应用推荐