rlongonly.test(m, n = 2, k = n, segments = NULL, x.t = 1, x.l = 0,
x.u = x.t, max.iter = 1000)
random.longonly.test
using the R function
lapply
. The result which is a list contains the investment weight vectors and number
of iterations. Thse data are stored in a matrix of investment weights and a vector
of iterations. These arrays are returned as a list.
Marsaglia, G. and T. A. Bray, 1964. A convenient method for generating normal variables, SIAM Review, 6(3), July 1964, 260-264.
Ross, S. M. (2006). Simulation, Fourth Edition, Academic Press, New York NY.
random.longonly.test
###
### generate 100 long only portfolios with 30 investments and 30 non-zero positions
###
x.result <- rlongonly.test( 100, 30 )
###
### generate 100 long only portfolios with 30 investments and 10 non-zero positions
###
y.result <- rlongonly.test( 100, 30, 10 )
Run the code above in your browser using DataLab