text:
# Infimum and supremum of the empty set

Let $E$ be an empty set. Then, $\sup(E) = -\infty$ and $\inf(E)=+\infty$. I thought it is only meaningful to talk about $\inf(E)$ and $\sup(E)$ if $E$ is non-empty and bounded?

Thank you.

-
What is the question? –  Did Jun 29 '13 at 11:51
@Did He's asking if the thought what he thought. –  Git Gud Jun 29 '13 at 11:58
It's because every real number is an upper bound/lower bound as its empty. Of course, in this definition we're using the extended reals. –  BU982T Jun 29 '13 at 11:59
@Alexy Can you provide more context? Are you considering $E$ as a subset of a strictly larger poset? Is so, what poset is that? Where are you getting this from? I'm guessing it's a definition. It's not possible to prove a definition. –  Git Gud Jun 29 '13 at 12:04
@Git Gud: I read this from a textbook on Analysis some time ago( I can't remember the name). Can I see it this way: sup(E) = the least x such that x is greater than or equal to all elements in E. since E is empty, any x would be an upper bound for E, so just choose the least one; similarly, inf(E) = the greatest x such that x is smaller than or equal to all elements of E. Since E is empty, any x will be a lower bound for E, so just choose the greatest one. –  Alexy Vincenzo Jun 29 '13 at 12:18

There might be different preferences to how one should define this. I am not sure that I understand exactly what you are asking, but maybe the following can be helpful.

If we consider subsets of the real numbers, then it is customary to define the infimum of the empty set as being $\infty$. This makes sense since the infimum is the greatest lower bound and every real number is a lower bound. So $\infty$ could be thought of as the greatest such.

The supremum of the empty set is $-\infty$. Again this makes sense since the supremum is the least upper bound. Any real number is an upper bound, so $-\infty$ would be the least.

Note that when talking about supremum and infimum, one has to start with a partially ordered set $(P, \leq)$. That $(P, \leq)$ is partial ordered means that $\leq$ is reflexive, antisymmetric, and transitive.

So let $P = \mathbb{R} \cup \{-\infty, \infty\}$. Define $\leq$ the "obvious way", so that $a\leq \infty$ for all $a\in \mathbb{R}$ and $-\infty \leq a$ for all $a\in \mathbb{R}$.

With this definition you have a partial order and it this setup the infimum and the supremum are as mentioned above. So you don't need non-empty.

-

When you say "meaningful" you actually mean to say something "$\sup(E)$ exists". But what does it mean to exist? In the context of the real numbers it means that there exists a real number $r$ such that $r=\sup(E)$.

Of course $\pm\infty$ are not real numbers, but they still contain information for us. When we say that $\sup(E)=+\infty$ then we say that $E$ does not have a supermum in the real numbers, or equivalently for every $r\in\Bbb R$ we can find $e\in E$ such that $r<e$.

So in fact we can extend the definition of $\sup$ and $\inf$ to include $\pm\infty$ as possible values by adding two formal symbols for these "points at infinity".

Now, what was the definition of $\sup(E)$ anyway? It was the least point which is not smaller than any of the points in $E$. That is, $\sup(E)=x\iff\forall r\in E:r\leq x\land\forall z(\forall r\in E(r\leq z)\rightarrow x\leq z)$.

Plug this to the empty set, then $\forall r\in\varnothing$ is vacuously true, so every $r\in\Bbb R$ satisfies this condition. It follows that $-\infty$ also satisfies this condition. Therefore $\sup(\varnothing)=-\infty$.

If grasping this is somewhat difficult, here is an equivalent way of looking at this. Consider only $[0,1]$, and now define $\sup^*$ and $\inf^*$ as before but for subsets of $[0,1]$ and requiring that the $\sup^*$ and $\inf^*$ are from $[0,1]$ as well. What is $\sup^*(\varnothing)$?

-
Thanks for your instructive comments! May I know how $-\infty$ satisfy this condition? –  Alexy Vincenzo Jun 29 '13 at 13:10
Alexy, because every number does, so no real number is an upper bound. On the other hand, $-\infty$ is still vacuously larger than all the members of the empty set, but it is smaller than all the other values! –  Asaf Karagila Jun 29 '13 at 13:12
Hi Asaf, since every real number satisfy this condition, this means every real number is sup(E).( Isn't this contradictory?) Hence, in order for sup(E) to be unique, we define sup(E) = $-\infty$ ? –  Alexy Vincenzo Jun 29 '13 at 13:23
No, I meant to say that every number is an upper bound. The $\sup$ is the least possible value which is still an upper bound. –  Asaf Karagila Jun 29 '13 at 13:26

Let $\Bbb{R}$ be the set of real numbers with the usual order and let $\overline{\Bbb{R}}=\Bbb{R}\cup\{+\infty;-\infty\}$ with the following rules:$$-\infty< x< +\infty~~\forall x\in\Bbb{R}$$ Let $E=\emptyset$ be a subset of $\overline{\Bbb{R}}$. $U$ is an upper bound of $E$ if: $$\exists U\in\Bbb{R};~x\leq U~~~\forall x\in E$$ and $E$ doesn't have an upper bound in $\Bbb{R}$ if:$$\forall U\in\Bbb{R},~\exists x\in E;~~~x>U$$ which is clearly false since $E$ doesn't contain any element, so $E$ doesn't have an upper bound in $\Bbb{R}$. Let us define $\sup(E)=-\infty$ (you'll see why in a moment).

We have the relation $\sup(A\cup B)=\max\{\sup(A);\ \sup(B)\}$. If $B=\emptyset$, we expect $\sup(A\cup B)$ to be equal to $\sup(A)$ which is only verified if $\sup(\emptyset)=-\infty$

-

It seems you are aware of the following:

Fact: For any non-empty set of real numbers $E$ with an upper (lower) bound in $\Bbb R$, there is a least (greatest) upper (lower) bound. We call this $\sup E$ ($\inf E$).

Now, suppose we are given any set $E\subseteq R$. Define $U(E):=\{x\in\Bbb R:\forall y\in E(y\le x)\}$ to be the set of upper bounds of $E$ in $\Bbb R$. Similarly, let $L(E):=\{x\in\Bbb R:\forall y\in E(x\le y)\}$ be the set of lower bounds of $E$. You should be able to show the following:

• $U(E)$ is an upward-closed set--that is, if $x\in U(E)$ and $z\in\Bbb R$ with $x\le z,$ then $z\in U(E)$. Likewise, $L(E)$ is downward-closed.
• The only upward-closed subsets of $\Bbb R$ are $\emptyset,$ $\Bbb R,$ and the sets of the form $(a,\rightarrow):=\{x\in\Bbb R:a<x\}$ and $[a,\rightarrow):=\{x\in\Bbb R:a\le x\}$ for $a\in\Bbb R$. Similarly, the downward-closed subsets of $\Bbb R$ are $\emptyset,$ $\Bbb R,$ and the sets $(\leftarrow,b):=\{x\in\Bbb R:x<b\}$ and $(\leftarrow,b]:=\{x\in\Bbb R:x\le b\}.$
• $\Bbb R$ is the only upward-closed (downward-closed) subset of reals that is unbounded below (above).
• $E=\emptyset$ if and only if $U(E)=L(E)=\Bbb R.$

Now we can see the following:

Fact (rephrased): For any non-empty set of real numbers $E,$ either $U(E)$ is empty--meaning that $E$ has no upper bound in $\Bbb R$--or $U(E)$ has a least element--meaning that $U(E)=[a,\rightarrow)$ for some $a\in\Bbb R.$ This $a$ is uniquely determined by $E$, and we call it $\sup E$. Likewise, for any non-empty set of real numbers $E,$ either $L(E)$ is empty or $L(E)=(\leftarrow,b]$ for some unique $b\in\Bbb R$, which we call $\inf E$.

In the case that $E=\emptyset$, we have $U(E)=\Bbb R,$ which has no least element, so we can't say that there is any real number that we call $\sup E$ in this case. Accordingly, "$\sup E=-\infty$" should be interpreted (using my notation) to mean that $U(E)$ is unbounded below, which (by the discussion in the bullet points) is just another way of saying that $E$ is empty. Likewise, "$\inf E=+\infty$" means that $L(E)$ is unbounded above, just another way of saying that $E$ is empty.

Finally, note that if $E$ is non-empty and bounded above, then $\sup E=\inf U(E)$. In this light, we should interpret "$\sup E=+\infty$" in the same way as "$\inf U(E)=+\infty$," meaning $U(E)$ is empty (see previous paragraph), meaning that $E$ is unbounded above. Similarly, we should interpret "$\inf E=-\infty$" as saying that $E$ is unbounded below. These conventions are usually easier to grasp/swallow than that "$\sup E=-\infty$" and "$\inf E=+\infty$" both mean "$E=\emptyset$"--at least, that has been my experience--and I know you didn't directly ask about them, but I felt they were worth mentioning for elucidation.

-


text:
The web server that hosts the groups.inf.ed.ac.uk web site (and various others) is one of the last to be upgraded to SL7. I had hoped to squeeze it in before the end of the year, but it will now happen on Friday January 12th 2018.

The groups.inf web server actually hosts multiple sites, the main ones being (groups|conferences|workshops).inf.ed.ac.uk, but see the complete list at the end of this post.

The upgrade will change the version of Apache from 2.2 to 2.4 and, as with the homepages upgrade, this may require some changes to .htaccess files if you use them. As these files will be accessed (at least for a short time) by both the SL6 Apache 2.2 and then SL7 Apache 2.4 servers, then you need make the changes conditional on which server is
parsing the file or you will get errors.

I’ve already searched for .htaccess files that could be affected, and edited them to use the new directives, eg if you had an .htaccess file that had:

Order allow,deny
Deny from all

Then it will now look like:

<IfVersion < 2.4>
Order allow,deny
Deny from all
</IfVersion>

<IfVersion >= 2.4>
require all denied
</IfVersion>

# neilbSL7

The # neilbSL7 is just a marker I used to record that I’d updated the file. For a list of changes when upgrading from Apache 2.2 to 2.4, see https://httpd.apache.org/docs/2.4/upgrading.html.

## Other Changes

SSI expressions have also changed, but the old behaviour can be enabled with SSILegacyExprParser on in a suitable .htaccess file. I’ve actually made this the default for groups.inf to aid transition, but would like to turn it off at some point in the future.

The PHP version will also change from 5.3.3 to 5.4.16. Again, at some point in the future, I’d like to update that further to 5.6.

For anyone using Cosign access control, then simply turning on Cosign with “CosignProtected on” is not enough to force authentication with Apache 2.4. You need the full:

  CosignProtected On
AuthType Cosign
Require user AAA BBB CCC

Also “CosignAllowPublicAccess on”, does not work as it did before. If you have it set on and then try to do a “require valid-user” (or similar) you will get a server error because of the conflicting instructions. So sections that were “Allow public access on”, you’ll just have to not enable authentication at all, or be happy to turn off public access, and force authentication.

## Testing

Where I can, I’ve created temporary “sl7” URLs to the various .inf.ed.ac.uk sites (listed below) so you can test your site on the new server ahead of the upgrade. There is just an extra “.sl7” in front of the existing “.inf.ed.ac.uk” part of the URL eg http://groups.inf.ed.ac.uk/ becomes http://groups.sl7.inf.ed.ac.uk/

For sites who’s DNS is not within inf.ed.ac.uk, there are no test URLs. If the owners want to contact me ahead of the switch, I can probably arrange a temporary URL to try things on. Best to do that via the support form.

Previous upgrades of web servers from SL6 to SL7 have been fairly uneventful, so hopefully this upgrade will be equally smooth.

Neil

### List of all web sites hosted on the groups.inf server

aicat.inf.ed.ac.uk
carma.inf.ed.ac.uk
www.cav2005.inf.ed.ac.uk
compucast.inf.ed.ac.uk
conferences.inf.ed.ac.uk
cybersecpriv.inf.ed.ac.uk
data.cstr.inf.ed.ac.uk data.cstr.ed.ac.uk
dbibd-05.inf.ed.ac.uk
devproj.inf.ed.ac.uk
www.etaps05.inf.ed.ac.uk
events.inf.ed.ac.uk
groups.inf.ed.ac.uk ease.groups.inf.ed.ac.uk
hoppers.inf.ed.ac.uk
www.icdt2005.inf.ed.ac.uk
www.ilsi.inf.ed.ac.uk
infcricket.inf.ed.ac.uk
isoc.inf.ed.ac.uk
media.inf.ed.ac.uk
mipc.inf.ed.ac.uk
newbuildpics.inf.ed.ac.uk
progclub.inf.ed.ac.uk
proofgeneral.inf.ed.ac.uk
ref2014.inf.ed.ac.uk
ref2020.inf.ed.ac.uk
robotperception.inf.ed.ac.uk
secpriv.inf.ed.ac.uk
select.inf.ed.ac.uk
touchscreens.inf.ed.ac.uk
uitp05.inf.ed.ac.uk
valkyrie.inf.ed.ac.uk
waim-05.inf.ed.ac.uk
workshops.inf.ed.ac.uk
# There are .sl7.inf.ed.ac.uk test URLs for all the sites above here
# but not for the following
inspace.ed.ac.uk
history.dcs.ed.ac.uk
www.enhance-project.org
www.gaussianprocess.org
www.hscma2011.org
pact2013.pactconf.org
www.mgb-challenge.org
www.neurogems.org

format: plain


text:
# Why do we need the Condon-Shortley phase in spherical harmonics?

I'm confused with different definitions of spherical harmonics:

$$Y_{lm}(\theta,\phi) = (-1)^m \left( \frac{(2l+1)(l-m)!}{4\pi(1+m)!} \right)^{1/2} P_{lm} (\cos\theta) e^{im\phi}$$

For example here they claim, that one can decide whether to include or omit the Condon-Shortley phase $(-1)^m$. And, also they claim this is useful in quantum mechanical operations, such as raising and lowering.

In The Theory of Atomic Spectra, Condon and Shortley state:

"If we had approached the problem through the usual form of the theory of spherical harmonics the natural tendency would have been to chose the normalizing factors with omission of the $(-1)^m$ in these formulas"

So the whole point of using $(-1)^m$ is that the following identity holds

$$Y_{l-m}(\theta,\phi) = (-1)^m Y_{lm}(\theta,\phi)^*$$

How is the Condon-Shortley phase used with these operations and why is this phase beneficial?

You don't need it: it's a sign convention and the only thing you need to do with it is to be consistent. (In particular, this means always checking that the sign and normalization conventions for $Y_{lm}$ and $P_l^m$ agree for all the sources that you're using, and correctly account for any differences there.)
The Condon-Shortley sign convention is built so that the spherical harmonics will play nicely with the angular momentum ladder operators: in particular, they enable you to write \begin{align} Y_l^m(\theta,\varphi) & = A_{lm} \hat{L}_-^{l-m} Y_l^l(\theta,\varphi), \quad \text{and} \\ Y_l^m(\theta,\varphi) & = A_{l,-m} \hat{L}_+^{l+m} Y_l^{-l}(\theta, \varphi), \end{align} where the $A_{lm}=\sqrt{\frac{(l+m)!}{(2l)!(l+m)!}}$ are all positive constants. This comes from Aarfken, 6th ed (2005), Eq. (12.162) p. 794, and it uses the conventions \begin{align} Y_l^m(\theta,\varphi) & = (-1)^m \sqrt{\frac{2l+1}{4\pi}\frac{(l-m)!}{(l+m)!}} P_l^m(\cos(\theta)) e^{im\varphi}, \text{ for} \\ P_n^m(\cos(\theta)) & = \frac{1}{2^n n!}(1-x^2)^{m/2} \frac{\mathrm d^{m+n}}{\mathrm d x^{m+n}}(x^2-1)^n ,\text{ and with}\\ L_\pm & = L_x\pm i L_y = \pm e^{i\varphi}\left[\frac{\partial}{\partial \theta} \pm i\cot(\theta) \frac{\partial}{\partial \varphi} \right] . \end{align} Ignoring the Condon-Shortley phase would introduce signs into the $A_{lm}$, which can be seen as (vaguely) undesirable - you want the awkward constants in the fiddly special-functiony side, which is always awkward to begin with, and not in the Hilbert-space side where clean relationships between wavefunctions and vectors are much more valuable.


text:
Volume 398 - The European Physical Society Conference on High Energy Physics (EPS-HEP2021) - T12: Detector R&D and Data Handling
Detector characterization for Legend-200 experiment
V. Biancacci*  on behalf of the LEGEND Collaboration
Full text: pdf
Pre-published on: March 09, 2022
Published on: May 12, 2022
Abstract
The LEGEND collaboration is developing an experimental search for the neutrinoless double-beta ($0\nu\beta\beta$) decay of the $^{76}$Ge isotope.
Its first phase, LEGEND-200, uses $200~$kg of $^{76}$Ge-enriched high-purity germanium (HPGe) detectors in an active liquid argon shield and is currently under construction at the Laboratori Nazionali del Gran Sasso (LNGS) in Italy.
Inverted coaxial point-contact (ICPC) detectors are deployed in the experiment. Their unique geometry provides an excellent energy resolution in a broad energy range and impressive discrimination of signal against background events.
LEGEND’s search for $0\nu\beta\beta$ requires a precise understanding of the behavior of germanium detectors, requiring extensive detector characterization.
The acceptance tests aim to verify the performance of the delivered detectors meets specifications and to determine their optimal operational parameters.
A review and the first results of the detector characterization program are discussed.
DOI: https://doi.org/10.22323/1.398.0800
How to cite

Metadata are provided both in "article" format (very similar to INSPIRE) as this helps creating very compact bibliographies which can be beneficial to authors and readers, and in "proceeding" format which is more detailed and complete.

Open Access


text:
稀疏编码自编码表达

 Revision as of 06:47, 21 March 2013 (view source)Kandeng (Talk | contribs)← Older edit Revision as of 06:50, 21 March 2013 (view source)Kandeng (Talk | contribs) Newer edit → Line 59: Line 59: 观察修改后的目标函数$J(A, s)$，给定$s$的条件下，目标函数可以简化为$J(A; s) = \lVert As - x \rVert_2^2 + \gamma \lVert A \rVert_2^2$（因为$s$的L1范式不是$A$的函数，所以可以忽略）。简化后的目标函数是一个关于$A$的简单二次项式，因此对$A$求导是很容易的。这种求导的一种快捷方法是矩阵微积分（[相关链接]部分列出了跟矩阵演算有关的内容）。遗憾的是，在给定$A$的条件下，目标函数却不具备这样的求导方法，因此目标函数的最小化步骤只能用梯度下降或其他类似的最优化方法。 观察修改后的目标函数$J(A, s)$，给定$s$的条件下，目标函数可以简化为$J(A; s) = \lVert As - x \rVert_2^2 + \gamma \lVert A \rVert_2^2$（因为$s$的L1范式不是$A$的函数，所以可以忽略）。简化后的目标函数是一个关于$A$的简单二次项式，因此对$A$求导是很容易的。这种求导的一种快捷方法是矩阵微积分（[相关链接]部分列出了跟矩阵演算有关的内容）。遗憾的是，在给定$A$的条件下，目标函数却不具备这样的求导方法，因此目标函数的最小化步骤只能用梯度下降或其他类似的最优化方法。 - [原文] + 理论上，通过上述迭代方法求解目标函数的最优化问题最终得到的特征集（A的基向量）与通过稀疏自编码学习得到的特征集是差不多的。但是实际上，为了获得更好的算法收敛性需要使用一些小技巧，后面的[[ Sparse Coding: Autoencoder Interpretation#稀疏编码实践| 稀疏编码实践]] 稀疏编码实践章节会详细介绍这些技巧。用梯度下降方法求解目标函数也略需技巧，另外使用矩阵演算或[[Deriving gradients using the backpropagation idea | 反向传播算法]]则有助于解决此类问题。 - + In theory, optimizing for this objective function using the iterative method as above should (eventually) yield features (the basis vectors of $A$) similar to those learned using the sparse autoencoder. However, in practice, there are quite a few tricks required for better convergence of the algorithm, and these tricks are described in greater detail in the later section on [[ Sparse Coding: Autoencoder Interpretation#Sparse coding in practice | sparse coding in practice]]. Deriving the gradients for the objective function may be slightly tricky as well, and using matrix calculus or [[Deriving gradients using the backpropagation idea | using the backpropagation intuition]] can be helpful. In theory, optimizing for this objective function using the iterative method as above should (eventually) yield features (the basis vectors of $A$) similar to those learned using the sparse autoencoder. However, in practice, there are quite a few tricks required for better convergence of the algorithm, and these tricks are described in greater detail in the later section on [[ Sparse Coding: Autoencoder Interpretation#Sparse coding in practice | sparse coding in practice]]. Deriving the gradients for the objective function may be slightly tricky as well, and using matrix calculus or [[Deriving gradients using the backpropagation idea | using the backpropagation intuition]] can be helpful.


text:
# Ubuntu – PHP 5.6 not used by Apache instead it uses PHP 5.5

Apache2PHPserver

I am trying to upgrade my PHP version from 5.5 to 5.6 so I can get Laravel working. So I followed the instructions from here but instead of adding this repository:

sudo add-apt-repository ppa:ondrej/php5-5.6

sudo add-apt-repository ppa:ondrej/php5

anything else didn't work. Afterwards I installed PHP and to test the version I did this:

php -v

which gave me this:

PHP 5.6.28-1+deb.sury.org~trusty+1

however when I navigate to the server in my browser phpinfo() showed this:

PHP Version 5.5.9-1ubuntu4.20

Why is that happening, why isn't Apache loading the new version?

Also, in my /etc folder I have two php folders one is: /etc/php5 (which I think contains php5.5) and another called: /etc/php (which I think contains php5.6).

• I found out that I have the following files inside /etc/apache2/mods-available/

php5.6.conf
php5.conf
php5filter.conf
php7.0.conf

so what I did is the following

sudo a2dismod php5.load

and then

sudo a2enmod php5.6.load

that switched the version the apache was using to 5.6 and voila problem solved : )


text:
# [2011.00147] Pixel-Level Cycle Association: A New Perspective for Domain Adaptive Semantic Segmentationopen searchopen navigation menucontact arXivsubscribe to arXiv mailings

Domain adaptive semantic segmentation aims to train a model performing satisfactory pixel-level predictions on the target with only out-of-domain (source) annotations. The conventional solution to this task is to minimize the discrepancy between source and target to enable effective knowledge transfer. Previous domain discrepancy minimization methods are mainly based on the adversarial training. They tend to consider the domain discrepancy globally, which ignore the pixel-wise relationships and are less discriminative. In this paper, we propose to build the pixel-level cycle association between source and target pixel pairs and contrastively strengthen their connections to diminish the domain gap and make the features more discriminative. To the best of our knowledge, this is a new perspective for tackling such a challenging task. Experiment results on two representative domain adaptation benchmarks, i.e. GTAV $\rightarrow$ Cityscapes and SYNTHIA $\rightarrow$ Cityscapes, verify the ef

2 mentions:
Keywords:
Date:

## Referring Tweets

@AkiraTOSEI t.co/yVX8HAoCYA 領域分割タスクにおいて、ランダム抽出したsourceパッチ→その最近傍targetパッチ→その最近傍sourceパッチのラベルが同じものになるように制約をかけることで、ドメイン適応を行う研究。先行研究を大きく超える結果。 t.co/6Vl5Cju4PF
@AkiraTOSEI t.co/yVX8HAoCYA A study of domain adaptation in semantic segmentation task by constraining the labels of randomly extracted source patches >its nearest neighbor target patches >its nearest neighbor source patches to be the same. The results greatly exceed previous results t.co/cnjBOVAkmx

## Related Entries

[2006.10337] Category-Specific CNN for Visual-aware CTR Prediction at JD.comopen searchopen navigati...
0 users, 2 mentions 2020/11/12 12:59
[2012.00364] Pre-Trained Image Processing Transformer
0 users, 2 mentions 2020/12/23 11:21
[2012.06044] Mesoscopic photogrammetry with an unstabilized phone camera
0 users, 2 mentions 2020/12/25 17:21
[2010.04456] Augmenting Physical Models with Deep Networks for Complex Dynamics Forecasting
0 users, 2 mentions 2021/02/12 11:21
MAE/SimMIM for Pre-Training Like a Masked Language Model | by Akihiro FUJII | Dec, 2021 | Medium
0 users, 1 mentions 2021/12/23 22:09

# ML-Newsについて

ML-NewsはSNSを情報源とした機械学習に特化したニュースサイトです。機械学習に関する論文ブログライブラリコンペティション発表資料勉強会などの最新の情報を効率的に収集できます。

## お知らせ

• 2021/12/31: デザインを刷新しました
• 2021/04/08: 日本語Kaggleのカテゴリを新設しました


text:
# 2nd fundamental theorem of calculus chain rule

It has gone up to its peak and is falling down, but the difference between its height at and is ft. Use the chain rule and the fundamental theorem of calculus to find the derivative of definite integrals with lower or upper limits other than x. AP CALCULUS. (max 2 MiB). This preview shows page 1 - 2 out of 2 pages.. ( x). The Second Fundamental Theorem of Calculus. Introduction. See how this can be … Then F′(u) = sin(u2). Unit 7 Notes 7.1 2nd Fun Th'm Hw 7.1 2nd Fun Th'm Key ; Powered by Create your own unique website with customizable templates. Solution. As mentioned earlier, the Fundamental Theorem of Calculus is an extremely powerful theorem that establishes the relationship between differentiation and integration, and gives us a way to evaluate definite integrals without using Riemann sums or calculating areas. Get 1:1 help now from expert Calculus tutors Solve it with our calculus … FT. SECOND FUNDAMENTAL THEOREM 1. Stokes' theorem is a vast generalization of this theorem in the following sense. Of the two, it is the First Fundamental Theorem that is the familiar one used all the time. - The integral has a variable as an upper limit rather than a constant. Solving the integration problem by use of fundamental theorem of calculus and chain rule. The Two Fundamental Theorems of Calculus The Fundamental Theorem of Calculus really consists of two closely related theorems, usually called nowadays (not very imaginatively) the First and Second Fundamental Theo-rems. I want to take the first and second derivative of $F(x) = \left(\int_0^xf(t)dt\right)^2 - \int_0^x(f(t))^3dt$ and will use the fundamental theorem of calculus and the chain rule to do it. ���y�\�%ak��AkZ�q��F� �z���[>v��-��$��k��STH�|A Problem. Solution By using the fundamental theorem of calculus, the chain rule and the product rule we obtain f 0 (x) = Z 0 x 2-x cos (πs + sin(πs)) ds-x cos ( By using the fundamental theorem of calculus, the chain rule and the product rule we obtain f 0 (x) = Z 0 x 2-x cos (πs + sin(πs)) ds-x cos It also gives us an efficient way to evaluate definite integrals. Have you wondered what's the connection between these two concepts? }\) Viewed 1k times 1$\begingroup$I have the following problem in which I have to apply both the chain rule and the FTC 1. 5 0 obj The first part of the theorem says that if we first integrate $$f$$ and then differentiate the result, we get back to the original function $$f.$$ Part $$2$$ (FTC2) The second part of the fundamental theorem tells us how we can calculate a definite integral. The Second Fundamental Theorem of Calculus says that when we build a function this way, we get an antiderivative of f. Second Fundamental Theorem of Calculus: Assume f(x) is a continuous function on the interval I and a is a constant in I. The FTC and the Chain Rule Three Different Concepts As the name implies, the Fundamental Theorem of Calculus (FTC) is among the biggest ideas of Calculus, tying together derivatives and integrals. The total area under a curve can be found using this formula. - The variable is an upper limit (not a lower limit) and the lower limit is still a constant. %PDF-1.4 2nd fundamental theorem of calculus ; Limits. The area under the graph of the function $$f\left( x \right)$$ between the vertical lines $$x = a,$$ $$x = b$$ (Figure $$2$$) is given by the formula Ask Question Asked 2 years, 6 months ago. x��\I�I���K��%�������, ��IH�A��㍁�Y�U�UY����3£��s���-k�6����'=��\�]�V��{�����}�ᡑ�%its�b%�O�!#Z�Dsq����b���qΘ��7�$F''(x) = 2\left(f(x)\right)^2 + 2f'(x)\left(\int_0^xf(t)dt\right) - 3f'(x)(f(x))^2 \$ by the product rule, chain rule and fund thm of calc. The middle graph also includes a tangent line at xand displays the slope of this line. Second Fundamental Theorem of Calculus. Fundamental theorem of calculus. But and, by the Second Fundamental Theorem of Calculus, . Proof. The fundamental theorem of calculus is a theorem that links the concept of differentiating a function with the concept of integrating a function. The Fundamental Theorem of Calculus tells us that the derivative of the definite integral from to of ƒ() is ƒ(), provided that ƒ is continuous. The Fundamental Theorem of Calculus The Fundamental Theorem of Calculus shows that di erentiation and Integration are inverse processes. The Fundamental Theorem of Calculus, Part 1 shows the relationship between the derivative and the integral. Second Fundamental Theorem of Calculus. Second Fundamental Theorem of Calculus. The Fundamental Theorem tells us that E′(x) = e−x2. identify, and interpret, ∫10v(t)dt. The middle graph, of the accumulation function, then just graphs x versus the area (i.e., y is the area colored in the left graph). We need an antiderivative of $$f(x)=4x-x^2$$. Solution. The applet shows the graph of 1. f (t) on the left 2. in the center 3. on the right. Fundamental Theorem of Calculus Part 1: Integrals and Antiderivatives. ( s) d s. Solution: Let F ( x) be the anti-derivative of tan − 1. Suppose that f(x) is continuous on an interval [a, b]. The Fundamental Theorem of Calculus, Part 2, is perhaps the most important theorem in calculus. Let f be continuous on [a,b], then there is a c in [a,b] such that. Second Fundamental Theorem of Calculus (Chain Rule Version) dx f(t)dt = d 9(x) a los 5) Use second Fundamental Theorem to evaluate: a) 11+ t2 dt b) a tant dt 1 dt 1+t dxo d) in /1+t2dt . The total area under a curve can be found using this formula. Let F be any antiderivative of f on an interval , that is, for all in .Then . I would know what F prime of x was. A conjecture state that if f(x), g(x) and h(x) are continuous functions on R, and k(x) = int(f(t)dt) from g(x) to h(x) then k(x) is differentiable and k'(x) = h'(x)*f(h(x)) - g'(x)*f(g(x)). Solution. So any function I put up here, I can do exactly the same process. We define the average value of f (x) between a and b as. Note that the ball has traveled much farther. We use two properties of integrals to write this integral as a difference of two integrals. Example: Compute d d x ∫ 1 x 2 tan − 1. Find F′(x)F'(x)F′(x), given F(x)=∫−3xt2+2t−1dtF(x)=\int _{ -3 }^{ x }{ { t }^{ 2 }+2t-1dt }F(x)=∫−3xt2+2t−1dt. Define a new function F(x) by. The Chain Rule and the Second Fundamental Theorem of Calculus1 Problem 1. 4 questions. The Chain Rule and the Second Fundamental Theorem of Calculus1 Problem 1. I would define F of x to be this type of thing, the way we would define it for the fundamental theorem of calculus. Thus if a ball is thrown straight up into the air with velocity the height of the ball, second later, will be feet above the initial height. But what if instead of we have a function of , for example sin()? We use the chain rule so that we can apply the second fundamental theorem of calculus. (We found that in Example 2, above.) You can also provide a link from the web. How does fundamental theorem of calculus and chain rule work? Active 2 years, 6 months ago. Click here to upload your image If $$f$$ is a continuous function and $$c$$ is any constant, then $$f$$ has a unique antiderivative $$A$$ that satisfies $$A(c) = 0\text{,}$$ and that antiderivative is given by the rule $$A(x) = \int_c^x f(t) \, dt\text{. It also gives us an efficient way to evaluate definite integrals. The second part of the theorem gives an indefinite integral of a function. Active 2 years, 6 months ago. Solution. The fundamental theorem of calculus states that the integral of a function f over the interval [a, b] can be calculated by finding an antiderivative F of f: ∫ = − (). You may assume the fundamental theorem of calculus. By the Chain Rule . Solution By using the fundamental theorem of calculus, the chain rule and the product rule we obtain f 0 (x) = Z 0 x 2-x cos (πs + sin(πs)) ds-x cos ( By using the fundamental theorem of calculus, the chain rule and the product rule we obtain f 0 (x) = Z 0 x 2-x cos (πs + sin(πs)) ds-x cos Fundamental Theorem of Calculus, Part 2: The Evaluation Theorem. Example \(\PageIndex{2}$$: Using the Fundamental Theorem of Calculus, Part 2. Proof. This preview shows page 1 - 2 out of 2 pages.. That is, if f and g are differentiable functions, then the chain rule expresses the derivative of their composite f ∘ g — the function which maps x to $${\displaystyle f(g(x))}$$— in terms of the derivatives of f and g and the product of functions as follows:

0 comentarii pentru: 2nd fundamental theorem of calculus chain rule


text:
# New-MailboxExportRequest refusing get-date variable

## PowerShell

Powershell script wanted

I have been ripping my hair out about this. I am trying to backup a mailbox to .pst via a script. I just want to grab everything that is more that a week old. The format on the get-date seems to throw everything out of whack. If I change it to suit then it fails?

This is what I have so far. If i change the get-date to -8days then this works fine.

Powershell
Windows PowerShell

PS C:\Users\Administrator> . 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'
Welcome to the Exchange Management Shell!

Full list of cmdlets: Get-Command
Only Exchange cmdlets: Get-ExCommand
Cmdlets that match a specific string: Help *<string>*
Get general help: Help
Get help for a cmdlet: Help <cmdlet name> or <cmdlet name> -?
Show quick reference guide: QuickRef
Exchange team blog: Get-ExBlog
Show full output for a command: <command> | Format-List
Tip of the day #92:

Need to verify that an organization relationship is correctly configured and functioning as expected for a user in an ex
ternal Exchange organization? Just type:
Test-OrganizationRelationship -UserIdentity <user email address> -Identity <external domain> -Confirm

VERBOSE: Connecting to macrail-dc.macrail.local
VERBOSE: Connected to macrail-dc.macrail.local.
[PS] C:\Users\Administrator>#create rule to forward incoming mail to info this will be disable by another TPCRremoverule
.ps1
[PS] C:\Users\Administrator>new-inboxrule "Weekday Rule" -Mailbox TPCR -MyNameInToOrCcBox $true -forwardto info@mydomain. co.uk Name Enabled Priority RuleIdentity ---- ------- -------- ------------ Weekday Rule True 1 15690891845968077354 [PS] C:\Users\Administrator>#begin cleanup [PS] C:\Users\Administrator>#declare variables [PS] C:\Users\Administrator>$user="TPCR"
[PS] C:\Users\Administrator>$name=(get-date).tostring("dd-MM-yyyy") [PS] C:\Users\Administrator>$since=(Get-Date).AddDays(-7).tostring("dd/MM/yyyy")
[PS] C:\Users\Administrator>#backup mail more than age as set by $since. save to file path and don't require confirmatio n [PS] C:\Users\Administrator>New-mailboxexportrequest -mailbox$user -ContentFilter "(Received -lt '$since')" -name$name
-FilePath "\\macrail-dc\it\backup\TPCR_Mail\$name.pst" -confirm:$false
The provided ContentFilter value is invalid. ContentFilter is invalid. The value "13/09/2013" could not be converted to
type System.DateTime. --> The value "13/09/2013" could not be converted to type System.DateTime.
+ CategoryInfo          : InvalidArgument: ((Received -lt '13/09/2013'):String) [], ContentFilterInvalidPermanentE
xception
+ FullyQualifiedErrorId : FE166541

So I figured it may be because it doesn't like that date format so...

Powershell
[PS] C:\Users\Administrator>$since=(Get-Date).AddDays(-7).tostring("MM/dd/yyyy") [PS] C:\Users\Administrator>New-mailboxexportrequest -mailbox$user -ContentFilter "(Received -lt '$since')" -name$name
-FilePath "\\macrail-dc\it\backup\TPCR_Mail\$name.pst" -confirm:$false

Name                                           Mailbox                                        Status
----                                           -------                                        ------
20-09-2013                                     macrail.local/Departments/NPC's/Track Partn... Queued

I thought that got it but then...

Powershell
[PS] C:\Users\Administrator>Get-MailboxExportRequest -Mailbox $User -name$name

Name                                           Mailbox                                        Status
----                                           -------                                        ------
20-09-2013                                     macrail.local/Departments/NPC's/Track Partn... Failed

I am fairly new to powershell and I am ripping alot of this from here But I don't think it's anything to do with that. Its the stupid get-date format!!

Mace
OP
##### Chamele0n Sep 20, 2013 at 4:19 UTC

The Content filter line should look like this:

Powershell

1
· · ·
Anaheim
OP
##### ilikemysocks Sep 20, 2013 at 4:22 UTC

Thanks. I'll try this out now. Any thoughts on why it sometimes works? It goes through fine when I use anything above 7days. I thought maybe because of US date vs UK date?

0
· · ·
Mace
OP
##### Chamele0n Sep 20, 2013 at 4:27 UTC

The Gate-date should work fine. Does it have to be in that format? Or could it be the below?:

Powershell
(Get-Date).AddDays(-7)

0
· · ·
Anaheim
OP
Powershell
[PS] C:\Users\Administrator>New-mailboxexportrequest -mailbox $user -ContentFilter {((Received -le$since))} -name $name -FilePath "\\macrail-dc\it\backup\TPCR_Mail\$name.pst" -confirm:$false Name must be unique per owning mailbox. There's already a request with the name '20-09-2013' owned by mailbox 'macrail. local/Departments/NPC's/Track Partnership Control Room'. + CategoryInfo : InvalidArgument: (TPCR:MailboxOrMailUserIdParameter) [New-MailboxExportRequest], NameMus tBeUniquePermanentException + FullyQualifiedErrorId : C024F68B,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest  Ooops. Had this a few times. Anyone who comes across this, this will fix it. Powershell [PS] C:\Users\Administrator>Get-MailboxExportRequest -Mailbox$User -name $name | Remove-MailboxExportRequest Confirm Are you sure you want to perform this action? Removing request 'macrail.local/Departments/NPC's/Track Partnership Control Room\20-09-2013'. [Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): y [PS] C:\Users\Administrator>Get-MailboxExportRequest -Mailbox$User -name $name | Remove-MailboxExportRequest  1 · · · Anaheim OP ##### ilikemysocks Sep 20, 2013 at 4:30 UTC Your solution worked beautifully. Thank you. 0 · · · Mace OP ##### Chamele0n Sep 20, 2013 at 4:30 UTC Your welcome...glad that was easy. 0 · · · Anaheim OP ##### ilikemysocks Sep 20, 2013 at 4:32 UTC I'd been trying for hours. I haven't posted on here before but I won't hesitate next time. After some careful googling of course! 1 · · · Mace OP ##### Chamele0n Sep 20, 2013 at 5:16 UTC Yes, please don't hesitate. A few of us here in the PowerShell forum are very quick to respond, because we subscribe to receive emails about all posts to this forum. Also, don't hesitate to participate. Throw your input out there on other problems. 1 · · · Mace OP ##### tfl Sep 20, 2013 at 7:09 UTC Chamele0n wrote: Yes, please don't hesitate. A few of us here in the PowerShell forum are very quick to respond, because we subscribe to receive emails about all posts to this forum. Also, don't hesitate to participate. Throw your input out there on other problems. +1 (or more) 0 · · · Mace OP ##### tfl Sep 20, 2013 at 7:18 UTC Purely out of curiosity, why the double parens -ContentFilter {((Received -le$since))}

Wouldn't

-ContentFilter {(Received -le $since)} or even -ContentFilter {Received -le$since}

have worked?

I do not have an Exchange VM up and runnig to test this...

0
· · ·
Mace
OP
##### Chamele0n Sep 20, 2013 at 7:56 UTC

tfl wrote:

Purely out of curiosity, why the double parens

-ContentFilter {((Received -le $since))} Wouldn't -ContentFilter {(Received -le$since)}

or even

-ContentFilter {Received -le $since} have worked? I do not have an Exchange VM up and runnig to test this... Yes, it still would have worked. I had copy and pasted, then just removed the unneeded extra -and 's that were there. So I left the parentheses. 0 · · · Pimiento OP ##### alt21 Sep 29, 2013 at 9:37 UTC 1st Post I believe for the$since variable to work you need to use double quotes instead of {} and also have the date in single quotes.Chamele0n wrote:

tfl wrote:

Purely out of curiosity, why the double parens

-ContentFilter {((Received -le $since))} Wouldn't -ContentFilter {(Received -le$since)}

or even

New-MailboxExportRequest -Mailbox use1 -ContentFilter {((Received -ge $since))} –FilePath “\\192.168.204.87\backup4\PST\test\use1.pst" this creates a full pst while New-MailboxExportRequest -Mailbox user1 -ContentFilter {(Received -ge "10/09/2013")} –FilePath “\\192.168.204.87\backup4\PST\test\use1.pst" works fine. Any ideas? //Shawn 0 · · · Anaheim OP ##### ShawnRC Oct 10, 2013 at 2:14 UTC I should add that I am not in the US or Canada and the regionalsettngs are for western europe. I noticed that if I add$since=(Get-Date).AddDays(-1).tostring("dd/MM/yyyy").Replace("-","/")

in a seperate ps1 it gives the correct date format, ie 10/09/2013. Not sure if this gets lost when running the new-mailboxexportrequest cmdlet.

0
· · ·
Pure Capsaicin
OP
##### Martin9700 Oct 10, 2013 at 2:26 UTC

For a DateTime object the regional settings don't matter, those are only used when displaying to us people :)

0
· · ·
Pimiento
OP
##### alt21 Oct 10, 2013 at 10:07 UTC

This should work

$since=(Get-Date).AddDays(-1) New-MailboxExportRequest -Mailbox use1 -ContentFilter "(Received -ge '$since')" –FilePath "\\192.168.204.87\backup4\PST\test\use1.pst"

Replace { } with " " and $since with '$since'

Edited Feb 13, 2014 at 6:51 UTC
1
· · ·
Anaheim
OP
##### ShawnRC Oct 11, 2013 at 7:05 UTC

Thanks Etienne. Worked like a charm (you missed the " before the UNC but that one I could see :-) )

0
· · ·
Pure Capsaicin
OP
##### Martin9700 Oct 11, 2013 at 10:43 UTC

alt21 wrote:

This should work

$since=(Get-Date).AddDays(-1) New-MailboxExportRequest -Mailbox use1 -ContentFilter "(Received -ge '$since')" –FilePath \\192.168.204.87\backup4\PST\test\use1.pst"

Replace { } with " " and $since with '$since'

Just an FYI, When you do (Get-Date).AddDays(-1) it subtracts exactly 1 day from the time.  So if you run at 6pm it will be 6pm the previous day.  If you want to capture the entire day (12am) you can:

Powershell
((Get-Date).AddDays(-1)).Date

0
· · ·
Tabasco
OP
##### ArtB Oct 11, 2013 at 1:03 UTC

Ole, Martin! You beat me to it for once!!

Actually, you don't need the extra set of Parentheses. This will work as well:

Powershell
(Get-Date).AddDays(-1).Date

0
· · ·
Anaheim
OP
##### ShawnRC Oct 11, 2013 at 9:13 UTC

Thanks a bunch guys. You ROCK! I hope to be able to help you out one day.

1
· · ·
Pimiento
OP
##### David54241 Feb 13, 2014 at 2:17 UTC

Sorry to re-start on old post but I just cannot get this to work.  I simply want to export the last few days of every users' mailbox to PSTs. We are using a single Exchange 2010 SP3, Rollup 4 with en-GB regional settings.

I've tried to pre and post set the regional codes and date format as per below because of the known issue with the powershell script.  Does anyone know why this won't work please?  It does not give errors, just no output ie an empty PST.

Thanks.

$since=(Get-Date).AddDays(-5).tostring("MM/dd/yyyy") # also tried just$since=(Get-Date).AddDays(-5)

Set-MailboxRegionalConfiguration -Identity "Dave" -language en-US -DateFormat "MM/dd/yyyy"

New-MailboxExportRequest -Mailbox "Dave" -ContentFilter "(Received -ge '$since')" -FilePath \\ELS3\PST\MB1.pst Set-MailboxRegionalConfiguration -Identity "Dave" -language en-GB -DateFormat "dd/MM/yyyy"  0 · · · Anaheim OP ##### ShawnRC Feb 13, 2014 at 2:54 UTC this is my final script David: ****$Folder=(Get-Date -f yyyy_MM_dd)
md \\Server\share\$Folder$since=(Get-Date).AddDays(-1)
foreach ($i in (Get-Mailbox -ResultSize Unlimited)) { New-MailboxExportRequest -BadItemLimit 100 -AcceptLargeDataLoss -Mailbox$i -ContentFilter "(Received -ge '$since')" -FilePath "\\Server\share\$Folder\$($i.Alias).pst" }

***

Notice It doesnt have the "/" in the date, its not a valid character here. (I Think)

As you see, this script creates a folder with the days date as its name.

1
· · ·
Pure Capsaicin
OP
##### Martin9700 Feb 13, 2014 at 3:14 UTC

Hi David, usually I'd delete this for necro-posting, but you are on topic.  That said, I still think you'll have MUCH better luck posting as a new question.  There are a lot of people here who can probably help but may not be following this thread anymore!  So I'd really encourage you to post a new question!

0

This discussion has been inactive for over a year.

You may get a better answer to your question by starting a new discussion.


text:
# Test your tests are Testing

Find out how effective your tests are, using mutation testing.

Are your tests testing? Are you assertions asserting?

Let’s find out how we can test that our tests are testing, with the mutation testing framework: infection.

Imagine this, you spend the last few hour refactoring a big part of the code base. You made some big changes and a lot of logic has been completely changed. Now it’s time to figure out what tests have broken due to all the refactoring. You open up the terminal and enter the good old vendor/bin/phpunit and watch the tests run.

That doesn’t look right, at least a few tests should have been broken by those changes. Some exceptions are no longer being thrown, return types have changed yet, your tests don’t care. According to them everything is still just as it was.

## What is mutation testing

Have you ever created a unit test, and then changed something in your code to see if it failed? Well mutation testing is exactly that, but automated.

Let’s say you have the following class you are testing

<?php
class Calculator
{
public function adds(int $a, int$b): int
{
return $a +$b;
}

public function subtracts(int $a, int$b): int
{
return $a +$b;
}
}

And the following test to make sure it works

<?php
class CalculatorTest extends TestCase
{
{
$calc = new Calculator();$this->assertTrue(is_int($calc->adds(1,2))); } public function test_subtracts() {$calc = new Calculator();
$this->assertTrue(is_int($calc->subtracts(1,2)));
}
}

We have 100% coverage, tests are green, so everything works as intended, right?

Of course, the subtracts method has a bug, instead of a - there is a +. A simple copy paste error, but our tests aren’t catching it.

So, how do we make sure our tests will catch those bugs? Through mutation testing. PHP has the mutation testing framework Infection, which is what we will be using for the example.

Let’s look at the interesting parts of the output:

Four mutations were created, but only two were killed, while the other two escaped. Lets look at infection-log.txt to see what has happened:

Escaped mutants:
================

1) /home/gpagter/Projects/Randoms/calculator/src/Calculator.php:8    [M] Plus

--- Original
+++ New
@@ @@
{
public function adds(int $a, int$b) : int
{
-        return $a +$b;
+        return $a -$b;
}
public function subtracts(int $a, int$b) : int
{

2) /home/gpagter/Projects/Randoms/calculator/src/Calculator.php:13    [M] Plus

--- Original
+++ New
@@ @@
}
public function subtracts(int $a, int$b) : int
{
-        return $a +$b;
+        return $a -$b;
}
}

