practice of omitting notes in jazz piano

Question: I'm trying to find a name for the practice of omitting notes in jazz piano.
There was an American jazz pianist (black I think) who was famous for it.  His show piece was to start playing "Mac The Knife" and omit notes till the tune just disappeared. Then he would add notes back in but now the tune became "The Dead March".  Extremely clever.
I had this on and album now lost and I also want to find the name of the musician.  I think it was Thelonius Monk but I cannot find this particular piece on the web so I may be wrong.
Comment: I haven't heard this, but it certainly sounds like something Monk could/would do.
Comment: I read the question such as that it is notes of the _melody_ that gets omitted, rather than notes of the chords. I imagine such as playing the full melody the first chorus, and during the next chorus omitting for instance all C notes of the melody, or perhaps all notes on the first beat of each measure, and then omitting more and more melody notes for the consecutive choruses. Is this what you are asking about? (I.e. more of a music performance gimmic technique question rather than a music theory question.)
Answer: Based on your description, "omit notes till the tune just disappeared", I assume that the player is either omitting notes from the melody or from everything, until he is playing nothing or almost nothing.  Because this isn't done incredibly frequently it may not have a proper name, merely a description of what is happening.  The closest thing I could think of was called "note suppression" which is well described in this paper(I can't find a free version): http://journals.cambridge.org/action/displayAbstract;jsessionid=087865DECE297BD3A0D33A018D2EF0AB.journals?fromPage=online&aid=253947
This concept describes avoiding one note from the scale (in a regular tonal piece) throughout the majority of a song, then presenting it later in the piece and it feels special because it is the one thing you haven't had.  The example in the article uses The Beatles "Fixing a Hole".  In the bridge they "fill the whole" with the suppressed note and emphasize it with repetition.
So, to answer your question, if it doesn't have a name and needs a description, I could imagine calling it "Gradual Suppression" but that would only describe the first half.  The second half could be "Gradual Introduction" or "Gradual Exposition" if it happened on its own, or "Transition Through Gradual Suppression/Introduction" for the whole thing.
That is not a quick way to refer to something so the technique would likely end up taking a shorter name, maybe named after the performer if others don't do it much.
Answer: I believe it has a few names, I call it a Suggestive chord.
Practical/Technical Justification
The practice is especially prominent in guitar playing, because the wide spacing and only having 6 strings limits the number of tones that can be played at the same time.
suppose you want to play a C13, this consists scale wise of 1 3 5 b7 9 11 and 13. with 6 strings and 4 fingers on your left hand, playing the chord with all notes at once is impossible.
On piano this limitation is less so, which brings me to...
Sonic Justification
From a sonic point of view though, playing 7 tones creates an extremely dense sound.  as far as intervals go you have 5040 different combinations happening! (7x6x5x4x3x2).
Depending on the mood of the piece or what you're going for often a simpler chord which includes the 13 is more (subjectively)appropriate. For example if an add 13 chord is used instead, you only have 4 notes happening at once which is a less dense 24 intervals at once.  Then of course you have all the choices of which notes to include, the voicing and all that other fun stuff reserved for somewhere else.
For guitarists reading this who want to learn more, you could do worse than Ted Greene's  Chord Chemistry
I'm sure a piano player could reccommend a similar book that can be mentioned here, and purchased by me ;)
Related Questions
Does a chord need to include its root?
Answer: Sounds like you're describing an additive/subtractive process which is a technique used a lot in minimalist music and, I believe, has its origins in indian classical music. This page (search for "additive") distinguishes between two kinds of additive process:

Linear: one keeps adding notes and the musical unit becomes longer and longer. If your pianist used this technique, he'd first play all of "Mac The Knife", then play it again, maybe leaving out a few notes from the end thus making it shorter, then with the next repeat leave out more notes, etc. When there's nothing more to play he'd play perhaps the first few notes of "The Dead March", then play a longer segment, etc. until finally he plays the whole piece.
Block: the musical unit has a fixed length and the added notes just replace rests. If the pianist used this technique he'd play "Mac The Knife" many times but every time replacing more and more notes with corresponding rests. Finally it would be all silence and he'd start to replace some of the silence with notes from "The Dead March" and keep repeating it until he plays all of them.

EDIT: Actually the page also mentions textural additive process where one adds voices until all of them are present. This doesn't seem to apply in your case, though, since it would mean something like first playing the piece in full, then dropping the bass line, then dropping chords (perhaps partially), then dropping the melody etc.


What's the proper design of a data reading/storing application?

Question: I need to read 200,000 or so records from a website and store them in DB. The application is a desktop app implemented on top of Netbeans Rich Client Platform. By using Apache HttpComponent library, I can send request to the website and retrieve the response that contains the record information; then using regex, I can fairly easily extract the dozen of fields that I need from the HTML.
I am thinking to have 2 worker threads besides the GUI thread. One worker thread handles the HTTP request/response part and also extracts the record from the HTML using regex; while the other worker thread stores the records into DB. So, there will be a data structure to hold the records so that it can be shared between the two worker threads. I am also considering to have a buffer of size 100 (for example) for the HTTP worker thread to store the records, and when the buffer is full, transfer 100 records at one time to the shared records holder.
Please comment on my design and also my questions are:

what is the proper data structure to hold the records?
how to synchronized it between the two worker threads?
how would the multi-threads be implemented in the modular system of Netbeans Platform?
Comment: @Brian: NetBeans IDE != NetBeans Platform http://netbeans.org/features/platform/
Comment: what does the NetBeans IDE have to do with this?
Comment: @Esko thank you for the clarification. I'd only ever heard the term used in reference to the IDE and had never heard of the platform.
Comment: Is this a one-time application? If so, you could probably write it simple (and inefficently) in a single thread and run it faster than design one that's going to be faster.
Answer:
what is the proper data structure to hold the records?

Depends on the data. Probably a simple class with a bunch of fields (preferably immutable to make using multiple threads safer).

how to synchronized it between the two worker threads?

One of the BlockingQueue implementations might be good for that. ArrayBlockingQueue can be used as a fixed-size buffer for passing work between the threads.

how would the multi-threads be implemented in the modular system of Netbeans Platform?

No idea whether NetBeans Platform has anything to say about that. Launching your own threads should work.
Comment: Thanks a lot. BlockingQueue is the right one. I should probably ask if Swing has anything to say here, if I want the progress to be shown on the UI. How about using a SwingWorker?
Comment: With Swing you need to take care that UI updates are processed in the event dispatch thread (see class javax.swing.SwingUtilities). Swing also has a progress bar component which may be useful.
Answer: First of all, this kind of HTML parsing would slow down your app quite badly. Also, the code would be quite fragile since HTML changes quite often for aesthetic enhancements. You should resort to 'HTML scraping' as the last resort. Most customers agree to opening up a web-service/data-service for this once you explain the disadvantages.
If you really have no other alternatives, then I think your approach is good. But instead of waiting for the buffer to be full, you could have a set of threads writing into the buffer and a set of threads reading from the buffer simultaneously. I would suggest using more number of HTTP scraper threads and less number of DB-write threads since the HTTP request-response cycle and HTML parsing would be order of times slower than a database write.
Comment: I really have no other choices then HTML scraping. Fortunately, I am pretty sure that the HTML format won't change.
Comment: Regarding the number of threads, your suggestion makes sense. However, if I have multiple HTTP scraper threads, it's hard, if not impossible, to divide work between them and let them know when to stop: the records have IDs starting from 1, and keep increasing, problem is that some numbers in between are skipped. Currently, I compare the total # of existing records to the # of records being processed. But if I have multiple scraper threads, how would I know how many are processed in total?


iterator nao esta funcionando

Question: Alguém pode me ajudar a consertar esse problema por favor!
no console do java aparece isso:
Exception in thread "main" java.lang.NullPointerException
    at Main.Main.allAmigos(Main.java:116)
    at Main.Main.main(Main.java:66)

tenha 3 classes (a classe Amigo e a classe ListaAmigo juntos, a classe Main fica separado).
Na ListaAmigo inseri essas informações:
package Amigo;
import java.util.ArrayList;
import java.util.Iterator;

public class ListaAmigo {

    private static ArrayList<Amigo> alAmigos = new ArrayList<Amigo>();

    // construtor cria alAmigos, ArrayList que fica encapsulado na classe ListaAmigos
    public ListaAmigo() {
        super();
        this.alAmigos = alAmigos;
    }
}

Na Main queria criar um while com o iterator para mostrar todos os "amigos" que inseri:
public class Main {
    private static ListaAmigo amigos = new ListaAmigo();

    public static void main(String[] args) {
    Amigo idAmigo;
    allAmigos();
    }

    private static void allAmigos() {
        Iterator<Amigo> it = alAmigos.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }

    }

Como o mouse no erro do alAmigos aparece isso daqui:
Answer: Esta mensagem é porque não está encontrando a variável, experimenta colocar assim:
Iterator<Amigo> it = ListaAmigo.alAmigos.iterator();

após isso a mensagem possivelmente deve mudar, porém ele vai informar que não está visível ou coisa assim, isso será porque alAmigo está como private na classe ListaAmigo, então mude para public.
na classe ListaAmigo você pode criar um get e set para alAmigo desse jeito ele pode continuar private
depois na classe main voce pode fazer assim:
Iterator<Amigo> it = amigos.getAlAmigos().iterator();
Comment: obrigada funcionou :)))

iterator nao esta funcionando


Application vs Database Resident Connection Pool

Question: Situation:
I have a requirement to use connection pooling while connecting to Oracle database in python. Multiple python applications would use the helper connection libraries I develop.
My Thought Process:
Here I can think of two ways of connection pooling:
1) Let connection pool be maintained and managed by database itself (as provided by Oracle's DRCP) and calling modules just ask connections from the connection broker described by Oracle DRCP.
2) Have a server process that manages the connection pool and all caller modules ask for connections from this pool (like dbcp?)
What suggestions do I need:
option 1) looks very straight forward since pool does not need to be stored by application.
But I wanted to know what advantages do I get other than simplicity using option 1)?
I am trying to avoid option 2) since it would require a dedicated server process always running (considering shelving is not possible for connection objects).
Is there any other way?
Answer: Let the database handle the pool. . . it's smarter than you'll be, and you'll leverage every bug fix/performance improvement Oracle's installed base comes up with.


