2
$\begingroup$

At present I am writing a scientific paper and have problems bringing source code into mathematical form.

I have a time series that I present in Python as a list of tuples. For example:

timeseries = [(datetime_1, 1.0),(datetime_2, 2.0),...,(datetime_999, 999.0)]

For these I calculate, for example, the area between two points in time using the area content formula for trapezoids:

for i in range(0, len(timeseries)):
    area.append(0.5 * (timeseries[i][1] + timeseries[i+1][1]) 
                    * (ticks(timeseries[i+1][0]) - ticks(timeseries[i][0])))

However, I would like to do my scientific work without source code in it. How can this best be formulated in a scientific thesis with mathematical tools?

My approach was to describe the list of tuples with two mathematical vectors:

$\pmb{x}_{dates} \in \mathbb{R}^n$ with $x_i$ which represents the miliseconds from 1970 and $\pmb{x}_{values} \in \mathbb{R}^n$ with $x_i$ which represent the corresponding values. Then we have a vector $\pmb{a}$ with: $$\Big\{\Big(\frac{1}{2} * (x_i^{values} + x_{i+1}^{values}) * (x_{i+1}^{dates} - x_{i}^{dates})\Big), ...,\Big(\frac{1}{2} * (x_{n-1}^{values} + x_{n}^{values}) * (x_{n}^{dates} - x_{n-1}^{dates})\Big)\Big\}$$

Is my approach okay? How would you do that?

$\endgroup$
  • $\begingroup$ I see no objection to writing an equation like $a_i = \tfrac{1}{2}(y_i + y_{i+1})(x_{i+1} - x_i)$, defining $a \in \mathbb{R}^n$ as a function of $x \in \mathbb{R}^n$ and $y \in \mathbb{R}^n$. $\endgroup$ – Calum Gilhooley Sep 28 '18 at 11:35
  • $\begingroup$ @CalumGilhooley Thanks for your feeback. Then I'd write it something like this: $\pmb{a} \in \mathbb{R}^{n-1}$ is a vector with $a_i = \frac{1}{2} * (x_i^{values} + x_{i+1}^{values}) * (x_{i+1}^{dates} - x_{i}^{dates})$. And would you not use labels (such as "values" and "dates") when defining variables? $\endgroup$ – Anne Bierhoff Sep 28 '18 at 12:01
  • $\begingroup$ I personally wouldn't use labels in that way - but nor would I claim to know what is good practice, especially in a field I'm not familiar with, because conventions differ widely, even between pure and applied subfields of mathematics. That said, I would be inclined to use ordinary English text to explain that $x$ (or whatever other symbol is chosen) is an $n$-tuple of dates, $y$ (or ... etc.) is an $n$-tuple of values, and $a$ (or ...) is an $n$-tuple of areas. Keeping labels out of the equation makes it easier to read (for me, at least). $\endgroup$ – Calum Gilhooley Sep 28 '18 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.