Changing automatically the arguments of a function

I have a function of the type:

f[a,b,c,d,e,f,g,h,i]


I would like to evaluate the function changing the values of the arguments automatically. For instance varying a from 0 to 1 with a given step, keeping the other arguments constant, and varying after also all the other arguments with different intervals and steps. For instance: {a,b,c,d,e,f} with intervals 0 to 1 with step 0.1; and {g,h,i} with intervals {0 to Pi/4}, with step Pi/16. I'm sure there is an efficient way to do this, without having to write an immense table.

UPDATE

My final goal is to random sample my set of arguments. As BlacKow pointed out, I would have 84375 points to evaluate. Since I have quite a heavy function, this would take way too much time. So I would rather attempt to random sample it. Following BlacKows definition, I would have something like,

RandomSample[points, 300];


Anyhow, I think both answers were very useful.

• "Immense table"? I'm not sure why that would be bad. The other alternative would be to generate the ranges of values and MapThread your function over it, but it still seems to me that a Table with multiple iterators would be the most natural solution. – MarcoB May 11 '16 at 15:23
• Yes, I already thought of table. Yet having there to be variables having the same interval and the same step, I thought it might have been possible to change such variables in a more tidy way. – Mirko Aveta May 11 '16 at 15:24
• Would you please include appropriate Table code in your question that does what you want, so people know exactly what you want to accomplish and have a point of comparison for their improved solutions? – MarcoB May 11 '16 at 15:26
• Sounds like a good use case for Manipulate. – chuy May 11 '16 at 16:11

Calculate argument vectors:

points = Partition[#, 8] &@
Flatten@Tuples[{Tuples[Range[0, 1, 0.25], 5],
Tuples[Range[0, Pi/4, Pi/8], 3]}];

Dimensions[points]
(*{84375, 8} equals to 5^5*3^3 *)


and then f@@@points

Update If you need a random sample in the 8-dimensional space, you need following

samplPoints[n_] := # {1, 1, 1, 1, 1, Pi/4, Pi/4, Pi/4} & /@
RandomReal[{0, 1}, {n, 8}];
samplPoints[10]


It will generate 10 points in 8D.

• Your solution probably best fits my problem. Indeed my next step would be to use a RandomSample, or a Latin Hypercube. – Mirko Aveta May 11 '16 at 21:08
• @MirkoAveta it's not much different form @kglr. Also you have to check which one is faster for your application. I just though applying Tuples to Tuples would be cool. – BlacKow May 11 '16 at 21:14
• Yes they both return the same result. Fair enough! I was just wondering which is best for random sampling. For my very heavy function, 84375 points is impossible! (time is time...) – Mirko Aveta May 11 '16 at 21:16
• @MirkoAveta Now I'm confused. You don't want to apply you function to all of these points? You just want some sort of Monte-Carlo sample of your 8-dimensional space? Then, the code will be different... – BlacKow May 11 '16 at 21:27
• @MirkoAveta if you use my updated code, the Pi related variables are always in the end. – BlacKow May 12 '16 at 12:52

smaller version of the problem with a function with 5 arguments:

h @@@ Tuples[Join[ConstantArray[Range[0, 1, .2], 3],
ConstantArray[Range[0, Pi/4, Pi/16], 2]]]


or

Tuples[h @@ Join[ConstantArray[Range[0, 1, .2], 3],
ConstantArray[Range[0, Pi/4, Pi/16], 2]]]


• kglr may I ask you why there are three at signs? – Mirko Aveta May 11 '16 at 20:54
• @Mirko, regarding @@@ and @@` see the docs: Apply – kglr May 11 '16 at 21:17