Solve equation for a given set of parameters

Question: I'm modelling a process for which the probability of the event (stop) not happening before time $t$ is $e^{-\lambda\cdot t }|\lambda>0$. When the event happens, the process stops running for a constant time $\kappa > 0$. After this time has passed, the process restarts.
For a time horizon, $\tau > 0$, using $N = \left\lceil\frac{\tau}{\kappa}\right\rceil-1$ and $\delta_i = \tau - i\cdot \kappa$ the expected active time is:
$$\sum_{i = 0}^N \int_0^{\delta_i} e^{-\lambda\cdot t}\cdot(1- e^{-\lambda\cdot t})^i dt = \frac{1}{\lambda} \sum_{i=0}^N\frac{(1- e^{-\lambda\cdot \delta_i})^{(i+1)}}{i + 1} = Res $$
Is there a closed form to recover $\tau$ given $\kappa, \lambda, Res $?
If not, what is the recommended approach?
Comment: You write *"for a time horizon, $\tau > 0$"*, and what that means is not clear. The reader would be able to figure it out reading the formula, but because you include complicated and not intuitively explained parameters $N$ and $\delta_i$ (and $\tau$ is not directly visible in the formula) it is difficult to imagine what you are doing and what 'time horizon' means. (I am not saying it is impossible and I have an idea, but I feel that you could describe the problem a bit more simple)
Comment: Probably, it was complex to explain. $\tau$ represents a time horizon (end of day). The $\delta$ is used to make the formula easier to read.
Comment: Possibly you can simplify the equations by assuming $\tau = 1$. The time scale is arbitrary anyway.
Comment: Your computation of $Res$ seems to be computing how often you have the stops, but does it also take into account the possibility that the stop is occurring at the boundary of the horizon and not fully inside the time period?
Comment: @SextusEmpiricus sorry for the late response, I was on vacation, and I didn't check my question. The calculation of $Res$ considers the boundary $\tau - i \cdot\kappa>0$. My doubt would be how to get $\tau$ from a given $Res$. I think the solution has to be reach using numeric methods due to the step function, but I was wondering if a closed solution exists.
Comment: I already have doubts about whether your formula for $Res$ is actually computing what you want.
Answer: I already have doubts about whether your formula for $Res$ is actually computing what you want. Consider $\tau < \kappa < 2  \tau$, then $N = 1$ and according to your computation $$Res = \frac{1}{\lambda} \left( 1-e^{-\lambda \cdot \tau}\right) +  \frac{1}{2\lambda} \left( 1-e^{-\lambda \cdot (\tau-\kappa)}\right)^{1/2}$$
When I compute this alternatively by simulation, then I get a difference, 0.948 for the simulation versus 0.974 for the formula.

<code>set.seed(1)
tau = 1.5
kappa = 1
lambda = 1

### computation
expectation = (1-exp(-lambda*tau))/lambda + (1-exp(-lambda*(tau-kappa)))/lambda/2

### simulation
sim = function() {
   t = rexp(2,lambda)
   time = tau
   if (t[1] < tau) {
       time = t[1]
       if (t[1] < tau-kappa) {
         if (t[1]+t[2] < tau) {
           time = t[1] + t[2]
         } else {
           time = tau - kappa
         }
       }
   }
   time
}

### compute simulations and plot histogram
t = replicate(10^6,sim())
hist(t, freq = 0,breaks = seq(0,tau,0.01))

### compare estimates
mean(t)       # 0.9476016
expectation   # 0.9736045
</code>
Comment: Sorry it took me a while to debug your code. There is a bug on your nested if  `if(t[1]+t[2] < tau)` should be `tau-kappa` and the expectation should be `expectation = (1 - exp(-lambda * tau)) / lambda +
  ((1 - exp(-lambda * (tau - kappa))) ^ 2) / lambda / 2`


Missing data analysis software

Question: Does any standard statistical software like R, SAS or SPSS have procedures or codes to analyze log-linear models for missing data in contingency tables using maximum likelihood estimation (or EM algorithm or other iterative procedures), not multiple imputation techniques ?
Answer: Yes, the cat package in R has the em.cat function which uses the EM algorithm to find the MLE of a saturated log-linear model for a contingency table with missing values.

Missing data analysis software


What is the relationship between the function $\mathbb{E}(Y \mid X = x)$ and linear regression?

Question: Consider the  function

$$
r(x) = \mathbb{E}(Y \mid X = x)
$$

This has been called the regression function in a textbook I'm using. I'm trying to figure out the relationship between this function and the classical linear regression model.
So, I know that it is a theorem* that we may write
$$
Y = r(X) + \epsilon
$$
for some random variable $\epsilon$ s.t. $\mathbb{E}(\epsilon) = 0$.
Now suppose that we have

$$
Y = \beta_0 + \beta_1 X + \epsilon
$$

This is the classical 1-dimensional regression function (assuming the $\beta_0$ and $\beta_1$ minimize the residual sum of squares).
Question: Is it then a mathematical theorem that if $Y$ is defined as above, that
$$
r(X) = \mathbb{E}(Y \mid X) = (\beta_0 + \beta_1 X)?
$$
And is this why the function $\mathbb{E}(Y \mid X)$ is called the "regression function"?
EDIT: The theorem that I am making use of is as follows (from All of Statistics pg. 89):

Regression models are sometimes written as
$$
Y = r(X) + \epsilon
$$
where $\mathbb{E}(\epsilon) = 0$. We can always rewrite a regression model this way. To see this, define $\epsilon = Y - r(X)$ and hence $Y = Y + r(X) - r(X) = r(X) + \epsilon$. Moreover, $\mathbb{E}(\epsilon) = \mathbb{E}\mathbb{E}(\epsilon \mid X) = \mathbb{E}(\mathbb{E}(Y - r(X)) \mid X) = \mathbb{E}(\mathbb{E} ( Y \mid X) - r(X)) = \mathbb{E}(r(X) - r(X)) = 0$.
Comment: The connection is that a linear regression model is exactly the claim that $r$ is a linear function of some observed Xs. Naturally, this claim need not be true, although as an approximation to $r$ it can be better or worse. The chapter of 'Mostly Harmless Econometrics' called 'Making regression make sense' is a good discussion.
Comment: Or have I missed what you were asking?
Comment: Check the related answer: http://stats.stackexchange.com/questions/173660/definition-and-delimitation-of-regression-model/211229#211229
Answer: Summarizing the question:

Given $Y = \beta_0 + \beta_1 X + \varepsilon$,
  is it then a mathematical theorem that $r(X) = \mathbb{E}(Y \mid X) = (\beta_0 + \beta_1 X)$?

Yes, by basic properties of expectation:
$$
\begin{align}
\operatorname{E}(Y\mid X) & = \operatorname{E}(\beta_0 + \beta_1 X + \varepsilon) \\[6pt]
& = \operatorname{E}(\beta_0) + \operatorname{E}(\beta_1 X) + \operatorname{E}(\varepsilon) & & \text{(linearity of expectation)} \\[6pt]
& = \beta_0 + \beta_1 X + 0 & & \text{(Noting that $X$ is constant here} \\[-2pt]
& & & \quad \text{because we conditioned on it.)} \\[6pt]
& = \beta_0 + \beta_1 X
\end{align}
$$
The historical reasons for regression being called regression relate to Galton noticing the "regression to the mean" effect -- initially in an experiment in plants involving seed-size of offspring compared to the seed size of parents. A relationship through the mean seed size on both variables will have slope less than $1$ (which slope can be estimated by what we call linear regression). The smaller the slope the stronger the "regression" effect. The issue is illustrated by Galton in the linked pdf by heights of children (as adults) compared to average heights of parents (females being scaled up by a constant factor of $8\%$ to make them comparable to males). The diagrams on the third to fifth pages indicate something of what was observed.
So an attempt to estimate the size of this "regression to the mean" is obtained by what came to be called linear regression. Of course there's nothing special going on - the regression to the mean isn't some special biological "drive to mediocrity" as might originally have been guessed, but a fairly simple consequence of the mathematics of the situation in essentially the same sense that correlations are always between $-1$ and $1$.
Comment: I've replaced your crude use of \qquad with proper use of "align" in MathJax, plus a few other MathJax details, and I await peer review of the edit. $\qquad$
Comment: @Michael I'm aware of align and have used it many times -- but what is the actual benefit in the edit in this case? I wanted it left aligned rather than in the center to leave room for the comments to be on a single line and I wanted the comments not to be in the heavy text that MahJax leaves you with, preferring the light text of ordinary markup. The present result is something that no longer matches the appearance I was actually seeking. Rather than being "crude" it was deliberately chosen. If you have a way that achieves what I wanted with *less* effort than mine required, I'm all ears.
Comment: ok, I guess not all tastes are in accord with each other$\,\ldots\qquad$
Comment: The as-designed appearance is ideal, I think, for articles and books but doesn't always reflect what I think is best in a forum like this, at least not always. I recognize my tastes on this issue (and numerous other aspects of site appearance I often try to work around) may be different from the norm, so I'll leave it as it stands, but I don't promise to try to continue to try to get align to do what I want when it seems easier to do it other ways.
Comment: Does the theorem go the other direction, too? That is, given $X$ and $Y$, can we always conclude that $\mathbb{E}(Y \mid X) = (\beta_0 + \beta_1 X) + \epsilon$ for the $\beta_0, \beta_1$ the regression coefficients? If not, what are the conditions for when we can and cannot say this?
Comment: That's a whole new question now ... but why would knowing $X$ and $Y$ imply that the conditional expectation was linear?


Exposing C++ functions, that return pointer using Boost.Python

Question: I want to expose the following C++ function to Python using Boost.Python:
int* test1() {
    return new int(42);
}

// Now exposing the function with Boost.Python

BOOST_PYTHON_MODULE(libtest1)
{
    using namespace boost::python;
    def("test1", test1);
}

