[R] IMPORTANT!!!! PLEASE HELP ME

0 views
Skip to first unread message

Jasmin

unread,
Nov 24, 2012, 5:03:51 PM11/24/12
to r-h...@r-project.org
Hi,
I want to generate 10000 samples from normal distribution with replacement
case and every sample size is 50. What should I do ?



--
View this message in context: http://r.789695.n4.nabble.com/IMPORTANT-PLEASE-HELP-ME-tp4650676.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-h...@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.

chuck.01

unread,
Nov 24, 2012, 5:16:25 PM11/24/12
to r-h...@r-project.org
1st. Calm down, this doesn't seem that important.
Then you will need to know some base functions.
see

?rnorm

Doing this 10,000 times and making them of size 50 is no problem.

FYI: I don't understand what "with replacement case" means; could you
clarify?



Jasmin wrote
> Hi,
> I want to generate 10000 samples from normal distribution with
> replacement case and every sample size is 50. What should I do ?





--
View this message in context: http://r.789695.n4.nabble.com/IMPORTANT-PLEASE-HELP-ME-tp4650676p4650677.html

jim holtman

unread,
Nov 24, 2012, 5:50:30 PM11/24/12
to Jasmin, r-h...@r-project.org
What do you want to do with the samples after you generate them? What
are the parameters for the normal distribution? You left a lot of
information out. You can generate 500,000 numbers and then store them
in a 10000x50 matrix quite easily.
--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

Pete Brecknock

unread,
Nov 24, 2012, 6:24:24 PM11/24/12
to r-h...@r-project.org
jholtman wrote
> What do you want to do with the samples after you generate them? What
> are the parameters for the normal distribution? You left a lot of
> information out. You can generate 500,000 numbers and then store them
> in a 10000x50 matrix quite easily.
>
> On Sat, Nov 24, 2012 at 5:03 PM, Jasmin <

> yasemin_deniz89@

> > wrote:
>> Hi,
>> I want to generate 10000 samples from normal distribution with
>> replacement
>> case and every sample size is 50. What should I do ?
>>
>>
>>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/IMPORTANT-PLEASE-HELP-ME-tp4650676.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>>

> R-help@

> 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.
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
>
> ______________________________________________

> R-help@

> 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.


maybe ...

replicate(10000, rnorm(50))

could work for you

HTH

Pete



--
View this message in context: http://r.789695.n4.nabble.com/IMPORTANT-PLEASE-HELP-ME-tp4650676p4650686.html

Pete Brecknock

unread,
Nov 24, 2012, 7:18:46 PM11/24/12
to r-h...@r-project.org
Jasmin wrote
> I try to use hansen-hurwitz and horvitz-thompson estimator.So I should
> generate samples which come from normal distribution (mu=50,sigma=3).

I have taken the liberty of scaling the problem down to something more
digestible and have changed lines 5 and 7 in your code

nsamples=10
sampsize=5
i=0
y=matrix(rnorm(nsamples*sampsize,50,3),nrow=nsamples)
s=matrix(NA,10,5)
for(i in 1:10){
s[i,]=sample(y,5,replace=T)
}

HTH

Pete



--
View this message in context: http://r.789695.n4.nabble.com/IMPORTANT-PLEASE-HELP-ME-tp4650676p4650692.html

Jasmin

unread,
Nov 24, 2012, 6:46:36 PM11/24/12
to r-h...@r-project.org
It is my assignment and I try to use hansen-hurwitz estimator &
horvitz-thompson estimator.Therefore, I should generate samples from a type
of distribution with and without replacement. I try to use below code but I
can't do.

nsamples=1000000
sampsize=50
i=0
y=matrix(rnorm(nsamples*sampsize,50,3),nrow=nsamples)
s=matrix(1000000,50)
for(i in 1:1000000){
s[i]=sample(y,50,replace=T)
}



--
View this message in context: http://r.789695.n4.nabble.com/IMPORTANT-PLEASE-HELP-ME-tp4650676p4650689.html

Jasmin

unread,
Nov 24, 2012, 6:51:36 PM11/24/12
to r-h...@r-project.org
I try to use hansen-hurwitz and horvitz-thompson estimator.So I should
generate samples which come from normal distribution (mu=50,sigma=3).



--
View this message in context: http://r.789695.n4.nabble.com/IMPORTANT-PLEASE-HELP-ME-tp4650676p4650690.html

Rolf Turner

unread,
Nov 25, 2012, 3:54:16 PM11/25/12
to Pete Brecknock, R Project Help, chuck.01


PLEASE remember: This list has a "no homework" policy. Students
should do their own homework.

cheers,

Rolf Turner

On 25/11/12 13:18, Pete Brecknock wrote:
> Jasmin wrote
>> I try to use hansen-hurwitz and horvitz-thompson estimator.So I should
>> generate samples which come from normal distribution (mu=50,sigma=3).
> I have taken the liberty of scaling the problem down to something more
> digestible and have changed lines 5 and 7 in your code
>
> nsamples=10
> sampsize=5
> i=0
> y=matrix(rnorm(nsamples*sampsize,50,3),nrow=nsamples)
> s=matrix(NA,10,5)
> for(i in 1:10){
> s[i,]=sample(y,5,replace=T)
> }

Reply all
Reply to author
Forward
0 new messages