Dear community,
I need to evaluate a function of this type
f[List_]:=Product[1-i,{i,List}]
and I need to do this for 10 millions of times and then I need to calculate the average, I am only interested in the numerical value of the function. Each of this times the list obviously change but not only in the content but also in length. Using the standard Mathematica tools I solved the problem defining a not constant list of two levels, e.g.:
List2= {{1,2,3},{2,3,4,5},{1,2}}
in my case I have 10 millions of sublists of different length, these length are randomly assigned through a Poisson distribution, the content of the lists is as well randomly assigned.
I evaluate the mean in this way:
Mean[Table[f[List2[[i]],{i,1,n}]]
if I use n=1 million my laptop needs 207s, with n=10 millions it needs more than 1 hour ( I never ended the simulation).
Since I need to repeat this process a lot of times, is there a method to speed up the code without using a more powerful pc?
In a similar case I really improved my code using the built-in function Compile, but I do not think it is possible use an irregular list like mine with this function, isn’t it?
Thanks for the attention