When I try to compile this library the error occurs due to (it's my guess) Boost.Python don't know, how to convert int* to PyObject.
I think what needs to be done is to define conversion structure, something like this:
template<class T>
struct int_ptr_to_python
{
   static PyObject* convert(int* i_ptr)
   {
        return i_ptr;
   }
};

And pass it to the BOOST_PYTHON_MODULE declaration:
BOOST_PYTHON_MODULE(libtest1)
{
    using namespace boost::python;
    def("test1", test1);
    to_python_converter<int*, int_ptr_to_python<int*> >();
}

But it also doesn't work. And I can't find any information about how the functions, that return pointers should be handled.
Does anyone can help?
Answer: In short, one cannot directly expose a function returning int* with Boost.Python, as there is no  meaningful corresponding type in Python given integers are immutable.

If the goal is to return a number to Python, then return int by value.  This may require using an auxiliary function to adapt legacy APIs.
If the goal is to return a pointer to an object allocated with a new-expression, then the object must be a class or union, and the function must be exposed with specific policies to indicate ownership responsabilities.

Rather than present the final solution immediately, I would like to take the time to step through the compiler errors.  With Boost.Python, sometimes pre-C++11 static assertions are used to provide instructions in the compiler messages.  Unfortunately, it can be a bit difficult to find them amongst the heavy templates.
The following code:
#include <boost/python.hpp>

int* make_int() { return new int(42); }

BOOST_PYTHON_MODULE(example)
{
  namespace python = boost::python;
  python::def("make_int", &make_int);
}

produces the following relevant output in clang, with the important details accentuated in bold:

.../boost/python/detail/caller.hpp:102:98: error:
  no member named 'get_pytype' in 'boost::python::detail::
    specify_a_return_value_policy_to_wrap_functions_returning<int*>'
  ...create_result_converter((PyObject*)0, (ResultConverter *)0,
                             (ResultConverter *)0).g...

Boost.Python is informing us that a boost::python::return_value_policy needs to be specified for functions returning int*.  There are various models of ResultConverterGenerators.  Often times the policies are used to control the ownership or lifetime semantics of the returned object.  As the function in the original code is returning a new pointer directly to Python, the boost::python::manage_new_object is appropriate if the caller is expected to take responsibility for deleting the object.
Specifying a policy for object management still fails:
#include <boost/python.hpp>

int* make_int() { return new int(42); }

BOOST_PYTHON_MODULE(example)
{
  namespace python = boost::python;
  python::def("make_int", &make_int,
    python::return_value_policy<python::manage_new_object>());
}

produces the following relevant output:

.../boost/python/object/make_instance.hpp:27:9:
  error: no matching function for call to 'assertion_failed'
    BOOST_MPL_ASSERT((mpl::or_<is_class<T>, is_union<T> >));

In this case, Boost.Python is informing us that the object returned from a function with a managed_new_object ResultConverterGenerator must be either a class or union.  For an int*, the most appropriate solution is to return the int by value when passing through the Boost.Python layer.  However, for completeness, below demonstrates:

Using an auxiliary function to adapt a legacy API.
How to limit the creation of a user defined type with a factory function that returns pointers.

#include <boost/python.hpp>

/// Legacy API.
int* make_int() { return new int(42); }

/// Auxiliary function that adapts the legacy API to Python.
int py_make_int()
{
  std::auto_ptr<int> ptr(make_int());
  return *ptr;
}

/// Auxiliary class that adapts the legacy API to Python.
class holder
  : private boost::noncopyable
{
public:
  holder()
    : value_(make_int())
  {}

  int get_value() const     { return *value_; }
  void set_value(int value) { *value_ = value; }

private:
  std::auto_ptr<int> value_;
};

/// Factory function for the holder class.
holder* make_holder()
{
  return new holder();
}

BOOST_PYTHON_MODULE(example)
{
  namespace python = boost::python;
  python::def("make_int", &py_make_int);

  python::class_<holder, boost::noncopyable>("Holder", python::no_init)
    .add_property("value",
      python::make_function(&holder::get_value),
      python::make_function(&holder::set_value))
    ;

  python::def("make_holder", &make_holder,
    python::return_value_policy<python::manage_new_object>());
}

Interactive usage:
>>> import example
>>> assert(42 == example.make_int())
>>> holder = example.Holder()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: This class cannot be instantiated from Python
>>> holder = example.make_holder()
>>> assert(42 == holder.value)
>>> holder.value *= 2
>>> assert(84 == holder.value)

Comment: your the only guy on the entire stack overflow that makes sense of this obfuscated system


Infer relationships between coefficients given covariance information

Question: Quant Interview Question:
Given $y$ = $a_1$$x_1$, $y$ = $b_1$$x_1$+$b_2$$x_2$, $cov(x_1,y)$ != 0, $cov(x_1,x_2)$ > 0, $cov(x_2,y)$ = 0. Compare $abs(a_1)$ and $abs(b_1)$. Which one is larger and why?
My intuition tells me that this has something to do with linear regression since covariance is given. The OLS coefficient estimates consist of the covariance, but after writing them out, I'm not sure how to proceed. Specifically, I'm not sure how to move towards the absolute of the coefficients and how to move from the estimates to the true values.
Any help would be greatly appreciated!
Comment: Although this might look like OLS, it isn't really, because the $a_i$ and $b_i$ are not estimates.  Compute the variance of $y$ in two ways and use the crucial inequality $\operatorname{Cov}(x_1,x_2)\gt 0.$
Comment: @whuber I get $a_1=b_1$ without using $\operatorname{Cov}(x_1,x_2)\gt 0$ at all. Am I missing something?
Comment: I got $(a^2-b^2)$$(Var(x_1))$ = ${b_2}^2$$Var(x_2)$ + $2b_1b_2Cov(x_1,x_2)$. Now, if we know that $b_1$ and $b_2$ have the same sign, we know abs(a) > abs(b_1) but idk how to proceed. I listed out all the variance I can get from rearranging the variables.
Comment: @statmerkur I realized there's a flaw in the conditions. Not sure if this is intended. See my comment under your answer.
Answer: Using the bilinearity of the covariance, the definition of the variance of a random variable, and $\mathrm{Cov}\left(x_2, y\right)=0$, we get
$$
\begin{align}
0 \leq \mathbb V\left(y\right)
&= \mathrm{Cov}\left(y, y\right) \\
&= \mathrm{Cov}\left(b_1 x_1 + b_2 x_2, y\right) \\
&= \mathrm{Cov}\left(b_1 x_1, y\right) + \mathrm{Cov}\left(b_2 x_2, y\right) \\
&= b_1\mathrm{Cov}\left(x_1, y\right) + b_2\mathrm{Cov}\left(x_2, y\right) \\
&= b_1\mathrm{Cov}\left(x_1, a_1 x_1\right) + 0 \\
&= a_1b_1\mathbb V\left(x_1\right).
\end{align}
$$
From $\mathrm{Cov}\left(x_1, y\right) \neq 0$ we now see that $a_1 \neq 0,\mathbb V\left(x_1\right) \neq 0,$ and either $\mathrm{sgn}\left(a_1\right) = \mathrm{sgn}\left(b_1\right)$ or $b_1=0$.
We also have
$$
\mathbb V\left(y\right) = \mathbb V\left(a_1 x_1 \right) = a_1^2\mathbb V\left(x_1 \right)
$$
and thus
$$
a_1b_1\mathbb V\left(x_1\right)= a_1^2\mathbb V\left(x_1 \right) \iff a_1 b_1 = a_1^2 \iff b_1 = a_1.
$$
Comment: @wakuwaku I agree, trying to satisfy all three (instead of just two) covariance conditions simultaneously seems
to yield such contradictions.
Comment: If you apply $Cov(x_2, y)$ = $Cov(x_2, a_1x_1)$ = $a_1Cov(x_2, x_1)$ = 0. However,  $Cov(x_1, x_2)$  > 0. Doesn't this mean that $a_1$ = 0 and therefore contradicts your conclusion that $a_1$ != 0? @whuber


Picture URLs for gallery sources Android

Question: Hi im fairly new to this im trying to use image urls as sources for my
gallery pictures but im having difficulty finding how this works, this
is the code so far.
 public class ImageAdapter extends BaseAdapter {
       private static final int ITEM_WIDTH = 232;
       private static final int ITEM_HEIGHT = 150;

       private final int mGalleryItemBackground;
       private final Context mContext;

       private final Integer[] mImageIds = {
               R.drawable.pic1,
               R.drawable.pic2,
               R.drawable.pic3,

       };

where would i put the urls ?
Answer: If the URL's are from the web, there is some work to be done. Fortunately, there are many Libraries offering ImageView implementations that handle these scenarios.
Check out LoopJ's SmartImageView
Also look into GreenDroid for a more robust UI-builder implementation.


Sum of two subspaces is a subspace

Question: I am wondering if someone can check my proof that the sum of two subspaces is a subspace:
1) First show that $0 \in W_1 + W_2$:
Since $W_1, W_2$ are subspaces, we know that $0 \in W_1, W_2$.
So if $w_1, w_2 = 0, w_1 + w_2 = 0 + 0 = 0 \in W_1 + W_2$.
2) Show that $cu+v \in W_1 + W_2$.
Let $W = W_1 + W_2$
Let $cu \in W$. We can find some $u_1 \in W_1, u_2 \in W_2, c \in \mathbb{F}$ such that $cu = u_1 + u_2$.
Similarly, since $v \in W$, we can find $v_1, v_2 \in W_1, W_2$ such that $v = v_1 + v_2$.
So $cu+v = c(u_1 + u_2) + (v_1 + v_2)$
$= cu_1 + cu_2 + v_1 + v_2$
$= cu_1 + v_1 + cu_2 + v_2$
And so $cu_1 + v_1 \in W_1$ and $cu_2 + v_2 \in W_2$, and therefore $cu+v \in W_1 + W_2$.
Is my proof correct? Please let me know!
Answer: Your proof is not rigorously correct.
The first part 1) is perfect.
For the part 2), there are some points that can be improved.

