A confusion about the fact that contractible spaces are simply connected

Question: Question 1: Greenberg's Algebraic topology has a proof that contractible spaces are simply connected. In the middle of the proof, the book makes use of the following fact without justifying it (probably because the author thinks its useful):

Fact 1: Let $p:\mathbb{I}\rightarrow X$ be a continuous function such that
  $p(0)=p(1)=x_0$ for some $x_0\in X$ . Let $c:\mathbb{I}\rightarrow X$ send every element of the interval to $x_0$. If $p,c$ are homotopic, then there exists a continuous
  function $F:\mathbb{I}\times \mathbb{I}\rightarrow X$ such that:
1) $F(s,0)=c(s)$ for all $s\in \mathbb{I}$
2) $F(s,1)=p(s)$ for all $s\in \mathbb{I}$
3) $F(0,t)=F(1,t)$ for all $t\in \mathbb{I}$

Since the book is assuming this fact as obvious, I suppose it should be much easier to prove than to prove that contractible spaces are simply connected. I asked this here before and I got comments implying that fact 1 is almost as hard as proving the fact that "contractible spaces are simply connected". Well if this were true, is the proof of Greenberg's algebraic topology bad because it is assuming that fact 1 is obvious when proving that contractible spaces are simply connected while fact 1 is as hard as proving the original claim "contractible spaces are simply connected" ????
Important remark: I noticed that when I asked this question before, people were trying to prove the fact that "contractible spaces are simply connected" instead of answering the question. I know that it is tempting to answer this question without reading it carefully and just proving the fact that "contractible spaces are simply connected", please try to avoid this temptation :)
Question 2: Let's assume that fact 1 is true, since it's mentioned in the book.  The following fact is also mentioned in the book. I will state it without proof:

Fact 2: Let $F:\mathbb{I}\times\mathbb{I}\rightarrow X$ be continuous such that $F(0,0)=F(0,1)=F(1,0)=F(1,1)$. Let $\gamma,\delta,\alpha,\beta :\mathbb{I}\rightarrow X$
  be given by $\gamma
(s)=F(s,0),\delta(s)=F(s,1),\alpha(t)=F(0,t),\beta(t)=F(1,t)$, then
  $\delta $ is homotopic to $\alpha^{-1} \gamma \beta$ $rel\{0,1\}$

Claim: Let $p:\mathbb{I}\rightarrow X$ be continuous such that $p(0)=p(1)=x_0$ for some $x_0\in X$. Let $c:\mathbb{I}\rightarrow X$ send every element of the interval to $x_0$. If $p,c$ are homotopic, then $p,c$ are homotopic rel$\{0,1\}$
Proof: Since $p,c$ are homotopic, therefore fact 1 can be used to show that there exists a homotopy $F$ between $p,c$ such that $F(0,t)=F(1,t), F(s,0)=c(s),F(s,1)=p(s)$ for all $t\in\mathbb{I}$. Set $\alpha(t)=F(0,t),\beta(t)=F(1,t)$. From fact 1, we know that $\alpha=\beta$. From Fact 2, we know that $p$ is homotopic to $\alpha^{-1} c \alpha$ rel $\{0,1\}$. Since $\alpha^{-1}c\alpha$ is homotopic  to $\alpha^{-1}\alpha$ rel $\{0,1\}$ (because $c$ is constant map) , the last is homotopic to $c$ rel $\{0,1\}$. Therefore $p,c$ are homotopic rel $\{0,1\}$.
What is wrong with my argument in proving the above claim ?

I will explain here why I think my claim is not correct:
Consider the space $S$ formed as the identification space that results from gluing the the subspace $\mathbb{I}\times\{0\}\cup\{(0,1),(1,1)\}$  of $\mathbb{I}^2$ to one point. Let $F:\mathbb{I^2}\rightarrow S$ be the identification map. The space $S$ looks like the space resulting from gluing the three vertices of a triangular sheet of paper together (I already tried it using paper). Now note that $F:\mathbb{I}\times \mathbb{I}\rightarrow X$ is a homotopy between the paths $F|\mathbb{I}\times \{0\}$ and $ F|\mathbb{I}\times \{1\}$. I fail to see that the paths: $F|\mathbb{I}\times \{0\},F|\mathbb{I}\times\{1\}$ are homotopic rel $\{0,1\}$ visually on the space $S$ that I created using paper. Thus, this is a potential counterexample to the claim .
If you have time, could you please construct the space $S$ from paper just like I did to understand me better ?

Question 3: I want to see a proof that contractible spaces are simply connected using the knowledge/definitions I have so far. I only know the definition of homotopic, homotopic rel $\{0,1\}$. Simply connected means having a trivial fundamental group. Contractible means that the identity map $1_X:X\rightarrow X$ is homotopic to some constant map $c:X\rightarrow X$
Finally thank you for wasting your time in answering my (probably) trivial questions
Comment: I have had to delete my first answer, pretty picture or no, since it purports to prove false theorems.  My current answer explains why.
Comment: Isn't Fact 1 the same as your claim?
Comment: @leo: Actually, the claim is even more specific, if I understand what "rel $\{0,1\}$" is supposed to mean.  Fact 1 furnishes a homotopy through loops; the claim furnishes a homotopy through loops with a fixed basepoint.
Answer: After some thought, I believe that neither Fact 1 nor the Claim are actually true as stated.  Fact 2 is true, but does not imply Fact 1.  The argument against Fact 1 is simple: let $X = S^1 = \{z \in \mathbb{C} \mid \lvert z \rvert = 1\}$ be the circle, let $p \colon [0,1] \to S^1$ be $p(t) = e^{2\pi i t}$, and let $c \colon [0,1] \to \{x_0\} = (1,0)$.  Then $p$ is very much homotopic to $c$, say via
$$H(s,t) = e^{2\pi i st};$$
we have $H(s,0) = c(s)$ and $H(s,1) = p(s)$.  But $p$ is not homotopic to $c$ through loops, as Fact 1 claims.  This is tricky to prove (how do you show that some homotopy doesn't exist?) and one would normally prove it with covering spaces, which show immediately that anything homotopic to $p$ has winding number $1$, while $c$ clearly has winding number $0$.  I will simply leave it at that, since I don't think you can really do this with your current level of technology.
Note that any path is homotopic to any point along it, by a similar trick: just pick any $t_0 \in [0,1]$ and, since the interval is contractible, choose a continuous contraction $f(s,t)$ from the identity to $t_0$; for example,
$$f(s,t) = t_0 + s(t - t_0)$$
(at $s = 0$ you get $t_0$, at $s = 1$ you get $t$, and since $0 \leq s \leq 1$, we have $f(s,t) \in [0,1]$; in fact, $f(s,t)$ is between $t$ and $t_0$ for all $s$).  Then given a path $p \colon [0,1] \to X$, the map $F(s,t) = p(f(s,t))$ is a homotopy from $p$ to $p(t_0)$.  As the other answer says, homotopy of paths without fixing endpoints is pretty meaningless.
Anyway, the Claim is an even more specific fact, that $p$ and $c$ must be homotopic through loops based at $x_0$.  This is impossible for the same reason.
I am actually a bit puzzled where you got Fact 1 from.  I have a copy of the book Algebraic Topology by Greenberg and Harper, presumably a revision, and the proof in question is covered entirely, and without unproven claims, by just Fact 2 (their Lemma 3.3). I believe you may have misinterpreted the key step in the following expanded version of the argument there, which does produce a homotopy with the properties given in Fact 1, but from stronger hypotheses.
Theorem: If $X$ is contractible, then it is simply connected.
Proof: Let $p \colon [0,1] \to X$ be any loop with $p(0) = p(1) = x_0$.  Because of this, we can define a new continuous function
$$q \colon S^1 \to X$$
where we consider $S^1 = [0,1]/(0 = 1)$.  More explicitly, let $f \colon [0,1] \to S^1$ be the continuous map identifying $0$ with $1$, so we have $p = q \circ f$.
Suppose $X$ is contractible; then there is a homotopy
$$H(x,t) \colon X \times [0,1] \to X$$
with $H(x,0) = x$ and $H(x,1) = x_0$ from the identity function to the constant function $x_0$.  From this, we define a map
$$H' \colon S^1 \times [0,1] \to X$$
by $H'(s,t) = H(q(s),t)$.  This is a homotopy from $q$ to $x_0$, since
$$\begin{align}
 H'(s,0) = H(q(s),0) = q(s) &&
 H'(s,1) = H(q(s),1) = x_0
\end{align}$$
It is continuous, being a composition of continuous functions.  Define a further homotopy
$$F(s,t) \colon [0,1]^2 \to X$$
by $F(s,t) = H'(f(s),t)$.  It is continuous and a homotopy from $p$ to $x_0$, since
$$\begin{align}
 F(s,0) = H'(f(s),0) = q(f(s)) = p(s) &&
 F(s,1) = H'(f(s),1) = x_0.
\end{align}$$
$F$ has the property that
$$\begin{align}
 F(0,t) &= H'(f(0),t) = H(q(f(0)),t) = H(p(0),t) = H(x_0,t) \\
 &= H(p(1),t) = H(q(f(1)),t) = H'(f(1),t) = F(1,t).
\end{align}$$
That is, $F$ satisfies the criteria of Fact 1.  (Note that we had to use the global homotopy $H$ to get $F$, not merely a homotopy from $p$ to $x_0$.)  Defining $\alpha = \beta$ to be this common vertical-edge path, which is actually a loop at $x_0$ since $F(0,0) = F(0,1) = F(1,0) = F(1,1) = x_0$, we get from Fact 2 that $\alpha^{-1} p \alpha$ is homotopic to $x_0$ as loops based at $x_0$.  That is, we have
$$[\alpha]^{-1} [p] [\alpha] = [x_0] = 1$$
as homotopy classes in $\pi_1(X, x_0)$.  Moving $[\alpha]$ to the other side, we get $[p] = [\alpha][\alpha]^{-1} = 1$, so $[p]$ is the trivial element of the fundamental group.  Since $p$ is arbitrary, $X$ is simply connected. $\square$
Based on the manipulations in this proof, the best approximation to Fact 1 that I can come up with is:
Proposition: Let $X$ be a topological space and $f, g \colon X \to X$ two homotopic continuous maps.  Then for any loop $p \colon [0,1] \to X$ based at $x_0 = p(0) = p(1)$, there is a homotopy $F \colon [0,1]^2 \to X$ from $f\circ p$ to $g\circ p$, both loops at $x_0$, such that for each $t \in [0,1]$, the path $s \mapsto F(s,t)$ is a loop based at $x_0$; i.e. $F(0,t) = F(1,t)$ for all $t$.
Proof: In short, make $p$ into a map $q$ from the circle and compose the assumed homotopy from $f$ to $g$ with $q$ in the first variable.  Then, unwrapping the circle, you find that the resulting homotopy from $f \circ p$ to $g \circ p$ has the property claimed.  The details are above. $\square$
Comment: This answer is saying is that once you have a homotopy $F$ between a path $p$ with $p(0)=p(1)$ and a constant path  that sends all elements of the interval to $p(0)$, you can turn it into a homotopy $G$ that satisfies the conditions of fact 1. Note that the proof of this answer does not use  contractibility.
Comment: Thanks again for your help. I will read your answer later today.
Comment: OK. So you think that fact 1 is incorrect. What can you say about this answer: http://math.stackexchange.com/questions/518848/a-question-about-the-proof-of-the-fact-that-contractible-spaces-are-simply-conne/518902#518902
Comment: Looks like Omar changed his answer in the last few hours.  The previous answer was wrong since, as he noted, it was not a continuous homotopy.  In fact, my example shows that it is impossible to prove Fact 1 without assuming contractibility (whereas it follows easily from Fact 2 when $X$ is contractible).
Comment: Regarding the proof that contractible spaces are simply connected, I don't see how you go from $H(q(s),t)$ is a homotopy from $q$ to $x_0$. Also $F$ seems to be defined using $H'$. Could you please write the explicit defintion of $F$ from $H'$ ? Also if $H'$ is defined from $H$, could you please write its definition explicitly using $H$ ?
Comment: Hi Amr. The definition of $F$ directly from $H$ is given in my new, finally correct, answer to your other question. And $H'$ is defined just like $F$: $H'(s,t)=H(p(s),t)$ if you regard $S^1$ as $[0,1]/\{0,1\}$, the unit interval with the endpoints identified.
Comment: @Amr I have expanded the proof.  It is now completely detailed.  I've also left some comments on Fact 1 that may be helpful.  The relationship between the various concepts of homotopy is a little subtle, which is why both Omar and I fell for the trap of proving it.
Comment: I might be missing something but isn't the detour via $q$ and $H'$ just for proving **Theorem** unnecessary? Given $p$ and $H$, couldn't we have directly defined $F:[0, 1]^2\to X$ as $F(s, t) = H(p(s), t)$?
Answer: Question 1: I apologize again for trying to prove Fact 1. It is false, as Ryan already explained. A correct similar statement is that if $X$ is contractible, then for any path $p$ there exists a homotopy $F$ satisfying those conditions.
Question 2: Claims 2 is also false, and your proof of the claim is correct except for using Fact 1 which is false. By changing the first sentence of your proof you can turn it into a correct proof of the correct claim that if $X$ is contractible, for any loop $p$, $p$ and the constant map $c \equiv p(0) = p(1)$ are homotopic relative to endpoints.
Question 3: Here is how I think of the proof that contractible implies simply-connected. The whole thing boils down to showing your Fact 2: the definition of contractible you're using only gives homotopies that are not relative to endpoints, Fact 2 is the thing that converts those into homotopies rel endpoints.
I will use the following notation and facts:

By $p \sim q$ I'll mean that the two paths $p, q : [0,1] \to X$ are homotopic relative to the endpoints. (I won't use any symbol for homotopies that are not between paths or are not relative to endpoints.)
I'll use $q \cdot p$ to mean the concatenation of paths $p$ and $q$ (doing $p$ first and then $q$, say), and I'll need to use that this operation

