User:Lothar.brendel: Difference between revisions

From Arbeitsgruppe Kuiper
Jump to navigation Jump to search
m (→‎Background: engl.)
Line 15: Line 15:
== Polynomial fit \(\hat y=\sum_{p=0}^{m-1}a_p x^p\) ==
== Polynomial fit \(\hat y=\sum_{p=0}^{m-1}a_p x^p\) ==


verschwindende partielle Ableitung nach \(a_q\):
vanishing partial derivative with respect to \(a_q\):
\[
\[
\begin{align}
\begin{align}
0&=\sum_i \frac{y_i-\sum_p a_p x_i^p}{\sigma_i^2}x_i^q\\
0&=\sum_i \frac{y_i-\sum_p a_p x_i^p}{\sigma_i^2}x_i^q\\
\Leftrightarrow\quad
\Leftrightarrow\quad
\underbrace{\sum_i\frac{y_i x_i^q}{\sigma_i^2}}_{\displaystyle\psi_q}&=\sum_i\sum_p \frac{a_p x_i^{p+q}}{\sigma_i^2}=\sum_p a_p\underbrace{\sum_i\frac{x_i^{p+q}}{\sigma_i^2}}_{\displaystyle X_{pq}}
\underbrace{\sum_i\frac{y_i x_i^q}{\sigma_i^2}}_{\displaystyle\psi_q}& =\sum_i\sum_p \frac{a_p x_i^{p+q}}{\sigma_i^2}=\sum_p a_p\underbrace{\sum_i\frac{x_i^{p+q}}{\sigma_i^2}}_{\displaystyle X_{pq}}
\end{align}
\end{align}
\]
\]
Unter der Voraussetzung, dass die (nicht-stochastische) Matrix \(X\) eine Inverse \(\Xi\) besitzt, gilt also (ab jetzt Summenkonvention)
Assuming that the (non-stochastic) matrix \(X\) has an inverse \(\Xi\), the following holds true (from now on, summation convention)
\[
\[
a_p = \Xi_{pq}\psi_q
a_p = \Xi_{pq}\psi_q
\]
\]
und wegen der Linearität und der Tatsache, dass \(\Xi\) nicht von den stochastischen \(y_i\) abhängt, auch
and, due to linearity and the fact that \(\Xi\) does not depend on the stochastic \(y_i\), also
\[
\[
\langle a_p\rangle = \Xi_{pq}\langle\psi_q\rangle
\langle a_p\rangle = \Xi_{pq}\langle\psi_q\rangle
Line 35: Line 35:
=== Uncertainty of the fitting parameters ===
=== Uncertainty of the fitting parameters ===


Für die Korrelationen benötigen wir die Produkte
For the correlations, we need the products
\[
\[
\langle\psi_q\psi_{q'}\rangle = \frac{x_i^q x_j^{q'}}{\sigma^2_i\sigma^2_j}\langle y_i y_j\rangle
\langle\psi_q\psi_{q'}\rangle = \frac{x_i^q x_j^{q'}}{\sigma^2_i\sigma^2_j}\langle y_i y_j\rangle
\quad\text{und}\quad
\quad\text{and}\quad
\langle\psi_q\rangle\langle\psi_{q'}\rangle = \frac{x_i^q x_j^{q'}}{\sigma^2_i\sigma^2_j}\langle y_i\rangle\langle y_j\rangle
\langle\psi_q\rangle\langle\psi_{q'}\rangle = \frac{x_i^q x_j^{q'}}{\sigma^2_i\sigma^2_j}\langle y_i\rangle\langle y_j\rangle
\]
\]
so dass
so that
\[
\[
\langle\psi_q\psi_{q'}\rangle-\langle\psi_q\rangle\langle\psi_{q'}\rangle=\frac{x_i^q x_j^{q'}}{\sigma^2_i\sigma^2_j}\big(\underbrace{\langle y_i y_j\rangle-\langle y_i\rangle\langle y_j\rangle}_{\displaystyle\sigma^2_i\delta_{ij}}\big)=\sum_i\frac{x_i^{q+q'}}{\sigma^2_i}=X_{qq'}
\langle\psi_q\psi_{q'}\rangle-\langle\psi_q\rangle\langle\psi_{q'}\rangle=\frac{x_i^q x_j^{q'}}{\sigma^2_i\sigma^2_j}\big(\underbrace{\langle y_i y_j\rangle-\langle y_i\rangle\langle y_j\ rangle}_{\displaystyle\sigma^2_i\delta_{ij}}\big)=\sum_i\frac{x_i^{q+q'}}{\sigma^2_i}=X_{qq'}
~.
~.
\]
\]
Damit und mit
Thus, and using
\[
\[
a_p a_{p'}=\Xi_{pq}\Xi_{p'q'}\psi_q\psi_{q'}
a_p a_{p'}=\Xi_{pq}\Xi_{p'q'}\psi_q\psi_{q'}
\]
\]
können wir die Varianz der Fitparameter (\(p'=p\)) berechnen zu
we can calculate the variance of the fit parameters (\(p'=p\)) as
\[
\[
\langle a_p^2\rangle-\langle a_p\rangle^2=\Xi_{pq}\Xi_{pq'}\big(\langle\psi_q\psi_{q'}\rangle-\langle\psi_q\rangle\langle\psi_{q'}\rangle\big)=x^{p+p'}\Xi_{pq}\Xi_{pq'}X_{qq'}=\Xi_{pq}\delta_{pq}=\Xi_{pp}
\langle a_p^2\rangle-\langle a_p\rangle^2=\Xi_{pq}\Xi_{pq'}\big(\langle\psi_q\psi_{q'}\rangle-\langle\psi_q\rangle\langle\psi_{q'}\rangle\big)=x^{p+p'}\ \Xi_{pq}\Xi_{pq'}X_{qq'}=\Xi_{pq}\delta_{pq}=\Xi_{pp}
~.
~.
\]
\]
Line 58: Line 58:
=== Uncertainty of the fitting function's values ===
=== Uncertainty of the fitting function's values ===


Für ein vorgegebenes \(x\) gilt für das prognostizierte \(y=a_p x^p\):
For a given \(x\), the following holds for the predicted \(y=a_p x^p\):
\[
\[
\begin{align}
\begin{align}
\langle y\rangle &=\langle a_p\rangle x^p=\langle\psi_q\rangle\Xi_{qp}x^p\\
\langle y\rangle &=\langle a_p\rangle x^p=\langle\psi_q\rangle\Xi_{qp}x^p\\
\langle y^2\rangle-\langle y\rangle^2 &= x^{p+p'}\big(\langle a_p a_{p'}\rangle-\langle a_p\rangle\langle a_{p'}\rangle\big)=x^{p+p'}\Xi_{pq}\Xi_{p'q'}\big(\langle\psi_q\psi_{q'}\rangle-\langle\psi_q\rangle\langle\psi_{q'}\rangle\big)\\
\langle y^2\rangle-\langle y\rangle^2 &= x^{p+p'}\big(\langle a_p a_{p'}\rangle-\langle a_p\rangle\langle a_{p'}\rangle\big)=x^{p+p'}\ \Xi_{pq}\Xi_{p'q'}\big(\langle\psi_q\psi_{q'}\rangle-\langle\psi_q\rangle\langle\psi_{q'}\rangle\big)\\
&=x^{p+p'}\Xi_{pq}\Xi_{p'q'}X_{qq'}=x^{p+p'}\Xi_{pq}\delta_{p'q}=\Xi_{pp'}x^{p+p'}
&=x^{p+p'}\Xi_{pq}\Xi_{p'q'}X_{qq'}=x^{p+p'}\ \Xi_{pq}\delta_{p'q}=\Xi_{pp'}x^{p+p'}
\end{align}
\end{align}
\]
\]


Die Varianz von \(y(x)\) ist also ein Polynom mit dem doppelten Grad des Fit-Polynoms.
The variance of \(y(x)\) is thus a polynomial of twice the degree of the fitting polynomial.


=== Uncertainty of a crossing point ===
=== Uncertainty of a crossing point ===


Es sei \(x_0\) durch \(\langle y\rangle(x_0)=c\) definiert. Wir linearisieren um \(x_0\), d.h.
Let \(x_0\) be defined by \(\langle y\rangle(x_0)=c\). We linearize about \(x_0\), i.e.,
\[
\[
\langle y\rangle(x) = \langle y\rangle(x_0)+(x-x_0)\langle y'\rangle(x_0)+\mathcal O((x-x_0)^2)
\langle y\rangle(x) = \langle y\rangle(x_0)+(x-x_0)\langle y'\rangle(x_0)+\mathcal O((x-x_0)^2)
\]
\]
und fragen nach der Auswirkung der Fluktuationen auf das gemessene \(x_0\):
and ask about the effect of the fluctuations on the measured location:
\[
\[
\begin{align}
\begin{align}
Line 86: Line 86:
\end{align}
\end{align}
\]
\]
In führender Ordnung sind die Fluktuationen des gemessenen \(x_0\) also durch die von \(y(x_0)\) gegeben, die von \(y'(x_0)\) tragen als Korrektur höherer Ordnung bei:
To leading order, the fluctuations of the measured location are thus given by those of \(y(x_0)\), while those of \(y'(x_0)\) contribute only as a higher-order correction:
\[
\[
\langle(x-x_0)^2\rangle\approx\frac{\langle y^2\rangle(x_0)-\langle y\rangle^2(x_0)}{\langle y'\rangle^2(x_0)}=\frac{\Xi_{p'q}x_0^{p'+q}}{(p\langle a_p\rangle x_0^{p-1})^2}~,
\langle(x-x_0)^2\rangle\approx\frac{\langle y^2\rangle (x_0)-\langle y\rangle^2(x_0)} {\langle y'\rangle^2(x_0)}=\frac{\Xi_{p'q}x_0^{p'+q}}{(p\langle a_p\rangle x_0^{p-1})^2}
\]
\]
wobei die Summe im Nenner bei \(p=1\) startet.


= Scratch Pad =
= Scratch Pad =

Revision as of 10:58, 24 April 2026

Polynomial fitting and estimation of uncertainty

Background

If the measured values \(y_i\) are statistically independent but follow the same normal distribution centered around a mean \(\langle y_i\rangle\) that depends on \(x_i\), then the parameters \(\{a_k\}\) which minimize \[ \sum_{i=1}^n(y_i-\hat y(x_i;a_1,\dots,a_m))^2 \] maximize the probability density for the occurrence of the data set \(\{y_i\}\); i.e., adjacent data sets are less likely. If the variance of the respective normal distribution, \(\sigma_i\), is also \(x_i\)-dependent, then instead \[ \frac{\chi^2}{2}=\sum_{i=1}^n\frac{(y_i-\hat y(x_i;a_1,\dots,a_m))^2}{2\sigma_i^2} \] must be minimized.

Polynomial fit \(\hat y=\sum_{p=0}^{m-1}a_p x^p\)

vanishing partial derivative with respect to \(a_q\): \[ \begin{align} 0&=\sum_i \frac{y_i-\sum_p a_p x_i^p}{\sigma_i^2}x_i^q\\ \Leftrightarrow\quad \underbrace{\sum_i\frac{y_i x_i^q}{\sigma_i^2}}_{\displaystyle\psi_q}& =\sum_i\sum_p \frac{a_p x_i^{p+q}}{\sigma_i^2}=\sum_p a_p\underbrace{\sum_i\frac{x_i^{p+q}}{\sigma_i^2}}_{\displaystyle X_{pq}} \end{align} \] Assuming that the (non-stochastic) matrix \(X\) has an inverse \(\Xi\), the following holds true (from now on, summation convention) \[ a_p = \Xi_{pq}\psi_q \] and, due to linearity and the fact that \(\Xi\) does not depend on the stochastic \(y_i\), also \[ \langle a_p\rangle = \Xi_{pq}\langle\psi_q\rangle ~. \]

Uncertainty of the fitting parameters

For the correlations, we need the products \[ \langle\psi_q\psi_{q'}\rangle = \frac{x_i^q x_j^{q'}}{\sigma^2_i\sigma^2_j}\langle y_i y_j\rangle \quad\text{and}\quad \langle\psi_q\rangle\langle\psi_{q'}\rangle = \frac{x_i^q x_j^{q'}}{\sigma^2_i\sigma^2_j}\langle y_i\rangle\langle y_j\rangle \] so that \[ \langle\psi_q\psi_{q'}\rangle-\langle\psi_q\rangle\langle\psi_{q'}\rangle=\frac{x_i^q x_j^{q'}}{\sigma^2_i\sigma^2_j}\big(\underbrace{\langle y_i y_j\rangle-\langle y_i\rangle\langle y_j\ rangle}_{\displaystyle\sigma^2_i\delta_{ij}}\big)=\sum_i\frac{x_i^{q+q'}}{\sigma^2_i}=X_{qq'} ~. \] Thus, and using \[ a_p a_{p'}=\Xi_{pq}\Xi_{p'q'}\psi_q\psi_{q'} \] we can calculate the variance of the fit parameters (\(p'=p\)) as \[ \langle a_p^2\rangle-\langle a_p\rangle^2=\Xi_{pq}\Xi_{pq'}\big(\langle\psi_q\psi_{q'}\rangle-\langle\psi_q\rangle\langle\psi_{q'}\rangle\big)=x^{p+p'}\ \Xi_{pq}\Xi_{pq'}X_{qq'}=\Xi_{pq}\delta_{pq}=\Xi_{pp} ~. \]

Uncertainty of the fitting function's values

For a given \(x\), the following holds for the predicted \(y=a_p x^p\): \[ \begin{align} \langle y\rangle &=\langle a_p\rangle x^p=\langle\psi_q\rangle\Xi_{qp}x^p\\ \langle y^2\rangle-\langle y\rangle^2 &= x^{p+p'}\big(\langle a_p a_{p'}\rangle-\langle a_p\rangle\langle a_{p'}\rangle\big)=x^{p+p'}\ \Xi_{pq}\Xi_{p'q'}\big(\langle\psi_q\psi_{q'}\rangle-\langle\psi_q\rangle\langle\psi_{q'}\rangle\big)\\ &=x^{p+p'}\Xi_{pq}\Xi_{p'q'}X_{qq'}=x^{p+p'}\ \Xi_{pq}\delta_{p'q}=\Xi_{pp'}x^{p+p'} \end{align} \]

The variance of \(y(x)\) is thus a polynomial of twice the degree of the fitting polynomial.

Uncertainty of a crossing point

Let \(x_0\) be defined by \(\langle y\rangle(x_0)=c\). We linearize about \(x_0\), i.e., \[ \langle y\rangle(x) = \langle y\rangle(x_0)+(x-x_0)\langle y'\rangle(x_0)+\mathcal O((x-x_0)^2) \] and ask about the effect of the fluctuations on the measured location: \[ \begin{align} y(x) &= \underbrace{\langle y\rangle(x_0)}_c+\delta y(x_0)+(x-x_0)(\langle y'\rangle(x_0)+\delta y'(x_0)) \stackrel{!}{=}c\\ \Leftrightarrow\quad x-x_0 &= \frac{\delta y(x_0)}{\langle y'\rangle(x_0)+\delta y'(x_0)}\\ \Rightarrow\quad (x-x_0)^2 &= \frac{\delta y^2(x_0)}{\langle y'\rangle^2(x_0)}\big(1+\delta y'(x_0)/\langle y'\rangle(x_0)\big)^{-2}\\ &\approx \frac{\delta y^2(x_0)}{\langle y'\rangle^2(x_0)}\big(1-2\delta y'(x_0)/\langle y'\rangle(x_0)+3\delta y'^2(x_0)/\langle y'\rangle^2(x_0)+\dots\big) \end{align} \] To leading order, the fluctuations of the measured location are thus given by those of \(y(x_0)\), while those of \(y'(x_0)\) contribute only as a higher-order correction: \[ \langle(x-x_0)^2\rangle\approx\frac{\langle y^2\rangle (x_0)-\langle y\rangle^2(x_0)} {\langle y'\rangle^2(x_0)}=\frac{\Xi_{p'q}x_0^{p'+q}}{(p\langle a_p\rangle x_0^{p-1})^2} \]

Scratch Pad

2D flow in polar coordinates \((\rho,\phi)\)

  • vorticity: \(\omega=(\vec\nabla\times\vec u)\cdot\vec e_z=\partial_\rho u_\phi+\displaystyle\frac{u_\phi-\partial_\phi u_\rho}{\rho }\)
    • its gradient: \(\vec\nabla\omega=\vec e_\rho\partial_\rho\omega+\displaystyle\frac{\vec e_\phi}{\rho}\partial_\phi\omega\)
  • divergence \(\nabla\cdot\vec u=\displaystyle\frac{\partial_r(ru_r)+\partial_\phi u_\phi}{r}\)
  • stress tensor:
    • \(\sigma_{rr}=-p+(\zeta-2\mu/3)\displaystyle\frac{\partial_r(ru_r)+\partial_\phi u_\phi}{r}+2\mu\,\partial_r u_r\)
    • \(\sigma_{r\phi}=\sigma_{\phi r}=\mu\displaystyle\frac{\partial_\phi u_r-u_\phi}{r}+\mu\,\partial_r u_\phi\)
    • \(\sigma_{\phi\phi}=-p+(\zeta-2\mu/3)\displaystyle\frac{\partial_r(ru_r)+\partial_\phi u_\phi}{r}+2\mu\displaystyle\frac{\partial_\phi u_\phi+u_r}{r}\)

Energy equation

\begin{align} E' &= \rho e+\frac{\rho}{2}\vec u^2\\ E &= E' + \rho\phi\\ \partial_t E &= \partial_t E' + \phi\partial_t\rho\\ &= -\vec\nabla\cdot\big((E+P)\vec u\big)\\ &= -\vec\nabla\cdot\big((E'+P)\vec u+\phi\rho\vec u\big)\\ &= -\vec\nabla\cdot\big((E'+P)\vec u\big)-\phi\vec\nabla\cdot(\rho\vec u)-\vec u\cdot\rho\vec\nabla\phi\\ \Leftrightarrow\quad \partial_t E' &= -\vec\nabla\cdot\big((E'+P)\vec u\big)+\vec u\cdot\vec f \end{align}

Florian's eCDF

Let \(p_n\) be the relative frequencies and let \(p_n=0\) for \(n_{i-1}<n<n_i\). Then, being a step-function, the eCDF fulfills $$ c(n_i)-c(n_{i-1})\stackrel{*}{=}c(n_i)-c(n_i-1)=c(n_i)-c(n_i-\epsilon)=p_{n_i}~. $$ Florian's modified eCDF replaces the step-function \(c\) by a continous, piecewise linear function \(\tilde c\) with \(\tilde c(n_i)=c(n_i)\), from which one obtains fictious empirical probabilities \(\tilde p_n=\tilde c(n)-\tilde c(n-1)\) for \(n_{i-1}<n\le n_i\). Due to the "natural" \(\Delta n=1\) of the Steigungsdreieck, those \(\tilde p_n\) (being all the same because of the linearity) coincide with the slope $$ s_{n_i}=\frac{\tilde c(n_i)-\tilde c(n_{i-1})}{n_i-n_{i-1}} = \frac{c(n_i)-c(n_{i-1})}{n_i-n_{i-1}}~, $$ which implies $$ \sum_{n=n_{i-1}+1}^{n_i} \tilde p_n = (n_{i}-n_{i-1})\tilde p_n = (n_{i}-n_{i-1})s_{n_i} = c(n_i)-c(n_{i-1}) = p_{n_i}~. $$ Hence, the effect of using \(\tilde c\) is replacing the "bar" \(p_{n_i}\) and the zeros to its left by smaller "bars" of equal height \(\tilde p_n\) while preserving probability, which of course implies \(\sum_k\tilde p_k=1\). In other words, the scheme is a left-biased coarse graining.


*: even though in general \(n_{i-1}\ne n_i-1\)

Hamiltons principle

Discretizations

\begin{align} f'_0 &= \frac{-f_{-1/2}+f_{1/2}}{h}+\mathcal O(h^2)\\ &= \frac{f_{-3/2}-27 f_{-1/2}+27 f_{1/2}-f_{3/2}}{24h}+\mathcal O(h^4)\\ &= \frac{-9 f_{-5/2}+125 f_{-3/2}-2250 f_{-1/2}+2250 f_{1/2}-125 f_{3/2}+9 f_{5/2}}{1920h}+\mathcal O(h^6)\\[3ex] f_0 &= \frac{f_{-1/2}+f_{1/2}}{2}+\mathcal O(h^2)\\ &= \frac{-f_{-3/2}+9f_{-1/2}+9f_{1/2}-f_{3/2}}{16}+\mathcal O(h^4)\\ &= \frac{3 f_{-5/2}-25 f_{-3/2}+150 f_{-1/2}+150 f_{1/2}-25 f_{3/2}+3 f_{5/2}}{256}+\mathcal O(h^6) \end{align}

Values of ghost cells

Robin \(af(0)+b f'(0)=c\) : \[ f(-x):=\frac{b+ax}{b-ax}f(x)-c\frac{2x}{b-ax} \]

Special cases:

Dirichlet \(f(0)\): \[ f(-x):=2f(0)-f(x) \]

Neumann \(f'(0)\): \[ f(-x):=f(x)-2xf'(0) \]