What is a "recurrent model" in forecasting

Question: In this book, there is a chapter titled Recurrent Models (you can see that chapter in Google books) but it's very short and some parts are not very clear to me. Recurrent Models seem to refer to a regression of the following form:
$$y_{k} = f(y_{k-m},..., y_{k-1},x_{k-m},..., x_{k-1}) \hspace{20mm}\text{for} \; k = m+1,....,n$$
However, I would like to get more information about this topic but maybe the name recurrent model is not a very common one, so I'm having a hard time getting more notes or books about it. Can anyone give me some pointers?
Thanks
Comment: May refer to Recurrent Neural Network models (Googling recurrent model yields much material related to RNNs). RNNs are dynamical neural network models where there is feedback, as opposed to the output being a static function of the input. .. I would stay away from this stuff and learn algebra and topology and metric spaces instead.
Comment: I don't really think it refers to RNN (even if RNN can also be used with regression) but just out of curiosity, why did you suggest to stay away from RNNs?
Comment: Was going by the top Google hits. To give you an example of how excruciating NNs can be, my thesis advisor analyzed a small network of less than 10 neurons (Hopfield type, but w/o symmetries) coupled to an external environment, resulting in 30 pages of (Mathematica assisted) bifurcation analysis to understand them.
Comment: Now I understand your suggestion :-)
Answer: I don't know what you need this for, but what this author calls 'recurrent' seems a general version of autoregressive (AR) or vector-autoregressive (VAR) models. While these, to my knowledge, are assumed linear in their evolution over time, I'm not sure if the more general functional relationship of this book's definition is actionable in practice. If you need to estimate something along these lines, you might want to start reading about these well-understood and investigated models. Here's the wiki link: http://en.wikipedia.org/wiki/Vector_autoregression. A good book covering this in great detail is Hamilton, Time Series analysis.
Edit (see comment below): I touched base with my gf. While not precisely under the name "recurrent models," she suggested to google "Real-time computing without stable states," and the researcher names Maass, Buonomano, and Jaeger; also a paper by Abbott&Sussillo on recurrent nets for computation. This is how 'recurrent' models are used in contemporary theoretical neuroscience, which may or may not be what you are interested in. There should be an introductory article on Scholarpedia, eg, http://www.scholarpedia.org/article/Echo_state_network.
Comment: Thank you for your answer. I don't need this for a particular purpose. I have already read about AR models so 'recurrent models' indeed seem like generalized AR models, but a quick google search didn't return something similar to what I'm looking for. Hamilton's book covers AR models too? By the way, the author more or less motivates this using fine-state machines, so autoregressive and recurrent models are approximations to Moore and Mealy machines, respectively.
Comment: Hamilton was encyclopedically complete when I was in grad school (~late '90s) for anything (V)AR under the unifying theme of GMM; I don't know if it got updated after. It's focused heavily towards applications in economics/finance, so might not be best for neuroscience and FSM applications as neuroscience at least simulates heavily non-linear information transmission (my gf is a neuro grad student currently). So I don't know. :)
Comment: @Robert Smith: in any case, it's good to see The Cure passionate about math...:)
Comment: @RobertSmith: see an edit I added above, which maybe is closer to what you are interested in.
Comment: Thanks! It seems that echo state networks are similar to recurrent models but the motivation is quite different. By the way, I read some parts of Hamilton's book and it covers AR and VAR models but it's very hard to know whether it contains something along the lines of recurrent models under a different name. Anyway, 1+ for the effort and for the reference to The Cure.


Theorems with the greatest impact on group theory as a whole

Question: In his Contemporary Abstract Algebra text, Gallian asserts that Sylow's Theorem(s) and Lagrange's Theorem are the two most important results in finite group theory.  He also provides this quote by G.A. Miller:

Generally these three results are implied by the expression "Sylow's Theorem."  All of them are of fundamental importance.  In fact, if the theorems of group theory were arranged in order of their importance Sylow's Theorem might reasonably occupy the second place - coming next to Lagrange's Theorem in such an arrangement."

