You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm beginner. Im running a MC integration to compute the CDF of a vinecopula model (involving 6 different variables). However, I have a lack of speed and efficency in the process. Tackling it, I'm trying to perform my model using VEGASFLOW, but I'm not sure how can I convert a rpy object to tensor, and also how can I set the limits of integration .
I don't think for this case in particular you will see a gain of performance by using VegasFlow. VegasFlow is most useful when you whole problem can be cast as a set of tensorflow primitives (or more generally, tensors). In your case I see you are using an R package so I believe you won't see any advantages with respect to vegas (unless you aim to use the parallelization over function returns see docs)
But here you have some answers to your questions:
In order to change any object to a tensor, you can follow the same strategy you are following but instead of using np.array you can use tf.constant. Another possibility is to enable eager mode so that you can integrate an arbitrary numpy function. See docs for that: https://vegasflow.readthedocs.io/en/latest/examples.html#integrating-a-numpy-function
I'm beginner. Im running a MC integration to compute the CDF of a vinecopula model (involving 6 different variables). However, I have a lack of speed and efficency in the process. Tackling it, I'm trying to perform my model using VEGASFLOW, but I'm not sure how can I convert a rpy object to tensor, and also how can I set the limits of integration .
Here is my code using VEGAS:
`@vegas.batchintegrand
def integrate_fun(k): # Calculate VineCopula pdf
pdf_vine = np.array(VineCopula.RVinePDF(k, θ))
return pdf_vine
def vegas_6D(θ,u,v,w,x,y,z):
integ = vegas.Integrator([[0, u], [0, v], [0, w], [0, x], [0, y], [0, z]])
result = integ(integrate_fun, nitn = 10, neval = 10000)
return result.mean`
where u,v,w,x,y,z are: np. linspace between 0 and 1
Thank you in advance for your help
The text was updated successfully, but these errors were encountered: