How to set formula for N variables?

I want to use a TLinearFitter for a linear multiple regression, i.e. I am need to find parameters a_i of

 y = a_0 + a_1 * x_1 + a_2 * x_2 + ....

I know that I could use

TLinearFitter::SetFormula("x[0]++x[1]++x[2]"); 

but how can I set the formula, when there are N variables? I am looking for something like

TLinearFitter::SetFormula("Sum(N)");

Is this possible?

I’m not really sure what exactly you want to achieve, but if the pattern is nice and repetitive, you could try building the string with a loop, like:

[code]Int_t appends = 5;
TString str = “x[0]”;
for(Int_t i=0; i<appends; ++i)
{
str += Form("++x[%d]", i+1);
}

TLinearFitter::SetFormula(str);[/code]
This code gives me the string “x[0]++x[1]++x[2]++x[3]++x[4]++x[5]” which I then feed to the SetFormula() method.