respects homotopy in the sense that $p_1 \sim p_2 \implies q \cdot p_1 \sim q \cdot p_2$,
is homotopy associative, $p \cdot( q \cdot r) \sim (p \cdot q) \cdot r$, and
has homotopy units given by constant paths $c_x$, i.e., $p \cdot c_{p(0)} \sim p$, $c_{p(1)} \cdot p \sim p$.
has homotopy inverses given by traversing paths in reverse order, $p \cdot p^{\leftarrow} \sim c_{p(1)}$, $p^{\leftarrow}  \cdot p \sim c_{p(0)}$.

I'm sure you've developed all of that if you know what the fundamental group is.
Now, let $X$ be contractible and choose a homotopy $H : X \times [0,1] \to X$ between the identity and a constant path $c_{x_0}$. Each point $x \in X$ then gets a chosen path $h_x$ connecting it to $x_0$, given by $h_x (t) = H(x,t)$. We can use your Fact 2 to produce some a homotopy relative endpoints for any path $p$: applying Fact 2 to the homotopy $(s,t) \mapsto H(p(s),t)$ we get a homotopy showing that $h_{p(1)} \cdot p \cdot h_{p(0)} ^ {\leftarrow} \sim c_{x_0}$. Using the above facts for the operation $\cdot$, we get that $p \sim h_{p(1)} ^\leftarrow \cdot h_{p(0)}$. This shows that all paths between $p(0)$ and $p(1)$ are homotopic to each other relative to endpoints because they are all homotopic to $h_{p(1)} ^\leftarrow \cdot h_{p(0)}$. This proves in particular that $X$ is simply-connected, because if $p(0)=p(1)$ we get $p \sim h_{p(1)} ^\leftarrow \cdot h_{p(0)} \sim c_{p(0)}$.
Comment: Thanks Omar for your help. +1
Answer: I do not know the book.
Let $p$ and $q$ be loops (closed paths) in $X$, i.e. $p,q\colon I\to X$, $p(0)=p(1)$, $q(0)=q(1)$. We can consider three concepts of homotopy between $p$ and $q$:
The first would be that there is a map $H\colon I\times I\to X$ such that $F(\bullet,0)=p$, $F(\bullet, 1)=q$.
The second would be that additionally $F(0,\bullet)=F(1,\bullet)$.
The third would be that $F(0,\bullet)$ and $F(1,\bullet)$ are even constant.
Now the Fact 1 that you have stated claims that the first condition implies the second (in the case that one of the paths is constant). This is certainly not true, and Ryan has pointed that out. Indeed, this first concept of homotopy is rather useless. According to it two loops are homotopic if and only if their images lie in the same path-component (exercise, but see at the end). So either the author was confused or you misread. What seems more likely is that the author meant that whenever he speaks of homotopies between paths he means those of the second kind.
The third kind is of course what you know as a homotopy relative to $\{0,1\}$ and what occurs in the definition of the fundamental group.
Ryan has also mentioned that this second kind of homotopy is a very natural concept if one thinks of a loop in $X$ as a map $\mathbb S^1\to X$ instead.
Now, generally homotopy relative base point (third kind) is stronger then free homotopy (second kind). However, and that is what you have shown with the help of Fact 2, a loop is freely homotopic to a constant loop if and only if it is homotopic relative $\{0,1\}$ to a constant loop.
You thought you had proved something even stronger because you used a wrong Fact 1, and that stronger statement is indeed false. Also your example for showing this is correct. Indeed, it suffices to identify $(0,1)$ and $(1,1)$.
Now to prove that contractible spaces are simply connected, it remains to show that in a contractible space every loop is freely homotopic (again, speaking of the second kind) to a constant loop.  But this is easy, indeed just compose the loop with the homotopy showing that the space is contractible.
In case you feel that I have evaded you question one: If it was true then your proof (the one after Fact 2) would show that a space is simply connected if every loop in it allows a homotopy of the first kind to a constant loop. But every path $p$ does, just take $H(s,t)=p(ts)$. And there are non-simply connected spaces.
Comment: Actually, your third-last paragraph is subject to my counterexample.  There is really no relationship between free homotopy and based homotopy of loops unless you are using an auxiliary global homotopy to produce both of them.  See my revised answer.
Comment: I do not understand what you mean. What I try to say is that the notion of homotopy as in Fact 1 (and indeed with an arbitrary loop instead of the constant loop) is what you get if you identify the loops (closed paths) with maps from $\mathbb S^1$ and consider homotopies of maps from $\mathbb S^1$ without extra conditions.
Comment: What I mean is that even with Fact 2, you can't show that a loop that is freely homotopic to a constant loop is also homotopic rel $\{0,1\}$ to a constant loop.  Because I give an example of how the circle is freely homotopic to a constant loop, but has a nontrivial fundamental group, so can't be homotopic as a loop.
Comment: I should clarify this in my answer. By freely homotopic I refer to a homotopy during which the path remains a loop at all times. The weaker concept is, as I wrote rather useless.
Comment: @RyanReich, thank you for your criticism, I have reworked my answer.


How to move comments section out of its parent div

Question: How can we move or override the placement of the comments in a node. Usually the comment section is placed inside its content div. My aim is to place this comment section out of its parent div which is usually the node content.

        Some Node Contents ...

Add new comment

I have my template overrides

field--comment.html.twig
comment.html.twig
page.html.twig

Inside themes/contrib/mytheme/templates
Answer: Depending on which container you want to escape, you need to use either node.html.twig (recommended) or page.html.twig (harder, unlike node you can't use {{ content.field_comment }} in page).
If you are using node.html.twig (or somehting like node--BUNDLENAME.html.twig) and you manually render {{ content.field_comment }}, then you can avoid double-rendering of comments by rendering the "normal" content using the without filter {{ content|without('field_comment') }}


Test to match different Likert scaled variables

Question: I have a set of answers to a number of 7 point Likert scaled questions that ranged from very bad to very good. I have about 200 answers for each question.

Q1(type1): Very bad, ..., ..., ..., ..., Very good
Q2(type2): ...
Q3(type1):
Q4(type1):
Q5(type2):
Q6(type1):
...

What I'd like to do now is check which type1 question matches with which type2 question in such a way that I will know that a question of type 1 is as bad or as good as a question of type 2.
I'm trying to figure out which test to use but I'm stuck. It can't be that I have to run lots of pretests but a variance analysis also doesn't seem right. I'm assuming my answers are interval scaled.
Comment: I'd like to say, people find Q1 as bad as Q5 for example. Q5 and Q1 are types of things that people can find very bad to very good.
Comment: What do you mean by "as bad or as good"?
Answer: If you are assuming that the Likert scaled variables are interval scaled (which is questionable, but probably OK for this purpose) then you can look at the mean.  You just need to define how close the means have to be to be "as bad" or "as good". Alternatively, if you are only interested in the extremes, you could match the proportion saying "very bad" or the proportion saying "very good".
If you want to get fancier (although I don't think you need to) you could look into "item difficulty" measures from item response theory, and equate "difficulty" with one end of the scale.
Comment: I was looking for a solution for which I don't have to compare the means one by one with the use of t-tests, but in one big test. Can this be done? I'm using SPSS
Comment: If you want to know which ones match with which, you have to compare them all. But I would not use a t-test or any other test, I would look at the means (all of them) and decide based on what you mean by close. A t-test (or ANOVA or whatever) would tell you if there are statistically significant differences among the tests. I don't see how this answers your question.
Comment: That's what I'd like to to, compare the means and say which ones are (alpha 5%) the same. The problem is that I have about 7 variables in the first category and 7 in the second. I can't seem to find out which test I can use to compare all the means from the first group with the ones in the second.
Comment: I still don't really understand what you are trying to accomplish, but have you looked at correlations?


There exists a point $y_0 \in A $ with $d(y_0,x) = d(x,A)$ if choose the correct option

Question: let A  be a  subset of $\mathbb{R}^P$ and $ x \in \mathbb{R}^P$  denotes  $d(x,A) = \inf \{ d(x,y) : y \in  A\}$.There exists a  point $y_0 \in A $ with  $d(y_0,x) = d(x,A)$  if
choose the correct option
$a)$ $A$ is any closed non emepty  subset  of $\mathbb{R}^P$
$b)$$ A$ is  any  non  empty  subset of $\mathbb{R}^P$
$c)$$ A$ is any non empty  compact  subset   of $\mathbb{R}^P$
$d)$$ A$  is any non empty bounded subset  of $\mathbb{R}^P$
My attempt : i thinks option a)  will correct because if A is closed then $x \in  \bar A= A,$ that is $d(y_0,x) = d(x,A)=0$
I don't know that other option pliz help me
Comment: That explains why you claim that $\overline A=A$. But why $x\in\overline A$?
Comment: Why do you claim that $x\in\overline A$?
Comment: because  A is closed   @ Jose carlos sir
Comment: @JoséCarlosSantos.....soory  sir  that is my  misunderstanding
Answer: a) and c) are true and b) and d) are false. For a) choose $\{x_k\} \subset A$ such that $d(x,x_k)$ converges to $d(x,A)$. Then $\{x_k\}$ is bouunded, so it has a convergent subsequence. If the limit of the subsequence is $y$ the $ y \in A$ and $d(x,y)=d(x,A)$.    C) follows from a). For b) and d) Take $x=0$ and $A=(0,1)$ in $\mathbb R$. Thanks to Jose carlos Santos for pointing out an error in my earlier answer.
Comment: This is not correct, since option a) is also true.
Comment: @JoséCarlosSantos Thanks. I have edited my answer using your comment. My answer is  a bit different so I though of retaining it.  I hope you have no objection to this.
Comment: Of course I have no objection.
Comment: thanks u @Kavi  sir  ,,,i need detail
Answer: a) It is correct. Take $a\in A$ and consider the closed ball $\overline{B_{d(x,a)}(x)}$. Then $a\in\overline{B_{d(x,a)}(x)}\cap A$ and, since $\overline{B_{d(x,a)}(x)}\cap A$ is closed and bounded, it is compact. So, there is a $a'\in\overline{B_{d(x,a)}(x)}\cap A$ such that$$d(x,a')=\min\{d(x,c)\,|\,c\in\overline{B_{d(x,a)}(x)}\cap A\}.$$And if $c\in A\setminus\left(\overline{B_{d(x,a)}(x)}\cap A\right)$, then $d(x,c)>d(x,a)\geqslant d(x,a')$. So, $d(x,a')=d(x,A)$.
b) It is false. take $x=(0,0)$ and $A=(0,1)\times\{0\}$.
c) It is correct, since a) holds.
d) It is false. Consider the same example as inmy answer to b).
Comment: Option b) is false, which means that there is no $y_0$. In my example, $d(x,A)=1$, but there is no $y_0\in A$ such that $d(x,y_0)=1$.
Comment: carlos  sir what is   $y_0$  in option  b)   how  can i contradict    im getting$ d(y_0,x) = d(x,A) = 0 = d( 0, (0,1))$?
Comment: Strictly speaking, the argument for a) depends on the correctness of c) and vie versa.


Calling WCF Service from JQuery does not work

Question: Problem is how to access a non aspx service from JQuery.
What i have tried:
Easiest case:
Contract:
using System.ServiceModel;
using System.ServiceModel.Web;

namespace TheService
{
    [ServiceContract]
    public interface ITheService
    {
        [OperationContract]
        [WebGet(ResponseFormat = WebMessageFormat.Json)]
        string Get();
    }
}

The Service:
using System;
using System.ServiceModel.Web;
namespace TheService
{
    public class TheService : ITheService
    {
        public string Get()
        {
            return "Hello, world!";
        }
    }
}

Hosting the service:
class Program
    {
        static void Main(string[] args)
        {
            Uri httpUrl = new Uri("http://localhost:22334/TheService");

            ServiceHost host = new ServiceHost(typeof(TheService), httpUrl);

            ServiceMetadataBehavior serviceMetaDataBehaviour = new ServiceMetadataBehavior
            {
                HttpGetEnabled = true,
                MetadataExporter = {PolicyVersion = PolicyVersion.Policy15}
            };
            host.Description.Behaviors.Add(serviceMetaDataBehaviour);

            host.AddServiceEndpoint(typeof(ITheService), new WebHttpBinding(), "");

            host.Open();

            Console.ReadLine();
        }
    }

If i try to access the service with the wcftestclient, i can access the data.
Now i tried to access it via jquery
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                    "http://www.w3.org/TR/html4/loose.dtd">

What I assumed that should happen is that I get a Hello world back. but it doesn't.
I tried:
$.ajax({
    type: "GET",
    url: "http://localhost:22334/TheService/Get",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(msg) {
        alert(msg);
    },
    error: function(err) {
        alert(err.toString());
        if (err.status == 200) {
            ParseResult(err);
        }
        else { alert('Error:' + err.responseText + '  Status: ' + err.status); }
    }
});

and all i got was two alerts "[Object] object" and "Error: Status: 0"
So in this case it seems that it runs into some error, but in which?
I have never used jquery before, so is there any where to get a little bit more helpful error message?
Do I need to define anything else in the wcf service?
At the end both projects should not be in the same aplication. the JQuery should be used at a client side and the wcf service run at a centralized server.
If i change
ServiceHost host = new ServiceHost(typeof(TheService), httpUrl);

to
WebServiceHost host = new WebServiceHost(typeof(ServiceCalculator), httpUrl);

i can see that a debug point at the WCF server is reached (return of the text) - but still both error dialogs are show.
(Added: localhost:22334/TheService/Get returns "Hello World" in browser - therefore i think it is either a problem with JQuery/Ajax, or ? )

Update:
Corresponding to the reply and http://pranayamr.blogspot.de/2011/06/calling-cross-domain-wcf-service-using.html i added the following:
Set Debug to true:
ServiceDebugBehavior debug = host.Description.Behaviors.Find<ServiceDebugBehavior>();

if (debug == null)
{
    host.Description.Behaviors.Add(new ServiceDebugBehavior { IncludeExceptionDetailInFaults = true });
}
else
{
    if (!debug.IncludeExceptionDetailInFaults)
    {
        debug.IncludeExceptionDetailInFaults = true;
    }
}

change behaviour to asp compatibility
for (int i = 0; i < host.Description.Behaviors.Count; i++)
{
    if (host.Description.Behaviors[i] is AspNetCompatibilityRequirementsAttribute)
    {
        host.Description.Behaviors.RemoveAt(i);
        break;
    }
}
host.Description.Behaviors.Add(new AspNetCompatibilityRequirementsAttribute { RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed });

allow crossdomainscriptaccess
host.Description.Behaviors.Add(serviceMetaDataBehaviour);
WebHttpBinding binding = new WebHttpBinding {CrossDomainScriptAccessEnabled = true};
host.AddServiceEndpoint(typeof(IServiceCalculator), binding, "");

and tried to set jsonp
$.ajax({
    type: "GET",
    url: "http://localhost:22334/TheService",
    method: "Get",
    contentType: "application/json; charset=utf-8",
    dataType: 'jsonp',
    success: function(msg) {
        alert(msg);
    },
    error: function(err) {
        alert(err.toString());
        if (err.status == 200) {
            ParseResult(err);
        }
        else { alert('Error:' + err.responseText + '  Status: ' + err.status); }
    }
});

Now it seems to work somehow. (Still getting no real error information if something goes wrong...) (and the asp part does not seem to be needed also..)
Answer: You might have run into a cross-domain request (http://www.d-mueller.de/blog/cross-domain-ajax-guide/).
Try CORS (http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) or JSONP (http://en.wikipedia.org/wiki/JSONP) or something of the like.
Comment: I don't think so, it appears all of the testing is being done on `localhost`.
Comment: Port, protocol and domain must be the same.
Comment: Too right you are; I think you're answer may be more on track than my own.
Comment: When I first started out with client-side requests this thing drove me crazy! The behaviour makes sense, though.
Comment: Thanks, I changed the code (as not shown in answer) and used jsonp as datatype. Now i get a response. but i still cannot the a good error message if something goes wrong.


Algebraic Independence of Equations vs Polynomials

Question: I am considering the difference between algebraic independence of a system of equations and polynomials. Are these two notions equivalent? For example, for $x, y, z$ real,
$xy = A$
$yz = B$
$xz = C$
Seems to be algebraically dependent, because if we set $A=0$, then either $x=0$ or $y=0$, which then implies either $C=0$ or $B=0$. Admittedly, I am not sure of a polynomial $f$ such that $f(xy, yz, xz) = 0$.
However, if we were to view these as polynomials in $x, y, z$, i.e. elements of $\mathbb{R}[x, y, z]$, they seem to be algebraically independent i.e., all the maximal minors of $(\frac{\partial f}{\partial x_{i}})$ are nonzero. Am I correct in saying these two notions are not the same?
EDIT: It is also possible I am confusing the notion of coupling and algebraic dependence - i.e., maybe the suggested equations are algebraically independent, but are coupled, which is why specifying the solution to two sets the solution of the third. Clarification on this point would be appreciated as well
Comment: I'd say the equations $D:xy=0$, $E:xz=0$, $F:yz=0$ are *logically* dependent, as $D$ implies ($E$ or $F$). I'm not sure that makes the equations $xy=A$, $xz=B$, $yz=C$ dependent, logically or otherwise. And certainly the polynomials $xy$, $xz$, $yz$ are algebraically independent.
Comment: Similar question posted to MO, http://mathoverflow.net/questions/123824/algebraic-independence-of-polynomials-in-n-variables-with-real-coefficients
Answer: EDIT: OP has edited reference to linear independence out of the question, so what follows is no longer relevant.
Linear independence and algebraic independence are very different things. For example, the polynomials $x$ and $x^2$ are linearly independent, since there are no real numbers $a$ and $b$ such that $ax+bx^2$ is the zero polynomial, but they are algebraically dependent, since if $f(u,v)=u^2-v$ then $f(x,x^2)$ is identically zero.
Another example: $1$ and $\sqrt2$ are linearly, but not algebraically, independent over the rationals.
Comment: Ah, I just realized I said the polynomials "appear to be linearly independent" in $\mathbb{R}[x, y, z]$. I did not mean to put linearly there. I've now adjusted the original question.
Answer: Your notion of algebraically independent equations is not one that I am familiar with. Using your example, I would guess that the definition is that $f_1(x_1, \ldots, x_n)$, $f_2(x_1, \ldots, x_n)$, ..., $f_m(x_1, \ldots, x_n)$ are "algebraically independent as equations" if, given the knowledge of the values of any $m-1$ of the $f_i$, the remaining $f$ is still free to assume any value. I'm going to term this "logical independence". I have not seen this condition before, but I'll try to make some useful remarks about it.
Claim The polynomials $f_1$, $f_2$, ..., $f_m$ are logically independent iff the map
$$F:(x_1, \ldots, x_n) \mapsto (f_1(x), \ldots, f_m(x))$$
from $k^n \to k^m$ is surjective.
Proof: It is clear that, if $F$ is surjective, then the $f_i$ are algebraically independent. Conversely, suppose that the $f_i$ are logically independent. Let $(x_1, \ldots, x_m)$ be an arbitrary point in $k^m$.
We will show, by induction on $i$, that there is a point $(x_1, x_2, \ldots, x_i, y_{i+1}, \ldots, y_m)$ in the image of $F$. The base case, $i=0$, is vacuous. Suppose that $(x_1, \ldots, x_i, y_{i+1}, \ldots, y_m)$ is in the image of $F$. Since the $f_i$ are logically independent, the equations $f_1=x_1$, $f_2=x_2$, ..., $f_i=x_i$ does not let us deduce anything about $f_{i+1}$. In particular, it does not let us deduce $f_{i+1} \neq x_{i+1}$. So there is some $z$ with $f_1(z) = x_1$, ..., $f_i(z) = x_i$ and $f_{i+1}(z)=x_{i+1}$. This completes the induction. $\square$.
As your example demonstrates, logical independence is stronger than algebraic independence: $f_1$, ..., $f_m$ are algebraically independent (over an infinite field) if and only if there is a nonzero polynomial $P$ which vanishes on the image of $F$. A simpler example is
$$x \ \mbox{and} \ xy.$$
When $k$ is not algebraically closed, logical independence seems to be a very hard notion to work with. For example,
$$x^{37}+y^{37}+z^{37} \ \mbox{and} \ xyz$$
are logically dependent over $\mathbb{Q}$ by the work of Taylor and Wiles. It would probably be easy to find equations where it is still an open problem whether they are logically independent.
When $k$ is algebraically closed, this is a reasonable notion, but I've never seen a more concise name for it than "the map $(f_1, \ldots, f_m)$ is surjective".
When $k$ is algebraically closed and $m=n$, we have the following result: If $k[x_1, \ldots, x_n]$ is a finite $k[f_1, \ldots, f_n]$-module, this implies that the $f_i$ are logically independent. The adjective for this is "the map $F$ is finite". "Finite" is strictly stronger than surjective. For example,  $(x,y) \mapsto (x+xy, x^2 y)$ is surjective over $\mathbb{C}$ (exercise!) but I claim that $\mathbb{C}[x+xy, x^2 y]$ is not a finite $\mathbb{C}[x,y]$ module. (Harder exercise. Hint:  Show that $\mathbb{C}[x,xy]$ IS finite over $\mathbb{C}[x+xy,xy^2]$.)
I don't know of a good generalization of "finite" to the case $m \neq n$.
Comment: Hm. You raise some interesting points. I take back what I said in my original example - the Jacobian defined by the three equations I have listed is square, so its maximal minor is itself and is indeed zero - so in this case, the polynomials are algebraically dependent and "logically dependent" by your definition. Thank you for the help, your notion of logical independence is exactly what I was attempting to describe.
Comment: Can you potentially think of an example of polynomials which are algebraically independent but logically dependent? In my specific case, I am only interested when we are looking at polynomials in $\mathbb{R}[x_{1},x_{2},...,x_{m}]$, so perhaps that makes the notions equivalent, or easier than a general field? Ideally they will be equivalent, as if they are not I might be out of luck for what I am trying to do.
Comment: Uh, as I said, $(x, xy)$ is logically dependent but algebraically independent. So is your original example: The Jacobian is $\det \begin{pmatrix} y & x & 0 \\ 0 & z & y \\ z & 0 & x \end{pmatrix} = 2 xyz \neq 0$.


Visitor Counter

Question: Is there a way of finding out the number visitors of a drupal website, where they go to and where they are from. Google Analytics come to mind (or if any other module can do a better job).
Comment: Maybe something like in [this answer](https://drupal.stackexchange.com/a/161888/39516)? Or maybe something similar to what is shown on [this site](http://drupal.placeto.be/visitors)?
Answer: If you also want to track user interactions with forms/nodes/etc you might want to look into Events Log Track - https://www.drupal.org/project/events_log_track
With that said adding Google Analytics is also super easy via the module. https://www.drupal.org/project/google_analytics
* Edited to comment on  Visitors module as there appears to be a bug that was introduced into it in D8* You might also want to keep an eye on the visitors module I used it with great success in D7 . It's available in D7 and D8, but there appears to be a bug mentioned with the D8 install that is being worked on. - https://www.drupal.org/project/visitors.

Visitor Counter


Symmetric matrix as sum

Question: Let $B$ be a symmetric matrix, and $A$ an invertible matrix (or course both square matrices with the same order). Show that there is a matrix $X$ such that $$B= AX^T + A^T X$$
Comment: As sranthrop points out in the answer below, the statement does not hold in general. I guess there may be a typo in your question --- the correct statement is probably that $B=AX^T+XA^T$ for some $X$. If this is the case, the statement is rather trivial and it holds over any field of characteristic $\ne2$.
Comment: Note that $AX^T+XA^T=(AX^T)+(AX^T)^T$. Since $B$ is symmetric, we have that $B=1/2B+1/2B^T$. Thus, if $AX^T=1/2B$, you are done. Indeed, take $X=1/2(A^{-1}B)^T=1/2 B(A^{-1})^T$.
Comment: You're right! There must be a typo in the lecture notes I'm reading... . But just to finish the question, how can I solve for $X$ in $B= AT^T + XA^T$? I can guess that $X=\frac{1}{2}B(A^T)^{-1}$, but I am not able to write the complete proof:  multiplying by $(A^T)^{-1}$ we have then $B(A^T)^{-1}=AX^T(A^T)^{-1}+X =A(A^{-1}X)^T+X$, but I get stuck there! BecauseI don't know that $A^{-1}X$ is symmetric do I?
Answer: JUST A COMMENT: Are you sure you didn't miss any additional assumptions?
I think this is not possible in general. For instance, take $A=\begin{pmatrix}0 & 1 \\ 1 & 0 \end{pmatrix}$ and $B=\begin{pmatrix}1 & 1 \\ 1 & 0 \end{pmatrix}$. Writing $X=\begin{pmatrix}x_1 & x_2 \\ x_3 & x_4 \end{pmatrix}$, your equation is equivalent to the linear system
\begin{align*}
x_2-x_3&=1\\
x_2-x_3&=0,
\end{align*}
which obviously has no solution.
In general, if $A$ is symmetric, but $A^{-1}B$ is not (see the example above), then your equation cannot have a solution: If $A$ is symmetric, then $B=AX^T+A^TX=A(X^T+X)$, and this implies $X^T+X=A^{-1}B$. The left hand side is symmetric, but the right hand side is not.
Comment: There was a typo in the lectures notes I was reading. But the statement was that and you gave a very convincing counterexample. Thanks!

Symmetric matrix as sum


Data analysis using matched design - SPSS help

Question: I would love to get some advice regarding the following please!
I am involved in a study that is looking at cognition across 3 separate groups (1= the clinical group of interest; 2= clinical control group; 3=healthy control group). All participants completed a range of cognitive tests. Preliminary analysis on the entire sample (n=51) showed that there was a general intellect difference between groups (grp 3 was higher than grps 1+2), which meant that any subsequent analysis showing differences on the cognitive tests could be due to intellect alone rather than a true difference. So the sample was specifically matched on IQ, resulting in an adjusted sample size of n=33 (11 per group).
I was originally instructed to perform repeated measures ANOVAs on the refined sample for each of my cognitive tests. As such, the layout of my SPSS datafile shows 11 rows, so there are 3'groups' per variable (e.g., test1_group1; test1_group2; test1_group3).
Now, there were no significant differences for any of these cognitive tests. However, there was a significant difference in terms of mood, and so I would be interested in running a repeated measures ANCOVA to investigate how much mood is impacting on the cognitive results. However, given the layout of my variables, I am becoming confused at how to run the repeated measures ANCOVA using SPSS, as my variable options re: the mood questionnaire produces 3 options (e.g., Mood_group1; mood_group2; mood_group3) - do I choose the mood variable for the group with the significant difference only, or use all 3 variables as covariates (which complicates the output somewhat!)
To add yet another layer of complexity, I consulted with some friends about my analyses. They were confused why I was analysing using repeated measures and suggested I instead alter the layout of my SPSS datasheet so that I would have 33 rows (to match the n=33), and run a series of independent one-way ANOVAs, which would seem to solve my 3 variables per 'person' dilemma re: performing an ANCOVA, but leaves me extremely confused as this seems to make sense, but is not in line with what I was told originally.
I'm sorry this has turned into a longer post than I had intended but hopefully it provides enough background in order for some well-needed advice to be thrown my way!! Any input/ideas would be greatly appreciated!
Answer: I think you would be better off using linear regression, which is essentially the same as an AN(C)OVA, but slightly more general. Using a linear regression allows you to control for the influence of group membership and intellect separately, as well as by interaction. I would not recommend throwing away data. Selecting data post hoc introduces sampling bias so that you can no longer safely assume a random sample. This essentially means that your results are less valid and less generalizable.
You should organize your data in a different way. In SPSS the rows contain cases, and the columns contain variables. The best way to organize your data would be to include all 51 cases over 51 rows. Instead of having every measure three times for every group, you will have one variable for every measure plus two dummies to indicate group membership. You need two group dummies because you always need k-1 amount of dummies to discern between k number of groups. How to code dummy variables is explained here.
Comment: your answer is a good one.  The OP should have remarked that going from n=51 to n=33 is a strong signal than an inappropriate analysis has been chosen.  There is no justification for matching, especially when it discards valuable data.  Covariate adjustment is much less arbitrary and is more efficient.


Is the usage of unbiased estimator appropriate?

Question: Sometimes I find the usage of unbiased estimator quite confusing. For example, the unbiased estimator of variance:$$S^2=\frac{\sum (X_i-\bar{X})^2}{n-1}\,.$$
True, it is the expectation of variance. But when should we use it? I mean, there are other ways to estimate $\sigma^2$, such as MLE. How can I know when I should use MLE and when I should use unbaised estimator?
Secondly, some books(such as A-level and AP syllabus and textbooks) uses $S$ as an estimation of standard deviation.  However, $S$ is NOT an unbiased estimation. This perplexes me a lot because I don't know what they are trying to do. Why don't they use an unbiased estimator of standard deviation instead?
Here are some unbiased estimators of standard deviation. https://en.wikipedia.org/wiki/Unbiased_estimation_of_standard_deviation#Background
So I have two questions:

When should we use unbiased estimator? How can I choose between Maximum Likelyhood Estimation and Unbiased Estimation?
Why in some books, unbiased estimator are used in such a way that it end up with bias?
Comment: To answer the question about the standard deviation: *an unbiased estimator of some parameter does not always exist.* In the case of the standard deviation, well... [there is none.](https://en.wikipedia.org/wiki/Unbiased_estimation_of_standard_deviation#Background)
Comment: @ClementC. There is one unbaised estimator of standard deviation for independent normal variables, as shown in wikipedia. WHY we rarely use it?
Answer: You've pinpointed an important problem with unbiasedness as a desideratum for an estimator, and that is that it's not invariant under reparameterization. The same thing happens with an exponential distribution. There are two common parameters to use, the rate $\lambda$ or the mean $\theta=1/\lambda.$ MLE is invariant so what you get either way is consistent: $$ \hat\theta_{MLE} = \overline X\\\hat\lambda_{MLE} = \frac{1}{\overline X}$$ where $\overline X$ is the sample mean. However, since generally $\tfrac1{E(X)} \ne E\left(\tfrac1{X}\right),$ it turns out that while $\hat \theta_{MLE}$ is unbiased, $\hat \lambda_{MLE}$ is biased.
An obvious answer would seem to be that we should use the bias-adjusted estimator for whichever version of the parameter we "care about" more, or in other words, which parameter's interpretation is more in line with what we are intuitively trying to measure by estimating. By this standard, one might think we should be using an unbiased estimator for the standard deviation rather than the variance, since the standard deviation is intuitively a size of an average fluctuation.
As straightforward as this sounds, there are a number of problems with this line of thinking. The first is pretty minor but still worth noting: actually, the standard deviation isn't the size of an average fluctuation! That would be something closer to the mean average deviation, and for normal distributions this is different by a factor of $\sqrt{2/\pi}$ (or something like that... don't quote me).
Which brings me to the second more important point. What is the formula even for the bias-adjusted standard deviation? It's very complicated compared to the bias-adjusted variance (for the normal distribution). Furthermore, the unbiased variance estimator has a nice property: it is unbiased regardless of distribution. The precise form of the unbiased estimator for the standard deviation depends on the distribution. So that said, it's pretty obvious why authors prefer the unbiased variance estimator.
(Also the unbiased estimator, is a misnomer. I mean the estimator proportional to the square root of the standard variance estimator with the proportionality constant chosen to make it unbiased.)
Fortunately the authors aren't sacrificing much for the sake of parsimony: unbiasedness is an extremely overrated property and we shouldn't care too much about it. Think about what it means: it means that if you do the experiment where you collect sample size $n$ a million times, the average value you get for the estimator is exactly, squarely equal to the true parameter. Think about this literally: is this actually what you want? It seems like ideally this would probably be the case, but we're missing an important dimension of estimator variance. Surely we'd prefer an estimator whose mean is $1\%$ higher than the true value and whose fluctuations are $2\%$ to one whose mean is exactly the true value and whose fluctuations are $20\%.$
One popular metric for the quality of an estimator is mean squared error. This includes contributions from both variance and bias. And it's generally not equal to the unbiased estimator. However, like the unbiased standard deviation estimator, it depends on the distribution... which, between that and the additional conceptual overhead explains why that one isn't 'standard'.
As for why we typically use the bias corrected variance estimator rather than the MLE, it's really just that usually bias-corrected MLEs have marginally better finite sample efficiency than uncorrected. There's also the fact that the unbiased version is the one that makes the formula for the t-test the least cumbersome, which is an explanation that probably shouldn't be overlooked.
Comment: I totally agree with you. Thanks!
Answer: There is no unanimous criterion. All you need to know is that given certain criterion, you prefer this one to that one, and so.
Unbiased estimators don't assure a good estimate per se. Sometimes between an unbiased estimator with a very large variance and another one with a little bias and a much smaller variance, you will prefer the second one. The MSE criterion, which chooses between several estimators $\hat \theta_k$ of the parameter $\theta$ that with lesser MSE (if there is one), uses that same idea, since
$$MSE_\theta(\hat \theta)=E(\theta-\hat\theta)^2$$
and its easy to prove that
$$MSE_\theta(\hat \theta)=(Bias(\hat \theta))^2+Var(\hat \theta).$$
But even so, it's not a universal truth that $MSE$ is the measure of accuracy. Why squaring instead of absolute value? Why expectation instead of median...?
The best criterion (if there's such a thing) depends on the real world problem you analize; given that criterion, there might be (or not) a best estimator. The mathematical background is not enough to give an absolute answer.
Comment: I just want to know how to choose between MLE and unbiased estimation.
Comment: How to choose... Depends on which criteria you base your choose. If I were you, I would go look if my teachers said something about it. If you want to use MSE, well... MLE is better (in the sense of having lesser MSE) than unbiased $S$. I usually use that one. In any case, nor $\sqrt S$ nor the square root of the MLE are unbiased. And I agree with **spaceisdarkgreen**: unbiasedness is sooo overrated...
Answer: I'll start with a quick answer to you practical problem ant then will elaborate a little on the basic notions. So, if you have relatively small sample size - then you should care about the bias. As such, as long as the unbiased estimator is a simple adjustment of the MLE (or some other "legitimate" estimator), then use it. If you have large sample size, then it does not matter as the MLE's bias vanishes asymptotically and it is neglectable for large sample sizes.
Now, for the more general question - What are the desired properties of a "good" estimator? As already have been said, there is no universal criteria, but I guess that no one will argue that (1) consistency and (2) stability are important features. By consistency we assure that our estimator converges in probability (or almost surely for strong consistency) to the true value of the parameter. Moreover, it assures that your estimator will be asymptotically unbiased, i.e.,
$$
\lim_{n\to \infty} \mathbb{E}[\hat{\theta}] = \theta.
$$
And stability - that you estimator will not fluctuate much. Which brings us to the basic measure of stability - its MSE that incorporates both its variance and again its bias, i.e.,
$$
\operatorname{MSE}(\hat{\theta}) = \operatorname{Var}(\hat{\theta}) + b^2(\hat{\theta}).
$$
As such, once again the bias is involved, as large bias will increase the MSE substantially, and the first feature of consistency applies (given a finite second moment) that
$$
\lim_{n\to \infty}\operatorname{MSE}(\hat{\theta}) = 0.
$$
I.e., asymptotic unbiasedness is again a consequence of a more basic feature. Furthermore, let me convince you that include the unbiasedness as a primary estimator's property isn't smart as you may end up dealing with inadmissible estimators. Assume that you have $X_1,...,X_n$ i.i.d from $\mathcal{N}(\mu, \sigma^2)$, then I can define silly estimator like $\hat{\mu} = X_1$ that is unbiased, as
$$
\mathbb{E}[X_1]=\mu.
$$
Howevre, its MSE is $\sigma^2$, and thus it is an iconsistent estimator.
In this manner I can construct plenty of useless unbiased estimators. As such, including unbiasdness as a primary desirable feature isn't the right approach.
So... why so much ado about this bias thing? Apparently, it can be useful as a secondary desirable property. I.e., consistency that applies asymptotic unbiasedness and vanishing MSE is asymptotic property and I never witnessed an infinitely large or near infinitely large sample size. Hence, when dealing with real world statistics - considering the size of the bias may be valuable. However, there are also useful theoretical considerations. If you want to establish some general theory of evaluating estimators, you will have to reduce or restrict the class that you deal with. In such a case, restricting your attention only to unbiased estimators will lead you to important and insightful ways to obtain and compare estimators - UMVUE, the Gauss-Markov BLUE in regression analysis and more. Namely, once you restrict your class only to unbiased estimators apparently, you can derive general theorems regarding the features and ways of construction (e.g., Lehmann-Scheffe theorem) globally (over this class) optimal estimators. Hence, to sum it up. Bias as itself is not that important. What is more important is consistency and stability, and once you set your goal to achieve these two properties, then by dealing only with unbiased estimators you can derive uniformly best possible unbiased estimators. Namely, being sure that you cannot improve your estimators. But once you leave this realm of only unbiased estimators - you are stumble into the bias-variance tradeoff dilemma (e.g., in regression analysis you can reduce substantially the MSE of the estimators with methods like LASSO and/or Ridge regularizations, but it will introduce bias to your estimators) that opens one again the whole problem of finding optimal estimators.


Is a log-normal distribution uniquely determined by its moments or not?

Question: Wikipedia states that

A log-normal distribution is not uniquely determined by its moments $\text{E}[X^k]$ for $k\ge 1$, that is, there exists some other distribution with the same moments for all $k$. In fact, there is a whole family of distributions with the same moments as the log-normal distribution.

However, just prior to that, it states that

Equivalently, parameters $\mu$ and $\sigma$ can be obtained if the expected value and variance are known[.]

This confuses me. What am I missing? Is it perhaps a freedom in the base itself?
NB: I would also like to be sure that the 'ln-normal' (log-normal in base $e$?) is uniquely determined by expectation and variance.
Answer: They are referring to the fact that the moment generating function is not convergent for the lognormal distribution. For a random variable $X$ that ranges over $[0,\infty)$ with a probability density function $f$, the moment generating function is defined as
$$M(t) = E(e^{tX}) = \int_{0}^{\infty} e^{tx} f(x) dx $$
If it exists, then expanding the exponential in a Taylor series leads to a series expansion for $M$ of the form
$$M(t) = 1+ \sum_{k=1}^{\infty}\frac{t^k}{k!}E(X^k) $$
This is useful as an alternative to direct integration to find the moments $E(X^k)$ if the generating function is known.
Unfortunately this does not converge for the lognormal distribution (due to the $x^{-1}$ factor in the probability density function.)  When the moment generating function does not exist, then the moments do not uniquely define the distribution.
That said, it is true that two parameters appear in the lognormal pdf and you can solve for them using the mean and variance. However, there can be other distributions with additional parameters that have the same moments.
I believe an example is to multiply the usual lognormal pdf by $[1+ a\sin(2n\pi \log(x)].$
Answer: The lognormal distribution is not uniquely identified by its moments. At our sister site Cross Validated there are detailed answers:

https://stats.stackexchange.com/questions/261545/nonuniqueness-of-lognormal-moments

With some plots: https://stats.stackexchange.com/questions/84219/whether-distributions-with-the-same-moments-are-identical

With better plots:  https://stats.stackexchange.com/questions/84158/how-is-the-kurtosis-of-a-distribution-related-to-the-geometry-of-the-density-fun/84213#84213


calculate the runtime for the Java program

Question: I want to calculate the runtime of my Java program. when I used the following method:
long startTime = System.currentTimeMillis();
           ...my program...
long endTime   = System.currentTimeMillis();
long totalTime = endTime - startTime;
System.out.println(totalTime);

the result is different from time to time, so I am thinking to get some (100 or some..) samples and calculate the average to make it more accurate:
long total = 0
for (int i = 0; i < 100; i++) {
    Long s = System.currentTimeMillis();
    ...my program...
    Long e = System.currentTimeMillis();
    total += (e - s);
}

so I got the total runtime.. for the first method, it is normally about 600ms and for the second method, the result would be around 30000ms (so avg time: 30000/100 = 300ms).
I think it might be related to JVM, it requires some time to load the file or convert it to byte code. and the second method only load&convert once and just run the method 100 times?
I'm not sure about my explanation, please correct me if I'm wrong.
and my problem is: if I want to get the "real" total running time and calculate the average value, what should I do?
Thanks in advance!
Answer: Timing in Java is bound to be quite unreliable in this fashion, because not only are you going to be sensitive to events happening outside your program, but the nature of JIT compilation and so forth makes it difficult to predict whether or not a given event will take the same amount of time in all situations. Basically, the best you can do is do a TON of iterations and get an average value. Back when I had to do timings for class, I would get pretty consistent timing results if I used tens of thousands of iterations per test, but again, you are not going to get terribly accurate timing in this fashion with Java (and to a lesser extent, any language).
EDIT: Also, you should look into profilers if you desire more accurate timing calculations, as they would probably give a clearer look of execution time per method than trying to do things this way.
Answer: Netbeans has a Profiler option to calculate runtime of Java applications under Profile section. You might be searching for that since, Profiler calculates actual CPU and memory times. Based on my experiences, I can say it's pretty stable.


Use multiple WHERE clauses to display result?

Question: Good day,
I was hoping if anyone could help me. I'm using VirtueMart in Joomla. I've found a way to change the layout of the products which changes it to a list.
In VirtueMart you can create custom fields, which you can set the value to once you create a new product. Now, in this example, I have two custom fields:

Expiry Date
Batch Number

Now, the following piece of code will show the "customfield_value" from the correct table in the database WHERE "customfield_value" is equal to the "virtuemart_product_id".
 <?php //make a database connection and find the field record that contains the customfield string
 $db = JFactory::getDBO();
 $db->setQuery("SELECT customfield_value FROM jos_virtuemart_product_customfields WHERE virtuemart_product_id=".$product->virtuemart_product_id.";");
 $db->query();
 $result = $db->loadResult();
 echo ($result) ?>

That is all well and good. It must do that. However, there's one issue. When I copy this piece of code for the other "customfield_value" (Batch Number), it still shows only the first "customfield_value" (Expiry Date).
So now, it needs two conditions:
It needs to show the "customfield_value" WHERE the "customfield_ID" = "2" AND WHERE it is equal to the current "product_id".
I hope that makes sense.
I wrote some code below which I hope gives you an idea of what it needs to do. Can someone please help me review this code and see what I'm doing wrong:
 <?php //make a database connection and find the field record that contains the customfield string
 $db = JFactory::getDBO();
 $db->setQuery("SELECT customfield_value,customfield_id,virtuemart_product_id FROM jos_virtuemart_product_customfields WHERE virtuemart_product_id=".$product->virtuemart_product_id.";". AND "WHERE customfield_id=5");
 $db->query();
 $result = $db->loadResult();
 echo ($result) ?>

Thanks for reading and I hope someone can help me. I've been struggling with this and just can't seem to get it right.
Answer: You don't have to use multiple WHERE keyword in condition just use AND to separate them in where also remove ; from middle of the query
$db->setQuery("SELECT customfield_value,customfield_id,virtuemart_product_id
FROM jos_virtuemart_product_customfields WHERE
virtuemart_product_id=".$product->virtuemart_product_id." AND customfield_id=5");

Comment: Thanks a lot man I will give it a try! I hope it works since I've tried messing around with the structure of the code but did not try this version.


How to import classes in subfolders

Question: On Python 3.6
I want to organize my classes in folders.
ClassX in folder Classes
Subclass_of_ClassX in a subfolder
MyPackage
    -__init__.py
    -someCode.py
    -folder Classes
        -__init__.py
        -ClassX.py
        -Subfolder SubClasses
            -__init__.py
            -Subclass_of_ClassX.py

Subclass_of_ClassX overriddes elements (functions and variables) from ClassX
The question is: if I import ClassX on any project, and I get any instance of Subclass_of_ClassX, and I want to use any overriden function, do I need to explicitly import the subclass?
Or can I just import ClassX and abstract from any inherited class, using any subclass instance as if it were ClassX?
Answer: If you got instance of class - you already don't need to import anything, because it was imported in some other place already.
Comment: by "instance of class", you also mean any subclass instance?
Comment: Yeah, I am talking about subclass - instances already have link to their class, so you can't create instance without having class imported somewhere.

You can even get Subclass itself, without importing it, by `instance.__class__`
Answer: If you get an instance of Subclass_of_ClassX from somewhere, you don't need to additionally import the class at all. Importing a class just makes the name available in your current scope (module).
You only need to import the class or subclass when you need to...

create a new instance
write a subclass
use it otherwise like in isinstance(obj, ClassX)
Answer: What you describe is not the Pythonic way to structure packages.
You'll end up with having to do
from mypackage.Classes.ClassX import ClassX

when you could do with
from mypackage.class_x import ClassX

If your package is, uh, for the sake of example, a zoo where you have animals and foods, I would suggest putting the animals in one package and their foods in another.

myzoo/__init__.py (empty)
myzoo/animals/__init__.py (empty)
myzoo/animals/base.py (containing your Animal base class)
myzoo/animals/cats.py (containing Lion and Tiger, for instance)
myzoo/foods/__init__.py (empty)
myzoo/foods/base.py (containing your Food base class)
myzoo/foods/kibbles.py (containing kibbles for the cats, not that they'll like them)

(You could also have one file per animal/food, and probably should if you anticipate them growing large.)

How to import classes in subfolders


dataTable editável JSF não mostra atributos do objeto

Question: Preciso fazer uma atividade com uma lista JSF onde é possível adicionar, editar e excluir os usuários registrados. Tinha conseguido fazer os registros de novas pessoas, mas quando comecei a usar cellEdit pra fazer as edições nos registros, notei que nenhum dos atributos dos objetos aparecem na lista além do ID, e não sei qual é o erro no código. Ao testar, notei que as pessoas estão sim sendo salvas na lista, porém nada aparece na dataTable.
Código do xhtml:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<h:head>
    <title>Lista de pessoas</title>
</h:head>
<h:body>
    <h:form id="form">

        <h:panelGrid columns="4" cellpadding="5">
            <h:outputLabel for="nome" value="Nome:" style="font-weight:bold" />

            <h:outputLabel for="email" value="Email:" style="font-weight:bold" />

        </h:panelGrid>

]

                    <f:facet name="output"><h:outputText value="#{pessoa.id}"/></f:facet>
                    <f:facet name="input">
</f:facet>

                <f:facet name="output"><h:outputText value="#{pessoa.nome}"/></f:facet>
                <f:facet name="input">
</f:facet>

                <f:facet name="output"><h:outputText value="#{pessoa.email}"/></f:facet>
                <f:facet name="input">
</f:facet>

    </h:form>
</h:body>

Código do GerenciadorBean:

package br.senai;

import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class GerenciadorBean {

    int id = 1;

    private List<Pessoa> listPessoas = new ArrayList();

    private Pessoa pessoa = new Pessoa();

    public void inserir(){
        pessoa.setId(id);
        listPessoas.add(pessoa);
        pessoa = new Pessoa();
        id++;
    }

    public Pessoa getPessoa(){
        return pessoa;
    }

    public List<Pessoa> getPessoas(){
        return listPessoas;
    }

    public void setPessoa(Pessoa pessoa){
        this.pessoa = pessoa;
    }
}

Código do Pessoa.java:
package br.senai;

public class Pessoa {
    private String nome;
    private String email;
    private int id;

    public Pessoa(String nome, String email){
        this.nome = nome;
        this.email = email;
        this.id = id;
    }

    public Pessoa(){}

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    /*  <h:panelGrid columns="2" cellpadding="5" id="display">
                <h:outputText value="#{gerenciadorBean.exibirNome()}" />
                <h:outputText value="#{gerenciadorBean.exibirEmail()}" />
            </h:panelGrid> */
   }

Comecei agora em JSF e não sei o que fazer. Qualquer ajuda é bem-vinda!
Answer: Erro bobo!
Somente o ID aparecia pois ele era o único que estava dentro da tag , e por isso ele era o único que imprimia na tabela.


seamless ssh with condition

Question: I am looking for a way of seamless ssh in a way that when user does ssh through shell, it will be disallowed (or normal rules apply) but if a process (non-interactive) tries to ssh with the same user should be allowed without password. May be some keys generated by the root of the server for users coming with some extra inputs.
Please help.
Comment: @Rilindo Hi Rilindo, I can see a similar point raised by you in one communication in 2011. Please share if you know a way for the same. ssh -i, still seem to be asking for password for me. ref link: http://serverfault.com/questions/323958/how-do-you-create-an-ssh-key-for-another-user?answertab=active#tab-top
Answer: best way to do this is to have a dedicated ssh key for each process that requires access, make sure that no other user has permissions on the private keys.
Each process should have it's own key so that if any key is comprimised you only have to change one processes setup rather than each one that uses the key.
If you don't want ssh prompting for a password you can use
<code>ssh -o "PasswordAuthentication=no" user@host
</code>
This will silently fail if no other authenication succeeds (ie public key) and no prompt will be given
Comment: Can you please elaborate on how we can generate ssh key on process basis? Please note that there is no separate user account here.
Comment: [Ssh-keygen](http://linux.die.net/man/1/ssh-keygen) -C "comment to add to key file" -f /path/to/privatekeyfile -N ""  ; this should create a private key in the file given to the -f flag with corresponding pubfile created with an appending .pub. the comment should probably be the process the key is for. The -N is the password for the private key, best to be blank for non-interactive stuff if omitted it will prompt you for it

seamless ssh with condition


Integration of $\int_0^{1/4} \frac{x^3}{ \sqrt{1-9x^2}} dx$ using trigo substitution

Question:
Evalute $\int_0^{1/4} \frac{x^3}{ \sqrt{1-9x^2}} dx$ using trigo substitution

Because $\sqrt{a^2 - b^2x^2} => x = a/b \sin \theta$
So, Let $x= \frac{1}{3} \sin \theta$
$dx = \frac{1}{3} \cos \theta$
Elimination of roots:
$\sqrt{1-9x^2} = \sqrt{1- \sin^2 \theta} = \sqrt{\cos^2 \theta} = \cos \theta $
The limit of integration is $x=0$ to $x=1/4$
Therefore, the new limit of integration is:
$0 \le \theta \le 0.8481$ This is in the 1st quadrant and therefore $\cos \theta$ is positive
Actual substitution:
$\int_0^{1/4} \frac{x^3}{ \sqrt{1-9x^2}} dx = \int_0^{0.8481} \frac{\frac{1}{9} \sin^3 \theta}{\cos \theta} (\frac{1}{3} \cos \theta)d\theta =\int_0^{0.8481} \frac{\sin^3 \theta}{27} d\theta$
However, the calculated value of the definite integral is incorrect. I was told that my trigo substitution is correct. I cannot find which step I made a careless in.
Comment: Your integral should have $1/27$ in the numerator, not $1/9$. That's all.
Answer: @Accelerator pointed out the mistake for why OP could not get the answer correctly.
Here is another way to solve without trig substitution:
Let $u=x^2$, the definite integral will now become $$\frac{1}{2}\int_{0}^{1/16}\frac{u}{\sqrt{1-9u}}du$$
Let $v=1-9u$, then it will become
$$\frac{-1}{18}\int_{1}^{7/16}\frac{1-v}{9\sqrt{v}}dv=\frac{-1}{18}\int_{1}^{7/16}(\frac{1}{9\sqrt{v}}-\frac{\sqrt{v}}{9})dv$$
Answer: Let
$$ I = \int_{0}^{1/4} \, \frac{x^3 \, dx}{\sqrt{1- 9 \, x^2}}. $$
Make the substitution $3 \, x = \sin\theta$ to obtain the following.
Let $ a = \sin^{-1}(1/4)$.
\begin{align}
I &= \int_{0}^{a} \, \frac{\sin^3\theta}{3^3} \, \frac{1}{\sqrt{1-\sin^2\theta}} \, \frac{\cos\theta \, d\theta}{3} \\
&= \frac{1}{3^4} \, \int_{0}^{a} \frac{\sin^3\theta \, \cos\theta \, d\theta}{\cos\theta} \\
&= \frac{1}{3^4} \, \int_{0}^{a} \sin^3\theta \, d\theta \\
&= \frac{1}{3^4 \, 4} \, \int_{0}^{a} ( 3 \, \sin\theta - \sin(3\theta) ) \, d\theta \\
&= \frac{1}{3^5 \, 4} \left[ \cos(3\theta) - 9 \, \cos\theta \right]_{0}^{a} \\
&= \frac{1}{3^5 \, 4} \, \left[8 + \cos\left(3 \, \sin^{-1}\left(\frac{3}{4}\right)\right) - 9 \, \cos\left(\sin^{-1}\left(\frac{3}{4}\right)\right) \right] \\
&= \frac{1}{3^5 \, 4} \, \left[ 8 - \frac{5 \, \sqrt{7}}{16} - 9 \, \frac{\sqrt{7}}{4} \right] \\
&= \frac{1}{3^5 \, 4} \, \left(8 - \frac{41 \, \sqrt{7}}{16} \right).
\end{align}
A straight integration reveals
\begin{align}
I &= \int_{0}^{1/4} \, \frac{x^3 \, dx}{\sqrt{1- 9 \, x^2}} \\
&= - \frac{1}{3^5} \, [ (9 x^2 + 2) \, \sqrt{1 - 9 x^2} ]_{0}^{1/4} \\
&= \frac{1}{3^5 \, 4} \, \left( 8 - \frac{41 \, \sqrt{7}}{16} \right)
\end{align}
as expected.


How mock then and catch in jest with mongoose

Question: I'm trying to run a jest spyOn on a mongoose method that contains a promise.
but it is returning me an error: Received message: "Cannot read properties of null (reading 'then')"
I have a repository with this function:
async getByEndpointId(endpointId: string) {
 return await this._requestModel.find({endpointId})
  .then((request) => request.filter((req) => !req.deleted))
  .catch((error) -> console.log("One Error"))
}

When I try to test with jest this way:
jest.spyOn(mockEndpointModel, 'find').mockReturnValue(value as any)

The runntime show me this error:
Received message: "Cannot read properties of null (reading 'then')"
if I remove the then and catch methods my test works
Answer: Why are you mocking a promise rather than having Jest mock a resolve or reject which is a promise? jest.spyOn(mockEndpointModel, 'find').mockResolvedValue(value) or jest.spyOn(mockEndpointModel, 'find').mockRejectedValue(new Error('Something bad happened')
This repo has a bunch of Nest unit testing samples and might be useful to you
Comment: I found in your repo one way to make this and works:

```
jest.spyOn(mockEndpointModel, 'find').mockReturnValue({
      exec: jest.fn().mockResolvedValueOnce(value),
} as any);
```
Comment: This is specific to mongoose and the way the `exec` call works. Notice how the service code is all `find(options).exec()` that's why the `find` and `exec` methods are both mocked. Based on your code, you should just have your `find` mock resolve a promise.
Comment: At first it didn't work but now I managed to make it work, thanks

`jest.spyOn(mockEndpointModel, 'find').mockResolvedValue(value)`


Ajax shopping cart

Question: I installed several ajax carte modules but none have possibility to display shopping cart in there menu as on the image, if you add some products, shopping card displays number of added products
Comment: Hi, please remember that this is a Q+A site. You need to ask a specific question about the problem you're facing. Rather than just asking how to accomplish this whole broad feature, you need to break this down and describe exactly what you've tried, where you're stuck, and exactly what you need help with. Many thanks
Comment: Changed my question to more specific
Comment: is there any possible variants how can I do this task???
Answer: I think this module will be helpfull
Commerce Popup Cart
Comment: in this module shopping cart doesn't refresh with ajax
Comment: [Ajax Basket Link](https://www.drupal.org/project/commerce_ajax_basket_link)
Comment: thanks for reply but it didn't refresh cart

Ajax shopping cart


If a sequence of boundaries converges, do the spectrums of the enclosed regions also converge?

Question: A planar region will have associated to it a spectrum consisting of Dirichlet eigenvalues, or parameters $\lambda$ for which it is possible to solve the Dirichlet problem for the Laplacian operator,
$$ \begin{cases} \Delta u + \lambda u = 0 \\ u|_{\partial R} = 0 \end{cases}$$
I'm wondering, if we have a sequence of boundaries $\partial R_n$ converging pointwise towards $\partial R$, then will the spectrums also converge? (I make the notion of convergence formal in the following manner: $\cap_{N=1}^\infty l(\cup_{n=N}^\infty\partial R_n)=\partial R$; $\cap_{N=1}^\infty l(\cup_{n=N}^\infty\mathrm{spec}(R_n))=\mathrm{spec}( R)$, where $ l(\cdot)$ denotes the set of accumulation points of a set and $\mathrm{spec}(\cdot)$ denotes the spectrum of a region.)
One motivating pathological example is the sequence of boundaries, indexed by $n$, defined by the polar equations $r=1+\frac{1}{n}\sin(n^2\theta)$. The boundaries converge to the unit circle. However, since the gradient of any eigenfunction must be orthogonal to the region boundary (as it is a level set), the eigenfunctions can't possibly converge to anything (under any meaningful notion) and so it makes me question if it's even possible for the eigenvalues to do so.
If the answer is "no, the spectrum doesn't necessarily converge," a much broader question arises: what are necessary and sufficient conditions for it to converge? Intuitively, I imagine a necessary condition is that the curvature of the boundaries also converge appropriately, but I have no idea if that's sufficient. EDIT: Another interesting question is if the principal eigenvalue (the smallest nonzero one) can grow arbitrarily large.
Comment: Non-convergence of eigenvectors is probably not an obstruction. You can easily construct smooth family of matrices whose eigenvalues converge but whose eigenvectors won't.
Answer: There is a domain monotonicity of Dirichlet eigenvalues: if domains $\Omega^1\supset\Omega^2\supset\ldots\supset\Omega^n\supset\ldots\ $ then the corresponding eigenvalues $\lambda_k^1\ge\lambda_k^2\ge\ldots\ge\lambda_k^n\ge...\ $ so convergence of curvatures are not necessary in this case. There are also lots of more general results on spectral stability problems for elliptic differential operators.
Comment: The link to `resources.aims.ac.za` is also broken. Presumably it points to a 2010 publication of Mohammed, Mogtaba A. Y. (MR Author ID: [1096638](https://mathscinet.ams.org/mathscinet/search/author.html?mrauthid=1096638)) at the [African Institute for Mathematical Sciences](https://en.wikipedia.org/wiki/African_Institute_for_Mathematical_Sciences), but I am unable to identify which one it might be...


Obter value de input

Question: Olá gostaria de saber como posso obter um value de um input de uma página depois de realizar um curl com requests no python 3.6!
Exemplo:
<input type="hidden" name="authURL" value="1526610106833.UG2TCP2ZiJ9HKXhlrlgybcdEBB0=" data-reactid="37"/>

Queria pegar o conteúdo do "value", que muda a cada request, e utilizar-lo no header para outro curl.
Answer: Se quiseres fazer com regex:
import re

html = '<input type="hidden" name="authURL" value="1526610106833.UG2TCP2ZiJ9HKXhlrlgybcdEBB0=" data-reactid="37"/>'

match = re.compile('name="authURL" value="(.*?)"').search(html)
if match == None:
  print('Não encontrado')
else:
  print(match.group(1)) # 1526610106833.UG2TCP2ZiJ9HKXhlrlgybcdEBB0=

DEMONSTRAÇÃO
Com BeautifulSoup (recomendado):
from bs4 import BeautifulSoup as bs

html = '<input type="hidden" name="authURL" value="1526610106833.UG2TCP2ZiJ9HKXhlrlgybcdEBB0=" data-reactid="37"/>'

soup = bs(html, 'html.parser')
inp = soup.find('input', {'name': 'authURL'})
print(inp.get('value')) # 1526610106833.UG2TCP2ZiJ9HKXhlrlgybcdEBB0=

DEMONSTRAÇÃO
Comment: @Gennie, https://repl.it/repls/ZealousConventionalAnalysts
Comment: Muito obrigado!
Comment: Amigo, eu preciso pegar o value do authurl de um link, esse authurl muda nesse tal link a cada vez que eu dou refresh na página, como proceder ?
Comment: @Gennie tendo o html (resposta do servidor) podes ir buscar o value ao input, desta maneira e usa-lo como quiseres para futuros pedidos http. Repara nas DEMONSTRAÇÕES
Comment: Miguel, não consigo compreender, teria como você fazer uma outra demonstração para mim utilizando um link no qual você puxa dados desse link ?
Comment: @Gennie tens o link a que queres fazer este parse, podes dar-me para eu dar uma olhada
Comment: Peguei esse de modo aleatório::https://www.netflix.com/br/login
Comment: Como faço pra dar curl (get) nesse link e pegar o value de ""
Comment: O value desse input muda a cada request

Obter value de input


Is this a valid technique for this linear algebra proof?

Question: Let {$A$v$_1$....$A$v$_n$} be a linearly independent set. If $A$ is invertible, prove that {v$_1$....v$_n$} is linearly independent.
PROOF:
Because {$A$v$_1$....$A$v$_n$} is a linearly independent set,
the equation $c_1A$v$_1$+....+$c_nA$v$_n=0$ implies that $c_1$....$c_n$ must all equal $0$.
multiplying the equation by $A^{-1}$ we obtain: $c_1$v$_1$+....+$c_n$v$_n=0$, where $c_1$....$c_n$ must still must all be $0$.
We can therefore conclude that {v$_1$....v$_n$} is linearly independent
Comment: You need to rearrange the argument.  To prove $v_1,\dots,v_n$ is linearly independent, start with a linear combination of these, $c_1v_1+\dots+c_nv_n=0$ and work toward proving that all $c_i$ are zero.  Note your formulation is incorrect... there is only $A$, not $A_1, A_2,\dots$.
Comment: okay in that case there is no reason for the problem to require that A is invertible, correct?
Comment: @JackK95 No $A$ invertible is still necessary. He is just saying that your $A_1v_1, \ldots, A_nv_n$ should just be $Av_1, \ldots, Av_n$.
Comment: Right okay, I knew that. Don't know why I wrote it out like that. Is there still a mistake apart from that though?
Comment: @JackK95 Yes you do not need $A$ invertible.  You start with $c_1v_1+\cdots+c_nv_n=0$ and multiply by $A$ to conclude that the $c_i$ are $0$.
Answer: I see a bit of a problem with the argument. To prove that a set is linearly independent, you have to allow $c_1...c_n$ to be an arbitrary tuple that yields the zero vector when used as coefficients for the set, then prove they're all zero. That is, you need $c_1 \textbf v_1 +...+c_n\textbf v_n =\textbf 0 \rightarrow c_1...c_n = 0$. You have instead proved $c_1 \textbf{Av}_1 +...+c_n\textbf{Av}_n =\textbf 0 \rightarrow c_1...c_n = 0$. Now, it certainly is true that if $c_1 \textbf{Av}_1 +...+c_n\textbf{Av}_n = \textbf 0$, then $c_1 \textbf v_1 +...+c_n\textbf v_n =\textbf 0$, so if you have all $c_1...c_n$ for   which $c_1 \textbf{Av}_1 +...+c_n\textbf{Av}_n = \textbf 0$, then all of your tuples are tuples that you are looking for. But "everything I find is a tuple I'm looking for" and "all I'm looking for is a tuple I find" are different statement.   If there is any set of coefficients for which $c_1 \textbf v_1 +...+c_n\textbf v_n =\textbf 0$ but $c_1 \textbf{Av}_1 +...+c_n\textbf{Av}_n \neq \textbf 0$, then you haven't proven that $c_1...c_n=0$ for all $c_1...c_n$ for which $c_1 \textbf v_1 +...+c_n\textbf v_n =\textbf 0$. There aren't actually any such coefficients, and this fact is relatively trivial, but it's about the same level of triviality as what you're being asked to prove, so it isn't really valid to assume it.
When doing proofs, it's important to follow quantifiers exactly.
Comment: okay thanks. what I am gathering from all this is that I dont need A invertible. And that I start with $c_1v_1+...+c_nv_n=0$ then multiply by A to get $c_1Av_1+...+c_nAv_n=0$ and then conclude all $c_i=0$?


Erro em Query Mysql

Question: Tenho uma página em php que precisa fazer uma consulta em 3 campos no Banco Mysql.
Campo Aprovado
Campo Reprovado
Campo Resolution

$select = mysql_query("select * from denuncia where (resolution is NOT NULL)
AND status='aprovado' or status='reprovado'");

Esta Query só retorna o campo Reprovado, porem preciso que retorne tudo que estiver com status aprovado, reprovado e o campo Resolution não for nulo.
Onde estou errando?
Comment: O erro deve estar na precedência dos operadores lógicos, tente: `"select * from denuncia where (resolution is NOT NULL)
AND (status='aprovado' or status='reprovado)'"`
Comment: Eu já tinha tentado desta forma. Retorna este erro: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in
Comment: O que está passando como argumento para o `mysql_fetch_assoc`?
Comment: A variavel select desta query : while($fetch = mysql_fetch_assoc($select)){
Comment: Tente executar a função `echo mysql_error();` após a linha `$select = mysql_query("...");`.
Comment: Erro de sintaxe    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Comment: Desculpe, há um erro de sintaxe na query que sugeri, a última aspas ficou fora do parenteses, corrigindo: `select * from denuncia where (resolution is NOT NULL) AND (status='aprovado' or status='reprovado')`.
Comment: Deu certo. Obrigado :)
Answer: Olá!
Você deve escrever a sua consulta da seguinte maneira:
select * from denuncia where resolution IS NOT NULL AND (status='aprovado' OR status='reprovado')

Comment: Isso mesmo. Apenas acrescentei como sugestão do @PanterA 3 acima, os parenteses nos campos Status tb. Obrigado.

Erro em Query Mysql


Unix concatenation commands

Question: I've got a question here that I dont understand:
cat abc.dat | tee bcd.dat | tr ab ba > cde.dat

In this instance, I understand the translate part, but I'm a little confused as to what the pipe | does, I've been told that it takes the stdout of a program with the stdin of another. If I were to try to explain this, correct me if I'm wrong but you're taking abc.dat's contents, duplicating the output into bcd.dat, and then taking the content from bcd.dat and translating instances of a and b into b and a respectively, and then taking that and putting it into cde.dat?
The official answer is: abc.dat is copied to bcd.dat. and abc.dat is copied to cde.dat but with 'a' replaced by 'b' and 'b' replaced by 'a'. But why is abc.dat copied into cde.dat instead of bcd.dat? does the pipe not continue?
Answer: The "official" answer is poorly worded. Neither tee nor tr know anything about abc.dat; it just happens that what it reads from tee is what tee read from cat, which is what cat read from abc.dat.
Comment: soooooo...my explanation was right?
Comment: Close. Nothing reads from `bcd.dat`, but the standard output of `tee` (which `tr` reads from) is identical to what is written to `bcd.dat`.
Comment: ohhh that makes sense. so after the creation of bcd nothing actually happens to it, and it's never referenced again. In short, the tee function produces not only a stdout but also a duplicate of what was taken in (which are not the same things), right?
Comment: Right; it writes to standard output as well as any file whose name is passed as an argument.
Answer: The tee utility reads from stdin and writes this firstly to stdout, and secondly to all files given as argument. In your case, stdin is written to stdout, and to file bcd.dat. The pipe behind the tee links the stdout of tee to the stdin of the tr. Although the data is the same, it is not the content of file bcd.dat that is being piped to tr. It is the output of the initial cat, which in turn is the content of file abc.dat.

Unix concatenation commands


How can I disable image loading in Awesomium?

Question: How can I disable image loading in the browser Awesomium in offscreen rendering mode?
Comment: Is this a software development question or a question about the settings of an individual application?
Comment: This is a software development question. Awesomium is .Net and C++ web control library.  [link](http://www.awesomium.com)
Comment: Cheers; not heard of it before, wanted to check that it was relevant to the site (this question came up on my "review" list). You may want to ask on http://answers.awesomium.com/ too, as that seems to have quite an active audience too.
Answer: You can switch off loading of images when you create a WebSession:
WebView.WebSession = WebCore.CreateWebSession(new WebPreferences(){LoadImagesAutomatically = false});
Answer: Also you can use ResourceInterceptor. Advantage: it can be switched without recreating WebSession + WebControl/WebView.
public class ResourceInterceptor : IResourceInterceptor
{
    public bool NoImages { get; set; }

    private static string[] _imagesFileTypes = { ".png", ".jpg", ".jpeg", ".gif", ".bmp" };

    public ResourceResponse OnRequest(ResourceRequest request)
    {
        string ext = System.IO.Path.GetExtension(request.Url.ToString()).ToLower();

        if (NoImages && _imagesFileTypes.Contains(ext))
        {
            request.Cancel();
        }

        return null;
    }

    public bool OnFilterNavigation(NavigationRequest request)
    {
        return false;
    }
}

...

ResourceInterceptor ResInt = new ResourceInterceptor();
WebCore.ResourceInterceptor = ResInt;


Need help with natural deduction logic proof (Chiswell/Hodge exercise 2.6.2d)

Question: in Chiswell/Hodge exercisee 2.6.2d it asks for the proof of $\{\lnot(\phi\leftrightarrow\psi)\}\vdash((\lnot\phi)\leftrightarrow\psi)$. I've managed to produce half the proof, but I'm unable to produce the other half indicated at D.
$$
\frac{(1)\frac{D^{(1)}}{((\lnot\phi)\rightarrow\psi)}(\rightarrow I) \qquad \frac{\cfrac{(6)\frac{\phi^{(6)}\quad\psi^{(2)}}{\phi\rightarrow\psi}(\rightarrow I)\quad (5)\frac{\psi^{(5)}\quad\phi^{(4)}}{\psi\rightarrow\phi}(\rightarrow I)}{\phi\leftrightarrow\psi}(\leftrightarrow I)\qquad \lnot(\phi\leftrightarrow\psi)}{(4)\cfrac{\bot}{(2)\cfrac{\lnot \phi}{(\psi\rightarrow(\lnot\phi))}(\rightarrow I)}(\lnot I)}(\lnot E)}
{((\lnot\phi)\leftrightarrow\psi)}(\leftrightarrow I)
$$
I had considered...
$$(1)\frac{\cfrac{\phi\quad\lnot\phi^{(1)}}{\cfrac{\bot}{\psi}(RAA)}(\lnot E)} {((\lnot\phi)\rightarrow\psi)}(\rightarrow I)$$
But that leaves me with an undischarged $\phi$. I'm otherwise unsure of how to produce the $\psi$ for the $(\rightarrow I)$ in the left branch, as an absurdity (other than as proposed) discharges $\lnot\psi$, and I can't use this to construct an absurdity against the assumption $\lnot(\phi\leftrightarrow\psi)$ similar to how I did in the right branch.
At this point in the text, the only rules available are elimination/introduction of $\land$, $\rightarrow$,$\leftrightarrow$,$\lnot$ and RAA.
I would be very grateful to understand this particular exercise further as I'm losing sleep over it.
(Also if someone has formatting advice regarding \frac or some suitable alternative via PM, I would be further grateful.)
Comment: @Bram28 Why not? I'm not in a class, I'm doing this to myself. I took a long distance degree in philosophy, but it had no formal logic, which as an engineer I found interesting. However, I've yet to appreciate where people actually use formal logic (I've seen people say how important it is in many texts, but no actual use). So my question is genuine - why IS this a waste of time? Is it impractical?
Comment: No one should lose sleep over proving that $\neg (\phi \leftrightarrow \psi) \vdash \neg \phi \leftrightarrow \psi$ ... Why are we still torturing our students this way?
Comment: You can try with a long sub-proof : assuming $\lnot \phi$ and $\lnot \psi$ derive (by contraposition) $\phi \leftrightarrow \psi$. Then you have a contradiciton with the premise and, by double negation, you can derive $\psi$ discharging $\lnot \psi$ and conclude with $\lnot \phi \to \psi$ by $\to$-intro, discharging $\lnot \phi$.
Comment: @MauroALLEGRANZA I was afraid someone would suggest a strategy not yet introduced in the book, but in my midnight wisdom I was not sure how to head this off, and hoped an answer within the constraints simply appeared. A little more awake, the only rules available are elimination/introduction of $\land$, $\rightarrow$, $\leftrightarrow$, and $\lnot$. I believe the authors intend the problem to be solved using only these rules. I've since edited the original question.
Comment: @Lugh Concerning the practical relevance of logic, consider program verification.  Microsoft has a computer farm running their theorem prover [Z3](https://github.com/Z3Prover/z3) 24/7 to expose security vulnerabilities.  They do it because it's effective.  There are many other examples.
Comment: @Lugh If you are looking to improve your day to day logical reasoning skills, then I would say that most formal approaches are too 'straight-jaceketed'; too stringent.  It would be like learning to program starting with machine code.  Now, as Fabio says, there *are* important practical applications of formal logic in computer science, from circuit design, to programming languages, to program verification. So if that's what you want to go into, then sure, continue with your studies in formal logic.  But I would urge you to look at lots of different logic systems and techniques.
Answer: 1) $\lnot (\phi \leftrightarrow \psi)$ --- premise
2) $\lnot \phi$ --- assumed [a]
3) $\psi$ --- assumed [b]
4) $\lnot \psi$ --- assumed [c]
5) $\bot$ --- from 3) and 4)
6) $\phi$ --- from 2) and 5) by Double Negation, discharging [a]
7) $\psi \to \phi$ --- from 3) and 6) by $\to$-intro, discharging [b]
8) $\lnot \phi \vdash \phi \to \psi$ --- repeat the derivation above, with assumption [d] : $\lnot \phi$