Your started with "let $cu\in W$". You need to start with "let $u\in W$." Why can you conclude that $cu\in W$, for any $c\in\mathbb{F}$?
Your conclusion $cu+v=cu_1+v_1+cu_2+v_2$ is correct. But why $cu_1+v_1\in W_1$ and $cu_2+v_2\in W_2$?

You should focus in these details in order to obtain a logically correct proof.

Minor detail: the notation $v_1,v_2\in W_1,W_2$, despite well understable, is not standard. It is better to write $w_1\in W_1$ and $w_2\in W_2$.
Comment: Ahh okay. So for your first point, I should just add that because $W$ is a subspace, it is closed under scalar multiplication, so we can conclude that $cu \in W$ if $u \in W$. For your second point, I should add that since subspaces are closed under scalar multiplication and addition, if I have two elements $cu_1, v_1 \in W_1$, then $cu_1 + v_1 \in W_1$. And that is sufficient? Thank you!
Comment: @agra94 Yes, perfect!
Comment: Thanks for your help :)
Comment: @agra94 you are welcome! =)
Answer: Yes it is correct, indeed you have verified that all the properties hold even if usually they are stated as
$1) \ \vec{0} \in W= W_1 + W_2\\
2) \ \vec{v}+\vec{w} \in W= W_1 + W_2\\
3) \ \vec{cv}\to c \cdot \vec{v}\in W= W_1 + W_2 \ ,c \in \mathbb{R}$
Thus you could improve and make more clear in my opinion as follow
2) $\ \vec{v}+\vec{w} \in W= W_1 + W_2\\$

$\vec v=v_1+v_2$ for some $v_1\in W_1$ and $v_2 \in W_2$
$\vec w=w_1+w_2$ for some $w_1\in W_1$ and $w_2 \in W_2$

then

$v+w=(v_1+w_1)+(v_2+w_2)$

3) $\ \vec{cv}\to c \cdot \vec{v}\in W= W_1 + W_2 \ ,c \in \mathbb{R}$

$c\cdot \vec v =c(v_1+v_2)=cv_1+cv_2$

Sum of two subspaces is a subspace


What does the apostrophe mean in Falk's №1?

Question: See the picture from the guitar composition:

What does the apostrophe mean and how does it affect playing ?
Answer: Nothing specifically to do with guitar technique.   It's a general musical instruction.   Breath mark. Caesura.  A brief time-out from the flow as if you were a singer taking a breath. It DOESN'T imply a fermata on the note before it though.
Answer: Its more usual use is to indicate where a breath may be taken. Maybe for guitarists short of breath..! Probably a vestige from another transcription of the piece played on a wind instrument. Now more an indication of the end of one phrase, and the beginning of the next, possibly cutting that last crotchet a little bit in length, which is what would happen when played on a wind instrument.
Comment: I've seen this for non wind instruments, it's always about "breathing" anyway, even if it's not a requirement of the instrument: you don't need to *actually* take a breath, but the musical effect should be like you are taking it. And, even for non wind instruments, it's good practice to actually take that breath anyway, as it really helps musicality.


Genus of complete $ k $-partite graph

Question: What is the formula for the genus of a complete $ k $-partite graph, with partite set of size $n_1,n_2,\dots,n_k$, where $ k $ is an integer greater than or equal to $3$?
Comment: The genus of the complete tripartite graph $K_{mn,n,n}$ is shown to be $(mn-2)(n-1)/2$, for all natural numbers m and n (see A. T. White, {\em The genus of the complete tripartite graph $K_{mn,n,n}$}, J. Com. Theory, 7, 283-285 (1969)). I think the problem to find the formulae for the genus of a complete $k$-partite graph is still an open problem!
Answer: The complete bipartite graph $K_{m,n}$ has genus $\left\lceil\frac{(m-2)(n-2)}{4}\right\rceil$ (from http://mathworld.wolfram.com/GraphGenus.html).
Bettayeb has a paper on the genus of complete multipartite graphs; see Link.
Comment: I wouldn't expect anything more to be known about multipartite graphs, but do you know of any conjectures about it?

Genus of complete $ k $-partite graph


THREE.EffectComposer is not a constructor

Question: first time here :) Hello everyone !
I was trying to follow some code to create a volumetric light scattering shader using THREE, trying to reproduce this: https://codepen.io/abberg/pen/pbWkjg
But when I do it, I get a console error saying: 'THREE.EffectComposer is not a constructor'
The issue is that I'm trying to reproduce this in ES6 environnement, using gulp. In order to prevent too much compiling time, I removed THREE from the gulp watch compilation for the duration of the dev, and imported it directly in index.html as follow:

