TimeSeriesMapThread[f,tes]
creates a new time series with time-value pairs {t,f[t,x]} for each pair {t,x} of the time or event series data tes.
TimeSeriesMapThread[f,tes,{{a1,a2,…},{b1,b2,…},…}]
gives {{t1,f[t1,x1,a1,b1,…]},{t2,f[t2,x2,a2,b2,…]},…} for tes.
TimeSeriesMapThread
TimeSeriesMapThread[f,tes]
creates a new time series with time-value pairs {t,f[t,x]} for each pair {t,x} of the time or event series data tes.
TimeSeriesMapThread[f,tes,{{a1,a2,…},{b1,b2,…},…}]
gives {{t1,f[t1,x1,a1,b1,…]},{t2,f[t2,x2,a2,b2,…]},…} for tes.
Details
- TimeSeriesMapThread is typically used to apply functions to the times and values in a time or event series.
- Possible forms of tes include:
-
TimeSeries[…] continuous time-ordered sampled data EventSeries[…] temporal events with corresponding values TemporalData[…] collection of paths composed of time-value pairs {x1,x2,…} list of values with implied integer times starting at 0 {{t1,x1},{t2,x2},…} list of time-value pairs - TimeSeriesMapThread[f[…]&,tes] is equivalent to TimeSeriesMap[f[#Time,…]&,tes].
- TimeSeriesMapThread threads pathwise for TemporalData objects with multiple paths.
Examples
open all close allBasic Examples (3)
Apply a function f to the times and values in a time series:
ts = TimeSeries[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5]}, {1}];TimeSeriesMapThread[f, ts]Take a time series of random real values:
ts = TimeSeries[RandomReal[{-1, 1}, 10 ^ 3], {1}];ListPlot[ts]Apply a function of time and value:
TimeSeriesMapThread[Sin[#1 / 100] + #2&, ts]ListPlot[%]Create a time series with increasing variance as a function of time:
ts = TimeSeries[Table[RandomVariate[NormalDistribution[0, σ]], {σ, 1000}]];ListPlot[ts]Add quadratic trend to the values:
TimeSeriesMapThread[#2 + #3&, ts, {Subdivide[0, 50, 999]^2}]//ListPlotScope (7)
Basic Uses (2)
ts = TimeSeries[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5]}, {1}];f[3, _] := 0;
f[_, v_] := v;TimeSeriesMapThread[f, ts]["Path"]Add time-dependent noise to a vector-valued signal:
data = TimeSeries[Table[{t, {Sin[t], Cos[t]}}, {t, 0, 30, 0.1}]];ListLinePlot[data]ListLinePlot[TimeSeriesMapThread[RandomReal[{-#1 / 50, #1 / 50}] + #2&, data]]Data Types (5)
Apply a function f to a list of time-value pairs:
ts = {{1, a}, {2, b}, {3, c}, {7, d}};TimeSeriesMapThread[f, ts]Set the values for times greater than 3 in TimeSeries to 1:
ts = TimeSeries[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5]}, {1}];f[a_, b_] := If[a > 3, 1, b]TimeSeriesMapThread[f, ts]["Path"]Visualize TemporalData for integer times:
data = RandomFunction[WienerProcess[0, 7], {0, 20, .1}, 40]ListLinePlot[data, PlotStyle -> Thin]TimeSeriesMapThread[If[Mod[#1, 1] == 0., #2, 0]&, data]ListLinePlot[%]Set the middle 50 values of EventSeries to 0:
es = TemporalData[EventSeries, {{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 5, 5, 6, 6, 6, 7, 8, 8, 9, 10, 10, 10, 10, 11, 11, 11, 12, 12,
12, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, ... 20, 20, 21, 22, 22,
23, 23, 24, 25, 26, 26, 27, 27, 28, 28, 28, 28, 29, 30, 30, 30, 31, 31, 31, 32, 32, 33, 33,
33}}, {{0, 99, 1}}, 1, {"Discrete", 1}, {"Discrete", 1}, 1,
{ResamplingMethod -> None, ValueDimensions -> 1}}, False, 10.];ListPlot[es, Filling -> Axis]TimeSeriesMapThread[If[25 < #1 < 74, 0, #2]&, es]ListPlot[%, Filling -> Axis]Modify the values of a time series involving quantities:
s = Quantity[{0, 16, 9, 3, 20, 23}, "Meters"];ts = TimeSeries[s]Modify the values for times greater than 2:
f[a_, b_] := If[a > 2, Quantity[1, "Meters"], b]new = TimeSeriesMapThread[f, ts]new["Path"]Applications (5)
Inflation (1)
The following are spot oil prices from 1970 to 2010. This data is not corrected for inflation:
oilPrices = TemporalData[TimeSeries, {{{Quantity[3.35, "USDollars"/"BarrelsOfOilEquivalent"],
Quantity[3.35, "USDollars"/"BarrelsOfOilEquivalent"],
Quantity[3.35, "USDollars"/"BarrelsOfOilEquivalent"],
Quantity[3.35, "USDollars"/"BarrelsOfOilEqu ... ilEquivalent"]}},
{TemporalData`DateSpecification[{1970, 1, 1, 0, 0, 0.}, {2010, 1, 1, 0, 0, 0.},
{{45, "Day"}, {15, "Hour"}, {41, "Minute"}, {20, "Second"}}]}, 1, {"Discrete", 1},
{"Discrete", 1}, 1, {ValueDimensions -> 1}}, True, 10.];DateListPlot[oilPrices, Joined -> True]The consumer price index (CPI) is often used to correct historical prices for inflation:
pi = TemporalData[TimeSeries, {{{22.424, 22.747, 22.935, 23.233, 23.588, 23.905, 24.146, 24.345, 24.745,
24.894, 25.114, 25.398, 25.398, 26.145, 26.634, 27.095, 27.095, 28.266, 29.127, 30.012, 30.69,
31.138, 31.692, 32.22, 32.567, 32.893, 33.3 ... 100.179, 100.179}},
{TemporalData`DateSpecification[{1970, 1, 1, 0, 0, 0.}, {2010, 1, 1, 0, 0, 0}, {1, "Quarter"}]},
1, {"Continuous", 1}, {"Discrete", 1}, 1,
{ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 314.1];DateListPlot[pi, Joined -> True]cpiCor[base_, t_, v_] := (v * base/pi[t])Adjusted prices for inflation using the most recent value of the CPI:
baseCPI = pi["December 31st, 2009"]cp = TimeSeriesMapThread[cpiCor[baseCPI, #1, #2]&, oilPrices];DateListPlot[{cp, oilPrices}, Joined -> True, PlotLegends -> {"Adjusted", "Original"}, PlotStyle -> Thick]Find the adjusted oil price on March 5, 2001:
cp["March 5th, 2001"]Weather (1)
The following are monthly average temperatures for a Missouri city over a three-year period. Separate the seasonal and nonseasonal components of this data:
temp = TemporalData[TimeSeries, {{{22.82, 17.01, 11.85, 7.14, 0.37, -4.54, -1.58, 6.57, 12.34, 19.02,
20.95, 22.02, 19.59, 19.77, 12.38, 7.21, -0.54, -2.28, 1.12, 3.13, 12.51, 16.38, 23.54, 23.65,
23.23, 20.73, 12.63, 6.39, -3.88, 2.98, -1.07, 4.84, 13.32, 16.42, 21.69, 24.02, 22.18}},
{TemporalData`DateSpecification[{2004, 1, 1}, {2007, 1, 1}, "Month"]}, 1, {"Discrete", 1},
{"Discrete", 1}, 1, {ValueDimensions -> 1}}, True, 10.];DateListPlot[temp, Joined -> True]Fit a model for the seasonal component:
mod = NonlinearModelFit[temp, a Sin[(x - b/5000000)], {a, b}, x];DateListPlot[scomp = TimeSeriesMapThread[mod[#1]&, temp], Joined -> True]Use the model to obtain the nonseasonal component:
sCor[t_, v_] := v - scomp[t]ncomp = TimeSeriesMapThread[sCor, temp];DateListPlot[ncomp, Joined -> True]Combining the components yields the original data:
Normal[TimeSeriesThread[Total, {ncomp, scomp}]] == Normal[temp]Simulation (1)
Use TimeSeriesMapThread to simulate a transformed random process:
μ = 0;σ = 1 / 3;t0 = 0;t1 = 2;x0 = 0;x1 = 0;Simulate WienerProcess:
proc = WienerProcess[μ, σ];
SeedRandom[3];
data = RandomFunction[proc, {t0, t1, .1}];Apply transformation to the random sample to obtain Brownian bridge:
sample = TimeSeriesMapThread[x0(x1 - x0)(#1 - t0) / (t1 - t0) + #2 - (#1 - t0) Last[data["Values"]] / (t1 - t0) - (t1 - #1)First[data["Values"]] / (t1 - t0)&, data];Compare to the corresponding BrownianBridgeProcess:
SeedRandom[3];
data = RandomFunction[BrownianBridgeProcess[σ, {t0, x0}, {t1, x1}], {t0, t1, .1}];ListLinePlot[{sample, data}, PlotStyle -> {Thick, Dotted}]GDP (1)
Study the discrepancy in the estimate of GDP for Switzerland, in dollars:
GDPDiscrepancy = EntityValue[Entity["Country", "Switzerland"], EntityProperty["Country", "DiscrepancyInExpenditureEstimateOfGDP", {"CurrencyUnit" -> "CurrentLCU", "Date" -> All}]]The currency in which data is given:
GDPDiscrepancy["FirstValue"]//QuantityUnitTransfer to US dollars and adjust for inflation:
GDPDiscrepancyInUSDollars = TimeSeriesMapThread[InflationAdjust[Quantity[QuantityMagnitude[#2], DatedUnit["SwissFrancs", First@DateList[#1]]], DatedUnit["USDollars", First@DateList[#1]]]&, GDPDiscrepancy]DateListPlot[GDPDiscrepancyInUSDollars]Moon Phases (1)
Create a lunar calendar in which the background color depends on the fraction of the moon illumination:
dates = DateRange[DateObject[{2014, 1, 1, 12}], DateObject[{2014, 1, 31, 12}], 1];mp = MoonPhase[dates, "Icon"];
sf = MoonPhase[dates, "Fraction"];Create a new series of labeled images with gradient background:
phases = TimeSeriesMapThread[Framed[Labeled[ImageResize[#2, 45], Style[DateString[#1, {"DayNameShort", " ", "DayShort"}]]], Background -> Lighter[ColorData["StarryNightColors", #3], .3]]&, mp, {sf["Values"]}];Labeled[Grid[Partition[phases["Values"], 7, 7, 4, ""], Dividers -> All, Spacings -> {0, 0}], "January 2014", Top]Properties & Relations (3)
Take a simple time series and construct another one by map-threading f:
ts = TimeSeries[{11, 17, 13}]res1 = TimeSeriesMapThread[f, ts]This result can also be obtained by converting to Tabular, using ConstructColumns and converting back:
ConstructColumns[Tabular[ts], "s" -> Function[f[#Timestamp, #Value]]]res2 = TimeSeries[%[All, "s"], {ts["Times"]}]res1 === res2Map a binary function f over timestamps and values of a simple time series:
ts = TimeSeries[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5]}, {1}]res = TimeSeriesMapThread[f, ts]TimeSeriesMap[f, ts]//NormalNormal[res]The same result can be obtained using TransformColumns:
res === TransformColumns[ts, "Value" -> (f[#Timestamp, #Value]&)]TimeSeriesMapThread[Function[f[#2]],ts] is equivalent to TimeSeriesMap[f,ts]:
ts = TimeSeries[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5]}, {1}]res = TimeSeriesMapThread[f[#2]&, ts]Normal[res]res === TimeSeriesMap[f, ts]Related Guides
Text
Wolfram Research (2014), TimeSeriesMapThread, Wolfram Language function, https://reference.wolfram.com/language/ref/TimeSeriesMapThread.html (updated 2026).
CMS
Wolfram Language. 2014. "TimeSeriesMapThread." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/TimeSeriesMapThread.html.
APA
Wolfram Language. (2014). TimeSeriesMapThread. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TimeSeriesMapThread.html
BibTeX
@misc{reference.wolfram_2026_timeseriesmapthread, author="Wolfram Research", title="{TimeSeriesMapThread}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/TimeSeriesMapThread.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_timeseriesmapthread, organization={Wolfram Research}, title={TimeSeriesMapThread}, year={2026}, url={https://reference.wolfram.com/language/ref/TimeSeriesMapThread.html}, note=[Accessed: 13-June-2026]}