The notion of 'most important theorem' in any area of mathematics is of course highly subjective, but if we depart from this phrasing and think of theorems that are very far-reaching, widely applicable, or theorems that impacted group theory the most (surely there is a good deal of overlap), do Lagrange's and Sylow's theorems still top this list when we consider the whole of group theory?  If not, what theorem or theorems would?
What theorem(s) within strictly infinite group theory would top such a list?
Comment: What part of your car engine is most important?
Comment: This is a good question and does not deserve to be closed. Understanding the theorems that are considered most important in any field of math is an important step towards understanding that field.
Comment: Wow, wasn't expecting this to be closed.  The idea of a 'most important theorem' is certainly not mine.  Evidently Joseph Gallian and G.A. Miller, if no one else, found the question of 'most important theorem' a reasonable one to at least attempt to subjectively answer.  Would community members feel better about it if I worded it as something more like 'most far-reaching theorems,' 'most widely applicable theorems,' or 'theorems with the most impact'?
Comment: What...is the capital of Assyria? In all seriousness, I'd probably put forward the [First Isomorphism Theorem](http://en.wikipedia.org/wiki/First_isomorphism_theorem#First_isomorphism_theorem).
Comment: I agree with @user18921, and so am voting to re-open.
Comment: What are you going to do with an answer to this question?
Comment: The question is not so easy to answer. There is a larger question about what is known/unknown and/or of current interest in the infinite dimensional setting. An appraisal of what is known or unknown or in want of knowing would be a quite interesting answer in my view.
Comment: This probably should be CW
Answer: What is the most important theorem in infinite group theory? I would say that it is the rather annoying theorem which says that "groups are (very!) complicated". There are three fundamental theorems on "complicated-ness", and I will mention each of these below. However, the proofs of the other two are based on the first, which is why I am proposing it for the "most important" theorem. The three problems I will talk about are called Dehn's problems, and were posed by Dehn in 1914. He proved that they are soluble for the fundamental groups of closed, orientable surfaces of dimension two. The key point is that they are not soluble in general. (Note that there are plenty of similar results, but these three are the classical, fundamental ones.)
A general reference for most of the stuff below is the paper Decision problems for groups: surveys and reflections by Chuck Miller III. You can download this from his webpage. Another reference is the book of Lyndon-Schupp entitled Combinatorial group theory (this also provides a reference for my mentioning of Dehn's proof that the problems are soluble for the fundamental groups of closed, orientable surfaces of dimension two). [Note. Since writing this post I came across an answer of Henry Wilton on MathOverflow. See here. It is very relevant to this post, and I believe explains extremely well why we as geometric group theorists care about the existence an non-existence of algorithms.]
Presentations. Before we can state the theorems, we need to briefly introduce presentations. Let $G$ be a group. Then every group can be given by a presentation, so $G=\langle X; R\rangle$. Here, $X$ is a set of generators for $G$ and $R$ is a set of relators which tell you how the generators multiply together. If $G$ can be given by a presentation such that $X$ and $R$ are both finite then $G$ is said to be finitely presentable. For example, the Klein-four group $V$ is given by the following presentation. $$\langle a, b; a^2=1, b^2=1, ab=ba\rangle$$ Therefore, $V$ is finitely presentable (if I recall correctly, this is a worked example at the start of the book Combinatorial group theory by Magnus-Karrass-Solitar (note: not Lyndon-Schupp - same name, different books)). Indeed, every finite group is finitely presentable as one can take $X$ to be all the (non-trivial) elements of $G$ and then take the elements of $R$ to be simply the way that two elements multiply together, so if $g, h, k\in G$ such that $gh=k$ then $ghk^{-1}\in R$. For example, the Klein-four group can be given by the following presentation. $$V\cong\langle a, b, c; ab=c, ab=b, a^2=1, ba=c, b^2=1, bc=1, ca=b, cb=a, c^2=1\rangle$$ Note that there are infinite groups with finite presentations, for example $\langle a;-\rangle$ and $\langle a, b; b=1\rangle$ are two different presentations of the infinite cyclic group.
Algorithms. It is not necessary, but you might find this post of Arturo Magidin helpful before continuing. Or perhaps you might want to read it afterwards. It discusses what it means for things to be "decidable", and so on.
The word problem for groups. One of the most natural questions one can ask when given a group via a (finite or otherwise) presentation is the following.

"Can I decide if two words in the generators are equal?"

That is, if $G=\langle X; R\rangle$ and $U(X)$, $V(X)$ are words over $X$, is it true that $U(X)=_GV(X)$? Equivalently, "Is it true that $U(X)V^{-1}(X)=_G1$?", and so the word problem for groups asks this.

Let $G$ be a group given by a presentation $\langle X; R\rangle$. Then, given a word $W(X)$, is it decidable if $W(X)=_G1$?

It turns out that this is an intrinsic property of the group, linked to Turing machines. But that is not the theorem I want to tell you about (it just lets me talk about groups as opposed to presentations). The theorem I want to tell you about is as follows.

Possibly the most important theorem in (infinite) group theory.
Theorem (Novikov-Boone) There is a finitely presented group $G$ such that the word problem in $G$ is undecidable.

Or more informally, there exists a group $G$ such that it is impossible to tell if an element is trivial or not. This was proven in the 1950s. And should blow your mind!
Note that the word problem is soluble for finite groups.
The conjugacy problem for groups. Let $G$ be given by a presentation $\langle X;R\rangle$. Then the conjugacy problem for groups asks if when given two elements $U(X)$ and $V(X)$ it is decidable whether these elements are conjugate, that is, whether there exists a third element $W(X)$ such that $W^{-1}UW=V$. Note that insoluble word problem implies insoluble conjugacy problem. However, there is a middle way.

Theorem (Collins) There exists a finitely presented group $G$ which has soluble word problem but insoluble conjugacy problem.

The isomorphism problem for groups. Let $\langle X; R\rangle$ and $\langle Y; S\rangle$ be two presentations. Then can we decide if they define isomorphic groups? Erm, once again, no...

Theorem (Adian-Rabin) It is undecidable whether a finite presentation defines the trivial group.

Actually, Adian-Rabin's result is deeper. They prove that "Markov properties of finitely presented groups are not recursively recognisable". This is in Miller's paper.
Why Novikov-Boone? Now, all three results are impressive. However, I am proposing the Novikov-Boone result as the "most important" because one can prove the other results using it. It is therefore the most fundamental of the three theorems. A rather lovely example of this is the paper Isomorphism versus commensurability for a class of finitely presented groups by Arzhantseva-Lafont-Minasyan, which can be found here. The use Novikov-Boone to give groups with insoluble isomorphism problem in an exceptionally elegant way. The insolubility of lots of other decision problems for groups follow from Novikov-Boone. Arzhantseva-Lafont-Minasyan's paper includes other examples, but one can derive using rather elementary means that it is insoluble in general whether two group homomorphisms are the same.
What next? Another reason for proposing this theorem is that finding classes of groups which have soluble word problem is more than just a fun game: it is a major driving force in geometric group theory. For example, Dehn started with closed, orientable surfaces of dimension two. This was generalised to "small cancellation theory" (Greendlinger, Lyndon, etc.) which led to "hyperbolic groups" (Gromov), and this was all motivated by soluble word and conjugacy problems. In time, this theory led to Wise's work on groups with a "quasi-convex hierarchy", which has led to the resolution of the virtually Haken conjecture by Agol. (The virtually Haken conjecture is an important now-theorem in 3-manifold theory.)
Comment: Very nice, thanks!  I really love the topological connections.  So groups have solvable word problem if they are the fundamental group of a closed, orientable surface of dimension two?  Where could I read the proof - or about the proof - of this?  Is it fair to call this an application of topology to group theory, or is that not how it works?
Comment: @AlexPetzke If I recall correctly, Dehn used a presentation for the fundamental group of these surfaces, but perhaps I am mistaken (and so not topology). You should look up the book of Lyndon-Schupp. It is the standard reference for "small cancellation theory", which is a theory designed to exploit the underlying concept on Dehn's proof (and hyperbolic groups exploit this even further, getting to the crux of the proof). Lyndon-Schupp explain nicely how Dehn's proof fits in. Small cancellation theory has a very geometric interpretation though, using things called "van Kampen diagrams".
Comment: If you want an example of topology and group theory going side-by-side, you should look up the [Siefert-Van Kampen Theorem](http://en.wikipedia.org/wiki/Seifert%E2%80%93van_Kampen_theorem). This gives a nice topological interpretation of certain fundamental group theoretic constructions (HNN-extensions and free products with amalgamation). For the group theory, again Lydon-Schupp is your best bet, while for the topology it should be covered in [Hatcher's book](http://www.math.cornell.edu/~hatcher/AT/ATpage.html).
Comment: @user1729: This wiki page https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB4QFjAA&url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FHigman%27s_embedding_theorem&ei=KyZrVOH3FY7_ugT6k4GICg&usg=AFQjCNHKO1YN3BYw977IrTESHcJg6BE8IA&bvm=bv.79908130,d.c2E says "Higman's embedding theorem also implies the Novikov-Boone theorem"
Comment: @user123733 True, I had forgotten that. Don't think it changes my opinion thought :-)
Comment: Are there any well-written expositions of the Novikov-Boone Theorem and its proof?
Comment: @Achilles I am afraid I don't know.
Answer: A natural answer to the question in your title is the Classification. This does not quite address what you ask in the body of the question, as it is a result strictly within finite group theory, but I believe it is important enough, and of a different nature than such basic pillars as the Sylow theorems or Lagrange, that it deserves some remarks. I address extensions to infinite group theory at the end.
Let me quote from a nice paper by Michael Aschbacher, one of the key figures in the classification effort. Particularly, note the second point. (Emphasis is mine.)

Conventional wisdom says the ideal mathematical proof should be short, simple and elegant. However, there are now examples of very long, complicated proofs, and as mathematics continues to mature, more examples are likely to appear.
I have some experience with one such effort: the Classification of the finite simple groups. [...] I'll begin by listing some features of the theorem and its proof. [...]
First, the proof of the Classification is very long and complicated. As a guess, the proof involves perhaps 10 000 pages in hundreds of papers, written by hundreds of mathematicians. [...]
Second, the theorem is very useful. One cannot do serious finite group theory without the Classification, and it has made possible numerous applications of finite group theory in other branches of mathematics. One can speculate that a proof of the complexity of the Classification would be unlikely to evolve in the absence of such strong incentives. One can also speculate that such theorems can only be proved via some kind of evolutionary process: the extent of the problem and possible paths to a solution only become visible after a large amount of preliminary investigation and experimentation.
Third, at first glance the Classification is a prototypical classification theorem. [...]
But also fourth, the collection $L$ of examples is large, varied, and of great interest, and each member has a rich structure. [...] [The] proof supplies a wealth of detailed information about the structure of members of $L$. Such information is a prerequisite for applying the Classification. Thus after a bit more thought, the Classification is more than just a 'classification theorem'.
Fifth, the proof is inductive and depends upon a good knowledge of the structure of members of $L$. [...]
Now I'd like to draw some implications from the example. I began with the observation that the ideal proof is short, simple, and elegant. The proof in our example has none of these desirable qualities. That hasn't stopped mathematicians from appealing to the theorem, but it does raise various questions.
First, because of the complexity of the proof and the absence of a definitive treatment in the literature, one can ask if the theorem has really been proved. After all, the probability of an error in the proof is one. Indeed, presumably any attempt to write down a proof of such a theorem must contain many mistakes. Human beings are not capable of writing up a 10 000 page argument which is entirely free of errors. Thus if we demand that our proofs be error free, then the Classification can't be proved via techniques currently available. [...]
By concensus [sic] of the community of group theorists, the Classification has been accepted as a theorem for roughly 25 years, despite the fact that, for at least part of that period, gaps in the proof were known to exist. At this point in time, all known gaps have been filled. [...]
I believe the Classification is an example of mathematics coming to grips with a complex information rich problem. [...]
[T]he utility of the theorem stems from two facts: First, it seems to be possible to reduce most questions about finite groups to questions about simple groups. Second, the
  explicit description of the groups on the list $L$ supplied by very effective representations of most of the groups, make it possible to obtain a vast amount of detailed information about the groups. [...]
My guess is that we will begin to encounter many more such problems, theorems, and proofs in the near future.

The paper is Highly complex proofs and implications of such proofs, Philos. Trans. R. Soc. Lond. Ser. A Math. Phys. Eng. Sci., 363 (1835), (2005), 2401–2406. MR2197656 (2006h:00004). It appeared on a volume on The nature of mathematical proof.
Finally, let me mention that there is ongoing work by model theorists to extend the results and techniques of (parts of) the classification to appropriate infinite settings, hoping that this will eventually prove similarly useful in certain contexts. Rather than studying arbitrary simple groups, the effort is currently centered on those simple groups that have finite Morley rank, a certain generalization of the idea of dimension. This finite dimensionality assumption has proved very fruitful in terms of lifting and generalizing techniques from the strictly finite setting.
Though many researchers are involved in this program, let me highlight Tuna Altınel, Alexandre V. Borovik, and Gregory Cherlin, who have co-authored a monograph on this topic, Simple groups of finite Morley rank, Mathematical Surveys and Monographs, 145. American Mathematical Society, Providence, RI, 2008. MR2400564 (2009a:20046).
This page has additional details on the goals of the program, and further references.
Answer: I quite like this very old question, and I think there is room for another answer.
I'll propose the theorem underlying Dehn's Algorithm as having one of the greatest impacts on infinite group theory:

Theorem: For $g \geq 2$, let $\Gamma_g$ be the fundamental group of a closed genus $g$ surface, with generators $S_g=\{a_1,b_1,\ldots,a_g,b_g\}$ and with defining relation $[a_1,b_1]\cdots[a_g,b_g]=1$. Let $w$ be a nontrivial reduced word in the generators $S_g$ such that $w$ represents the identity in $\Gamma_g$.  Then $w$ contains a subword $r_1$ of length $k \geq 2g+1$ such that there exists a word $r_2$ of length $4g-k$ with $r_1 r_2$ a cyclic permutation of $[a_1,b_1]\cdots[a_g,b_g]$.

Now that may sound technical, but here's the immediate point. Regarding Dehn's "Word Problem" which was addressed in the answer of @user1729, the theorem above represents Dehn's example of a positive solution to the Word Problem (just as the Novikov-Boone Theorem proposed by @user1729 represents a negative solution): applying that theorem immediately leads to an algorithmic solution of the word problem in $\Gamma_g$.
But beyond that, the method of proof used by Dehn, and in particular his use of the geometry of the hyperbolic plane, was the motivation behind a couple of tremendous explosions in the progress of infinite group theory.
The first, long wave of that explosion is represented by "combinatorial group theory" and associated work in "small cancellation theory". For example, Dehn's Algorithm has the simple corollary that the isoperimetric function or Dehn function of $\Gamma_g$ has a linear upper bound: the number of relators needed to prove that a word does or does not represent the identity is bounded above by a linear function of the word length. One way to think of small cancellation theory is that it was devoted to discovering broadly formulated, new conditions on groups under which nice upper bounds of the Dehn function could be derived.
A second explosion grew out of several works which would not have been possible without the groundwork laid by Dehn's algorithm and combinatorial group theory, those works being: Milnor's theorems on growth functions of groups, and Gromov's theorem on groups of polynomial growth which answered one of Milnor's questions; Stallings' ends theorem; and the Mostow rigidity theorems regarding lattices in semisimple Lie groups. What these things triggered was an explosive synthesis laid down by Gromov, represented by two closely related theories which have been burgeoning for the last 40 years: the theory of hyperbolic groups (and associated theories of nonpositively curved groups of various flavors); and the theory of quasi-isometric classification of finitely generated groups.
A third explosion, arising from Milnor's work mentioned above and therefore also part of the line of descent from Dehn's Algorithm, is Grigorchuk's example of a finitely generated group of intermediate growth, meaning growth that lies strictly between polynomial and exponential. This example led to many followup questions and associated theories, such as the theory of automata groups (not to be confused with automatic groups). This theory (and other ground breaking counterexamples) has also motivated the art of "constructions", which I think of as the use of ideas surrounding small cancellation theory and techniques developed by Grigorchuk, Rips, and others to construct new groups that confound expectations and break conjectures. There is also a certain overlap between this theory and the Novikov--Boone work mentioned in the answer of @user1729.
Comment: Nice answer! I like to think of the paper of Dehn where he proves this as the "start of geometric group theory" (as he states the 3 problems which bear his name and prove them for surface groups). Magnus then killed the theory off for 70 years...
Comment: Also, possibly it's worth mentioning the theory of one-relator groups (not on the same influence as some of the topics you mention, but intriguingly central none-the-less). Magnus was a student of Dehn, and I like to think of his PhD thesis, where he resolves of the word problem for one-relator groups, as the starting point of combinatorial group theory. His result was clearly influenced by Dehn, even if his proof was of a different flavour from Dehn's.


Adding default package imports

Question: In Java, Scala, or generally any JVM language, there is a set of packages that is imported by default. Java, for instance, automatically imports java.lang, you don't need to do it in your Java code file.
Now I don't know which component takes care of this exactly (the compiler? the JVM?), but is there any way to have additional packages or even classes imported by default?
Say you have a package defining a set of utility functions you use throughout your project (an example could be scala.math in Scala), it would be great if you were able to skip the import for it in every math related class.
Comment: Your latter point, in my opinion, should be a decision made by the project author. You could write books about that issue, so I'd like to put it aside here.

About your first point, true, any modern Java IDE can auto-resolve a class name and add an import. So this might be an issue related to Scala only. In Scala (2.8), you can have "package objects" that can define fields and methods on a package scope. You make those definitions visible as if they were defined in the class you're working in by importing the package (using the wildcard). No IDE supports that at this moment from what I know.
Comment: "it would be great if you were able to skip the import".  Why?  Modern IDEs have auto-complete and functions to add imports as needed.  Besides, imports are intended mostly to document the code for other programmers.  If the imports are missing, how is the programmer supposed to know that it uses 3rd arty classes?
Comment: @AndrewThompson, Boilerplate hindrance to my eyes = inefficiency.
Answer: Scala, as of 2.8, has package objects, the contents of which are automatically imported into every file of the package. Create a file called package.scala in the top level directory of your package (e.g., x/y/z/mypackage), and put into it
package x.y.z

package object mypackage {
  ...
}

Then any definition within the package object is automatically imported (i.e., no import statement is needed) into any file in package x.y.z.mypackage
You can take a look at the Scala sources -- do a find dir -name package.scala -- there are a bunch of them, the topmost defining the implicit imports for the scala package itself, which are automatically imported into every scala source file.
Comment: @VonC Saying +1 is nice, but actually uprating the answer would be even nicer. :-)
Comment: Good point. For any code within a given package, this is a good solution. +1
Comment: This works as long as you are working in one and the same package, I'm already making use of this. However, usually you work with package trees. Unfortunately, package objects can't be inherited and definitions inside a package object do not affect any sub packages. That would allow me to define a package object for the root package and everything would be fine. I hope this will be possible in the future.
Comment: @pdinklag You can, however, put imports into your package objects, giving you a form of manual inheritance.
Comment: Aha! That didn't get quite clear in your posting (IMO), would be good if you added it. In that case this is a great emulation indeed! Not quite the perfection I'm looking for yet ;) but the best that's within the possibilities.
Comment: @pdinklag Unfortunately it doesn't seem to work -- the import in the package object is apparently locally scoped, sigh.
Comment: @Jim Balter Got to unaccept then. So in all it looks like there is no cross-package way so far. I might file package object inheritance as an issue in the Scala tracker if it doesn't already exist.
Comment: @VonC Ok, thanks -- perhaps SO has some sort of delay, as I do not believe it was there when I posted that comment.
Answer: Jim Balter mentions in his answer (go upvote it) the Scala 2.8 package object.

