# Combine Time Series

TimeSeriesThread can be used to add, multiply, or otherwise combine time series.

Subtract two time series.

 In[1]:= X{buseyOpen, buseyClose} = Table[TimeSeries[ FinancialData["NASDAQ:BUSE", prop, {{2013, 6, 1}, {2014, 6, 1}}]], {prop, {"Open", "Close"}}];
 In[2]:= Xdiff = TimeSeriesThread[{1, -1}.# &, {buseyClose, buseyOpen}]
 Out[2]=
 Out[3]=

Construct the time series of angular distance between the Moon and the Sun.

 In[4]:= Xdates = DateRange[{2014, 4, 1}, {2014, 6, 1}, {12, "Hour"}]; sunpos = SunPosition[dates, CelestialSystem -> "Equatorial"]; moonpos = MoonPosition[dates, CelestialSystem -> "Equatorial"];

Define a function to compute the angular distance between two objects on a sphere.

 In[5]:= XAngularDistance[{{\[Phi]1_, \[Theta]1_}, {\[Phi]2_, \[Theta]2_}}] := InverseHaversine[ Haversine[\[Phi]1 - \[Phi]2] + Cos[\[Phi]1] Cos[\[Phi]2] Haversine[\[Theta]1 - \[Theta]2]]/Degree
 In[6]:= Xangdist = TimeSeriesThread[AngularDistance, {sunpos, moonpos}];
 In[7]:= XDateListPlot[angdist, ImageSize -> 300, FrameLabel -> "degrees"]
 Out[7]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »