how to replace SQLAlchemy mapper deprecated "order_by" option?

Question: I have a Single Table Inheritance sqlalchemy orm model that looks like this:
class Human(Base):

    __tablename__ = "human"

    id = Column(Integer, primary_key=True)
    name = Column(String)
    index = Column(Integer)
    parent_id = Column(Integer, ForeignKey("human.id"), nullable=True)
    type = Column(String)
    parent = relationship(
        "Human",
        cascade="save-update, merge",
        backref=backref("children", cascade="all"),
        lazy=False,
        remote_side="Human.id",
    )

    __mapper_args__ = {"polymorphic_on": type, "polymorphic_identity": "human"}

class Parent(Human):

    __mapper_args__ = {"polymorphic_identity": "parent"}

class Child(Human):

    hobby = Column(String)
    pet = Column(String)

    __mapper_args__ = {"polymorphic_identity": "child"}

This relationship looks like a nested tree, where I can query the oldest person (i.e: great grandparent, using query.get(1)) and then in his children attribute all his children will be present, and each child will also have their children present.
This relationship works just fine in every aspect.
I want the children that are queried when I query a Parent (due to lazy=False) to be ordered by the index column not the id column (which is the default).
I was achieving this by adding the following "order_by": "index" to the Human class' __mapper_args__ as follows:
__mapper_args__ = {"polymorphic_on": type, "polymorphic_identity": "human", "order_by": "index"}

I recently found out that in SQLAlchemy the order_by argument in the mapper() class is deprecated since SQLAlchemy version 1.1 (reference). And that they say to use Query.order_by() to order the set instead, which is not working for me for some reason.
I have tried the following:

adding order_by to the query, session.query(Human).order_by(Human.index).get(1)
adding order_by="Human.index" to the relationship() in the Human class.

these two methods are not working.
How can I achieve the same effect as the order_by in mapper() now that it is being deprecated?
Comment: Also being discussed on GitHub [here](https://github.com/sqlalchemy/sqlalchemy/issues/5870).
Comment: @GordThompson that was me posting it there as well :)
Answer: I got an answer after asking the question on sqlalchemy's github.
I am posing the response in case anyone else searches for this issue and finds it here instead of sqlalchemy's github.
The answer:

the ordering of a collection loaded by a relationship is controlled by the order_by parameter of relationship() and/or backref. In this case you want "children" to be ordered so you put that where you define "children":
parent = relationship(
       "Human",
       cascade="save-update, merge",
       backref=backref("children", cascade="all", order_by="Human.index"),
       lazy=False,
       remote_side="Human.id",
   )

that is, this has nothing to do with mapper.order_by, although that attribute was having the effect you were seeking. if you had tried relationship->order_by on the "parent' side, that was the wrong side, it goes where the actual thing to be ordered is defined, in this case the backref.


Playing Am pentatonic scale over A blues chord progression