I use THREE 0.88.0
Did I miss a plugin ? Search on google didn't lead me to any recent answer about this issue.
Thanks in advance for your answer !
Comment: Thanks it was indeed that I missed the plugins
Comment: Possible duplicate of [Can't get three.js EffectComposer to work](https://stackoverflow.com/questions/13350084/cant-get-three-js-effectcomposer-to-work)
Answer: EffectComposer is not included in the three.js bundle you are referencing in your script tag. You will need to add the following:

Same idea for adding OrbitControls and other unofficial three.js modules.


A problem in calculating integral

Question: I have a problem in calculating the integral:
$I=\displaystyle\int\limits_{-\infty}^{\infty} \dfrac{xe^{-x^2/2}}{\sqrt{2\pi}}
dx$.
My teacher said that $\dfrac{xe^{-x^2/2}}{\sqrt{2\pi}}$ is an odd function, thus $I=0$.
This is my solution, but I wonder if it's right.
$I=\displaystyle\int\limits_{-\infty}^{\infty} \dfrac{xe^{-x^2/2}}{\sqrt{2\pi}}
dx=\dfrac{1}{\sqrt{2\pi}}\displaystyle\int\limits_{-\infty}^{\infty} e^{-x^2/2}d(\dfrac{x^2}{2})=0$
Is the statement $\displaystyle\int\limits_{-\infty}^{\infty} \dfrac{xe^{-x^2/2}}{\sqrt{2\pi}}
dx=\dfrac{1}{\sqrt{2\pi}}\displaystyle\int\limits_{-\infty}^{\infty} e^{-x^2/2}d(\dfrac{x^2}{2})$ right?
My teacher said that $f(x)=\dfrac{xe^{-x^2/2}}{\sqrt{2\pi}}$ needs to be injective so that we can write as above, but I can't find any theorem confirm that. Anyone help me please?
Comment: Your lower limit after change of variable is not correct.
Comment: I added an answer, does it make sense?
Comment: Thank you for caring about my problems, But can you tell me how to correct it?
Comment: I still don't understand why my lower limit is wrong. I mean that x goes from $-\infty$ to $\infty$
Comment: Yes, I'm stil reading it. Thank you for your answer.
Answer: When you're using the substitution $u=z(x)$
$$
\int_a^bf(x)\,dx=\int_{z(a)}^{z(b)} f(z^{-1}(u))\frac{dz^{-1}(u)}{du}\,du
$$
which tells us if our substitution is valid,  $z$ has to be invertible or equivalently $z$ is an injective function over the required domain. Now in your post $$u=\frac{x^2}{2}\implies z(x)=\frac{x^2}{2},\quad x\in(-\infty,+\infty)$$
But this $z$ is indeed not injective over $\mathbb R$ as
$$z(x)=z(-x)$$
The way you have used substitution the lower limit should be $z(-\infty)=+\infty\,$.
Wikipedia page on u-substitution has the theorem you're looking for (most likely).
Comment: @liverpool29 I'm not aware of any such convention (however it might be correct). Note that in the Wikipedia theorem the limits in LHS are $\phi(a),\phi(b)$. Suppose we had $\phi(a')=\phi(a)$ with $a'\neq a$, we'd be in trouble figuring out the correct limit for RHS wouldn't we?
Comment: Thank you. But in the theorem you mentioned, it didn't include the condition of injective. By the way, I wrote $d(x^2/2)$ means that the limits is for x not for $x^2/2$. Isn't it right?
Comment: I have edited my question more clearly.
Comment: @liverpool29 [A little scrolling on the same page](https://en.wikipedia.org/wiki/Integration_by_substitution#Substitution_for_multiple_variables) leads you to a theorem that requires $\varphi$ to be injective.
Answer: Break the integral into two parts, integrating from $0$ to $\infty$ in one part and from $-\infty$ to $0$ in the other. The substitution $x^2/2=y$ is injective over each part.
Answer: Actually you need injective condition to $\varphi(x) = x^2$ on the intergration domain, say $[-\infty , \infty]$. However, on this domian, $\varphi$ is not injective. Why don't you split the integral into
$$
\int_{-\infty}^{\infty} = \int_{-\infty}^{0} + \int_{0}^{\infty}
$$
so that $\varphi$ can be an injective function on those sub-domains, thus you can follow the way as in your post, which results $I=0$ as well.
For further reference, one can read at integration by substitution, herein we can see that the injective condition is to guaranteed that the integration domain can not be overlapped via the transformation $\varphi$, e.g. in your problem $\varphi([0,\infty)) = [0 , \infty) = \varphi((-\infty,0]) \overset{overlapped \, right \, here}{=} \varphi((-\infty,\infty)) $.
Comment: The second "=" is right, however, the third "=" is not certain and you need to prove it. An easy way to show it is to split the integration domain into sub-domains.
Comment: Thanks for your answer. My question is in my third sentence(in the first post), the second "=' is it right?
Comment: Oh thanks, this is the answer I waiting for, the third '=' I wrote in the short way. My teacher said that the second '=' is wrong.
Answer: Well, substitute $\text{u}=-\frac{x^2}{2}$ and $\text{d}\text{u}=-x\space\text{d}x$:
$$\mathcal{I}\left(x\right)=\frac{1}{\sqrt{2\pi}}\int x\exp\left(-\frac{x^2}{2}\right)\space\text{d}x=-\frac{1}{\sqrt{2\pi}}\int\exp\left(\text{u}\right)\space\text{d}\text{u}=\text{C}-\frac{\exp\left(-\frac{x^2}{2}\right)}{\sqrt{2\pi}}$$
Now:

$$\lim_{x\to-\infty}\left\{-\frac{\exp\left(-\frac{x^2}{2}\right)}{\sqrt{2\pi}}\right\}=-\frac{1}{\sqrt{2\pi}}\cdot\lim_{x\to-\infty}\frac{1}{\exp\left(\frac{x^2}{2}\right)}=0$$
$$\lim_{x\to\infty}\left\{-\frac{\exp\left(-\frac{x^2}{2}\right)}{\sqrt{2\pi}}\right\}=-\frac{1}{\sqrt{2\pi}}\cdot\lim_{x\to\infty}\frac{1}{\exp\left(\frac{x^2}{2}\right)}=0$$

A problem in calculating integral


How to compare custom product bundles in Drupal Commerce

Question: I am a Drupal Commerce newbie, and would like advice on how to accomplish a particular project requirement.
I have two kinds of products - Panel and Converter. Each project has a mix of those panels and converters. The type and amount of each panel and converter comes from a custom module. Each of these converters and panels have different prices.
I'm supposed to create a view with the top 5 combinations of converters and panels, sorted by price and allow the user to select the one they want, which then goes into the cart.
I hope that all made sense...
Does anyone know of any tools, modules, or methods that I could look into to accomplish this task? I feel like I'm looking for the ability to create dynamic product bundles, that are then able to be put into a view to compare. Is that even possible?
Thanks for the help
NOTE: I am just beginning this part of the project, so if this is easily accomplished with ubercart or some other ecommerce module, I'm open to that as well.
Answer: For comparing drupal commerce products check out this module: https://drupal.org/project/commerce_product_comparison
There is also a module available which allows you to create product bundles using products of your choosing: https://drupal.org/project/commerce_product_bundle


Turn off colors in Netware console?

Question: I'm looking for a method of changing colors in default Novell Netware (OES) console
Answer: If absolutely nothing else comes up, you could try adding -m to the end of $TERM or setting it to vt100 before running the console.

Turn off colors in Netware console?


Big O notation in python

Question: Does anyone know of any good resources to learn big o notation? In particular learning how to walk through some code and being able to see that it would be O(N^2) or O(logN)? Preferably something that can tell me why a code like this is equal to O(N log N)
def complex(numbers):
    N = len(numbers)
    result = 0
    for i in range(N):
        j = 1
        while j < N:
            result += numbers[i]*numbers[j]
            j = j*2
    return result

Thanks!
Comment: It's not about "code"、"program" or language ,it's about algorithm.
Comment: @Porcelain ahh ok, but do you know of any good websites that can help? Kinda like a crash course on it?
Comment: @JohnLaRooy whoops sorry, O( N log N )
Answer: To start, let me define to you what O(N log N) is. It means, that the program will run at most N log N operations, i.e. it has a upper bound of ~N log N (where N is the size of the input).
Now here, your N is the size of numbers, or your code:
N = len(numbers)

Notice that the first for loop runs from 0 to N-1, for a total of N operations. This is where the first N comes from.
-
Then, where does the log N come from? It is from the while loop.
In the while loop, you keep multiplying 2 to j until j is greater or equal than N.
This will be completed when we have executed the loop ~log2(N) times, which describes how many times we have to multiply j by 2 to get to N. For example, log2(8) = 3, because we multiply j by 2 three times to get 8:
#ofmult. j      oldj
  1      2  2 <- 1 * 2
  2      4  4 <- 2 * 2
  3      8  8 <- 4 * 2

To better illustrate this, I have added a print statement in your code, for i and j:
def complex(numbers):
    N = len(numbers)
    result = 0
    for i in range(N):
        j = 1
        while j < N:
            print(str(i) + " " + str(j))
            result += numbers[i]*numbers[j]
            j = j*2
    return result

When this is run:
>>> complex([2,3,5,1,5,3,7,3])

This is what is outputted:
0 1
0 2
0 4
1 1
1 2
1 4
2 1
2 2
2 4
3 1
3 2
3 4
4 1
4 2
4 4
5 1
5 2
5 4
6 1
6 2
6 4
7 1
7 2
7 4

Notice how our i goes from 0...7 (N times for a total of O(N) ), and the second part, there are always 3 ( log2(N) ) j-outputs for every i.
So, the code is O(N log2 N).
Also, some good websites I would recommend are:
https://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/
And, a video from a lecture series from a Stanford professor:
https://www.youtube.com/watch?v=eNsKNfFUqFo
Comment: It means, that the program will run at most at most **C times N log N**, where C is some constant.
Answer: When you multiply j by 2, you're effectively saying "I've done half the remaining problem!". At each step in the while loop, you're solving half the remaining problem. Therefore if your problem is x size, then the number of iterations required would be i = log_2 x, which we just say is log x. In this case your x is just equal to N.
The for loop has you do the above section N times again, so you get N * log N.
We use O(N log N) to mean that, at each step, we might do any CONSTANT number of things (for example inside the while loop I might do a billion operations), but we don't care about this constant, because generally N is usually bigger, and can get arbitrarily big (beyond a certain size point, even a billion is nothing in comparison to what N COULD be, i.e. a googol). Hence we have O(N log N).
Here's a short crash course in the form of a pdf:
http://www1.icsi.berkeley.edu/~barath/cs61b-summer2002/lectures/lecture10.pdf
Here's a short crash course in the form of a lecture:
https://www.youtube.com/watch?v=VIS4YDpuP98
Comment: both are dead links as of March 2019

Big O notation in python


Prove $f(x)=0$ has one root in between roots of $g(x)=0$

Question: $f(x)=(a-b)x^2+(b-c)x+(c-a)$
$g(x)=(b-a)x^2+(a+c-2b)x+(b-c)$
given that $a<b $ and $2a^2+b^2+ac<3ab+bc$

Find common root of $f(x)=0 $ and $ g(x)=0$ . Prove $f(x)=0$ has one root in between roots of $g(x)=0$

My Work
First I took roots of $f(x)=0$ as $\alpha,\beta$ and $g(x)=0$ as $\alpha,\gamma$
By substituting $\alpha$ to both equations I was able to find the common root i.e. $x=1$. But I don't know how to proceed. Can you please help me? Thank you!
Answer: A different approach to the first part: If $f(x)=0$ and $g(x)=0$, then also
$$0=f(x)+g(x)=(a-b)x+(b-a) $$
and this linear equation has exactly one root $x=1$ (where we use $a\ne b$!). So if they have a common root then it must be $1$. One verifies that $1$ is indeed a root of both.
Once we know one root of a quadratic, we can find the other by dividing out the corresponding linear factor. Or, recall that the product of the roots of $Ax^2+Bx+C$ (with $A\ne 0$) is $\frac CA$ (and the sum of the roots is $-\frac BA$). Knowing that one root is $=1$, the product of the roots is simply the other root. So the other root of $f$ is $\frac {c-a}{a-b}$ and the other root of $g$ is
$\frac{b-c}{b-a}$. So the desired result is that $\frac{a-c}{b-a}$ is between $\frac{b-a}{b-a}$ and $\frac{b-c}{b-a}$, or equivalently, $a-c$ is between $b-a$ and $b-c$. From $a<b$, we find $a-c<b-c$, hence what we still need is $b-a<a-c$, or equivalently
$$\tag1 b+c<2a.$$
Unfortunaltely,$(1)$ is not a consequence of the given inequalitites. In fact, if $b>a$, then $2a^2+b^2+ac<3ab+bc$ holds for all $c\gg0$, wheras $(1)$ certainly does not.
In concreto, we can use this to construct a counterexample:
Let $a=2$, $b=4$, $c=1$. Then $a<b$ and $2a^2+b^2+ac<3ab+bc$, but we have $$ \begin{align}f(x)=-2x^2+3x-1&\text{ with roots } \{\tfrac12,1\},\\ g(x)=2x^2-5x+3&\text{ with roots } \{1,\tfrac32\}.\end{align}$$


desativar o espaço em branco ao final das linhas (não-arrasto-espaços)

Question: Tenho esse erro em um projeto vue js, sei que se trata eslint verifiquei o tutorial no site sobre como remover o erro com comando --fix, entretanto não surtiu efeito, se caso alguém conheça,  eu agradeço se poder ajudar.
Erro:
http://eslint.org/docs/rules/key-spacing    Missing space before value for key 'component'
  src\router\index.js:9:29
          {path:'/',component:Home}
                               ^
5 problems (5 errors, 0 warnings)
Errors:
  3  http://eslint.org/docs/rules/key-spacing
  1  http://eslint.org/docs/rules/comma-spacing
  1  http://eslint.org/docs/rules/indent
@ ./src/main.js 5:0-30
 @ multi ./build/dev-client ./src/main.js

Listening at http://localhost:8080

Vue js
import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/components/Home'

Vue.use(Router)

export default new Router({
    routes:[
        {path:'/',component:Home}
    ]
})

Comment: Qual foi o comando que usaste? Criei um ficheiro com o teu código e fiz `eslint eslinttest.js --fix` e funcionou bem
Comment: eslint --fix, neste caso devo selecionar o ficheiro que esta dando o erro
Comment: http://eslint.org/docs/rules/indent       Expected indentation of 2 spaces but found 0
  src\router\index.js:11:1
  }
   ^
