[R] ?OT: Probabilistic Simulation
Greg Snow
Greg.Snow at imail.org
Wed Dec 23 18:41:02 CET 2009
A simple starting place for your simulation could be something like:
peg <- rnorm(100000, 1.8, 0.01)
hole <- rnorm(100000, 1.8, 0.02)
fits <- peg < hole
table(fits)
mean(fits)
Then you would need to add in the effects of temperature, drill type, etc. to account for the different pieces. If you want to take into account non-circularity, then you will need a more complicated comparison than the simple <.
You may want to then wrap all of this in a function so that you can change the different settings and see the outcomes.
If things get more complicated, then the sapply and replicate functions may be of help.
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Polwart Calum (County Durham and Darlington
> NHS Foundation Trust)
> Sent: Friday, December 18, 2009 4:17 PM
> To: r-help at r-project.org
> Subject: [R] ?OT: Probabilistic Simulation
>
>
> Sorry this may well be defined as Off Topic. I apologize in advance.
>
> I am interested in performing what I think would be a probabilistic
> sensitivity simulation. I've done some crude ones before in excel but
> I'm wondering if R can help me do it more effectively?
>
> I have a set of theoretical variables for simplicity lets use (what I
> think) is an easier example: I have a peg and a hole which I want to
> predict how often they would not fit together securely.
>
> The peg should be 1.8mm in diameter.
> But there are some variables which might affect if it is actually 1.8mm
> but I'd expect it to be normally distributed around 1.8mm with a known
> standard deviation. There are also variables such as temperature which
> would influence if the peg was the correct size (there would be a known
> relationship to temperature, and a mean temperature with a standard
> deviation would be known)
>
> The hole should be 1.8mm diameter as well. Again there are variables
> that affect if it is, drill size, drilling method, substrate being
> drilled, temperature at time of drilling, temperature at time of
> fitting peg (would be same as above). I'd be looking to model if the
> peg would fit in the hole, AND if it fitted how well it fitted.
>
> I'd then want to run a simulation of say 500 scenarios, randomly
> picking temperature, hole characteristics etc for each simulation.
> From there I'd get the number of times in 500 samples the peg wouldn't
> fit. I could then try adjusting a variable - say using a different
> drilling method and see if that 'easier' but less reliable drilling
> method actually would affect the number of times the peg didn't fit the
> hole properly.
>
> So from what I understand this is a MonteCarlo simulation of
> probability. And this is where I go off topic! Am I right? I know
> its off topic - so what I'd like to know is can someone point me to
> where I can find out?
>
> Then if it is a monte-carlo can someone point me to a good description
> of how to get R to model this?
>
> Ta
>
> Calum
>
> ***********************************************************************
> *********************************************
>
> This message may contain confidential information. If
> yo...{{dropped:21}}
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list