[R] Custom sampling method in R XXXX

Dan Abner dan.abner99 at gmail.com
Mon Jun 23 23:11:00 CEST 2014


 Hi all,

I have the following situation and a good efficient way to perform
this operation in R has not come to me. Any suggestions/input are
welcome.

I have a user-defined parameter (let's call it x) whose value is
selected from a set of possible values (j). Once the user selects one
of the values of j for x, then I need to map a probability
distribution to the values of j such that the middle probability of
.5385 (see probs below) is associated with the value of x and the tail
probabilities are assigned to the 2 values below x and 2 values above
x in j. Therefore, in the example below:


x<-.250
j<-c(0.000,0.125,0.250,0.375,0.500,0.625,0.750,0.875,1.000)
probs<-c(0.02307692,0.20769231,0.53846154,0.20769231,0.02307692)

probabilities would be assigned to the values of j as such:

value     probability
0            0.023077
0.125     0.207692
0.25       0.538462
0.375     0.207692
0.5         0.023077

And then 1 value of j is selected based on the associated probability.
Any ideas on an efficient way to do this?

An added dimension of complexity is when the value of x is selected
near the parameter boundary of j. If x = 0, then the easiest thing I
can think of is to assign probabilities as:

value      probability
0             0.76923077
0.125      0.207692
0.25        0.023077

However, I am open to other possibilities.

Any assistance is appreciated.

Thanks,

Dan



More information about the R-help mailing list