Question: I had a guitar entrance exam yesterday regarding improvisation. The guy put on a A blues backing track and told me to improvise.
As I'm not a blues guy myself, I went and improvised on the A major scale (Ionian mode). After a few seconds he stopped me and asked me if I was playing on the pentatonic, I said no and that I'm currently playing on the Ionian mode. He told me that the pentatonic is more appropriate to blues and to play on it. I said ok and proceeded to play on the F# minor pentatonic scale, since its A major's relative minor. He stopped me again and told me to play the A minor pentatonic scale, saying that's what gives it the blues feel- playing the minor scale on a major chord progression (Am pentatonic on A blues chord progression).
He failed me at the test (even tho my improv wasn't anything close to bad).
Note: this was not a 'blues improvisation exam', but simply an improvisation exam.
Now my question; was my 'mistake' that serious? Yes, I'm not a blues guy and my improv was not so bluesy probably, but still, failing me felt totally out of the blue.
Edit for clarification, since this came out more as a rant: Is it obvious and known that minor pentatonic should be played on major chord progression (Am pentatonic on top of A) in blues, and are other scales (pentatonic on relative minor/other modes) used as much in blues improvisation.
Comment: 'Failing me felt totally out of the blue,' - gettit?
Comment: A lot of us don't live in US either. So it might be of use in an answer. It'll be useful for personal anecdotes, maybe.
Comment: I think the obvious answer is that yes, in the eyes of the adjudicator, your mistake was that serious. But I'm not clear on exactly what your question is. Are you asking why you failed the exam? Are you asking what would be expected at a blues gig? There's a lot of information missing here — especially what the purpose and extent of the audition was.
Comment: @blueskiwi I see what you meant now.  BTW On the Scottish Pentatonic page, scroll down to the "Common Names" and you'll see it's also known by some [who?] as "blues major", and by many other names around the world.  It's of course just a mode of the major pentatonic.
Comment: @Aaron Yes you're correct. I guess my question is- is it obvious and known that minor pentatonic should be played on major chord progression (Am pentatonic on top of A) in blues, and are other scales (pentatonic on relative minor/other modes) used as much in blues improvisation. I'll edit my question since its unclear.
Comment: Just out of interest, what exam board, what grade?
Comment: @Tim It was an entrance exam for a music school. I dont live in the US so I doubt any further info is helpfull. I passed overall but failed this part.
Comment: The backing track presumably had dominant 7th chords A7 D7 E7, which is why A Ionian was a wrong choice - there are note clashes between your scale and the chords, and those clashes are not the same ones that make something sound bluesy.  F# minor pentatonic has the same problem e.g. when you get to the D7.  You could play the corresponding A/D/E mixolydian over each chord and it would at least have no clashes and be not-wrong. There's no single (common) scale that fits across all 3 chords without clashes, so choice is between following the chords and/or picking clashes that fit the idiom.
Comment: @Sapper What blues tunes have you played, can you give a few links? I read your question and honestly thought, "has this person ever heard, let alone played, any blues at all." IMO, music and particularly improvisation, is learned by listening and playing. Blues idioms and stylistic features are behind many other genres, and I think it's important to know them. For example, dominant-seventh harmony being used as "tonic" which isn't expected to resolve anywhere.
Comment: How much exposure have you had to blues music as a *listener*?
Comment: Expanding on the above comment by @blueskiwi: The *less-common* scale that fits *all three* chords is the "Blues Enneatonic (9-tone)", a.k.a. [Raga Malgunji](https://ianring.com/musictheory/scales/3773)
Comment: @piiperiReinstateMonica I dont listen to blues, nor did I ever really learn blues licks/songs. The only real exposure I had/have to blues is when I improvise to a blues backing track once in a blue moon. This explains why I didnt know the basics really. I learned all my life classical music and havent strayed from it too much.
Comment: I don't know what the entry exam tried to find out, but I could imagine one of the criteria being to see if you could not only produce notes but to play something that fits the style. For a guitarist, rudimentary knowledge of stylistic features of blues could reasonably be expected, IMO. It's not just about selecting the right scale, there are many "bluesy" aspects that can be found in other styles, and the easiest way build a blues vocabulary is to play blues. Is this blues? https://www.youtube.com/watch?v=HQ_TzhblPjw There's a lot of blues _in it_, but a lot of other things as well.
Comment: @piiperiReinstateMonica Yes, I think you're right about the criteria. Before he stopped me the last time he commented "That's not really blues but whatever". I havent played anything out of scale to my ears, but what I played was without a doubt- not blues. Thanks for the input.
Comment: "even tho my improv wasn't anything close to bad" - how do you know that? :-)
Comment: @BartoszKP I'm fairly confident in my skills.
Comment: @Theodore that is an interesting scale, and only lacks the b5 and b2 (b5 of the V) to make it a "comprehensive" blues scale. But I really meant a scale that has no avoid notes across all three chords, i.e. the notes in common from the 3 mixolydians... apparently this is called a "Scottish Pentatonic" https://ianring.com/musictheory/scales/677 ... TIL!
Comment: @Theodore aha, nice!
Comment: @Sapper I can see that. But why do you think one's confidence is enough to self-judge in a meaningful way?
Answer: There are a variety of scales that can be used in blues improvisation, depending somewhat on the specific style involved. However, using a A minor pentatonic over an A blues is the most basic. It's a very typical first scale taught in blues improvisation, and it would be reasonably expected in an audition or examination that this would be known.
An A major blues contains three main chords: A7, D7, and E7. The A minor pentatonic — A C D E G — contains pitches common to those chords so provides a simple way to begin improvising. A slightly more advanced improviser might use the A minor pentatonic over the A7 chord, then switch to different scales for the D7 and E7.
There are also blues scales, mixolydian scales, and bebop scales, all of which are frequently used in blues (or jazz) improvisation.
Blues itself comes in many variations with many different chords and alterations to those chords, so there is a corresponding proliferation of scales that could be used.
Comment: "then switch to D minor pentatonic over D7" ...no I don't think so, that would sound wrong for the IV chord.  E minor pentatonic over the E7 (the V chord) yes, but not on the IV chord, stick with A minor pentatonic for the D7.  Basically the "minor melody over major chord" sound of blues only applies to the I and the V. Soloing-wise the IV chord is more like an extension of the I chord, the 7th giving it a more minor-key flavour (from perspective of the I chord, the home key).
Comment: it sounds wrong and inept on a major key blues, that only works for "minor key" blues where the chords are minor too. the IV chord does not have a minor/major clash like the I and V do, in idiomatic blues
Comment: Its so basic yet I had no idea. I always thought to find the relative minor for the pentatonic whenever I met with blues, that this is how its done. Appreciate the info.
Comment: @blueskiwi - funny, cos that's worked for loads of us for decades ('switch to Dm pent for D7'). Why the heck wouldn't it work? If Am pent works over A7 and Em pent over E7, then Dm pent *has* to work over D7. And it always has. And always will. Yes, stick with Am pent over D7, but, boring. Several notes belong to both, though...
Comment: I have to chime in and agree with blueskiwi. It logically makes sense to say Dm pent works over D7 but as a IV chord the F creates a rub with the key of A to my ear. Blues players tend to improvise over tonalities as opposed to chords like jazz players do. If making a change my preferred option is to use A major pent over the I then switch to Am pent for the IV.
Comment: @blueskiwi has it right for exactly the reason JohnBelzaguy gives. I've updated the post.
Comment: @JohnBelzaguy - we'll agree to differ. There's only one note different, as I said. Am pent - ACDEG, Dm pent DFGAC. Lose the E, and play F instead. That F is the m3 of the D chord, and just like we'd bend C up to C#, we can bend F up to F#. Not including it denies us that capability. It's Blues after all.
Comment: @Tim the Am pent gives you 2 great neighboring tones to the D, E and C. If I want an F# I bend up a step from the E, nothing is denied. The F over D7 doesn't work for me in A major blues. In minor I'll take the F all day. As you said, we'l agree to differ.
Comment: "That F is the m3 of the D chord, and just like we'd bend C up to C#, we can bend F up to F#." ...but the context is different. The blues tonality occurs within the context of the chord sequence, it's not a rule you blindly apply to any dominant 7th wherever. The m3 of the IV chord scale is an avoid note in major-key blues. OTOH the m3 of the I chord matches the 7th of the IV, and the m3 of the V matches the 7th of the I.  Blues is more a superposition of tonalities with contextual emphasis/de-emphasis rather than a series of scales that move strictly in step with the chords.
Comment: @blueskiwi I think you meant to "@" Tim...?
Comment: @Aaron yes, sorry
Comment: @blueskiwi No apology needed. I'm just suggesting you might re-post your comment so that Tim sees it.
Comment: @blueskiwi - I've seen it, and stick with what I wrote. It's an age old trick to play a phrase a couple of times (over the 1st 4 bars), then repeat 5 frets higher over the IV for the next, and so on. Without what I wrote, that's a lot harder to do.
Answer: It's common to use the minor pent. over a Blues, and most Blues will use major, or more likely dominant seventh chords throughout. Major pent. will work, but won't sound too bluesy. It'll sound fine over the tonic (I), but not work over IV or V so well. You moving to F♯m pent. gave you exactly the same set of notes,(as A major pent.)  no wonder he stopped you again!
Your teacher should have warned you that minor pent. works over both major and minor Blues songs, but major pent. will not work over minor Blues.
The main notes that make something Blues are ♭3, ♭5 and ♭7, (the 1st and last of which occur in minor pent.); none of which you would be using with major pent. No wonder he stopped you. You should still have played a decent solo over the sequence, but it wouldn't have sounded too bluesy.
Blues players will usually mix major and minor pents. in their playing, adding bends to particular notes. These would be expected in someone asked to improvise over a Blues sequence. And probably there was none of that, as the notes you stuck to didn't allow that to happen. Or maybe you bent notes that shouldn't need bending?


how to generate state and reward in model free reinforcement Learning

Question: In the model free reinforcement Learning, most algorithms mentioned that using random walk simulates the next state. Here I don't understand how to generate the next state? Does it select all the states with same probability?
And for the reward $r(s,a,s'),$ in the algorithms, why isn't it a input function i.e. when $(s,a,s')$ is given, we have a value.
I think it is better to give a real world example to illustrate above question.
Answer: Reinforcement learning is often described in an MDP or POMDP framework. By framework, I mean a set of abstract concepts which can be used to describe a large number of different specific problems / games at once. Frameworks are generally useful because it allows you to reason about many different specific things at once. In the (PO)MDP framework, concepts include such things as "reward", and "state", and "transition".
Driving a car is an example of a task which can be abstracted as an POMDP: the state consists of the relevant state of the world (e.g. the road ahead, nearby cars, pedestrians, and other objects, the car itself and its mechanical parts), the "transition function" is simply the laws of physics, and the "reward" is a bit subjective, but you can imagine you're rewarded for getting to your destination and penalized for crashing into things.
A robot trying to navigate a maze can also be abstracted as a POMDP: the state consists of the location of the robot in the maze, the transition is governed by again by the laws of physics governing how the robot can physically move, and the reward is presumably positive if the robot solves the maze.

So returning to your questions:

how to generate the next state?

The next state comes from the transition function of your (PO)MDP. Exactly what that transition function depends on what your (PO)MDP is modeling, it may be physical laws, or the rules of a board game, etc. If it's a board game, you can just use the rules of the game to determine what happens next.

And for the reward r(s,a,s′), in the algorithms, why isn't it a input
function

In order for the (PO)MDP framework to be able to model a large number of different games and problems, the abstract reward function is often formulated as being random. Maybe you're playing a game where you roll a dice, and get the resulting number of dollars (aka reward). If MDPs could only have deterministic reward, then it would be difficult to fit this type of game into the framework. So in an effort to make the framework as general as possible, rewards are stochastic.
Comment: Thanks. `transition function depends on what your (PO)MDP is modeling` in the model-free case, we don't know the transition function and then how to randomly generate the next state?
Comment: model free means your RL agent doesn't know the transition function, not that *you* don't know it. for example, it's perfectly possible to train a model free agent which plays pacman, even though you know the exact rules and transition function of pacman.
Comment: I still don't understand what's the difference between Agent know the transition function and I know the transition function? Could I understand as when Agent know the transition function, the transition function is actually the part of optimal policy (optimal policy is based on the he transition function);  when only I know the transition function, the optimal policy is independent on the transition function? Could you use pacman as a example to illustrate above two case?
Comment: the optimal policy is something completely independent from notions of model free or model based. you might find this question/answers useful for clarifying model free vs based https://stats.stackexchange.com/questions/407230/what-is-the-difference-between-policy-based-on-policy-value-based-off-policy or feel free to ask a separate question if that still doesn't help


Can Logistic Regression be used as the base learner in bagging?

Question: I am working on a multiclass classification problem which uses sentiments extracted from review texts as feature space and tries to predict the numerical ratings. I am interested in using bagging approach to make predictions. My question is about the appropriateness of using Logistic Regression as the base learner in bagging. The reason why I am interested in Logistic Regression is because I came to know that TF-IDF and Logistic Regression is a powerful combo.
Answer: You definitely can. You can use bagging with any type of classifier. However, because bagging is an ensemble method, and logistic regression is a stable classifier, they are not a powerful combo. On the other hand, decision trees are unstable classifiers and they work well when combined in ensembles. The reason for this is that in order for your ensemble to work well, the classifiers in the ensemble should produce independent mistakes. Unstable classifiers, such as decision trees, tend to perform significantly different when the training set is slightly perturbed. This is why the ensemble methods use bootstrap sampling to create a separate training set for all classifiers in the ensemble.


Toss 100 fair coins and take away the tails; toss the remaining coins and take away the tails. Continue until no coins remain.

Question: 100 participants have a fair coin each, on a given round, the not already discarded participants flip their coins, those who flip a tail are discarded from the game, the remaining ones continue to play until nobody is left (everyone has been discarded).

What would be the average number of trials (where each trial consists of a tossing and removing the tails) one would expect from doing this experiment?

Does conditional expectation work for something like this?

I know that each individual coin follows a Geometric distribution, but I am trying to figure out the sum of them to determine the average number of trials for a game like this.
My Logic/Thought Process: I started out trying to think of the probability that a particular coin makes it to round $r$ which is $\frac{1}{2^m}$. I then realized that each coin outcome can be modeled by a Geometric random variables with $p = 0.5$. I am just now unsure how to take the leap from this single case to a case with 100 coins. I presume it has to do with summing the geometric random variables, but I am not sure.
Comment: What have you tried? What is the number of trials if you started with 1 coin? 2 coins? 3 coins?
Comment: @CalvinLin just added my thought process above
Comment: What is the expected number of trials if you started with 2 coins?
Comment: Hint: per Calvin, work out smaller cases (1, 2, 3 coins) with conditional expectation.
Comment: you expect it to take 1 trial to remove both coins? Please show your work.
Comment: @CalvinLin $\sum^2_{x=1} \frac{2!}{1! * 1!} (.5)^x (.5)^{2-x}$
Comment: You're doing a summation on x, but the RHS has no x terms. So you expect it to take 2*2*.5*.5 = 1 trial? Are you sure? Please show your work and explain what you are doing.
Comment: @CalvinLin Just fixed it. I tried using a binomial, but now that I think about it, the sum of geometric random variables yields a negative binomial, so should I be doing something with that instead?
Comment: @user839334 A) Are you sure of your claim? B) Even if your claim is true, how does it apply to this setup? Please show your work / reasoning. C) You seem to be mixing up several concepts, like expected value, . Without a sufficiently detailed explanation , I don't know what you're thinking of and where the error is.
Comment: Just to spell out the connection with the proposed duplicate, rather than taking a sum of the random variables (outcomes for individual coins), you want the (expected value of the) maximum of those variables.
Answer: This is essentially equivalent to computing the expected value of the maximum of $n=100$ iid geometric random variables, for $p=\frac12$
(BTW: The linked question includes the recursion given by @saulspatz's answer)
There is no closed form solution, but this approximation for large $n$ (with bounds) is given:
$$E_n \approx \frac{1}{2} + \frac{1}{\lambda} H_n$$
where $\lambda = - \log(1-p)=0.69314718\cdots$ and $H_n$ is the harmonic number.
For example, for $n=3$ this gives $E_3 \approx 3.14494$ , very near the exact $E_3=22/7=3.14285$
For $n=100$ this gives $E_{100} \approx 7.98380382$.
More in "Yet another application of a binomial recurrence order statistics",
W. Szpankowski; V. Rego, Computing, 1990, 43, 4, 401-410.
Comment: $H_n = \sum_{k=1}^n 1/k \approx \log(n)$ https://en.wikipedia.org/wiki/Harmonic_number
Comment: can $H$ be expressed in summation notation?
Answer: I doubt that there's a simple expression for the expectation.  Let $E_n$ be the expected number of trials when $n$ coins remain, so that we are asked to compute $E_{100}$.  We know that $E_0=0$ and that $E_1=2$.  Now $$E_2=1+\frac14E_2+\frac12E_1+\frac14E_0$$ because we have to make one trial, and with probability $\frac14$ we throw two heads and still have two coins, with probability $\frac12$ we throw a head and a tail, and with probability $\frac14$, we throw two tails, and the experiment ends.  This gives $E_2=\frac83$.
We can continue in this manner: $$E_3=1+\frac18E_3+\frac38E_2+\frac38E_1+\frac18E_0$$ which gives $E_3=\frac{22}7$ if I'm not mistaken.
One could easily write a computer program to work back to $E_{100}$, but it would be easier to proceed by simulation.
EDIT
I wrote the script I suggested.  The exact value if a fraction whose numerator has $894$ decimal digits and whose denominator has $893$.  The approximate value is $7.98380153515692$.
Comment: @user839334 $$E_n=\frac{1}{2^n-1}\left(2^n+\sum_{k=0}^{n-1}\binom nkE_k\right)$$
Comment: I got those initial values too. I agree that this is likely a computing process (though OP doesn't seem to have a good enough grasp of statistics)
Comment: @saulspatz - could this be written in summation notation?
Answer: Searching OEIS with @saulspatz first values, we can find that:
$$E_n = \frac{a(n)}{b(n)}$$
where $a(n)$ is OEIS A158466 and $b(n)$ is OEIS A158467. At OEIS A158466 you can find also the following formulas:
$$E_n = -\sum_{k=1}^n (-1)^k \frac{{n \choose k}}{1-\frac{1}{2^k}}$$
$$E_n = \sum_{k=1}^{\infty} k \left(\left(1-\frac{1}{2^k}\right)^n - \left(1-\frac{1}{2^{k-1}}\right)^n\right)$$
and thus (see here):
$$E_{100} \approx 7.983801535$$
Answer: Set $N_0=100$ and take $N_k$ to be the number of coins that remain after the $k^\text{th}$ trial in this process. So we can say something like $$P(N_1=81|N_0=100)={100 \choose 19}\Big(\frac{1}{2}\Big)^{100}$$
Now for $i\in \{0,1,\ldots, 100\}$ and $j\in \{0,1,\ldots ,i\}$ we have $$P(N_{k+1}=j|N_{k}=i)={i \choose j-i}\Big(\frac{1}{2}\Big)^i$$ Notice $\{N_k\}_{k=0}^{\infty}$ is an absorbing Markov chain with $0$ as an absorbing state. You're looking to compute the expected number of trials in this random process before being absorbed in state $0$ starting from state $100$. There are many ways to compute this expected value, the most efficient is probably by making use of the fundamental matrix which you can learn about here


Removing data point outside of a specific quantile

Question: I would like to remove data points above 97.5% and below 2.5%. I created the following parsimonious data set to explain the issue:
y <- data.table(a = rep(c("b","d"), each = 2, times = 3), c=rep(c("e","f"),
each = 3, times = 2), seq(1,6))

I created the following script to accomplish the task:
require(data.table)
y[, trimErr := ifelse(y$V3 < quantile(y$V3, 0.95) & y$V3 > quantile(y$V3, 0.05),y$V3, NA),
by = list(a,c)]

I then got 4 warning messages, I will only provide the first warning:
Warning messages:
1: In `[.data.table`(y, , `:=`(trimErr, ifelse(y$V3 < quantile(y$V3,  :
  RHS 1 is length 12 (greater than the size (3) of group 1). The last 9 element(s) will be discarded.

can you please explain to me what the warning means and how can i modify my code.
Would you suggest a better code to remove the top and bottom 2.5% of the data. Thanks in advance.
Answer: You're grouping by a and c, but passing in a vector that is the length of the entire data.table, instead of just the data for each group.
You don't need the y$ inside the [.data.table call
y[, trimErr:=ifelse(V3 < quantile(V3, 0.95) & V3 > quantile(V3, 0.05),V3, NA),
  by=list(a,c)]
y
#    a c V3 trimErr
# 1: b e  1      NA
# 2: b e  2       2
# 3: d e  3      NA
# 4: d f  4      NA
# 5: b f  5       5
# 6: b f  6      NA
# 7: d e  1      NA
# 8: d e  2       2
# 9: b e  3      NA
#10: b f  4      NA
#11: d f  5       5
#12: d f  6      NA


O que é a arquitetura de Cleópatra?

Question: Existem várias arquiteturas básicas de computadores modernos. Aqui no SOPt possui algumas perguntas, sobre arquitetura de Von Neumann e de Harvard. Recentemente, em uma pequena leitura, citaram uma outra arquitetura, que seria essa tal arquitetura de Cleópatra(ou Arquitetura Cleópatra). Percebi que existiu o computador chamado Cleópatra, pelo que li em poucos coisas em português, então acabou me confundindo um pouco.

Trazer para a próxima aula o manual e o resumo da arquitetura
  Cleópatra. Organização e Arquitetura de Computadores p.9/9

O que é a arquitetura de Cleópatra?
Comment: Pelo que eu achei nem é uma arquitetura no mesmo nível, é uma forma de implementação da Von Newmann, se não estiver enganado, não tem informação clara.
Comment: @bigown por isso que achei estranho e me confundi. A primeira dúvida foi qndo li em um slide que encontrei na internet sobre arquitetura de Harvard estava escrito: "Na próxima aula vocês trazem algo sobre a arquitetura de Cleópatra." Por isso fiz a pergunta.
Comment: http://www.inf.pucrs.br/emoreno/undergraduate/CC/orgarqi/class_files/Aula18
Answer: Algumas universidades criam algumas arquiteturas para servirem como suporte no ensino de cadeiras de arquitetura de computadores. Essas são geralmente baseadas nas principais arquiteturas do mercado. A arquitetura Cleopatra é uma dessas, outros exemplos são Neander e Ramses.
Comment: Isso explica por que é tão difícil encontrar algo sobre essas arquiteturas.

O que é a arquitetura de Cleópatra?


How much memory to allocate to sql server

Question: I have SQL Server inside an ESX VM... the server has 32GB Ram.  Right now, I've given it 4GB of Ram because I had some to spare.
How do I know how much memory I should throw at SQL Server (since it takes all it can get at bootup) and if moving to 64 bit is useful or not?
Answer: You want to go 64-bit if at all possible. SQL Server will be able to allocate the extra memory as necessary to all memory pools. There are limits to what it can do in the 32-bit version, even if you configure AWE memory support.
How much memory is really dependent on how much utilization the SQL Server will see. 4 GB is a good starting point and you should measure performance from there to determine if you need more. Keep in mind that SQL Server will expand to take up all the memory that is available as it needs more memory and that it won't let the memory go unless the OS experiences memory pressure. Therefore, don't be alarmed if you see SQL Server taking up a lot of memory. That is normal (and expected with RDBMS platforms).
As to the virtualization question, it depends. Unless there are very heavy loads, virtualization can work with production systems. The key is to not short change SQL Server or the OS because it is virtualized. Allocate it the same amount of processor and memory as if it were on a physical server. Also, make sure you've followed the best practices with respect to disk configuration for the version of ESX you're running.
Answer:
As much as you can is the simple answer, but if you have a single 1GB database then 1.5 GB would be OK.
64 bit: Yes. Absolutely. 100%.

However, running a prod SQL Server instance virtually isn't a good idea.


CDF of distance to a point in 3D-sphere

Question: Let's say we have a unit sphere and want to generate uniformly distributed points inside it. We use rejection to do so, and as such we place the sphere inside a $2$x$2$x$2$ bounding box and generate points uniformly inside of there, rejecting any points that don't end up inside the sphere.
If I'm correct then there is a .23 rejection rate.
But let's say we introduce a random variable $L$ that is the distance from the center of the sphere to a random point inside the sphere. What would the CDF of $L$ be?
Comment: Think about what the CDF $F(r)$ represents.  It is the probability that a random point is closer than some radius $r$.  When is a point closer than some radius $r$?  It is when the point falls within a *sphere* of radius $r$ (centered at the origin); the points within this sphere are all closer to the origin than $r$.  Since the point is selected uniformly from the unit sphere, the probability must be equal to the volume of the smaller sphere, divided by the volume of the unit sphere.
Answer: Hint: the volume of a sphere of radius $L$ is $\frac{4}{3} \pi L^3$.
Comment: No, the CDF of the distance from the centre of a sphere of radius $R$ to a random point in the sphere is $F(x) = $(volume of sphere of radius $x$)/(volume of sphere of radius $R$) $=x^3/R^3$ for $0 \le x \le R$, $0$ for $x < 0$, $1$ for $x > R$.
Comment: So the CDF is the volume of a sphere with radius 1? I.e the CDF is $\frac{4}{3} \pi$?

CDF of distance to a point in 3D-sphere


In little league, can an umpire change their ruling based on advice from coaching staff?

Question: In a little league championship game, there have been two outs, with a man on second. The batter hits a home run. The batter runs bases and gets home, but the outfield team notice that he didn't step on third base.
The coaches instruct the pitcher to go back to mound and throw to his third baseman, who tags the base. The umpire then calls the runner out. As a result, the home run doesn't count and this is the third out.
While the other team is celebrating, the team in the outfield leaves the field. The coaches of the team that just hit the home run start questioning what happened. After the umpire explains to them why the batter is out, the coaches start verbally disputing the decision.
After a long discussion with both team coaches, the umpire decides to change his call and allows the home run to count. This is in spite of one of the outfield coaches openly admitting that the player missed third base.
Is there any basis in the rules for the call being changed, or was the original call correct?
Even if the original call was incorrect, is the umpire permitted to change it at this stage once the outfield team has left the field?
Should umpires in little league be making decisions based on input from coaches from either or both teams?
Comment: VTC, *too broad*. You are asking three separate questions which arise from a scenario, related though they may be. At the very least, the third question must be split off. The others would fare better if also split up.
Comment: I've added the rules tag, since there is probably a "can the umpire" element to this question (as opposed to the "should the umpire" as covered by the officiating tag). I will attempt to edit the question, but please note that paragraphing makes the question easier to read. This can avoid unnecessary downvoting / close voting and make it more likely to receive an answer.
Comment: I've removed what I felt was not relevant to the general question. I don't think it was important what was said, but rather, the fact that the outfield coaches disputed the decision. I've tried to distill what you were getting at into three points at the end. If you feel this edit has changed the question too much, please feel free to roll it back.
Comment: I agree this may be too broad, but I disagree with the separation you have proposed. I think the second and third questions are the two most closely related. They go to the core issue, which is the decision making process in little league baseball. The first question, if any, should be split off, as it is a simple rules question based on whether a player who fails to touch third should be tagged out.
Comment: I think we need more information from the original questioner, as to whether they want information on the decision making process (how late can a decision be changed and should coaches have input into a changed decision in little league), or the correctness of the out decision itself.
Comment: I have a question about "despite one of the outfield coaches openly admitting" - what does this mean?  A coach from the team in the field? Or a base-coach for the team at bat?
Comment: This happened to me once. The empire called something, and the coach overruled him since the coach was the league president, even though the empire disagreed with the coach...
Answer: Traditionally, an umpire only changes his calls after discussion with the rest of the umpiring crew. Technically, the umpire that made the call is the only one that can overturn it.
So yes, an Umpire is allowed to change a call like this, however it is highly unusual to do so after coaches protest. If the kid did truly miss the bag, there is really no reason to call him safe, and changing a call like this is unprofessional.
However, depending on the ages of the kids, and the opinion of the pitching teams coach, this may not be so egregious. If the kids are young, and the coach of the defense agrees that they want to let the kid have the homerun, than this call might not be so bad. If the kids are older, and this is the championship in a competitive league, or the defense's coach was not in agreement, this is poor umpiring.
Answer: I would say, technically, the umpire can do so, but there is usually a more formal process vs off the cuff, which seems to have been followed here.
So, this brings up the larger issue of what we mean by "little league."  A relatively informal kids' T-ball league?  The earliest iterations of pitched baseball, meant mostly to get kids interested and having fun?  More competitive leagues that are looking to qualify for the eventual World Series?
It makes a difference, both in how they want rules applied for that league, and the amount of experience and formal structure there is to the umpires organizations that officiate the games.
If it's the lower levels, do you really want to crush a kids' spirit because he got so excited about hitting his first-ever home run, a game-winner, that he missed third base?  Do you want the other team to "earn" their win not through play on the field, but a technicality?  As the kids get more experience, we expect them to understand the rules, follow them more tightly, and to understand the consequences, but if we're talking about 7 or 8 year-olds, it would be a horrible thing to be that pedantic about the rules and to look to win games on that kind of a technicality at that level.  It sends all the wrong messages about sports to kids, IMO.
Answer: I have been a baseball umpire for 20+ years and have done everything from little league to high school, to adult to junior college.  Here is my take.

An umpire can change his call, period.  Case in point.  Last weekend I was on the plate and I thought an inside pitch growing hit the knob of the bat and I immediately called foul ball. My partner had the same thing.  However, the batter was quick to show me a growing welt with baseball stitches on his lower arm very near his wrist. Easy, changed to HBP, told the opposing coach why and everyone was fine.
The defensive team made a correct appeal on the first runner missing 3B, the runner was called out and with 2 outs that ends the inning and the home run does not count.  For scoring purposes the batter is awarded a hit, can be a single, double or triple.  Up to the scorekeeper.
With less than 2 outs the home run counts, he scores and the runner that missed the base is declared out.

Hope this helps!


Using the Clone Function(jQuery)

Question:
Possible Duplicate:
problem when cloning jQuery UI datepicker

I used the jQuery clone function to clone a table with a datepicker function, but each time I clone a new table and try to click on its datepicker input, it appears on the default table that was cloned:
$('.clone_table').on("click", function() {
    var $fromTable = $(this).closest(".contain");
    var $cloneTable = $fromTable.clone(true);
    $(".contain:last").after($cloneTable);
    var selects = $fromTable.find("select");
    $(selects).each(function(i) {
        var select = this;
        $cloneTable.find("select").eq(i).val($(select).val());
    });
});

Comment: This is the Table function `this.insertStatsTable = function() {
  self.insertInstanceRow($(".contain:first"));
  var $newTable = $(".contain:first").clone(true);
  $("tbody tr td select:eq(0)", $newTable).attr("disabled", "true").append($("").val("*").text("AGGREGATE VALUE"));
  self.generateTimeColumns(defaultcolumn, $newTable);
  ($("tbody tr", $(".contain:first"))).remove();
  $(".contain:last").after($newTable);
  $newTable.show();
  $(".datepicker", $newTable).datetimepicker({
   onClose: function(p1, p2) {
    processStaticTable($(p2.input));
 }
  });
  return $newTable;
 };`
Comment: @deetu it would generally be better to edit your original post instead of pasting code in the comments.  It does have a 600 character limit after all. :P
Answer: The clone function MUST be called with parameters of true,  true (withDataAndEvents and deepWithDataAndEvents) for this to work. withDataAndEvents might be enough though.
$("#element").clone(true, true); //You might not need the last true!

Comment: its fine now, what i did was ` $(".datepicker", $cloneTable).datetimepicker("destroy").removeAttr("id");
                 $(".datepicker", $cloneTable).datetimepicker({
      onClose: function(p1, p2) {
       processStaticTable($(p2.input));
      }
     });`

Using the Clone Function(jQuery)


How to emit event each action

Question: I am an entry level developer of RxJS ,
I use
react,
redux,
react-redux,
redux-observable,
above of all in my side project;
but I can not figure out , why can not my epic code blocks work as I want , hopes somebody helps my out.
/* store actions */

export const ACTION_1 = 'ACTION_1';
export const ACTION_2 = 'ACTION_2';
export const ACTION_3 = 'ACTION_3';

/* store reducer */
import * as actionTypes from 'actions.js';

const someInitialState = {};

const reducer = (state = someInitialState , action) => {

    switch(actionTypes.ACTION_1){
        case(actionTypes.ACTION_1):{
            return {
                ...state,
                /*do something...*/
            }
        }
        case(actionTypes.ACTION_2):{
                /*do something...*/
        }
        case(actionTypes.ACTION_3):{
                /*do something...*/
        }
    }
}

/* actionEpic.js */

import * as actionTypes from 'actions.js'

const actionEpic = (action$ , store$) => {
    retrun action$.pipe(

        ofType(actionTypes.ACTION_1),
        map( () => ({type : actionTypes.ACTION_2}) ),
        map( () => ({type : actionTypes.ACTION_3}) ),

    )
}

This is a pseudo code , so please ignore the detail syntax and structure.
My Question is Why in my actionEpic epic ,
the first action 1 and last action 3 will be emitted and works fine,
but the action 2 in between always be ignored , never emit.
what if I want to emit these 3 action ,one by one , how to do it?
could somebody helps me,
and sorry about the english grammar problems around my post,
thx a lots.
Answer: You can emit both actions using flattening operators, for example mergeMap, so your code would be something like:

const { of } = rxjs; // = require("rxjs")
const { filter, mergeMap } = rxjs.operators; // = require("rxjs/operators")

const actionEpic = (actions$) => {
  return actions$.pipe(
    filter(a => a.type === "ACTION_1"),
    mergeMap(() => [
      { type: "ACTION_2" },
      { type: "ACTION_3" }
    ])
  )
}

const actions$ = of({ type: "ACTION_1" });
actionEpic(actions$).subscribe(e => console.log(e));

How to emit event each action


How to compute the power of Wilcoxon test?

Question: I am using Wilcoxon test to compare two paired sets of data for whether their means differ. Besides the p-value, I would also like to know the power of this test. How to compute it in R? Thank you in advance.
Comment: The power depends on the shape of the true distribution of the pairwise differences. You have to specify your assumption what kind of distribution this is.
Comment: One comment: The wilcoxon signed rank test, tests the hypothesis that the MEDIANS differ I do believe. http://udel.edu/~mcdonald/statsignedrank.html
Comment: B_Miner, no, it is for means.  There is an assumption of balance around the median but the medians is not what you're comparing.
Comment: @john - is the source I cite incorrect?
Comment: B_Miner... I did a few quick searches.  An intro stats text next to me, a Vassar site, and Wikipedia support my assertion.  Nevertheless, there are a couple of 'handbooks' like the one you cited that do state it's about differences between medians.  I didn't read them all carefully but now I'm thinking about it and I'm wondering if it actually matters.  In fact, the NIST reference I found didn't even mention means or medians. hmmmm... probably more time than I want to spend on this topic until I actually want to do one of these.
Comment: @B_Miner what your link *actually* says is "*median difference between pairs of observations*" (which is correct). That's not the same as the difference in medians of the groups; I believe you simply misinterpreted the phrase.
Comment: @eJohn The signed rank test does not compare means. Nor strictly speaking does it compare medians. (It's quite easy to demonstrate that it does neither.) If you add some assumptions - ones already required under the null anyway - it serves to compare either medians or means however (providing means exist).
Answer: I don't know if there's an analytical solution to your question, but when all else fails, one can simulate the distribution you think the two samples come from many thousands of times using Monte Carlo methods. The percentage of those samples the Wilcoxon test correctly identifies as "different" is the power of the test. For example, if you generated 10,000 different simulated paired samples that match your actual data in terms of size and the distribution they came from, and 8,000 of them are correctly identified by the test as different, your power = 0.80.
Answer: Suppose you have Ho: median <= 8 and Ha: median > 8
As par for the course, remove any values from your data equal to 8.
Calculate the sample mean and sample standard deviation. Use the sample mean as your alternate mean for the power calculation.
In my data, n=9 (df = 8) and I'm testing at alpha = 5%. The t critical value is 1.86.
Also, the sample mean from my data is 12.7333333... and the sample standard deviation is 7.79527429.
Calculate X1 = 1.86(7.97527429)/sqrt(9) + 8 = 12.94467006
Calculate t1 = 12.94467006 - 12.733333.... = 0.211336726
Then, power = P(t > 0.211336726) = 0.491 based on df = 8.
I found this procedure here:
https://ncss-wpengine.netdna-ssl.com/wp-content/themes/ncss/pdf/Procedures/PASS/Wilcoxon_Signed-Rank_Tests.pdf
However, they are using a non-central t distribution which only complicates the matter.
Comment: This pair of hypotheses is not the same as testing whether the medians differ. Also,  using means to compute the power will need justification.


Multicollinearity based on F-test vs Individual T-Tests

Question: I am currently working with a multiple regression with three parameters; $\beta_1, \beta_2, \beta_3$. The individual T-test for each parameter contains large p values (>.05) while the p-value of the F-test for the null hypothesis that all coefficients are 0 is quiet small (approx. 0).
Is this suggestive of the issue suggested here of multicollinearity? And thus, would you reject or accept the null hypothesis, either for individual parameters or the model as a whole?
Answer: It's okay to reject the idea that all three parameters equal zero while not being able to pin down which of the three are nonzero. That is logically consistent and seems to be what is happening, statistically.
Comment: @Bepop That really warrants its own posted question, one that I would expect to be well-received if not for it almost certainly being a duplicate (so a good question, just one that I suspect has been asked and answered). Working from memory, it seems that there has been work to give the usual inferences from regularized regression (maybe stepwise, too), but they are not in the mainstream of statistics (by which I mostly mean that I do not know any offhand).
Comment: Thanks! Would you say it makes sense to remove 1 or 2 predictors and repeat the regression?
Comment: @Bepop Then you're doing a form of stepwise regression, which can be highly problematic for the kind of inferential work you're doing ([could work well if you just care about predictions, however](https://stats.stackexchange.com/questions/594106/how-competitive-is-stepwise-regression-when-it-comes-to-pure-prediction)). Briefly, when you fit the model with the variables removed, your statistics all assume that you had not checked those variables and then removed them, rather than reflecting the reality of y workflow, and you can wind up being too optimistic with your claims.
Comment: Thanks again! This is slightly unrelated but do any extensions of Lin Reg (from variable selection to LASSO/Ridge techniques, etc) have mainstream inferential usage in statistics? For ex, I know Ridge regression doesn't really have the confidence intervals that OLS allows for
Comment: Related: https://stats.stackexchange.com/questions/151403/significance-of-individual-coefficients-vs-significance-of-both/151410#151410


How to tell if a note is sharp or flat if there is no indicator

Question: So I have this sheet music by Coldplay, the title of the song is called Clocks and I am trying to understand the notes. My question is how do I know when a flat or sharp is supposed to be played? I wrote down the notes and what I have is D A G D A G D A for the first set. However, when I watch tutorials on how it is played they use D# A# and G. How am I supposed to know that only certain notes are sharp (or flat) because when I look at the sheet and the key signature, only the F key is sharp, so how am I supposed to ascertain that the only certain keys are supposed to be sharp or flat or normal? To summarize, how am I supposed to know G is played normally (not flat or sharp) and D and A are supposed to be sharp.
Here is the sheet music:
https://ibb.co/w635zmC
Any help will be upvoted, thank you.
Comment: Maybe a link to the tutorials you are referring to could help? From the score you give D and A should be played naturals. Maybe the tutorial are playing a transposed version.
Comment: [link](https://www.youtube.com/watch?v=L1ts9crexyE)  [link](https://www.youtube.com/watch?v=TeWEKtqeFI0) Here are the two that I watched
Comment: The first linked tutorial has a link to sheet music in the description, which you'll find is different than the sheet music you linked to in your own question: it has four flats in its key signatures (not sharps), hence the different notes (which would be E-flat, B-flat and G, not D-sharp, A-sharp and G).
Answer: The issue is that the sheet music you have is a half step lower than the Coldplay recording and this tutorial:

In the sheet music you provided the chords are D, Am, Em but the actual chords are Eb, Bbm, Fm. It's better to think of them as flats instead of sharps by the way, the notes Eb-Bb-G instead of D#-A#-G.
They chose to write the sheet music in the key of G, even though the song is in D (the sheet music version, the actual song is in Eb) maybe in order to not have to use natural signs on the Am chords But this is a bad practice in general, it leads to confusion.
Comment: @Tim, it's in D but with a G key signature, saves ink writing natural signs on the C's of the Am chords :)
Comment: That would put it into D Mixolydian, then?
Comment: @Tim Sounds reasonable, I didn't think of it from a modal point of view.
Comment: @JohnBelzaguy Sorry! Yours is way more complete, I did not even bother looking for the actual key (or the correct score key for that matter…) (+1)
Comment: @Tom No worries, yours is on the money and +1 to you as well. We're all here to help each other out, that's the important thing,
Comment: Posting a song half an octave out! Why bother?
Comment: @JohnBelzaguy Neither did Coldplay.
Answer: The first link you provide in your comment is starting D# A# G but your score is not D A G but D A F#.
The score is thus transposed a semi-tone lower than the tutorial, maybe in order to simplify things ;).
Comment: Looking at the notes actually written by the piano keys - you'll see Eb, Bb. A far more usual way to write those two notes.
Comment: @Ret It's a *transposed* version, probably to get in a simpler key. Does not mean that the score is actually *simplified*. Note that in "popular" music the key is usually chosen to match the singer's voice (which you cannot change) not to simplify the playing ;)
Comment: @Tim yes I know, that was just not to confuse the OP further by using the same notation.
Comment: So it's just the simplified version of the sheet music? Thank you
Answer: If in doubt go by the sound. Listen to the official Coldplay version.
I think this tutorial may resolve it.

Coldplay - Clocks | Guitar Lesson (Tutorial) Chords & Intro

You will see that the guitar is played using D Am etc. in terms of chord shapes.  However the guitarist has the capo on the first fret, thus raising the chords by a semitone to Eb.
There are many possibilities here, I'll mention three.

Coldplay were tuned a semitone higher than standard pitch when they recorded this (unlikely)

The song was originally written in the key of D but the singer in the band asked for the band to play it higher to make it easier for his voice.

The sheet music gives you the easy version of the guitar chords and assumes you know to use a capo.


How to setup a Linux LAN local mail?

Question: I'm looking for instructions on how to create a Linux local mail server for a LAN, in the following way:

The Server (Ubuntu) as the SMTP server;

The workstations getting their mail (and sending to other clients) through the server.

Initially, only local mail (say ending with @localhost.com).
So far, I've found stuff about using the very client machine as the host, not including the server.
Thank you.
Answer: You should install a mail service such as Postfix (that's the one I use).
Then simply have people use that service using the IP address of that one computer.
If you really want each computer to be able to send mail, then look at installing a sendmail utility and set it up to send mail to the computer with Postfix (or other mail service).
The setup for Postfix needs to accept relaying the emails sent from another service. Since you have a local network (LAN), you can just put that IP as one of the trusted IP addresses in Postfix. Without that, it will reject the mail sent by sendmail.
Maybe something like this:
<code>mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 10.0.0.0/24
</code>
The 127. and ::1 are there by default. I added 10.0.0.0/24 as an example. Whatever you use for your network (another often used is 192.168.1.0/24).
Services that support SMTP directly can be given the IP address of your Postfix system instead of using sendmail.
Comment: Thank you for your answer, Alexis.

Yes, Postfix is needed. I'll read the docs, especially when it comes to mail storage (where and how to store mail) and how to create local mail addresses, only for internal use, and public ones.

How to setup a Linux LAN local mail?


Non-linear Cauchy problem for $xu_x+uyu_y=-xy$

Question:
Consider the partial differential equation $$x\frac{\partial u}{\partial x}+uy\frac{\partial u}{\partial y}=-xy$$ for $x>0$ subject
  to $u=5$ on $xy=1$. Then
$(a)$ $u(x,y)$ exists when $xy\leq 19$ and $u(x,y)=u(y,x)$ for
  $x>0,y>0$.
$(b)$ $u(x,y)$ exists when $xy\geq 19$ and $u(x,y)=u(y,x)$ for
  $x>0,y>0$.
$(c)$ $u(1,11)=3$ and $u(13,-1)=7$.
$(d)$ $u(1,-1)=5$ and $u(11,1)=-5$.

I attempted the method of characteristics and obtained the equations as $$\frac{dx}{x}=\frac{dy}{uy}=\frac{du}{-xy}$$ Afterwards I took first, third and second, third ratio respectively and then adding them together to find one characteristic as $\displaystyle{(u+1)^2+2xy=c_1}$, $c_1$ being some arbitrary constant. Now if I use that equation to first and second ratio, it gives $$\frac{dx}{x}=\frac{dy}{y(\sqrt{c_1-2xy}-1)}$$ which is obviously too laborious to solve. I don't think actual solution to this problem would involve that much calculation. What is the best possible approach to this problem? If solution for $u(x,y)$ is the only way, what is the fault at my attempt above? Thanks in advance.
Comment: This equation is not linear due to the presence of $u$ in the $uyu_y$ term.
Comment: Yes, this is not linear, but it should be quasi-linear instead of nonlinear, I think.
Comment: Quasi-linear is a class of non-linear.  You might change your title by replacing
"linear" with "non-linear".  Cheers!
Answer: I agree with your result :
$$(u+1)^2+2xy=c_1$$
is a first characteristic equation.
Then one is tempted to look for a second characteristic equation in order to get the general solution.
But in the present case we don't need the general solution since the first characteristic equation alone can be fitted to the specified boundary condition :
$u=5$ on the curve $xy=1$, with $(5+1)^2+2(1)=c_1=38$.
Thus the particular solution fitting to the boundary condition is a curve lying on the particular characteristic curve whose implicit equation is :
$$(u+1)^2+2xy=38$$
The solution on explicit form is :
$$\boxed{u(x,y)=-1+\sqrt{38-2xy}}$$
Note that the part $u=-1-\sqrt{38-2xy}$ of the characteristic curve is rejected because the boundary condition wouldn't be satisfied on it.
With this explicit solution it is easy to find which proposed options are exact or not.
$$ $$
In addition, COMPLETELY SOLVING the PDE :
A second characteristic equation comes from
$\frac{dx}{x}=\frac{du}{-xy}= \frac{2du}{(u-1)^2-c_1}$
$\ln|x|+\int\frac{2du}{c_1-(u-1)^2}=c_2$
$\ln|x|-\ln|c_1-(u+1)^2|-\frac{2}{\sqrt{c1}}\tanh^{-1}\left(\frac{u+1}{\sqrt{c_1}} \right)=c_2$
$\ln|x|-\ln|2xy|-\frac{2}{\sqrt{(u+1)^2+2xy}}\tanh^{-1}\left(\frac{u+1}{\sqrt{(u+1)^2+2xy}} \right)=c_2$
$-\ln|y|-\frac{2}{\sqrt{(u+1)^2+2xy}}\tanh^{-1}\left(\frac{u+1}{\sqrt{(u+1)^2+2xy}} \right)=c_2+\ln(2)=c'_2$
Genertal solution on the form of implicit equation $c_1=F(c'_2)$ :
$$\boxed{(u+1)^2+2xy=F\left(-\ln|y|-\frac{2}{\sqrt{(u+1)^2+2xy}}\tanh^{-1}\left(\frac{u+1}{\sqrt{(u+1)^2+2xy}} \right) \right)}$$
$F$ is an arbitrary fonction to be determined according to the boundary condition.
Condition : $u=5$ on the curve $xy=1$ :
$38=F\left(-\ln|y|-\frac{2}{\sqrt{38}}\tanh^{-1}\left(\frac{6}{\sqrt{38}} \right) \right)$
Due to $\ln|y|$ it is impossible that the function $(\ln|y|+C)$ be constant, except if the function itself is a constant function $F=38$
Now the function $F$ is determined and we see that the particular solution of the PDE which satisfies the boundary condition is the function already found above.
Answer: The Lagrange's auxiliary equations for the given PDE are $$\frac{dx}{x}=\frac{dy}{uy}=\frac{du}{-xy}\tag1$$
Choosing $~y,~x,~(1+u)~$ as multipliers , each fraction of $(1)$
$$=\dfrac{ydx+xdy+(1+u)du}{xy+uxy-xy(1+u)}=\dfrac{ydx+xdy+(1+u)du}{0}$$
So $$ydx+xdy+(1+u)du=0\implies (1+u)^2+2xy=c$$where $~c~$ is constant.
Given that $~u=5\quad \text{on}\quad xy=1~$, so $~c=36+2=38$.
Therefore $$(1+u)^2+2xy=38\implies u=\sqrt{38-2xy~}-1$$

$u(x,y)~$exists if $$~38-2xy\ge 0\implies x\le 19$$

Also here $$u(x,y)=\sqrt{38-2xy~}-1=\sqrt{38-2yx~}-1=u(y,x)\qquad\text{for$~~x>0,y>0$}$$So we can conclude that option $(a)$ is correct while option $(b)$ is not.

$$u(1,11)=\sqrt{38-22~}-1=3$$

$$u(13,-1)=\sqrt{38-26~}-1=7$$
so option $(c)$ is correct.

$$u(1,-1)=\sqrt{38+2~}-1=\sqrt{40}-1\ne 5$$
$$u(10,1)=\sqrt{38-22~}-1=3\ne 5$$
so option $(d)$ is not correct.


How is video replay implemented in association football?

Question: It's a little known fact that video replay in football has already begun its entrance into the sport, at least in experimental stages.  The NCAA recently approved it, and the MLS was testing it in a youth tournament.  However there seems to be a dearth of knowledge on how it is actually implemented during the play of the game.  While a few places give suggestions on how it could, no one seems to know what exactly the official procedure is, which should at least be known from the MLS test.
Answer: Here's a link to an article regarding it's first use in competitive play. The official procedure right now appears to be:

The VAR (video assistant referee) automatically reviews every goal, every red card and all penalties, and communicates directly with the head referee, who ultimately decides whether to resort to the monitor.

It appears that behind each goal is a small monitor for the referee to make a quick review of the play if they so choose. The last I heard regarding full implementation in MLS, is that Don Garber (MLS commissioner) is hoping for it to be used starting in the second half of the 2017 season.
Answer: IFAB's VAR Protocol clearly defines how Video Assistant Referee technology needs to be implemented. Here is the Principle section of the protocol:

The use of VARs in football matches is based on a number of
  principles, all of which must apply in every match using VARs.

A video assistant referee (VAR) is a match official, with independent access to match footage, who may assist the referee only
  in the event of a 'clear and obvious error' or 'serious missed
  incident' in relation to:

a. Goal/no goal
b. Penalty/no penalty
c. Direct red card (not second yellow card/caution)
d. Mistaken identity (when the referee cautions or sends off the wrong player of the offending team)

The referee must always make a decision, i.e. the referee is not permitted to give 'no decision' and then use the VAR to make the
  decision; a decision to allow play to continue after an alleged
  offence can be reviewed.
The original decision given by the referee will not be changed unless the video review clearly shows that the decision was a 'clear
  and obvious error'.
Only the referee can initiate a 'review'; the VAR (and other match officials) can only recommend a 'review' to the referee.
The final decision is always taken by the referee, either based on information from the VAR or after the referee has undertaken an
  'on-field review' (OFR).
There is no time limit for the review process as accuracy is more important than speed.
The players and team officials must not surround the referee or attempt to influence if a decision is reviewed, the review process or
  the final decision.
The referee must remain 'visible' during the review process to ensure transparency.
If play continues after an incident which is then reviewed, any disciplinary action taken/required during the post-incident period is
  not cancelled, even if the original decision is changed (except a
  caution/sendoff for stopping a promising attack or DOGSO).
If play has stopped and been restarted, the referee may not undertake a 'review' except for a case of mistaken identity or for a
  potential sending-off offence relating to violent conduct, spitting,
  biting or extremely offensive, insulting and/or abusive gesture(s).
The period of play before and after an incident that can be reviewed is determined by the Laws of the Game and VAR protocol.
As the VAR will automatically 'check' every situation/decision, there is no need for coaches or players to request a 'review'.

Here is how VAR was implemented during the FIFA World Cup 2018:
The same 4 incidents were reviewable as defined in VAR protocol. Then:

STEP 1 - Incident occurs
The referee informs the VAR, or the VAR recommends to the referee that
  a decision/incident should be reviewed.
STEP 2 - Review and advice by the VAR
The video footage is reviewed by the VAR, who advises the referee via
  headset what the video shows.
STEP 3 - Decision or action is taken
The referee decides to review the video footage on the side of the
  field of play before taking the appropriate action/decision, or the
  referee accepts the information from the VAR and takes the appropriate
  action/decision


Confusing result with quadratic regression

Question: So, I'm trying to fit some pairs of x,y data with a quadratic regression, a sample formula can be found at http://polynomialregression.drque.net/math.html.
Following is my code that does the regression using that explicit formula and using numpy inbuilt functions,
import numpy as np
x = [6.230825,6.248279,6.265732]
y = [0.312949,0.309886,0.306639472]
toCheck = x[2]

def evaluateValue(coeff,x):
    c,b,a = coeff
    val = np.around( a+b*x+c*x**2,9)
    act = 0.306639472
    error=  np.abs(act-val)*100/act
    print "Value = {:.9f} Error = {:.2f}%".format(val,error)

###### USing numpy######################
coeff = np.polyfit(x,y,2)
evaluateValue(coeff, toCheck)

################# Using explicit formula
def determinant(a,b,c,d,e,f,g,h,i):
    # the matrix is [[a,b,c],[d,e,f],[g,h,i]]
    return a*(e*i - f*h) - b*(d*i - g*f) + c*(d*h - e*g)

a = b = c = d = e = m = n = p = 0
a = len(x)
for i,j in zip(x,y):
        b += i
        c += i**2
        d += i**3
        e += i**4
        m += j
        n += j*i
        p += j*i**2
det = determinant(a,b,c,b,c,d,c,d,e)
c0 = determinant(m,b,c,n,c,d,p,d,e)/det
c1 = determinant(a,m,c,b,n,d,c,p,e)/det
c2 = determinant(a,b,m,b,c,n,c,d,p)/det

evaluateValue([c2,c1,c0], toCheck)

######Using another explicit alternative
def determinantAlt(a,b,c,d,e,f,g,h,i):
    return a*e*i - a*f*h - b*d*i +b*g*f + c*d*h - c*e*g # <- barckets removed

a = b = c = d = e = m = n = p = 0
a = len(x)
for i,j in zip(x,y):
        b += i
        c += i**2
        d += i**3
        e += i**4
        m += j
        n += j*i
        p += j*i**2
det = determinantAlt(a,b,c,b,c,d,c,d,e)
c0 = determinantAlt(m,b,c,n,c,d,p,d,e)/det
c1 = determinantAlt(a,m,c,b,n,d,c,p,e)/det
c2 = determinantAlt(a,b,m,b,c,n,c,d,p)/det

evaluateValue([c2,c1,c0], toCheck)

This code gives this output
Value = 0.306639472 Error = 0.00%
Value = 0.308333580 Error = 0.55%
Value = 0.585786477 Error = 91.03%

As, you can see these are different from each other and third one is totally wrong. Now my questions are:
1. Why the explicit formula is giving slightly wrong result and how to improve that?
2. How numpy is giving so accurate result?
3. In the third case only by openning the parenthesis, how come the result changes so drastically?
Answer: So there are a few things that are going on here that are unfortunately plaguing the way you are doing things.  Take a look at this code:
for i,j in zip(x,y):
        b += i
        c += i**2
        d += i**3
        e += i**4
        m += j
        n += j*i
        p += j*i**2

You are building features such that the x values are not only squared, but cubed and fourth powered.
If you print out each of these values before you put them into the 3 x 3 matrix to solve:
In [35]: a = b = c = d = e = m = n = p = 0
    ...: a = len(x)
    ...: for i,j in zip(xx,y):
    ...:         b += i
    ...:         c += i**2
    ...:         d += i**3
    ...:         e += i**4
    ...:         m += j
    ...:         n += j*i
    ...:         p += j*i**2
    ...: print(a, b, c, d, e, m, n, p)
    ...:
    ...:
3 18.744836 117.12356813829001 731.8283056811686 4572.738547313946 0.9294744720000001 5.807505391292503 36.28641270376207

When dealing with floating-point arithmetic and especially for small values, the order of operations does matter.  What's happening here is that by fluke, the mix of both small values and large values that have been computed result in a value that is very small.  Therefore, when you compute the determinant using the factored form and expanded form, notice how you get slightly different results but also look at the precision of the values:
In [36]: det = determinant(a,b,c,b,c,d,c,d,e)

In [37]: det
Out[37]: 1.0913403514223319e-10

In [38]: det = determinantAlt(a,b,c,b,c,d,c,d,e)

In [39]: det
Out[39]: 2.3283064365386963e-10

The determinant is on the order of 10-10!  The reason why there's a discrepancy is because with floating-point arithmetic, theoretically both determinant methods should yield the same result but unfortunately in reality they are giving slightly different results and this is due to something called error propagation.  Because there are a finite number of bits that can represent a floating-point number, the order of operations changes how the error propagates, so even though you are removing the parentheses and the formulas do essentially match, the order of operations to get to the result are now different.  This article is an essential read for any software developer who deals with floating-point arithmetic regularly: What Every Computer Scientist Should Know About Floating-Point Arithmetic.
Therefore, when you're trying to solve the system with Cramer's Rule, inevitably when you divide by the main determinant in your code, even though the change is on the order of 10-10, the change is negligible between the two methods but you will get very different results because you're dividing by this number when solving for the coefficients.
The reason why NumPy doesn't have this problem is because they solve the system by least-squares and the pseudo-inverse and not using Cramer's Rule.  I would not recommend using Cramer's Rule to find regression coefficients mostly due to experience and that there are more robust ways of doing it.
However to solve your particular problem, it's good to normalize the data so that the dynamic range is now centered at 0.  Therefore, the features you use to construct your coefficient matrix are more sensible and thus the computational process has an easier time dealing with the data.  In your case, something as simple as subtracting the data with the mean of the x values should work.  As such, if you have new data points you want to predict, you must subtract by the mean of the x data first prior to doing the prediction.
Therefore at the beginning of your code, perform mean subtraction and regress on this data.  I've showed you where I've modified the code given your source above:
import numpy as np
x = [6.230825,6.248279,6.265732]
y = [0.312949,0.309886,0.306639472]

# Calculate mean
me = sum(x) / len(x)
# Make new dataset that is mean subtracted
xx = [pt - me for pt in x]

#toCheck = x[2]

# Data point to check is now mean subtracted
toCheck = x[2] - me

def evaluateValue(coeff,x):
    c,b,a = coeff
    val = np.around( a+b*x+c*x**2,9)
    act = 0.306639472
    error=  np.abs(act-val)*100/act
    print("Value = {:.9f} Error = {:.2f}%".format(val,error))

###### USing numpy######################
coeff = np.polyfit(xx,y,2) # Change
evaluateValue(coeff, toCheck)

################# Using explicit formula
def determinant(a,b,c,d,e,f,g,h,i):
    # the matrix is [[a,b,c],[d,e,f],[g,h,i]]
    return a*(e*i - f*h) - b*(d*i - g*f) + c*(d*h - e*g)

a = b = c = d = e = m = n = p = 0
a = len(x)
for i,j in zip(xx,y): # Change
        b += i
        c += i**2
        d += i**3
        e += i**4
        m += j
        n += j*i
        p += j*i**2
det = determinant(a,b,c,b,c,d,c,d,e)
c0 = determinant(m,b,c,n,c,d,p,d,e)/det
c1 = determinant(a,m,c,b,n,d,c,p,e)/det
c2 = determinant(a,b,m,b,c,n,c,d,p)/det

evaluateValue([c2,c1,c0], toCheck)

######Using another explicit alternative
def determinantAlt(a,b,c,d,e,f,g,h,i):
    return a*e*i - a*f*h - b*d*i +b*g*f + c*d*h - c*e*g # <- barckets removed

a = b = c = d = e = m = n = p = 0
a = len(x)
for i,j in zip(xx,y): # Change
        b += i
        c += i**2
        d += i**3
        e += i**4
        m += j
        n += j*i
        p += j*i**2
det = determinantAlt(a,b,c,b,c,d,c,d,e)
c0 = determinantAlt(m,b,c,n,c,d,p,d,e)/det
c1 = determinantAlt(a,m,c,b,n,d,c,p,e)/det
c2 = determinantAlt(a,b,m,b,c,n,c,d,p)/det
evaluateValue([c2,c1,c0], toCheck)

When I run this, we now get:
In [41]: run interp_test
Value = 0.306639472 Error = 0.00%
Value = 0.306639472 Error = 0.00%
Value = 0.306639472 Error = 0.00%

As some final reading for you, this is a similar problem that someone else encountered which I addressed in their question: Fitting a quadratic function in python without numpy polyfit.  The summary is that I advised them not to use Cramer's Rule and to use least-squares through the pseudo-inverse.  I showed them how to get exactly the same results without using numpy.polyfit.  Also, using least-squares generalizes where if you have more than 3 points, you can still fit a quadratic through your points so that the model has the smallest error possible.


How Can I calculate Power function of Feng and Sun test?

Question: I'm wondering how I can calculate the power function of the test statistic

$$T_n=\frac{1}{n_1(n_1-1)}\frac{1}{n_2(n_2-1)}\sum_{k=1}^p  \underset{i\not=j}{\sum^{n_1}\sum^{n_1}}
 \underset{s\not=t}{\sum^{n_2}\sum^{n_2}}\frac{(X_{1ik}-X_{2sk})(X_{1jk}-X_{2tk})}{\hat{\sigma}^2_{1k(i,j)}+\gamma\hat{\sigma}^2_{2k(s,t)}}$$
where $\gamma=n_1/n_2$, $\hat{\sigma}^2_{1k(i,j)}$ is the sample variance of $\{X_{1lk}\}_{l=1}^{n_1}$ excluding $X_{1ik}$ and $X_{1jk}$

which is given in Feng and Sun (2015) [1], page 31, from theorem 1 (same page):

Under Conditions (C1)--(C3), as $p,n \to \infty$,
  $\frac{T_n-E(T_n)}{\sqrt{\mathrm {var}(T_n)}}\overset{\mathcal{L}}{\longrightarrow} N(0,1).$

Any help will be appreciated.
[1]: L.Feng and F.Sun (2015),
"A note on high-dimensional two-sample test",
Statistics and Probability Letters, 105, 29–36
http://www.sciencedirect.com/science/article/pii/S0167715215001789
[arXiv version arXiv:1502.05455 [stat.ME] here]
Comment: I have added some brief quotes of the precise things referred to though additional context would help
Comment: I know my question was bad! You edit is even more appreciated than your answer, thanks @Glen_b
Answer: The short answer is you can't compute power from theorem 1. That's not what it's about. Theorem 1 establishes the asymptotic distribution of the test statistic under the null hypothesis, as Feng and Sun state quite directly, just above the statement of the theorem:

The following theorem establishes the asymptotic null distribution
  of $T_n$.

(emphasis mine)
The null distribution doesn't tell us about power (which is the rejection rate under some alternative).
The authors do subsequently perform some power calculations, which they describe in a later section, and which they obtain via simulation.
Power is calculated for a sequence of alternatives by specifying the exact situation at each specific alternative, simulating samples (from whichever  high-dimensional distribution they chose to look at) many times, performing their test each time and calculating the proportion of rejections at that specific alternative, and repeating the process at every alternative they want to give the power for. It is possible to compute power curves and power surfaces in this fashion, given sufficient computational effort.
[If such an exercise in power simulation is not something you've done before, don't start with this test - start with something much simpler, such as an investigation of power for the Wilcoxon-Mann-Whitney univariate two sample test. You'll have enough hurdles to overcome doing that, but once you've done generated a few power curves for simpler cases, much about this more complex situation will become considerably clearer.]


For each $x \geq 6$ there exists a prime $p$ such that, $x - 1 > p > 1$ and $p$ does not divide $x$.

Question: Here is the proof that I have constructed. I am basically wondering if this proof works. Also feel free to post any simpler proofs or improvements/critiques on this one.
Let $x \in \mathbb{Z}$ be such that $x \geq 6$. Now suppose for the sake of contradiction we have that all the primes less than $x$, $2 , \cdots , p_n$ , $p_i | x$. Notice here that $p_n$ is the largest prime is less than $x$. Since $(p_i , p_j) = 1$ for each $i,j \in [1,n]$ such that $i \neq j$, we have $2\cdot 3 \cdots p_n | x$. Thus $x \geq 2 \cdot 3 \cdots p_n$. Consider $3\cdot 4 \cdots p_n - 2 = P$. It is easily verified that if $x \geq 6$ we have $x-1 > P > p_n$. Since $P$ P is less than $x$ it must be divisible by some $p_i$. $P$ is not divisible by 2, since it is 2 less than some product of odd numbers. If $p_i | P$ then $p_i| (3\cdots p_i \cdots p_n - P)$. Since $3\cdots p_i \cdots p_n - P = 2$ we have $p_i | 2$ which implies $p_i = 2$ which is a contradiction. Thus there must exist some prime less than $x-1$ that does not divide $x$.
Comment: but for $x=6$ the primes $1 1 this is true for every x ≥ 3.
Comment: I would say that any counterexample x would have to be a multiple of the product of all primes < x. If every prime p < 6 divides x then x is a multiple of 30. If every prime p < 30 divides x then x is a multiple of 6,469,693,230. If every prime p < 6,469,693,230 divides x then x is pretty big :-)
Comment: You might want to research Bertrand theorem.  If all p < x-1 divide x then if q is the largest prime less than x-1 then x = kp.  And between p and kp - 1 = x-1, there aren't any primes.  Bertrand theorem has something to say about that.
Answer: Supose $x\geq 5$, then every prime that divides $x-2$ also divides $x$, notice that if a prime divides $x$ and $x-2$ then that prime is $2$. We conclude that $x-2$ is a power of $2$, the same reasoning shows $x-4$ is also a power of $2$.
Since $x-4$ and $x-2$ are powers of $2$ we conclude $x=6$, and $x=6$ is the only counterexample larger than $4$.
Comment: this argument works for $x\geq 5$. Notice that the claim is not true for $x=4$.


jQuery DataTables with Node.js

Question: So i am trying to implement a pagination table with the datatables plugin, this is my first time using this plugin. I followed the documentation on the plugin and tried to get the values from the server through the use of Ajax, as per presented in the plugins documentation.
I seem to be getting the following error once i make the get request and i am unsure of why?
Error: Uncaught TypeError: Cannot read property 'length' of undefined
On client side i have the following code
viewReports = {
    init: function(){
        $('#paginatedData').DataTable({
            "processing": true,
            "serverSide": true,
            "ajax": '/viewreports'
        });

    }
};

$(document).ready(viewReports.init);

In my server side i have the following
router.get('/viewreports', function(res, req){

    async.parallel({
        viewReports: function(callback){
            restCall('/rest/bugbounty/latest/message/searchReport', 'POST', parameters, function(data){
                callback(null, data);
            });
        }
    }, function(err, result){
        if(!err){
            res.send(result.viewReports);
            res.render('viewreports');
        }
    });
});

Returned JSON:

{ reportList: [ { reportID: 'EIBBP-448', eBayUserID: ' ', reportStatus: 'New', summary: 'BugBounty Report created by Raj', lastUpdatedDate: '2015-06-15 01:05', createdDate: '2015-06-15 01:05', paypalLoginID: 'firstname.lastname@example.com' } ], searchStatus: 'Success', eBayUserID: '', errorCode: '0', rowCount: '6', pageNumber: '1', paginationValue: '1', paypalLoginID: 'firstname.lastname@example.com' }

It would be great to know if there is anyone who has worked with node.js server side processing for datatables
Comment: In server-side processing mode your server-side code should return data in the JSON format as described [here](https://datatables.net/manual/server-side#Returned-data). Please post the JSON file that your server returns.
Comment: so there is no specific file where i am saving my json data to, but upon rendering the route '/viewreports' i am able to see the following value on the console { reportList:
   [ { reportID: 'EIBBP-448',
       eBayUserID: ' ',
       reportStatus: 'New',
       summary: 'BugBounty Report created by Raj',
       lastUpdatedDate: '2015-06-15 01:05',
       createdDate: '2015-06-15 01:05',
       paypalLoginID: 'firstname.lastname@example.com' } ],
  searchStatus: 'Success',
  eBayUserID: '',
  errorCode: '0',
  rowCount: '6',
  pageNumber: '1',
  paginationValue: '1',
  paypalLoginID: 'email@example.com' }
Comment: Do i need to stringify the above json value?
Comment: Your response is not correct for server-side processing mode, please read [Server-side processing](https://datatables.net/manual/server-side) for more details and data format. And yes, you need to return string in JSON format.
Comment: Please Check answer of pankaj kumar [https://stackoverflow.com/questions/50731153/jquery-datatable-with-nodejs-mysql/78165849#78165849](https://stackoverflow.com/questions/50731153/jquery-datatable-with-nodejs-mysql/78165849#78165849)
Answer: You need to define dataSrc and columns.data - the following should work :
var table = $('#example').DataTable({
    processing: true,
    serverSide: true,
    ajax: {
        url: "/viewreports",
        dataSrc: "reportList"
    },
    columns: [
        { data : "reportID" },
        { data : "eBayUserID" },
        { data : "reportStatus" },
        { data : "summary" },
        { data : "lastUpdatedDate" },
        { data : "createdDate" },
        { data : "paypalLoginID" }
   ]
});

on an empty table :

dataSrc to specify what the array holding row items is named (cause of "Cannot read property 'length' of undefined")
columns.data to map item properties to columns
Answer: You simply don't have to bother with the server side processing.
I used a simple way to trick dataTables initialization.
First, you will need to fetch the data you want to display in the table through your most preferred way, after you have confirm that data displays well, now head to where you initialize dataTables and make it so that it delays before initialization.
setTimeout(() => {
    $('#yourtable').dataTable({
        // datatables customization options
    });
}, 100)

For example, in my case I gave it a delay of 100ms, and it works like a charm.

jQuery DataTables with Node.js


Interpretation of dccalpha and dccbeta in DCC-GARCH model

Question: I've used DCC-ARMA(1,0) -GARCH(1,1) to model green bond co-movement with some other marekts. In the output, I get the parameters "dccalpha" and "dccbeta". However, I do not know how to interpret these. Don't know if the output is needed to answer my quesiton but included it in the bottom in case someone is interested.
From previous literature, I have understood that alpha1 and beta1, aka jointalpha and jointbeta, tell me the degree of volatility spillovers in-between the time series. Is this true or does they rather show the correlation of the time series?
The reason why I distinguish these two is that "to me" correlation indicates the strength of which two variables tend to co-move which does not have to imply a causal relationship whereas spillovers means that volatility in prices of one market has a causal effect on price movements in another market.

*** Below is an update form the orignially posted question. It was made in order to answer Richard Hardy's response with an equation containing subscripts and denotations. These details makes the formula easier to understand.
Comment: What do you think about my answer? If it is helpful and clear, you may accept it by clicking on the tick mark to the left. Otherwise, you may ask for further clarification. This is [how Cross Validated works](https://stats.stackexchange.com/tour).
Answer: As I have said in "DCC GARCH - specifying ARCH and GARCH parameter matrices in Stata", I do not see how DCC could generate spillovers in the sense that $\sigma_{i,t}^2$ be a function of $\sigma_{j,t}^2$ for assets $\{i,j\}$ where $i\neq j$. For any asset in the set, its volatility is generated by a univariate GARCH model. Thus the asset's volatility depends only on its own past, not the past of other asset's volatilities. In that sense there are no spillovers or causal effects. There are only contemporaneous correlations between the standardized innovations.
dccalpha and dccbeta tell you how the correlations are evolving over time in an autoregressive manner. dccalpha provides the contribution of the realized correlation matrix from last period while dccbeta provides the contribution of a "long-run" (intentionally in quotation marks as this is likely not the standard name for it) correlation matrix that is due to all previous periods.
Comment: Okey, gotcha with the "no spillover effect part", thanks! However, what does it mean that they are evolving in an autoregressive manner? Seems wierd to me that there is two seperate parameters if both of them reflective how autoregressive the correlation is. What is then the difference betweem the dccalpha and the dccbeta :)
Comment: @Isac, updated.
Comment: It makes sense "on the surface" but have a hard time grasping the dccalpha matrix. Since I am not to familiar with matrices I like the algebraic approach of explaining how to retrieve DCC. The formula in the updated question shows this approach. That is,  the standardized residuals are calculated in Formula 1. Then the DCC is calculated in formula 2. Since the information set It-1 is used, this would be the beta? How would the alpha look like? Also, I couldn't understand this from Engle (2002). It is from that paper or do you have any other paper that would be appropiate to refer to? :)
Comment: @Isac, think about GARCH(1,1): there is a weighted combination of two components: the "realized" variance (the last error squared) plus the last conditional variance (the one underlying the last error). In DCC, we have an analogy: a weighted combination of the "realized" empirical correlation matrix from the last period (the error vector multiplied by itself to make a matrix) plus the conditional correlation matrix from last period (the one supposedly underlying the error vector from the last period). Does that make sense?
Comment: maybe. In GARCH(1,1) , the larger the coefficient of the ARCH parmeter, the more similar we expect the volatility of t and t-1 to be. The greater the GARCH coefficient, the greater impact yestardays "distance" from u(t-2) to u(t-1) is expected to have on todays voaltility.

So the greater dccalpha, the more similar we expect todays correlation to be that of yestardays correlation?  A high dccbeta means that we expect the that the flucuation of DCC (t-2) to DCC (t-1) will have a high impact on DCC(t)?

 Also, when you say "empirical correlation", does that mean Pearson rather than DCC?
Comment: @Isac, I wonder if you are getting the GARCH coefficient and DCC beta coefficient right. These are not about the difference between $t-1$ and $t-2$, they are about what the conditional volatility (in GARCH) or conditional correlation matrix (in DCC) were last, and that is in turn a function of the entire past of the series, just like an autoregression is the weighted sum of all past shocks (think of the MA representation of AR). Empirical means empirical; whether it is emp. Pearson or emp. DCC is another question; here I meant an estimate of correlation from a single time point worth of data.
Comment: @Isac, let me know if you need further help with the question.


A bounded sequence with accumulation points of 2 and 3 must be in the interval $(1,4)$ for large $n$.

Question: Below is the exercise I wish to solve, I have also provided my work. Could I get some feedback? If there is some better approach and this gets me nowhere your help would also very much be appreciated!

Let $\{a_n \}$ be a bounded sequence that has precisely the accumulation points $2$ and $3$. Show by contradiction that:
  $$ \exists n_0 \in \mathbb{N}, \forall n \geq n_0 : \space  a_n \in (1,4).$$
  note: we defined $0 \in \mathbb{N}$. Hint: argue by contradiction and use Bolzano-Weierstrass.

I will assume on the contrary that $$ \forall n_0 \in \mathbb{N}, \exists n < n_0 : \space  a_n \not \in (1,4).$$
We know that for some $n_0$ we can always finds points that are outside of ($1,4)$.  We also know that $a_n$ is bounded, so we take some arbitrary lower bound $L$ that is less than $1$ and some arbitrary upper bound $U$ that is greater than $4$.
I am not sure about this part. We get whenever $n< n_0$:
Either
$$L\leq a_n \leq 1  $$
or,
$$4\leq a_n \leq U  $$
By Bolzano Weierstrass: Every bounded, infinite set of real numbers has at least one accumulation point ( I am not sure I get an infinite amount of points like this.) Anyway,
This would give use that both these interval have at least one accumulation point which contradicts our assumption that $2$ and $3$ were the only ones.
Comment: A bounded sequence is necessary, otherwise $2,3,1,2,3,2,2,3,3,...,2,3,n,...$ would be a counter example.
Comment: The sequence is bounded by some $B$ hence the set $[-B,1] \cup [4,B]$ can only contain a finite number of points (otherwise, since it is compact...).
Comment: Group shave? ${}{}$
Comment: It is bounded, see the yellow box.
Comment: I understand, but the title does not say bounded.
Comment: Good one, I will add
Answer: The negation of the statement is actually $\forall n_0, \exists n\geq n_0: a_n \notin (1,4)$. This implies that there are infinitely many elements $a_n$ of the sequence verifying $L \leq a_n \leq 1$ or $4 \leq a_n \leq U$, where $L$ is a lower bound and $U$ is an upper bound of the sequence. Then at least one of the intervals $[L,1]$, $[4,U]$, contains infinitely many elements of the sequence. By Bolzano Weierstrass that interval will contain an accumulation point of the sequence. But by hypotesis the only accumulation points of the sequence are 2 and 3, which are not in $[L,1]$ or $[4,U]$. Contradiction.
Comment: Thank you, I knew I had made a mistake there somewhere.
Comment: It also makes more sense, much appreciated.


Dirichlet vs. logarithmic density

Question: The Dirichlet density of A relative to B is
$$
\lim_{s\to 1^+}\frac{\sum\limits_{n\in A}n^{-s}}{\sum\limits_{n\in B}n^{-s}}
$$
and the logarithmic density of A relative to B is
$$
\delta(A) = \lim_{n \to \infty} \frac{\sum_{a \in A,\, a \le n} \frac1a}{\sum_{b\in B,b\le n}\frac 1b}
$$
with the respective lower and upper densities defined with $\liminf$ and $\limsup$ respectively. ($A\subseteq B\subseteq\mathbb{N}$ of course.)
I have read in one source that the Dirichlet density exists if and only if the logarithmic density exists (in which case they are equal). In another source I read that they are the same. I wanted to check; to wit:

Is the lower Dirichlet density always equal to the lower logarithmic density?
Is the upper Dirichlet density always equal to the upper logarithmic density?
Does the Dirichlet density always exist if and only if the lower logarithmic density exists?
If both exist, are they equal?
Do the above hold in the special case $B=\mathbb{N}$?
Sometimes terminology is not standardized; are these definitions standard?
Comment: If $B= \mathbb{N}$ _Dirichlet density_ always exist for any $A$. But _Logarithmic density_ may not. If later exists then it must be equal to Dirichlet density. Not exactly your problem, but still you may look at [this](http://math.stackexchange.com/questions/437673/natural-density-implies-dirichlet-density?lq=1)
Comment: @Olivier You're right, it doesn't. The existence of a natural density implies the existence of a logarithmic density, and that in turn implies the existence of a Dirichlet density (and as far as they exist, the densities are equal), but at least the first implication is not reversible (I'm not sure whether a Dirichlet density implies a logarithmic density). The set of positive integers whose decimal expansion starts with digit $d$ (no leading zeros) has logarithmic density $\frac{\log (d+1) - \log d}{\log 10}$ (and thus the same Dirichlet density), but no natural density.
Comment: @Kunnysan Unless I've made a silly mistake, the Dirichlet density of $$A = \mathbb{N}\cap \bigcup_{k = 0}^{\infty} \bigl[2^{2^{2k}}, 2^{2^{2k+1}}\bigr)$$ relative to $\mathbb{N}$ doesn't exist. Up to a term tending to $0$, the $\zeta$-quotient is $f\bigl(2^{1-s}\bigr)$, where $f$ is [Hardy's oscillating function](https://mathoverflow.net/questions/198665/on-an-example-of-an-eventually-oscillating-function), according to my calculations.
Comment: @DanielFischer  Just to be sure : in case $B=\mathbf N$, does the existence of a Dirichlet density of a set $A$ implies the one of a natural density ? I suspect not, but  I found no reference on this on Math.SE. Do you know one by chance ?
Answer: Let
$$ \alpha_{n} = \sum_{\substack{ a \leq n \\ a \in A}} \frac{1}{a}
\quad \text{and} \quad
\beta_{n} = \sum_{\substack{ b \leq n \\ b \in B}} \frac{1}{b}. $$
The following holds:
$$ \varliminf_{n\to\infty} \frac{\alpha_{n}}{\beta_{n}}
\leq \varliminf_{s\to 0^{+}} \frac{\sum_{n\in A} n^{-1-s}}{\sum_{n\in B} n^{-1-s}}
\leq \varlimsup_{s\to 0^{+}} \frac{\sum_{n\in A} n^{-1-s}}{\sum_{n\in B} n^{-1-s}}
\leq \varlimsup_{n\to\infty} \frac{\alpha_{n}}{\beta_{n}} \tag{1} $$
It is clear that this inequality holds if $\beta_{n}$ converges. (In this case, the above inequality reduces to equality.) So we may assume that $\beta_{n} \to \infty$. Then note that we have
$$ \sum_{n\in A} \frac{1}{n^{1+s}} = \sum_{n=1}^{\infty} \alpha_{n} \left( \frac{1}{n^{s}} - \frac{1}{(n+1)^{s}} \right) $$
and likewise for $\beta_{n}$. Thus if we put $\bar{\rho} = \varlimsup \alpha_{n} / \beta_{n}$, for $\epsilon > 0$ we can find $N$ such that $\alpha_{n} < (\bar{\rho} + \epsilon) \beta_{n}$ for $n > N$. Thus
\begin{align*}
\sum_{n\in A} \frac{1}{n^{1+s}}
&\leq \sum_{n\leq N} \alpha_{n} \left( \frac{1}{n^{s}} - \frac{1}{(n+1)^{s}} \right) + \sum_{n>N} (\bar{\rho} + \epsilon) \beta_{n} \left( \frac{1}{n^{s}} - \frac{1}{(n+1)^{s}} \right) \\
&= \sum_{n\leq N} (\alpha_{n} - (\bar{\rho} + \epsilon) \beta_{n}) \left( \frac{1}{n^{s}} - \frac{1}{(n+1)^{s}} \right) + (\bar{\rho} + \epsilon) \sum_{n\in B} \frac{1}{n^{1+s}} \tag{2}
\end{align*}
Dividing both sides of $(2)$ by $ \sum_{n\in B} n^{-1-s} $ and taking $s \to 0^{+}$, we have
$$ \varlimsup_{s\to 0^{+}} \frac{\sum_{n\in A} n^{-1-s}}{\sum_{n\in B} n^{-1-s}}
\leq \bar{\rho} + \epsilon. $$
Here, we exploited the fact that
$$ \lim_{s \to 0^{+}} \sum_{n\in B} \frac{1}{n^{1+s}} = \sum_{n\in B} \frac{1}{n} = \lim_{n\to\infty} \beta_{n} = \infty $$
so that the $\sum_{n \leq N}$ part of the sum $(2)$, divided by $ \sum_{n\in B} n^{-1-s} $, vanishes as $s \to 0^{+}$. Since $\epsilon$ is arbitrary, we obtain the rightmost part of the inequality $(1)$. Similar consideration proves another side, completing the proof.
Kunnysan showed that $(1)$ need not reduce to an equality, hence this is not far from the sharpest result.

Dirichlet vs. logarithmic density


What is the general method to study the convergence of a sequence

Question: I want to ask questions :
First : In general how can I study the convergence of any sequence in $L^p$ ( $L^1$ , $L^2$ , $L^3$ , .......) of course the sequence belongs to the space which I want to study the convergence of the sequence in it .
How can I determine if the sequence is convergent or divergent ???
Because I don't know what is the general method to study the convergence in like space
Comment: Although **this is neither necessary nor sufficient**, it is probably useful to check for pointwise convergence first. Precise statement: If the sequence converges in $L^p$, then there is some subsequence which converges almost everywhere to the limit. Once the limit is identified, try to look for applicable convergence theorems (monotone convergence, dominated convergence, or the Vitali convergence theorem (see http://en.wikipedia.org/wiki/Vitali_convergence_theorem, although I don't really like the version on Wikipedia).
Comment: Here (http://math.stackexchange.com/questions/116820/uniform-integrability-and-tightness) is a version of Vitali's theorem that I like more (since it also applies to infinite measure spaces).
Answer: I would say that your first port of call is the fact that these spaces are complete and so we can appeal to the fact that absolute convergence implies convergence in Banach spaces.
Edit: You should unaccept this because while it is correct it is referring to convergence of series rather than sequences... then I can delete it.


Need someone to explain the SharedPreferences class

Question: Android provides the SharedPreferences class, and we need to create an XML file to store the value of each Preferences (that is what I know). But I don't know, after using SharedPreferences.Editor to modify value, where the modified values are stored? I can't see any change in the XML file.
Also, what are the differences between apply() and commit(), getSharedPrefences and getPreferences?
Answer: Preferences will be stored in internal memory (phone memory).

apply()
commit()
getSharedPreferences(java.lang.String, int)
another getSharedPreferences()

I'm sorry I don't know which one is getPreferences() you mentioned.
Comment: there is a SharedPreferences getPreferences(int mode) method in Android. same to getSharedPreferences() but only Activity can use it, not other component
Answer: commit() returns a boolean value. If the data is save then it returns true otherwise false.
If you don't care about this (boolean value) then use the apply() method.
getPreferences:
               Use this when you only need one preference
getSharedPreferences: Use this if you need multiple preferences in a single file


Left hand injury

Question: My fiance has no feeling in his thumb, index & half of his middle finger on his left hand due to a wrist injury. He was in an accident where a mirror broke and slit through his left wrist down to the bone.
Because he can't feel these fingers, he has been having a rough time trying to play the guitar again. In order to try and play he has to look at the guitar to see what he is doing, because he can't feel anything. He says it messes him up to look at it while trying to play. It really frustrates him & I was wondering if anyone has any advice on what he can do.
There is no chance in him gaining any feeling back in these fingers, but desperately wants to play his acoustic guitar again.
Answer: I sympathise with him! I don't think guitarists need to use feel in fingers as much as they think they do. It's going to be more down to re-training the fingers to press the right strings on the right frets. More down to repetitive motions, mainly getting the fingers used to all arriving together. As far as knowing how hard they need to push down, since the muscles still presumably work, listen to how clean each chord sounds, and press less until the chord buzzes, then get used to pressing that little bit harder.
As far as needing to look, that's not a good move really, but if it's necessary, he could sit opposite a mirror, which will obviate slouching over to see the fingerboard.
Not convinced that playing lefty would suit, especially if he's been playing for a long time, as the change is cataclysmic, and holding a pick with numb fingers is going to lead to more frustration.
I'd also suggest that if all that ends in disaster, try a different instrument rather than stop music altogether - there are several options which can embrace his needs.
Answer: That's a pretty sad situation :(
I'm not sure if the following will work, but desperate times call for desperate measures. Also, it's going to take a while: if he can still hold a plectrum in his left hand, he could try learning to play guitar left-handed.
(For reference: I am left-handed, but play guitar right-handed, since I learned to play on my brother's guitar.)
Comment: Sure, that's what the 'if's are for. Holding something might be easier than moving your fingers around the fretboard.
Comment: The digits that are almost always used to hold a pick are thumb, index and middle finger, so this is a pretty tall order, I think.
Answer: Sad for your husband, but the situation is not dire / difficult. Your husband simply has to rely / use his other fingers. Well-know gypsy jazz guitarist Django Reinhardt had a similar issue - unable to use a couple of fingers in his hand.
Comment: Django had the most useful fingers - index and middle - that still worked. The burnt ones he still used in some way when needed for chords. But I believe that no feeling will produce different problems, especially in the key fingers - and thumb.

Left hand injury