Killed mutants:
===============

1) /home/gpagter/Projects/Randoms/calculator/src/Calculator.php:6    [M] PublicVisibility

--- Original
+++ New
@@ @@

class Calculator
{
-    public function adds(int $a, int$b) : int
+    protected function adds(int $a, int$b) : int
{
return $a +$b;
}

2) /home/gpagter/Projects/Randoms/calculator/src/Calculator.php:11    [M] PublicVisibility

--- Original
+++ New
@@ @@
{
return $a +$b;
}
-    public function subtracts(int $a, int$b) : int
+    protected function subtracts(int $a, int$b) : int
{
return $a +$b;
}
}

Let’s dissect what has happened, and see what it means for us.

When looking at the Killed mutants, we see two mutants, both PublicVisibility. What infection has done for these methods, is change their signature from public to protected. And then it ran all tests that are relevant for that line of code. The tests then failed, which means that the mutation was ‘killed’. Our tests detected this change in the code.

But what about the two ‘escaped’ mutants? Our tests did not pick up on this change. When the + got changed to a -, our tests did not fail, all assertions were okay. This means that the mutant has ‘escaped’. The tests did not pick up on the fact that our code changed.

If a test took too long, or caused a PHP error, it is also considered killed. The last option are mutants that are not covered by tests. Infection still takes these into account for metrics.

