Differences listwise of 3 dimensional array

 Differences listwise of 3 dimensional array

How can I calculate listwise the differences of a 3 dimensional array?

Is it possible with Map, Outer or somehow else?

SeedRandom["test"];

data = RandomReal[10, {10, 3}]

(* {{1.04846, 4.33855, 6.2083}, {6.92971, 0.394173, 3.10888}, 
    {9.59448, 6.45967, 0.771441}, {4.38537, 1.7312, 4.01913}, 
    {6.44216, 8.99589, 4.29102}, {3.73494, 3.56734, 7.87144}, 
    {9.54701, 6.50486, 3.06923}, {2.63492, 0.274406, 9.23417}, 
    {3.71316, 0.458837, 4.63566}, {5.89552, 5.34734, 9.28392}} *)

I want to produce the following array:

{Differences[data[[All, 1]]], Differences[data[[All, 2]]], Differences[data[[All, 3]]]}

(* {{5.88125, 2.66477, -5.20911, 2.05679, -2.70722, 5.81207, -6.91208, 1.07823, 2.18236}, 
    {-3.94438, 6.06549, -4.72847, 7.26469, -5.42855, 2.93752, -6.23046, 0.184431, 4.88851}, 
    {-3.09942, -2.33744, 3.24769, 0.271883, 3.58043, -4.80221, 6.16494, -4.59851, 4.64825}} *)

1 Answer

Let’s block ads! (Why?)

Recent Questions – Mathematica Stack Exchange