# [R] simple simulation problem

David Meyer meyer at ci.tuwien.ac.at
Sun Mar 17 23:00:46 CET 2002

```your comparisons don't do what you clearly expected.

for

if (a < b < c)

use

if (a < b && b < c)

salut,

-d

Mag. David Meyer		Wiedner Hauptstrasse 8-10
Vienna University of Technology		A-1040 Vienna/AUSTRIA
Department for			Tel.: (+431) 58801/10772
Statistics and Probability Theory	mail: david.meyer at ci.tuwien.ac.at

On Sun, 17 Mar 2002, Yannick Wurm wrote:

> Help!
>
> I'm desperate! I don't understand why my function won't work!
> Its for a simple simulation exercise: robin hood fires an arrow
> at a target with 50cm radius, and his aim follows a centered
> normal distribution with a standard deviation of 40cm (on x and
> y axis, independently). Here he takes 10 shots and is awarded
> points if he hits close to the center.
>
> For some reason, this function always returns a score of 870?!?!
> I'm probably missing something really quite obvious but I just
> can't figure out what it is.
>
> thanks for your help (you guys are great!),
>
> Yannick.
>
>
> function(){
> score_0
> x_rnorm(10, mean=0, sd=40)
> y_rnorm(10, mean=0, sd=40)
> d_sqrt(x^2 + y^2)
> for(i in 1:10) {
> 	if (d[i] > 50) print("désolé\n")
> 	if (40 < d[i] < 50) score_sum(score,2)
> 	if (25 < d[i] < 40) score_sum(score,5)
> 	if (15 < d[i] < 25) score_sum(score,10)
> 	if ( 5 < d[i] < 15) score_sum(score,20)
> 	if ( 0 < d[i] <  5) score_sum(score,50)
> }
> print(d)
> print(score)
> }
>
> ------------------------------------
>       yannick.wurm at insa-lyon.fr
> http://homepage.mac.com/yannickwurm/
> tel: 06.16.41.71.92    icq: 22044361
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```