Lets go ahead and update our tests to kill these mutants.

<?php
class CalculatorTest extends TestCase
{
{
$calc = new Calculator();$result = $calc->adds(1,2);$this->assertTrue(is_int($result));$this->assertSame(3, $result); } public function test_subtracts() {$calc = new Calculator();
$result =$calc->subtracts(1,2);
$this->assertTrue(is_int($result));
$this->assertSame(-1,$result);
}
}

Now we find that our subtracts method is actually returning 3 instead of -1. So we fix the bug, and run our tests again. They all pass, so lets run infection again as well.

We did it, we fixed the bug, killed all mutants and saved the day!

## Metrics

We have seen the Metrics in the infection output, but what does it mean?

Mutation Score Indicator (MSI)

Let’s say our code base has a total of 100 possible mutations. 40 of those are caught by the tests, either because the tests fail or because they cause a time out or a php error. 20 of them are not covered by tests, and another 40 don’t cause the tests to fail and ‘escape’.

This would give us a MSI of 40% (The amount of killed mutations divided by the total possible amount.) You generally want this number to be close to your code coverage. If it is a lot lower it means your tests aren’t as good as you think they are.

It can be enforced, for example on CI, with the --min-msi flag.

Mutation Code Coverage

This the amount of mutations that are covered by tests, if we take the numbers of the MSI example, it would be 80%.

