# Simulating from Custom Function

I am going through an old research paper and I am stuck in one area of the coding. I'll spare you with most of the details but the function I want to simulate from is a complicated multivariate beta function that looks like:

mvBeta[rating_,x_,R_]:=densityProduct[rating,x]*mvnCopula[copulaInput[rating,x],R]


So clearly, I've already defined other functions. I know that I need to input rating and R. However, I would like perform a monte carlo simulation to obtain vectors of x.

Any help would be greatly appreciated.

• Welcome, Jim! Do you perhaps mean mvBeta[rating_,x_,R_]:=densityProduct[rating,x]*mvnCopula[copulaInput[rating,x],R], noting this: mathematica.stackexchange.com/a/18487/8 ? And what sort of input is x? Random real numbers? Some other distirbution? Dec 2, 2014 at 5:25
• This is just a guess without more information, but something using Map (/@) is probably what you want: mvBeta[rating,#,r]&/@ xvector. Dec 2, 2014 at 5:31
• input for x is random real numbers in the[0,1] interval. I am not sure how the map is going to work because I do not have a xvector. Rather, I want to simulate this vector just given rating and R
– Jim
Dec 2, 2014 at 5:58
• xvector = RandomReal[{0,1},100] ? Dec 2, 2014 at 6:10

Based on the comments appended to the question, I believe that what you are looking for is:

mvBeta[myrating, #, myR] & /@ RandomReal[{0,1},100]


where you can change 100 to be any length vector you like, and myrating and myR have already been defined.

• Hmm. This might work but now it gives me an error in another place. Would you know how to generate a vector of multivariate standard normals that must have a given correlation matrix?
– Jim
Dec 2, 2014 at 6:41
• reference.wolfram.com/language/ref/MultinormalDistribution.html RandomVariate[MultinormalDistribution[parameters],numberofiterates] Dec 2, 2014 at 6:54
• Thank you. I understand I need to use the MultinormalDistribution function. However, I am not sure how to make it so that my vector of standard normals have a given correlation matrix, say R.
– Jim
Dec 2, 2014 at 6:57