4 problems (4 errors, 0 warnings)
Comment: Usa o nome do ficheiro no comando: `eslint ./src/main.js --fix`
Answer: Usa o nome do ficheiro no comando: eslint ./src/main.js --fix
Comment: Podias ter dito que [a minha sugestão](https://pt.stackoverflow.com/questions/251957/desativar-o-espa%c3%a7o-em-branco-ao-final-das-linhas-n%c3%a3o-arrasto-espa%c3%a7os/253645#comment516993_251957) tinha  funcionado que eu dava uma resposta :)


What does it mean when progression is resolved?

Question: I saw this text inside a very basic piano workbook in which I'm not sure what the author means by using "resolve".

Progression #1: C-F-G-F-C
NOTE: This 4 bar progression resolves back to C after the final time it's played on the play  along CD.

Dictionary.com gives this definition for "resolve" as used in music:

Resolve: [Music] to progress from a dissonance to a consonance.

But the problem is that I don't here any dissonance on the above progression. C, F, and G totally sound harmonic and simply good!
Answer: Try playing a sequence C - F - G - F in a loop. Think of it as the basis of a song. This is probably what you'll hear on your play-along CD.
Now see what happens if you simply stop after the final F.
Most people would agree that it hasn't ended properly. It's hanging; the listener expects something else. It is unresolved.
Now try ending by adding that final C after the last F. Now it sounds as if it's finished.
Because the sequence starts with a C chord, and because all of the chords use notes from the C major scale, C feels like the "home" chord.
When you move away from the home chord, you introduce a tension - not a dissonance -- and when you return to the home chord, you resolve that tension.
Some pieces defy expectations by ending on an unresolved chord. But if your aim is to make the listener comfortable; to have that sense of closure; then resolving to the home chord is the conventional thing to do.
Comment: Thanks Slim. 2 more questions. First, so you believe this definition is not a good one and it shouldn't be called dissonance?! Second, Is resolving only called to this kind of ending?
Comment: The dictionary definition is correct but too specific. Resolving could be informally described as going from anything "nasty" to something "nice" - discord to harmony; unsynchronized rhythms to synchronized; uncomfortable chord to comfortable chord.
Answer: "Resolution" has a slightly broader definition than just "from dissonance to consonance." Before I get to that, though, I want to touch on why exactly that definition is used.
First, let's throw out the chord progression you supplied: it's very 60's doo-wop, and not a good example for common practice harmony. Let's replace it with |: C F C G :| C (I am using |: - :| to indicate repeats.)
We are playing in the key of C major. This is clear from the fact that we start and end on that chord, and all of the other chords contain notes within the key of C major. This means that our C chord is called the tonic chord. It functions as a "home base," if you will. In common practice harmony, a dominant chord is one that implies a following resolution to a tonic chord. There are many other names for different chord functions in a key, including mediant, sub-mediant, sub-dominant. I am only going to focus on dominant and tonic here, so you should know that we use I (Roman numeral one) to refer to the tonic chord built on the root note of the key (C), and V (Roman numeral five) to refer to the dominant chord built on the 5th note of the key (G).
Back to our progression. Let's change it once more, to |: C F C G7 :| C. With Roman numerals, we would use |: I IV I V7 :| I. This is where we get the dissonance that your original definition was talking about. The V7 chord is called a dominant 7th, because it contains a tritone that strongly implies a resolution to the tonic chord. (The dissonant tritone is caused by the 7th chord member, in this case, F.)
To exemplify this, play G7 as follows: G - F - B (from the bottom of the chord to the top). The F with the B above forms a dissonant interval of a tritone. It should sound odd and unstable. To resolve this chord to our consonant tonic chord of C, move the B up half a step, move the F down half a step, and move the G down a 5th to C. We are resolving the dissonant tritone outward by half-step to our consonant tonic chord.
So, that's essentially where your resolution definition is coming from. Now, let's bring it back to your original example step-by-step.
If we consider G - C in C major (V - I), we don't have a dominant 7th chord to fuel our resolution, but it really isn't necessary. If the entire piece has been in C major this whole time, the listener is going to expect the piece to end on the tonic I chord. We call this ending a cadence, essentially meaning a kind of chord-to-chord resolution. The V chord (G) still has dominant function in the key of C major, so we can say we are resolving to C, EVEN THOUGH the G chord IN ISOLATION sounds like it doesn't need to go anywhere. Context is incredibly important in music theory and analysis.
Now, back to our original example of |: C F G F :| C, or |: I IV V IV :| I. The cadence we are analyzing is IV - I, or F - C. We are still in the key of C major, so the ear is going to expect the piece to end on the I chord, C. We can call it a resolution from F to C because the ear expects this in context. The IV - I chord progression actually has a special name: the "Plagal cadence". It is easily remembered since it is commonly used to set the text "A-men" at the end of hymns.
As slim alluded to, a better definition for "resolution" might be a "release of musical tension". Dissonance causes musical tension, as does moving away from the tonic "home" chords. The tension is then released by resolving back to the tonic.
Comment: Comprehensive musical answer!


Assembly Code in C++

Question: I would like to learn reading the assembly code generated by the compiler. Where and how could I assess the assembly code generated from C++ ?
Thanks
Answer: Your compiler likely has an option to generate assembly code output, optionally interleaved with the corresponding source code.  In Microsoft Visual C++ v10 this is /Fa.
Or, just look at the two side-by-side in your debugger.
However you look at this, be sure to compare the versions built with and without optimization.  It's amazing to see how much can be discarded by today's compilers without affecting the operation of the program.
Answer: From your object file:
$ g++ -g -c -Wall yourfile.cpp -o yourfile.o

Then:
$ gdb yourfile.o

Once in GDB you could use disassemble command to view the generated assembly.
So, if your C++ source is:
int f() { return 1; }

You can do in GDB:
(gdb) disassemble f

And the output will be:
Dump of assembler code for function f:
0x00000000 <f+0>:       push   %ebp
0x00000001 <f+1>:       mov    %esp,%ebp
0x00000003 <f+3>:       mov    $0x1,%eax
0x00000008 <f+8>:       pop    %ebp
0x00000009 <f+9>:       ret

Comment: The compiler option for generating assembly listings is much much more helpful than running a disassembler, because it will show source code with the assembly.
Comment: @Ben Voigt: 100% with you on that. That doesn't make my answer wrong though. It's just another way to do it. It might be helpful if you don't have the source code around, for example.
Answer: If you are using gcc, use the -S argument and the compiler's output won't go through the assembler.
Answer: For GCC and objdump.
Using GCC to produce readable assembly?
For Visual Studio, if you are using the IDE, you can modify the C/C++ 'Output Files' property in your project's properties, and change 'Assembler Output' to 'Assembly with Source Code'
This is also the '/Fas' flag for Visual C++ compiler.
Comment: There's the question I was looking for!
Answer: //a.cpp
#include <iostream>

int main()
{
   std::cout << "hello";
}

On gcc you can use the -S option, i.e gcc -S a.cpp generates a.s
(a.s):

        .file   "a.cpp"
.lcomm __ZStL8__ioinit,1,1
        .def    ___main;        .scl    2;      .type   32;     .endef
        .section .rdata,"dr"
LC0:
        .ascii "hello\0"
        .text
.globl _main
        .def    _main;  .scl    2;      .type   32;     .endef
_main:
        pushl   %ebp
        movl    %esp, %ebp
        andl    $-16, %esp
        subl    $16, %esp
        call    ___main
        movl    $LC0, 4(%esp)
        movl    $__ZSt4cout, (%esp)
        call    __ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
        movl    $0, %eax
        leave
        ret
        .def    ___tcf_0;       .scl    3;      .type   32;     .endef
___tcf_0:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $24, %esp
        movl    $__ZStL8__ioinit, (%esp)
        call    __ZNSt8ios_base4InitD1Ev
        leave
        ret
        .def    __Z41__static_initialization_and_destruction_0ii;       .scl
3;      .type   32;     .endef
__Z41__static_initialization_and_destruction_0ii:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $24, %esp
        cmpl    $1, 8(%ebp)
        jne     L3
        cmpl    $65535, 12(%ebp)
        jne     L3
        movl    $__ZStL8__ioinit, (%esp)
        call    __ZNSt8ios_base4InitC1Ev
        movl    $___tcf_0, (%esp)
        call    _atexit
L3:
        leave
        ret
        .def    __GLOBAL__I_main;       .scl    3;      .type   32;     .endef
__GLOBAL__I_main:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $24, %esp
        movl    $65535, 4(%esp)
        movl    $1, (%esp)
        call    __Z41__static_initialization_and_destruction_0ii
        leave
        ret
        .section        .ctors,"w"
        .align 4
        .long   __GLOBAL__I_main
        .def    __ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc;
.scl    2;      .type   32;     .endef
        .def    __ZNSt8ios_base4InitD1Ev;       .scl    2;      .type   32;
.endef
        .def    __ZNSt8ios_base4InitC1Ev;       .scl    2;      .type   32;
.endef
        .def    _atexit;        .scl    2;      .type   32;     .endef

Assembly Code in C++


Display changelog after eclipse plugin update

Question: I want to display changelog in first run after plugin update. I interested where should I keep information about version of plugin. I'm thought about preference /.metadata/.plugins/org.eclipse.core.runtime/.settings but I'm not sure it's good idea.
Comment: That location is for preferences only. What do you mean by 'information about version of plugin'?
Comment: To display after update I want have place with version. Every time I run my plugin it would check if version is good and then don't display changelog, but if version is different it's gona display it.
Answer: Platform.getStateLocation returns you a directory where you can keep any information you like.
Bundle bundle = ... your plugin bundle ...

IPath dirPath = Platform.getStateLocation(bundle);

The directory will usually be .metadata/.plugins/<your plugin id> in the workspace.


How to Sample from a Randomisation Distribution?

Question: I will use an example to explain my problem, but I think that it can be generalised to any randomization testing that does not allow one to create the null distribution by enumerating of all the possible orders of the data (that is the number of possible data permutation is too large to make the complete enumeration impossible), and a sampling of the randomised data should be made.
Example: Differential Correlation
Let be $\mathbf x_1$ and $\mathbf y_1$, both of length $n_1$, a pair of vectors that represents the age and weight of $n_1$ male individuals, and $\mathbf x_2$ and $\mathbf y_2$, both of length $n_2$, a pair of vectors that represents the age and weight of $n_2$ female individuals. The number of males may be different than the number of females.
Let $\rho_1$ be the Pearson's correlation coefficient between $\mathbf x_1$ and $\mathbf y_1$, and $\rho_2$ the Pearson's correlation coefficient between $\mathbf x_2$ and $\mathbf y_2$. To reject the null hypothesis that $\rho_1=\rho_2$ using a permutation test I should create random vectors where paired elements of $\mathbf x_1/\mathbf y_1$ are swapped with paired elements of $\mathbf x_2/\mathbf y_2$, in order to remove the relationship between the measurements and the labels (male/female).
The complete enumeration of all possible order of the data would be equal to all the possible order of the vector $\mathbf x (\mathbf y)$ built by concatenating the two vectors $\mathbf x_1 \mathbf x_2 (\mathbf y_1 \mathbf y_2)$, that is $(n_1+n_2)$!
This makes my complete enumeration impossible, and I need to sample $N$ configurations from all the possible configuration of $\mathbf x$, of length $n_1+n_2$.
The problem: How many elements are swapped (in average) in each data configuration?
Each possible configuration will swap a random number $R$ of (paired) elements from $\mathbf x_1/\mathbf y_1$ to $\mathbf x_2/\mathbf y_2$, and I would like to know if $R$ follows any known distribution.
Let then $\mathbf v$ be a vector of length $n_1+n_2$, built by concatenating a vector $\mathbf v_1$, that includes $n_1$ elements set to $0$ representing $\mathbf x_1/\mathbf y_1$, and $\mathbf v_2$ that includes $n_2$ elements set to $1$ representing $\mathbf x_2/\mathbf y_2$.
Let then shuffle the element of $\mathbf v$ for $N$ times, and count, at each step $i$ (with $i \in [i, N]$), how many elements $c_i$ of $n_1$ are now set to $1$, that is, how many elements were swapped at that permutation step.
Let then build the distribution of my permuted elements $c$.
These steps are performed by the following function, while the histogram will show the distribution:
count.permuted.elements <- function(n1, n2, N=10000) {
    c <- numeric(N)
    for (i in 1:N) {
        v <- c(rep(0, n1), rep(1, n2))
        v <- sample(v)
        c[i] <- sum(v[1:n1])
    }

    c
}

hist(count.permuted.elements(n1, n2))

I have run some simulations with different values of $n_1/n_2$, and what I obtained (see plots below) are normal distributions, as also confirmed by the function fitdist (in the R package fitdistrplus). Let me underline that the right tail is limited by the length of the shortest vector, that is, I can't permute more elements than those included in the shorter vector (see the plot on the bottom right for an example).

The problem (restated): How to estimate the parameters of the normal distributions ($\mu$ and $\sigma$) showed above, by using only $n_1$ and $n_2$?
After running several simulation, varying $n_1/n_2$, it seems to me that the mean $\mu$ is a function of the length of the smaller vector (let's say $n_1$) and the square root of the ratio between the two lengths, that is:
$$\mu = n_1 \cdot \left(-0.604 \cdot \sqrt{\frac{n_1}{n_2}} + 1.101\right)$$
However, I can't find a way to calculate $\sigma$ --and I am not sure that what I did to evaluate $\mu$ is very correct.
My question is: does anyone know how to evaluate, in a formal or empirical way, the parameters of the normal distributions ($\mu$ and $\sigma$) build by counting how many elements are swapped (in average) between the two arrays in each data configuration?
Thank you very much for your help!
Comment: You have a fundamental problem: the permutation test you describe does not work the way you believe.  It does not test the hypothesis that the two correlation coefficients are equal.
Comment: You don't need to know how many are swapped on average to do the randomization; indeed if you're using such a calculation in order to randomize (by swapping that average number) you'll be doing randomization wrong.
Comment: @whuber Which part of the question are you referring to? The code (and the main question in the post) is not meant to test if two correlation coefficients are equal, but to simulate how many elements are swapped at each permutation step.
Comment: @Glen_b I think I got what you mean. But how to implement a correct permutation scheme then? For a number of reasons I can't concatenate my two vectors, as done in the example, and I need to decide how many elements to sample (permute) at each step.
Comment: Indeed, I think "*how to implement a correct permutation scheme?*" is what you really need to ask in your question; at present you seem to have an [XY-problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem/66378#66378)
Comment: @Glen_b I actually believed that matching the same _distribution_ created by the R function `sample` (that is what it is usually used in practise, when vector can be concatened) would work.  With _distribution_ I mean the number of elements that are permuted --that are indeed any number from 1 to the length of the shortest vector. What do you suggest?
Comment: Matching the entire distribution would work, yes (assuming you begin with a sampling scheme using `sample` that's correct for your problem) -- but if you're matching what `sample` does, why would you not use `sample`?
Comment: @Glen_b Yes, I do use `sample` in the posted code and to generate the shown histograms I was willing to match. Unfortunately, I can't use  `sample` directly in the code I am developing because I can't concatenate the two pairs of vectors, so I am trying to find a distribution mimicing `sample`'s behaviour. Does it make sense?
Comment: @alesssia looking at the discussion, I'd suggest to divide your question into two separate ones: this one, about distribution of values drawn without replacement and a new one about proper implementation of permutation test.
Comment: @allessia you sample from an index (representing which row numbers), and use the same index on both sets
Comment: @Glen_b In the posted example I sample from a (pair of) vector that is the result of the bind between the two (pair of) vector representing the two condition. If I sample only from one (the shortest) and use the same indeces, I will never permute some of the element of the longest. Does it make sense?
Comment: Yes, sorry, I got muddled about what you were doing. Your sampling scheme won't work unless you have much stronger conditions than just the same correlation, and if those conditions hold, you'd simply combine them all into one large sample and draw a sample the same size as the first sample, leaving the remainder for the second sample.
Comment: @Glen_b What do you mean with "you have much stronger conditions than just the same correlation"? Forgot to mention: I can't combine them. For software design they need to stay separate :(
Comment: To do a permutation or randomization test you need the objects being
chosen between to be at least exchangeable. In this case your objects are bivariate observations. Paris having the same correlation under the null is insufficent; you'd need the distribution to be the same for the process to work (see whubers comment). Note that you don't need to physically combine them as objects in code, you just need to have your selection process choose from a pool of all such objects with equal probability. The "combine" was conceptual; it can be achieved in many ways in code.
Comment: I am choosing with equal probability a number of objects that follows a  hypergeometric distribution (as pointed out by @Tim below)...
Answer: You have $n_1$ $0$'s and $n_2$ $1$'s, so probability of sampling $1$'s from the whole sample is $p = \frac{n_2}{n_1+n_2}$. You randomly sample from it $n_1$ cases, where probability of sampling $1$'s is $p$, when $n_1 \ll n_2$ this resembles binomial distribution with parameters $n_1$ and $p$.
However your data does not follow binomial distribution since you are sampling without replacement from finite population. Your data follows a hypergeometric distribution. In this case mean and variance are
$$ \mu = n_1 \frac{n_2}{n_1+n_2} \\
   \sigma^2 = n_1 \frac{n_2}{n_1+n_2} \frac{n_1}{n_1+n_2} \frac{n_2}{n_1+n_2-1} $$
Below you can see data created with your function with added pmf of binomial (red curve) and hypergeometric (blue curve) distribution.
Comment: Thank you very much. This quite good approximation is more than fine!


Redifferencing multiple checkpoint-avhdx'es agains the root vhdx instead of an intermediate avhdx

Question: I'm currently in this situation of differentiating avdhx-files where A1, A2, B and C represents the actual checkpoints I'm using.

I would like to convert A1 and A2 into differentials directly against master.vhdx like B and C are, removing the dependency to A.
Is this possible?
Comment: Are these standalone differential files or do they belong to checkpoints?
Comment: @EricSiron A1, A2, B and C belong to checkpoints. A does not, but A1 and A2 depend on it. I'm not sure how this happened.
Answer: Make a copy of A and A1.  Call them D and D1.  (If you're using ReFS, this copy won't actually need to replicate the data.)  Then use the Merge-VHD PowerShell cmdlet (or any other method) to merge D1 into D.  (Again, if you're using ReFS, this won't actually move any data.)  D is now the VHD that you want from A1.  Replicate the process for A2.
Comment: Thank you Jake! I see that someone downvoted your answer, any idea why?


Proof that if $\lim_\limits{n\to\infty}(a_n\cdot b_n)=0$ then $\lim_\limits{n\to\infty}a_n$ or $\lim_\limits{n\to\infty}b_n = 0$

Question: We had to prove that if
$$\lim_{n\to\infty}(a_n\cdot b_n)=0$$
Then either $\lim_{n\to\infty}a_n$ or $\lim_{n\to\infty}b_n$ HAS to be equal to $0$.
My hypothesis is that since
$$\lim_{n\to\infty}(a_n\cdot b_n)=\lim_{n\to\infty}a_n\cdot \lim_{n\to\infty}b_n$$
Then for $\lim_{n\to\infty}(a_n\cdot b_n)$ to be zero, and since the only "number" that when multiplied by another one produces $0$ (or something along those lines), at least one of the factors ($a_n$ and $b_n$) MUST be $0$.
But the thing is that we couldn't come up with any formal proof, using the definition of limit or something... So any advice would be appreciated.
Thanks.
Comment: @darksky he forgot to assume that at least one of the sequences converges.
Comment: If in the limit neither is zero, the product will be non-zero. What kind of formalism are you looking for?
Comment: In the problem we don't assume that at least of the sequences converges, we have to prove or disprove that one of them converges to zero. But someone already gave a counterexample.
Answer: The claim is false. Consider $$a_n=\begin{cases}0, & n\:\:\mathrm{even}, \\1, & n\:\:\mathrm{odd}, \end{cases}$$ and $$b_n=\begin{cases}1, & n\:\:\mathrm{even}, \\0, & n\:\:\mathrm{odd}. \end{cases}$$
We have $a_nb_n=0,\forall n$ and thus $\lim_{n\infty} a_nb_n=0.$ But $\lim_{n\to\infty}a_n$ and $\lim_{n\to\infty}b_n$ don't exist.
Comment: Nice! I didn't use to think of sequences of that style but now I will.
Answer: This isn't true.
Take:
$a_n=\left\{\begin{matrix}
1/n^2 & n \:  odd \\
n & n \: even
\end{matrix}\right., \; \;
b_n=\left\{\begin{matrix}
1/n^2 & n \:  even \\
n & n \: odd
\end{matrix}\right.$
Then $a_n\cdot b_n = 1/n$ for every $n$ but non of the sequences has a limit.


How to construct discontinuous derivative with piecewise-polynomials?

Question: Problem :
Construct differentiable function with piecewise-polynomials, but it has discontinuous derivative.
My Attempt
At first I tried to make similar one of : $$x\to x^2\sin\left(\frac{1}{x}\right)$$
Since $x^2$ is already polynomial, I tried to imitate $\sin$ part with
$$f\quad \colon\quad
 x\to (-1)^n2^n\left(x-\frac{1}{2^{n+1}}\right)\left(x-\frac{1}{2^n}\right)\quad \left(\frac{1}{2^{n+1}} \le x \le \frac{1}{2^n}\right)$$ for each $n \in \mathbb{N}$.
Then $f$ is differentiable for $x\neq 0$.
And I have problems :

How can I find $f$ is bounded or not? (to find $f$ is continuous or not at $x=0$)

(I tried to bound it with $x^2$ but I dont think its valid because $x^2$ is convex but the $f$ switches convex and concave infinitely many times )

(If $f$ is continuous  at $x=0$) Can I construct discontinuous derivative with $f$ and something?

If I can't for '2', Is there any piecewise-polynomial which has discontinuous derivative?
Comment: That's impossible, because of [Darboux's theorem](https://en.wikipedia.org/wiki/Darboux%27s_theorem_(analysis)).
Comment: Why does $max\{x, 0\}$ solve this?
Comment: @Bananach Sorry, I mean a differentiable function but its derivative is discontinuous one. I edited my post.
Comment: Can your function be a derivative? @PeterO.
Comment: I meant the 'construct $f$ with piecewise-polynomials such that $f$ is differentiable but $f'$ is discontinuous'. So my question is : Can I construct oscillating discontinuity with piecewise-polynomials.
Comment: Customarily, _piecewise_ means the set of endpoints of the subintervals is _locally finite_, in which case no such example exists. Presumably that's not your intent...?
Answer: Your example looks like $x \mapsto x \sin(1/x)$. This function is continuous but not differentiable at the origin.
The key point in the example $x \mapsto x^2 \sin(1/x)$ is that the local extrema are attained for $x$ such that $\sin(1/x) = 1$ and thus lie on a parabola.
Let us compute the extrema in your example. For a polynomial $x \mapsto (x-a)(x-b)$, the derivative is zero for $x = (a+b)/2$ and the absolute value of the function at this point is $(b-a)^2/4$. We have $a=1/2^{n+1}$, $b = 1/2^n$ so that the extremum of $f$ in the interval $[a,b]$ is attained at $x = 3/2^{n+2}$ and
$$
\left|f\Bigl({3\over 2^{n+2}}\Bigr)\right| = 2^n {(1/2^n-1/2^{n+1})^2\over 4} = {1 \over 2^{n+4}} = {1 \over 12} ({3\over 2^{n+2}})
$$
The extrema lie on the line $y=x/12$ and not on a parabola.
So $f$ is bounded but the derivative is not continuous at zero, since the variation ${f(3/2^{n+2}) - f(0) \over 3/2^{n+2}}$ takes alternatively the values $-1/12$ and $1/12$.
If you want an example close to the $x^2\sin(1/x)$ map, you can remove the leading coefficient $2^n$. Then the extrema will be on a parabola. You lose the continuity of the derivative at the points $1/2^n$, I don't know if you see it as a problem. By looking at higher degree polynomials, this continuity could be restored.
Anyway, once the extrema are on a parabola, the function $f$ can be studied in the same manner as the function $x^2 \sin(1/x)$ so as to reach the same conclusions.


If $S = \{x_1,...,x_{n-1}$} is linearly independent, how to prove $x\in S\iff $det$[x, x_1 ... x_{n-1}]=0$?

Question: For the precondtion, $S$ and $x$ are in $ℝ^n$.
$\Rightarrow$ $S$ is linearly independent $\iff$ $Ax=0$ only has trivial solution $\iff$ $A$ is invertible (by inverse theorem) $\iff$ det$[x, x_1 ... x_{n-1}]\ne 0$
What happened here, how am I suppose to prove it? Did I misunderstand something?
Comment: What does $A$ denote?
Answer: All i think can be the problem is maybe $S = \{x_1,...,x_{n-1}\}$, as you have it stated if $x$ is already in $S$ then there is no reason to pose this question.
In that case if $x \in S$ clearly we would then have $\{x,x_1,...,x_{n-1}\}$ is linearly dependent which would case the determinate to be zero. Similarly if the determinate is zero we must have that it is linearly dependent.
Hope this helps.
Answer: If $x \in S$ then the set is linearly dependent, hence the matrix is not invertible, hence the determinant is $0$.
If the determinant is $0$, then the matrix is not invertible, hence the column space is linearly dependent, and thus you can write $x$ as a sum.


How to force Panels to render a node field even when field is empty

Question: I have a field that I want to display via the Views Hybrid formatter in a panel pane as a node element. It renders just fine when there is at least one user-selected item in the field, but when there is none, it is treated as an empty field and so none of the view results show either. The whole thing is not displayed just because the field is empty.
How can I force panels to render a node element even when the field contains zero values?
Comment: Does https://www.drupal.org/project/empty_fields work in Panels?
Comment: I don't think so. I tried it and it doesn't seem to be saving its settings properly.
Answer: The reason i wanted to render an empty field in a panel was because the views hybrid formatter shows a view when the field is empty.  Instead,  i ended up showing the view via a views pane and making that pane conditional on the value of the field being empty.


How to calculate the probability of multiple people winning multiple games?

Question: If for example I have $100$ people playing a coin toss game. Every person has $5$ coin tosses. If a person manages to successfully call each of the $5$ coin tosses they win.
So I know to calculate for 1 person's odds, its just $0.5^5 = 1/32$ ($3.125\%$), but if I want to calculate the odds of, say, $42$ people correctly guessing all $5$ in a row, how do I figure that out?
Comment: By means of [binomial distribution](https://en.wikipedia.org/wiki/Binomial_distribution). There are $100$ independent experiments that can succeed or fail, and all have the same chance to succeed. To be found is $P(X=42)$ and the parameters are $n=100$ and $p=2^{-5}$.
Comment: This [tutorial](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference) explains how to typeset mathematics on this site.
Answer: This will follow a binomial distribution with parameters $n=100$ and $p = \frac{1}{32}$.
Now we know that if $X \sim B(100,\frac{1}{32})$,
$$P(X = k) = \binom{100}{k} \left(\frac{1}{32} \right)^k \left(1-\frac{1}{32} \right)^{100-k}$$


How to do $state.go() with params?

Question: I have perfectly initialized $stateProvider and I'm using all this states with ui-sref. Works great.
User presses the button and thorugh the $stateProvider goes to the edit page.
On this page I have a form which does $http request:
 this.pushData = function (data) {
        $http.post('/data/' + $stateParams.dataId + '/otherdata', JSON.stringify({
            id: otherdata.id,
            name: otherdata.name
        }), configAuth).then(
            function success(response) {
                var addedData = response.data;
                $.notify({message: addedData.name + " has been added"},{type:'success'});

                $state.go('roleInfo({roleId: $stateParams.roleId})');
            },
            function error(data) {
                console.log(data);
                $.notify({message: data.data.message},{type:'danger'});
            }
        );

    }

And I want to do redirect to other view if everything is fine. But this:

$state.go('roleInfo({roleId: $stateParams.roleId})');

doesn't work. How can I do $state.go with params?
Answer: The way you are trying that would work with ui-sref directive, while calling it using $state.go method, you should pass 1st parameter is stateName & then pass params in Object format.
$state.go('roleInfo', {roleId: $stateParams.roleId});

Answer: Try this:
$state.go('myStateName', {roleId: $stateParams.roleId});
You can read the docs here
Answer: i have changed
$state.go('roleInfo({roleId: $stateParams.roleId})'); to
 $state.go('roleInfo',{roleId :$stateParams.roleId});

this will work

this.pushData = function (data) {
            $http.post('/data/' + $stateParams.dataId + '/otherdata', JSON.stringify({
                id: otherdata.id,
                name: otherdata.name
            }), configAuth).then(
                function success(response) {
                    var addedData = response.data;
                    $.notify({message: addedData.name + " has been added"},{type:'success'});

                   $state.go('roleInfo',{roleId :$stateParams.roleId});                    },
                function error(data) {
                    console.log(data);
                    $.notify({message: data.data.message},{type:'danger'});
                }
            );

        }

How to do $state.go() with params?


What variable importance criterion?

Question: A student of mine developed a heuristic supervised machine learning algorithm for highly multivariate data. It seems to work pretty well, and once the model has been derived from the training data set, we can represent it as
$X'=X\cdot L$
Where $X$ is the $n \times k$ sample matrix with $n$ samples and $k$ variables, and $L$ is a $k \times m$ loading matrix. The resulting $X'$ matrix is related (or can be understood) just like principal components matrix in a PCA, or the variates matrix in a PLS-DA.
The $X'$ matrix is then used for classification, and the assigned class is simply based on euclidean or Mahalanobis distances of the $m$-dimensional sample representations from the class centroids.
What would be, in your opinion, the best way of determining variable importance, such that we could sort the $k$ variables according to their contribution to the decision making process?
Answer: Usually, the variable of importance could be generally obtained, not depending on the algorithm of the machine learner.
For example, we could randomize one of the k variables to run the model, and get the difference of error compared to the original data. The larger the difference, the more the contribution such variable makes.
So after repeating this procedure one by one, we can sort or order the contribution of the variables, or saying importance of variables.
Comment: This is true. However, it might not be practical given that we deal with hundreds of thousands of variables.
Answer: If I understand well, you use either PCA or PLS-DA as compression step and then use a k-nn like approach on the scores.
The variables are lost in the calculations of the Mahalanobis distances, however you might have a look at their individual influence using the pseudo-samples approach initially proposed by Gower and used in metabolomics here and here. The use of kernels is equivalent to your Mahalanobis step.

What variable importance criterion?