step-wise vs. circle of fifths movement in bass line

Question: This post got me thinking about root movement. It has been said time and again that root movement of an upward fourth and descending fifth are particularly satisfying, and obvious choices when working towards good voice leading. But are there situations in which a bass that moves by step is more appropriate? Sequences like the one below are what mostly come to mind (C maj):

But I can think of other examples . . . what about the chorus of Changes by David Bowie?
It looks something like this (also in C maj):

And it certainly is amazing. But wouldn't traditional music theory have pushed him to write a bass line that looks more like this (forgive me if this doesn't look pretty):

If anyone could elaborate on this concept (namely, the various effectiveness of stepwise bass vs. bass lines that follow the circle of fifths), then I would be very appreciative.
Best,
286642
Comment: "But wouldn't traditional music theory have pushed him to write a bass line that looks more like this " No - not unless he had only read the very first lesson of a modern harmony textbook, and hadn't progressed beyond "chords in root position only". (Also note, in your proposed example the third bass note should be F not C!)
Comment: @alephzero, according to the OP's question, he is right making the bass note of the third chord a C because he is talking about bass line movement of fourths and fifths. An F there would make movement of a 2nd or 7th depending on direction.
Comment: @alephzero, thanks for the comment. I decided to make it an IV6/4 chord so that I could still have the upward 4th movement. I was doing this for example's sake, because the alternative would have been the stepwise movement from G to F which I was trying to contrast the example with. That brings me to another question, though, so thank you. Does the upward fourth/downward fifth movement suggestion only apply to chords in root position? Thanks!
Answer: Both are nice. Both can be (and have been) used with the same root progression. Take the "La Folia" progression: i,V,i,VII,III,VII,i,V,.... One bass progression is 1,5,1,7,3,7,1,5.... Another is 1,#7,1,2,3,2,1,#7,1. The second case makes a nice discant to the first bass line.
Answer: Not a lot to say except that yes, V - I bass lines are good and strong, and so are stepwise ones.  I wouldn't consider 'traditional theory' preferred one or the other.
Answer: You can try turning this question around and see how voice leading paradigms result in the different root movements.
Basic voice leading holds common tones between chords and moves the other voice the smallest distance to the tones of the other chord.
With triadic harmony there are only 3 possibilities for moving the voices: move 1 voice, 2 voices, or 3 voices.
When those basic rules are put together we get chord progressions whose roots move by descending/ascending 5th, 2nd, and 3rd...

1. root progression by descending/ascending fifth

all step-wise in two voices
parallel 3rds and 6ths

2. root progression by ascending 2nd

stepwise and thirds (leaps) in all thre  voices in contrary motion to the bass
parallel 3rds and 6ths
direct perfect 4ths

3. root progression by descending 2nd

all step-wise in all three voices parallel to the bass which plays the third of each chord
parallel 3rds, 6ths, and 4ths

4. root progression by ascending third

step-wise in one voice only
oblique motion between 3rds and 4ths

In my notation I put a line between notes of the moving voices to show the relative motion and position.
I tried to typical functions: circle of fifths sequences, IV V for ascending 2nd, dominant harmony for ascending 3rd. Ascending 3rd is rare in common practice so I decided to demonstrate with dominant harmony V viio this could be interpreted as a non-progression and instead an arpeggiation of the larger V7 chord.
I put inversion figures in parenthesis to show that all these progression types - except #2 roots by descending 2nd, parallel sixth chords - can be used over root position bass parts.
Back to the original question...

...root movement of an upward fourth and descending fifth ...are there situations in which a bass that moves by step is more appropriate?

