Commit 5a62d6bd authored by Stefano Covino's avatar Stefano Covino
Browse files

270326 commit

parent 316069bd
Loading
Loading
Loading
Loading
+14 −4

File changed.

Preview size limit exceeded, changes collapsed.

+23 −0
Original line number Diff line number Diff line
%% Cell type:markdown id:91330533 tags:

**What is this?**


*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).*

%% Cell type:markdown id:915ee876 tags:

**This is a `julia` notebook**

%% Cell type:code id:41d298ca-3a5c-457d-ab57-308a7de2d3c0 tags:

``` julia
import Pkg; Pkg.activate(".")
```

%% Output

      Activating project at `/mnt/chromeos/GoogleDrive/MyDrive/Teaching/Insubria/Docs_2025_26/Lectures/Lecture - Spectral Analysis`

%% Cell type:code id:6fff2b26-f553-42dd-a7fd-292dbcdbfbed tags:

``` julia
Pkg.instantiate()
```

%% Output

    Precompiling packages...
       3751.8 ms  ✓ StructUtils
       1833.7 ms  ✓ Interpolations → InterpolationsUnitfulExt
       1036.7 ms  ✓ StructUtils → StructUtilsTablesExt
       2383.2 ms  ✓ FFMPEG_jll
       4454.8 ms  ✓ Cairo
       4604.1 ms  ✓ DSP
       1529.4 ms  ✓ DSP → OffsetArraysExt
       6901.0 ms  ✓ JSON
       7864.2 ms  ✓ Distributions
       1474.2 ms  ✓ ColorBrewer
       1719.4 ms  ✓ Distributions → DistributionsTestExt
       2840.3 ms  ✓ Distributions → DistributionsChainRulesCoreExt
       1687.3 ms  ✓ KernelDensity
      50750.9 ms  ✓ DataFrames
       2007.5 ms  ✓ Latexify → DataFramesExt
     166724.3 ms  ✓ Makie
       6654.0 ms  ✓ Polynomials → PolynomialsMakieExt
      51968.9 ms  ✓ CairoMakie
      18 dependencies successfully precompiled in 237 seconds. 309 already precompiled.

%% Cell type:code id:8fa2633c-c139-4196-8a1e-3273bfe990a4 tags:

``` julia
using CairoMakie
```

%% Cell type:markdown id:53194e25 tags:

![Time Domain Astrophysics](Pics/TimeDomainBanner.jpg)

%% Cell type:markdown id:a7b36f9a tags:

# A few important Fourier Transforms
***

## The rectangular function
***

- We want to compute the FT of the rectangular function: e.g. a function $g(t)$ with a given amplitude and extending from $t=-T/2$ to $t=T/2$. For $|t|>T/2$, $g(t)=0$.

- We will write the square pulse or box function as $rect_T(t)$, indicating that the rectangle function is equal to 1 for a period of $T$ (from $-T/2$ to $+T/2$) and 0 elsewhere,

%% Cell type:markdown id:8781bea3 tags:

 $$\mathfrak{F} \{  g(t) \} = G(f) = \int_{-\infty}^\infty g(t) e^{-2 \pi i f t} dt = \int_{-T/2}^{T/2} A e^{-2 \pi i f t} dt = \frac{A}{-2 \pi i f} e^{-2 \pi i f t}\Big|_{-T/2}^{T/2} = \frac{A}{-2 \pi i f} [ e^{-\pi i f T} - e^{\pi i f T} ] = $$

 $$ = \frac{AT}{\pi f T} \frac{ e^{-\pi i f T} - e^{\pi i f T} }{2i} = \frac{AT}{\pi f T} \sin (\pi f T) \equiv AT {\rm sinc} (fT)$$

 - where we have defined the "sinc" function defined as ${\rm sinc} (t) = \sin(\pi t) / \pi t$.

%% Cell type:code id:d6bcbb4b-132a-4ebf-9af6-acc1d871f456 tags:

``` julia
T=2.

#f(x) = (x >= -T/2 && x <= T/2) ? 1 : 0

function f(x; T=2)
    if x >= -T/2 && x <= T/2
        return 1
    else
        return 0
    end
end

xrng = range(start=-5.,stop=5.,step=0.01)


fg1 = Figure(size=(1000,500))

ax1 = Axis(fg1[1, 1],
    xlabel = "t",
    )

T=1
lines!(xrng,map(x -> f(x;T=T),xrng),label="T = "*string(T))
T=3
lines!(xrng,map(x -> f(x;T=3),xrng),label="T = "*string(T))


axislegend()


frng = range(start=-10.,stop=10.,step=0.01)


ax2 = Axis(fg1[1, 2],
    xlabel = "f",
    )

T=1
lines!(frng,T*sinc.(T*frng),label="T = "*string(T))
T=3
lines!(frng,T*sinc.(T*frng),label="T = "*string(T))

xlims!(-5,5)

axislegend()

fg1
```

%% Output


%% Cell type:markdown id:15b3a2a7-1cbc-4615-8c20-c8c35e5c92b7 tags:

## The Gaussian function
***

- We want now to compute the FT of the Gaussian function: $g(t) = e^{-\pi t^2}$.

- Let G(f) be the Fourier Transform of g(t), so that:


$$G(f) = \mathfrak{F} \{  g(t) \} = \int_{-\infty}^\infty g(t) e^{-2 \pi i f t} dt = \int_{-\infty}^\infty e^{-\pi t^2} e^{-2 \pi i f t} dt$$

- Take the derivative of both sides of equation with respect to f, so that:

$$\frac{dG(f)}{dt} = \int_{-\infty}^\infty e^{- \pi t^2} (-2 i \pi t) e^{-2 \pi i f t} dt$$

- Writing $u = e^{-2 \pi i f t}  \rightarrow du = (-2 \pi i f)e^{-2 \pi i f t} dt$ and $v = i e^{-\pi t^2} \rightarrow dv = -2 \pi i t e^{-\pi t^2} dt $, and given the formula for integration by parts: $\int udv = uv - \int vdu$ we have (the uv term becomes zero, because the limits are evaluated from $-\infty$ to $\infty$, where the product is zero):

$$\frac{dG(f)}{dt} = \int_{-\infty}^\infty ie^{- \pi t^2} (-2 i \pi f) e^{-2 \pi i f t} dt = -2 \pi f \int_{-\infty}^\infty e^{- \pi t^2} e^{-2 \pi i f t} dt = -2 \pi f G(t)$$

- This is a first order simple differential equation for $G(f)$. The solution for this differential equation is given by:

$$G(f) = G(0) e^{-\pi f^2} $$

- All we need to do now to find $G(f)$ is figure out what $G(0)$ is.
- $G(0)$ is simply the average value of $g(t)$, because if you substitute $f=0$ into the equation for $G(f)$ the complex exponential term goes away.
    - The integral has actually an [elegant solution](https://en.wikipedia.org/wiki/Gaussian_integral). The result is:

$$G(0) = \int_{-\infty}^\infty e^{-\pi t^2} dt = 1$$

- Therefore:

$$G(f) = \mathfrak{F} \{  g(t) \} = e^{-\pi f^2} $$

%% Cell type:markdown id:0cd961f2 tags:

### Credits
***

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><a href="Lecture-StatisticsReminder.ipynb">Reminder of frequentist statistics</a></td>
    <td><a href="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, 2026*.
+27 −12

File changed.

Preview size limit exceeded, changes collapsed.

−4.04 KiB (393 KiB)
Loading image diff...
+118 −114

File changed.

Preview size limit exceeded, changes collapsed.

Loading