0

I have 567 unique customer ID with their Trips and Cumulative Trips. I want to get 10%, 20%, 30% customer sample by Bootstrap simulation. I also want to see the normal distribution for 10%, 20%, and 10% sample mean. As I am new in R and did not do it previously, so your help is appreciated

10% sampling (57 Sample)

set.seed(4123)
CI.trips=c(new.col.allc$n)
mean <‐ mean(CI.trips)
mean
N <‐ 57
nboots <‐ 1000
boot.result <‐ numeric(nboots)
for(i in 1:nboots)
{
boot.samp <‐ sample(CI.trips, N, replace=FALSE)
boot.result[i] <‐ mean(boot.samp)
}
print(boot.samp)
  hist(boot.result)
  print(boot.result)
  

I am getting the following outputs

> set.seed(4123)
> CI.trips=c(new.col.allc$n)
> mean <‐ mean(CI.trips)
> mean
[1] 45.49206
> N <‐ 57
> nboots <‐ 1000
> boot.result <‐ numeric(nboots)
> for(i in 1:nboots)
+ {
+ boot.samp <‐ sample(CI.trips, N, replace=FALSE)
+ boot.result[i] <‐ mean(boot.samp)
+ }
> print(boot.samp)
 [1]  15  11   3   6   6  81   1  14   2   7  10   2  28 153   1  15  46   1   2 246 118 223   2  38  28  32  24  12   5
[30]  86 402 106   1  16   1  29   6   6   5  10   6  22  56  34   7 299 112 122  27  31 307   2   2  27   4 136  20
> hist(boot.result)

enter image description here

Community
  • 1
  • 1
  • What is actually your problem? – jay.sf Jul 23 '19 at 18:39
  • Hi Jay, Thank you for your response, actually I am trying to pick 10%(57), 20%(114), 30%(171) random sample from 567 samples using Bootstrap simulation. – Md Mintu Miah Jul 23 '19 at 23:48
  • Hi, you need to make your question [reproducible](https://stackoverflow.com/a/5963610/6574038) for Stack Overflow, cheers. – jay.sf Jul 24 '19 at 05:03

0 Answers0