Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a this calculation, as you can see it is doing a calculation on each list, from list 1 to list 4 of the datafile. My problem is that using Mapthread to do this calculation does not work because it does not do it stepwise. Is it possible to do these calculations in one go.

example=datafile[[2 ;;, 1]] is a singe list of stock close price from a period of 500 days, looking like this: sample:

{4.40267, 4.85723, 8.80984, 4.62259, 6.74677, 3.41247, 2.3579, \
1.5767, 8.1023, 0.846309}

xt=Range[20]
In[81]:= d1 = CorrelationFunction[datafile[[2 ;;, 1]], #] & /@ xt

Out[81]= {0.999145, 0.998342, 0.997537, 0.996713, 0.995874, 0.995047, \
0.994209, 0.9934, 0.992535, 0.991635, 0.990724, 0.989826, 0.988893, \
0.98796, 0.987006, 0.986039, 0.985056, 0.984071, 0.983062, 0.982049, \
0.981015, 0.980023, 0.979034, 0.978088, 0.977124, 0.976173, 0.975284, \
0.974368, 0.973422, 0.972492}

In[86]:= d2 = CorrelationFunction[datafile[[2 ;;, 2]], #] & /@ xt

Out[86]= {0.998978, 0.997943, 0.996913, 0.995889, 0.994845, 0.993787, \
0.992737, 0.991701, 0.990673, 0.989631, 0.988578, 0.987528, 0.986518, \
0.985486, 0.984453, 0.983412, 0.982381, 0.981336, 0.98028, 0.97924, \
0.978187, 0.977157, 0.976174, 0.975197, 0.974231, 0.97327, 0.97235, \
0.971439, 0.970547, 0.969652}

In[92]:= d3 = CorrelationFunction[datafile[[2 ;;, 3]], #] & /@ xt

Out[92]= {0.999266, 0.998475, 0.997678, 0.996881, 0.996119, 0.995341, \
0.994551, 0.993777, 0.992971, 0.992156, 0.991314, 0.990456, 0.989605, \
0.988753, 0.98795, 0.98713, 0.986287, 0.985381, 0.984481, 0.983552, \
0.982617, 0.981703, 0.980813, 0.97997, 0.979149, 0.978341, 0.977537, \
0.976723, 0.975906, 0.975078}

In[90]:= d4 = CorrelationFunction[datafile[[2 ;;, 4]], #] & /@ xt

Out[90]= {0.998632, 0.997179, 0.995736, 0.994285, 0.99281, 0.991288, \
0.989771, 0.988194, 0.986626, 0.985064, 0.983506, 0.981978, 0.980482, \
0.978987, 0.977529, 0.976089, 0.974685, 0.973293, 0.971882, 0.970521, \
0.969074, 0.967699, 0.966367, 0.965024, 0.963719, 0.962478, 0.961284, \
0.960064, 0.958861, 0.957659}
share|improve this question
    
Without the definition for datafile, reproducing your output is cumbersome. –  Yves Klett Sep 27 '13 at 7:06
    
I have added a definition of the datafile. –  ALEXANDER Sep 27 '13 at 7:22
2  
Could you match your example data and the output (so that anyone can actually reproduce your steps via cut/paste) and correct the formatting? That would make your question much more useful. –  Yves Klett Sep 27 '13 at 7:36

1 Answer 1

up vote 3 down vote accepted

Is this a code, which you need ?

xt=Range[20]
Table[CorrelationFunction[datafile[[2 ;;, i]], #1] & /@ xt,{i,1,4}]

If no, please give more detailed value (example) of datafile and the structure of expected output.

share|improve this answer
    
That is great, exactly the output I needed, would you be able to do it by using some sort of sequence calculation or hold, holdfirst. I am trying to understand how to work with holding expressions but I am not able to master it. –  ALEXANDER Sep 27 '13 at 7:03
    
I don't know what exactly you need, but I would like to show you an example of the usage of the Hold, HoldFirst ... technics (see the answer) –  Vahagn Poghosyan Sep 27 '13 at 7:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.