*This jupyter notebook is part of a collection of notebooks on various topics discussed during the Time Domain Astrophysics course delivered by Stefano Covino at the [Università dell'Insubria](https://www.uninsubria.eu/) in Como (Italy). Please direct questions and suggestions to [stefano.covino@inaf.it](mailto:stefano.covino@inaf.it).*
#### - This is serious. Specialized academic courses, in a manner of speaking, should be enjoed...!
#### - This is serious. Specialized academic courses, in a manner of speaking, should be enjoyed...!
%% Cell type:markdown id:2d351400 tags:
## Time-Series are ubiquitous
***
- Anytime we have a measurement repeated multiple times we have a time-series.



- As a matter of fact, a time-series does not need to have "time" as index!


%% Cell type:markdown id:722fb437 tags:
## Temptative program (it may change…)
***
1. Introduction
2. Statistics reminder - part I
3. Statistics reminder - part II
4. Spectral analysis - part I
5. Spectral analysis - part II
6. Science cases: Sunspots Number - X-ray Binaries
7. Irregularly sampled time series
8. Science Cases - Variable Stars
9. Time domain analysis - part I
10. Time domain analysis - part II
11. Science Cases - AGN and blazars
12. Wavelet analysis
13. Time of arrival analysis
12. Wavelet analysis and climatology science case
13. Time of arrival analysis and paleo-climatology science case
14. Science case: FRBs
15. Non-parametric methods - part I
16. Non-parametric methods - part II
17. Singular spectrum analysis - part I
18. Singular spectrum analysis - part II
19. Gaussian processes - part I
20. Gaussian processes - part II
21. Science case: GRBs
22. Astrostatistics: final considerations
%% Cell type:markdown id:f73fd0ea tags:
## How is the course managed?
***
### Frontal lectures
- These are the traditional university lectures.
- Although this increases the organizational complexity substantially, I am availbale to stream and record my lectures, if needed.
- There are contraindications. As a matter of fact, this is one of few cases where a remote access is not even close as effective as being in presence.

### Real research life examples…
- Scientists working in the field will deliver "didactic lectures", allowing one to see most of ideas deveooped during the course applied in a real research environment.

### (Optional) papers to deepen our knowledge…
- Most of the topics discussd during the course can be investigated thoroughly and papers from astrophysical (mainly) literature are presented for particularly concerned readers.

### Question time
- The course is divided in several main sections. At the end of each of them, some time will be devoted to open discussions and questions.

### Lectures from specialists in the field
- Together with regular lectures, a few specialists in the field, i.e. scientist carrying out researches by time-domain tools and techniques, are invited to describe their works.

### Language
- According to university guidelines, lectures will be delivered in English. Of course, a fair evaluation of the context might ask some flexibility.

### Statistical framework
- During this course we are going to work in a Bayesian framework.
- Bayesian statistics is an approach to inferential statistics based on Bayes' theorem, where available knowledge about parameters in a statistical model is updated with the information in observed data. The background knowledge is expressed as a prior distribution and combined with observational data in the form of a likelihood function to determine the posterior distribution. The posterior can also be used for making predictions about future events.
- Nevertheless, we are not dogmatic and mentions or applications based on familiar "frequentist" approaches are preseneted and discussed, when we deem it opportune.

### Programming languages
- Most of the examples we are going to analyze during the course are based on some sort of computer analysis.
-`Python` is *de-facto* the standard language in data science.
- Yet, while this language is definitely truly amazing, well designed and worth mastering, for the specific needs of scientific computing there are alternatives of growing popularity.
-We threfore provide examples mainly with `Julia`, and encourage the students to get some confidence with this programming language too.
-Indeed, we provide examples mainly with `Julia`, and encourage the students to get some confidence with this programming language too.
- Notebooks are written by the [markdown language](https://www.markdownguide.org/basic-syntax/), a simple language integrating features of the HTML and latex languages.
-A remarkable introducti0n to the `julia` language for a scientist is available online[here](https://juliadatascience.io/).
-Many introductions to the `julia` language for a scientist are available online, e.g. [Julia data science](https://github.com/tirthajyoti/Julia-data-science).
%% Cell type:markdown id:9bf3b78e tags:
## Warning! The course is not only for astrophysicists!
- It is indeed part of the set of courses for future astrophysicists. Nevertheles, almost nothing we are going to discuss is truly only for astrophysics. In reality, several applications and ideas are taken from other fields, i.e. economics, social sciences, climatology, etc.
- It is indeed part of the set of courses for future astrophysicists. Nevertheles, almost nothing we are going to discuss is truly only for astrophysics. In reality, several applications and ideas are taken from other fields, i.e. economiy, social sciences, climatology, etc.

%% Cell type:markdown id:dedc01e8 tags:
## Final assessment
- The final examination is an oral one.
-*Students* must interact with the teacher in advance of the examination and a science case obtained by the modern literature will be selected.
- The *student* will be asked to properly describe the main formal aspects of the study and discuss critically the reliability and limits of the presented results.
> As a ganeral rule, in order to take the exam attending $\sim$ 50\% of the lectures is required.
> As a ganeral rule, in order to take the exam, attending $\sim$ 50\% of the lectures is required.
%% Cell type:markdown id:6e9e2d08 tags:
## Gitlab repository
- Slides, notebooks, papers, etc. are available on [gitlab](https://www.ict.inaf.it/gitlab/stefano.covino/TimeDomainAstrophysics.git)
- Check the repository frequently since is (rather often) updated during the course.
- This clones the whole tree (i.e. the course material, about 3GB).
> Repeating frequently the last command (`git pull`) you will always have the tree fully updated and you notebooks, data, papers, etc. ready to be used on your computer.
The course calendar, notes, advised, topics discussed during a given lecture, and remote connection details can be found at this [url](https://calendar.google.com/calendar/u/0?cid=Y19iMmFmN2RiNjQ0OWNjMTdjY2ZmMzJlMzE3ZjVhZWQ4N2FkYzliN2FkZWFmMzY1YjllYmMwOWFkODA4MjhlNzZjQGdyb3VwLmNhbGVuZGFyLmdvb2dsZS5jb20).
%% Cell type:markdown id:e96ac78c tags:
## Relaxing time(-series...)

%% Cell type:markdown id:ffe137ba tags:
## Reference & Material
- The course is based on published scientific papers distributed by the teacher before any main topic is addressed.
- Science cases are based on actual scientific papers as well.
- Slides prepared by the teacher will also be distributed.
- A general introductory text to time series analysis as: [“Introduction to Time Series and Forecasting”, by P.J. Brockwell and R.A Davis](https://link.springer.com/book/10.1007/978-3-319-29854-2) might be useful. However, any other analogous text easily obtainable by the student will be fine as well.
- Two textbooks more strictly related to the topics discussed during the course mainly, but not only, for astrophysical applications are:
-[“Modern Statistical Methods for Astronomy”, by E.D. Feigelson and G.J. Babu](https://www.cambridge.org/core/books/modern-statistical-methods-for-astronomy/941AE392A553D68DD7B02491BB66DDEC)
-[“Statistics, data Mining and Machine Learning in Astronomy”, by Ivezić et al.](https://press.princeton.edu/books/hardcover/9780691198309/statistics-data-mining-and-machine-learning-in-astronomy)
%% Cell type:markdown id:dff2c952 tags:
## Further Material
Papers for examining more closely some of the discussed topics.
-[Voughan et al. (2013) - "Random Time Series in Astronomy"](https://royalsocietypublishing.org/doi/10.1098/rsta.2011.0549)
-[Storopoli et al. (2021) - "Julia Data Science"](https://juliadatascience.io/)
This notebook is provided as [Open Educational Resource](https://en.wikipedia.org/wiki/Open_educational_resources). Feel free to use the notebook for your own purposes. The text is licensed under [Creative Commons Attribution 4.0](https://creativecommons.org/licenses/by/4.0/), the code of the examples, unless obtained from other properly quoted sources, under the [MIT license](https://opensource.org/licenses/MIT). Please attribute the work as follows: *Stefano Covino, Time Domain Astrophysics - Lecture notes featuring computational examples, 2026*.
*This jupyter notebook is part of a collection of notebooks on various topics discussed during the Time Domain Astrophysics course delivered by Stefano Covino at the [Università dell'Insubria](https://www.uninsubria.eu/) in Como (Italy). Please direct questions and suggestions to [stefano.covino@inaf.it](mailto:stefano.covino@inaf.it).*
- Let $X_1$, $X_2$,…,$X_N$ be i.i.d. random variables that form a random sample of size ’N’. Assume that we have drawn this sample from a population that has a mean $μ$ and variance $σ²$.
- Let $\bar{X}_N$ be the sample mean: $\bar{X}_N = \frac{X_1+X_2...+X_N}{N}$
- Let $\bar{Z}_N$ be the standardized sample mean: $\bar{Z}_N = \frac{\bar{X}_N-\mu}{\sigma/\sqrt{N}}$
- The Central Limit Theorem states that as N tends to infinity, $\bar{Z}_N$ *converges in distribution* to $N(0,1)$, i.e. the CDF of $\bar{Z}_N$ becomes identical to the CDF of $N(0, 1)$.
- To prove this statement, we use the property of the Moment Generating Function (MGF) that if the MGFs of $X$ and $Y$ are identical, then so are their CDFs.
- To prove this statement, we use the property of the Moment Generating Function (MGF): if the MGFs of $X$ and $Y$ are identical, then so are their CDFs.
%% Cell type:markdown id:b283881c tags:
### Moment Generating Function
***
- The k-th moment of a random variable $X$ is the expected value of $X$ raised to the k-th power: $\mu_k(X) = \mathbb{E}(X^k) = \sum_i x_i^k P(X=x_i) $
- The k-th moment of $X$ around some value $c$ is known as the k-th central moment of $X$: $\mu_k(X) = \mathbb{E}((X-c)^k) = \sum_i (x_i-c)^k P(X=x_i) $
- The k-th standardized moment of $X$ is the k-th central moment of $X$ divided by k-th power of the standard deviation of $X$: $\frac{\mu_k(X)}{\sigma^k} = \frac{\mathbb{E}((X-c)^k)}{\sigma^k} $
- For the record, the first 5 moments of $X$ have specific values or meanings attached to them:
- The zeroth’s raw and central moments of X are $\mathbb{E}(X^0)$ and $\mathbb{E}[(X — c)^0]$ respectively. Both equate to 1.
- The 1st raw moment of $X$ is $\mathbb{E}(X)$. It’s the mean of $X$.
- The second central moment of $X$ around its mean is $\mathbb{E}[X — \mathbb{E}(X)]^2$. It’s the variance of X.
- The third and fourth standardized moments of $X$ are $\mathbb{E}[X — \mathbb{E}(X)]^3/σ^3$, and $\mathbb{E}[X — \mathbb{E}(X)]^4/σ^4$. They are the skewness and kurtosis of $X$ respectively.
- Let's now define a new random variable $tX$ where $t$ is a real number. Here’s the Taylor series expansion of $e$ to the power $tX$ evaluated at $t = 0$:
- Now, it is easy to realize that the k-th derivative of the EGF, when evaluated at $x = 0$ gives us the k-th coefficient of the underlying sequence. So, $M_X^0(t=0) = 1, M_X^1(t=0) = \mathbb{E}(X), ..., M_X^k(t=0) = \mathbb{E}(X^k)$
- If two random variables $X$, $Y$ have identical moments (i.e. identic MGF) they must unavoidably have identical CDF.
- We can say more. If $Y = aX + b$, then $M_Y(t) = \mathbb{E}(e^{(aX+b)t}) = e^{bt}M_X(t) $.
- Besides, if $Y$ the sum of $N$ independent, identically distributed random variables, $Y = X_1 + X_2 + ...$ then $M_Y(t) = \mathbb{E}(e^{t(X_1+X_2+..)}) = \mathbb{E}(e^{tX_1})\mathbb{E}(e^{tX_2})...$, due to the independency. And, finally $M_Y(t) = [\mathbb{E}(e^{tX})]^N = [M_X(t)]^N$ since they are identically distributed.
- One last useful result related to MGF is that if $X \sim \mathcal{N}(0,1)$ then $M_X(t) = e^{\frac{t^2}{2}}$, since the given distribution has mean = 0, variance = 1, skew = 0 and kurtosis = 1.
%% Cell type:markdown id:3af8b388 tags:
- Coming back to the proof of the CLT, we now understand that we need to prove that the MGF of $\bar{Z}_N$ converges to the MGF of $\mathcal{N}(0,1)$, i.e.:
- Next, we split this expansion into two parts. The first part is a finite series of three terms corresponding to $k = 0, k = 1$, and $k = 2$. The second part is the remainder of the infinite series.
- $M^0$, $M^1$, $M^2$, etc. are the 0-th, 1st, 2nd, and so on derivatives of the MGF $M_Z(t/\sqrt{N})$ evaluated at ($t/\sqrt{N}) = 0$. We know that these derivatives of the MGF are the 0-th, 1st, 2nd, etc. moments of $Z$.
- The 0-th moment, $M^0(0)$, is always 1. $Z$ is, by its construction, a standard normal random variable. Hence, its first moment (mean), $M^1(0) = 0$, and its second moment (variance), $M^2(0) = 1$. So:
This notebook contains material obtained by https://towardsdatascience.com/a-proof-of-the-central-limit-theorem-8be40324da83.
%% Cell type:markdown id:05e93b1d tags:
## Course Flow
***
<table>
<tr>
<td>Previous lecture</td>
<td>Next lecture</td>
</tr>
<tr>
<td><ahref="Lecture-StatisticsReminder.ipynb">Reminder of frequentist statistics</a></td>
<td><ahref="Lecture-StatisticsReminder.ipynb">Reminder of frequentist statistics</a></td>
</tr>
</table>
%% Cell type:markdown id:591bd355 tags:
**Copyright**
This notebook is provided as [Open Educational Resource](https://en.wikipedia.org/wiki/Open_educational_resources). Feel free to use the notebook for your own purposes. The text is licensed under [Creative Commons Attribution 4.0](https://creativecommons.org/licenses/by/4.0/), the code of the examples, unless obtained from other properly quoted sources, under the [MIT license](https://opensource.org/licenses/MIT). Please attribute the work as follows: *Stefano Covino, Time Domain Astrophysics - Lecture notes featuring computational examples, 2025*.
This notebook is provided as [Open Educational Resource](https://en.wikipedia.org/wiki/Open_educational_resources). Feel free to use the notebook for your own purposes. The text is licensed under [Creative Commons Attribution 4.0](https://creativecommons.org/licenses/by/4.0/), the code of the examples, unless obtained from other properly quoted sources, under the [MIT license](https://opensource.org/licenses/MIT). Please attribute the work as follows: *Stefano Covino, Time Domain Astrophysics - Lecture notes featuring computational examples, 2026*.