Covered Code MSI

This is the same as MSI, except only for covered code. So all mutations that are not covered by tests are ignored. If we take the numbers of the MSI example, we have a Covered Code MSI of 50%. You want this to be as close to 100% as possible.

It can be enforced, for example on CI, with the --min-covered-msi flag.

## Usage

Installation

You can install infection in a few ways:

• Through Composer as a dev dependency: composer require infection/infection --dev
• Through Composer as a global package: composer global require infection/infection
• Or as a phar:
$wget https://github.com/infection/infection/releases/download/0.8.2/infection.phar$ wget https://github.com/infection/infection/releases/download/0.8.2/infection.phar.pubkey

$chmod +x infection.phar  If you want to update your phar you can do so by running $ ./infection.phar self-update.

Local usage

Running infection can take a lot of time if you have a big project or if your tests are slow. One way to speed it up is to run it with the following option: --threads=nproc. This will run the tests against mutations multi threaded, with as much threads as useful. Note: This should only be done if your tests can be ran parallel. If they use a database or the file system this can lead to a lot of mutations being killed that are not detected by your tests.

CI

If you run infection during CI, its recommended to run it with the --min-msi and/or --min-covered-msi. This will force you to write better tests and keep your MSI and Covered Code MSI as a stable rate.

If you are already generation coverage on CI, you can hand infection that coverage, so it doesn’t have to generate it itself. Infection needs xml and junit coverage to run

$vendor/bin/phpunit --coverage-xml coverage/coverage-xml --log-junit=coverage/phpunit.junit.xml$ vendor/bin/infection --coverage=coverage

If you only want to run infection against changed code, you can run it like this:

INFECTION_FILTER=$(git diff${GIT_PREVIOUS_SUCCESSFUL_COMMIT:-origin/master} $GIT_COMMIT --name-only | grep /src/ | paste -sd "," -)$ vendor/bin/infection --threads=4 --min-msi=70 --only-covered --filter="\${INFECTION_FILTER}" --ignore-msi-with-no-mutations

This will only run infection against changed files that differ from the last successful commit on this branch, or master if there is none, in the src folder. The --ignore-msi-with-no-mutations flag causes us to not error on min msi when we have 0 mutations.

For all the configuration options, you can check out infections documentation.

##### Gert de Pagter
###### Software Engineer

My interests include software development, math and magic.


text:
Property of transpose Tr in category of modules (Auslander-Reiten theory)

I am reading the book Elements of the Representation Theory of Associative Algebras: Volume 1 , and I have a question on its proof of main properties of transpose $$Tr$$, appearing in Auslander-Reiten theory.
Here we assume $$A$$ is a finite dimensional algebra over an algebraically closed field $$K$$, and $$mod A$$ is a category of finitely generated modules of $$A$$. Also, consider a functor $$(−)^t = Hom_A(−,A) : mod A → mod A^{op}$$.
For an object $$M$$ in $$mod A$$, we define $$Tr M$$ as follows:

If $$P_1→P_0→M→0$$ is a minimal projective presentation, then $$Tr M=Coker(P_0^t→P_1^t)$$. In other words, $$P_0^t→P_1^t→TrM→0$$ is exact.

Proposition 2.1.(b) in the textbook p.107 is about showing that

If M is not projective, then the exact sequence $$P_0^t→P_1^t→TrM→0$$ is a minimal projective presentation of an $$A^{op}$$ module $$Tr M$$.

In the proof, author assumes $$P_0^t→P_1^t→TrM→0$$ is not a minimal projective presentation. Then there exist non-trivial decompositions (by projective modules) $$P_0^t=E_0'⊕E_0''$$, $$P_1^t=E_1'⊕E_1''$$ and an isomorphism $$v:E_0''→E_1''$$ and a homomorphism $$u:E'_0→E'_1$$ such that the previous exact sequence is expressed as $$E_0'⊕E_0''\overset{\begin{pmatrix} u & 0 \\ 0 & v \end{pmatrix}}{\rightarrow}E_1'⊕E_1''→Tr M→0$$.
(I think the author assumed $$E'_0\overset{u}{\rightarrow}E'_1→Tr M→0$$ is a minimal projective presentation.)

But I couldn't quite understand the next step. It is written as,

But then applying $$(−)^t$$ yields a projective presentation of M of the form $${E'_1}^t\overset{u^t}{\rightarrow}{E'_0}^t→M→0$$

But I couldn't figure out why we get $$M$$ as a cokernel of $$u^t$$. Any helps will be appreciated. Thank you for reading.

For finitely generated projective modules $$X$$, the evaluation map $$X\to X^{tt}$$ (defined by $$x\mapsto[\varphi\mapsto\varphi(m)]$$) is a natural isomorphism.
So $$P_1\to P_0$$ is isomorphic to $$P_1^{tt}\to P_0^{tt}$$, which in turn is isomorphic to the direct sum of $$E_1'^t\xrightarrow{u^t}E_0'^t$$ and $$E_1''^t\xrightarrow{v^t}E_0''^t$$.
But $$v$$ is an isomorphism, so $$v^t$$ is an isomorphism and so its cokernel is zero. So $$M$$, which is the cokernel of $$P_1\to P_0$$, is also the cokernel of the first summand $$E_1'^t\xrightarrow{u^t}E_0'^t$$.


text:
## BSSPC '21 J3 - Magic Paint Gun Cartridges

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

Minestro is recreating images on the Internet with his magic paint gun when he unexpectedly runs out of cartridges!

Minestro has access to a supply of cartridges in the three primary colors - red, blue and yellow. Each image is represented by a grid of rows and columns of cells that are all initially empty, with no paint of any color in any cell.

Minestro can consume a single paint cartridge with his gun to add paint of the color of the cartridge to a contiguous sequence of adjacent cells in a single row. It is possible for up to three cartridges to paint their color on the same cell, in which case the resulting color is a mixture of all colors applied, according to the following table:

Color Symbol Primary Colors to Mix
White . None
Red R Red
Blue U Blue
Yellow Y Yellow
Orange O Red and yellow
Green G Blue and yellow
Purple P Red and blue
Brown B Red, blue, and yellow

Minestro still has one image to paint, so he needs you to tell him the minimum number of red, yellow, and blue paint cartridges he needs to buy — paint cartridges are expensive!

