we read that if $(\Omega, \mathcal{F}, \mathcal{P})$ is a probability space and $X:\Omega\to\mathbb{R}$ is a random variable with mean and variance, then $$\min\limits_{c\in\mathbb{R}}\mathbb{E}((X - c)^{2}) = \mathbb{E}((X-\mathbb{E}(X))^2).$$ I.e., the expected value $c=\mathbb{E}(X)$ minimizes $\mathbb{E}((X - c)^{2}).$ My question is how to prove it?
According to the Page 87 in Kruschke: Doing Bayesian Data Analysis, the author says that the mean of a distribution is a value that minimizes the variance of a probability distribution, for example, a normal distribution. The following is what is mentioned in the page:  It turns out that the value of $ M $ that minimizes $ ∫dx p(x)(x−M)^2$ is $E[X] $. In other words, the mean of the distribution is the value that minimizes the expected squared deviation. In this way, the mean is a central tendency of the distribution.  I have read the paragraph and kind of understood what the author is trying to say but I wonder how this can be written mathematically using the above equation or any other ways.
Help with creating a symbolic link I'm confused with how symbolic links work. I hope someone can guide me in the right direction.  I want to put a demo online from our software, which normally only runs locally on a Mac Mini. So I put all the files in the var/www from my Ubuntu 12.04 server installation.  There are a lot of hardcoded links in the software which point to /Applications/XAMPP/xamppfiles/htdocs/narrowcasting  Of course, I could change all these code on my html/php files in /var/www, but that would be quite annoying. I hope I can fix this by creating a symbolic link. For example, I have a directory called thumb in /var/www/thumb. The PHP code is trying to put an image in /Applications/XAMPP/xamppfiles/htdocs/narrowcasting/thumb.   Can anyone give me a tip how to achieve this with a symbolic link? Consider this example (typical in OOP books):    I have an Animal class, where each Animal can have many friends. And subclasses like Dog, Duck, Mouse etc which add specific behavior like bark(), quack() etc.  Here's the Animal class:  public class Animal {     private Map&lt;String,Animal&gt; friends = new HashMap&lt;&gt;();      public void addFriend(String name, Animal animal){         friends.put(name,animal);     }      public Animal callFriend(String name){         return friends.get(name);     } }   And here's some code snippet with lots of typecasting:  Mouse jerry = new Mouse(); jerry.addFriend("spike", new Dog()); jerry.addFriend("quacker", new Duck());  ((Dog) jerry.callFriend("spike")).bark(); ((Duck) jerry.callFriend("quacker")).quack();   Is there any way I can use generics for the return type to get rid of the typecasting, so that I can say      jerry.callFriend("spike").bark(); jerry.callFriend("quacker").quack();   Here's some initial code with return type conveyed to the method as a parameter that's never used.   public&lt;T extends Animal&gt; T callFriend(String name, T unusedTypeObj){     return (T)friends.get(name);         }   Is there a way to figure out the return type at runtime without the extra parameter using instanceof? Or at least by passing a class of the type instead of a dummy instance. I understand generics are for compile time type-checking, but is there a workaround for this? Buying from AliExpress I've notice that the business to business site AliBaba and it's more consumer friendly AliExpress website have a number of bike components for sale. They tend to be complete component groupsets and the like but are some quite reasonable deals, especially if you are building a bike from scratch.  I've used AliExpress before to purchase electronic components, which have been good quality and are what they say on the tin.   Has anyone used AliExpress to buy bike components and have they had any trouble? (quality, counterfeit etc.)  One benefit is that your money is held in escrow until you receive the item and aprove the payment so some safety. linux command to prevent dos attack by using netstat and iptables I want to DROP more than 200 requests per ip to prevent ddos attack. this is command that i used to detect requests count per ip :  netstat -alpn | grep :80 | awk '{print $5}' |awk -F: '{print $(NF-1)}' |sort | uniq -c | sort -nr   now i want add all ip addresses that made more than 200 requests into IPtables to DROP input and out put. How do you sort du -sh /dir/* by size? I read one site that said use | sort -n but that's obviously not right. Here's an example that is wrong.  [~]# du -sh /var/* | sort -n 0       /var/mail 1.2M    /var/www 1.8M    /var/tmp 1.9G    /var/named 2.9M    /var/run 4.1G    /var/log 8.0K    /var/account 8.0K    /var/crash 8.0K    /var/cvs 8.0K    /var/games 8.0K    /var/local 8.0K    /var/nis 8.0K    /var/opt 8.0K    /var/preserve 8.0K    /var/racoon 12K     /var/aquota.user 12K     /var/portsentry 16K     /var/ftp 16K     /var/quota.user 20K     /var/yp 24K     /var/db 28K     /var/empty 32K     /var/lock 84K     /var/profiles 224M    /var/netenberg 235M    /var/cpanel 245M    /var/cache 620M    /var/lib 748K    /var/spool cron Vs. sleep - which is the better one in terms of efficient cpu/memory utilization? Ubuntu 14.04 System Logging Last month, I was travelling on a backpacking trip across Russia and the Baltic states (Schengen zone). I'm an Indian by nationality. So I had to get the respective single entry visa for Russia and Schengen Europe.  At the border crossing into Estonia by road (at Ivangorod-Narva), I exited the Russian border with an exit stamp (so now I can't go back to Russia since I had a single entry visa). When I was at the immigration checkpoint of Estonia, I was heavily questioned on the intent of my travel to Europe while entering Estonia by road.   Though I finally got into Europe, It got me wondering - what happens if a foreign national is denied entry into a country not at the airport but by land between 2 countries he cannot go into ?  Generally, if you are denied entry at the airport the airline has the obligation to fly you back to your country. But what happens when you are stuck between two countries and you cant get into either ? What happens to you then ? Accessing inherited variable from templated parent class Consider the following code:  template&lt;class T&gt; class Foo { public:   Foo() { a = 1; }  protected:   int a; };  template&lt;class T&gt; class Bar : public Foo&lt;T&gt; { public:   Bar() { b = 4; };    int Perna(int u);  protected:   int b;  };  template&lt;class T&gt; int Bar&lt;T&gt;::Perna(int u)  {    int c = Foo&lt;T&gt;::a * 4; // This works   return (a + b) * u;    // This doesn't }   g++ 3.4.6, 4.3.2 and 4.1.2 give error   test.cpp: In member function `int Bar&lt;T&gt;::Perna(int)': test.cpp:25: error: `a' was not declared in this scope   g++ 2.96 and MSVC 6, 7, 7.1, 8 and 9 accept it, as do (at least) older Intel and SGI c++ compilers.   Do the new Gnu C++ compiler obey the standard or not? If they do, what is the rationale behind that inheriting class is not able to see a protected inherited member variable?  Also, if there's  int A() { return a; }    in Foo, I get error  test.cpp:25: error: there are no arguments to A that depend on a template parameter, so a declaration of A must be available test.cpp:25: error: (if you use -fpermissiveâ, G++ will accept your code, but allowing the use of an undeclared name is deprecated)   when I try to use it in a member function of Bar. I find that curious as well: Bar inherits Foo, so I think it's obvious that A() in scope of Bar is Foo::A(). Let $x\in\mathbb{Q}$ with $x&gt;0$.  Prove that we can find $n\in\mathbb{N}^*$ and distinct $a_1,...,a_n \in \mathbb{N}^*$ such that $$x=\sum_{k=1}^n{\frac{1}{a_k}}$$ Get current editor toolbar tab via Python? Optimal step size in gradient descent Statistics interview questions Left inverse implies right inverse in a finite ring Let $R$ be a finite ring with identity $1$, and assume $\exists x,y\in R$ such that $ xy=1$. How can I show it implies $yx=1$? Restricting T to string and int? I have built myself a generic collection class which is defined like this.   public class StatisticItemHits&lt;T&gt;{...}   This class can be used with int and string values only. However this  public class StatisticItemHits&lt;T&gt; where T : string, int {...}   won't compile. What am I doing wrong? Is spacetime flat inside a spherical shell? In a perfectly symmetrical spherical hollow shell, there is a null net gravitational force according to Newton, since in his theory the force is exactly inversely proportional to the square of the distance.  What is the result of general theory of relativity? Is the spacetime flat inside (given the fact that orbit of Mercury rotates I don't think so)? How is signal from the cavity redshifted to an observer at infinity? An investigator wishes to produce a combined analysis of several datasets.  In some datasets there are paired observations for treatment A and B.  In others there are unpaired A and/or B data.  I am looking for a reference for an adaptation of the t-test, or for a likelihood ratio test, for such partially paired data.  I am willing to (for now) to assume normality with equal variance and that the population means for A are the same for each study (and likewise for B). How do you reopen a closed question? How to pack the game files into one without using any file compressor? Well, one example is this file of the game The Sims 2 for PS2: quickdat.arc. The file contains this .arc extension, but it's no one an archive file and it contains some data of the game inside. How can I do this? Put so many files in one?  How to do something like this? All the game files inside one without using a file compressor? My internal storage capacity is running low,  what can I do? Currently, my internal storage is running low on space.    What can I do besides moving applications to the external memory, as to free up more space, but preserve my current applications and avoid uninstalling?  (Some of them won't be moved)