9) $\lnot \psi, \lnot \phi \vdash (\phi \leftrightarrow \psi)$ --- from 7) and 8) by $\leftrightarrow$-intro

10) $\bot$ --- from 1) and 9)
11) $\psi$ --- from 4) and 10) by Double Negation, discharging [c]

12) $\lnot \phi \to \psi$ --- from 8) and 12) by $\to$-intro, discharging [d].

We have discharged all the "temporary" assumptions; thus, the above derivation amounts to :

$\lnot (\phi \leftrightarrow \psi) \vdash (\lnot \phi \to \psi)$

You can also simplify the other part a little bit...
1) $\lnot (\phi \leftrightarrow \psi)$ --- premise
2) $\phi$ --- assumed [a]
3) $\psi$ --- assumed [b]
4) $\phi \to \psi$ --- from 3) by $\to$-intro
5) $\psi \to \phi$ --- from 2) by $\to$-intro
6) $\phi \leftrightarrow \psi$ --- from 4) and 5) by $\leftrightarrow$-intro
7) $\bot$ --- from 1) and 6)
8) $\lnot \phi$ --- from 2) and 7) by $\to$-intro, discharging [a]

9) $\psi \to \lnot \phi$ --- from 3) and 8) by $\to$-intro, discharging [b].
Answer: This answer is only possible due to the answer provided by MauroAllegranza; however, their answer is in Fitch style, and I wanted to provide a Gentzen style to match the question, in case someone searches for this in the future.
The following is only the solution to D, as provided by Mauro, to sub into the overall proof. For formatting reasons I had to further break it down, hence D1.
Part#1 (D1)
$$
D1=\dfrac{(4)\cfrac{\cfrac{\cfrac{\psi^{(4)}\quad\lnot\psi^{(3)}}{\bot}(\lnot E)}{\phi}(RAA)}{\psi\rightarrow\phi}(\rightarrow I)\quad (2)\cfrac{\cfrac{\cfrac{\phi^{(2)}\quad\lnot\phi^{(1)}}{\bot}(\lnot E)}{\psi}(RAA)}{\phi\rightarrow\psi}(\rightarrow I)}{(\phi\leftrightarrow\psi)}(\leftrightarrow I)
$$
Part#2 (D)
$$
D= (1)\dfrac{(3)\cfrac{\cfrac{\cfrac{D1^{(3)(1)}}{(\phi\leftrightarrow\psi)}\qquad\lnot(\phi\leftrightarrow\psi)}{\bot}(\lnot E)}{\psi}(RAA)}{((\lnot\phi)\rightarrow\psi)}(\rightarrow I)
$$
Answer: The quickest proof of all would simply involve noticing that the negation of "if and only if" is an XOR operation. Then to notice that $\lnot p\leftrightarrow q$ will read: $p(\lnot q)\lor (\lnot p)q$ . Which, (funnily enough) is an XOR operation.
As $\ \lnot(A\leftrightarrow B)=\ A\oplus B$
And as $\ \lnot p\leftrightarrow q=\ p(\lnot q)\lor (\lnot p)q\ $
which in turn is $\ p\oplus q$
$\therefore \lnot(p\leftrightarrow q) = \lnot p\leftrightarrow q$
It may not be in the style of the question but I thought you might appreciate the brevity of this proof.
Answer: Since I wrote the proof during my own study, I might as well post it here.