Any kind of definition that you can put inside a class, you can also put at the top level of a package. If you have some helper method you'd like to be in scope for an entire package, go ahead and put it right at the top level of the package.
To do so, put the definitions in a package object. Each package is allowed to have one package object

Scala actually has its own scala package object.
See "Where to put package objects".
So package object can solve the problem of explicit import for a given package, but not for any package.
Its current limitations include:

First, you cannot define or inherit overloaded methods in package objects.
Second, you cannot define or inherit a member in a package object which is also the name of a top-level class or object in same package.

We expect that some future Scala release will drop these restrictions.

Original answer:
On the Scala side, a question like "should Scala import scala.collection.JavaConversions._ by default?" shows that you cannot just add default imports as a Scala user.
It has to be supported by the language.
By the way, the conclusion was:

From a Scala expert perspective: Let's keep things simple and limit the implicits that are imported by default to the absolute minimum.
Heiko Seeberger

Raphael does comment though:

I guess you could write your own compiler plugin to add some packages?

And sure enough, this Scala article describe how to extend the Scala compiler.
But the main additions supported are:

You can add a phase to the compiler, thus adding extra checks or extra tree rewrites that apply after type checking has finished.
You can tell the compiler type-checking information about an annotation that is intended to be applied to types.

So even with a tree rewrite (including additional imports), I am not sure said rewrite would be done in time for the types and functions (referenced by the implicit imports you are asking for) can be correctly analyzed.
But maybe the Scala Compiler Corner has more ideas on that.
Comment: I guess you could write your own compiler plugin to add some packages?
Comment: Things have changed in Scala 2.8; see my answer.
Answer: The default import of all classes from java.lang is specified in the Java language Specification (7.5.5)
All other classes have to be import with the import statement.
Answer: In Java there is not a way to do that.
Comment: A large number of imports indicates your class is probably doing too much and should be refactored.  Hiding the imports somehow would hide that issue.
Comment: I understand that this is comprehensibility vs coding efficiency, and that the Java philosophy tries to maintain a good comprehensibility of code (which, IMO, it fails at in several ways, but that's not the matter at hand), but for my project I chose coding efficiency (which is also why I prefer Scala over Java), and a feature like this would make life a lot easier for me. You're supposed to stuff functions in appropriately named classes, and the reward for doing so is having to import tons of packages and classes everywhere they are needed - not too nice IMO.
Comment: @pdinklag Please see my answer; Scala has the feature you're looking for.

Adding default package imports


Tabela Dinâmica com Ajax e JSP

Question: Estou aprendendo Java Web e gostaria de saber se poderiam me ajudar no seguinte: Possuo um formulário que insiro dados no banco, e embaixo dele uma tabela no qual realizo a listagem do que foi inserido no banco, porém o que acontece é o seguinte, estou tentando inserir um dado no banco por esse campo, só que queria que a linha da tabela atualizasse de maneira assíncrona. Alguém poderia ajudar?
Esse código só está enviando uma mensagem como resposta pois tinha tentado outras maneiras e como baguncei resolvi deixar assim mesmo por enquanto.
Index.jsp:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

        <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>

        <title>JSP</title>

Texto

            <form action="TextoServlet" method="post" onsubmit="return salvar()">

                    Descrição:
                    <input id="nome" type="text" name="descricao">
                    <button class="btn btn-default" type="submit">
                        Salvar
                    </button>

            </form>

            <jsp:useBean id="dao" class="modelo.TextoDAO"></jsp:useBean>

                Aqui está aparecendo a mensagem!

                        Codigo
                        Descricao
                        Alterar
                        Excluir

                    <c:forEach var="txt" items="${dao.listar}">

                            ${txt.codigo}
                            ${txt.descricao}
                            <button>Alterar</button>
                            <button>Deletar</button>

                    </c:forEach>

E aqui está o Servlet:
package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import modelo.Texto;
import modelo.TextoDAO;

public class TextoServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        String acao = request.getParameter("acao");
        String codigo = request.getParameter("codigo");
        if (acao.equals("excluir")) {
            TextoDAO texto = new TextoDAO();
            int cod = Integer.parseInt(codigo);
            try {
                texto.excluir(cod);

            } catch (Exception ex) {
                out.print("Excluido");
            }
        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        //objeto acima para escrever na tela

        String descricao = request.getParameter("descricao");

        try {

            if (!descricao.equals("") && descricao != null) {
                Texto texto = new Texto();
                texto.setDescricao(descricao);
                TextoDAO dao = new TextoDAO();
                dao.salvar(texto);
                out.print("
Salvo com Sucesso!
");

            }
            else {
                out.print("
Preencha o campo corretamente!
");

            }

        } catch (Exception e) {
            out.print("
Erro ao salvar Texto
");
        }

    }

}

Comment: Poderia inserir na pergunta o código que você já implementou?
Comment: Não sei se mandei da maneira certa mas está ai
Answer: Você ja pensou em usar Ajax? Eu passei pelo mesmo problema e com Ajax consegui resolver a questão da chamada assíncrona.
Recomendo o uso do Ajax com jquery.
Segue uma ótima referencia do uso de Ajax com Servlets:

https://stackoverflow.com/questions/4112686/how-to-use-servlets-and-ajax
Comment: Vou dar Uma olhada Muito obrigado!

Tabela Dinâmica com Ajax e JSP


Multiple Surveys and Confidence Interval

Question: Hello and i please need some assistance.  Every week I send out a survey request to 1,000 customers rating service from 1-10.  Each week only 20% respond.  Each week I report on the average.  Because this is a sample, shouldn't I also report the margin of error?
Follow up.  Instead of reporting weekly, i sum all of the surveys for every week and report the results.  This would change the margin of error calculation.  Does that violate any principals? That feels incorrect as I am running weekly surveys.
Comment: Is it possible that you have responses from some customers in several different weeks. At the extreme, could a customer respond every week? If so, you can't combine results from several weeks without violating the random sampling assumption. // The margin of error might be different from week to week because of different customers, various seasons, changing economic environment, etc.
Comment: Yes, there is repeated surveying of individual customers.  Fantastic point @BruceET.  To confirm, margin of error reporting on a weekly basis is appropriate, right?  I'm being told it isn't needed because all the weekly surveys add up to a large sample for the year.  That doesn't feel accurate.
Answer: I agree that suitable reports of the (estimated) margin
of error for relevant 95% CIs could be useful. The
difficulty is that it is not clear which of several
methods one would use for the margin of error.
First, the margin of error of a confidence interval for
a binomial success probability $p$ based on $n$ observations depends on both $p$ and $n.$
Consider $n = 100$ Bernoulli trials with $x = 5$ successes. Then the estimated SE 0f estimate $\hat p = 2/n$ of $p$ is $\sqrt{\hat p(1-\hat p)/n}.$
Specifically, the margin of error is $1.96\sqrt{\hat p(1-\hat p)/n} = 0.0427,$ so that a 95% Wald confidence interval for $p$ is of the form $\hat p \pm 1.96\sqrt{\hat p(1-\hat p)/n}.$
p.hat = 5/100; n = 100
1.96*sqrt(p.hat*(1-p.hat)/n)
0.04271721

Of course, if $n = 100$ remains the same and $p$ is larger, then one might expect a larger $x$ which would change the margin of error. Specifically, with, $x = 50, n = 100$ the estimated margin of error for the Wald interval would
be $0.098.$
p.hat = 50/100; n = 100
1.96*sqrt(p.hat*(1-p.hat)/n)
[1] 0.098

So, you might be reporting a different Wald margin of error
for each week, depending on the number of respondents and
the number invited to take the poll.
Another complicating issue is that
many different styles of confidence intervals are
in common use. Some are based on
normal approximations and some are not.
For an Agresti-Cooil 95% CI, which is more accurate than the Wald CI for
smaller $n,$ one uses point estimate $\tilde p = (x+2)/(n+4)$
and margin of error $1.96\sqrt{\tilde p(1-\tilde p)/(n+4)} = 0.0482.$
p.est = 7/104
1.96*sqrt(p.est*(1-p.est)/(n+4))
[1] 0.04815495

Also, various styles of CIs are programmed into different
binomial tests in R and in other statistical software.
With $x = 5, n = 100,$ the R procedure prop.test (which essentially uses a normal approximation) would
give the 95% CI $(0.022, 0.112),$ with implied margin of error
$0.045.$ That is, any estimate of $p$ in this CI would
not lead to rejecting $H_0: p = 0.05.$
prop.test(5, 100, p=.05)$conf.int
[1] 0.02154368 0.11175047
attr(,"conf.level")
[1] 0.95

By contrast, the R procedure binom.test uses an exact binomial distribution instead of a normal approximation.
It's associated 95% CI is wider to make sure of 95%
coverage probability for any value of $p.$ Because this
interval is not centered at $0.05,$ it is difficult to say what margin of error is implied.
binom.test(5, 100, p=.5)$conf.int
[1] 0.01643188 0.11283491
attr(,"conf.level")
[1] 0.95

In conclusion, I'm not saying that the task of providing an idea of the
margin of error for the CIs you report is so impossibly difficult that you should abandon the idea. However,
it does require you to understand the style of 95% CI
you are using, and the statistical sophistication of
the audience for the document in which such 'margins of error'
are to be reported.
At the very least, you might start by rounding the reported CIs so that there is no false indication of accuracy.
For example, report something like $(0.02, 0.11),$
instead of something like
$(0.0164, 0.1128).$
Comment: If you found this answer helpful, then please consider
[upvoting](https://stats.stackexchange.com/help/why-vote)
and/or
[accepting](https://stats.stackexchange.com/help/accepted-answer)
it.
Comment: @BruceET, your thorough response is so appreciative.


nginx - The page you are looking for is temporarily unavailable

Question: my site is responding me The page you are looking for is temporarily unavailable.
Please try again later.
Any ideas what I did wrong? Thank you.
This config is working on another site, but not this one. I don't know why.
    server {
                listen   80; ## listen for ipv4; this line is default and implied

                root /var/www/vhosts/site.com;
                index index.php index.html index.htm;

                # Make site accessible from http://localhost/
                server_name server.com;

                error_log /var/log/nginx/err.com.error.log;

                ## Compression
                gzip              on;
                gzip_buffers      16 8k;
                gzip_comp_level   4;
                gzip_http_version 1.0;
                gzip_min_length   1280;
                gzip_types        text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript im$
                gzip_vary         on;

                add_header Access-Control-Allow-Origin *;

                location / {
                        # if you're just using wordpress and don't want extra rewrites
                        # then replace the word @rewrites with /index.php
                        # try_files $uri $uri/ @rewrites;
                        try_files $uri $uri/ /index.php?$args;
                }

                # Allow access to root index.php
#        location ~ ^/index\.php {
        location ~ \.php {
                include     fastcgi_params;
#                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass    127.0.0.1:9000;
                fastcgi_index   index.php;
#                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

        location ~* \.(jpg|jpeg|gif|css|png|js|ico|html|pdf|xlsx|xls|docx|doc|zip|rar)$ {
                 access_log off;
                 expires max;
        }

        #
        # 404 error page
        #
        error_page 404 /404.html;

        #
        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
               root /usr/share/nginx/www;
        }

        location ~ /\.ht {
                deny all;
        }
}

Comment: Sorry for disturbing, I've just solved it. Uncommented fastcgi_split and fastcgi_param so it's solved now.
Comment: Share access and error log first of all please.
Answer: Wrong fastcgi_pass :) I just had to change it to 127.0.0.1:9000
Comment: It would be a better answer if you would've include some more details about how you changed it


HTML5 validation before ajax submit

Question: This should be simple, yet it's driving me crazy. I have an html5 form that I am submitting with ajax. If you enter an invalid value, there is a popup response that tells you so. How can I check that the entries are valid before I run my ajax submit?
form:
<form id="contactForm" onsubmit="return false;">
  Name:
  <input type="text" name="name" id="name" required placeholder="Name" />
  Subject:
  <input type="text" name="subject" id="subject" required placeholder="Subject" />
  Email:
  <input type="email" name="email" id="email" required placeholder="firstname.lastname@example.com" />
  Message:
  <textarea name="message" id="message" required></textarea>
  <input type="submit" id="submit"/>
</form>

submit:
$('#submit').click(function(){
    var name = $("input#name").val();
    var subject = $("input#subject").val();
    var email = $("input#email").val();
    var message = $("input#message").val();

    var dataString = 'email=' + email + '&message=' + message + '&subject=' + subject + '&name=' + name ;

    $.ajax({
        url: "scripts/mail.php",
        type:   'POST',
        data: dataString,
        success: function(msg){
            disablePopupContact();
            $("#popupMessageSent").css("visibility", "visible");
        },
        error: function() {
            alert("Bad submit");
        }
    });
});

Answer: If you bind to the submit event instead of click it will only fire if it passes the HTML5 validation.
It is best practice to cache your jQuery selectors in variables if you use it multiple times so you don't have to navigate the DOM each time you access an element. jQuery also provides a .serialize() function that will handle the form data parsing for you.
var $contactForm = $('#contactForm');

$contactForm.on('submit', function(ev){
    ev.preventDefault();

    $.ajax({
        url: "scripts/mail.php",
        type:   'POST',
        data: $contactForm.serialize(),
        success: function(msg){
            disablePopupContact();
            $("#popupMessageSent").css("visibility", "visible");
        },
        error: function() {
            alert("Bad submit");
        }
    });
});

Comment: This should be the accepted answer as HTML5 validations are triggered before submit event. Basically, listening on submit event, then preventing default action should do the job. There is no need to invoke the checkValidity() method as shown in accepted answer because if HTML5 validations don't pass, submit event will not be triggered.
Comment: Despite what your saying, it get's fired without any kind of validation. Part of my code:  $('#begininstall').on('click',function(){
      $('#formbegininstall').submit();
    });

    $('#formbegininstall').on('submit',function(ev){
      ev.preventDefault();
      var serializado = $('#formbegininstall').serialize();
      $.ajax({
Comment: I can't edit my previous answer. My problem was I was using a link to submit ajax. All I had to do was replace the link by a submit button.
Answer: By default, jQuery doesn't know anything about the HTML5 validation, so you'd have to do something like:
$('#submit').click(function(){
    if($("form")[0].checkValidity()) {
        //your form execution code
    }else console.log("invalid form");
});

Comment: Returning false (preventing default action)... See the answer from csbarnes which is more accurate.
Comment: `return false` on submit event, as done by OP, is what I was looking for..
Comment: This works, but the minor problem I see with this is that it don't show the pop ups of the elements with the required attribute.
Answer: If you are using HTML5 form validation you'll have to send the ajax request in the form's submit handler. The submit handler will only trigger if the form validates. What you're using is a button click handler which will always trigger because it has no association with form validation. NOTE: not all browsers support html5 form validation.
Answer: I prefer using the jQuery submit handler, you will still get the response to your form with the following method.
jQuery('#contactForm').on('submit', function (e) {
    if (document.getElementById("contactForm").checkValidity()) {
        e.preventDefault();
        jQuery.ajax({
            url: '/some/url',
            method: 'POST',
            data: jQuery('#contactForm').serialize(),
            success: function (response) {
                //do stuff with response
            }
        })
    }
    return true;
});

Answer: Not exactly sure what you mean. But I assume that you want to check in realtime if the input is valid. If so you should use .keyup instead of .click event, because this would lead to an action if the user presses submit. Look at http://api.jquery.com/keyup/
With this you could check the input with every new character insert and display e.g. "not valid" until your validation ist true.
I hope this answers your question!
Answer: U can also use jquery validate method to validate form like
$("#form id").validate();
which return boolean value based on form validation  & also u can see the error in log using errorList method.
for use above functionality u must include jquery.validate.js file in your script

HTML5 validation before ajax submit


Superfish menu is not responsive for mobile screens

Question: i'm using drupal 7 and superfish 7.x-1.9, the problem is when i reduce the browser, the menu is not responsive, it still be the same nothing moves, i'm working on it for hours now and nothing
Please any help on configurations ?
Here a screenshot of the desktop menu :

And here the same menu with browser reduced on width :
Comment: Hide it for mobile and show a mobile menu for mobile
Comment: @J.Reynolds This is exactly what i want to do(keeping the desktop and hide it for mobile AND create a second menu for mobile that is hidden on desktop), but superfish is supposed to be responsive by default, but not for the menu i've created
Comment: I don't see anything in the documentation about it being responsive. When I used it in the past I made the text and padding smaller at various breakpoints, then hid it completely at mobile breakpoint. Looj here for alternative: https://www.drupal.org/project/responsive_dropdown_menus
Comment: Yes I see @J.Reynolds but from the superfish 2.0 the menu is responsive, so for my version i'm gonna work with custom breakpoints as you said
Answer: Superfish has a pretty extensive settings/configuration area, all of which, do take away any necessary programming for menus, and make setting up a complex menu simple.
You are probably missing a mobile declaration somewhere in the settings/config, I would read up on the Superfish documentation here: https://www.drupal.org/node/754652
This also has other useful links that may assist with your situation.


What is the valuation between different starting positions in auto racing?

Question: I see this question broadly discusses the worth of Pole position in NASCAR, but I wondered if any more of a full mathematical analysis had been performed to determine the "marginal gain" of each position, and how it differs between various auto series?
It would be nice to know if all these long qualifying days are really significant for teams, or whether they can do well by putting their attention on race day.  Certainly there are a few different "chicken-egg" arguments possible [does a better position lead to an easier race, or does a better position show a better car making a good result more likely] (which could be considered in future questions), but the results of starting position would seem important for any scientific mind interested in maximizing their sport viewing time!
In lieu of a deeper data, at least statistics on the average finishing position by starting position would be interesting.
Comment: In F1 the significance varies depending on the track.  For example at Monaco it is almost impossible to overtake whilst at a track like Shanghai it is relatively easy due to the length of the main straight.
Comment: Through looking around, I came upon http://racing-reference.info/wc.htm data.  That looks promising... perhaps just a simple graph of average result (and standard deviation bars?) on the y and starting position on the x, done over like 5 or 10 years would say a lot.  Or a scatter plot, using percentile in field for the positions, to make different size fields more comparable.  Just wondered if anyone knows of similar work out there before any work to reinvent the wheel.
Answer: I don't think you will ever find a definitive answer for this, as it varies so much from venue to venue and series to series, not to mention external factors (weather etc.) play just as big a role. However, qualifying is certainly important, and I will explain why below.
Firstly, let's look at the factors influencing the importance of starting position;

The race distance - At F1 tracks, the grid positions are separated by 8 metres. Therefore, starting 20th compared with 1st is a distance disadvantage of 152 metres. If the race is just one lap, this disadvantage is of course going to be tougher to overcome than in a 24 hour race - the initial disadvantage will make up a greater percentage of the overall race distance on a shorter race. Of course, the grid separation and start procedure (rolling start vs. standing start) also have an effect on determining the initial distance disadvantage.
The number of cars - The more cars, the greater the initial distance disadvantage. Likewise, more cars means more cars to overtake, and generally you will lost time battling for positions, so the more cars you have to battle with the greater the disadvantage.
Ease of overtaking - In F1 at Monaco for example, it is very difficult to overtake, so the advantage of starting on pole is generally far greater than Nascar for example.
How closely matched the competitors are - If for example you qualify 20th and the lap time difference between 15th and 1st is 1.5 seconds, then you will lose 1.5 seconds for each lap you are stuck trying to get past 15th place. If however, the difference is just 0.05 seconds, then of course the time loss getting through the field is going to be far less.

However, there are also several other external factors that can impact the importance of qualifying positions, and these are far more unpredictable;

The weather - One critical thing regarding the weather is the wind - both its speed and direction. If for example there is a strong headwind on the main straight, then the effect of the slipstream will be greatly increased, putting the lead driver at a disadvantage and the following drivers at more of an advantage.
Safety cars - If a safety car is deployed, the field close up. Therefore, a driver may have qualified last and lost 30 seconds to the leader battling through to 2nd. However, if a safety car is deployed near the end of the race, this driver is now merely tenths of a second behind the overall leader. In this scenario, the disadvantages of starting lower down the order no longer have such a significant impact on the race result.
The rules of the competition - In F1 for example, the rules several years ago were that the cars could not refuel from qualifying to the race. Therefore, a car may qualify on a heavier fuel load, thereby meaning they are slower and qualify lower down the order. However, this may be the optimum race strategy. Therefore, starting a few positions further back will be less important than gaining time later on in the race when the strategy pays off.

Therefore, in answer to your question, there are several factors which play a role in determining how important qualifying is. However, even if all of the factors mentioned above play out to the disadvantage of the leader, the optimum position to be in the race would still probably be no lower than 3rd or 4th, with the perfect time to take the lead being on the last lap (in some cases the final corner).
For the purposes of an example, let's take 3rd place as being the optimum position on the final lap. You then have to consider how the driver can make sure they are in this optimum position at the right time. This is made much easier by qualifying higher up - the leader simply has to slow down and let two drivers by at the right time to get into the optimum position. Whereas a driver qualifying lower down the order has to overtake drivers to get into this optimum position. Of course, you could argue the driver in the best position is the one who qualified 3rd, as they can try to maintain the optimum position for the entire race. However, in most circumstances, it would be extremely difficult to judge their qualifying lap such that they drive fast enough to qualify 3rd, but slow enough not to qualify on pole or 2nd.
Even if you are in the optimum position at the right time, this is still just theoretically the best position and it would be reliant on the driver making the most of this opportunity - if they mess it up, they won't get another chance given it is the last lap and possibly last corner. Therefore, in most circumstances, drivers would probably still prefer to be out in front, unless the advantage of being behind is extremely significant.
Another thing to factor in as well is that qualifying further back puts you at greater risk of being caught up in accidents, particularly first lap incidents.
In conclusion, qualifying is always important in making the race easier. Depending on the circumstances, qualifying may be more or less important, and sometimes being the leader isn't the optimum place to be. However, the optimum place to be is almost always somewhere very near the front of the field, and the simplest way to ensure you are at or near this optimum position is to qualify as far up the order as possible. However, there are an awful lot of factors that are as important, if not more so, than qualifying, and that is what makes motor-sport unpredictable and exciting.
Comment: Another factor is that, generally speaking, one side of the grid will be on the racing line and therefore have more grip than the other side, giving them a better start. Pole position at Suzuka used to be off the racing line, so the driver in 2nd actually had the advantage at the start.


How do you migrate a site with Drupal 7 Image Styles and make sure the adjusted images migrate?

Question: I am moving a D7 site from local to staging for the first time. I pushed my codebase through deployment, and I did drush sql-dump to get the database moved over. Then I copied the files directory as-is.
The new server site works perfectly -- except that images that are supposed to be generated by the image styles show up as broken. They're not being dynamically generated like they should, even though the styles themselves are there.
Any thoughts on why this would happen or how to debug it?
Answer: Turns out I was trying to run deployment with my files directory outside of the Drupal root, and even though I was relatively pointing to the right path, it just didn't like that. So I symlinked sites/default/files to the folder outside of the Drupal root and it works fine now.
Answer: In general using the Features module is the best way to push configuration changes like "Image Styles" from dev to production: http://drupal.org/project/features . Yours is a different use case since you are pushing the entire database.
There is no "good" reason why the Image Styles shouldn't work on your new server. I would check to make sure that the file permissions on your production server are setup correctly. See: http://drupal.org/node/244924
Even if "sites/default/files" is given the proper permissions "sites/default/files/styles" might not have the proper permissions. You can check that the Image Style settings for your server are working correctly by visiting "/admin/config/media/image-styles/edit/thumbnail". If a style is not being generated there is an issue with your server setup.
Are you using 'GD2' or 'ImageMagic' and what version of PHP are you using to resize your images? These are PHP libraries that Drupal needs (1 of them has to be installed) to resize images.  If you visit 'admin/reports/status' you should be able to see if one or both are installed correctly.


What is the practical impact or use of a dodecagram?

Question: Looking for an answer about modulation and affects I came across with the term "dodecagram".
So I was interested whether this has been already asked here, as I think it would be quite useful but I wonder how? Does it represent more than the simple keyboard pattern of the 12 keys and the circle of fifths as we know it? Do I miss something, or does it just look nice?
Answer: The only added feature that I can see is the use of color.
The colors tend to be organized by proximity around a given key. C major, which is something like pink/red, is thus most closely aligned with G (pink/orange) and F (red/magenta). The further the two keys, the further their colors are.
To help visualize this, consult a color wheel:

We see that red is farthest from green, and sure enough, as opposites to the red of C and F, we have keys like F♯, B, and E.
Comment: I didn't see the colors, interesting.
Answer: The I, IV, and V chords for any given key are connected by the lines here. Although it's a little misleading. For example, the key of D major the I, IV, and V are D, A, and G (all major). You can see that D is connected by these lines to A and G. But this connection sort of looks like you would start on D and D, G and C. When in fact it's D, A, G. So you would change this to be closed isosceles triangles between the DAG to we that more clearly.
However the DGC connect does show perfect fifths. In fact, you can easily derive the circle of fifths from this picture by starting on B, beadgcf.
This image shows the order of the notes, the circle of 5ths and the I,IV, V (if you look at it the right way).
There's probably a lot more hidden on here. It's just counting by 4s or 5s or 3s repeated.
There is another way of drawing this where you get perfect 4ths and 4 cool overlapping triangles, but it's not as meaningful.
Finally if you use the top and number it 0 and go to 11, you can use clock math to know all the notes on a fretboard. For example, A is 0, F is 8, so the 8th fret of the A string will be F.
Comment: 1) Be aware that this question is ca 2 years old, and I think the OP understood how it's meant to work, and was asking "what's the point." 2) I think, when you say "it's misleading," you're mistaking what the chart is trying to do. It's not trying to help you move from IV to V, just to show the IV and the V of each I. 3) *"I, IV, and V are D, A, and G"* I think you meant to say "D, G, A"


Can Wishart be close to Normal distribution?

Question: I'm trying to figure out if Wishart can be close to Normal for a number of degrees of freedom enough large.
About chi-squared distribution, Wikipedia states:
<code>By the central limit theorem, because the chi-squared distribution is the sum of k
independent random variables with finite mean and variance, it converges to a normal
distribution for large k. For many practical purposes, for k > 50 the distribution is
sufficiently close to a normal distribution for the difference to be ignored.
</code>
Since Wishart is presented as a generalization to multiple dimensions of the chi-squared distribution, is there a similar property?
Answer: The Wishart distribution (when dimension is 2 or higher) is a distribution on a space of matrices, if the underlying space had dimension $d$, the space of symmetric positive matrices $d \times d$ has dimension $d(d+1)/2$, so for approximating Wishart by a normal you would need a normal of that dimension which in addition fulfills the (non-linear) conditions necessary to be a positive definite matrix. That doesn't sound like being possible, so I believe the answer to your question is NO.
Answer: According to the Multivariate Normal Central Limit theorem, it will be close to Multivariate Normal DIstribution. Check section 2 of the paper by Anderson.


FTP Spring Integration with Inbound Streaming Channel Adapter

Question: I am using spring-integration with ftp. When i use int-ftp:inbound-channel-adapter, then it is working fine, but int-ftp:inbound-streaming-channel-adapter yields the following error:
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'int-ftp:inbound-streaming-channel-adapter
What could I be missing?
The relevant portion of my code is
<int-ftp:inbound-streaming-channel-adapter id="ftpInbound"
         channel="ftpChannel"
         session-factory="ftpClientFactory"
         filename-pattern="*.txt"
         filename-regex=".*\.txt"
         filter="customFilter"
         remote-file-separator="/"
         comparator="comparator"
         remote-directory-expression="'/OUT/SDI402_CARATT_JD'">
     <int:poller fixed-rate="1000" />
 </int-ftp:inbound-streaming-channel-adapter>

Comment: I have cleaned up the question, but a sample of your code will be very useful in answering your question.
Comment: I fixed the code tags, for code use four spaces. You were adding spoiler tags :)
Comment: did you ever resolve this? if so what was the solution?
Comment: i  used version 4.3.7.RELEASE of spring-integration-ftp. then it start working fine.
Answer: Use in your dependencies spring integration 4.3.1.RELEASE. That solved the exact same problem in my case.
Comment: i am using the following pom entry but still i am getting the error.
org.springframework.integration
spring-integration-core
4.3.1.RELEASE
Comment: in xml, i am using the following URL
            http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd. i didnt see any folder with ftp name, may be because of this we are getting error


Risk function or expected loss function

Question: I was going through the following text and actually i could not resources to understand the same online.
If anyone could explain or point me out to any resource to understand the same that would be helpful.

To get Risk function corresponding to loss function ; its is multiplied to PMF (I am not sure, i could be wrong.)
Why is that multiplied.
And in the formula why are we integrating w.r.t dy?
PS: Explanation or any resource explaining the formula would be helpful.
Comment: Can you explain this maybe with a concrete example? It's not really sinking in. [![expected risk function](https://i.stack.imgur.com/Zw4Gc.png)](https://i.stack.imgur.com/Zw4Gc.png) Given a fixed theta, integrate over the probability density function f(x) to compute the risk.
Comment: @bottledatthesource please do not use answers for asking questions. If you have a question, post it as a question.
Answer: The risk function is the expected loss. In your case the loss function is a random variable that depends on the variable you want to predict (target variable) $Y \in \mathcal{Y}$ and on some function $f(\cdot)$ of the random variable $X \in \mathcal{X}$ (the data you may observe). You are dealing with uncertainty on the realization of both $Y$ and of $X$.
For continuous random variables to compute the expectation of $L(Y,f(X))$ you need the joint density function of $(X,Y)$, hence the expectation is
$
E[L(Y,f(X))] = \int_{\mathcal{X}}\int_{\mathcal{Y}} L(y,f(x)) p(x,y) dy dx
$
where the notation is simplified as $\int L(y,f(x)) p(x,y) dy dx$.

Risk function or expected loss function


Windows Backup failed as another backup or recovery is in progress

Question: i have set up backup schedule on our server. SQL Server 2008 to 01:00am on windows server 2008 R2 to 4:00am. Sql backup runs well, but system backup ends sometimes with error.

The error is : http://technet.microsoft.com/en-us/library/dd364768%28WS.10%29.aspx
I mean, that is caused by SQL Server, because it unexpectedly runs backup.
this is from sql server log (it runs for every database):

Date      4.2.2010 4:00:21 Log        SQL Server
  (Current - 29.1.2010 23:25:00)
Source        spid72
Message I/O is frozen on database
  master. No user action is required.
  However, if I/O is not resumed
  promptly, you could cancel the backup.

and

Date      4.2.2010 4:00:24 Log        SQL Server
  (Current - 29.1.2010 23:25:00)
Source        Backup
Message Database backed up. Database:
  master, creation date(time):
  2010/01/29(23:25:32), pages dumped:
  370, first LSN: 859:56:37, last LSN:
  859:80:1, number of dump devices: 1,
  device information: (FILE=1,
  TYPE=VIRTUAL_DEVICE:
  {'{17B91D5C-9968-4D11-A7F1-1A31523D32F0}25'}).
  This is an informational message only.
  No user action is required.

My questions is:
Why runs sql backup with windows backup?
How can i dissolve this that errors?
Thank you a lot.
Answer: did you exclude SQL servers data file from the backup ? Else Windows backup will try to backup them through VSS
How do you backup SQL server ? SQL dumps ?
Comment: i turned off sql vss writer and it didnt help. Backup operation succeded, but it logs still the same error:  The backup operation that started at '2010-02-10T03:00:14.895304600Z' has failed because another backup or recovery operation is in progress.
Comment: No, i haven't exclude anything. There is configured maintanence plan on SQL server for backup.
Comment: As you are doing SQL backup through Maintenance plan, SQL data files must be excluded from the windows backup
Comment: i have database files on system drive and if i want to exclude folders with sql databases, i cannot use bare metal recovery.  doesn't exist another solution? thanks
Comment: poor way: disable the SQL VSS writer through vssadmin, files will be locked and so skipped. I will do some tests to see how to do that the right way


Ruby Koans: Why convert list of symbols to strings

Question: I'm referring to this test in about_symbols.rb in Ruby Koans
https://github.com/edgecase/ruby_koans/blob/master/src/about_symbols.rb#L26
def test_method_names_become_symbols
  symbols_as_strings = Symbol.all_symbols.map { |x| x.to_s }
  assert_equal true, symbols_as_strings.include?("test_method_names_become_symbols")
end

  # THINK ABOUT IT:
  #
  # Why do we convert the list of symbols to strings and then compare
  # against the string value rather than against symbols?

Why exactly do we have to convert that list into strings first?
Answer: This has to do with how symbols work.  For each symbol, only one of it actually exists.  Behind the scenes, a symbol is just a number referred to by a name (starting with a colon).  Thus, when comparing the equality of two symbols, you're comparing object identity and not the content of the identifier that refers to this symbol.
If you were to do the simple test :test == "test", it will be false.  So, if you were to gather all of the symbols defined thus far into an array, you would need to convert them to strings first before comparing them.  You can't do this the opposite way (convert the string you want to compare into a symbol first) because doing that would create the single instance of that symbol and "pollute" your list with the symbol you're testing for existence.
This is a bit of an odd one, because you have to test for the presence of a symbol without accidentally creating that symbol during the test.  You usually don't see code like that.
Comment: That still has the problem of creating the symbol which can't be destroyed.  Any future tests for that symbol will be ruined.  But this is just a Koan, it doesn't have to make much sense or be fast, just demonstrate how symbols work.
Comment: Isaac, because of the issue identified, which is that specifying `:test_method_names_become_symbols` in the comparison will create it, so the comparison will always be true. By converting `all_symbols` to strings and comparing strings, we can distinguish whether the symbol existed prior to the comparison.
Comment: Note that a better way of doing this safely is to assign the output of `Symbol.all_symbols` to a variable, then test for inclusion. Symbols are faster at comparison, and you're avoiding converting thousands of symbols into strings.
Comment: So much I don't understand. If I do >> array_of_symbols=Symbol.all_symbols, then >> array_of_symbols.include?(:not_yet_used), I get false, and I get true for something that was defined, so I don't understand why the conversion to strings is necesary.
Comment: This answer doesn't work for me. If we're searching for existence of a symbol, why are we specifying a string argument to ``include?`` If we specified ``:test_method_names_become_symbols`` we wouldn't have to convert all those symbols to strings.
Comment: @codenoob : Yes you are correct and we can compare symbols like that. But if you ran Symbols.all_symbols again, you ll see :not_yet_used being created. so the point is if we tried to check the symbols directly without using temp variable, then it ll always be true
Comment: @Stephen wouldnt the array from `Symbols.all_symbols` be an older array, which wouldnt contain that symbol? since that symbol would have been created after the array was created? Or is that function returning a reference to the main array and not a copy? Or is it an order of evaluation thing? or implementation dependant?
Comment: @KarthikT Yep, I believe the symbol is being evaluated before the include? method is being invoked (eager/strict evaluation).
Comment: What I took from the koan and this discussion is that we want to avoid introducing _anything_ in tests that might invalidate other tests. The purpose of the test is to check the output of your code, not artifacts from other tests. Creating symbols in a test pollutes all_symbols; it's no longer a valid representation of the code you are testing. Ergo, it's better practice to use string comparisons when testing for the existence of symbols.
Answer: Because if you do:
assert_equal true, all_symbols.include?(:test_method_names_become_symbols)

It may (depending on your ruby implementation) automatically be true, because :test_method_names_become_symbols creates the symbol. See this bug report.
Comment: Isaac, the other answer isn't wrong but it's not explained as concisely. for sure. Anyway, you can verify what Andrew's saying with the following:

assert_equal true, Symbol.all_symbols.include?(:abcdef)

This will always pass (at least, it does for me) regardless of the symbol. I guess one lesson is, don't try to use the presence/absence of symbols as a boolean flag.
Comment: So the accepted answer is the wrong one (or so it seems to me).
Comment: Looking at this question, which still interests me, 2 years later, I really appreciate this answer, and the comments. I think Isaac is right this is the answer most clearly explaining why the conversion to strings may be the way to go, though I think you could put the intermediary step (store all the symbols before the compar) in to make it work better.
Comment: WOW, that's deep!
Answer: Both answers above are correct, but in light of Karthik's question above I thought I would post a test that illustrates how one might accurately pass a symbol to the include method
def test_you_create_a_new_symbol_in_the_test
  array_of_symbols = []
  array_of_symbols << Symbol.all_symbols
  all_symbols = Symbol.all_symbols.map {|x| x}
  assert_equal false, array_of_symbols.include?(:this_should_not_be_in_the_symbols_collection)  #this works because we stored all symbols in an array before creating the symbol :this_should_not_be_in_the_symbols_collection in the test
  assert_equal true, all_symbols.include?(:this_also_should_not_be_in_the_symbols_collection) #This is the case noted in previous answers...here we've created a new symbol (:this_also_should_not_be_in_the_symbols_collection) in the test and then mapped all the symbols for comparison. Since we created the symbol before querying all_symbols, this test passes.
end

An additional note about the Koans:  make use of puts statements as well as custom tests if you don't understand anything. For instance, if you see:
string = "the:rain:in:spain"
words = string.split(/:/)

and have no idea what words might be, add the line
puts words

and run rake at the command line. Likewise, tests like the one I added above can be helpful in terms of understanding some of the nuances of Ruby.
Comment: Looking at this question, which still interests me, 2 years later, I really appreciate this answer, and the comments.


How is this integral operation called? $\langle f(x),\phi(x)\rangle = \int_{-\infty}^{\infty}f(x)\phi(x)dx $

Question: Please, can someone tell what is the name of this operation in the context of Fourier analysis?
$$ \langle f,\phi \rangle := \int_{-\infty}^{\infty}f(x)\phi(x) \,{\rm d}x $$
And what is the meaning behind it?
Comment: It's an inner product, much like the dot product for real vetors.
Comment: In the context of distribution theory, it is called the "action" of the regular distribution T=[f] on "test function" ϕ
Comment: It is also an example of a "pairing".  See https://math.stackexchange.com/q/2360350/442
Answer: Consider $[a,b]\subset \mathbb R$ and $L^2[a,b]:=\{f:[a,b]\to\mathbb C :\int_a^b\vert f(x)\vert^2dx<\infty\}$.
The sum and the multiplication for a scalar $\alpha\in\mathbb C$ are defined as
$$(f+g)(x)=f(x)+g(x),\hspace{1.5cm}(\alpha f)(x)=\alpha f(x).$$
You can define an inner product $(\cdot,\cdot):L^2[a,b]\times L^2[a,b]\to\mathbb C$ as
$$(f,g)=\int_a^b \overline{f(x)}g(x)dx$$
and a norm
$$\Vert f\Vert^2=(f,f)=\int_a^b\vert f(x)\vert^2dx.$$
Hence you have a metric $\rho$ defined as $\rho(f,g)=\sqrt{(f-g,f-g)}$. When $-\infty=a<b=+\infty$ the space $L^2[a,b]$ can be written as $L^2(\mathbb R)$, which is an Hilbert space.
In the context of Fourier analysis these definitions are fundamental for the Fourier series of a function.
If $\mathcal H$ is an Hilbert space and $\Psi=\{\psi_k\}_{k\ge 1}$ is a basis for $\mathcal H$, the the Fourier series of a function $f\in\mathcal H$ is defined as
$$\sum_{k=1}^\infty f_k\psi_k=\sum_{k=1}^\infty(\psi_k,f)_{\mathcal H}\psi_k$$
and in the case $L^2[a,b]$, the Fourier corefficients correspond to $f_k=\int_a^b \overline{\psi_k(x)}f(x)dx$.


trying to define a delete function where user enters a name and clicks on the button and the row is deleted

Question: trying to define a delete function where in the user enters a name and clicks on the delete button and the row containing the data delete with the help of tkinter and sqlite in python.
this is my delete function:
def deleteMovie(name):
    conn = sqlite3.connect('moviedata.db')
    sql = "Delete from movies WHERE name=?"
    conn.execute(sql,(name,))
    messagebox.showinfo("information","MOVIE DELETED")
    conn.commit()
    conn.close()
#this is my entry

code:
window = tk.Tk()
window.title("SP Movie Admin Form")
window.geometry("400x250")
window.resizable(0, 0)

lName = ttk.Label(window,text="Name",padding=2)
lName.grid(row=1,column=1,columnspan=1)
nameent = StringVar()
nameent = ttk.Entry(window,textvariable=nameent)
nameent.grid(row=1,column=2,columnspan=3)

this is my button:
buttondelete = ttk.Button(window,text="Delete",command=deleteMovie)
buttondelete.grid(row=7,column=2)

window.mainloop()

this is the error
Traceback (most recent call last):
  File "C:\Users\gayat\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
TypeError: deleteMovie() missing 1 required positional argument: 'name'

Answer: Your button callback needs to fetch the data it needs, rather than having it passed in. If you want to keep your function that accepts a parameter, you can create a function specifically for the button which fetches the value and then calls deleteMovie.
For example:
def deleteCommand():
    name = nameent.get()
    deleteMovie(name)

Then, have your button call the callback:
buttondelete = ttk.Button(window,text="Delete",command=deleteCommand)

You can of course use a single function that does both of these by removing the parameter and calling the get() method:
def deleteMovie():
    name = nameent.get()
    conn = sqlite3.connect('moviedata.db')
    sql = "Delete from movies WHERE name=?"
    conn.execute(sql,(name,))
    messagebox.showinfo("information","MOVIE DELETED")
    conn.commit()
    conn.close()

Answer: TypeError: deleteMovie() missing 1 required positional argument: 'name'

Of course, what is the name of the movie you want to delete?
I guess it should be nameent, but you also named your entry nameent. won't work.
You have to set the StringVar() variable different from the Entry variable and then use .get() to get the value in the StringVar().
def deleteMovie():
    name=movie_name.get()
    conn = sqlite3.connect('moviedata.db')
    sql = "Delete from movies WHERE name=?"
    conn.execute(sql,(name,))
    messagebox.showinfo("information","MOVIE DELETED")
    conn.commit()
    conn.close()
#this is my entry
window = tk.Tk()
window.title("SP Movie Admin Form")
window.geometry("400x250")
window.resizable(0, 0)

lName = ttk.Label(window,text="Name",padding=2)
lName.grid(row=1,column=1,columnspan=1)
movie_name= StringVar()
nameent = ttk.Entry(window,textvariable=movie_name)
nameent.grid(row=1,column=2,columnspan=3)

buttondelete = ttk.Button(window,text="Delete",command=deleteMovie)
buttondelete.grid(row=7,column=2)

window.mainloop()

Comment: Welcome, howbeit, comments should be for clarification or additional suggestions. If it worked just mark it as answer.


CRUD genérico ou SQLs especificas

Question: Em um sistema que tende a crescer em número de classes e de usuários, qual seria a melhor abordagem para se trabalhar com acesso ao banco de dados?

criar um CRUD genérico? ou
criar métodos específicos para inserir e atualizar cada classe model que está persistida no Banco de dados?

A meu ver a 1ª abordagem tem a vantagem de se escrever somente uma vez o código pra inserir e remover e outros, porém tem a desvantagem de não se saber previamente as SQLs disponíveis e de não prover queries complexas. A 2º abordagem tem como vantagem a simplicidade, a capacidade de ser específica, e como desvantagem ter de reescrever o código das consultas simples.
Qual seria a melhor abordagem para a situação apontada?
Answer: A melhor abordagem depende sempre do objetivo colocado no horizonte.
O modelo de desenvolvimento baseado na criação de CRUDs sempre vai levar vantagem na rapidez do desenvolvimento, considerando que muitas coisas são feitas em automático. A abordagem vale a pena porque não é todo sistema que é inteiramente complexo. Na maior parte dos casos, os sistemas seguem o bom e velho Princípio de Pareto, em que 80% dos gargalos de desempenho estão concentrados em até 20% do código. Nestes casos, não há grandes ganhos quando a produção de código é artesanal, ou seja, feita sentença a sentença.
Mesmo quando o sistema tem uma tendência de desenvolvimento contínuo, a segunda abordagem é mais interessante no momento em que problemas de desempenho são sentidos. É aquele momento no ciclo de vida do código em que telas e ações que antes eram rápidas começam a se tornar lentas. Aí vale a pena estudar o plano de execução das sentenças, reescrever o código buscando otimização, e assim por diante.
Ainda assim, no atual estágio dos frameworks baseados em mapeamento objeto-relacional (os famosos ORM's), a ideia é justamente que o próprio framework faça um trabalho de otimização prévio, livrando a equipe de desenvolvimento a gastar tempo com otimização num estágio inicial de desenvolvimento.
Comment: então a segunda solução (mais simples, porem mais demorada) seria a mais adequada por ser mais legível e eficiente (em desempenho).
Comment: Num segundo momento de desenvolvimento, conforme o sistema ganha complexidade, sim, mas não tem porquê ter isso no início do desenvolvimento.

CRUD genérico ou SQLs especificas


Which correlation should be used for non-normal data: Spearman's rho versus Kendall's tau versus Kendal's tau-b?

Question: I'm trying to see if there is a correlation between the height of grass and the height under branches available for grass to grow. I have 227 paired observations:
GrassHeight HeightUnderDebris
0            0
0            0
0            0
8            16
0            0
0            0
0            0
2            2
6            6
0            0
0            0
1            1
0            0
0            0
0            0
8            15
0            0
7            7
15           15

My data is not normally distributed and it fails at the assumption of bivariate normality:
result<-hzTest(data,cov = TRUE,qqplot = FALSE)
result<-mardiaTest(data,cov = TRUE,qqplot = FALSE)
result<-roystonTest(data,qqplot = FALSE)

Therefore, I need to use a Spearman's rho or Kendall's tau. Firstly, Spearman's rho results in a warning message:
cor.test(GrassHeight, HeightUnderDebris, method="spearman")

Spearman's rank correlation rho

data:  GrassHeight and HeightUnderDebris
S = 123090, p-value < 2.2e-16
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
0.9368622

Warning message:
In cor.test.default(GrassHeight, HeightUnderDebris, method = "spearman") :
Cannot compute exact p-value with ties

So I then decided to use Kendall's tau as it can deal with ties:
cor.test(GrassHeight, HeightUnderDebris, method="kendall")

Kendall's rank correlation tau

data:  GrassHeight and HeightUnderDebris
z = 17.202, p-value < 2.2e-16
alternative hypothesis: true tau is not equal to 0
sample estimates:
tau
0.858494

Firstly, should I be concerned that my data has many zeros? They are important as they reflect that if there is no space under branches, then there is no space for grass growth hence why the grass height is 0.
Secondly, how would you interpret Kendall's results? Is it right that the two variables are uncorrelated at 0.05 significance level if their correlation coefficient is zero? In this case, tau is 0.858. That is not zero and will be rounded up to 1. Can I say that the two variables are correlated based on this?
Should I rather look at rpudplus and the function rpucor, which now uses Kendall's tau-b to compute the correlation coefficient?
What post-hoc test can I do to find out the nature of the correlation, i.e: as the height between the ground and branch increases, grass height increases?
Answer: Pearson's correlation doesn't assume normality, so you should use it. You really don't need Kendall's tau in your example.
In your analysis, you should start off with a simple plot. Like this:
grass  <- c(0,0,0,8,0,0,0,2,6,0,0,1,0,0,0,8,0,7,15)
height <- c(0,0,0,16,0,0,0,2,6,0,0,1,0,0,0,15,0,7,15)
plot(grass, height)

This is clearly linear and monotonic positive, and so it was pointless for you to do a normality test.
Both Pearson and Spearman give similar results:
cor(grass, height) # 0.9300721
cor(grass, height, method='spearman') # 0.9947245

In this example, it's not really not that important to do a correlation test because you know the p-value will be very small and your result will be significant. But let's do it anyway:
cor(grass, height) # 8.227e-09
cor.test(grass, height, method='spearman', exact=FALSE) # 2.2e-16

In the first line, we did a test for Pearson's correlation. Your very small p-value give you confidence that your correlation is not zero (not very surprising).
In the second line, we have a test for Spearman's correlation. Note that your zeros made the default exact test impossible, so you'll need to set exact to FALSE to approximate your test statistic with t approximation. Again, this is very significant.
Comment: what should have normal dist are the residues
Answer: Spearman's rho and Kendall's tau can both be used for non-parametric data, as they are both measures of rank correlation. One key difference: Spearman's rho can be used for both continuous AND discrete variables, while Kendall's tau should only be used for discrete variables. Spearman's rho takes into account how far the ranks are from each other, while Kendall's tau only considers whether they are equal or not.
In your case, your data are discrete and either is thus appropriate. However, if you were to measure the heights as continuous variables (e.g. with decimal points) then Spearman's rho would be the preferred measure.
I would not be concerned about the zeroes. As you say, they reflect a real consideration for your study.
Interpretation of Spearman's rho and Kendall's tau are similar. They can range from -1 to +1, with -1 reflecting a perfect negative correlation (as one variable increases, the other decreases), 0 reflecting no relationship between the variables and +1 reflecting a perfect positive correlation (as one variable increases, the other will also increase). In both instances, your values are close to 1 and it is thus safe to say that the data are strongly positively correlated, i.e. as the available height under branches increases, the height of the grass can be expected to increase. This is easily interpreted from the p values. In both cases, p < 0.05 and the relationship is thus significant. Also in both cases, the rho/tau values are positive, hence a significant, positive correlation is evident. This is usually the case, i.e. rho and tau generally lead to similar inferences.
In this case, I don't think it would be necessary to use tau-b for the calculation. You are unlikely to find manifest differences that would influence your interpretation.
There is no need for a post-hoc test to determine the nature of the correlation. As stated above, the rho or tau value provides you with this information. Closer to -1 indicates strongly negative correlation, closer to 0 indicates weak/no correlation, closer to +1 indicates strongly positive correlation.


Repeatedly rolling a six sided die four times and summing the highest three results gives you a distribution with what mean and standard deviation?

Question: Repeatedly rolling a six sided die four times and summing the highest three results gives you a distribution with what mean and standard deviation?
I've only taken AP statistics, but I would like to learn how to do this.
Comment: If you roll a die four times, do you know how to find the distribution of the *minimum* value? Even if you're unsure of how to do that, can you see how you might use that information to solve your problem?
Comment: Did you do that in your head whuber?
Comment: For the record--to help those who would like to check their solutions--the mean is $15869/1296 \approx 12.2446$ and the SD is $\sqrt{13612487}/1296 \approx 2.84684$.
Comment: @Macro: (+1) While that is much more plausible in whuber's case than in most others, this problem is easily approachable by brute force and can be checked in 3-4 lines of $R$ code.
Comment: Highly relevant to this question is the thread on a [Formula for dropping dice](https://stats.stackexchange.com/questions/130025).
Answer: (D&D player?) It's easy enough to just enumerate the whole distribution. In R:
<code>> a1 <- rep(1:6,times=216)
> a2 <- rep(1:6,times=36,each=6)
> a3 <- rep(1:6,times=6,each=36)
> a4 <- rep(1:6,each=216)
> tot <- a1+a2+a3+a4-pmin(a1,a2,a3,a4)
</code>
That's all it takes (there's a bunch of other ways to do it). Results:
<code>> mean(tot)
[1] 12.2446
> n <- length(tot)
> sd(tot)*sqrt((n-1)/n)  # we have the whole distribution; we want n-denominator, not n-1
[1] 2.846844
> quantile(tot)
  0%  25%  50%  75% 100%
   3   10   12   14   18
> table(tot)  #frequencies
tot
  3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
  1   4  10  21  38  62  91 122 148 167 172 160 131  94  54  21
> print(table(tot)/sum(table(tot))*100,d=2)  # as percentages
tot
     3      4      5      6      7      8      9     10     11     12     13
 0.077  0.309  0.772  1.620  2.932  4.784  7.022  9.414 11.420 12.886 13.272
    14     15     16     17     18
12.346 10.108  7.253  4.167  1.620
</code>
Comment: (+1) Along the lines of @cardinal's suggestion, `p <- tabulate(apply(gtools::permutations(6,4, repeats.allowed=TRUE), 1, FUN=function(x) sum(sort(x)[-1]))) / 6^4` yields the probability distribution all at once.
Comment: (+1) This doesn't give much in the way of probabilistic insight, but it *is* the fastest and safest method for small problems like this. Note that you can use `expand.grid` to replace the first four lines of your code.
Comment: @cardinal - indeed, I contemplated using expand.grid
Answer: Each roll has a uniform distribution on $\{1, 2, 3, 4, 5, 6 \}$ and to get the distribution for the minimum you can use $P[m>k] = {\rm probability \ that \ all \ four \ rolls \ are \ } >k$ and by independence this is the probability that each roll is $\geq k$ raised to the fourth power where $m$ is the minimum of the 4 rolls. Now for each roll $P[X>k] =(6-k)/6 = 1 - k/6$ So $P[m>k]  = (1-k/6)^4$ and therefore $P[m<=k]=1 - (1-k/6)^4$.
From this we get $P[m=k]=P[m \leq k]-P[m \leq k-1]$ - knowing that $m=k$ means that the smallest of the three in the sum you calculate is at least $k$.
Let $S$ be the sum of the three highest rolls.  You want $P[S=k]$ for $k=3,...,18$.  You can calculate this as $P[S=k]=∑_{j=1}^{6} P[S=k|m=j] P[m=j]$.  Note that for a variety of $k$s and $j$s $P[S=k|m=j]=0$. For example $P[S=3|m=k]=0$  for $k=2,3,4,5,6$.  Of course once you determine $P[S=k]$ for $3 \leq k \leq 18$ you can calculate the mean and variance.
Comment: I tried to fix the TeXing - I'm pretty sure this is verbatim what you had before.


Get inactive mailboxes with their primary SMTP address and last logon information

Question: I want to get list of all inactive mailboxes with their primary SMTP address and last logon information.
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select DisplayName, LastLoggedOnUserAccount, LastLogonTime

This command returns all inactive mailboxes with their display name but problem is that I want to get this list with PrimarySMTPAddress of mailbox because there is a possibility that multiple accounts can have same display name. Is there a way to get it with PrimarySMTPAddress?
Answer: The primary SMTP address for an Exchange mailbox is found in its 'ProxyAddresses' attribute. This is a multi-value attribute, and Exchange denotes the primary by using an all-caps 'SMTP:' prefix for the address. Non-primary SMTP addresses will use a lowercase 'smtp:' prefix.
Here's an example of how to query your primary SMTP  address:
Get-ADUser -Identity "Muhammad Arsalan Altaf" -Properties ProxyAddresses | select -ExpandProperty ProxyAddresses | ? {$_ -clike "SMTP:*"}

Comment: thanks for your answer but I want to get their last logon detail. Get-MailboxStatistics returns logon details with many other details but it gives us display name not primary SMTP address. I'm trying to find such a way that it also returns me primary SMTP address with these statistics by running just one script.
Answer: # actually Exchange management shell
$results = foreach ($mailboxdata in (Get-Mailbox -ResultSize Unlimited)) {
$stats =  Get-MailboxStatistics -identity $mailbox  ;
$mailboxdata | add-member NoteProperty -name LastLoggedOnUserAccount -value  $stats.LastLoggedOnUserAccount
$mailboxdata | add-member NoteProperty -name LastLogonTime  -value  $stats.LastLogonTime}
$results

Or just use https://github.com/cunninghamp/Get-MailboxReport.ps1 by Paul Cunningham former owenr of https://practical365.com
Answer: What the version of your exchange server?
If your exchange server is on premise, I found a similar scripts for your reference.
If your exchange server is online, you could Go to https://protection.office.com and sign in using the credentials for an administrator account in your Office 365 organization, Click Information governance > Retention, On the Retention page, click MoreNavigation Bar ellipses, and then click Inactive mailboxes.
For more details: View a list of inactive mailboxes
Comment: Server version is Exchange 2019. I want to get these information using code not using UI.
Comment: You could seek for a powershell expert, who will provide the most accurate advice:)


count syntax in mysql

Question: I would like to get the number of rows that satisfies the condition.
mysql_query("SELECT COUNT(*) FROM sid WHERE sid='".session_id()."'");

this one ignores the condition.
update:
$session = session_id();
$sql = "SELECT COUNT(*) as row_count FROM sid WHERE sid = '$session' ";
var_dump($r = mysql_query($sql));//resource(4) of type (mysql result) (1)
var_dump(mysql_fetch_assoc($r));
//array(1) { ["row_count"]=> string(1) "1" }  - this result is OK(2)

(1) resource(4) - I thought that 4 was the count
(2) mysql_real_escape_string($_SESSION['id']); gives 0
note:
I have changed from mysql_num_rows to this type of getting count because I thought it will return immediately the count and I dont have to write more lines to get this basic data.
Comment: Well it shouldn't - why are you so sure it does?
Comment: Somewhat unrelated: if the `session_id()` can be manipulated by the user in anyway (i.e. comes from a cookie or URL parameter - not a PHP specialist), this code is vulnerable to SQL injection and should be fixed.
Comment: @Romain you make a valid point, although I think that PHP is intelligent enough to spot this/will not allow it anyway, as (at least) `';` are not valid characters in a session id, and if you send an invalid session id, a call to `session_start()` will create a new session and generate a new id. Still +1 for your comment, though, as I'm not 110% sure about this.
Comment: @DaveRandom, the `;` is not a possible vector for SQL-injection attacks. `mysql_query` does not allow multiple queries, the XKCD is incorrect and **that** attack is impossible.  What is possible is a `' or (1=1) UNION SELECT username, password, email FROM users -- ` kind of injection. Of course `'` can be encoded in clever ways. You should never rely on internals, but just escape everything before injecting it into the SQL-statement.
Comment: @Johan Fair enough - I am not that hot on exactly what SQL injection attacks are possible for any given query, so I tend to just escape *everything* (to a possibly unecessary level) but it's nice to see that *some* people have a clue what's going on...
Comment: if `some_id = 0` this will usually generate 0 hits, because id's generally are positive integers >= 1.
Comment: @Johan: in the past, there was a way to have `mysql_query` accept multiple statements. I sure hope it's not the case anymore as this was a horrible, horrible usage pattern.
Comment: @Romain `mysqli_multi_query` can accept multiple statements.
Answer: The correct way of doing this is:
$session = mysql_real_escape_string($_SESSION['id']);  <<-- Get the session id
echo "debug: session_id = ".htmlentities($session);
$sql = "SELECT count(*) as row_count FROM tablename WHERE sid = '$session' ";
$result = mysql_query($sql);
if (!$result) {
  die('error in query '.$sql.' error is: '.mysql_error());
}
//we only have 1 result
$row = mysql_fetch_array($result);
//always sanitize so you don't suffer XSS attacks when the query changes
//and the $row['x'] changes from an integer to a user-supplied string.
$count = intval($row['row_count']);
echo "count is: ".$count;

The table name and the column name can be the same, but in your case they probably are not.
sid obviously stands for the field "session_id", so you need to replace the first sid after FROM with your tablename.
Comment: +1 ...and then (for clarity) `$result = mysql_query($sql); $row = mysql_fetch_assoc($result); $count = $row['row_count'];`
Answer: first write your query in php variable and echo it to check what session_id() returns and then try may be there is nothing in your session_id(); like
$sql = "SELECT COUNT(*) FROM sid WHERE sid='".session_id()."'";
echo $sql;

and run it in phpmyadmin if it work than your query is qrite else something is wrong
Answer: table name = "sessions"
column name = "sid"
mysql_query("SELECT COUNT(*) FROM sessions WHERE sid='".session_id()."'");

count syntax in mysql