Note: Some Python 2/3 solutions may require PyPy to pass.

#### Input Specification

The first line will contain two integers and , the number of columns and rows of cells in the image, respectively.

The next lines will each contain characters, each of which is one of the eight characters ., R, O, Y, G, U, P, or B. The character on the line represents the required color of the cell on the row.

#### Output Specification

Output the minimum number of red, yellow, and blue paint cartridges Minestro needs to buy to paint the picture, separated by spaces.

#### Sample Input 1

6 4
..RR.P
..OORO
BBB.UU
ROBB..

#### Sample Output 1

5 4 4

#### Explanation for Sample Output 1

Minestro needs red cartridges: for the first row and in every other row. He needs yellow cartridges: in the second row and each in the last two rows. blue cartridges are used: in the first row, in the third, and in the last.

#### Sample Input 2

18 9
.B................
..YY...........YYY
...YYY.....YYYY...
..YYYYYYYYYYYYY...
.YYBBYYYYYBBYYY...
.RRYYYYBYYYYRRY...
.RRYYYOOOYYYRRY...
..YYYYOOOYYYYYY...
.YYYYYYYYYYYYYY...

#### Sample Output 2

10 13 4

#### Explanation for Sample Output 2

Minestro needs:

• red cartridges: in the first row, in the fifth, in the sixth, in the seventh, and in the eighth row.
• yellow cartridges: in the first row, in the second and third each, in the fourth and fifth each, in the sixth and seventh each, and cartridge each for the last two rows.
• blue cartridges: in the first row, in the fifth, and in the sixth row.


text:
How can I calculate the amount of heat my copper water trap can dissipate?

My small (1.5hp) air compressor is connected to a water trap made of 8mm copper of about 4 metres length. The idea is that you push the compressed air through the piping which cools it, condensing the water out (which you drain away) and thus sending dry air to your air tools.

I know the system works, but i would like to understand the maths behind it. I started trying to work it out with help of the below graph from engineeringtoolbox.com but didn't know where to go next.

How can I mathematically determine the temperature drop of the air in the piping? We can assume an average ambient temperature of 25 degrees Celcius with air coming out of the compressor at 100 degrees Celcius.

• Check out conduction, convection and radiation. Feb 12 '19 at 14:09
• you should figure out the mass flow rate of air through the pipe and also the heat capacity of moist air and the latent heat of condensation of water vapor. Both properties can probably be found on engineering toolbox. Feb 13 '19 at 0:22
• Just a side note, if the numbers in the chart inside parentheses supposed to be the Celsius conversation of the Fahrenheit they are all wrong. Feb 13 '19 at 5:57
• What is either the mass flow or the volumetric flow of gas through the pipe? Feb 15 '19 at 2:50

$$T_{out} = \frac{\dot{Q}}{\dot{m}C_p}+T_{in}$$ Where T is temperature, $$\dot{Q}$$ is heat rate, $$\dot{m}$$ is mass flowrate and $$C_p$$ is the specific heat of air at constant pressure. To check the units: $$T_{out}[C] = \frac{\dot{Q} \left[\frac{J}{s}\right]}{\dot{m}\left[\frac{kg}{s}\right]C_p\left[\frac{J}{kgC}\right]} + T_{in} [C]$$ To clarify, $$\frac{J}{s} = W$$, and these are SI units (Joule, kilogram, Celsius).

• Thank you very much for this! What is heat rate? I Googled but the term seemed too generic to give any specific detail. Feb 14 '19 at 13:56
• The heat rate will be the heat loss from the figure you showed in your post multiplied by the length of the copper pipe in meters. Feb 14 '19 at 17:26

Pipe (Dry) Air Flow

Theory

Start from the air flow through the pipe. The energy balance equation below considers only convection from the outer air and takes a lumped analysis of the fluid in the pipe. In this, P is the perimeter length of the pipe.

$$\dot{m}\tilde{C}_p\frac{dT}{dx} = - h_a P (T - T_a)$$

Given the tube length $$L$$ and the entering hot temperature $$T_h$$, we recast this as a dimensionless expression using $$\Theta = (T - T_a)/(T_h - T_a)$$ and $$X = x/L$$.

$$\frac{d\Theta}{dX} = -\beta \Theta$$

The dimensionless factor $$\beta = h_a P L / \dot{m}\tilde{C}_p$$ is the ratio of heat leaving the pipe by convection to the heat entering the pipe with the fluid flow. The factor $$PL$$ is the total external tube area $$A$$. With the boundary condition $$\Theta = 1$$ at $$X = 0$$, we have the solution.

$$\ln(\Theta) = -\beta X$$

Here is a plot of $$\Theta$$ versus $$X$$ for $$\beta = 2$$ (black upper curve) and $$\beta = 3$$ (blue lower curve).

Typical Values

The pipe in your problem has a DIAMETER of 8 mm and a length of 4 m. This gives $$A = (4)(2)\pi(0.004) = 0.1$$ m$$^2$$.

Stagnate air outside the tube has a value $$h_a \approx 5$$ W/m$$^2$$ $$^o$$C [engineering toolbox]. Air has a specific heat of $$\tilde{C}_p \approx 0.7$$ J/g $$^o$$C [Ohio MAE Website].

Mass flow of air as an ideal gas is $$\dot{m} = M(p\dot{V}/RT)$$. At 25 $$^o$$C and 1 bar, this gives a relationship for mass flow (g/s) to volumetric flow (m$$^3$$/s) as below.

$$\dot{m} = 28(101325\dot{V})/((8.314)(298)) = 1150 \dot{V}$$

In the end, we have the relationship for $$\beta$$ to mass flow (g/s) or STP volumetric flow (m$$^3$$/s) as below.

$$\beta = 0.71/\dot{m} = 6.2 \times 10^{-4}/ \dot{V}$$

Suppose we take a mass flow of 1 g/s of air through the tube. This gives $$\beta \approx 0.7$$.

$$\Rightarrow$$ To proceed further, we need the mass or volumetric flow through the tube.

Condensation of Water Vapor

Water vapor will condense when its partial pressure is equal to (or above) its vapor pressure. We can consider the Antoine equation to track the vapor pressure as a function of temperature.

$$\log( p_{vap} ) = A - \frac{B}{C + T}$$

The first relationship we need to make is to translate the curve of $$\Theta$$ versus $$X$$ to a corresponding curve of $$p_{vap}$$ versus $$X$$. For ease in what follows, define that relationship as $$AE \equiv 10^{\log (p_{vap})} = f(\Theta)$$. We can then use the relative humidity of the incoming air to obtain the $$p_{H_2O}$$ in the incoming stream based on it $$p_{vap}$$.

$$p_{H_2O}(X = 0) = RH_o\ p_{vap}(X = 0) = RH_o\ AE(\Theta(X = 0))$$

The incoming stream has an initial value of $$p_{H_2O}(X = 0)$$. We have a plot of $$p_{vap}(X)$$ from $$AE(\Theta(X))$$. When $$p_{vap}(X)$$ falls below the value $$p_{H_2O}(X = 0)$$, water vapor will condense. The analysis needed to find the point $$X$$ when condensation starts is left as an exercise.

Starting at the point where water vapor condenses, the latent enthalpy of the exothermic condensation will act as an additional heat source in the energy balance. The temperature of the air will fall less rapidly. This analysis is also left as an exercise.

A poor method to remove water. The air velocity from a relatively large compressor into a small line will atomize the condensed water and give a "fog" at discharge. Why not use the standard efficient system ? Normally the compressor discharges into a large ( steel ) tank where the water condenses to the bottom and is periodically drained. My 1/3 Hp compressor used a very short length of about 12 mm tubing into the reservoir , so your 8mm tubing on a 1.5 Hp compressor will result in very high velocities when flowing. The standard reservoir system worked fine for condensate control when I used it to paint a couple cars.


text:
# Digital pre-filtering

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

After demodulation and range gating, the receiver signal $\mathbf{S}$ at one particular range gate forms a discrete complex time series for $k= 0,\ldots, N_{ci} \cdot N_p\cdot N_s -1$ (The length of the time series is written as a product of three integers for later convenience, $i = \sqrt{-1}$):

$S[k] = S_I[k] + i S_Q[k]$.

The sampling time $\Delta T$ depends on the inter-pulse period.

### 1 Coherent integration

RWP's often apply a simple preprocessing method called coherent integration:

$S^{ci} [m] = \frac{1}{N_{ci}} \sum_{n=0}^{N_{ci}-1} S[m \cdot N_{ci} + n]$.

This is a digital filter with decimation (Farley (1985)), whereby the sampling interval is increased to $N_{ci} \Delta T$. Its frequency response is referred to as comb-filtering (Schmidt et.al. (1979)), with an amplitude transfer function depending on frequency as

$|H(f)| = \frac{\sin(N_{ci} \pi f \Delta T)}{N_{ci} \sin(\pi f \Delta T)} = \mathcal{D}_{N_{ci}}(f \Delta T)$,

where $\mathcal{D}_{N_{ci}}$ is the Dirichlet kernel. A plot of this function around baseband is shown below. Note that the function is periodic and only plotted over a finite interval. The time increment of the coherently integrated series is changed to $N_{ci} \cdot \Delta T$. This method poses no problems if the number of coherent samples $N_{ci}$ is chosen not to large.

H(f)

The motivation for coherent integration is a reduction of the data rate and it has mainly historical roots. For sufficiently capable hardware it is possible to set this method aside, which has some advantages, see Wilfong et.al. (1999), Hocking (1997a) and Hocking (1997b).

### 2 Filtering of nonstationary clutter

Any non-stationary character of clutter signals, as for example caused by bird or airplane echoes, make a sole spectral representation of the signal inadequate for an efficient and suitable description of the clutter component. Methods of non-stationary signal analysis therefore need to be used to find a decent (hopefully sparse) representation for such signals, which may then allow efficient filtering strategies with the purpose of either fully removing the intermittent clutter component or for setting appropriate quality flags.

Examples are wavelet filtering methods as suggested by Jordan et.al. (1997) or Boisse et.al. (1999) and Gabor frame based methods, see Lehmann and Teschke (2008), Lehmann (2012).

Back to RWP_Fundamentals


text:
# Chapter 21 Multivariate Methods

$$y_1,...,y_p$$ are possibly correlated random variables with means $$\mu_1,...,\mu_p$$

$\mathbf{y} = \left( \begin{array} {c} y_1 \\ . \\ y_p \\ \end{array} \right)$

$E(\mathbf{y}) = \left( \begin{array} {c} \mu_1 \\ . \\ \mu_p \\ \end{array} \right)$

Let $$\sigma_{ij} = cov(y_i, y_j)$$ for $$i,j = 1,…,p$$

$\mathbf{\Sigma} = (\sigma_{ij}) = \left( \begin{array} {cccc} \sigma_{11} & \sigma_{22} & ... & \sigma_{1p} \\ \sigma_{21} & \sigma_{22} & ... & \sigma_{2p} \\ . & . & . & . \\ \sigma_{p1} & \sigma_{p2} & ... & \sigma_{pp} \end{array} \right)$

where $$\mathbf{\Sigma}$$ (symmetric) is the variance-covariance or dispersion matrix

Let $$\mathbf{u}_{p \times 1}$$ and $$\mathbf{v}_{q \times 1}$$ be random vectors with means $$\mu_u$$ and $$\mu_v$$ . Then

