vendredi 24 avril 2020

Generate new random distributions based on distribution of my data in R

I have a data set with 27 observations and the associated probability of observation (ranging between 0 and 1) as shown below

Data Prob_1 Prob_2 
1      .1     1        
2       0     1          
3       0     1       
4       0    .8    
5      .3    .5         
6      .6    .2
7      .9    .1
8       1     0
9       1     0
10     .6     0
11     .2     0
12     .2    .1 
13     .6    .3
14     .4    .4
15     .1    .5
16     .1    .3
17     .4     0
18     .7     0
19      1     0
20      1    .1
21      1    .4
22     .8    .8
23     .4     1
24     .2     1
25     .1     1
26      0     1
27      0     1

I want to generate between 100-250 random samples for prob_1 and prob_2 from these distributions. I also want to plot them along with the variance band to see how the random sample varies. I have tried this so far


test_dist = sample(1:27,150,
                   replace=TRUE,
                   prob=c(1,1,1,.8,.5,.2,.1,0,0,0,0,.1,.3,.4,.5,.3,0,0,0,.1,.4,.8,1,1,1,1,1)
                  )


Once I have test_dist, I am not sure how to plot it to view the probabilities and the variance band for the new data generated for points 1 to 27.

I am not even sure if this is the best way to generate random sample distributions following the distribution I have.

Thanks!




Aucun commentaire:

Enregistrer un commentaire