*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).*
12. 3/4 - Guest lecture - Spectral analysis in Cosmology
13. 9/4 - Guest lecture - X-ray pulsators
14. 10/4 - Time domain analysis - ARIMA models
15. 16/4 - Time domain analysis - Advanced tools
16. 30/4 - Wavelet analysis
17. 7/5 - Guest lecture - Exoplanets
18. 8/5 - Time of arrival analysis
19. 14/5 - Non-parametric methods
20. 15/5 - Gaussian processes
21. 21/5 - Science case: GRBs
22. 22/5 - 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 will also provide examples with `Julia`, and encourage the students to get some confidence with this programming language too.
- We threfore 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.
## Warning! The course is not only for astrophysicists!
- It is indeed part of the set of courses for future astrophysocsts. 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. economics, 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.
%% 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.
- 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)
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*.
- `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 will also provide examples with `Julia`, and encourage the students to get some confidence with this programming language too.
- We threfore 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.
## Warning! The course is not only for astrophysicists!
- It is indeed part of the set of courses for future astrophysocsts. 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. economics, social sciences, climatology, etc.
*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).*
"""
# ╔═╡ ec67de24-d88a-46fa-ae46-c0cd7b797adc
md"""
**This is a `pluto` notebook**
"""
# ╔═╡ 5029a214-0841-40fb-b397-4a2e1047bfb7
md"""
$(LocalResource("Pics/TimeDomainBanner.jpg"))
"""
# ╔═╡ 404060d3-23ec-400b-84cf-779e63b90293
md"""
# Baeysian view of the LS Periodogram
***
- What we want to be able to do is to detect variability and measure the period in the face of both noisy and incomplete data. Instead we'll use Fourier decomposition to get a more useful tool for actual data analysis.
- For a periodic signal we have:
$$y(t+P)=y(t),$$ where $P$ is the period.
- We can create a *phased light curve* that plots the data as function of phase:
- where ${\rm int}(x)$ returns the integer part of $x$.
"""
# ╔═╡ 72cf6fcf-2e2f-4dee-994b-ce2bfef51802
md"""
### A Single Sinusoid
***
- Let's take the case where the data are drawn from a single sinusoidal signal:
$$y(t)=A \sin(\omega t+\phi)+\epsilon$$
- and determine whether or not the data are indeed consistent with periodic variability and, if so, what is the period.
- This model is **non-linear** in the frequency term, $\omega$ and the phase, $\phi$ and therefore We rewrite the argument as $\omega(t−t_0)$ (reexpressing the phase term) and use trigonometrics identies to rewrite the model as:
$$y(t)=a \sin(\omega t)+b \cos(\omega t)$$
- where
$$A=(a^2+b^2)^{1/2} \text{ and } \phi=\tan^{−1}(b/a)$$
- The model is now linear with respect to coefficients $a$ and $b$ (and nonlinear only with respect to frequency, $\omega$).
"""
# ╔═╡ 3941f9fb-5b32-4152-8e3f-65767e63e055
md"""
- Assuming constant uncertainties on the data, we can write a likelihood function down:
- where $y_i$ is the measurement (e.g., the brightness of a star) taken at time $t_i$.
- With a lof of math we do not report here, and assuming uniform priors on $a, b, \omega$, and $\sigma$ (which gives nonuniform priors on $A$ and $\phi$), the posterior distribution of parameters can be simplified to:
- To determine if our source is variable or not, we first compute $P_{\rm LS}(\omega)$ and then model the odds ratio for our variability model vs. a no-variability model.
- If our variability model is "correct", then the peak of $P(\omega)$ gives the best $\omega$ and the $\chi^2$ at $\omega = \omega_0$ is $N$.
"""
# ╔═╡ 41b8576d-21fc-4683-a379-8a6bfb835a9a
md"""
- If the true frequency is $\omega_0$ then the maximum peak in the periodogram should have a height:
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*.