$\mathbf{\Sigma}_{uv} = cov(\mathbf{u,v}) = E[(\mathbf{u} - \mu_u)(\mathbf{v} - \mu_v)']$

in which $$\mathbf{\Sigma}_{uv} \neq \mathbf{\Sigma}_{vu}$$ and $$\mathbf{\Sigma}_{uv} = \mathbf{\Sigma}_{vu}'$$

Properties of Covariance Matrices

1. Symmetric $$\mathbf{\Sigma}' = \mathbf{\Sigma}$$
2. Non-negative definite $$\mathbf{a'\Sigma a} \ge 0$$ for any $$\mathbf{a} \in R^p$$, which is equivalent to eigenvalues of $$\mathbf{\Sigma}$$, $$\lambda_1 \ge \lambda_2 \ge ... \ge \lambda_p \ge 0$$
3. $$|\mathbf{\Sigma}| = \lambda_1 \lambda_2 ... \lambda_p \ge 0$$ (generalized variance) (the bigger this number is, the more variation there is
4. $$trace(\mathbf{\Sigma}) = tr(\mathbf{\Sigma}) = \lambda_1 + ... + \lambda_p = \sigma_{11} + ... + \sigma_{pp} =$$ sum of variance (total variance)

Note:

• $$\mathbf{\Sigma}$$ is typically required to be positive definite, which means all eigenvalues are positive, and $$\mathbf{\Sigma}$$ has an inverse $$\mathbf{\Sigma}^{-1}$$ such that $$\mathbf{\Sigma}^{-1}\mathbf{\Sigma} = \mathbf{I}_{p \times p} = \mathbf{\Sigma \Sigma}^{-1}$$

Correlation Matrices

$\rho_{ij} = \frac{\sigma_{ij}}{\sqrt{\sigma_{ii} \sigma_{jj}}}$

$\mathbf{R} = \left( \begin{array} {cccc} \rho_{11} & \rho_{12} & ... & \rho_{1p} \\ \rho_{21} & \rho_{22} & ... & \rho_{2p} \\ . & . & . &. \\ \rho_{p1} & \rho_{p2} & ... & \rho_{pp} \\ \end{array} \right)$

where $$\rho_{ij}$$ is the correlation, and $$\rho_{ii} = 1$$ for all i

Alternatively,

$\mathbf{R} = [diag(\mathbf{\Sigma})]^{-1/2}\mathbf{\Sigma}[diag(\mathbf{\Sigma})]^{-1/2}$

where $$diag(\mathbf{\Sigma})$$ is the matrix which has the $$\sigma_{ii}$$’s on the diagonal and 0’s elsewhere

and $$\mathbf{A}^{1/2}$$ (the square root of a symmetric matrix) is a symmetric matrix such as $$\mathbf{A} = \mathbf{A}^{1/2}\mathbf{A}^{1/2}$$

Equalities

Let

• $$\mathbf{x}$$ and $$\mathbf{y}$$ be random vectors with means $$\mu_x$$ and $$\mu_y$$ and variance -variance matrices $$\mathbf{\Sigma}_x$$ and $$\mathbf{\Sigma}_y$$.

• $$\mathbf{A}$$ and $$\mathbf{B}$$ be matrices of constants and $$\mathbf{c}$$ and $$\mathbf{d}$$ be vectors of constants

Then

• $$E(\mathbf{Ay + c} ) = \mathbf{A} \mu_y + c$$

• $$var(\mathbf{Ay + c}) = \mathbf{A} var(\mathbf{y})\mathbf{A}' = \mathbf{A \Sigma_y A}'$$

• $$cov(\mathbf{Ay + c, By+ d}) = \mathbf{A\Sigma_y B}'$$

• $$E(\mathbf{Ay + Bx + c}) = \mathbf{A \mu_y + B \mu_x + c}$$

• $$var(\mathbf{Ay + Bx + c}) = \mathbf{A \Sigma_y A' + B \Sigma_x B' + A \Sigma_{yx}B' + B\Sigma'_{yx}A'}$$

Multivariate Normal Distribution

Let $$\mathbf{y}$$ be a multivariate normal (MVN) random variable with mean $$\mu$$ and variance $$\mathbf{\Sigma}$$. Then the density of $$\mathbf{y}$$ is

$f(\mathbf{y}) = \frac{1}{(2\pi)^{p/2}|\mathbf{\Sigma}|^{1/2}} \exp(-\frac{1}{2} \mathbf{(y-\mu)'\Sigma^{-1}(y-\mu)} )$

$$\mathbf{y} \sim N_p(\mu, \mathbf{\Sigma})$$

### 21.0.1 Properties of MVN

• Let $$\mathbf{A}_{r \times p}$$ be a fixed matrix. Then $$\mathbf{Ay} \sim N_r (\mathbf{A \mu, A \Sigma A'})$$ . $$r \le p$$ and all rows of $$\mathbf{A}$$ must be linearly independent to guarantee that $$\mathbf{A \Sigma A}'$$ is non-singular.

• Let $$\mathbf{G}$$ be a matrix such that $$\mathbf{\Sigma}^{-1} = \mathbf{GG}'$$. Then $$\mathbf{G'y} \sim N_p(\mathbf{G' \mu, I})$$ and $$\mathbf{G'(y-\mu)} \sim N_p (0,\mathbf{I})$$

• Any fixed linear combination of $$y_1,...,y_p$$ (say $$\mathbf{c'y}$$) follows $$\mathbf{c'y} \sim N_1 (\mathbf{c' \mu, c' \Sigma c})$$

• Define a partition, $$[\mathbf{y}'_1,\mathbf{y}_2']'$$ where

• $$\mathbf{y}_1$$ is $$p_1 \times 1$$

• $$\mathbf{y}_2$$ is $$p_2 \times 1$$,

• $$p_1 + p_2 = p$$

• $$p_1,p_2 \ge 1$$ Then

$\left( \begin{array} {c} \mathbf{y}_1 \\ \mathbf{y}_2 \\ \end{array} \right) \sim N \left( \left( \begin{array} {c} \mu_1 \\ \mu_2 \\ \end{array} \right), \left( \begin{array} {cc} \mathbf{\Sigma}_{11} & \mathbf{\Sigma}_{12} \\ \mathbf{\Sigma}_{21} & \mathbf{\Sigma}_{22}\\ \end{array} \right) \right)$

• The marginal distributions of $$\mathbf{y}_1$$ and $$\mathbf{y}_2$$ are $$\mathbf{y}_1 \sim N_{p1}(\mathbf{\mu_1, \Sigma_{11}})$$ and $$\mathbf{y}_2 \sim N_{p2}(\mathbf{\mu_2, \Sigma_{22}})$$

• Individual components $$y_1,...,y_p$$ are all normally distributed $$y_i \sim N_1(\mu_i, \sigma_{ii})$$

• The conditional distribution of $$\mathbf{y}_1$$ and $$\mathbf{y}_2$$ is normal

• $$\mathbf{y}_1 | \mathbf{y}_2 \sim N_{p1}(\mathbf{\mu_1 + \Sigma_{12} \Sigma_{22}^{-1}(y_2 - \mu_2),\Sigma_{11} - \Sigma_{12} \Sigma_{22}^{-1} \sigma_{21}})$$

• In this formula, we see if we know (have info about) $$\mathbf{y}_2$$, we can re-weight $$\mathbf{y}_1$$ ’s mean, and the variance is reduced because we know more about $$\mathbf{y}_1$$ because we know $$\mathbf{y}_2$$
• which is analogous to $$\mathbf{y}_2 | \mathbf{y}_1$$. And $$\mathbf{y}_1$$ and $$\mathbf{y}_2$$ are independently distrusted only if $$\mathbf{\Sigma}_{12} = 0$$

• If $$\mathbf{y} \sim N(\mathbf{\mu, \Sigma})$$ and $$\mathbf{\Sigma}$$ is positive definite, then $$\mathbf{(y-\mu)' \Sigma^{-1} (y - \mu)} \sim \chi^2_{(p)}$$

• If $$\mathbf{y}_i$$ are independent $$N_p (\mathbf{\mu}_i , \mathbf{\Sigma}_i)$$ random variables, then for fixed matrices $$\mathbf{A}_{i(m \times p)}$$, $$\sum_{i=1}^k \mathbf{A}_i \mathbf{y}_i \sim N_m (\sum_{i=1}^{k} \mathbf{A}_i \mathbf{\mu}_i, \sum_{i=1}^k \mathbf{A}_i \mathbf{\Sigma}_i \mathbf{A}_i)$$

Multiple Regression

$\left( \begin{array} {c} Y \\ \mathbf{x} \end{array} \right) \sim N_{p+1} \left( \left[ \begin{array} {c} \mu_y \\ \mathbf{\mu}_x \end{array} \right] , \left[ \begin{array} {cc} \sigma^2_Y & \mathbf{\Sigma}_{yx} \\ \mathbf{\Sigma}_{yx} & \mathbf{\Sigma}_{xx} \end{array} \right] \right)$

The conditional distribution of Y given x follows a univariate normal distribution with

\begin{aligned} E(Y| \mathbf{x}) &= \mu_y + \mathbf{\Sigma}_{yx} \Sigma_{xx}^{-1} (\mathbf{x}- \mu_x) \\ &= \mu_y - \Sigma_{yx} \Sigma_{xx}^{-1}\mu_x + \Sigma_{yx} \Sigma_{xx}^{-1}\mathbf{x} \\ &= \beta_0 + \mathbf{\beta'x} \end{aligned}

where $$\beta = (\beta_1,...,\beta_p)' = \mathbf{\Sigma}_{xx}^{-1} \mathbf{\Sigma}_{yx}'$$ (e.g., analogous to $$\mathbf{(x'x)^{-1}x'y}$$ but not the same if we consider $$Y_i$$ and $$\mathbf{x}_i$$, $$i = 1,..,n$$ and use the empirical covariance formula: $$var(Y|\mathbf{x}) = \sigma^2_Y - \mathbf{\Sigma_{yx}\Sigma^{-1}_{xx} \Sigma'_{yx}}$$)

Samples from Multivariate Normal Populations

A random sample of size n, $$\mathbf{y}_1,.., \mathbf{y}_n$$ from $$N_p (\mathbf{\mu}, \mathbf{\Sigma})$$. Then

• Since $$\mathbf{y}_1,..., \mathbf{y}_n$$ are iid, their sample mean, $$\bar{\mathbf{y}} = \sum_{i=1}^n \mathbf{y}_i/n \sim N_p (\mathbf{\mu}, \mathbf{\Sigma}/n)$$. that is, $$\bar{\mathbf{y}}$$ is an unbiased estimator of $$\mathbf{\mu}$$

• The $$p \times p$$ sample variance-covariance matrix, $$\mathbf{S}$$ is $$\mathbf{S} = \frac{1}{n-1}\sum_{i=1}^n (\mathbf{y}_i - \bar{\mathbf{y}})(\mathbf{y}_i - \bar{\mathbf{y}})' = \frac{1}{n-1} (\sum_{i=1}^n \mathbf{y}_i \mathbf{y}_i' - n \bar{\mathbf{y}}\bar{\mathbf{y}}')$$

• where $$\mathbf{S}$$ is symmetric, unbiased estimator of $$\mathbf{\Sigma}$$ and has $$p(p+1)/2$$ random variables.
• $$(n-1)\mathbf{S} \sim W_p (n-1, \mathbf{\Sigma})$$ is a Wishart distribution with n-1 degrees of freedom and expectation $$(n-1) \mathbf{\Sigma}$$. The Wishart distribution is a multivariate extension of the Chi-squared distribution.

• $$\bar{\mathbf{y}}$$ and $$\mathbf{S}$$ are independent

• $$\bar{\mathbf{y}}$$ and $$\mathbf{S}$$ are sufficient statistics. (All of the info in the data about $$\mathbf{\mu}$$ and $$\mathbf{\Sigma}$$ is contained in $$\bar{\mathbf{y}}$$ and $$\mathbf{S}$$ , regardless of sample size).

Large Sample Properties

$$\mathbf{y}_1,..., \mathbf{y}_n$$ are a random sample from some population with mean $$\mathbf{\mu}$$ and variance-covariance matrix $$\mathbf{\Sigma}$$

• $$\bar{\mathbf{y}}$$ is a consistent estimator for $$\mu$$

• $$\mathbf{S}$$ is a consistent estimator for $$\mathbf{\Sigma}$$

• Multivariate Central Limit Theorem: Similar to the univariate case, $$\sqrt{n}(\bar{\mathbf{y}} - \mu) \dot{\sim} N_p (\mathbf{0,\Sigma})$$ where n is large relative to p ($$n \ge 25p$$), which is equivalent to $$\bar{\mathbf{y}} \dot{\sim} N_p (\mu, \mathbf{\Sigma}/n)$$

• Wald’s Theorem: $$n(\bar{\mathbf{y}} - \mu)' \mathbf{S}^{-1} (\bar{\mathbf{y}} - \mu)$$ when n is large relative to p.

Maximum Likelihood Estimation for MVN

Suppose iid $$\mathbf{y}_1 ,... \mathbf{y}_n \sim N_p (\mu, \mathbf{\Sigma})$$, the likelihood function for the data is

\begin{aligned} L(\mu, \mathbf{\Sigma}) &= \prod_{j=1}^n (\frac{1}{(2\pi)^{p/2}|\mathbf{\Sigma}|^{1/2}} \exp(-\frac{1}{2}(\mathbf{y}_j -\mu)'\mathbf{\Sigma}^{-1})(\mathbf{y}_j -\mu)) \\ &= \frac{1}{(2\pi)^{np/2}|\mathbf{\Sigma}|^{n/2}} \exp(-\frac{1}{2} \sum_{j=1}^n(\mathbf{y}_j -\mu)'\mathbf{\Sigma}^{-1})(\mathbf{y}_j -\mu) \end{aligned}

Then, the MLEs are

$\hat{\mu} = \bar{\mathbf{y}}$

$\hat{\mathbf{\Sigma}} = \frac{n-1}{n} \mathbf{S}$

using derivatives of the log of the likelihood function with respect to $$\mu$$ and $$\mathbf{\Sigma}$$

Properties of MLEs

• Invariance: If $$\hat{\theta}$$ is the MLE of $$\theta$$, then the MLE of $$h(\theta)$$ is $$h(\hat{\theta})$$ for any function h(.)

• Consistency: MLEs are consistent estimators, but they are usually biased

• Efficiency: MLEs are efficient estimators (no other estimator has a smaller variance for large samples)

• Asymptotic normality: Suppose that $$\hat{\theta}_n$$ is the MLE for $$\theta$$ based upon n independent observations. Then $$\hat{\theta}_n \dot{\sim} N(\theta, \mathbf{H}^{-1})$$

• $$\mathbf{H}$$ is the Fisher Information Matrix, which contains the expected values of the second partial derivatives fo the log-likelihood function. the (i,j)th element of $$\mathbf{H}$$ is $$-E(\frac{\partial^2 l(\mathbf{\theta})}{\partial \theta_i \partial \theta_j})$$

• we can estimate $$\mathbf{H}$$ by finding the form determined above, and evaluate it at $$\theta = \hat{\theta}_n$$

• Likelihood ratio testing: for some null hypothesis, $$H_0$$ we can form a likelihood ratio test

• The statistic is: $$\Lambda = \frac{\max_{H_0}l(\mathbf{\mu}, \mathbf{\Sigma|Y})}{\max l(\mu, \mathbf{\Sigma | Y})}$$

• For large n, $$-2 \log \Lambda \sim \chi^2_{(v)}$$ where v is the number of parameters in the unrestricted space minus the number of parameters under $$H_0$$

Test of Multivariate Normality

• Check univariate normality for each trait (X) separately

• Can check Normality Assessment

• The good thing is that if any of the univariate trait is not normal, then the joint distribution is not normal (see again Properties of MVN). If a joint multivariate distribution is normal, then the marginal distribution has to be normal.

• However, marginal normality of all traits does not imply joint MVN

• Easily rule out multivariate normality, but not easy to prove it

• Mardia’s tests for multivariate normality

• Multivariate skewness is$\beta_{1,p} = E[(\mathbf{y}- \mathbf{\mu})' \mathbf{\Sigma}^{-1} (\mathbf{x} - \mathbf{\mu})]^3$

• where $$\mathbf{x}$$ and $$\mathbf{y}$$ are independent, but have the same distribution (note: $$\beta$$ here is not regression coefficient)

• Multivariate kurtosis is defined as

• $\beta_{2,p} - E[(\mathbf{y}- \mathbf{\mu})' \mathbf{\Sigma}^{-1} (\mathbf{x} - \mathbf{\mu})]^2$

• For the MVN distribution, we have $$\beta_{1,p} = 0$$ and $$\beta_{2,p} = p(p+2)$$

• For a sample of size n, we can estimate

$\hat{\beta}_{1,p} = \frac{1}{n^2}\sum_{i=1}^n \sum_{j=1}^n g^2_{ij}$

$\hat{\beta}_{2,p} = \frac{1}{n} \sum_{i=1}^n g^2_{ii}$

• where $$g_{ij} = (\mathbf{y}_i - \bar{\mathbf{y}})' \mathbf{S}^{-1} (\mathbf{y}_j - \bar{\mathbf{y}})$$. Note: $$g_{ii} = d^2_i$$ where $$d^2_i$$ is the Mahalanobis distance
• shows for large n

$\kappa_1 = \frac{n \hat{\beta}_{1,p}}{6} \dot{\sim} \chi^2_{p(p+1)(p+2)/6}$

$\kappa_2 = \frac{\hat{\beta}_{2,p} - p(p+2)}{\sqrt{8p(p+2)/n}} \sim N(0,1)$

• Hence, we can use $$\kappa_1$$ and $$\kappa_2$$ to test the null hypothesis of MVN.

• When the data are non-normal, normal theory tests on the mean are sensitive to $$\beta_{1,p}$$ , while tests on the covariance are sensitive to $$\beta_{2,p}$$

• Chi-square Q-Q plot

• Let $$\mathbf{y}_i, i = 1,...,n$$ be a random sample sample from $$N_p(\mathbf{\mu}, \mathbf{\Sigma})$$

• Then $$\mathbf{z}_i = \mathbf{\Sigma}^{-1/2}(\mathbf{y}_i - \mathbf{\mu}), i = 1,...,n$$ are iid $$N_p (\mathbf{0}, \mathbf{I})$$. Thus, $$d_i^2 = \mathbf{z}_i' \mathbf{z}_i \sim \chi^2_p , i = 1,...,n$$

• plot the ordered $$d_i^2$$ values against the qualities of the $$\chi^2_p$$ distribution. When normality holds, the plot should approximately resemble a straight lien passing through the origin at a 45 degree

• it requires large sample size (i.e., sensitive to sample size). Even if we generate data from a MVN, the tail of the Chi-square Q-Q plot can still be out of line.

• If the data are not normal, we can

• ignore it

• use nonparametric methods

• use models based upon an approximate distirubiton (e.g., GLMM)

• try performing a transformation

library(heplots)
## Warning: package 'heplots' was built under R version 4.0.5
library(ICSNP)
## Warning: package 'ICSNP' was built under R version 4.0.5
## Warning: package 'ICS' was built under R version 4.0.5
library(MVN)
## Warning: package 'MVN' was built under R version 4.0.5
library(tidyverse)

names(trees) <- c("Nitrogen","Phosphorous","Potassium","Ash","Height")
str(trees)
## 'data.frame':    26 obs. of  5 variables:
##  $Nitrogen : num 2.2 2.1 1.52 2.88 2.18 1.87 1.52 2.37 2.06 1.84 ... ##$ Phosphorous: num  0.417 0.354 0.208 0.335 0.314 0.271 0.164 0.302 0.373 0.265 ...
##  $Potassium : num 1.35 0.9 0.71 0.9 1.26 1.15 0.83 0.89 0.79 0.72 ... ##$ Ash        : num  1.79 1.08 0.47 1.48 1.09 0.99 0.85 0.94 0.8 0.77 ...
##  $Height : int 351 249 171 373 321 191 225 291 284 213 ... summary(trees) ## Nitrogen Phosphorous Potassium Ash ## Min. :1.130 Min. :0.1570 Min. :0.3800 Min. :0.4500 ## 1st Qu.:1.532 1st Qu.:0.1963 1st Qu.:0.6050 1st Qu.:0.6375 ## Median :1.855 Median :0.2250 Median :0.7150 Median :0.9300 ## Mean :1.896 Mean :0.2506 Mean :0.7619 Mean :0.8873 ## 3rd Qu.:2.160 3rd Qu.:0.2975 3rd Qu.:0.8975 3rd Qu.:0.9825 ## Max. :2.880 Max. :0.4170 Max. :1.3500 Max. :1.7900 ## Height ## Min. : 65.0 ## 1st Qu.:122.5 ## Median :181.0 ## Mean :196.6 ## 3rd Qu.:276.0 ## Max. :373.0 cor(trees, method = "pearson") # correlation matrix ## Nitrogen Phosphorous Potassium Ash Height ## Nitrogen 1.0000000 0.6023902 0.5462456 0.6509771 0.8181641 ## Phosphorous 0.6023902 1.0000000 0.7037469 0.6707871 0.7739656 ## Potassium 0.5462456 0.7037469 1.0000000 0.6710548 0.7915683 ## Ash 0.6509771 0.6707871 0.6710548 1.0000000 0.7676771 ## Height 0.8181641 0.7739656 0.7915683 0.7676771 1.0000000 # qq-plot gg <- trees %>% pivot_longer(everything(), names_to = "Var", values_to = "Value") %>% ggplot(aes(sample = Value)) + geom_qq() + geom_qq_line() + facet_wrap("Var", scales = "free") gg # Univariate normality sw_tests <- apply(trees, MARGIN = 2, FUN = shapiro.test) sw_tests ##$Nitrogen
##
##  Shapiro-Wilk normality test
##
## data:  newX[, i]
## W = 0.96829, p-value = 0.5794
##
##
## $Phosphorous ## ## Shapiro-Wilk normality test ## ## data: newX[, i] ## W = 0.93644, p-value = 0.1104 ## ## ##$Potassium
##
##  Shapiro-Wilk normality test
##
## data:  newX[, i]
## W = 0.95709, p-value = 0.3375
##
##
## $Ash ## ## Shapiro-Wilk normality test ## ## data: newX[, i] ## W = 0.92071, p-value = 0.04671 ## ## ##$Height
##
##  Shapiro-Wilk normality test
##
## data:  newX[, i]
## W = 0.94107, p-value = 0.1424
# Kolmogorov-Smirnov test
ks_tests <- map(trees, ~ ks.test(scale(.x),"pnorm"))
## Warning in ks.test(scale(.x), "pnorm"): ties should not be present for the
## Kolmogorov-Smirnov test
## Warning in ks.test(scale(.x), "pnorm"): ties should not be present for the
## Kolmogorov-Smirnov test

## Warning in ks.test(scale(.x), "pnorm"): ties should not be present for the
## Kolmogorov-Smirnov test

## Warning in ks.test(scale(.x), "pnorm"): ties should not be present for the
## Kolmogorov-Smirnov test

## Warning in ks.test(scale(.x), "pnorm"): ties should not be present for the
## Kolmogorov-Smirnov test
ks_tests
## $Nitrogen ## ## One-sample Kolmogorov-Smirnov test ## ## data: scale(.x) ## D = 0.12182, p-value = 0.8351 ## alternative hypothesis: two-sided ## ## ##$Phosphorous
##
##  One-sample Kolmogorov-Smirnov test
##
## data:  scale(.x)
## D = 0.17627, p-value = 0.3944
## alternative hypothesis: two-sided
##
##
## $Potassium ## ## One-sample Kolmogorov-Smirnov test ## ## data: scale(.x) ## D = 0.10542, p-value = 0.9348 ## alternative hypothesis: two-sided ## ## ##$Ash
##
##  One-sample Kolmogorov-Smirnov test
##
## data:  scale(.x)
## D = 0.14503, p-value = 0.6449
## alternative hypothesis: two-sided
##
##
## $Height ## ## One-sample Kolmogorov-Smirnov test ## ## data: scale(.x) ## D = 0.1107, p-value = 0.9076 ## alternative hypothesis: two-sided # Mardia's test, need large sample size for power mardia_test <- mvn( trees, mvnTest = "mardia", covariance = FALSE, multivariatePlot = "qq" ) mardia_test$multivariateNormality
##              Test         Statistic            p value Result
## 1 Mardia Skewness  29.7248528871795   0.72054426745778    YES
## 2 Mardia Kurtosis -1.67743173185383 0.0934580886477281    YES
## 3             MVN              <NA>               <NA>    YES

### 21.0.2 Mean Vector Inference

In the univariate normal distribution, we test $$H_0: \mu =\mu_0$$ by using

$T = \frac{\bar{y}- \mu_0}{s/\sqrt{n}} \sim t_{n-1}$

under the null hypothesis. And reject the null if $$|T|$$ is large relative to $$t_{(1-\alpha/2,n-1)}$$ because it means that seeing a value as large as what we observed is rare if the null is true

Equivalently,

$T^2 = \frac{(\bar{y}- \mu_0)^2}{s^2/n} = n(\bar{y}- \mu_0)(s^2)^{-1}(\bar{y}- \mu_0) \sim f_{(1,n-1)}$

#### 21.0.2.1Natural Multivariate Generalization

$H_0: \mathbf{\mu} = \mathbf{\mu}_0 \\ H_a: \mathbf{\mu} \neq \mathbf{\mu}_0$

Define Hotelling’s $$T^2$$ by

$T^2 = n(\bar{\mathbf{y}} - \mathbf{\mu}_0)'\mathbf{S}^{-1}(\bar{\mathbf{y}} - \mathbf{\mu}_0)$

which can be viewed as a generalized distance between $$\bar{\mathbf{y}}$$ and $$\mathbf{\mu}_0$$

Under the assumption of normality,

$F = \frac{n-p}{(n-1)p} T^2 \sim f_{(p,n-p)}$

and reject the null hypothesis when $$F > f_{(1-\alpha, p, n-p)}$$

• The $$T^2$$ test is invariant to changes in measurement units.

• If $$\mathbf{z = Cy + d}$$ where $$\mathbf{C}$$ and $$\mathbf{d}$$ do not depend on $$\mathbf{y}$$, then $$T^2(\mathbf{z}) - T^2(\mathbf{y})$$
• The $$T^2$$ test can be derived as a likelihood ratio test of $$H_0: \mu = \mu_0$$

#### 21.0.2.2 Confidence Intervals

##### 21.0.2.2.1 Confidence Region

An “exact” $$100(1-\alpha)\%$$ confidence region for $$\mathbf{\mu}$$ is the set of all vectors, $$\mathbf{v}$$, which are “close enough” to the observed mean vector, $$\bar{\mathbf{y}}$$ to satisfy

$n(\bar{\mathbf{y}} - \mathbf{\mu}_0)'\mathbf{S}^{-1}(\bar{\mathbf{y}} - \mathbf{\mu}_0) \le \frac{(n-1)p}{n-p} f_{(1-\alpha, p, n-p)}$

• $$\mathbf{v}$$ are just the mean vectors that are not rejected by the $$T^2$$ test when $$\mathbf{\bar{y}}$$ is observed.

In case that you have 2 parameters, the confidence region is a “hyper-ellipsoid.”

In this region, it consists of all $$\mathbf{\mu}_0$$ vectors for which the $$T^2$$ test would not reject $$H_0$$ at significance level $$\alpha$$

Even though the confidence region better assesses the joint knowledge concerning plausible values of $$\mathbf{\mu}$$ , people typically include confidence statement about the individual component means. We’d like all of the separate confidence statements to hold simultaneously with a specified high probability. Simultaneous confidence intervals: intervals against any statement being incorrect

###### 21.0.2.2.1.1 Simultaneous Confidence Statements
• Intervals based on a rectangular confidence region by projecting the previous region onto the coordinate axes:

$\bar{y}_{i} \pm \sqrt{\frac{(n-1)p}{n-p}f_{(1-\alpha, p,n-p)}\frac{s_{ii}}{n}}$

for all $$i = 1,..,p$$

which implied confidence region is conservative; it has at least $$100(1- \alpha)\%$$

Generally, simultaneous $$100(1-\alpha) \%$$ confidence intervals for all linear combinations , $$\mathbf{a}$$ of the elements of the mean vector are given by

$\mathbf{a'\bar{y}} \pm \sqrt{\frac{(n-1)p}{n-p}f_{(1-\alpha, p,n-p)}\frac{\mathbf{a'Sa}}{n}}$

• works for any arbitrary linear combination $$\mathbf{a'\mu} = a_1 \mu_1 + ... + a_p \mu_p$$, which is a projection onto the axis in the direction of $$\mathbf{a}$$

• These intervals have the property that the probability that at least one such interval does not contain the appropriate $$\mathbf{a' \mu}$$ is no more than $$\alpha$$

• These types of intervals can be used for “data snooping” (like Scheffe)

###### 21.0.2.2.1.2 One $$\mu$$ at a time
• One at a time confidence intervals:

$\bar{y}_i \pm t_{(1 - \alpha/2, n-1} \sqrt{\frac{s_{ii}}{n}}$

• Each of these intervals has a probability of $$1-\alpha$$ of covering the appropriate $$\mu_i$$

• But they ignore the covariance structure of the $$p$$ variables

• If we only care about $$k$$ simultaneous intervals, we can use “one at a time” method with the Bonferroni correction.

• This method gets more conservative as the number of intervals $$k$$ increases.

### 21.0.3 General Hypothesis Testing

#### 21.0.3.1 One-sample Tests

$H_0: \mathbf{C \mu= 0}$

where

• $$\mathbf{C}$$ is a $$c \times p$$ matrix of rank c where $$c \le p$$

We can test this hypothesis using the following statistic

$F = \frac{n - c}{(n-1)c} T^2$

where $$T^2 = n(\mathbf{C\bar{y}})' (\mathbf{CSC'})^{-1} (\mathbf{C\bar{y}})$$

Example:

$H_0: \mu_1 = \mu_2 = ... = \mu_p$

Equivalently,

$\mu_1 - \mu_2 = 0 \\ \vdots \\ \mu_{p-1} - \mu_p = 0$

a total of $$p-1$$ tests. Hence, we have $$\mathbf{C}$$ as the $$p - 1 \times p$$ matrix

$\mathbf{C} = \left( \begin{array} {ccccc} 1 & -1 & 0 & \ldots & 0 \\ 0 & 1 & -1 & \ldots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \ldots & 1 & -1 \end{array} \right)$

number of rows = $$c = p -1$$

Equivalently, we can also compare all of the other means to the first mean. Then, we test $$\mu_1 - \mu_2 = 0, \mu_1 - \mu_3 = 0,..., \mu_1 - \mu_p = 0$$, the $$(p-1) \times p$$ matrix $$\mathbf{C}$$ is

$\mathbf{C} = \left( \begin{array} {ccccc} -1 & 1 & 0 & \ldots & 0 \\ -1 & 0 & 1 & \ldots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ -1 & 0 & \ldots & 0 & 1 \end{array} \right)$

The value of $$T^2$$ is invariant to these equivalent choices of $$\mathbf{C}$$

This is often used for repeated measures designs, where each subject receives each treatment once over successive periods of time (all treatments are administered to each unit).

Example:

Let $$y_{ij}$$ be the response from subject i at time j for $$i = 1,..,n, j = 1,...,T$$. In this case, $$\mathbf{y}_i = (y_{i1}, ..., y_{iT})', i = 1,...,n$$ are a random sample from $$N_T (\mathbf{\mu}, \mathbf{\Sigma})$$

Let $$n=8$$ subjects, $$T = 6$$. We are interested in $$\mu_1, .., \mu_6$$

$H_0: \mu_1 = \mu_2 = ... = \mu_6$

Equivalently,

$\mu_1 - \mu_2 = 0 \\ \mu_2 - \mu_3 = 0 \\ ... \\ \mu_5 - \mu_6 = 0$

We can test orthogonal polynomials for 4 equally spaced time points. To test for example the null hypothesis that quadratic and cubic effects are jointly equal to 0, we would define $$\mathbf{C}$$

$\mathbf{C} = \left( \begin{array} {cccc} 1 & -1 & -1 & 1 \\ -1 & 3 & -3 & 1 \end{array} \right)$

#### 21.0.3.2 Two-Sample Tests

Consider the analogous two sample multivariate tests.

Example: we have data on two independent random samples, one sample from each of two populations

$\mathbf{y}_{1i} \sim N_p (\mathbf{\mu_1, \Sigma}) \\ \mathbf{y}_{2j} \sim N_p (\mathbf{\mu_2, \Sigma})$

We assume

• normality

• equal variance-covariance matrices

• independent random samples

We can summarize our data using the sufficient statistics $$\mathbf{\bar{y}}_1, \mathbf{S}_1, \mathbf{\bar{y}}_2, \mathbf{S}_2$$ with respective sample sizes, $$n_1,n_2$$

Since we assume that $$\mathbf{\Sigma}_1 = \mathbf{\Sigma}_2 = \mathbf{\Sigma}$$, compute a pooled estimate of the variance-covariance matrix on $$n_1 + n_2 - 2$$ df

$\mathbf{S} = \frac{(n_1 - 1)\mathbf{S}_1 + (n_2-1) \mathbf{S}_2}{(n_1 -1) + (n_2 - 1)}$

$H_0: \mathbf{\mu}_1 = \mathbf{\mu}_2 \\ H_a: \mathbf{\mu}_1 \neq \mathbf{\mu}_2$

At least one element of the mean vectors is different

We use

• $$\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2$$ to estimate $$\mu_1 - \mu_2$$

• $$\mathbf{S}$$ to estimate $$\mathbf{\Sigma}$$

Note: because we assume the two populations are independent, there is no covariance

$$cov(\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2) = var(\mathbf{\bar{y}}_1) + var(\mathbf{\bar{y}}_2) = \frac{\mathbf{\Sigma_1}}{n_1} + \frac{\mathbf{\Sigma_2}}{n_2} = \mathbf{\Sigma}(\frac{1}{n_1} + \frac{1}{n_2})$$

Reject $$H_0$$ if

\begin{aligned} T^2 &= (\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2)'\{ \mathbf{S} (\frac{1}{n_1} + \frac{1}{n_2})\}^{-1} (\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2)\\ &= \frac{n_1 n_2}{n_1 +n_2} (\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2)'\{ \mathbf{S} \}^{-1} (\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2)\\ & \ge \frac{(n_1 + n_2 -2)p}{n_1 + n_2 - p - 1} f_{(1- \alpha,n_1 + n_2 - p -1)} \end{aligned}

or equivalently, if

$F = \frac{n_1 + n_2 - p -1}{(n_1 + n_2 -2)p} T^2 \ge f_{(1- \alpha, p , n_1 + n_2 -p -1)}$

A $$100(1-\alpha) \%$$ confidence region for $$\mu_1 - \mu_2$$ consists of all vector $$\delta$$ which satisfy

$\frac{n_1 n_2}{n_1 + n_2} (\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2 - \mathbf{\delta})' \mathbf{S}^{-1}(\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2 - \mathbf{\delta}) \le \frac{(n_1 + n_2 - 2)p}{n_1 + n_2 -p - 1}f_{(1-\alpha, p , n_1 + n_2 - p -1)}$

The simultaneous confidence intervals for all linear combinations of $$\mu_1 - \mu_2$$ have the form

$\mathbf{a'}(\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2) \pm \sqrt{\frac{(n_1 + n_2 -2)p}{n_1 + n_2 - p -1}}f_{(1-\alpha, p, n_1 + n_2 -p -1)} \times \sqrt{\mathbf{a'Sa}(\frac{1}{n_1} + \frac{1}{n_2})}$

Bonferroni intervals, for k combinations

$(\bar{y}_{1i} - \bar{y}_{2i}) \pm t_{(1-\alpha/2k, n_1 + n_2 - 2)}\sqrt{(\frac{1}{n_1} + \frac{1}{n_2})s_{ii}}$

#### 21.0.3.3 Model Assumptions

If model assumption are not met

• Unequal Covariance Matrices

• If $$n_1 = n_2$$ (large samples) there is little effect on the Type I error rate and power fo the two sample test

• If $$n_1 > n_2$$ and the eigenvalues of $$\mathbf{\Sigma}_1 \mathbf{\Sigma}^{-1}_2$$ are less than 1, the Type I error level is inflated

• If $$n_1 > n_2$$ and some eigenvalues of $$\mathbf{\Sigma}_1 \mathbf{\Sigma}_2^{-1}$$ are greater than 1, the Type I error rate is too small, leading to a reduction in power

• Sample Not Normal

• Type I error level of the two sample $$T^2$$ test isn’t much affect by moderate departures from normality if the two populations being sampled have similar distributions

• One sample $$T^2$$ test is much more sensitive to lack of normality, especially when the distribution is skewed.

• Intuitively, you can think that in one sample your distribution will be sensitive, but the distribution of the difference between two similar distributions will not be as sensitive.

• Solutions:

• Transform to make the data more normal

• Large large samples, use the $$\chi^2$$ (Wald) test, in which populations don’t need to be normal, or equal sample sizes, or equal variance-covariance matrices

• $$H_0: \mu_1 - \mu_2 =0$$ use $$(\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2)'( \frac{1}{n_1} \mathbf{S}_1 + \frac{1}{n_2}\mathbf{S}_2)^{-1}(\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2) \dot{\sim} \chi^2_{(p)}$$

##### 21.0.3.3.1 Equal Covariance Matrices Tests

With independent random samples from k populations of p-dimensional vectors. We compute the sample covariance matrix for each, $$\mathbf{S}_i$$, where $$i = 1,...,k$$

$H_0: \mathbf{\Sigma}_1 = \mathbf{\Sigma}_2 = \ldots = \mathbf{\Sigma}_k = \mathbf{\Sigma} \\ H_a: \text{at least 2 are different}$

Assume $$H_0$$ is true, we would use a pooled estimate of the common covariance matrix, $$\mathbf{\Sigma}$$

$\mathbf{S} = \frac{\sum_{i=1}^k (n_i -1)\mathbf{S}_i}{\sum_{i=1}^k (n_i - 1)}$

with $$\sum_{i=1}^k (n_i -1)$$

###### 21.0.3.3.1.1 Bartlett’s Test

(a modification of the likelihood ratio test). Define

$N = \sum_{i=1}^k n_i$

and (note: $$| |$$ are determinants here, not absolute value)

$M = (N - k) \log|\mathbf{S}| - \sum_{i=1}^k (n_i - 1) \log|\mathbf{S}_i|$

$C^{-1} = 1 - \frac{2p^2 + 3p - 1}{6(p+1)(k-1)} \{\sum_{i=1}^k (\frac{1}{n_i - 1}) - \frac{1}{N-k} \}$

• Reject $$H_0$$ when $$MC^{-1} > \chi^2_{1- \alpha, (k-1)p(p+1)/2}$$

• If not all samples are from normal populations, $$MC^{-1}$$ has a distribution which is often shifted to the right of the nominal $$\chi^2$$ distribution, which means $$H_0$$ is often rejected even when it is true (the Type I error level is inflated). Hence, it is better to test individual normality first, or then multivariate normality before you do Bartlett’s test.

#### 21.0.3.4 Two-Sample Repeated Measurements

• Define $$\mathbf{y}_{hi} = (y_{hi1}, ..., y_{hit})'$$ to be the observations from the i-th subject in the h-th group for times 1 through T

• Assume that $$\mathbf{y}_{11}, ..., \mathbf{y}_{1n_1}$$ are iid $$N_t(\mathbf{\mu}_1, \mathbf{\Sigma})$$ and that $$\mathbf{y}_{21},...,\mathbf{y}_{2n_2}$$ are iid $$N_t(\mathbf{\mu}_2, \mathbf{\Sigma})$$

• $$H_0: \mathbf{C}(\mathbf{\mu}_1 - \mathbf{\mu}_2) = \mathbf{0}_c$$ where $$\mathbf{C}$$ is a $$c \times t$$ matrix of rank $$c$$ where $$c \le t$$

• The test statistic has the form

$T^2 = \frac{n_1 n_2}{n_1 + n_2} (\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2)' \mathbf{C}'(\mathbf{CSC}')^{-1}\mathbf{C} (\mathbf{\bar{y}}_1 - \mathbf{\bar{y}}_2)$

where $$\mathbf{S}$$ is the pooled covariance estimate. Then,

$F = \frac{n_1 + n_2 - c -1}{(n_1 + n_2-2)c} T^2 \sim f_{(c, n_1 + n_2 - c-1)}$

when $$H_0$$ is true

If the null hypothesis $$H_0: \mu_1 = \mu_2$$ is rejected. A weaker hypothesis is that the profiles for the two groups are parallel.

$\mu_{11} - \mu_{21} = \mu_{12} - \mu_{22} \\ \vdots \\ \mu_{1t-1} - \mu_{2t-1} = \mu_{1t} - \mu_{2t}$

The null hypothesis matrix term is then

$$H_0: \mathbf{C}(\mu_1 - \mu_2) = \mathbf{0}_c$$ , where $$c = t - 1$$ and

$\mathbf{C} = \left( \begin{array} {ccccc} 1 & -1 & 0 & \ldots & 0 \\ 0 & 1 & -1 & \ldots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \ldots & -1 \end{array} \right)_{(t-1) \times t}$

# One-sample Hotelling's T^2 test
#  Create data frame
plants <- data.frame(
y1 = c(2.11, 2.36, 2.13, 2.78, 2.17),
y2 = c(10.1, 35.0, 2.0, 6.0, 2.0),
y3 = c(3.4, 4.1, 1.9, 3.8, 1.7)
)

# Center the data with the hypothesized means and make a matrix
plants_ctr <- plants %>%
transmute(y1_ctr = y1 - 2.85,
y2_ctr = y2 - 15.0,
y3_ctr = y3 - 6.0) %>%
as.matrix()

# Use anova.mlm to calculate Wilks' lambda
onesamp_fit <- anova(lm(plants_ctr ~ 1), test = "Wilks")
onesamp_fit # can't reject the null of hypothesized vector of means
## Analysis of Variance Table
##
##             Df    Wilks approx F num Df den Df  Pr(>F)
## (Intercept)  1 0.054219   11.629      3      2 0.08022 .
## Residuals    4
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Paired-Sample Hotelling's T^2 test
library(ICSNP)

#  Create data frame
waste <- data.frame(
case = 1:11,
com_y1 = c(6, 6, 18, 8, 11, 34, 28, 71, 43, 33, 20),
com_y2 = c(27, 23, 64, 44, 30, 75, 26, 124, 54, 30, 14),
state_y1 = c(25, 28, 36, 35, 15, 44, 42, 54, 34, 29, 39),
state_y2 = c(15, 13, 22, 29, 31, 64, 30, 64, 56, 20, 21)
)

# Calculate the difference between commercial and state labs
waste_diff <- waste %>%
transmute(y1_diff = com_y1 - state_y1,
y2_diff = com_y2 - state_y2)
# Run the test
paired_fit <- HotellingsT2(waste_diff)
paired_fit # value T.2 in the output corresponds to the approximate F-value in the output from anova.mlm
##
##  Hotelling's one sample T2-test
##
## data:  waste_diff
## T.2 = 6.1377, df1 = 2, df2 = 9, p-value = 0.02083
## alternative hypothesis: true location is not equal to c(0,0)
# reject the null that the two labs' measurements are equal
# Independent-Sample Hotelling's T^2 test with Bartlett's test

names(steel) <- c("Temp", "Yield", "Strength")
str(steel)
## 'data.frame':    12 obs. of  3 variables:
##  $Temp : int 1 1 1 1 1 2 2 2 2 2 ... ##$ Yield   : int  33 36 35 38 40 35 36 38 39 41 ...
##  $Strength: int 60 61 64 63 65 57 59 59 61 63 ... # Plot the data ggplot(steel, aes(x = Yield, y = Strength)) + geom_text(aes(label = Temp), size = 5) + geom_segment(aes( x = 33, y = 57.5, xend = 42, yend = 65 ), col = "red") # Bartlett's test for equality of covariance matrices # same thing as Box's M test in the multivariate setting bart_test <- boxM(steel[, -1], steel$Temp)
bart_test # fail to reject the null of equal covariances
##
##  Box's M-test for Homogeneity of Covariance Matrices
##
## data:  steel[, -1]
## Chi-Sq (approx.) = 0.38077, df = 3, p-value = 0.9442
# anova.mlm
twosamp_fit <-
anova(lm(cbind(Yield, Strength) ~ factor(Temp), data = steel), test = "Wilks")
twosamp_fit
## Analysis of Variance Table
##
##              Df    Wilks approx F num Df den Df    Pr(>F)
## (Intercept)   1 0.001177   3818.1      2      9 6.589e-14 ***
## factor(Temp)  1 0.294883     10.8      2      9  0.004106 **
## Residuals    10
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# ICSNP package
twosamp_fit2 <-
HotellingsT2(cbind(steel$Yield, steel$Strength) ~ factor(steel$Temp)) twosamp_fit2 ## ## Hotelling's two sample T2-test ## ## data: cbind(steel$Yield, steel$Strength) by factor(steel$Temp)
## T.2 = 10.76, df1 = 2, df2 = 9, p-value = 0.004106
## alternative hypothesis: true location difference is not equal to c(0,0)
# reject null. Hence, there is a difference in the means of the bivariate normal distributions