Part of the problem is the question sort of switches back and forth between bass motion in terms or root and actual tones. Keep in mind that the tones the bass plays are not necessarily chord roots. In the four paradigms above the bass is a root position (except type #3) but the actual bass voice moves variously by descending/ascending 5ths and 2nds, as well as 3rds.
But another model should be added to those voice leading paradigms: the rule of the octave. The rule of the octave is a harmony model about how to harmonize a step-wise bass line. It's part of common practice harmony:

...if you examine the harmony you will see that while the bass movement is entirely step-wise the roots are almost all descending/ascending 5ths.
There is a complete mix of possibilities bass movement by step and leaps and chords in root position or inverted.
Regarding Changes by David Bowie: I don't think the 'traditional theory' approach would be to play the harmony all in root position. Understanding 'traditional theory' to mean common practice, the chord changes are the un-traditional part! Common practice might have kept the descending bass line harmonized it with slightly different chord, chords that would be mostly tonic/dominant.
Answer: In my experience and training, the circle of fifths progressions are more important in the overall chord progression. However, you can have good circle-of-fifths progressions and still have very smooth step wise bass voice leading by using inversions (Bach seems to have been excellent at this). I was taught to make the overall root harmonies follow circle of fifths, but make the vocal parts have smooth leading.
Hope this helps.
Comment: If bass guitar had been around in Bach's day, he'd have been one of the best bassists in the world.
Answer: Motion by fifth is much easier to manage in four voice harmony, if you are following the western-tradition voice leading rules. But stepwise motion is possible, with some caveats.
Stepwise motion with the root in the bass is problematic because it will usually result in parallel fifths, which are forbidden (and all over the place in your first example, by the way). In a typical IV-V progression, the upper voices move in contrary motion to the bass in order to avoid this. Just going up continuously is very difficult.
Stepwise motion is also do-able with the third in the bass, and doing this continuously is sometimes called parallel sixths. When voice leading with parallel sixths, you can even discard the customary predominant-dominant-tonic ordering, because it is considered sequential instead of progressive harmony.
Another possibility is stepwise motion in the bass where the bass note alternates in function. For example, Pachabel's Canon is written as a descending bass line where every odd-numbered chord is in root position and every other chord is in 63 position. This results in the sequence I V VI III IV I, which you may recognize from a whole bunch of other songs. This sequence is sometimes called "Descending 5-6 syncope" because it descends and alternates between 53 and 63 chords.
There are ascending versions as well (for example, Tiptoe through the Tulips).
But just straight chords up and down the scale with the bass in the root? Pretty rare. From a voice-leading perspective, very hard to pull off.
Comment: Parallel fifths *forbidden*? Not in some types of music, where they abound.
Comment: See paragraph above "if you are following the western tradition voice leading rules," which of course are not obligatory to any artist.


Bridge vs. Adapter Design Pattern

Question: I was questioned by a colleague about the design pattern of my implementation of a WCF windows service in a ASP.net client application and I really could not tell whether it is Bridge or Adapter!
Here is the implementation:

I have obtained the service contract
Defined a new interface similar to my WCF Data contract
I created a WCF client and wrapped it inside the new interface
Mapped the new interface operations to the original WCF client (I do some logging/error handling here)

I was always thinking of it as an implementation of Adapter pattern, but really I can not tell why isn't it Bridge!
I have read all the posts here in SO, GoF and wikipedia but it really makes no sense!
From my understanding, Both patterns point at an existing type, both decouple an abstraction from its implementation am I missing a point?
Here's from GoF:

The key difference between these patterns lies in their intents.
  Adapter focuses on resolving incompatibilities between two existing
  interfaces. It doesn't focus on how those interfaces are implemented,
  nor does it consider how they might evolve independently. It's a way
  of making two independently designed classes work together without
  reimplementing one or the other. Bridge, on the other hand, bridges an
  abstraction and its (potentially numerous) implementations. It
  provides a stable interface to clients even as it lets you vary the
  classes that implement it. It also accommodates new implementations as
  the system evolves.

I don't fully understand the above statement,

Does it mean that if I vary the adaptee or change the implementation
of the original interface at design time then it is Bridge Pattern?
The differences sounds trivial, Is there any other differences in
implementation/abstcation?
How can anyone tell what implementation is used after
development?
Can anyone give me a good example of bridge pattern and how it can
be changed during software lifecycle?

Update:
Again from GoF:

Remember that an adapter makes two existing interfaces work together
  as opposed to defining an entirely new one.

Does it mean that changing the existing interface so that it can work with another interface is an implementation of Adapter?
Update2:
Just found this incredible article: Illustrated GOF Design Patterns in C#
This is true Bridge Patter structure:
I was missing the fact that the Bridge pattern lets you combine the different abstractions and implementations and extend them independently
Answer: I think you don't have pure GoF pattern here. It's something between Decorator and Adapter. You are changing interface of service client (adapting it to your needs). But also you are adding new responsibilities to client (logging and error handling) - thats a decorating part. If you would stay with original service interface, it would be pure Decorator.
UPDATE: Any usage of inheritance does not mean, that we are using some GoF pattern. There are several things your current architecture missing to be Bridge:

Hierarchy of implementations. Your service interface should define some low-level operations. And you should have several service implementations.
Abstraction should define high-level interface. Usually those interfaces does not look similar to implementation interface (your client interface is similar to service interface, it exists on same level of abstraction).
Abstraction implementations should use service interface to implement high-level operations (i.e. they don't add some responsibilities to service, they implement different things, high-level things).
Comment: Yes, you are right by the the decorator part, however by definition it seems that this is Bridge pattern, since the WCF service contract is evolving during software lifecycle!
Comment: Bridge used for connecting two class hierarchies. I don't see any hierarchy here.
Answer: I was explained the bridge pattern as an intend to combine two class hierarchies with different purposes. For example consider you are writing a window framework with different types of controls and support for different window systems. You'd have one class tree for the controls and another to abstract away the differences between the window systems. Now if you want to add support for another window system, you simply add that to that side of the hierarchy, and if you want to add new controls, you add them to their side. The "bridge" exists between the top classes of the two hierarchies, where your control class has access to the abstract functions defined by the base class of the class hierarchy implementing support for the various window systems.
With the adapter pattern you don't want to combine two hierarchies of classes with different intentions, but adapt a class to work with your own interface. I suppose if you only supported a single window system in the example above and don't put an abstract class inbetween to maintain extensibility, that would be an adapter instead of a bridge.
Answer: This has been previously discussed here - Difference between Bridge pattern and Adapter pattern - The real quote you want from GoF is "Adapter makes things work after they're designed; Bridge makes them work before they are. [GoF, p219]
Your last question gets a yes - an adapter is used to make two otherwise disagreeable elements of a system play nicely together without changing their fundamental functionality beyond possibly subsetting the union of their functionalities -
A bridge pattern is usually used to deal with issues in initial design where the mental model presented to the consumer might be wildly different from the model that realizes the implementation of the consumers model.  Consider a high performance math library that looks the same across a wide variety of processors - you just want to multiply matrices, but behind the scenes there's all sorts of cruft involving swizzling, parallel data streams, odd behaviors to avoid pipeline stalls, and all done differently on 3+ realizations of a high performance superscaler core - and that's just Intel  :-(

Bridge vs. Adapter Design Pattern


When $f_x=f_y$, does that mean that all double partial derivative are the same?

Question: While working with some partial derivatives, I noticed that some functions' partial derivatives are the same (e.g. $f_x=f_y$). For example, both partial derivatives of $e^{2x+2y}$ are $2e^{2x+2y}$. When this occurs, you can apply the following logic:$$f_{xx}=(f_x)_x=(f_y)_x=f_{yx}=f_{xy}=(f_x)_y=(f_y)_y=f_{yy}$$This means that all the double partial derivatives are the same. I believe similar logic should apply for higher order partial derivatives. For example, $f_{xyyxxyxxx}=f_{yyxyyxxxy}$. This seems like a really powerful tool, but I wasn't tought it in Calc III, so I'm questioning if I made a mistake somewhere, and this isn't actually a valid technique.
Comment: I mean firstly, it should be defined right?
Answer: Your "technique" is right, but it is not a "really powerful tool" since it applies only to functions of the type $f(x,y)=g(x+y)$, $f_x=g'(x+y)⋅1$, $f_y=g'(x+y)⋅1$ so for example for $(x+y)^n$, $\sin(x+y)$, $\ln(x+y)$ etc. Once you see a function of this type you can use your rule, but most of the functions you have to deal with are not of this simple type.
Comment: @SebastianNuxoll This is a specific case of an actually really powerful tool: solving linear partial differential equations (here $\partial_x f - \partial_y f = 0$).
Comment: Cool, maybe I'm over-estimating how often these functions show up, but it's good to now that the method checks out.
Comment: @eyeballfrog Thanks, I think i found my next wikipedia rabbithole


Custom Picker Renderer bug - Picker displays twice upon calling Picker.Focus()

Question: I am trying to employ a custom renderer for my Picker controls. I also need my Picker to fire up when I open a tab. I do this by calling the picker's Focus() method on tab SelectionChanged.
if (e.NewPosition == 1)
{
    myPicker.Focus();
}

This, however, fires up two instances of the picker alert at the same time; one is the default renderer, the second one is my custom renderer. They are one atop the other, such that when I close the one with my custom renderer, the one with default renderer is visible.
Simply tapping the Picker will display only one instance, with the custom renderer (this works as intended).
I wrote my custom renderer following this post's answer.
I tried the answer described here, but the problem is that this skips over the second instance of the picker, which is not what I need. I need to keep the instance that has my custom renderer, not the one with the default renderer.
I also tried to make sure that I am running on the right thread, implementing code described in this question's answers.
Moreover, I tried to somehow remove events from the CustomRenderer and add them again, like this:
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Picker> e)
{
    base.OnElementChanged(e);
    Control.Click += null; // hoping this would override all existing events
    Control.Click += Control_Click;
}

Finally, this question came closest to my situation and I tried following the solutions described in the answers.
None of these worked. I believe that when Focus() is called, somehow the default renderer shows up first due to my custom renderer inheriting the default PickerRenderer.
How do I enforce the custom renderer?
Or is there a different way for me to fire up my picker upon changing tabs, instead of calling Focus()?
My project runs on Xamarin.Forms 126.96.36.1995 (latest version as of when I'm writing this question).
EDIT
I observed the following behaviour: Control.Click event is fired AFTER the default renderer is displayed. By debugging the app and placing a break point inside my Control.Click handler function, I can see that the app first opens the default picker, and then it halts in said breakpoint.
Comment: Yes, it is the case as you said. And you can create a new issue [here](https://github.com/xamarin/Xamarin.Forms/issues).
Answer: SOLVED
By studying the PickerRenderer.cs class, I realised that there were more functions that had to be overwritten.
To begin with, I made my custom renderer class implement the IPickerRenderer interface and added the following function:
void IPickerRenderer.OnClick()
{
    Control_Click(this, null); // this function handles the Control.Click event
}

Moreover, I overwrite the CallOnClick() function:
public override bool CallOnClick()
{
    Control_Click(this, null); // same function, that handles the Control.Click event
    return true;
}

Finally, I added this bit of code (thanks to this answer) that ensures the Picker shows up only once. Thus, my OnElementChanged function looks like this:
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
    base.OnElementChanged(e);

    if (Control != null)
    {
        Control.Focusable = false;
    }

    Control.Click += Control_Click; // this is where I link the handler to the event
}

The conclusion is that the described behaviour either

wasn't a bug, which means I just hadn't implemented it correctly
was a bug, and I managed to find a good workaround

Either way, I managed to solve my problem.
If anyone else stumbles upon this, I hope my work helps.


My standard errors are smaller when I use Newey-West? HELP!

Question: I am looking at some time series regressions,
When I use OLS, my standard errors on one of the coefficients is 0.002777409.
When I use the Newey-West correction the standard errors are smaller:
       OLS: 0.002777409.
    1 Lag:  0.001995232
    3 Lags: 0.001902868
    5 Lags: 0.001859962
    7 Lags: 0.001834708
    9 Lags: 0.001777297

Why is this possible and why do they decrease with lag length!
Answer: One possible explanation is that in the scores corresponding to your OLS estimates there are also some negative autocorrelations. These would cause the standard errors to be smaller than under independence.
Consider the following very basic artificial example in R using the sandwich package for Newey-West standard errors: Under independence the conventional standard error and the Newey-West standard error are very close.
set.seed(1)
y0 <- rnorm(250)
sqrt(diag(vcov(lm(y0 ~ 1))))
## (Intercept)
##  0.06087633
sqrt(diag(NeweyWest(lm(y0 ~ 1))))
## (Intercept)
##  0.05839612

However, if we create a time series with positive autocorrelation (here AR1 with 0.8) the conventional standard error is too small and the Newey-West standard error is much larger.
ypos <- filter(y0, 0.8, method = "recursive")
sqrt(diag(vcov(lm(ypos ~ 1))))
## (Intercept)
##  0.09946229
sqrt(diag(NeweyWest(lm(ypos ~ 1))))
## (Intercept)
##   0.2900413

Conversely, if we create a series with negative autocorrelation (here AR1 with -0.8), then the conventional standard error is too large and the Newey-West standard error much smaller.
yneg <- filter(y0, -0.8, method = "recursive")
sqrt(diag(vcov(lm(yneg ~ 1))))
## (Intercept)
##  0.09641663
sqrt(diag(NeweyWest(lm(yneg ~ 1))))
## (Intercept)
##  0.03262333

In a more complex regression model the situation may not be that simple and the effects might also not be the same for all regression coefficients. However, it is not completely unusual to get Newey-West standard errors that are smaller than the conventional standard errors.


Solving an infinite system of equations for the coefficients of a power series for $f(x+1)=\exp(f(x))$

Question: Consider the sequence of formulae, $a_n$, such that $a_0=1$ and for all $n>0$, we have
$$a_n = \sum_{k=1}^nT(n,k)c_k a_{n-k},$$
where $$T(n,k)=\frac{(n-1)!k}{(n-k)!},$$
$c_0=0$, and $c_k$ for $k>0$ are unknown coefficients of a power series (see the background below for more information). Pairing this with the secondary fact that
$$a_n=\sum_{k=n}^\infty \frac{k!}{(k-n)!}c_k,$$

can we solve for all $c_k$?

I am reasonably confident that this is sufficient information (given the background of the problem, as described below, assuming the uniqueness of an analytic solution). However, this effectively surmounts to solving an infinite set of nonlinear equations
$$\sum_{k=n}^\infty \frac{k!}{(k-n)!}c_k - \sum_{k=1}^nT(n,k)c_k a_{n-k} = 0,$$
and I am unaware of any methods which can do this (despite my confidence that this is possible), so any insight or advice would be great.

Background:
This essentially is a continuation of my earlier question (which lead me to a new attack vector as described above), in which we are constructing an analytic function $f:\mathbb{R}\to\mathbb{R}$ where
$$f(0)=0,f(x+1)=\exp(f(x)),\text{ and } x\in[0,1)\implies f(x)=\phi(x),$$
such that,
$$\phi(x)=\sum_{n=0}^\infty c_n x^n.$$
In fact, $a_n=\left(\frac{d}{dx}\right)^n f(1)$. Doing so would allow for (among other things) the explicit construction of an analytic function $h$ such that $h(h(x))=\exp(x)$, as described in this answer.

As requested in the comments, here is a table of some values for $T$. More terms are available on the OEIS as sequence A121757. (Be aware that my definition of $T$, and the respective definition in the OEIS have offset indices by $1$).
$$\begin{array} {|r|r|}\hline n & T(n,1) & T(n,2) & T(n,3) & T(n,4) & T(n,5) & T(n,6) & T(n,7) & T(n,8) & T(n,9) \\ \hline 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline 2 & 1 & 2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline 3 & 1 & 4 & 6 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline 4 & 1 & 6 & 18 & 24 & 0 & 0 & 0 & 0 & 0 \\ \hline 5 & 1 & 8 & 36 & 96 & 120 & 0 & 0 & 0 & 0 \\ \hline 6 & 1 & 10 & 60 & 240 & 600 & 720 & 0 & 0 & 0 \\ \hline 7 & 1 & 12 & 90 & 480 & 1800 & 4320 & 5040 & 0 & 0 \\ \hline 8 & 1 & 14 & 126 & 840 & 4200 & 15120 & 35280 & 40320 & 0 \\ \hline 9 & 1 & 16 & 168 & 1344 & 8400 & 40320 & 141120 & 322560 & 362880 \\ \hline  \end{array}$$
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/139463/discussion-on-question-by-graviton-solving-an-infinite-system-of-equations-for-t).
Answer:
update Remark: the interpretation of the matrix $T$ in its use as binomial coefficients (as matrix $P$) has some inconvenience because of the beginning of index-counting at $1$ as well as in the formulae after that. I hope I got this correct anyway. However, the coefficient $c_0$ is set to be zero, and this should indicate, that we are as well working with the iteration of $\exp(x)-1$ and not $\exp(x)$. This should be made more clear by the OP. For the time being I'll leave the text as it is, because we only need to change (eq 6c) and (eq 6d) and replace $B_b$ by $fS2F$ on the rhs resp. $\exp(x)$ by $\exp(x)-1$.
Additional remark: if $\exp(x)-1$ is under discussion, then the coefficients $c_k$ are easily determined

As far as I've analyzed the given equations & conditions, I must state, that your system gives a description for the Abel-function $\varphi(x)$ for the iteration of the $\exp(x)$ but no (new) way to actually determine the coefficients $c_k$ such that $\varphi(z)= \sum_{j=1}^\infty c_j \cdot x^j$.
The following is how far I came analyzing your conditions/equations and putting them into (my standard) framework of Carleman-matrices to show their functional properties.

T= Pascalmatrix  - On the second eqn
$\phantom a$
First, the matrix $T$ is the factorially scaled and shifted binomial-matrix.
I would write
$$ T(n,k)=k! \frac{(n-1)!}{(n-k)!(k-1)!}=k! \binom{n-1}{k-1} \tag {1a}$$
Note this is the shifted lower triangular pascalmatrix with columns scaled by factorials:
$$ \small \begin{bmatrix}
 1 & . & . & . & . & . \\
 -1 & 1 & . & . & . & . \\
 0 & -1 & 1 & . & . & . \\
 0 & 0 & -1 & 1 & . & . \\
 0 & 0 & 0 & -1 & 1 & . \\
 0 & 0 & 0 & 0 & -1 & 1
 \end{bmatrix} \cdot
\small \begin{bmatrix}
 1 & . & . & . & . & . \\
 1 & 1 & . & . & . & . \\
 1 & 2 & 1 & . & . & . \\
 1 & 3 & 3 & 1 & . & . \\
 1 & 4 & 6 & 4 & 1 & . \\
 1 & 5 & 10 & 10 & 5 & 1
 \end{bmatrix} \cdot \small \begin{bmatrix}
 1 & . & . & . & . & . \\
 . & 1 & . & . & . & . \\
 . & . & 2 & . & . & . \\
 . & . & . & 6 & . & . \\
 . & . & . & . & 24 & . \\
 . & . & . & . & . & 120
 \end{bmatrix} \\ =
\small \begin{bmatrix}
 1 & . & . & . & . & . \\
 0 & 1 & . & . & . & . \\
 0 & 1 & 2 & . & . & . \\
 0 & 1 & 4 & 6 & . & . \\
 0 & 1 & 6 & 18 & 24 & . \\
 0 & 1 & 8 & 36 & 96 & 120
 \end{bmatrix}
$$
$$ \tag {1b}$$
With my standard notation for the algebraic matrix-operations:
$$ T = \Delta \cdot P^\tau \cdot \,^dF \tag{1c}$$
What you use of this in your first equation is just the transposed submatrix from second row and column on, which is exactly the upper triangular Pascalmatrix $P$ scaled by the factorials
$$ \text{FP} = \small \begin{bmatrix}
1 & 1 &1 &1 &1 & ... \\
 . & 2 & 4 & 6 & 8 & ... \\
 . & . & 6 & 18 & 36 & ... \\
 . & . & . & 24 & 96 & ... \\
 . & . & . & . & 120 & ... \\
 \vdots & \vdots & \vdots & \vdots & \vdots & \ddots
\end{bmatrix} \tag {1d}$$ which I denote here for shortness $\text{FP}$

Description of $A$ - On the first eqn.
$\phantom a$
Using binomial notation instead of your $T()$ we have your first equation as:
$$ a_n=\sum_{k=1}^n k! \binom{n-1}{k-1}c_k a_{n−k} \qquad a_0=1 \tag {2a} $$
For the $a_n$ (assumed to be collected in a columnvector $A$) I get from this the columnvector of polynomials in $c_k$:
$$ \text{A} = \small \left[ \begin{array}{l}
 1 \\
 c_1 \\
 c_1^2+2c_2 \\
 c_1^3+6c_2c_1+6c_3 \\
 c_1^4+12c_2c_1^2+24c_3c_1+12c_2^2+24c_4 \\
 c_1^5+20c_2c_1^3+60c_3c_1^2+(60c_2^2+120c_4)c_1+120c_3c_2+120c_5
 \end{array}\right] \tag {2b}
$$

The Carleman-matrix $\phi$ reflecting the power series of your $\varphi()$ function
$\phantom a$
By inspection (and crosscheck) this shows the rowsums of the Carlemanmatrix $\phi$ of a function $\varphi(x)= c_1x+c_2x^2+c_3x^3 + ...$
Let's check this. We construct the Carlemanmatrix $\phi$ from this:
$$  \phi = \small \begin{bmatrix}
 1 & . & . & . & . & . \\
 0 & c_1 & . & . & . & . \\
 0 & c_2 & c_1^2 & . & . & . \\
 0 & c_3 & 2c_2c_1 & c_1^3 & . & . \\
 0 & c_4 & 2c_3c_1+c_2^2 & 3c_2c_1^2 & c_1^4 & . \\
 0 & c_5 & 2c_4c_1+2c_3c_2 & 3c_3c_1^2+3c_2^2c_1 & 4c_2c_1^3 & c_1^5
 \end{bmatrix} \tag {3a}
$$ and do the factorial scaling $^dF \cdot \phi \cdot \,^df$ (again simplifying the notation of its name as $F \phi f$):
$$ F\phi f = \small \begin{bmatrix}
 1 & . & . & . & . & . \\
 0 & c_1 & . & . & . & . \\
 0 & 2c_2 & c_1^2 & . & . & . \\
 0 & 6c_3 & 6c_2c_1 & c_1^3 & . & . \\
 0 & 24c_4 & 24c_3c_1+12c_2^2 & 12c_2c_1^2 & c_1^4 & . \\
 0 & 120c_5 & 120c_4c_1+120c_3c_2 & 60c_3c_1^2+60c_2^2c_1 & 20c_2c_1^3 & c_1^5
 \end{bmatrix} \tag {3b}
$$
Visual inspection shows, that we have equality with $A$ and rowsums in $F \phi f$
So in my matrix-lingo we have, with a columnvector $\,^cV(x)$ at $x=1$ which does the rowwise summation:
$$ F \phi f \cdot ^cV(1) = A  \tag {3c}$$
and for each row $n$:
$$   F \phi f_{n,} \cdot V(1) = a_n \tag{3d}$$
But putting the leading factorial away by premultiplication of the inverse of $F$ (simply say $f$) we could write
$$ \phi f \cdot V(1) = f \cdot A \tag {3e} $$
and then reorganize the second dot-product in the lhs, writing $fV(x)$ for $ [1,x/1!,x^2/2!,...]$
$$ \phi \cdot fV(1) = fA  \tag {3f} $$

The second determination of $A$ - on the third eqn.
$\phantom a$
I would similarly as in (eq $1$) expand the factorials to binomials and write
$$  a_n= n! \sum_{k=n}^\infty \frac{k!}{(k-n)!n!}c_k = n! \sum_{k=n}^\infty \binom{k}{n} c_k
\tag {4a}$$
This means, we work with derivatives of the function $\varphi()$ and we simply have
$$ a_n = \varphi^{(n)}(1) \tag {4b}
$$

The Abel's-functional equation - combining (3) and (4)
$\phantom a$
Using, that the matrix $\phi$ (due to its construction as a Carlemanmatrix for $\varphi()$) has in its second column the coefficients of the function $\varphi(x)$ and that coefficients are the derivatives at $x=0$ divided by the factorials:
$$\phi_{[,1]}= \text{vector}[ \varphi^{(r)}(0)/r! ]_{r=0}^\infty \tag {5a}$$
and rescaling (eq 4a) by the reciprocal factorials
$$ fA=\text{vector}[ \varphi^{(r)}(1)/r! ]_{r=0}^\infty \tag {5b} $$
getting the taylorseries for $\varphi()$ at $x=1$ we can as well write
$$ fA = P \cdot \phi[,1] \tag {5c} $$
because the binomial-matrix does exactly that shift:
$$ V(0) \cdot \phi = [1, \varphi(0), \varphi(0)^2,...]] \\
 V(0) \cdot P \cdot \phi = [1, \varphi(1), \varphi(1)^2,...]] \tag{5d} $$
