Re: [R] Writing program for these
Ben Boyadjian benjy_cy_21 at hotmail.com writes: Hello I am trying to solve these problems and I am not allowed to use loops or ifs. 1st Question My first question is that I have generated 100 random numbers from the uniform distribution then A)add only the negative integers. B)add elements until the first appearance of a negative element. I know how to choose the negative elements for A but how to find integers? If this is the standard uniform U(0,1) distribution (which I assume from your phrase *the* uniform distribution (emphasis added)) then there will be no integers in the sample ... ?? And I dont know what to do for B. 2nd Question Simulate 1000 observations from the student-t distribution with 3 degrees of freedom and then calculate the truncated mean by excluding bottom 5% and top 5%. Looks like homework questions, which are not answered on this list. Please read the posting guide; if these are *not* homework questions, please give us a plausible context. (Even if these are not homework questions, the posting guide asks that you do your homework in a broader sense by indicating what steps you have taken to solve your problem on your own before posting.) One hint for the second question: ?rt good luck, Ben Bolker __ R-help@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.
Re: [R] Writing program for these
On 11-01-27 14:24, Ben Bolker wrote: Ben Boyadjian benjy_cy_21 at hotmail.com writes: Double post? Hello I am trying to solve these problems and I am not allowed to use loops or ifs. 1st Question My first question is that I have generated 100 random numbers from the uniform distribution then A)add only the negative integers. B)add elements until the first appearance of a negative element. I know how to choose the negative elements for A but how to find integers? x - c(1, 1.3) x==round(x, 0) If this is the standard uniform U(0,1) distribution (which I assume from your phrase *the* uniform distribution (emphasis added)) then there will be no integers in the sample ... ?? And I dont know what to do for B. 2nd Question Simulate 1000 observations from the student-t distribution with 3 degrees of freedom and then calculate the truncated mean by excluding bottom 5% and top 5%. Looks like homework questions, which are not answered on this list. Please read the posting guide; if these are *not* homework questions, please give us a plausible context. (Even if these are not homework questions, the posting guide asks that you do your homework in a broader sense by indicating what steps you have taken to solve your problem on your own before posting.) One hint for the second question: ?rt Rather ugly and long winded, but works: z - rt(1000, 3) q - quantile(z, c(.05, .95)) mean(z[zq[1] zq[2]]) good luck, Ben Bolker __ R-help@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. -- Sascha Vieweg, saschav...@gmail.com __ R-help@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.
Re: [R] Writing program for these
Siterer Sascha Vieweg saschav...@gmail.com: On 11-01-27 14:24, Ben Bolker wrote: Ben Boyadjian benjy_cy_21 at hotmail.com writes: Double post? Yes, probably just hoped that if he changed the subject someone would do his homework for him... __ R-help@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.
Re: [R] Writing program for these
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [cc'ing back to r-help] On 01/27/2011 10:06 AM, Ben Boyadjian wrote: Yes the it says the uniform distribution on the interval (-5,5). If this is real-valued (which again is not precisely defined, but that would be how I would interpret) then the probability of choosing an integer is again zero. With double-precision floating point values it is not zero but is extremely small. This is what I have done for Question 2 There is the trim function that can give the answer but I am meant to write the program. My question is whether I use the 0.05 or the 0.1. I dont want anything below the 5% and above the 95%. Why not look at ?mean for the answer? Or compare the answer from using mean with the 'trim' argument to the alternative solution you listed below? # We first simulate 1000 observations . x-rt(1000,3) mean(x,trim=0.05) #or 0.1 I am not sure z-sort(x) #next use either y-z[-c(1:50,951:1000)] # We want the bottom 5% and top 5% so this corresponds to the elements that we are taking away. #or #y-z[-c(1:100,901:1000)] mean(y) -- From: Ben Bolker bbol...@gmail.com Sent: Thursday, January 27, 2011 2:24 PM To: r-h...@stat.math.ethz.ch Subject: Re: [R] Writing program for these Ben Boyadjian benjy_cy_21 at hotmail.com writes: Hello I am trying to solve these problems and I am not allowed to use loops or ifs. 1st Question My first question is that I have generated 100 random numbers from the uniform distribution then A)add only the negative integers. B)add elements until the first appearance of a negative element. I know how to choose the negative elements for A but how to find integers? If this is the standard uniform U(0,1) distribution (which I assume from your phrase *the* uniform distribution (emphasis added)) then there will be no integers in the sample ... ?? And I dont know what to do for B. 2nd Question Simulate 1000 observations from the student-t distribution with 3 degrees of freedom and then calculate the truncated mean by excluding bottom 5% and top 5%. Looks like homework questions, which are not answered on this list. Please read the posting guide; if these are *not* homework questions, please give us a plausible context. (Even if these are not homework questions, the posting guide asks that you do your homework in a broader sense by indicating what steps you have taken to solve your problem on your own before posting.) One hint for the second question: ?rt good luck, Ben Bolker __ R-help@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. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk1Bja0ACgkQc5UpGjwzenMf4wCeOsJ0uxMn5nOdUbAhJzrl8CHU uj8AniPodV2HAwA6Cqi8Hpm/0ANh+yQ1 =mTtk -END PGP SIGNATURE- __ R-help@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.