Random Drawings from a Empirical Distribution with Standard Deviation +- 1

How can I get random drawings from a list with data in the range of mean + - 1 standard deviation?

I know how to do it for a theoretical normal distribution

with(Statistics);
S := Sample(RandomVariable(Normal(0, 1)), 1000)

but not for an empirical distribution....

Robert Israel's picture

Empirical distribution

Do you mean something like this?

> with(Statistics):
   L := [3,1,4,1,5,9,2,6,5,3,5];
   mu:= Mean(L);
   sigma:= StandardDeviation(L);
   L1 := select(is, L, RealRange(mu-sigma, mu+sigma));
   X := RandomVariable(EmpiricalDistribution(Array(L1)));
   S := Sample(X, 1000);

Thanks Robert! It looks good

Thanks Robert! It looks good taken at face value.

I just realized though (correct me if I am wrong) that even if we sample a random

drawings from for example serial dependent data (empirical data) we still wont get serial correlated drawings, or?.

It would be nice to find a way to collect empirical data, calculate the returns,

sample a sequence of the returns ( with the original statistical properties such as serial correlation)

and then use that sample to simulate a unit root.

 

I mean I can due it with

I mean I can due it with brutal force by simply collecting data

calculate the serial correlation coefficient of the returns and then use the below code to calculate serial dependent drawings

restart:
randomize():
with(Statistics):
n:=1000:
p := .7;   # serial correlation
r := Sample(RandomVariable(Normal(0, 1)), n);
for i from 2 to n do
x[1] := 0; x[i] := p*x[i-1]+r[i] end do;
rr := [seq(x[i], i = 1 .. n)]
Correlation(rr[1 .. n-1], rr[2 .. n])

 

but there must be an more elegant version? maybe Bootstaping?!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}