Cleaning up YouTube downloads
Converting a system command to python for file search and delete
Proof that the coefficients in an OLS model follow a t-distribution with (n-k) degrees of freedom Background  Suppose we have an Ordinary Least Squares model where we have $k$ coefficients in our regression model, $$\mathbf{y}=\mathbf{X}\mathbf{\beta} + \mathbf{\epsilon}$$  where $\mathbf{\beta}$ is an $(k\times1)$ vector of coefficients, $\mathbf{X}$ is the design matrix defined by  $$\mathbf{X} = \begin{pmatrix} 1 &amp; x_{11} &amp; x_{12} &amp; \dots &amp; x_{1\;(k-1)} \\ 1 &amp; x_{21} &amp; \dots  &amp;       &amp;   \vdots \\ \vdots &amp;   &amp; \ddots &amp;       &amp;   \vdots \\ 1 &amp; x_{n1} &amp; \dots  &amp; \dots &amp;   x_{n\;(k-1)}     \end{pmatrix}$$ and the errors are IID normal,  $$\mathbf{\epsilon} \sim \mathcal{N}\left(\mathbf{0},\sigma^2 \mathbf{I}\right) \;.$$  We minimize the sum-of-squared-errors by setting our estimates for $\mathbf{\beta}$ to be $$\mathbf{\hat{\beta}}= (\mathbf{X^T X})^{-1}\mathbf{X}^T \mathbf{y}\;. $$   An unbiased estimator of $\sigma^2$ is  $$s^2 = \frac{\left\Vert \mathbf{y}-\mathbf{\hat{y}}\right\Vert ^2}{n-p}$$ where $\mathbf{\hat{y}} \equiv \mathbf{X} \mathbf{\hat{\beta}}$ ().   The covariance of $\mathbf{\hat{\beta}}$ is given by $$\operatorname{Cov}\left(\mathbf{\hat{\beta}}\right) = \sigma^2 \mathbf{C}$$ where $\mathbf{C}\equiv(\mathbf{X}^T\mathbf{X})^{-1}$ () .  Question  How can I prove that for $\hat\beta_i$, $$\frac{\hat{\beta}_i - \beta_i} {s_{\hat{\beta}_i}} \sim t_{n-k}$$ where $t_{n-k}$ is a t-distribution with $(n-k)$ degrees of freedom, and the standard error of $\hat{\beta}_i$ is estimated by $s_{\hat{\beta}_i} = s\sqrt{c_{ii}}$.    My attempts  I know that for $n$ random variables sampled from $x\sim\mathcal{N}\left(\mu, \sigma^2\right)$, you can show that  $$\frac{\bar{x}-\mu}{s/\sqrt{n}} \sim t_{n-1} $$ by rewriting the LHS as $$\frac{ \left(\frac{\bar x - \mu}{\sigma/\sqrt{n}}\right)  }   {\sqrt{s^2/\sigma^2}}$$ and realizing that the numertor is a standard normal distribution, and the denominator is square root of a Chi-square distribution with df=(n-1) and divided by (n-1) ().  And therefore it follows a t-distribution with df=(n-1) ().  I was unable to extend this proof to my question...  Any ideas?  I'm aware of , but they don't explicitly prove it, they just give a rule of thumb, saying "each predictor costs you a degree of freedom". Testing random number generation I have a program which generates random numbers. How can I test if the random number generator is generating actual random numbers? How to use sed to replace only the first occurrence in a file? I would like to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task, I normally use a small bash script with sed to re-write the file.   How do I get sed to replace just the first occurrence of a string in a file rather than replacing every occurrence?  If I use  sed s/#include/#include "newfile.h"\n#include/   it replaces all #includes.   Alternative suggestions to achieve the same thing are also welcome. With the new permission model for Marketing Cloud Installed Packages, there is a problem with the "Read"-Scope for Data Extensions.  If an installed package is granted the permission/scope "Data Extensions - Read" the API-Call fails with HTTP 403 "Forbidden".  How to provide read access to Data Extensions?  Related documentation: Adding Basemaps from Google or Bing in QGIS Clipping a figure to content Grammatical complements for "allow" Are any of these verb phrases grammatical?        allows the user of modeling and resolving     allows the user to model and resolve      Which version of the following sentence is correct/better?        In particular, it allows to acquire a signal using a sample rate significantly lower than the one dictated by the Nyquist criterion.   In particular, it allows acquiring a signal using a sample rate   significantly lower than the one dictated by the Nyquist criterion.      I searched Google Scholar for "" and "", and it seems people use both more or less with the same frequency. Give an example about limits: $\lim\limits_{x\to0}f(x^{2})$ exists but $\lim\limits_{x\to0}f(x)$ does not. #!/bin/bash - no such file or directory Best way to specify whitespace in a String.Split operation Why the name 'Rogue One'? So far, is there any suggestion, or speculation as to the reason for the name 'Rogue One' for the next Star Wars film?   To me, the name seems very close to the Rogue Squadron, most known from Hoth (their leader Luke Skywalker), especially the number following Rogue like a callsign.   However as far as I know, they were formed after the first Death Star destruction. So why Rogue One? Greyed-Out vs Invisible Statistics and causal inference? What does one second after big bang mean? Consider the following statement:     Hadron Epoch, from $10^{-6}$ seconds to $1$ second: The temperature of the   universe cools to about a trillion degrees, cool enough to allow   quarks to combine to form hadrons (like protons and neutrons).   What does it mean to say "from $10^{-6}$ seconds to $1$ second"?   How is time being measured?  One particle might feel just $10^{-20}\ \mathrm s$ having passed and another could feel $10^{-10}\ \mathrm s$ having passed.   Is saying "1 second after the big bang" a meaningful statement? First appearance of a predominately black cast in a TV show I was watching MeTV the other day, which is a fantastic station chock-full of old-time TV shows.  In one sitting I saw episodes of Superman, Batman, Wonder Woman, The Rifleman and Star Trek (TOS).  So it got me thinking...  None of these shows has many (if any) black actors.  And now I'm curious as to which TV show was the first to feature a predominantly black cast.  Anyone know?  I'm thinking back to What's Happening, Good Times, The Jeffersons...  But were there any before then? I don't know which buttons I have to click or what key combination to type to calculate a cube root. How can an uneducated but rational person differentiate between science and religion? I recently found myself unable to respond to the statement "But the big bang theory is just another creation myth!" during a science vs. religion argument. I found it very difficult to explain the difference between the big bang theory and creation myths without going through a crash course in Newtonian and then Relativistic mechanics.   This had me thinking of the following scenario: Consider a person who for various reasons never got a formal education beyond basic reading and writing. He/She doesn't know any science or math, and was never exposed to any scientific reasoning and experiments. She/He is however an open minded, level headed, and rational person (I've met more than one such person myself).   How would such a person differentiate science from religion? As far as he/she is concerned science has the exact same structure as religion:    A hard to understand scripture: Science treatises and journal papers.  An ordained clergy with a high entry barrier: Doctors, professors, scientists, etc... Seemingly arbitrary injunctions against certain behaviors: "Don't smoke", "Don't pollute",.... Various metaphysical (from his/her perspective) claims about the world around us: The big bang, other galaxies, blackholes, quarks,... Organizations which control and oversee doctrine: The FDA, The NIH, The NFS,...   From his/her perspective, all of these characteristics are no different than the way organized religion presents itself as being the source of truths about the world.   In particular if such a person were to heed the advice of the :         Do not go upon what has been acquired by repeated hearing (anussava),   nor upon tradition (paramparā),   nor upon rumor (itikirā),   nor upon what is in a scripture (piṭaka-sampadāna)   nor upon surmise (takka-hetu),   nor upon an axiom (naya-hetu),   nor upon specious reasoning (ākāra-parivitakka),   nor upon a bias towards a notion that has been pondered over (diṭṭhi-nijjhān-akkh-antiyā),   nor upon another's seeming ability (bhabba-rūpatāya),   nor upon the consideration, The monk is our teacher (samaṇo no garū) Kalamas, when you yourselves know: "These things are good; these   things are not blamable; these things are praised by the wise;   undertaken and observed, these things lead to benefit and happiness,"   enter on and abide in them.'      Following the Buddha's advice (ironically himself a religious figure), such a rational but uneducated person would have just as much reason to doubt the various results of scientists as to doubt the dogmas of organized religion.    How would it be possible for such a person to distinguish scientific facts from religious dogma?  How can we convince such a person of the validity of ideas like those of modern cosmology or evolutionary biology, without first having to teach them enough biology and physics to understand those concepts? Using the code below I add text to end of file names which are:  1.mp3 2.mp3   and should be:  1text.mp3 2text.mp3   but it changed to:  1.mp3text 2.mp3text   Code:  @ECHO ON  FOR %%A IN ("C:\Users\user123\Desktop\mp3\*.mp2") DO (     CALL :RenameFiles "%%~A" "%%~NXA" ) GOTO EOF  :RenameFiles  SET fname=%~2 SET renname=%fname=% REN "%~1" "%renname%text%" GOTO E How do I syntax check a Bash script without running it? Is it possible to check a bash script syntax without executing it?  Using Perl, I can run perl -c 'script name'. Is there any equivalent command for bash scripts? Redirect parent window from an iframe action