so we have now established the equality (eq 5c) and (eq 3f):
$$ P \cdot \phi_{[,1]} \underset{\text{by (eq 3f)}}= \phi \cdot fV(1) \tag {5e}  $$

The matrix $B_b$ for the exponentiation
$\phantom a$
Now we may remember, that the second column of matrix $B_b$ is equal to just that vector $fV(1)$ on the rhs, and I think it is not too hazardous to conclude, that your equations lead to the formula
$$ P \cdot \phi = \phi \cdot B_b \tag {6a}$$
where the matrix $B_b$ is just the Carlemanmatrix for $\exp(x)$ .
This is the functional form:
$$ V(x) \cdot P \cdot \phi = V(x) \cdot \phi \cdot B_b \tag {6b} $$
which - when the dotproducts are evaluated - simply denotes the Abel-equation
$$ \varphi(x+1) = \exp(\varphi(x)) \tag {6c} $$

Well, this confirms the basic sanity of your equations, and relates it to the well known Abel equation for the iteration of the $\exp(x)$ function.

We can do one more step, replacing $x$ by $\varphi^{\circ -1}(x)$ to get a better formulation for the iterative aspect:
$$ \small {\varphi(\varphi^{\circ -1}(x)+1) = \exp(x)} \\
\small {\varphi(\varphi^{\circ -1}(x)+2) = \exp^{\circ 2}(x)}\\ \small {\vdots} \\
\small {\varphi(\varphi^{\circ -1}(x)+h) = \exp^{\circ h}(x)} \tag {6d} $$
Unfortunately we have not more information about the coefficients $c_k$ from your observations (and/or some hypotheses), so we have to stop here.