Is it possible to use $(RELEASE.TRIGGERINGARTIFACT.ALIAS) as a condition to trigger different release stages?

Question: My problem is almost same as this question. However, I don't really get the comments or the solutions proposed there.
Say I have two artifacts: A1 and A2.
A1---> Dev stage
A2---> UAT stage.

What I want is that when A1 is released, only Dev stage is deployed. But at the moment, when A1 is rleased, Dev and UAT are triggered.
looking at the comments from previous question,

how can $(RELEASE.TRIGGERINGARTIFACT.ALIAS) be used as a trigger condition? Looking at filter, I can't see a place to put custom condition

If I create a third artifact as suggested, how can I set different tag base on if A1 or A2 is built?

If there other ways to solve this?
Answer:
Say I have two artifacts: A1 and A2.

Open Dev stage ->click Agent job->expand Additional options and select Custom condition using variable expressions-> add the condition eq(variables['RELEASE.TRIGGERINGARTIFACT.ALIAS'], 'A1'). The Dev stage only runs when the value of RELEASE.TRIGGERINGARTIFACT.ALIAS is A1, otherwise this stage will be skipped.
The same configuration in UAT stage, the condition is eq(variables['RELEASE.TRIGGERINGARTIFACT.ALIAS'], 'A2')

In my release pipeline, I update the Artifact _test to trigger this release pipeline and the variable RELEASE_TRIGGERINGARTIFACT_ALIAS is _test, it runs Stage 1 and skip Stage 2
Answer: This might not be the exact answer, but it still can work as a solution to your problem.
You can tag your builds depending on the produced artifact name. If the build produces artifact A1, add a tag A1 to it. That way you can set up release stage conditions based on artifact filters like this:

For the Dev stage trigger, filter build tags by A1 and for the UAT trigger, filter by A2.
Comment: but this will trigger both I think
Comment: actually, I cecided to merge two build pipeline into one and then uses branch filter in release. This makes things much easier.