An amateurish ansatz in this spirit (solving (eq 6d), calling $\varphi^{\circ -1}(x)$ the "superlog" or $\text{slog}(x)$) has been proposed in about 2005 by A. Robbins, who was also co-founder of the tetration-forum. He tried to construct the sequence of $c_k$ by assuming small dimensions of the involved matrices, say beginning at $n=3$ , increasing $n$ and look, whether the occuring matrices converge to some constant values of $c_k$ in the small indexes $k$. This is an easy approach and gives approximations for the fractional iterates, but is lacking any known relation to solutions like the Schröder-, the Ecallé-, the Walker- or the Kneser-method. (His paper is online on github).
A widely accepted ansatz for the construction of an explicite powerseries for the Abel-function $\varphi()$ has been given by J. Ecallé (don't know whether he was the first one) but which is more involved and is a Laurent series (having a leading term ${c_{-1} \cdot x^{-1}}$ ) with a logarithmic term ${\log(h)/3}$  and a constant $c_0$. This version is used for instance frequently in the tetration-forum. Or you may get a start at some question in MO and its related q&a's.
If I recall correctly, it is moreover based on the Schroeder-mechanism, and not by some attempt to find the $c_k$ as in your system directly.
It is too much to go deeper here, I must give my compliments that you seem to have found the basic formal properties of an Abel-system and its formal powerseries - whether it is solvable with that type of coefficients ($c_0=0$? $a_0=1$?) or not.

update2
7. Application and further development of the Robbins-ansatz
To show a method how to at least arrive at some estimates for the coefficients and get meaningful approximations for the values in the $\varphi^{\circ -1}()$ function.
I follow here the ansatz of A. Robbins.
First we observe, that in (eq 6d) $ \varphi(\varphi^{\circ -1}(x)+1)=\exp(x)$ we can $\varphi^{\circ -1}()$ apply on each side. (Of course we must assume that the powerseries/dotproducts have some finite radius of convergence). We get then the equation
$$ \varphi^{\circ -1}(x)+1=\varphi^{\circ -1}(\exp(x)) \tag {7a}$$
In matrix-notation (let's write for notational comfort $Q=\phi^{-1}$):
$$   V(x) \cdot Q \cdot P = V(x) \cdot B \cdot Q  $$
and then the identity of coefficients in the matrix-compositions alone
$$    Q \cdot P = B_b \cdot Q \tag {7b} $$
We assume the inverse $\varphi()$-function to be
$$ Q(x)= q_1 x + q_2 x^2 + q_3 x^3 + ...\tag {7c} $$
and that we have that coefficients in the second column in the (Carleman-) matrix $Q$:
$$ Q_{[,1]} = [0,q_1,q_2,q_3,...] \tag {7d} $$
Then, if we look again at (eq 7b) we can reduce the equality to the essential part
$$    (Q \cdot P)_{[,1]} = (B_b \cdot Q)_{[,1]} \tag {7e} $$
which is
$$  V(0) + Q_{[,1]}  = B_b \cdot Q_{[,1]} \tag {7f}$$
Now we can rearrange the left $Q_{[,1]}$ to the right
$$  V(0)  = B_b\cdot Q_{[,1]} -Q_{[,1]} \\
V(0)  = (B_b - I)\cdot Q_{[,1]} \tag {7g}$$
Now, using a finite size, say $n=8$ we could feed this in a solver, like
matsolve(Bb-I,V(0)) but unfortunately the first column in the expression $B_b - I$ is completely zero (because $B_b$ has the form of a Carlemanmatrix) and is thus not invertible.
The idea of Robbins was here,

to cheat a bit: to remove the first column and the last row to have again a square matrix, but which can now be inverted. If this works at all it might later be justified by the goal that we want to work with matrices of infinite size where such a transition might be possible and still meaningful.
to try this for increasing size of the matrices and to look, whether that increasing would make the leading coefficients converge to something.

I've reproduced that idea, and because the improving of approximation is slow, document only the doubled sizes: $n=2^1,2^2,2^3,...,2^7$ (for the shortened $B_b-I$!) and got the following output:
Table $7h$: approximations to coefficients $q_k$ of powerseries $Q(x)$
$$ \small \begin{array} {r|rrrrrrrrrrrrr}
 n & q_0 & q_1 & q_2 & q_3 & q_4 & q_5 & q_6 & q_7 & ...\\ \hline
 2&0 & 1.0000000 & 0 & . & . & . & . & . \\
 4&0 & 0.92307692 & 0.24615385 & -0.18461538 & 0.015384615 & . & . & . \\
 8&0 & 0.91644296 & 0.24850496 & -0.11395859 & -0.093197376 & 0.020154115 & 0.040614135 & -0.021681561 \\
 16&0 & 0.91595862 & 0.24921856 & -0.11061148 & -0.093582187 & 0.010588156 & 0.035629206 & 0.0054841446 \\
32& 0 & 0.91594399 & 0.24933929 & -0.11046111 & -0.093883524 & 0.010030915 & 0.035820110 & 0.0064801129 \\
64& 0 & 0.91594562 & 0.24935378 & -0.11046270 & -0.093932220 & 0.010001216 & 0.035889177 & 0.0065707651 \\
128& 0 & 0.91594601 & 0.24935461 & -0.11046450 & -0.093936126 & 0.010002714 & 0.035897333 & 0.0065738120\\ \hline
700^* & 0 & 0.91594606 & 0.24935460& -0.11046476& -0.093936255& 0.010003233& 0.035897922& 0.0065734011
 \end{array}
$$
 (*) Data computed by Jay D Fox (2007) in Tetration-forum
This values are also documented in the Robbins-article, however he wrote them as $n$'th derivatives, and his values must be divided by factorials. (After that I got differences to Robbins' data in about $7$'th decimal digit):
Table $7i$: comparision of coefficients of computed $Q(x)$ and Robbins' documentation:
$$ \small \begin{array} {r|r}
 \text{reproduction} & \text{Robbins}\\
   n=128  & n=160 \\ \hline
 0 & . \\
 0.91594601 & 0.91594603 \\
 0.24935461 & 0.24935462 \\
 -0.11046450 & -0.11046461 \\
 -0.093936126 & -0.093936220 \\
 0.010002714 & 0.010002913 \\
 0.035897333 & 0.035897641 \\
 0.0065738120 & 0.0065737081 \\
 -0.012305809 & -0.012306288
 \end{array}
$$
Robbins claims then additionally that a meaningful assumption would be $q_0=-1$ , because then we have normalized $Q_R(0)=-1$ and $Q_R(1)=0$ and $Q_R(e)=1$ (let's write that modified function $Q()$ indexed as $Q_R()$ from now). $Q_R(x)$ is then the function $\text{slog}()$ in Robbins' article.
Calculations by this style give then meaningful numbers with accuracy of some $6$ to $10$ digits precision, such that $Q_R(e^x)-Q_R(x)\approx 1$ and $Q_R(1)=0$ and for (small!) values $Q_R(\,^he) = h$. For instance using that value that Robbins gives for $ x =\,^{0.5}e \approx 1.6463546427466649$ and using this value in the $Q_R()$ function gives $Q_R( x ) =  0.50000026$ which I find quite a nice approximation (using $n=64$ terms/matrices). Note that this $x$ seems to exceed the range of convergence, but since $Q()$ has coefficients with (roughly) alternating signs the sum can be done by Euler-summation with small order. (With that Eulersummation we find by binary search the more precise value $x_{0.5}=1.64635422897119922045=\,^{0.5}e   $ and $Q_R(x_{0.5})=0.5$ to $20$ digits)
Robbins does not give the coefficients $c_k$ (by the inversion of the powerseries $Q_R(x)$).
But assuming the $Q(x)$ function with $q_0=0$ we can do inversion and get coefficients:
$$ \hat \varphi(x)=  1.0917674 x - 0.32449483 x^2 + 0.34983599 x^3 - 0.23085419 x^4 + 0.20133057 x^5 + O(x^6) \tag {7j} $$
(where I write $\hat \varphi()$ to denote that this is not taken from the original definition of $\varphi()$ above)
Looking at this with $64$ coefficients it is much likely that the radius of convergence is small, but it seems, that we can subtract the coefficients of the $\log(1+x)$-Mercator series from this, and get a better series even with larger range of convergence, say
$$ \hat \varphi_2(x) = \hat \varphi(x) - \log(1+x) \tag {7k} $$
The first few coefficients are then
$$ \hat \varphi_2(x)=  0.091767404 x + 0.17550517 x^2 + 0.016502661 x^3 + 0.019145810 x^4 + 0.0013305742 x^5 + 0.0023142725 x^6 - 2.1040292 E-5 x^7 + O(x^8) \tag {7L} $$
With this I get the following results:
Table $7m$ - tetrations of $e$ to height $x$
$$ \begin{array} {}
  x & y=\hat \varphi_2(x)+\log(1+x) & \exp(y) &\text{comment}\\ \hline
  0& 0& 1\\
  0.5 &   0.49856329 & 1.6463542 & 13 \text{ dig correct to } x_{0.5}\\
  \pi/4 &  0.77623646 & 2.1732776 & \\
1 & 1.0000000 & 2.7182818  & 22 \text{ dig correct}\\
  1.5 &    1.6463542 & 5.1880309 & 16 \text{ dig good} \\
  2.0 &   2.7182818 & 15.154262 & \text{$9$ and $8$ dig good} \\
  e & & 2075.9680 & \text{by using $e-2$  and } \exp(\exp(y)) \\
 & & &\text{ the Robbins-value is } 2075.9681
\end{array}$$
This looks very good, and leaves only, to add the exponentiation to the operation to have a tetration-function for the basis $e$.
We can thus fractionally tetrate to base $e$  and the final form should then be:
$$ \hat {\text{tet}}(x) = \exp(\hat \varphi_2(x) +\log(1+x)) \\
 = \,^x e  \tag {7n}$$

Well, this seems to have now escaped from your construction of the $c_k$ and your $\varphi(x)$-function. At the moment, I don't see how to establish a clearer relation, perhaps I can come back to this later...
Comment: This is a really great in-depth answer to my problem, despite the negative-result. Enjoyed our discussion in the comments leading up to this. To clarify your remark: I was originally looking to solve for iterations of $\exp(x)$ rather than $\exp(x)-1$. In any case, the coefficients $c_k$ are for $\phi(x)$, which denotes the $x^{\text{th}}$ exponentiation of zero, hence why I define $\phi(0)=\exp^0(0)=c_0=0$.
Comment: see my *addendum* concerning indexing from 0
Comment: nice work indeed !
Answer: ----  This is just an addendum to the excellent answer above, concerning  indexing the matrix and vectors from $0$  ---
We can index the matrix and the vector from $0$ putting:
$$
T_{n,m}  = \left( \begin{array}{c}
 n - 1 \\  n - m \\
 \end{array} \right)m!\;\,\left| {\;0 \le n,m} \right.
$$
wherefrom for $n=0$ we get
$$
\begin{array}{l}
 a_n  = \sum\limits_{k = 0}^n {T_{n,k} c_k a_{n - k} }
  = \sum\limits_{0 \le k} {T_{n,k} c_k a_{n - k} } \quad  \Rightarrow  \\
  \Rightarrow \quad a_0  = T_{0,0} c_0 a_0  = \left( \begin{array}{c}
  - 1 \\  0 \\
 \end{array} \right)c_0 a_0  \Rightarrow \left\{ \begin{array}{l}
 c_0  = 1 \\  a_0  = 1 \\
 \end{array} \right. \\
 a_n  = \sum\limits_{k = n}^\infty  {\frac{{k!}}{{\left( {k - n} \right)!}}c_k } \quad  \Rightarrow \quad a_n
  = n!\sum\limits_{0 \le k} {\left( \begin{array}{l}
 k \\  n \\
 \end{array} \right)c_k } \quad  \Rightarrow  \\
  \Rightarrow \quad a_0  = \sum\limits_{k = 0}^\infty  {c_k }  \Rightarrow \left\{ \begin{array}{l}
 c_0  = a_0  = 1 \\
 \sum\limits_{k = 1}^\infty  {c_k }  = 0 \\
 \end{array} \right. \\
 \end{array}
$$


wbadmin incremental system state backup

Question: I am doing system state backups on a Windows Server 2008 R2 Enterprise (Service Pack 1) machine and expected the backups after the first one to be incremental. However with each backup a new directory with vhd files are created and the vhd files are almost the same size as the with the first backup. So the backups does not seem to be incremental.
I used the following command to do the backup:

wbadmin start systemstatebackup -backupTarget:f:

I played around with the settings under "Configure Performance Settings" in the Windows Server Backup plugin in Server Manager but according to the description at the top of the dialog these settings are not applied to system state backups.
Are there any settings available for wbadmin system state backup to make the backups incremental?
Answer: The incremental backup will work when you assign a dedicated disk that will be formatted by the Windows Backup Software. If you use a shared location each time it will run will create a new full backup!
Answer: Windows Server Backup uses Volume Shadow Copy Service and block-level backup technology to efficiently back up and recover the operating system, files and folders, and volumes. After the first full backup is created, Windows Server Backup automatically runs incremental backups by saving only the data that has changed since the last backup occurred. Unlike previous versions, you no longer have to worry about manually scheduling full and incremental backups.
Comment: Is the changed data supposed to be copied/replaced to/in the same VHD that was created by the first backup? I get a new directory with a name like "Backup 2011-03-15 104335" with every backup that contains a VHD file of roughly 7GB.
Comment: Explained in detail here: http://standalonelabs.wordpress.com/2011/05/25/a-closer-look-at-windows-server-backup-and-where-did-my-backup-files-go/
Comment: @user74513 Guido is right at 85%. wbadmin need a local disk to be "able" to make a incremental backup. The tool can't make that on a remote folder in exemple, but it warn you when you make that choice in the wizard.

wbadmin incremental system state backup


E-mail Marketing e colspan

Question: Estou estudando HTML para utilizar em e-mail marketing e estava olhando este e-mail aqui:
Entendi o começo do código, porém não entendi a aplicação do colspan:

E caso eu tire o colspan, a parte de cima do layout move pra esquerda.
Comment: Se a outra linha tem 3 colunas, sem nenhum colspan, colspan="4" não faz sentido.
Comment: @bfavaretto e provavelmente um erro de quem originalmente criou o email - note que na imagem fornecida pelo OP a parte inferior possui um pixel a mais do lado direito, o que pode ser uma reserva de espaço na TR para a célula extra.
Answer: O colspan serve para informar quantas colunas aquela linha vai ocupar, por na situação que você mandou acima, repare que a primeira linha (TR) possui 4 colunas (TD), já a segunda possui apenas 1 coluna, sem informar a mesma utilizara o espaço de 4 colunas, a imagem ficaria torta tentando ocupar apenas o espaço do botão facebook, dentro de uma tabela, todas as linhas precisam ter o mesmo numero de colunas e cada uma seguira a mesma largura da sua correspondente.
Comment: A primeira linha tem 3 colunas.
Comment: Valeu pela explicação, consegui entender agora, valeu!
Answer: A tabela possui 2 linhas com 3 colunas na primeira e 1 só coluna na segunda.
Para que a segunda linha se ajuste com a primeira, você usa o colspan pra compensar.
Caso vc omita o colspan na segunda linha, a coluna desta linha ficará na largura da primeira coluna da primeira linha.
Execute o código abaixo:

    linha 1 - coluna 1

    linha 1 - coluna 2

    linha 1 - coluna 3

    linha 2 - coluna 1

Comment: Faltou justamente o colspan, não?
Comment: @bfavaretto Isso. Deixei sem o colspan pra vc ver a diferença. Se vc colocar o colspan a linha verde vai se expandir 3 colunas. Na verdade, aquele colspan="4" está incorreto. Como a tabela só tem 3 colunas, o ideal seria colspan="3", porém, se vc colocar um valor maior, não faz diferença pq o colspan só vai até o limite de colunas na tabela.
Comment: Eu sei (eu não sou o autor da pergunta rs). É que achei confuso seu exemplo ser sem colspan se o que ele quer é com (acho)
Comment: @bfavaretto Rss verdade. Não, eu botei sem justamente pra ele ver como fica, já que ele perguntou "E caso eu tire o colspan, a parte de cima do layout move pra esquerda.".
Comment: @DavidSamm Consegui entender perfeitamento, obrigado pela explicação. Executei o seu código e fiz uns testes com o meu e consegui entender, valeu!

E-mail Marketing e colspan


An exercise on continuous functions

Question: Show that if $f : \mathbb{R} \rightarrow \mathbb{R}$ is continuous, with $f(1)=-1$, $f(3)=28$, there exist $x_1, x_2 \in (1,3)$ such that
$f(x_1)f(x_2)+x_1^3x_2=0$
For the above we have that there exists $x_0 \in (1,3) : f(x_0)=0$, since $f$ is continuous in $[1,3]$ and $f(1)\cdot f(3)<0$ (Bolzano's theorem).
Any ideas on how to continue?
Answer: Let $\varphi(x,y)=f(x)f(y)+x^{3}y$, $(x,y)\in[1,3]\times[1,3]$, then $\varphi(1,3)=-25<0$. Now find some $x_{0}\in(1,3)$ such that $f(x_{0})=0$, then $\varphi(x_{0},1)=x_{0}^{3}>0$.
Consider the line $L$ joining $(x_{0},1)$ and $(1,3)$, that is, $L(x)=-\dfrac{2}{x_{0}-1}x+=\dfrac{3x_{0}-1}{x_{0}-1}$, then the map $\xi:[1,x_{0}]\rightarrow[1,3]$ defined by $\xi(x)=\varphi(x,L(x))$ is continuous and $\xi(1)=\varphi(1,3)<0$, $\xi(x_{0})=\varphi(x_{0},1)>0$, so some $x_{1}\in(1,x_{0})$ is such that $\xi(x_{1})=0$. Now $1<x_{2}:=L(x_{1})<3$, and we have $\varphi(x_{1},L(x_{1}))=\varphi(x_{1},x_{2})=f(x_{1})f(x_{2})+x_{1}^{3}x_{2}=0$.
Comment: thsnk you very much user284331, this is an elegant solution
Answer: Choosing $x_1=1$ the equation turns into $g(x_2)=0$ where $g(x)=-f(x)+x$. It holds that $g(1)=2$ and $g(3)=-25$. Consequently, there exists $x_2\in(1,3)$ such that $g(x_2)=0$. Done.
Comment: OP wants $x_1 \in (1,3).$
Comment: This is easy to handle. Just take $x_1=1+\varepsilon$ for $\varepsilon$ positive and sufficiently small. Proceed as in my answer and continuity of $f$ does the rest.

An exercise on continuous functions


Stable results with TensorFlow

Question: What would be a good way to ensure TensorFlow results persist across
different runs? I can't find much information on e.g. seeding random weight initialization, so my results tend to differ with every run.
Answer: The API method tf.set_random_seed() can be used to set a random seed that will be used in all TensorFlow random operations (including the usual random weight initializers and tf.RandomShuffleQueue).

Stable results with TensorFlow


Loading webform in modal is too slow

Question: I have webform with near 130 fields (text, entity checkboxes, radios, composite, etc)
Use it in modal:
click to open

It tooks near 9 seconds to load it.
Interal and Dynamic page cache enabled.
Js and css aggregation enabled.
Opens webform on it's own page and if page is cached then it tooks 2 sec to load (all page, not only form).
So I think the problem is in cache.
How can I cache ajax response or how to solve this issue?
Thanks in advance.
Comment: 130 fields… Make it into a multi step webform.
Comment: 130 field webform in a _modal_? You can set up wizard mode in Webform and disable the user controlled advancement.
Comment: Multistep is not usefull because user could't go to any tab.

I think I found the bottleneck... I use computed field in views that renders entity radios. Its load time is about 1 sec. I have four fields.

So I need to investigate why computed field time is so long.
Comment: 'Multistep is not usefull because user could't go to any tab' If I remember correctly they should be able to, but only to steps that have already been completed.
Comment: I removed computed field module and rewrite it with hook_node_presave. Perfomance increased 10 times.

Thanks to everyone.
Answer: The core team is working on cacheable Ajax requests. The first project using it is Views. Modals might be next.
Until then you could deliver the hidden webform together with the cached page and unhide it with javascript, like jQuery Modal or Bootstrap's modal component.
Alternatively, make a custom jQuery.ajax() call pointing at your own controller which returns the rendered web form in a cacheable response.
Comment: Thank you! It will be great if Ajax request will be cacheable.

Loading webform in modal is too slow


Server-side reactjs how to render all routes server-side / is it necessary for SEO? (Electrode)

Question: I am using walmart's electrode framework which is a universal framework that can render components/routes in reactjs on the server side and send back compiled html. Currently what happens is that the initial page load will render on the server and send me back compiled html. However, after clicking on any Link's, the subsequent routing navigation is handled in a SPA-like way and I am no longer receiving templates from the server, rather the client is building them.
So my questions are:
Is there a way I can set it up so that when I click to hit new routes, I continue to receive server-rendered html?
Or is this intentionally the idea that only the initial pageload needs to be rendered server-side and the rest is ok client-side?
Will it negatively impact SEO if only initial page loads and reloads serve html from the server while clicks and routing render html client-side?
Thanks
Answer:
Is there a way I can set it up so that when I click to hit new routes, I continue to receive server-rendered html?
  Or is this intentionally the idea that only the initial pageload needs to be rendered server-side and the rest is ok client-side?

Its intentionally setup this way. Once the server has generated HTML markup, there is no need to get "HTML" from the server, the client can generate the markup as required.

Will it negatively impact SEO if only initial page loads and reloads serve html from the server while clicks and routing render html client-side?

The answer would be No, Google and certain other bots are able to render Javascript on the client and index results. However for other bots, your HTML output is valuable and they will continue to navigate and load full pages - Essentially a multi-page application.
Bottom line: Use server rendered markup for SEO and performance value and continue client side.
Comment: I was just gonna say this :) Any bot that doesn't execute javascript will just do full reloads when following links as long as the history API is used instead of hash-urls.


Issues with using Expectation Maximization algorithm

Question: I was using the EM algorithm to maximize a partially observed likelihood. However, I have certain doubts. Normally, the algorithm works fine. I could print the value of the log likelihood of the observed data that I am trying to minimize and the values keeps on going down and converge. However, at times, I could see that it goes down for a while and then starts increasing. What could be the reason for that? As far as the code is concerned, I am pretty sure it's fine. Any suggestions?
Answer: Three possibilities that come to mind:

Numerical stability problems: due to the scale of the numbers you are dealing with, the floating point representation causes small inaccuracies that may become significant. This usually happens when combining numbers on very different scales.
Incorrect likelihood/gradient: you may have calculated the likelihood or gradient incorrectly.
Incorrect implementation of EM: have you implemented EM before? there may be some gap in understanding of the algorithm (no disrespect meant).

From your description it sounds like it is probably numerical issues.


Why does MAP converge to MLE?

Question: In Kevin Murphy's "Machine learning: A probabilistic perspective", chapter 3.2,
the author demonstrates Bayesian concept learning on an example called "number game": After observing $N$ samples from $\{1,...,100\}$, we want to pick a hypothesis $h$ which best describes the rule that generated the samples. For example "even numbers" or "prime numbers".
The maximum a-posteriori and maximum likelihood estimates are defined as:
$$\hat h_\mathrm{MAP}={\arg\max}_h\ p(\mathcal{D}|h)p(h)={\arg\max}_h[\log p(\mathcal{D}|h)+\log p(h)],$$
$$\hat h_\mathrm{MLE}={\arg\max}_h\ p(\mathcal{D}|h)={\arg\max}_h\log p(\mathcal{D}|h),$$
where $p(h)$ represents the prior probabilities of various hypotheses and the posterior is defined as:
$$p(\mathcal{D}|h)=\Bigg[\frac{1}{|h|}\Bigg]^N,$$
iff $\mathcal{D}\subset h$, i.e., how likely it is that uniform sampling with replacement from the hypothesis $h$ would yield set $\mathcal{D}$. Intuitively it means that the posterior is highest for "smallest" hypotheses. For example, hypotheses "powers of 2" explains observations $\{2,4,8,16,64\}$ better than "even numbers".
All of this is clear. However, I am confused about the following sentence (even though intuitively it makes perfect sense):

Since the likelihood term depends exponentially on $N$, and the prior stays constant, as we get more and more data, the MAP estimate converges towards the maximum likelihood estimate.

It is true that the likelihood depends exponentially on $N$, however, the exponentiated number is in the interval $(0,1)$ and as $N \to \infty$, $x^N \to 0$, so the likelihood should actually vanish.
Why does MAP converge to MLE in this case?
Comment: This is a consequence of the Bernstein - von Mises theorem: http://www.nber.org/WNE/Slides7-31-07/slides_7_bayes.pdf (start at slide 9.)  Also: http://andrewgelman.com/2017/11/27/asymptotically-we-are-all-dead/.
Comment: Thanks for the references. However, how do they explain this contradictory example?
Comment: Related https://stats.stackexchange.com/questions/200982/do-bayesian-priors-become-irrelevant-with-large-sample-size
Answer: There are two issues here, first, why does the MAP converge to the MLE generally (but not always) and the "vanishing likelihood" problem.
For the first issue, we refer ourselves to the Bernstein - von Mises theorem.  The essence of it is that, as the sample size grows, the relative information contained in the prior and in the data shifts in favor of the data, so the posterior becomes more concentrated around the data-only estimate of the MLE, and the peak actually converges to the MLE (with the usual caveat that certain assumptions have to be met.)  See the Wikipedia page for a brief overview.
For the second issue, this comes about because you have not normalized the posterior density.  By Bayes' Rule:
$$P(h|D) = {P(D|h)p(h) \over p(D)}$$
and, although $P(D|h) \to 0$ as $n \to \infty$, as you observe, so does $P(D)$.  For a little more concreteness, if we assume two hypotheses $h_1$ and $h_2$, we find the posterior by:
$$P(h_1|D) = {P(D|h_1)p(h_1) \over P(D|h_1)p(h_1) + P(D|h_2)p(h_2)}$$
Both the numerator and the denominator have terms raised to the power $N$, so both $\to 0$ as $N \to \infty$, but it should be clear that the normalization required fixes the problem that this would otherwise cause.
Comment: Why doesn't MAP always converge to MLE?
Comment: @HappyFace - the Wikipedia entry has a couple of examples.

Why does MAP converge to MLE?


R e PostgreSql - AND/OR e BEETWEN/NOT BEETWEN como ajudar na lógica?

Question: Preciso pegar algumas informações do banco de dados postgreSQL através do R .
Entretanto, os filtros não estão baixando o que eu quero. Gostaria que baixasse apenas as cnaes de empresas com situação cadastral "2" e na data "02/2020". Como fiz, ele está puxando outras datas.
Segue exemplo:
library(RPostgreSQL)
...
Cnae_selecionada <- dbGetQuery(con,"
                   SELECT *
                   FROM cnpj.cnae
                   WHERE
                      (cnae_fiscal BETWEEN 3700000 AND 3999999)
                   OR (cnae_fiscal BETWEEN 4900000 AND 5399999)
                   OR (cnae_fiscal BETWEEN 5500000 AND 5699999)
                   OR (cnae_fiscal BETWEEN 5800000 AND 6399999)
                   OR (cnae_fiscal BETWEEN 6600000 AND 6699999)
                   OR (cnae_fiscal BETWEEN 6800000 AND 7599999)
                   OR (cnae_fiscal BETWEEN 7700000 AND 8299999)
                   OR (cnae_fiscal BETWEEN 9200000 AND 9699999)
                   OR (cnae_fiscal BETWEEN 160000 AND 169999)
                   OR (cnae_fiscal BETWEEN 230000 AND 239999)
                   OR (cnae_fiscal BETWEEN 4520000 AND 4529999)
                   OR (cnae_fiscal BETWEEN 4543000 AND 4543999)
                   OR (cnae_fiscal BETWEEN 8550000 AND 8559999)
                   OR (cnae_fiscal BETWEEN 8590000 AND 8599999)
                   AND (cnae_fiscal NOT BETWEEN 6912000 AND 6912999)
                   AND (cnae_fiscal NOT BETWEEN 7010000 AND 7019999)
                   AND (cnae_fiscal NOT BETWEEN 8112000 AND 8112999)
                   AND (cnae_fiscal NOT BETWEEN 9400000 AND 9499999)
                   AND situacao_cadastral LIKE '2'AND data LIKE '%02/2020%'
                   ")

Tentei de algumas outras formas também, porém sem sucesso.
Comment: Verifique a prioridade dos operadores AND e OR. Talvez seja necessária uma parentização para a avaliação correta. No seu caso todos estes AND se aplicam apenas a `(cnae_fiscal BETWEEN 8590000 AND 8599999)` ou deveriam se aplicar a todas as faixas?
Comment: qual o tipo de dados do campo `data`?
Answer: Você precisa separar as condições OR e AND, se elas estiverem alinhadas, qualquer OR que seja true, vai ignorar os outros AND. Use ( ) e separe todos os OR:
   SELECT *
   FROM cnpj.cnae
   WHERE
   (
      (cnae_fiscal BETWEEN 3700000 AND 3999999)
   OR (cnae_fiscal BETWEEN 4900000 AND 5399999)
   OR (cnae_fiscal BETWEEN 5500000 AND 5699999)
   OR (cnae_fiscal BETWEEN 5800000 AND 6399999)
   OR (cnae_fiscal BETWEEN 6600000 AND 6699999)
   OR (cnae_fiscal BETWEEN 6800000 AND 7599999)
   OR (cnae_fiscal BETWEEN 7700000 AND 8299999)
   OR (cnae_fiscal BETWEEN 9200000 AND 9699999)
   OR (cnae_fiscal BETWEEN 160000 AND 169999)
   OR (cnae_fiscal BETWEEN 230000 AND 239999)
   OR (cnae_fiscal BETWEEN 4520000 AND 4529999)
   OR (cnae_fiscal BETWEEN 4543000 AND 4543999)
   OR (cnae_fiscal BETWEEN 8550000 AND 8559999)
   OR (cnae_fiscal BETWEEN 8590000 AND 8599999)
   )

   AND (cnae_fiscal NOT BETWEEN 6912000 AND 6912999)
   AND (cnae_fiscal NOT BETWEEN 7010000 AND 7019999)
   AND (cnae_fiscal NOT BETWEEN 8112000 AND 8112999)
   AND (cnae_fiscal NOT BETWEEN 9400000 AND 9499999)
   AND situacao_cadastral = '2' AND  data LIKE '%02/2020%'

A data, salvo se estiver no formato de texto, você pode usar:
date_trunc('day', data) between '01/02/2020' and '29/02/2020'

Comment: Perfeito ! Obrigado ! E a data está em forma de texto mesmo, com um charactere a mais, inclusive.


circle affine transformation

Question: I am trying to convert a region of pixels surrounded by an ellipse into an equivalent stretched circle.This basically means affine transformation. Assume I want to extract the region in light blue surrounded by the yellow ellipse, then find the equivalent circle for further processing. How can I do so using matrix multiplication, addition and subtraction only? Note that the centre of the ellipse may be another point rather than the origin, say (x0,y0). Assume that I have the values of the minor axis, major axis, the centre and the angle of rotation.

What I have in mind is to counter clockwise rotate the region by theta around the centre, then resize the region so that the length of the minor axis == length of major axis, and then rotate clockwise by theta again around the centre. Still, I don't know how to do so.
applying your answer, given in this code:
"
function [xr, yr] = ellipse2circle(x0,y0,a,b,theta, X, Y)
R1=[+cos(theta), +sin(theta), 0;
    -sin(theta), +cos(theta), 0;
        0,            0,      1];
R2=[+cos(theta), -sin(theta), 0;
    +sin(theta), +cos(theta), 0;
        0,            0,      1];
T1=[1, 0, -x0;    0, 1, -y0;    0, 0,  +1];
T2=[1, 0, +x0;    0, 1, +y0;    0, 0,  +1];
D=[1/1, 0,  0;    0, a/b, 0;    0, 0,  +1];
M=T2*R2*D*R1*T1;
V=[X, Y, ones(length(X),1)]';
U=M*V;
xr=U(1,:)';
yr=U(2,:)';
"
I got this result:
Answer: Assume that you're representing points as triples of real numbers of the form
$$
\begin{bmatrix}{x\\y\\1}\end{bmatrix}
$$
so that transformations can be described by $3 \times 3$ matrices. Let $\theta$ be the angle from the $x$-axis counterclockwise to the major axis of your ellipse (in your example, $\theta$ is about 45 degrees, or $\pi/4$ radians). Let $a = \cos \theta$ and $b = \sin \theta$, just to save me typing. Let $(c, d)$ be the center point of the ellipse.
Let
$$
R_1 = \begin{bmatrix}a & b & 0 \\
-b & a & 0 \\
0 & 0 & 1
\end{bmatrix}\\
R_2 = \begin{bmatrix}a & -b & 0 \\
b & a & 0 \\
0 & 0 & 1
\end{bmatrix}
$$
and
$$
T_1 = \begin{bmatrix}1 & 0 & -c \\ 0 & 1 & -d \\ 0 & 0 & 1\end{bmatrix}\\
T_2 = \begin{bmatrix}1 & 0 &  c \\ 0 & 1 &  d \\ 0 & 0 & 1\end{bmatrix}\\
$$
and
$$
D = \begin{bmatrix}
1 & 0 & 0 \\
0 & s/t & 0 \\
0 & 0 & 1
\end{bmatrix}
$$
where $s$ and $t$ are the major and minor axis lengths, respectively.
Then build the matrix
$$
M = T_2 \cdot R_2 \cdot D \cdot R_1 \cdot T_1
$$
and the transformation
$$
\begin{bmatrix}{x\\y\\1}\end{bmatrix} \mapsto M \cdot \begin{bmatrix}{x\\y\\1}\end{bmatrix}
$$
will be the one you want.
Basically, reading from right to left in the list of matrices, this

moves the ellipse-center to the origin
rotates the ellipse clockwise about the origin by angle $\theta$, so that the major axis lines up with the $x$-axis.
scales the $y$-axis up so that it's as fat in $y$ as in $x$.
rotates counterclockwise by $\theta$.
translates the ellipse-center back to where it used to be.
Comment: Thank you for the detailed answer :)
but does this transform into a unit circle? if yes, then how I transform into a circle with radius equals to the major axis length? just as explained in the figure above?
Comment: You're welcome. You might mark it as a correct answer so that I get credit for it. :)
Comment: sure, but please see my edit above first. It seems that the result of this is not a circle as you can see. I believe the issue is from the D matrix. Can you please help me to fix it?
Comment: Perhaps you want to swap $a$ and $b$, i.e., put $b/a$ instead of $a/b$ -- maybe you've got major and minor swapped. But it looks as if perhaps $a$ and $b$ are equal and you've got no scaling at all. Try putting in a breakpoint at that line and seeing what $a$ and $b$ actually are.
Comment: I checked what you said, a and b are correct and not equal, but maybe the issue is from the D matrix.
Comment: In your example, I guess $a$ should be about $70$ and $b$ about 35. The matrix $D$ should be diagonal with (roughly) $1, 2, 1$ on the diagonal. (Indeed, you can create it with "diag(1, a/b, 1)" in matlab!)

Debugging hint: Change your line "M=T2*R2*D*R1*T1;" to "M = T1" and runit; the ellipse should be centered at the origin. Change it to "M=R1*T1;"; you should get an axis-aligned ellipse at the origin, longer in $x$ than in $y$. While you're looking at it, compute r = width/height. Change it to  "M=D*R1*T1;" Check that the 2nd diag entry of $D$ is actually r. Should be a circle. Report back.
Comment: Thank you very much, I managed to debug the error (in other part of the code) and yours is perfectly working.

circle affine transformation


Error install nodejs...SSL_COMP_get_compression_methods

Question: installing node-v0.4.8 on mac os x leopard, I get the following error:
../src/node_crypto.cc:2917: error: 'SSL_COMP_get_compression_methods' was not declared in this scope
Waf: Leaving directory `/usr/local/node-v0.4.8/build'
Build failed:  -> task failed (err #1):
    {task: cxx node_crypto.cc -> node_crypto_4.o}

make: *** [program] Error 1

Anyone experienced this error installing the latest nodejs?  Thanks for any suggestions.
Comment: are you compiling with superuser privs in that /usr/local ?
Comment: idk, guessing blind since I don't do OSX
Answer: The version of openssl included with MacOSX is not the latest. I would recommend grabbing the latest version here:
http://www.openssl.org/source/openssl-1.0.0d.tar.gz
Extracting it to your directory of choice, cd to that directory:
$ ./configure
$ make
$ sudo make install

The last sudo command will require you enter your admin password. Then go to the node.js source directory and:
$ ./configure --openssl-includes=/usr/local --openssl-libpath=/usr/local

This will tell node to use the custom built openssl we just compiled and installed. Then finally:
$ make
$ sudo make install

Answer: Sorry, don't know how to comment instead of post an answer. But this didn't work for me. Same SSL error. This however worked:
http://nelsonslog.wordpress.com/2011/04/10/node-without-ssl/
This is fine for now since I'm just prototyping, but obviously lack of SSL sucks.


Unable to add deleted files to index after git branch merge

Question: In an Eclipse (Oxygen.3a Release (4.7.3a)) java project, I merged two branches and resolved all conflicts, getting no compilation errors and all tests to pass.
However, EGit (126.96.36.199712150930-r) won't let me add deleted files to the index/stage. The button for doing so is enabled, but nothing happens when I press it.
As a result, the conflicts regarding these files are not resolved (adding to the index is required for that), so I cannot proceed with a merge commit.
The situation is as in the figure below.
What do I need to do to resolve these conflicts?
Answer: I could not solve this problem with EGit, but closing Eclipse and running
<code>git add -A .
</code>
in the command line solved the problem (opening Eclipse again immediately showed the files to be staged). (This solution came from this answer.)
So not sure this is an EGit bug or if I just didn't know how to take this step using it. However, like I said, using the command line solved the problem.


Setup OAuth2 in Lumen

Question: I followed this article written to setup OAuth2 for my API that I'm writing in Lumen. I finished setting it up and I implemented the client so that I could test that it works. I haven't been able to get it to work. When I click the 'Login to API' button, it sends a POST to http://myserver.com/login and it never finishes. It hangs here and I get no exceptions or errors of any kind. Also, when it hangs like that I cannot just refresh the page. I have to serve it on another port, if that's a clue as to what's happening. I output a bunch of log messages and I've narrowed the trouble down to this:
$guzzleResponse = $client->post(sprintf('%s/oauth/access-token', $config->get('app.url')), [
            'body' => $data
        ]);

I checked the parameters and they look good. $client is a GuzzleHttp Client. The post method inside looks like this:
public function post($url = null, array $options = [])
{
    return $this->send($this->createRequest('POST', $url, $options));
}

I think I may have to enable cookies in Lumen. Where would I go to find that out? Does anyone have any other ideas?
Comment: Unless I'm mistaken, Socailite is for a client to authenticate from a provider, like Github. In my case, I'm the provider and I need to have an OAuth2 server that interacts with a client that others are developing.
Comment: Could you not pull in Laravel's Socialite instead of rolling your own?
Answer: To enable cookie, you can do this in .env file -
SESSION_DRIVER=cookie

Then run composer update command.
Answer: Had you check your .env?.. please add AUTH_MODEL=App\Auth\User if that no there.
Answer: Sometimes Guzzle doesnot work with port eg localhost:8888. If you are runnnig your server on some port change it to default 80  and guzzle will work

Setup OAuth2 in Lumen


how does links__system_main_menu() work?

Question: How does the below code work at a high level?
print theme('links__system_main_menu', array(
  'links' => $main_menu,
  'attributes' => array(
    'id' => 'main-menu-links',
    'class' => array('links', 'clearfix'),
  ),
  'heading' => array(
    'text' => t('Main menu'),
    'level' => 'h2',
    'class' => array('element-invisible'),
  ),
));

Answer: Drupal renders the array argument you passed by looking up a suitable theme hook for links__system_main_menu.
The meaning of the argument should be documented in the module that provides the theme hook.


What do I need to know about drums as an electric metal guitar player

Question: My questions are as follows ...

As A guitarist (Mostly electric with heavy distortion) what minimum knowledge of drums do I need to be able to create or chose drums beats that suits the song I am practicing.
I have seen many resources for dedicated drum lessons but those are lengthy and needs hands on practice with drum kit. Are there any good (free or paid) lessons or websites focusing on the basics of drums required for a guitarist?
Is there some set of very common drum beats that sounds well for most of the metal songs? If yes then how can I find them. Note that I am talking about the time I practice not the actual performance time.
I have heard that drum machines have some pre-existing beats/patterns. Is there are common set of drum patterns across most machines? If yes then what are they and can I find them without a drum machine? (Like guitar-pro files or other software)

Note that I already know staff notation and tablature for guitar. I am playing guitar for about 2 years and I don't have a friend who is a drummer. I am aware of backing tracks for songs and I am not talking about them. I need to have a basic understanding of drums so that I can chose which of the drum patterns will be good for the lick I am practicing.
Comment: Welcome to Musical Practice and Performance, Tanmoy!
Comment: There are essentially two questions here: 1) how to gain an understanding of the basics of playing the drums for a non-drummer and 2) using that, how to find and use loops and backing tracks to play over for rehearsal.
Answer: The vast majority of metal, and rock for that matter, use a basic 4/4 beat. So if you can't get your hands on a proper DAW you can at least make do with something much more basic.
When I am away from my main computer, or travelling, I have a pretty good metronome which I can set to run 4/4 time, have fills at specific points, and an outro and it works for most purposes.
You can also run happily with a sampling looper - which obviously sounds better, and much more realistic.
Much better, though, is a full featured DAW. I use Cubase, and it lets me use samples, generated effects, full recorded backing tracks or any combination of the above. Many magazines (eg Guitarist) release backing tracks which you can drop straight into the DAW and play along to.
And as for the first part of your question - as a guitarist you don't need to know anything about drums, but I feel any knowledge is useful in any case. A DAW lets you create drum beats without knowing anything about drums.
Answer: As for the second question, finding practice loops, If you have a computer-based DAW that you can use for practicing (GarageBand, Cubase, etc.), there are companies that sell libraries of loops recorded by real drummers in a VST/AU software package that you can use for practice, or for composing songs. I have no personal experience with these, but one example is ToonTrack.com, which sells a number of popular modules in their EZDrummer and Superior Drummer lines, several of which are libraries of hard rock and metal phrases.
Answer: As other answers pointed out, you don't necessarily need to learn anything about drums. Software packs provide you enough beats to play along.
However, if you don't have such software, or you don't feel like buying such software, here are a few beats that are very common in this genre. Write them down on Guitar Pro, or any other software able to generate MIDI drums, and you're good to go.
Some notes:

Every symbol should be taken as a 16th note;
All beats are in a 4/4 time signature;
o marks a regular note, x marks an accent (crash cymbal, for instance);
The first line goes for cymbals (hi-hat, or ride), the middle line goes to the snare drum, and the bottom line to the bass/kick drum.

The standard 16th note bass drum
x---o---o---o---|o---o---o---o---|o---o---o---o---|o---o---o---o---|
----o-------o---|----o-------o---|----o-------o---|----o-------o---|
oooooooooooooooo|oooooooooooooooo|oooooooooooooooo|oooooooooooooooo|

This four bar repeating beat is very common. Usually, there's some fill or slight difference in the last bar. This beat is common mostly due to being very flexible.
You may use it:

At slower tempos (120~150 bpm, probably with 8th notes on the cymbals, instead of quarter notes) to play along heavy, slow rhythms.
At faster tempos (150+ bpm) to play along fast-paced, powerful, rhythms. Example: Remembered by Firewind, the beat just after the introduction.
For very fast-paced songs, you may add snare drums on every quarter note. Example: Electric Messiah, by Symphony X, the first beat you hear.
For very fast tempos, but slow/heavy rhythms, the snares hit only on the 3rd quarter note, instead of every 2nd and 4th.

The rock-inspired single bass drum
x---o---o---o---|o---o---o---o---|o---o---o---o---|o---o---o---o---|
----o-------o---|----o-------o---|----o-------o---|----o-------o---|
o-------o-o-----|o-------o-o-----|o-------o-o-----|o-------o-o-----|

This beat is lighter, and works well on most tempos. Fear of the Dark, by Iron Maiden, or Head Up High, by Firewind, use similar beats. Fear of the Dark moves around some kick drums, while Head Up High uses 8th notes on the cymbals, instead of quarters.
The gallop feel
x---o---o---o---|o---o---o---o---|o---o---o---o---|o---o---o---o---|
----o-------o---|----o-------o---|----o-------o---|----o-------o---|
o-oo--ooo-oo--oo|o-oo--ooo-oo--oo|o-oo--ooo-oo--oo|o-oo--ooo-oo--oo|

This is also a common beat. It usually goes along similar gallops on the guitars. Example: More Than Meets the Eye, by Testament, just after the intro.
The double tempo
x---o---o---o---|o---o---o---o---|o---o---o---o---|o---o---o---o---|
--o---o---o---o-|--o---o---o---o-|--o---o---o---o-|--o---o---o---o-|
o---o---o---oo--|o---o---o---oo--|o---o---o---oo--|o---o---o---oo--|

I called it double tempo because the snare hits in every upbeat, while the bass drum kicks in every beat, which feels like the tempo is doubled. This is usually seen either in heavier styles, or folk styles. Fits well in fast-paced tempos. Example: Beer Beer, by Korpiklaani.


Can blocks being exist and displayed without being stored in blocks table?

Question: I'm wondering what could be the problem.
When I queried the homebox_default table , it showed bids with 1950
1387
1382
953
958
1916
but when queried in the blocks table for these blocks with these bids are not existant there was no blocks with those ids. But when I see the homebox/1 page it shows page with blocks. How is that possible?
Comment: Yep, they could exist in cache, for example. Can't really comment on your specific situation without more details
Answer: Homeblock is actually not storing the data in block, it is actually inserting the data in its own custom table, like homeblock_users.
<code>  $data = new stdClass();
  $data->uid = $user->uid;
  $data->name = $page->name;
  $data->settings = $blocks;
  drupal_write_record('homebox_users', $data);
</code>
It is saving block data in hoemblock_users table. It is creating only one Block i.e. Homebox custom block.
<code>homebox_prepare_block
</code>
Above is the function through which dynamic block is created for a page, and all the variables are assigned to it.


Condtional statement to rbind if object exists

Question: I want to rbind and object called old_dat to main data object called dat only if it exists, otherwise dat remains unchanged.
old_dat is created using a separate function.
I have tried the following two methods:
 dat<- ifelse(exists("old_dat", envir = .GlobalEnv),
              rbind(dat,old_dat),dat)

and
exists("old_dat") && dat<- rbind(dat,old_dat)

Answer: dat <- rbind(dat, if(exists("old_dat")) old_dat)


How did he get this outcome?

Question: It's a matrix solved with least squares equations (probaly). I used some calculator but can't get his outcome. If you have a way how to get to this please explain how.
[The math on that image is:
$$A = \left[\matrix{4&3&1&0&1\cr 5&2&1&0&1\cr 4&2&1&1&1\cr 3&1&0&1&1\cr 1&1&0&1&1\cr}\right], \quad\vec b = \left[\matrix{4\cr 6\cr 6\cr 3\cr 1\cr}\right]$$
"Least Squares" of $A\vec x = \vec b$ is $\vec x = \left[\matrix{1\cr -1\cr 2\cr 1\cr 1\cr}\right]$.]
Pic related:
http://postimg.org/image/7ellc2pnl/
Comment: I can't get it, either. The matrix $A$ is invertible, and I get the solution $(1,-1,3,1,0)$.
Answer: When using the matrix as you have above, I also get $\left[\begin{array}{c}{1 \\ -1 \\ 3 \\ 1 \\ 0}\end{array}\right]$
However, when I add a bias column of $1$'s, I get closer to his displayed result: $\left[\begin{array}{c}{1 \\ -1 \\ 2 \\ 0.5 \\ 0.5}\end{array}\right]$
Again, the matrix used with extra bias column is:
$$\left[\begin{array}{ccccc|c}4 &3 &1 &0 &1 &1 \\
5 &2 &1 &0 &1 &1 \\
4 &2 &1 &1 &1 &1 \\
3 &1 &0 &1 &1 &1 \\
1 &1 &0 &1 &1 &1 \end{array}\right]$$
Comment: Finnegan's Finagle Factor?
Comment: What is a bias column?
Comment: https://en.wikipedia.org/wiki/Linear_least_squares_(mathematics)#The_general_problem  "The first column is populated with ones, $X_{j1} = 1$, only the other columns contain actual data, and $n$ = number of regressors + 1)."
Comment: @Axoren : The words "bias column" don't appear on that page.
Comment: What this column does is allow us to learn a constant term that shifts the line away from the origin by some amount. This relieves the restriction that we're learning an approximation that travels through $\vec 0$
Comment: IOW, Finnegan's Finagle Factor.
Comment: @CarlHeckman A bias term is common in machine learning. It's some initial constant that does not depend on the input (a predisposition to a certain result, a bias). In the wikipedia page, it does not call it this, but it does however describe explicitly that this extra column exists. I've quoted the portion that states this. On hand, I don't have a better text to cite for this, so I used the wikipedia article.
Answer: Least squares of $\mathrm{A} \boldsymbol{x}  = \boldsymbol{b}$ is
$$(\mathrm{A}^\top\mathrm{A}) \boldsymbol{x}  = \mathrm{A}^\top \boldsymbol{b}$$
$$ \boldsymbol{x}  =(\mathrm{A}^\top\mathrm{A})^{-1} \mathrm{A}^\top \boldsymbol{b}$$
Comment: And when you follow that formula with the above $A$, they get different results. This isn't useful.
Comment: It is because it is the correct answer for least squares. How do you know the given answer is "correct"? I think there is row or two missing from $\mathrm{A}$ or there is a mistake in $\boldsymbol{b}$.
Comment: Your answer doesn't clarify their issues. It simply restates the mechanism they're already using.
Comment: If you plug in the given $\boldsymbol{x}$ to $\mathrm{A} \boldsymbol{x}-\boldsymbol{b}$ you will get all zeros except the last one, which is 1. That tells me something is wrong.
Answer: The least square:
$$ f(x)=||Ax-b||^2 $$
$$ x = \arg \min_{x\in\mathbb{R}}f(x) $$
The minimization is usually made by the Levenberg-Marquardt algorithm.
The result that you have is because your matrix is ill-conditioned.

How did he get this outcome?


Complex Regression Model in Python

Question: For a project I am working on, I need to find a model for the data graphed below that includes a sine or cosine component (hard to tell from the image but the data does follow a trig-like function for each period, although the amplitude/max/mins are changing).
data
I originally planned on finding a simple regression model for my data using Desmos before I saw how complex the data was, but alas, I do not think I am capable of determining what equation to use without the help of Python. I don't have much experience with regression in Python, I've only done basic linear modeling where I knew the type of equation and was just determining the coefficients/constants. Could anyone offer a guiding example, git code, or resources that would be useful for this?
Comment: Let me know if the below response is any helpful
Answer: Your question is pretty generic and looking at the graph, we cannot tell much about the data to give you a more detailed answer, but i'd say have a look at OLS
https://www.statsmodels.org/dev/generated/statsmodels.regression.linear_model.OLS.html
You could also look at scikit learn for the various regression models it provides.
http://scikit-learn.org/stable/modules/linear_model.html
Essentially,these packages will help you figure our the equation you are looking to have for your data.
Also, looks like your graph has an outlier ? Please note regression is very sensitive to outliers, so you may want to handle those data points before fitting the model.

Complex Regression Model in Python


What is the average Dubstep tempo (BPM)?

Question: I've seen so many contradictory answers that I still can't figure out whether Dubstep average tempo is 70-75 BPM or 140-150 BPM.
There is a dispute even on this comprehensive list of genres on this very site.
Does anyone have an answer for such a riddle?
Comment: You'll note that those two ranges vary by a factor of 2. It's just a matter of how you feel it. Also, this discussion belongs in that thread.
Comment: I think the comments in the List of tempos give a useful perspective. If you consider it to be a *Rock* beat, then you have snares on 2 and 4 and choose the slower BPM. If you think of the piece as a 2-step, or ohm-Pah ohm-Pah, then choose the doubled speed and have snares on 3. I think the *Rock* POV makes more sense, but there's no *right answer* per se.
Comment: With reference to your username:  Down-votes are not political.  They represent our opinion that your question is not useful, or not of general interest.  The  intent is to allow researchers to evaluate Q&A quality based on ratings.
Comment: @Mattputnam, I'd love to bring such discussion to that thread, but unfortunately I haven't got enough reputation to post comments on questions different from mine
Answer: It depends on the base unit (which notes "per minute" are counted).
For example, 70 BPM in 2/2 time signature will sound in the same speed as 140 BPM in 4/4 (by "the same speed" I mean the same absolute duration of a note with given length, i.e. melodies written with the same note lengths will sound identically in the terms of speed), since 70 halves are equivalent to 140 quarters.
So, the answer depends on both notation and feeling (which duration is felt as a "beat").
Comment: Measuring dubstep as a 4/4 genre would be, IMO, inconsistent with the genre definition: dubstep is a halftime genre, with a kick every two bars. Kick pattern frequency is, from my experience, the most common way of judging the tempo of an electronic genre. I don't know whether this belief of mine is correct or not, and I would love to have some feedback about it.


Taking control of the MediaController progress slider

Question: I need to catch touch events to the MediaController progress slider, so that updates to the MediaPlayer don't occur until the finger lifts off the slider.
[ Perhaps my situation is unique: I am playing streaming video that comes in multiple "stacks" for each "program". The next stack is not loaded until the previous one is finished. The slider needs to represent the duration of all stacks, and the progress of the "thumb" needs to represent total duration. This is easily done by overriding the getBufferPercentage(), getCurrentPosition(), and getDuration() methods of MediaPlayerControl ]
More problematic is "scrubbing" (moving the thumb) back and forth along the timeline. If it causes the data source to be set multiple times along with a seekTo for every movement, things very quickly bog down and crash. It would be better if the MediaPlayer did no action until the user has finished the scrub.
As others have written, Yes it would be best to write my own implementation of the MediaController. But why redo all that work? I tried extending MediaController, but that got complicated quickly. I just wanted to catch the touch events to the slider!
Answer: One is able to get a handle to the elements of MediaController:
final int topContainerId1 = getResources().getIdentifier("mediacontroller_progress", "id", "android");
final SeekBar seekbar = (SeekBar) mController.findViewById(topContainerId1);

Then set a listener on the seekbar, which will require you to implement its three public methods:
seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
    @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        // Log.i("TAG", "#### onProgressChanged: " + progress);
        // update current position here
        }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
        // Log.i("TAG", "#### onStartTrackingTouch");
        // this tells the controller to stay visible while user scrubs
        mController.show(3600000);
        // if it is possible, pause the video
        if (playerState == MPState.Started || playerState == MPState.Paused) {
            mediaPlayer.pause();
            playerState = MPState.Paused;
        }
    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
        int seekValue = seekBar.getProgress();
        int newMinutes = Math.round((float)getTotalDuration() * (float)seekValue / (float)seekBar.getMax());
        // Log.i("TAG", "#### onStopTrackingTouch: " + newMinutes);
        mController.show(3000); // = sDefaultTimeout, hide in 3 seconds
    }
});

Caveats:
This is not updating the current position as you scrub, the left-hand-side TextView time value. (I had a truly remarkable way to do this which this margin is too small to contain).
Comment: Note that the instantiation of the SeekBar **must** occur in the `VideoView.onPrepared(..)` Callback method.
Comment: @coco seekbar is null even after instantiation as you suggested
Comment: Thanks for that!
Saved me a ton of time
Comment: what's playstate and mpstate? can you edit with full code please!
Comment: and i also get seekbar null as @NarendraJi
Comment: I'm sorry, @RuchaBhattJoshi - that's been lost in the mists of time


Properties of convex functions

Question: Suppose that $f: \mathbb{R} \rightarrow \mathbb{R}$ is a convex function. Then show that
$$
\operatorname{det}\left[\begin{array}{ccc}
1 & 1 & 1 \\
x & y & z \\
f(x) & f(y) & f(z)
\end{array}\right] \geq 0
$$
for all $x<y<z$.
Here I got the determinant as $(y-x)(f(z)-f(x))-(z-x)(f(y)-f(x))$
how to prove the +ve definiteness
Answer: Hint: you can write the determinant as $$(z - x)\left(t f(x) + (1-t) f(z) - f(y)\right)$$
where $y = t x + (1-t) z$.

Properties of convex functions


How to compute area under the curve (intersection may occur) with the original dataset?

Question: I have a bunch of datasets of x's and y's. For each dataset, I plot points (x, y) in R. And the resulting plots are generally similar to either type A or type B. Type B has an intersection while type A doesn't have.
My question: Given a new dataset, is it possible to calculate (in R) the red shaded area under the curve as indicated in type A and type B plot without knowing the visualization?
The main challenges are:
1)  How to determine whether the dataset will generate type A or type B in R?
2)  How to compute the red shaded area in type B using the dataset with R?
Here is the code producing the dataset that generated type B curve.
<code>set.seed(300)
predicted_value_A = c(rbeta(300, 9, 2), rbeta(700, 2, 4), rbeta(10000, 2, 4))
predicted_value_B = c(rbeta(1000, 4, 3), rbeta(10000, 2, 3))
real_value = c(rep(1, 1000), rep(0, 10000))

library(ROCR)
library(ggplot2)

predB <- prediction(predicted_value_B, real_value)
perfB <- performance(predB, measure = "mat", x.measure = "f")

yB <- attr(perfB, "y.values")[[1]]

yB <- (yB + 1)/2

xB <- attr(perfB, "x.values")[[1]]

# dataset that generates type B curve
dfB <- data.frame(X = xB, Y= yB)

ggplot(df, aes(x=X, y=Y, ymin=0, ymax=1, xmin=0, xmax=1 )) + geom_point(size =     0.2, shape = 21, fill="white")+
ggtitle("Type B curve") +
theme(plot.title=element_text(hjust=0.5))
</code>
Comment: Not sure how this is an R question. I don't see any sample data or R coding attempts.
Comment: I added the R code that generates type B curve!
Answer: Here is a bit of code to shade the plot from a set of (x,y) points using an approximation with small rectangles. This assumes evenly spaced x values, and enough that the rectangular approximation works well.
<code># sample dataset
x <- seq(0,2,length.out=1000)
y1 <- x
y2 <- sin(x*pi)+x

# plot
plot(x,y1,type='l',ylab='y')
lines(x,y2)

# shade the plot
## not efficient but works
dx <- x[2]-x[1]
area <- 0

# shade plot and calculate area
## uses a rectangular strip approximation
## assumes even spacing in x. Could also calculate the dx in each step if it changes
for (i in 1:(length(x))) {

  if (y1[i] < y2[i]) {
    cord.x <- c(x[i]-dx/2,x[i]-dx/2,x[i]+dx/2,x[i]+dx/2)
    cord.y <- c(y1[i],y2[i],y2[i],y1[i])
  } else {
    cord.x <- c(x[i]-dx/2,x[i]-dx/2,x[i]+dx/2,x[i]+dx/2)
    cord.y <- c(y2[i],y1[i],y1[i],y2[i])
  }

  # draw the polygons
  polygon(cord.x, cord.y, col = 'pink', border = NA)

  # sum to the area
  area <- area + abs(y2[i]-y1[i])*dx
}
area
</code>
sample shaded plot by rectangular approximation
Comment: Hi Rob, thank you! The dataset I work with is messier than the data in the above code. The x's and y's are not ordered, and it is making the computation difficult. For example, how can I determine whether (x,y) is the higher part or the lower part of the curve? btw I added the dataset of x's and y's in the question part.
Comment: I've been trying to think of a clean solution to this and haven't been able to come up with one. You can specify particular regions where the one line is clearly the upper and the other the lower for a range of x values, but that would involve basically running the above script in a piecewise manner. You could also do it analytically, except that the data looks pretty noisy, which wouldn't make that feasible.


SVD to transform regularization problem

Question: Can anyone explain this transformation to me :
$$
||Ax-b||_2^2 + \delta ||x||_2^2 : A \in R^{m,n}, b \in R^m \rightarrow \\
\tilde{x} = (V^Tx, V_2^Tx), \tilde{b} = (U^Tb, U_2^Tb)\\
V_2 \in R^{n x (n-r)}, \, V_2^TV_2 = I, \, V_2^TV = 0\\
U_2 \in R^{m x (m-r)}, \, U_2^TU_2 = I, \, U_2^TU = 0\\
\rightarrow ||Ax-b||_2^2 + \delta ||x||_2^2 =
\sum_{i=1}^r(\sigma_i \tilde{x}_i - \tilde{b}_i)^2 +
\sum_{i=r+1}^m \tilde{b}_i^2, \, ||x||_2^2 = \sum_1^n\tilde{x}^2
$$
I get that a singular value decomposition is used :
$$A = U \text{diag} (\sigma) V^T = \sum_{i=1}^r \sigma_i u_i v_i$$
But I have no idea about the rest of the transform. I'd like to know the intuition behind it, if someone can point to a reference or explain, thank you.
Answer: Notice that for an  orthogonal matrix, we have $\|Ux\|^2=\|x\|^2$, since rotation and reflection doesn't change the length.
\begin{align}
\|Ax-b\|^2 + \delta \|x\|^2 &= \|U \Sigma V^Tx-b\|^2 + \delta \|x\|^2 \\
&=  \|U (\Sigma V^Tx-U^Tb)\|^2 + \delta \|V^Tx\|^2 \\
&= \|(\Sigma (V^Tx)-U^Tb)\|^2 + \delta \|(V^Tx)\|^2 \\
&= \|(\Sigma \tilde{x}-\tilde{b})\|^2 + \delta \|\tilde{x}\|^2 \\
&=\sum_{i=1}^r (\sigma_i\tilde{x}_i-\tilde{b}_i)^2+\sum_{i=r+1}^m \tilde{b}_i^2
 + \delta \|\tilde{x}\|^2\end{align}
Comment: my $V$ is actually your $[V, V_2]$ and my $U$ is your $[U, U_2]$. The second summation is due to only the first largest $r$ singular values are positive, the rest of them are zero, rather than $\tilde{b}_i^2$, they are actually $(0 \cdot \tilde{x}_i-\tilde{b}_i)^2$.
Comment: Hi thanks so much, but where does $V_2$ and $U_2$ come in?? Also, where does the second summation from $r+1 \rightarrow m$ come from?
Comment: Thanks, why would they break up $V$ into $[V, V_2]$ like that? Is there some utility in that? Also, you mean just in general case if those singular values from $r+1 \rightarrow m$ exist, then you organized them in their own term?
Comment: From the objective, only the first $r$ components of $\tilde{x}$ can take non-zero values.  In terms of solving and recovering the initial solution, only the first $r$ non-singular vectors are needed. Hence we can just compute an economical SVD rather than a full SVD.
Comment: Where did you study this? Some kind of advanced linear algebra course? You're like math king
Comment: $n$ years ago, where $n$ is huge, I took a class that is based on Gene Golub's matrix computation. I am not strong in maths, still learning everyday.

SVD to transform regularization problem


Can't redirect inside canvas, CodeIgniter

Question: I am using canvas for application development and the CodeIgniter  framework.
I have a link in a view, click here and I have a controller as:
public function index() {
    $user_profile = $this->facebook->api('/sujeet216');
    $token        = $this->session->userdata('token');

    $response     = $this->fb_model->checkUser($token);
    if ($response->num_rows <= 0) {
        if($this->fb_model->insertUser($user_profile,$token)) {
            $this->load->view('intro',$user_profile);
        }
    }
    else {
        $this->load->view('index',$user_profile);
    }
}

public function intro2() {
    $this->load->view('intro2');
}

Whenever I click a link, it redirects to the index controller. How do I load intro2 page from the second function?
Answer: If you're not routing the URL, index.php/module/controller/action goes to index.php/controller/method/parameter. Try redirecting to index.php/controller/intro2.
Answer: It's possible that the app is trying to authenticate and Facebook redirects the app back to the callback URL that you have set. You have two options to combat this:

Use a library, for example the PHP-SDK and ensure you autoload it, this will ensure that the access_token isn't lost.
Ensure that the API is being called and the access_token is being passed from each controller.

I'd recommend going for option number 1 as it gives you much more flexability in relation to using the API once the user has authenticated against Facebook.