How to prove an implication within an if and only if

Question: Suppose you need to prove that $A\iff (B\implies C)$.
The two ways to prove this are:

(1a): Suppose $A$ and $B$ are true. Prove that $C$ is true.
(1b): Suppose $B$ and $C$ are true. Prove that $A$ is true.

(2a): Suppose $A$ and $B$ are true. Prove that $C$ is true.
(2B): Suppose $A$ is not true and B is true, prove that $C$ cannot be true.

Are these ways correct? I always get confused what you can assume and what you have to prove when there's multiple implications and such in one statement.
Answer: It helps to call $D$ the statement $B\implies C$. One has to prove $A\iff D$. So we need to show that $A$ implies $D$, and $D$ implies $A$. This means again, that, assuming $A$ it must follow $C$ if we assume $B$, and conversely, that whenever $C$ follows from $B$, then $A$ follows. Now check your $4$ statements according to this reasoning.
Answer: Prove both directions:
Forward: assume A, prove ($B \implies $C). This means "suppose A and B are true. Prove that C is true".
Reverse: Assume ($B \implies $C), prove A. So, you don't  "Suppose B and C are true. Prove that A is true". Instead, "suppose the truth of B implies truth of C, then prove that A is true. $1b$ is incorrect.
Now, reverse can also be interpreted as suppose A is not true, prove ($B \implies $C) is not true by the contrapostive. Which means prove $B$ is true and $C$ is false. So you don't "Suppose A is not true and B is true, prove that C cannot be true." Instead, "Suppose A is not true, prove B is true and prove that C cannot be true." $2b$ is incorrect.
Comment: So in a sense, you can either assume both B and C are true, and prove A, or assume B is false and prove A. Or am I not getting correctly what you're trying to say?
Comment: I understand both corrections, the second one was a small difference which I understand. The first one I did on purpose; I know strictly speaking you must assume that ''If B, then C'', but when proving this is not a particularly useful mechanism. If you suppose B implies the truth of C, how do you use this when proving?
Comment: @Marc B is either true or not true. So if you want to use "if B, then C", to prove something, you'll need to prove that thing, when either B is false, or when B and C are both true. The assumption is useful in the sense that when B is true, C must also be true.
Comment: that is correct
Comment: @Marc Almost; you have to prove *both* of those. The statement $(B\to C)\to A$ is equivalent to $(\neg B\lor C)\to A$, which is equivalent to $(\neg B\to A)\land (C\to A)$. Thus, you must prove that if $B$ is false then $A$ is true, and also if $C$ is true then $A$ is true.
Comment: @JesseMeng `B is either true or not true` The constructivist community would like to have a word with you about your first sentence there ;)
Answer: Hint 1: There are 6 ways to prove $P\implies Q$:

Assume $P$, then prove $Q$
Assume $\neg Q$, then prove $\neg P$
Prove $\neg P$
Prove $Q$
Prove $\neg[P \land \neg Q]$
Prove $\neg P \lor Q$

Hint 2: To prove $P\iff Q$, prove $P\implies Q$, then prove $Q\implies P$


Survival analysis- how to assess the relative difference between two pairs of survival curves?

Question: I am working with a model organism, and we are interested in looking for difference in the effect on survival of both genotype and treatment.
For example, we would like to know if there is a larger relative difference in genotype A for a given treatment than for genotype B, something like ((A treated vs A untreated) vs (B treated vs B untreated)).
What would be the most appropriate way to get at this? I am using the survival package in R, so should I just include the interaction of genotype and treatment in the formula in survdiff()?
I've done quite a bit of survival analysis before, but usually only with varying one factor at a time, so this is new territory for me, and searching did not seem to turn up much literature on this issue in particular.
Thanks!
Answer: You can fit a Cox model and test for all sort of contrast in the same way that you would with a linear model. See coxph() for that. Of course, the assumption of proportional hazards kicks in, but there is usually a price to pay for more complex modeling.
Answer: I am no expert but would like to share my opinion. It seems to me you are trying to determine interaction of treatment and genotype. Then you may need to build certain models and add an interactive term to test for the interactive effect.
I use SAS and there are certain ways to address the issue, and I believe R also has such power.
Comment: Sorry, but you basically restated the contents of my question, which is not particularly helpful.


How to display another view in Bottom Navigation Activity?

Question: I am wondering what is the simplest way to display a View instead of
mTextMessage.setText(R.string.title_home); in a Bottom Navigation Activity?
public class MainActivity extends AppCompatActivity {

    private TextView mTextMessage;

    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.navigation_home:
                    // How to display anotherView here?
                    mTextMessage.setText(R.string.title_home);
                    return true;
                case R.id.navigation_dashboard:
                    mTextMessage.setText(R.string.title_dashboard);
                    return true;
                case R.id.navigation_notifications:
                    mTextMessage.setText(R.string.title_notifications);
                    return true;
            }
            return false;
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTextMessage = (TextView) findViewById(R.id.message);
        BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    }

}

Comment: this may help you https://inducesmile.com/android/android-bottom-navigation-view-example/
Comment: http://www.androprogrammer.com/2016/12/bottom-navigation-view-with-fragments.html
Comment: https://tutorialwing.com/android-bottom-navigation-view-tutorial-with-example/
Comment: You need to add a fragments for different navigation page. see the links given by @Nilu above these may be useful to you. Academy of Programmer
Comment: @InsaneCat thanks brother
Comment: Welcome @Nilu happy to help others. :)
Comment: Your Question is unclear what **`View`** want to display
Answer: I found good solution here Start fragment in BottomNavigationView
My working code is following
MainActivity
public class MainActivity extends AppCompatActivity {
  private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {

            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            switch (item.getItemId()) {
                case R.id.navigation_home:

                    FragmentOne selectedFragment1 = new FragmentOne();
                    transaction.replace(R.id.fragmentContainer, selectedFragment1);
                     break;
                case R.id.navigation_dashboard:

                    FragmentTwo selectedFragment2 = new FragmentTwo();
                    transaction.replace(R.id.fragmentContainer, selectedFragment2);
                    break;
                case R.id.navigation_notifications:

                    FragmentThree selectedFragment3 = new FragmentThree();
                    transaction.replace(R.id.fragmentContainer, selectedFragment3);
                    break;
            }

            transaction.commit();
            return true;
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        BottomNavigationView navigation = findViewById(R.id.navigation);
        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
        navigation.setSelectedItemId(R.id.navigation_home);
    }
}

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="android.apps.myapp.gpsmegatracker.MainActivity"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/fragmentContainer"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="?android:attr/windowBackground"
        app:menu="@menu/navigation" />
</LinearLayout>

Fragment classes are the same
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class FragmentOne extends Fragment {
    public FragmentOne() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        return inflater.inflate(R.layout.fragment_fragment_one, container, false);
    }
}

fragment_fragment_one.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".FragmentOne">

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button1" />

</FrameLayout>


Can not query the json column with sqlachemy

Question: I am trying to query with in json column in postgresql with flask-sqlalchemy.
here is my code
house_ = House()
results = house_.query.filter(
            House.information['branch_name'].astext == 'release0'
            ).all()

I am not sure what is wrong.
I tried to use .cast(Unicode) instead of astext as well.
Getting error as below:
NotImplementedError: Operator 'getitem' is not supported on this expression

Comment: Please post a [MCVE](http://stackoverflow.com/help/mcve)
Comment: What's the type of `House.information`? If it's JSONB, it should work
Answer: You shold use 'op'  method in your query, like this:
Session.query(Model).filter(Model.json_field.op('->')('KEY') == VALUE)

Also, you can use - >> JSON operator for auto-cast value to text. Also, you can read more about Postgresql JSON(B) operators :)


Compute $\lim_{x\to0}{1 - e^{-x}\over e^x - 1}$

Question:
Compute $\displaystyle \lim_{x\to0}{1 - e^{-x}\over e^x - 1}$.

So first and foremost, I know what the answer to this question is:
$$\begin{align}\lim_{x\to0}{1 - e^{-x}\over e^x - 1} &= \lim_{x\to0}\left({1 - e^{-x}\over e^x - 1}\right)\cdot{e^x\over e^x} \tag{$\star$}\\ & = \lim_{x\to0}{e^x - 1\over (e^x - 1)e^x} \\ &= \lim_{x\to0}{1 \over e^x} \\ &= {1\over e^0} \\ &= 1.\end{align}$$
Unfortunately, I found this solution by complete accident. I can't really justify the motivation of why I performed the step $(\star)$ other than "I saw the $e^{-x}$ and thought to try and get rid of it.
Initially the first thought that I had was to use the conjugate of one of the functions, but we end up not going anywhere with the problem (There's still that nasty $e^{-x}$ using either conjugate). Is this likely the intended solution to this problem? I unfortunately cannot see any other way of solving the problem.
Comment: Since you selected the tag "limits-without-lhopital", I presume that comments or answers instructing you to use L'Hopital aren't what you're looking for?
Comment: @amWhy, yes. A student asked me how to compute this limit, and unfortunately I could not come up with a better answer than presented here. The student in question is an introductory calculus student, and derivatives have not been covered yet. Hence, I wanted to know if there was something else that I might be missing in regards to this problem that makes it simpler. Incidentally, it appeared in the section where conjugates are discussed, and thus is the 1st step I went for in explaining the problem. But when that didn't work, I faithlessly tried multiplying by $e^x/e^x$ and it ended up working
Comment: You could use L'Hospitals rule at the beginning to reduce to the answer!
Comment: @amWhy that's correct I would assume
Comment: It's not clear to me whether you are asking how you can know why, in this case, multiplying by $\frac {e^x}{e^x}$ was a good idea?  (It is a good idea).  Or are you looking for alternative methods?
Comment: Another way (which comes out exactly as your solution) is to write $e^{-x}=1/{e^x}$ and then simplify the fraction. But I really like the way you did it and the reason you give: "I wanted to get rid of the $e^{-x}$". This is the same reason we often use when doing integrals by substitution: "Get rid of those awful expressions."
Comment: @BernardMassé Please look at my answer. I have pointed it out before you. There is point of saying the same thing again  :)
Answer: Here's three ways of doing it:
Taylor
You can use Taylor, i.e. $e^{x} \sim 1 + x$, so
$$\frac{1 - e^{-x}}{e^{x} - 1} \sim \frac{1 - (1-x)}{1+x-1} = \frac{x}{x} =1$$
Factorizing
Another (but equivalent) way is factor $e^{x}$ from the denominator
$$\displaystyle \lim_{x\to0}{1 - e^{-x}\over e^x - 1} = \displaystyle \lim_{x\to0}{1 - e^{-x}\over e^{x}(1 - e^{-x})}= \lim_{x\to0}\frac{1}{e^{x}} = \frac{1}{e^0} = 1 $$
L'Hopital
You can solve by L'Hopital, i.e.
$$\displaystyle \lim_{x\to0}{1 - e^{-x}\over e^x - 1} = \displaystyle \lim_{x\to0} \frac{e^{-x}}{e^{x}} = \frac{e^{0}}{e^{0}} = 1$$
You could use $(\epsilon,\delta)$ definition as well
Comment: You could also define $f(x)=\frac{1-e^{-x}}{e^{x}-1}$, which has the property that $f(x)=f(-x)^{-1}$. Take limits as $x \rightarrow  0$ on both sides, and note that the limit must be positive. ($f(x)=f(-x)^{-1}$ implies that if the right one-sided limit exists and is not zero, so does the left one. Existence of right limit follows directly from continuity of $f$ on $\mathbb{R}\setminus \left \{ 0 \right \}$)
Comment: That's right @LPenguin you could do that as well
Comment: Why does existence of the right limit follow from continuity? It could as easily be the case that $f(x)$ blows up as $x\to0$...
Answer: You may also use the substitution $x=\ln y$. This may make your trick seem more natural:
$${1 - e^{-x}\over e^x - 1} = {1 - e^{-\ln y}\over e^{\ln y} - 1} ={1 - {1 \over y}\over y - 1} ={y - 1\over y(y - 1)} = { 1\over y}\stackrel{y \to 1}{\longrightarrow}1$$
Comment: Another awesome way!!!
Answer: Another way is writing $e^{-x}$ as $\dfrac{1}{e^x}$.
Then, $$\begin{align}\lim_{x\to0}{1 - e^{-x}\over e^x - 1} &= \lim_{x\to0}\left({1 - \dfrac{1}{e^{x}}\over e^x - 1}\right) \\ & = \lim_{x\to0}{e^x - 1\over (e^x - 1)e^x} \\ &= \lim_{x\to0}{1 \over e^x} \\ &= {1\over e^0} \\ &= 1\end{align}$$
See? Almost same as your solution. I think one can easily see through these steps.
Answer: My own approach would be to notice the similarity between the numerator and denominator, and by educated guess perform the factorization
$$e^x-1=e^x(1-e^{-x})$$
and the rest is easy.
Or to perform the substitution $t:=e^x$, giving
$$\frac{1-\dfrac1t}{t-1}=\frac1t.$$


Another definition for the support of a random variable

Question: Let $S_X$ be the support of a random variable $X$,
\begin{equation}
S_X = \{x \in \mathbb{R} : F(x + \varepsilon) - F(x - \varepsilon) > 0 \mbox{ for all } \varepsilon > 0\}\mbox{,}
\end{equation}
being $F : \mathbb{R} \to [0 , 1]$ the distribution function associated with $X$. Defining the family
\begin{equation}
\mathcal{C} = \{C \subset \mathbb{R} : C \mbox{ is a closed set and } P_X(C) = 1\}\mbox{,}
\end{equation}
where $P_X$ is the probability induced by $X$, I want to show that
\begin{equation}
S_X = \bigcap_{C \in \mathcal{C}} C\mbox{.}
\end{equation}
I have already proved that $S_X$ is a closed set in $\mathbb{R}$, so I have only to show that $S_X \subset C$ for all $C \in \mathcal{C}$, though my attemps are not successful. Could you give me a hint? Thank you very much in advance.
Answer: Hint: It will suffice to assume $\exists C \in \mathcal{C}, x \in S_X$ s.t. $x \notin C$ and derive a contradiction. Since $C$ is closed, there is some $\varepsilon>0$ s.t. the interval $(x-\varepsilon,x+\varepsilon)\notin C$.
Comment: I agree, but how can I continue the proof?
Comment: Okay. Calling $\delta = \frac{\varepsilon}{2}$, we also have that $(x - \delta , x + \delta] \subset C^c$, so the contradiction is the next:
\begin{equation}
0 < F(x + \delta) - F(x - \delta) = P_X((x - \delta , x + \delta]) \leq P_X(\mathbb{R} \setminus C) = 1 - P_X(C) = 0\mbox{.}
\end{equation}
Do you agree? Thank you.
Comment: @joseabp91 Yes, looks good


Open CSV data in tableau

Question: I have had problems uploading the following file to Tableau:
https://www.kaggle.com/datasets/shivamb/netflix-shows/download

When loaded it looks like this
but loading it in R

Is it possible to load them in R and then by Rserve connect to tableau or is there a way to load them fine
Comment: The problem is that the "csv" file has fields that are wrapped in quotation marks.  Inside these there are extra commas.  You could use R to save tsv or use some other delimiter.
Answer: Looks like a problem within the interpreter.
I can't download the file myself as I don't have a Kaggle account, and its not clear from you R screenshots, though you could adjust the text file properties to see if you can adjust how the interpreter works by right-mouse the object "netflix_titles.csv" in the data model window and selecting Text file properties from the context menu.
Another option would be to try to use the interpreter Usar el intérprete de datos
Answer: It looks like Tableau is reading this file as a Text file and not a CSV.  Tableau should have multiple headers for every comma that it sees but your screenshot has a single column for the entire first row.
Sometimes, Tableau can correctly read the file if you check the "Use Data Interpreter" checkbox.
If you have trouble making that work, just simply open the CSV in Excel and save it as an XLSX.  You could even connect to it via an import to Google Sheets if you don't have Excel.

Open CSV data in tableau


Two navbars same row make collapse not work. How to make right nav disappear?

Question: I'm trying to get my navbar to collapse correctly.  I have three links on the right that should disappear when my navbar collapses.  Instead, they overlay the links I want to appear upon collapse.  Any suggestions?
Here is my code:

          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
           Toggle navigation

         </button>
        XYZ

Home

Projects

Finance

Resume

####UPDATED CODE, but icons collapse on new row overlaying content #######

     <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
         Toggle navigation

     </button>

Home

Projects

Finance

Resume

Comment: If I could make a suggestion - make use of free online services such as jsfiddle.net or bootply.com to enable others to quickly see your code, as well as visually show the problem. It makes it easier to assist you.
Answer: The easiest way seem to use the http://getbootstrap.com/css/#responsive-utilities.
For your right navigation (icons) use:

This will hide the icons when the navbar has been collapsed.
Also read: Bootstrap 3 Multiple Nav bar Menus
Comment: Thanks for the response.  I should have been clearer.  The right nav does disappear, but the icons on the right are super-imposed on my left-hand nav links when collapsed.  What I'd like is for those right s to totally go away when collapsed (unless they can be forced to work well with the collapsed left-hand nav).
Comment: Remove the class  pull-left from your code. Consider to wrap your icons in a div with class `navbar-right` (and float the li without navbar classes)
Comment: I tried floating the LIs without the navbar classes, but without the navbar classes, the bullet lists show up.  I slightly re-edited based on some of your suggestions, and it collapses better now (right-hand icons collapse to the right), but the right-hand icons are not directly across from the left-side (way down).  It overlays on top of my content as a result.  I've updated my code to show you what I have.


I've been playing guitar for about a year, and learning music production and attempting keyboard and violin

Question: How do I jump in to the deep end? I've taken glances at music theory, and I've tried learning sheet music (still am), but the most I've learned in the past few years of learning music on my own is limited to tablature, a few chords, guitar tuning, and very roughly learning Pro Tools First. I've gotten to the point of writing music for the guitar and keyboard, although most complex chords, or those I don't know/anything translated to the piano, I have to work with my keyboardist who's been doing music for much longer. I've started trying to understand through YouTube, but I don't know what I need to learn or if there are better ways.
Comment: Jump into the deep end of what? It's not clear what you're actually asking about, since your question mentions several different instruments, music theory, music production, and composition.
Comment: Welcome! To help get a good answer, can you edit the question to nail down: What's the goal? To be really good at one of those instruments, ok at the others, and have a general music production knowledge? To be an experienced audio engineer with some basic instrumental ability? Also, a bit of general advice: *don't* jump into the deep end. You drown! Learn everything a little bit at a time, so that you build on what you already know. You seem very eager, and want to know everything as quickly as possible, but you'll learn best in the right order.
Comment: @ToddWilcox Music theory, sorry for airy and open-ended question. I'd like to look into music theory to build a better foundation for the rest.
Comment: Take a class at your local community college or junior college.
Comment: For some idea of what to learn, in what order, here's the [course of study](https://elon.smartcatalogiq.com/en/2021-2022/Academic-Catalog/Academic-Programs/The-College-of-Arts-and-Sciences/Music/Music-Production-and-Recording-Arts-B-S) for a university near me that has a Music Production degree. There are various concentrations, but all include some study of music theory, aural skills, music history or other musicology, participation in making music, and hands-on experience with audio.
Comment: Get yourself a teacher - simple answer!
Comment: What exactly do you want to be able to do? I don't understand what the question is. Do you want to create your own music? What kind of music? Do you want to be able to play existing music? What kind of music? What instrument do you want to be able to play? What do you want to be able to do on that instrument? Think about these and ask a specific question about something that can be answered. :) As it currently is, the only thing is asking is, "what kind of music is good and what should I try to achieve in music?"  You must know yourself what you want to achieve in music, before asking.
Answer: I'm not a pro musician, but I went through a path similar to yours, I was basically secluded in my room.
Music theory per-se is not in itself what gives you the ability to compose music. It is rather a language or set of concepts that help you grasp and conceptualise the material you are working with (i.e. collection of pitches).
I'd strongly suggest learning it linearly. Like going through basics first before jumping to more advanced topics (I tried to learn about tonal music before I got the notion of counterpoint for example and it just frustrated me).
I'd suggest this one resource which I studied systematically and orderly:
https://musictheory.pugetsound.edu/mt21c/MusicTheory.html
I believe the best approach (or what worked for me) was to learn the basics of musical analysis and then just trying to "dissect" songs/pieces I like and I'm familiar with (and if I failed I'd just move on through the book until I learnt the concepts I wass missing).
Look at things like: how the counterpoint lines are moving in relation to one another; how each note of the counterpoint lines (bass, mid, treble) relate to the chords they belong to etc. what choed progression is being used and what chord progressions tend to appear more often in certain styles/genres of music.
note: You'll come across hard-core abstract theoreticians will argue traditional theory (counterpoint, harmonic functions) do not apply to pop/rock music. I'd shun this academic babble like plague. Learning 'traditional' theory will help your brain process music conceptually regardless of music style.
Even if both are the same thing, for example, conceptualising CM-GM-Em-Cm as I-V-iii-i or Tonic-Dominant-2ndTonic-ParallelTonic will comopletely change the way you cognitively process it (music linguistics again). But first the concepts associated need to be learnt gradually and progressively.
I'd most definitively avoid tablatures for analysis as they don't provide a visualisation of harmony and melody.
For a start, you don't need to be fluent in music notation (I'm not and probably will never be), just be able to read enough to spot inverted chords and harmonic relations etc.
To sum up, go through the book/resource/course (the one I recommended or any other) linearly. Avoid making jumps to too-advanced topics until the more basic concepts are settled. And practice as much analysis (learn to think analytically, and play your examples) as you can within the constrains of your given theoretical knowledge at that point in time.
This is not different than math in a way. If you learn the concept of, for example, derivative (which is in itself not that complicated) you'll have to solve a few exercises to get 'fluent' or familiar in differentiation. Look at the different methods for different types of equations etc.
Same goes for music theory ;)
Answer: I think the key problem is 'on your own'.
Music is by its very nature something to be shared - both by listener and performer. And since (it appears) you've been learning in isolation (not counting non-personal youtube stuff), you've had little or no input from other musos - apart from that keys player.
You need to be playing, talking, swapping riffs with other musos who wield all sorts of instruments. Their input will help your playing and give you different aspects on what their instruments can do. Obviously (as in comment) a teacher will do that job even better, but that's often not a viable option for many diverse reasons - whereas finding someone to play with is usually easier - and cheaper!
As far as theory is concerned, you'll learn a lot by just playing, although the technicalities of that will be denied as you'll be working on the principle of 'if it sounds good...', which is actually the criterion which works well.
Given more exact goals may elicit more exact answers!

I’ve been playing guitar for about a year, and learning music production and attempting keyboard and violin


Recommended Mutual Information Estimator for Continuous Variable

Question: The mutual information seems to be quite an interesting measure of the relationship between variables. As such I wanted to apply it to investigate the relationship of two continuous variables $X$ and $Y$ for which I only have a hundred observations. In particular, I would like to obtain a normed version of the mutual information such that it is $1$ in the case of perfect dependence. I guess this means that the entropy of $X$ and $Y$ also need to be estimated.
After doing some research, I realized that estimating the (unnormalized) mutual information of two continuous variables is highly nontrivial. As a result, multiple competing approaches exists. Khan et al (2007) provides an overview of some of them. This paper also compares multiple approaches under different settings and makes recommendations when to use which approach. However, this paper is already 12 years old and since then new estimators have been developed; for example, Belghazi et al (2018). So, is anybody active in this field and can provide a recommendation which estimator is currently to be preferred (in which situation)? Ideally, I would also like to obtain a confidence interval for the normed mutual information.
Answer: I am not sure i understand why this should be a very hard problem, at least in such a low-dimensional setting as you describe. I am not active in the fields of those who have authored the articles you cite, but I do not see why this could not be framed as a relatively simple statistical problem. An idea you could (perhaps) follow, is to relate it to the copula of $X$ and $Y$. The mutual information of $X$ and $Y$ is the Kullbach-Leibler divergence of their actual joint density $f(x, y),$ and their joint density under the assumption of independence $f^*(x, y) = f(x)f(y).$ If you write $$F(x, y) = C(F(x), G(y)),$$ (where $C$ is called a copula, and this is for a continous bivariate random vector a unique representation) such that $$f(x, y) = c(F(x), G(y))f(x)g(y),$$
where $c(u, v) = \frac{\partial C}{\partial u \partial v}(u, v)$ is the copula density of $X$ and $Y$,
then their mutual information can be written as
\begin{align*}
I(X, Y) &= \underset{\mathbb{R}^2}{\int\int}\log\left(\frac{f(x, y)}{f(x)f(y)}\right)f(x, y)dxdy\\
&=\underset{\mathbb{R}^2}{\int\int}\log\left(c(F(x), G(y)\right)c(F(x), G(y))f(x)f(y)dxdy\\
&=\underset{\mathbb{I}^2}{\int\int}\log\left(c(u, v)\right)c(u, v)dudv\\
&= \mathbb{E}_{C}\left(\log\left(c(U, V)\right)\right).
\end{align*}
I would suggest to use the semiparametric approach where you first compute the so called pseudo observations $\hat F(x) = \frac{1}{n-1}\sum_{i=1}^nI(x_i < x),$ $\hat G(y) = \frac{1}{n-1}\sum_{i=1}^nI(y_i < y),$ and then try to find some parametric copula $C_\theta$ that fits well to $(U^*, V^*) = (\hat F(X), \hat G(Y)).$ Then, you can estimate the mutual information by computing the integral above by numerical integration, or Monte Carlo methods, replacing $c$ and $C$ by $c_{\hat\theta}$ and $C_{\hat\theta}.$ If you estimate $I(X, Y)$ by sampling from the estimated copulas, you could get a confidence interval by repeatedly doing this based on, say, $100$ samples from $C_\hat\theta,$  and then
using empirical quantiles of these estimates.
I am not sure about a normed mutual information. I do not know if it is possible to compute bounds on the mutual information, and I am not sure how to compute the mutual information between two perfectly dependent random variables, as this would correspond to computing the expectation of the log-copula density of either of $M(u, v) = \min(u, v)$ or $W(u, v) = \max(u + v -1 , 0),$ which do not exist as these are not absolutely continous probability measures.
Comment: Thanks for the elaborate answer!! I guess with highly nontrivial I meant that finding an estimator that is optimal seems to be hard as there are so many alternatives. Finding an estimator seems to be relatively easy, as you have just demonstrated. I have to admit that I can't fully follow your suggestion as I am not familiar with copulas. However, using copulas for estimation was also suggested by https://www.sciencedirect.com/science/article/pii/S1007021411700086#cesec40. Other suggestions include using kernel density estimation and binning. The question is which of those should be preferred.
Comment: What advantages does this method have over simply trying to estimate the joint density by kernel density estimation?
Comment: It does not necessarily have any advantage over kernel density estimation. However, kernel density estimation tends to require a lot of data, especially if the data comes from a random variable without bounded support. Therefore, if the model assumptions you make to transform this problem into a simpler, one (or maybe two)-parameter estimation problem are not too restrictive, you could get a better estimate.
Comment: @develarist I found a paper [(Ma, Jian, and Zengqi Sun. "Mutual information is copula entropy." Tsinghua Science & Technology 16.1 (2011): 51-54.)](https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=6077935) that explores this relationship, and I posted two questions about it [1](https://stats.stackexchange.com/questions/510992/copula-entropy-calculation-is-borked) [2](https://stats.stackexchange.com/questions/511088/mutual-information-relationship-to-copula-entropy-is-borked).
Comment: is it correct to say that **mutual information** measures the **entropy of a copula**?


Principled Method for Reweighting Labels Based on Labeler Consistency?

Question: I have a large dataset where each datum has been labeled by multiple raters, and each rater has labeled multiple datums. Rather than assigning to each datum the naive average of all of the labels assigned to it by different raters, I thought it would be better to take a weighted average according to some measure of each rater's "reliability".
As a proxy for "reliability" I'm planning on using some measure of how often a given rater agrees with other raters, but am wondering how best to:

Quantify this consistency of rater agreement
Transform these consistency values into label weightings
Answer: I found that the Concordance Correlation Coefficient does what I need. For anyone else with a similar question, I recommend the wikipedia page on Inter-rater Reliability.


Limit with polar coordinates $ \lim_{(x,y) \to (0,0)} \frac{x^3y}{x^4+y^2} = 0$

Question: I need to prove that
$$ \lim_{(x,y) \to (0,0)} \frac{x^3y}{x^4+y^2} = 0$$
I'm using polar coordinates
$$\lim_{\rho \to 0} \frac{\rho^4\cos^3(\theta)\sin(\theta)}{\rho^2(\rho^2\cos^4(\theta)+\sin^2(\theta))} = \lim_{\rho \to 0} \frac{\rho^2\cos^3(\theta)\sin(\theta)}{\rho^2\cos^4(\theta)+\sin^2(\theta)} $$
From that point I can't find a function $g(\rho)\to 0$ for $\rho\to0$.
$$|\frac{\rho^2\cos^3(\theta)\sin(\theta)}{\rho^2\cos^4(\theta)+\sin^2(\theta)}|\leq\frac{\rho^2}{\rho^2\cos^4(\theta)+\sin^2(\theta)}$$
This is where I get stuck. Thank you in advance for your help!
Comment: Compare with [this](https://math.stackexchange.com/q/753381/11619) or possibly [this](https://math.stackexchange.com/q/1442771/11619). Using polar coordinates works on many occasions, but sometimes it leads to a mess.
Answer: I would use the AM-GM inequality:
$$x^4+y^2\geq 2x^2|y|$$ so
$$\frac{|x|^3|y|}{x^4+y^2}\le \frac{|x^3||y|}{2x^2|y|}=\frac{|x|}{2}$$ and this tends to zero.
Comment: What do you mean by your last comment?
Comment: I think using polar coordinates is not the best way.
Comment: Can you please help me understand if I can reach that same result in polar coordinates?
Comment: The solution using this theory is deleted.
Answer: The proof with polar is messy, but I will finish it, and then provide an alternative approach.

Polar Approach:
The key is to consider the cases when $\sin^2(\theta)<\rho$ and $\sin^2(\theta)\ge\rho$.
When $\sin^2(\theta)<\rho$ we have
$$\frac{\rho^2|\cos^3(\theta)\sin(\theta)|}{\rho^2\cos^4(\theta)+\sin^2(\theta)}<\frac{\rho^3|\cos^3(\theta)|}{\rho^2\cos^4(\theta)}=\frac\rho{\sqrt{1-\sin^2(\theta)}}<\frac\rho{\sqrt{1-\rho}}\to0$$
When $\sin^2(\theta)\ge\rho$ we have
$$\frac{\rho^2|\cos^3(\theta)\sin(\theta)|}{\rho^2\cos^4(\theta)+\sin^2(\theta)}<\frac{\rho^2}{\sin^2(\theta)}\le\frac{\rho^2}\rho=\rho\to0$$
Hence the limit is $0$, independent of $\theta$.

Alternative Approach:
Polar relies on $\rho^2=x^2+y^2$, which, in this case, results in a fairly messy expression. Alternatively, we can let $\rho^2=x^4+y^2$ to match our denominator. We thus have the inequalities $\rho^2\ge x^4$ and $\rho^2\ge y^2$, or $|x|\le\sqrt\rho$ and $|y|\le\rho$ (since $\rho>0$). Then we have
$$\frac{|x^3y|}{x^4+y^2}\le\frac{(\sqrt\rho)^3\rho}{\rho^2}=\sqrt\rho\to0$$
which is a much cleaner proof.


Validar mensagem lida ou não lida

Question: Criei um sistema de email. Agora pretendo verificar as mensagens lidas (aparecem sem bold) e não lidas (aparecem a bold) pelo utilizador.
Crio a tabela com os emails desta forma:
<?php
while($row = mysqli_fetch_array($result))
 {
?>

            De
            Assunto
            Prioridade
            Recebido

        Recebido: <?php echo $row["Data"]; ?>

        <?php echo $row["De"]; ?>
        <td class="td-info view_data" id="<?php echo $row["Id"]; ?>" data-toggle="modal" href="#dataModal" width="20%" style="font-weight:bold" <?php echo $row["Status"] != '1'?' Normal ':' negrito '?>><?php echo $row["Assunto"]; ?>
        <?php echo $row["Prioridade"]; ?>
        <?php echo $row["Hora"]; ?>

        <?php
        }
        ?>

Para ler o conteúdo da mensagem clico nesta td e abre um modal:
<td class="td-info view_data" id="<?php echo $row["Id"]; ?>" data-toggle="modal" href="#dataModal" width="20%" <?php echo $row["Status"] == '1'?' style="font-weight:bold" ':' style="font-weight:normal" '?>><?php echo $row["Assunto"]; ?>

Ao abrir o modal com o click faço update na coluna Status da tabela da base de dados de 1 para 0, para ficar como lida e na td acima faço essa verificação da seguinte forma:
width="20%" <?php echo $row["Status"] == '1'?' style="font-weight:bold" ':' style="font-weight:normal" '?>

o JavaScript para abrir o modal e fazer o update:
$('.td-info').click(function(){
    var item_id = $(this).attr("id");
    var status = $(this).attr("Status");
      $.ajax({
        url:"./fetchRAD",
        method: "POST",
        data:{item_id:item_id, status:status},
        success:function(data){
                }
      });
    });

Mas o problema, é que ao mudar o valor do Status para 0, se for um utilizador diferente também já vai mostrar como lida a mensagem. Então pretendia fazer esta verificação do lado do cliente e não do lado da base de dados.
Tabela para registar mensagens:
CREATE TABLE `Alertas` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Tipo` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Prioridade` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Email` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Para` longtext COLLATE utf8_unicode_ci,
  `Assunto` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Conteudo` longtext COLLATE utf8_unicode_ci,
  `Recebido` datetime DEFAULT NULL,
  `De` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Utilizadores que podem receber em grupo ou individualmente:
CREATE TABLE `testeCol` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Colaborador` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Grupo` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=149 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Tabela para preencher o status como lida:
CREATE TABLE `ValAlertas` (
  `IdVal` int(11) NOT NULL AUTO_INCREMENT,
  `IdSMS` int(11) DEFAULT NULL,
  `Para` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Status` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`IdVal`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Answer: Sugiro que você crie na tabela do banco a coluna que diz o status da mensagem(Lida ou Não-lida). E na tela de exibição das mensagens utiliza um filtro e verifique se no banco diz se a mensagem foi lida, exemplo:
<?php if($row['status'] == 'lida'): ?>

        <?php echo $row["De"]; ?>
        <td class="td-info view_data" id="<?php echo $row["Id"]; ?>" data-toggle="modal" href="#dataModal" width="20%" style="font-weight:bold" <?php echo $row["Status"] != '1'?' Normal ':' negrito '?>><?php echo $row["Assunto"]; ?>
        <?php echo $row["Prioridade"]; ?>
        <?php echo $row["Hora"]; ?>

<?php else: ?>

        <?php echo $row["De"]; ?>
        <td class="td-info view_data" id="<?php echo $row["Id"]; ?>" data-toggle="modal" href="#dataModal" width="20%" style="font-weight:bold" <?php echo $row["Status"] != '1'?' Normal ':' negrito '?>><?php echo $row["Assunto"]; ?>
        <?php echo $row["Prioridade"]; ?>
        <?php echo $row["Hora"]; ?>

<?php endif; ?>

Comment: Sim, dessa forma eu já tinha feito, o problema é que existem vários usuários, o primeiro ao ler troca o campo de status para lida e depois todos vão receber a mensagem como lida, e na verdade só o primeiro usuário leu
Comment: Pera aí? a mensagem é compartilhada?
Comment: Sim, a mensagem é para vários utilizadores, podem haver situações em que não depende dos utilizadores que selecionam o envio. O ideal era validar do lado do cliente e não em base de dados
Comment: No entanto no Client-side não tem como "Salvar" o ideal é que vc salve no banco com uma tabela. exemplo: tabela "leitura-usuário" que teria 4 campos: id, user_id, mensagem_id, status.
Caso o usuário 2 leia a mensagem 15 vc salva id=x; user_id=2; mensagem_id=15; status="lida".
Comment: Sim essa forma é a que estou a fazer, mas surge outro problema. A mensagem pode ser enviada para usuários específicos ou então para um grupo. Esse grupo refere-se por exemplo a 4 usuários, nesta situação vou ter o mesmo problema. Pergunto, eu ao selecionar o grupo, depois quando faço o insert é possível inserir uma linha para casa usuário que pertence aquele grupo?
Comment: Seria interessante se você editasse a pergunta e explicasse mais sobre seu projeto, bem como a estrutura do seu banco.
Comment: editei a pergunta com a informação completa
Comment: Vamos [continuar esta discussão no chat](https://chat.stackexchange.com/rooms/91665/discussion-between-bruno-and-vinicius-de-jesus).
Answer: Isso resolve:
De

Comment: é isso que pretendo, mas só existe um problema, sempre que atualizo a página volta a ficar negrito e não devia, depois de clicar uma vez, mesmo que atualize a página já não devia aparecer a negrito
Comment: Sugiro então que você salve a condição da Td no banco. no entanto cada td deveria ter um id.

Validar mensagem lida ou não lida


Como recuperar a URL da página anterior ASP

Question: Galera, boa tarde.
Gostaria de saber se alguém tem alguma dica para eu pegar a URL da página anterior no seguinte cenário:

Uma página MVC tem um link para uma página ASP
Clicar no link
Abre a página ASP
** Neste momento, como faço para guardar a URL da página MVC?

Obg!
Answer: Via JavaScript você pode usar:
var paginaAnterior = document.referrer;

Se optar capturar pelo ASP Clássico
paginaAnterior = Request.ServerVariables ("HTTP_REFERER")


Calculating parameters for a mixture of beta distributions

Question: I have two beta distributions with known parameters:
x <- seq(0,1.0,0.01)

mu1 <- 0.348
mu2 <- 0.619
var1 <- 0.017
var2 <- 0.028

alpha1 <- ((1-mu1)/var1 - 1/mu1)*mu1^2  # constrained to be greater than 1
beta1 <- alpha1*(1/mu1 - 1)
alpha2 <- ((1-mu2)/var2 - 1/mu2)*mu2^2  # constrained to be greater than 1
beta2 <- alpha2*(1/mu2 - 1)

betad1 <- dbeta(x, alpha1, beta1)
betad2 <- dbeta(x, alpha2, beta2)

plot(x,betad1,ylab="density",col='green')
points(x,betad2,col='blue')

(I didnt manage to insert my graphical outpout but it should be straighforward to plot)
I would like to do two things,

Plot the mixture distribution formed by betad1 and betad2
Find a set of single beta and alpha parameters (or mu and sigma) giving the best representation of this mixture.

For point number 1, I tried the method shown in this post, which is very useful but mixdist does not allow for beta distributions to be used: is there an similar package for a beta densities mixture?
For point number 2, I believe the best thing I can do is to "approximate" the bimodal mixture with a unimodal beta pdf, and calculate its parameters. I am unsure what is the best approach for this.
Alternatively, is there there a standard way to characterize a mixture with a single set of parameters?
Answer: As for item 1 you still need to specify the mixture weights, say a 50:50 weighting:
plot(x, 0.5 * betad1 + 0.5 * betad2, ylab = "density", type = "l")
lines(x, 0.5 * betad1, col = 3)
lines(x, 0.5 * betad2, col = 4)

Or as a different example with 25% and 75% weights, respectively:
plot(x, 0.25 * betad1 + 0.75 * betad2, ylab = "density", type = "l")
lines(x, 0.25 * betad1, col = 3)
lines(x, 0.75 * betad2, col = 4)

Possibly, the betareg package will also be useful for you. This supports estimation of finite mixtures of beta-distributed variables in function betamix(). See: http://www.jstatsoft.org/v48/i11/.


parameters of bidirectional LSTM

Question: I am new to LSTMs and also bidirectional lstms. I am trying to implement a model described in a scientific article. It says that the bilstm model has a layer size of 200 and number of hidden layers is 2. I think for the hidden layers I have to add 2 bilstm layers top of each other. But I can not understand what author means by layer size. Is this same as units parameter for keras.layers.lstm?
Answer: Yes, the 'layer size' is the hidden dimension within the LSTM—the size of the hidden state. The Keras toolkit calls that units in keras.layers.lstm.

parameters of bidirectional LSTM


Remove a specific string inside a string in Excel

Question: In Excel, I have the following strings:
U##########

B##########

############ (Last two digits are term indicator)

############ (Last two digits are term indicator)

OLF####### or OLTD####### or OLF######### (Last two digits are the term indicator) or OLTD######### (Last two digits are term indicator) or

OICF######### (Last two digits are term indicator) 09-##########-## (Last two digits are the term indicator)

OL######## or OLT####### or OL######### (Last two digits are the term indicator) or OLT######### (Last two digits are the term indicator) or OIC########## (Last two digits are the term indicator)

UDC_#######_##_01 or  UDV_#######_##_01 or UWD_#######_##_01 (11th & 12th digits are the term indicator)

My objective is to remove the mid strings or end strings that are enclosed in parenthesis. ie. (Last two digits are term indicator).
I am looking for a formula or vb code that will help me to remove these strings that are enclosed in paranthesis. Thanks in advance.
Answer: One would need TEXTJOIN and FILTERXML, both are newer formula and may not be available in all versions:
=TRIM(SUBSTITUTE(TEXTJOIN(" ",,FILTERXML(""&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"&","|"),"(",""),")","")&"","//b[string-length(.)>0]")),"|","&"))

As per @JvdV we can shorten it using &
=TRIM(TEXTJOIN(" ",,FILTERXML(""&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"&","&"),"(",""),")","")&"","//b[string-length(.)>0]")))

Comment: Yeah if you ever need to use it somehow in a string-check, use `&` [instead](https://stackoverflow.com/q/38416042/9758194). Btw. you can get the same result with `"//b[node()]"`. The times `FILTERXML` is helpfull...=)
Comment: I tried this and it works very stange. I entered the formula on the first cell (B2) and entered it. and then when I double click on the lower right corner to copy the formula, the same string (ie. if first cell A2 contains ####&&######, then that is the same value on other cells B2:B250 where the formula is copied) is repeated on the other cells. When I go to the next cell (ie. B3) and inspect the formula and hit enter, then i am getting the correct string (ie. if A3 contains ####&_######, then B3 also contains ####&_######....before that B3 was  ####&&######)
Comment: You may have your calcs not set to automatic.  Try hitting F9.
Comment: Nice Scott! + =)
Comment: @JvdV took me a good 20 minutes to figure out that FILTERXML does not like `&`.


Looking for a good user/group configuration for sites on apache httpd server

Question: we have a setup where various persons develop on their local machines, to later commit the changes to a local server repository.
In order to sync the changes to our external production server, we run a script which rsyncs a local subversion export to it.
We face a problem doing this sync, because in order to work, the user doing the sync on the remote server need to be the owner of the remote files.
Our solution was:
Create a user on the remote server (siteowner)
Giving him the ownership of the site (chown siteowner.siteowner /var/www/site)
Adding apache to the group of the siteowner (we had some problems with htaccess checks, and we can't chown siteowner.apache because when rsync does the sync it changes the permissions to siteowner.siteowner)
My question is... this setup seems reasonable? Do you know any other better one? Thanks in advance!
Answer: we use the following workflow for our PHP based websites.
Users commit their work to Subversion. We don't allow developers to manually deploy code to Staging and Live. Why not to staging? Because we want it to closely simulate Live.
Deployments are done via Webistrano, which is a web frontend to the well-known and powerful Capistrano deployment tool. We've created so-called recipes that script the deployment. It does approximately the following:

Webistrano logs into the server via ssh as user 'deploy'
It updates a remote working-copy cache
It copies the resulting working-copy to a releases// folder, using hardlinks (to save diskspace and for speed).
Symlinks customer-data (i.e. files not stored in subversion) to the proper locations.
The new release is chmodded to 775 to give the group write permissions.
If all the above steps succeeded it changes the 'current' symlink to /releases// folder.
It performs an 'apache2ctl graceful' to flush any caches (such as php's realpath() ) that are still caching the previous release.
If more than a certain number of releases are stored, the oldest one is purged.

The webserver is configured so the docroot of the virtual host points at the 'current' symlink, so during the deployment the old site is visible, and after successful deployment the new site appears instantly.
Code is owned by deploy:deploy but customer-data directories are owned by deploy:upload and have their SGID bit set at creation.
Apache's www-data user is a member of groups 'deploy' and 'upload'. Developers have personal scp accounts on the server and are members of group 'upload'. This setup works very well for us, since developers can't interact with the code except via Webistrano. It prevents 'live quickfixes' except by admins and has reduced accidents tremendously. Webistrano's built-in rollback feature makes it quick to revert a faulty deployment.
Developers are given write access to the customer-data dirs (because of the upload group), so they can upload placeholder content or help the customer prefill the site. After all, no customer content is stored in svn. The SGID bit on the directories make sure that only the user ownership of uploaded files is set to the user doing the uploading (providing a bit of accountability). The group ownership remains set to 'upload' by the SGID, so that Apache or other developers can still read-write the files and directories created.
The clear Webistrano interface has proven very useful, and since Capistrano comes with most of the above functionality built-in, our deployment recipes are only two dozen lines. Most of that is overriding Ruby-on-Rails specific defaults.
Comment: I'm using Webistrano but the project has been slowly sinking, no new commit in 10 months. Do you still use Webistrano and if not, can you tell us what you use now ?
Comment: Shadok, we still use Webistrano. I'm a bit worried about the stagnation. Pull requests are not being accepted, etc. I've recently cloned its Git repo on GitHub and added some of our few customizations. This should allow us to keep using it as long as our needs don't change. I look forward to suggestions about similar products though. Webistrano was just what we needed.
Answer: you can reconsider the workflow this way :

Every people is able to commit to the SVN server AND instead of playing with apache rights, create a user on the production server and add a SFTP server.
Everyone work on their files, and when the commit to the SVN server is done, they use their SFTP client to put in production their files.(Because the'll all use the same user you won't bother with rights)

Actually, before putting in production, you should have an extra server for pre-production.
Before every commit to the production server, they'll add their files to the pre-production server which must be ideally the exact replication of the production server.
When changes are validated, they can put in production the files.


Ukulele prodigy said Do-Re-Mi-Fa-Sol took him three months to learn - what does this mean?

Question: In this video, at around 18 seconds, ukulele guitar prodigy Feng E said his father taught him how to play ukulele, and he learned Do-Re-Mi-Fa-Sol in three months, which, according to him, might be a new world record.
Surely, this kid might be a new world record. But I am somehow baffled by specifically this statement about Do-Re-Mi-Fa-Sol - what does it mean?
Do-Re-Mi-Fa-Sol are the first five notes of a major scale (movable do), or of the C major scale (fixed do) - learning to sing them is, I guess, easy. So, what he could have meant when saying he learnt Do-Re-Mi-Fa-Sol?
Comment: I think it's sol.  And three months is a long time to learn those 5 notes.
Comment: Maybe he meant he learnt where all the five notes are on the neck or maybe he learnt all the positions on the neck for all the five major chords. But it is all guessing; after all you have to take into consideration that a child prodigy is still a child and you where reading a translation from a language whose meaning nuances are not always easy to translate.
Comment: That may be his way of saying he learned to sing solfege in 3 months...
Comment: But singing a major scale is easy, even people with no formal music training can do it ... so what's the point...
Comment: Yeah, I doubt there is a deeper meaning here. I guess another possibility, allowing for the difference in languages, could be that he learned the "Do-Re-Mi" song from *The Sound of Music.*
Comment: I don't quite get it, maybe he did an entire solfege course...or maybe his dad is easily impressed.
Comment: He's definitely an exceptional talent - but saying he is proud to do solfege (in three months), it is like... dont know... Neil Armstrong saying he is proud he can jump up a single staircase with his bare feet, or Steven Spielberg announcing he is able to hold a camera, or Linus Torvalds that he can type a word on a keyboard, or... anyway
Comment: Seems like total bs to me.
Comment: There's no denying he plays uke well. But where's solfege?
Answer: In China, the most commonly used method for referring to musical notes is to use the solfege syllables, ("do re mi" in Western music); however, they do understand and use Western notation. So I think he means sight-reading, hence the Guinness reference.


Calculate median for count data

Question: I've got data that looks like this:
<code>            Salary category  Count      Sex Year   Profession
1                   aa 0,00    842        M 2014   Arts (= doctor)
2       ab 0,01 / - 2500,00    454        M 2014   Arts
3    ac 2500,00 / - 5000,00    256        M 2014   Arts
4    ad 5000,00 / - 7500,00    218        M 2014   Arts
5   ae 7500,00 / - 10000,00    222        M 2014   Arts
6  af 10000,00 / - 12500,00    245        M 2014   Arts
7  ag 12500,00 / - 15000,00    266        M 2014   Arts
8  ah 15000,00 / - 17500,00    289        M 2014   Arts
9  ai 17500,00 / - 20000,00    250        M 2014   Arts
10 aj 20000,00 / - 22500,00    268        M 2014   Arts
11 ak 22500,00 / - 25000,00    277        M 2014   Arts
12 al 25000,00 / - 27500,00    344        M 2014   Arts
13 am 27500,00 / - 30000,00    473        M 2014   Arts
14 an 30000,00 / - 32500,00    502        M 2014   Arts
...
</code>
So I have a bunch of salary categories, sex, the year in which the salary was reported, and profession (doctor or veterinarian). I'm interested in differences in income. Given the way the data are arranged, it's a bit tricky to just fit a model. I'd like something that looks like this:
<code> Income ~ (sex + profession + year)^3
</code>
One way we thought up of reaching an dependent variable that was easier to work with, was to take the middle point of each interval (each salary category), multiply it by the count, adding all these values up for each category of sex, year and profession, and dividing it by the total number of people in the category. That way, we get a mean income per category (e.g. male vets in 2003).
Question 1) Is this a valid approach? Are there better ways of going about this?
Second, instead of taking the mean for each category, we were advised to look at median values instead. The data are indeed skewed, so this might be a better approach. But getting a median out of a bunch of count data is pretty complex. Therefore:
Question 2) Suppose we use the midpoint of each salary interval, how would we go about calculating a median value for each category in R? It's straightforward in essence, but I'm having trouble whipping up code to do it automatically for each category.
Comment: Note that this was migrated because we judged Question 1 to be more important and difficult. The second question is trivial in comparison and can be asked as a separate question on Stack Overflow when Question 1 is answered. Questions shouldn't be combined like that anyway.
Comment: Notice that (midpoint $\times$ count) / count does reduce to midpoint.  If my income category is 7, no other information about me will tell you any different.
Comment: I'd go straight for some kind of ordinal response model here. Replacing income bands by supposed incomes will just create uncertainties for which you have to undertake sensitivity analysis, especially what you do for your highest category, which is likely to create outliers.
Answer: Question 1) All approximations are 'valid' in some sense and 'invalid' in another sense. Rather than looking at validity, it helps to have an idea of what specific problem this approximation will cause you.
For example, suppose you knew that income was actually uniformly distributed within each group (that is, taking the 256 people in line 3, one earns 2,500, another 2,510, another 2,520, and so on). Then collapsing each group down to the midpoint will only barely affect the overall slope (because the midpoint is roughly equal to the mean), but will dramatically affect the estimate of $R^2$ and slope uncertainty.
However, if you have data that's skewed within each group (suppose the underlying income distribution is exponential, for example), then using the midpoint as a proxy of the mean will overestimate the actual mean for the group, shifting the data rightward. If it's exponential, the overestimation will be roughly the same for each group--and so the intercept is affected, but not the slope. If it's a distribution where the difference between midpoint and mean varies by region, then it could also affect the slope.
Your second part of this question seems unclear to me--how are you distinguishing between midpoint, mean, and median? It looks to me like you only have access to the first, and if you're estimating the median, you're likely using a distribution that you're better off using directly.
Which leads to:

The approach I would try is to come up with some underlying model. Maybe incomes are a mixture of a lognormal and a point mass at \$0. For any parameter vector for that distribution (here a triplet with $\mu$, $\theta$, and $p_0$), we can calculate the probability that a sample from that distribution will have the counts in the table. Find the MLE, and you're done.
But it looks like we want to estimate those parameters from the category labels--that is, we expect $\mu$ to depend on sex and year and so on. So then we can either fit a model to the MLE parameters (easy) or do a joint optimization for total likelihood (somewhat harder, but still doable).
Comment: The bands are quite narrow so replacing all by the mid-point might not be too bad. If the top category is open-ended then life may be hard.

Calculate median for count data


Sum of columns in list of objects

Question: My Problem is like below:. I have List Of Objects. I need to add column x2 with same column X3 and combine X1 columns. Later removed the old row. Please suggests.
<code>                Input:-

             List<A> list = new ArrayList<>()
            A A1 = new A(X1=111, X2=10, X3= '333')
            A A2 = new A(X1=222, X2=20, X3= '333')
            A A3 = new A(X1=333, X2=2, X3= '444')
            A A4 = new A(X1=444, X2=5, X3= '444')
            A A5 = new A(X1=666, X2=6, X3= '777')

            list.add(A1).addd(A2).add(A3).add(A4).add(A4)

            OutPut should be like below:-
             {
                Object A1 (list = {111,222}, x2= 30 , x3= '333')
                Object A3 (list = {333,444}, x2= 7 , x3= '444')
                Object A5 (list = {666}, x2= 6 , x3= '777')
            }

public class A {
   private long X1;
   private long X2;
   private String X3;
   private List<Long> list;
 }
</code>
Comment: In what context?  How is your program storing all this data currently?
Comment: you want to group by x3 column ? x1 is an array and x2 is an integer ?
Comment: currently my program storing in List variable . After implement some logic, current list should change with new output.
Comment: @user84 `After implement some logic` we need to understand that logic, can you give more explanation about your variables ?
Comment: I have added the class with variables. I am looking for that logic only.
Comment: Okay, so you want to loop through the list and if X3 values are the same they should be combined so that X1 values are put into a list and X2 values are added together?
Comment: @Tim Hunter, thats true.
Comment: What value would `X1` have in the resulting combined object?
Comment: X1 should be null
Comment: So `X1` is `Long`, not `long` then?
Comment: once we are gettting "List list" under each A object. we don't require X1. we can make 0 also.
Answer: Try this (java 8+), with A as a mutable object (which i do not like):
<code>        List<A> objects = new ArrayList<>();

        A A1 = new A(111, 10, "333");
        A A2 = new A(222, 20, "333");
        A A22 = new A(222, 20, "333");
        A A3 = new A(333, 2, "444");
        A A4 = new A(444, 5, "444");
        A A5 = new A(666, 6, "777");

        objects.add(A1);
        objects.add(A2);
        objects.add(A22);
        objects.add(A3);
        objects.add(A4);
        objects.add(A5);

        List<A> output = objects
                .stream()
                .collect(Collectors.collectingAndThen(
                        Collectors.toMap(A::getX3, a -> {
                            a.getList().add(a.getX1());
                            return a;
                        }, (a, b) -> {
                            a.getList().addAll(b.getList());
                            a.setX2(a.getX2() + b.getX2());
                            return a;
                        }),
                        map -> new ArrayList(map.values())
                ));

        System.out.println(output);
</code>
and the output shows:
<code>[A(X1=111, X2=50, X3=333, list=[111, 222, 222]),A(X1=333, X2=7, X3=444, list=[333, 444]),A(X1=666, X2=6, X3=777, list=[666])]
</code>
Comment: Thanks for solution. i think, a.getList() would be null initially . "a.getList().add(a.getX1())" will  give null pointer exception? any thoughts?
Comment: Ah sorry for my solution i had to initialize it with ˋList list = new ArrayList()ˋ
Answer: Perhaps you're looking for something like this? This can definitely be simplified, but I think it has the output you have in mind. Be sure to break it down to understand how it works so you can do it yourself in the future.
<code>  public static void main(String[] args) {
    List<A> vals = new ArrayList<>();
    vals.add(new A(111, 10, "333"));
    vals.add(new A(222, 20, "333"));
    vals.add(new A(333, 2, "444"));
    vals.add(new A(444, 5, "444"));
    vals.add(new A(666, 6, "777"));

    List<Output> outputs = getOutput(vals);
    for(Output output : outputs) {
      System.out.println(output);
    }
  }

  public static class Output {
    public List<Long> X1 = new ArrayList<Long>();
    public long X2;
    public String X3;

    //Set initial values
    public Output(A value) {
      X1.add(value.X1);
      X2 = value.X2;
      X3 = value.X3;
    }

    //Add additional values
    public void addValue(A value) {
      X1.add(value.X1);
      X2 += value.X2;
    }

    @Override
    public String toString() {
      return "X1: " + X1.toString() + ", X2: " + X2 +", X3: " + X3;
    }
  }

  public static class A {
    public long X1;
    public long X2;
    public String X3;

    public A(int x1, int x2, String x3) {
      X1 = x1;
      X2 = x2;
      X3 = x3;
    }
  }

  public static List<Output> getOutput(List<A> vals) {
    //Create return list
    List<Output> outputList = new ArrayList<>();

    //Copy given array
    List<A> values = new ArrayList<>(vals);

    while(!values.isEmpty()) {
      //Grab first value and remove it from list copy
      A value = values.get(0);
      values.remove(0);

      //Create output object
      Output output = new Output(value);

      //List for deleting objects processed
      List<A> deletionList = new ArrayList<>();

      //Process the rest of list to look for matching X3 values
      for(A otherValue : values) {
        if (value.X3.equals(otherValue.X3)) {
          deletionList.add(otherValue);
          output.addValue(otherValue);
        }
      }

      //Add output object to return list and remove processed values
      outputList.add(output);
      values.removeAll(deletionList);
    }

    return outputList;
  }
</code>
Comment: Thanks for solution. i can not change output object. It should be "A" not "OutPut".

Sum of columns in list of objects


Mongo db query | Join | Create query on two collection

Question: Select leadId count on two collection in Mongo DB
Collection 1 : leads
{
 leadId:"abc123",
 status:"OPENED",
 stage:"start",
 crossSell:
    {
      cc:
         {
            consent:true,
            shown:[{first:true}]
         }
    }
 }

Collection 2 : pdata
{
 activeLeadId:"abc123",
 status:"OPENED",
 details:
    [
        {
            rating:10
        },
        {
            rating:9
        }
    ]
}

Question : Find leadId count from leads collection join with pdata collection based on below conditions

leads.leadId = pdata.activeleadId and
leads.status = "OPENED" and
leads.crossSell.cc.consent = true and
leads.crossSell.cc.shown[0].first = true and
pdata.details.rating >= 5
Comment: what is the expected output in json? you want to unwind the arrays first and then do the lookup? or you want lookup with the arrays as they are? for example rating>=5 what it means? array to have at least one >=5, all >=5 or unwind and keep those that >=5?
Comment: Which `status` should be `"OPENED"`? Which or how many `rating`s in the `details` array need to have a value of `5` or higher?
Comment: @Takis expected output is count, I mean howmany records are available with matchin conditions. the array to include in condition which have at least one rating >=5
Comment: @user20042973 I have updated question, at-least one rating in details should have value >= 5
Answer: You can try a aggregation query,

$match your conditions for leads collection
$lookup with pdata collection, pass leadId to match with pdata
match required conditions for pdata
$limit to return single document, because we don't need that data in response
$match condition to check is pdata is not empty
$count to get total number of records

db.leads.aggregate([
  {
    $match: {
      status: "OPENED",
      "crossSell.cc.consent": true,
      "crossSell.cc.shown.first": true
    }
  },
  {
    "$lookup": {
      "from": "pdata",
      "let": { "leadId": "$leadId" },
      "pipeline": [
        {
          $match: {
            $expr: { $eq: ["$$leadId", "$activeLeadId"] },
            "details.rating": { $gte: 5 }
          }
        },
        { $limit: 1 }
      ],
      "as": "pdata"
    }
  },
  { $match: { pdata: { $ne: [] } } },
  { $count: "count" }
])

Playground
Comment: 'shown' in leads collection and 'details' field in pdata are array. can we use 'details.rating' on array.
Comment: This is not giving output. Query is always giving output 1 even for "details.rating": { $gte: 20}
Comment: can you provide example documents, that give an output of more than 1 count? you can add documents in the above playground and share the link.
Comment: I have added more documents. https://mongoplayground.net/p/GD6jXrV1MVK
Comment: What is the expected count for these documents?
Comment: expected count is 2


Do triads sound strongest in second inversion?

Question: On Mark Levine's Jazz Theory book, on Chapter Five, Slash Chords, it says:

Although triads can sound good in any inversion, all things being equal triads sounds strongest in second inversion.

Then there are some examples of slash chords, with C as the bass and all the major triads that can be played on top of it (1). All of them are in second inversion and then there is the aforementioned quote.
(1):

But why do triads sound strongest in second inversion?
Edit: With slash chords, the author isn't referring just to inversions. The example above shows any major triad that can be played over a C note. For instance, the E/C refers to the Lydian Augmented chord, which can also be written as C maj7 #5.
Comment: @Tim 1st inversion does *not* mean that the tonic is on top. Inversions refer only to which member of the chord is in the bass. All inversions could have the tonic on top if you voice it that way.
Comment: Subjectivity. Mark Levine may think so, I don't. 1st inversion can sound strong as the tonic is on top. There's only 3 options, so why should one sound better, apart from to an individual?
Comment: For those interested, the relevant page can be seen on google books here: https://books.google.com/books?id=iyNQpJ4oaMcC&pg=PT181&lpg=PT181#v=onepage. As @Chris surmised, this appears to be a glaring abuse of the traditional usage of the term "inversion", since it doesn't account for the bass note at all, and only refers to the R.H. voicing. Even more confusingly, he then uses the *correct* definition of inversion a few pages later, when he describes F/C as an F chord "in second inversion".
Comment: @MatthewRead OK, now I'm a bit mystified, there's clearly a terminological difference here that I've never encountered before. I'm not certain what RCM is, is it the Royal Conservatory of Music? What textbook are they getting this from? Kostka/Payne: "the inversion of a triad or seventh chord is determined only by what member of the chord is in the bass." Clen/Marv: "A voicing in which a chord member other than the root is the lowest-sounding pitch"
Comment: "Sometimes I think jazz is just an excuse to do everything wrong." = Dumbest thing on the site so far.
Comment: Also agreed with Tim here - The aural perception of 2nd inversion chords being "strongest" is purely subjective. In actual tradition, they are considered the *weakest* form of triad because of the 4th in the bass, which has been considered since the Baroque to be a dissonant interval.
Comment: I don't know for sure, but I would guess he would describe it that way because it kind of clashes with what we would expect a root position triad to have (3rd and 5th above the bass instead of 4th and 6th). Traditionally second inversion is considered dissonant for that reason.
Comment: Could you post the examples? Because it gets a bit confusing. You mention many major triads with the C on the bass but the only major triad in second inversion would be the F major. I'm suspecting that the author speaks of superimposed triads with the tonic and the third on the top voices.
Comment: More importantly, what about the 95% of cases where harmonies aren't three-note, closely-spaced structures? The beginning of Beethoven's Moonlight sonata has C#-C#-G#-C#-E. What would you call this chord? Second inversion because it has a third on top? Unidentifiable as any inversion?
Comment: Agreed with Pat Muchmore here - it is important to remember the distinctions between *open* and *closed* voicings.  Matthew's example definition could be considered closed voicing, while Pat's include both closed and open voicings. @Matthew - if a triad was E, C, G, would it not still be in first inversion?
Comment: @NeilMeyer using the term 'wrong' in music seems wrong. Isn't everything a bit subjective?
Comment: From the book reference, it's clear he is using "inversion" with some (presumably) jazz-specific meaning. It would be reasonable to conclude that "stable" also means whatever jazz theorists think it means (which is outside of my musical knowledge and interests). In terms of common-practice harmony, the statement is false, since 2nd inversions are either harmonically weak passing-chords,  or are unstable in the sense of requiring resolution.(for example at a cadence).
Comment: @PatMuchmore That's simply not true, the RCM for example defines inversions explicitly as the nearest set of notes meaning that in C Major first inversion you get an E, the G immediately above it, and the C immediately above that -- tonic always on top, you can't skip anything along the way.
Comment: I'll have to agree with Pat here. Inversions have nothing to do with which note is on the top; they only refer to the bass note.
Comment: Sometimes I think jazz is just an excuse to do everything wrong.
Answer: It should be mentioned that throughout the whole book there are three occurrences of the statement that triads sound stronger/strongest in second inversion:

Ex. 1
Ex. 2
Ex. 3

If you look at the context in each of these cases you'll see that Levine always talks about slash chords. In Ex. 1 he talks about a Gsus4 (actually G9sus4) voiced as a F/G chord, where the F triad on top of the G bass note is in second inversion. Ex. 2 is a G/Eb chord, where Levine compares the root position and the second inversion of the G triad. Finally, Ex. 3 is the example stated in the OP with all possible major triads over a C bass note (all of them in second inversion).
So even though it sounds like a general statement, Levine actually always refers to the second inversion as the strongest only in the context of slash chords. And that's a different thing than talking about pure triads, where he might not even agree with that statement. The statement also makes more sense in the context of slash chords because we are already dealing with a different root, so the root position of the top triad does not anymore have its original special significance (as having the chord's root as the lowest note).
Furthermore, looking at the harmonic series for a C root (not bothering about octaves)

1 2 3 4 5 6 ...
C C G C E G ...

we see that the second inversion G C E consists of lower harmonics (3 4 5) than the root position (4 5 6). I'm referring to close voicings here because that's what Levine means when he talks about the second inversion in all three examples. So one could argue that the second inversion in close voicing has some inherent stability IF the root of the triad loses its role due to the existence of another lower root, as is the case with slash chords.
Comment: @NeilMeyer: No, but if you add the context for all occurrences of that statement then it becomes clear that Levine always talks about slash chords with triads on top.
Comment: So the OP was miss quoting him then?
Answer: When Levine refers to a chord as being "stronger" is can also be read as "more stable", as in harmonically stable.
Take the C Major Triad as an example (C, E, G). If you analyze what the intervals are for each inversion (first and second) you can see the following:
First inversion; E is root under G and C
E,G = m3
E,C = m6
G,C = P4
Second inversion; G is root under C and E
G,C = P4
G,E = M6
C,E = M3
According to Paul Hindemith the intervals can be ranked from "strong" to "weak" like so:

1   2   3   4   5   6   7   8   9   10  11  12
P8, P5, P4, M3, M6, m3, m6, M2, m7, m2, M7, dim5

The P8 is strong, whereas the dim5 is weak.
Back to our example; first inversion contains intervals 6,7,3 (m3,m6,P4) while second inversion contains intervals 3,4,5 (P4,M3,M6). According to the interval ranking, second inversion is stronger because it contains more intervals that are towards the "strong" side of the ranked intervals.
Note that according to the interval ranking, a P5 is considered stronger than a P4. This means C,G will be more stable than G,C. Even though they are the same notes, the positioning of the notes determines what is called the order of Combination Tones (also known as Resultant Tones). The first resultant tone produced from a P5 is actually different from a P4.
I can't recall exactly what the notes are anymore; Hindemith maps it all out in his book "The Craft of Musical Composition: Book 1" (ISBN 0901938300).
Comment: But using that system the root would be the strogest as P5 and M3 come before P4 and M6
Comment: I was limiting my comparison to just first and second inversions; you're correct in that root position is the strongest for the reasons you cited. Nice job!
Answer: In general, when we say 2nd inversion we mean that the 5th of the chord is in the bass. However, the author is treating these slash chords as independent major chords superimposed over a C bass note. These particular chords are the ones in 2nd inversion regardless of the C note in the bass.
Moreover, in "close chord position" or "keyboard style" such as in the example, the only possibility of a chord in 2nd inversion would be: the 3rd note of the chord over the root, over the 5th.
Since the most characteristic notes of the triad (i.e. the root and the 3rd) are now in the top voices the result is a chord voicing with a "strong" character.
Comment: Oh, I see what Levine is saying now. Thanks for explaining it! Could you please flesh out your answer a little more, including the comment you added?
Comment: And how does that make the triad sound the strongest?
Comment: @Shevliaskovic I think the term "strongest" is debatable but I find this interpretation, of the tonic and third being on the top voices, to be the most obvious. Do they sound "stronger" relative to their root positions and their 1st inversions to you?


Make docker, registry cache container Use http proxy

Question: I'm trying to setup a caching local registry for docker using official registry:latest Image.
I want to make this container use organizations http proxy for internet access when trying to pull from docker hub.
any help would be appretiated.
P.S you can follow this guide to create a caching local registry.
Answer: After hours of trying different stuff, answering my own question to help others.
sudo docker run -d -p 5000:5000 -v /home/myhomedirectory/test:/var/lib/registry -e http_proxy=http://organizationswebproxyaddress:port/ --name registry registry /var/lib/registry/config.yml

Look at -e switch with -e switch you can pass in environmental variables to the container. In this case im passing http_proxy environmental variable so the container uses my http proxy for accessing the Internet. you can even authenticate if your proxy needs authentication.
Comment: I assumed you had already done this from the line in your original question: "I already tried setting http_proxy inside the container with no luck." Including the commands you were running would have helped debug your problem faster.
Comment: He deleted the line after you pointed it out :D


Configure DNS Server greyed out Windows Server 2008 R2 Standard

Question: Noob question, sorry, but I have Googled, and asked and no one knows.
Basically the option to configure the DNS server is greyed out, along with just about every other option.  The only option available is Launch NSLookup. I tried to submit images but apparently I don't have the reputation points needed. :)
I have removed and added the DNS role a couple of times.  The option to setup the DNS is greyed out.  In fact, just about every option is greyed out.
What should I do? Just trying to set up some simple Alias and MX records. Thanks!
Comment: So you've added DNS as a server role but in server manager it's still greyed out? Have you tried opening the DNS MMC snap-in (dnsmgmt.msc)?
Comment: Also take a look at the event logs, there's one dedicated to DNS. This will hopefully point to the problem.
Comment: Do you have local Admin rights on the server?
Comment: @Chris Thorpe - looked through the event logs, found out the exact time it stopped working.  Looks to be a problem with Active Directory. Couldn't load Active Directory, and then started throwing all sorts of errors.
Comment: @Cheekaleak - Yes I have local Admin, seems to be related to Active Directory, so I am going to attack that angel.
Comment: @Lemb - haven't tried that yet.  Will try that and also try fixing Active Directory today.  Thanks all for your help. We will fix this yet. :)
Answer: Active Directory and DNS are tightly integrated. If you are running AD on this same server, and you've removed the DNS role from the server, you've probably stuffed AD quite badly.
If you have another AD-integrated DNS server in your environment, try setting your server's DNS entries to point to that remote server for its DNS lookups. Once you've done that, AD should be able to come up properly.
Once AD is up properly, you should be able to DCPROMO the server so that it's not a domain controller anymore, and once you've done that, you should be able to install a standalone DNS role without AD integration.
Answer: Is the DNS service started? If not, it needs to be.
Comment: Yes it is started and set to automatic.
Answer: My case is very like yours. In my case, I tried this command:
<code>ipconfig /flushdns
</code>
and then restarted DNS service, and after these I found all back to normal.


Relation between inputs and outputs

Question: I have a problem which I do not know even if it is theoretically possible (not a ML expert):
Assuming that there is a vector of drugs dosages that people take. So the input vector is something like (0.2, .5, 0.4 ...). The output vector should be the of the same length, suggesting better dosages. Is there a machine learning algorithm that can be used for such a problem?
Edit:
There are many input vectors of drug therapy from people that are using same drugs with different dosages and I can tell if the treatment is succefull (it is not binary but it can be).
The output should be a vector with the best dosages where a value of 0 is accepatble. It will be great if I can add gender and age as inputs.
Comment: This is not an answer. You should post this sort of thing as a comment.
Comment: This information is not enough. Do you have a vector of drug therapy outcome, for example, so that you can tell which dosage led to which outcome?
Comment: 10XS! Added more info.
Comment: nmnir, as it was noted there are vast possibilities. If your outcome value is not binary but a continuous or categotical value, you can start with printing scatter plot x ~ y, and trying to estimate a degree of relationship between the two. Take correlation measure, for example.
Comment: Thanks @AlexeyBurnakov at least now I know that it is possible :) Will be grateful for good tutorials.
Comment: Sure, you are welcome. If you prefer MS Excel, start here: http://www.real-statistics.com/correlation/ I personally love this dude for his gentle and deep explanations. I work with R mostly, so I recommend to read something like this: http://www.sthda.com/english/wiki/correlation-test-between-two-variables-in-r
Answer: Many machine learning tasks attempt to discover the relationship between two vectors, X and Y from data containing paired examples of each. In your case you seem to be saying the X is a vector of current doses and Y is a vector of better doses if you happen to be on X already. So you need to ask yourself some questions:
Do I have a reliable set of data pairing examples of current doses to recommended better ones?
Is it reasonable to assume that the second set of doses are dependent to some extent on the first? Perhaps something like "If drug a is at 0.2 and b is at 0.4, then a can be increased to 0.3".
If you answer yes to those questions, you may find ML can help. You sound like you are at the beginning of your learning journey in this field, so find some help or do some reading before you embark on the project in earnest. ML is not a magic solution machine. You need to know what you are doing.
Comment: 10XS. I have read about it and found this http://scikit-learn.org/stable/modules/multiclass.html about Multiclass and multilabel algorithms. Please see my edit. I didn't find any algorithm that optimize the input vector.
Comment: Based on your edit, I can see that you have two tasks to perform. The first is to build a classifier that maps a drug dosage vector, gender and age to the outcome (whether treatment is successful or not). Once you have that, you then have an optimisation task where you use the model to search for a set of input values that cause the output class to become 'treatment successful'. This might be a simple hill climb, or something more complex like a GA.

Relation between inputs and outputs


My question is about reducing camera nervousness

Question: I am about to shoot for my first music video for a big band but am very nervous . I don't wish to spoil the entire song just because of my nervousness ... how can I destress myself or make myself feel comfortable
Answer:
Firstly ensure you know what you're performing inside out. I record and upload piano videos on Instagram and before I press record I play over what I'm going to be recording countless times, so much that I can play it with my eyes shut and without even thinking about it.
Secondly, whilst recording don't think about the camera just enjoy yourself and involve yourself in the music. When I play with my big band in front of an audience, I just forget about the audience and really get into the music and have a laugh with the other trumpeters.
This might seem a bit odd but it's worth a try... meditate. I have an app called headspace that I use before performing because it just chills me out completely.

I think step 1 is the most important, if you know your music inside out you won't be worrying about slipping up and therefore you're also going to be far more relaxed. Knowing the music 'technically' also helps on the performance side of things as it means you can then just concentrate on putting emotion into the music.


Study the converge $\sum_{n=1}^{\infty}(\sqrt[n]{n}-1)$

Question: I need to study the convergence of the series
$\sum_{n=1}^{\infty}(\sqrt[n]{n}-1)$
Now, I know that if we have a series $\sum_{n=1}^{\infty}a_n$ with positives elements and we can find a series $\sum_{n=1}^{\infty}b_n$ so that $0<a_n<b_n$ then if $\sum_{n=1}^{\infty}b_n$ is convergent then $\sum_{n=1}^{\infty}a_n$ is convergent.
Else, if $\sum_{n=1}^{\infty}a_n$ is divergent then $\sum_{n=1}^{\infty}b_n$ is divergent. The problem is I do not really know how to choose the series. Can you help me out?
Comment: Actually, $\sum_{n=1}^\infty\sqrt[n]n$ diverges.
Comment: $$\lim_{n\rightarrow \infty}n^{1/n}=1$$ so your comparison sum is divergent...
Answer: $$\sqrt[n]n-1={n-1\over(\sqrt[n]n)^{n-1}+(\sqrt[n]n)^{n-2}+\cdots+\sqrt[n]n+1}\ge{n-1\over n+n+\cdots+n+n}={n-1\over n^2}\ge{1\over2n}$$
(with the final inequality assuming $n\gt1$).
Comment: This is actually alot faster indeed. Nice thinking! But, be careful cause for $n\leq2$ the last inequality is not right.
Comment: (+1) for using elementary analysis only.
Comment: @Ghost, thanks for your comment.  Note, however, that the final inequality *is* correct for $n=2$. (My parenthetical remark accounts for the one case, $n=1$, where it's not correct.)
Comment: Yes, you are right! Sorry, I typed it wrong but, for $n<2$ it is not right. Now if we take n as a natural number, the only wrong case is $n=1$ but for n real it is $n<2$. Sorry I did not take into consideration n is natural number. Anyway, great thinking!
Answer: Hint: $$n^{1/n}-1=\left(e^{\log n/n}-1\right)\sim\frac{\log n}{n} $$
Answer: The series diverges by comparison with $\sum \frac{1}{n}\log n$.
Let $n \ge 2$. Since $\sqrt[n]{n} = e^{\frac{1}{n}\log n}$, the mean value theorem gives $\sqrt[n]{n} - 1 = e^{c_n}\cdot \frac{1}{n}\log n$ for some $c_n\in \left(0, \frac{1}{n}\log n\right)$. Now $e^{c_n} > 1$, so that $$\sqrt[n]{n} - 1 > \frac{1}{n}\log n$$ Now you can compare your series with the divergent series $\sum \frac{1}{n}\log n$.
Comment: Can you detaliate how you got that $\sqrt[n]{n} - 1 = e^{c_n}\cdot \frac{1}{n}\log n$? For what function you appy mean value theorem?
Comment: @Ghost I apply it to the function $f(x) = e^x$.
Comment: So for $f(x)=e^x$ we apply it on the interval $(0, \frac{1}{n}log  n)$?
Comment: @Ghost correct.
Comment: Now the only problem is how to show that the new series is divergent.
Comment: @Ghost It's larger than the harmonic series
Comment: @Ghost, for $n \ge 2$, $\log n \ge \log 2$. So $\frac{1}{n}\log n \ge \frac{1}{n}\log 2$ for $n \ge 2$. Since the harmonic series $\sum \frac{1}{n}$ diverges, it follows that $\sum \frac{1}{n}\log n$ diverges.
Comment: Ok, all is clear to me now. Thanks for all the explanation!


Formula for prediction interval for spatial regression

Question: I have a spatial error model that I have estimated and would like to create a figure with the prediction interval. By spatial error model, I mean that the errors are spatially correlated and thus OLS is unbiased but inefficient (not a spatially auto-regressive model).
I used the geostatistical approach to spatial statistics and estimated a semivariogram for my data and used the semivariogram estimates to create a weighting matrix to account for the spatial autocorrelation in the data. I think the answer to this question though would help anyone using weights in their regression regardless of the exact structure of their weighting matrix.
I see from this question that the formula for a 95% prediction interval for OLS is
$$
\hat{y} \pm 1.96 \hat{\sigma} \sqrt{1 + \mathbf{X}^* (\mathbf{X}'\mathbf{X})^{-1} (\mathbf{X}^*)'}.
$$
Given my limited intuition, my guess would be that the prediction interval for the case with weights would be this (where $\Omega$ is the weighting matrix):
$$
\hat{y} \pm 1.96 \hat{\sigma} \sqrt{1 + \mathbf{X}^* (\mathbf{X}'\mathbf{\Omega}^{-1}\mathbf{X})^{-1} (\mathbf{X}^*)'}
$$
and was hoping that I could get some feedback from the community here about the correctness or if I am even in the right ballpark.
Comment: Not quite sure why my formulas aren't rendering on the question page as they render just fine in the preview. If someone has enough reputation and wants to edit so that they display correctly it would be much appreciated.
Answer: Note that @whuber adresses all the points raised in the question, I will provide only the mathematical details. The regression with spatial error assumes that model is the following:
$$y=X\beta+u$$
where $Euu'=\Omega$. The efficient estimate of $\beta$  then is
$$\hat\beta=(X'\Omega X)^{-1}X'\Omega y$$
When you have new observation it also follows the model
$$y^*=X^*\beta+u^*$$
We predict $y^*$ by $X^*\beta$ so the prediction error is
$$y^*-\hat{y^*}=X^*\hat\beta+u^*$$
For linear model $u^*$ will be independent of $u$ so
$$Var(y^*-\hat{y^*})=Var(X^*\hat\beta+u^*)=Var(X^*\hat\beta)+Var(u^*)=\sigma^2+\sigma^2X^{* } (X'X)^{-1})(X^{* })'$$
For the spatial error model we have
\begin{align*}
Var(X^{* }\hat\beta)=
Var(X^{* } (X'\Omega X)^{-1}X'\Omega u)
=X^{* } (X'\Omega X)^{-1})(X^{* })'
\end{align*}
But now $u^*$ correlates with $u$ and we do not have such convenient decomposition. Thus the formula in your question cannot be used.
The general approach how to calculate the error is describe in this article. It shows how to get the best unbiased linear prediction in linear model when the model errors are correlated. Note that this heavily relies on the fact that you have reliable estimate of $\Omega$, so @whuber answer applies very strongly. Even if you have correct formulas they might give bad results if it is known that $\Omega$ cannot be reliably estimated.
Answer: Assuming $\Omega$ has been estimated with no appreciable error--which is rarely the case--the correct formula is given by the equation for the kriging prediction error.  It needs to replace everything under the square root sign.  What is missing from the second formula you give is any explicit accounting of the covariance between the value at the estimation location and the data values.
Some recent approaches, such as presented in Diggle & Ribeiro's "Model-based Geostatistics" (implemented as an R package) have the additional merit of incorporating the estimation error of $\Omega$ in the prediction uncertainty.
Comment: So really the spatial element of this problem is more of a nuisance rather than the story. If I were interested in the value at a specific location I agree that the kriging prediction would be error would be the ticket. If one were to view the problem as more of a weighted least-squares problem though, how would the prediction interval formula change?


Yahoo OAuth on Android - 401 error

Question: I'm trying to implement OAuth for Google, Twitter, Yahoo etc. on Android using the signpost libraries.
All of the above work fine, except Yahoo, which gives me a 401 error when trying to retrieve the Request Token. I've tried modifying my callback url to an http one, and even tried Out of Band authentication.
Does anyone have an idea on what I could be doing wrong  ?
My code which requests for the OAuth Request Token using Signpost libraries is pasted below.
private static CommonsHttpOAuthConsumer yahooConsumer = new CommonsHttpOAuthConsumer(
        YAHOO_CONSUMER_KEY, YAHOO_CONSUMER_SECRET);
private static CommonsHttpOAuthProvider yahooProvider = new CommonsHttpOAuthProvider(
        YAHOO_REQUEST_URL, YAHOO_ACCESS_TOKEN_URL, YAHOO_AUTH_URL);

and

String authURL = yahooProvider.retrieveRequestToken(
                                      yahooConsumer,YAHOO_REDIRECT_URL);
                  startWebView(authURL);

EDIT:
Here's the output from the catched Exception :

08-21 00:18:10.935: WARN/System.err(3752): oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.
  08-21 00:18:10.945: WARN/System.err(3752):     at oauth.signpost.AbstractOAuthProvider.handleUnexpectedResponse(AbstractOAuthProvider.java:239)
  08-21 00:18:10.945: WARN/System.err(3752):     at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:189)
  08-21 00:18:10.955: WARN/System.err(3752):     at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:69)

Thanks,
Abhinav
Comment: Could you please provide the error details from Yahoo with the 401?
Comment: @Kristiono - I've edited my question to add the logcat output with the exception. Thanks
Comment: Thanks for the exception thrown. I think you should also see the body response of 401 given by Yahoo. Yahoo should gave you a descriptive response of what being wrong.
Comment: Thanks for the help. Here's what signpost outputs to my Logcat - Authentication error: Unable to respond to any of these challenges: {oauth=WWW-Authenticate: OAuth oauth_problem=consumer_key_rejected}. Do you want me to install a request tracking software and give you the detailed request and response ?
Comment: @Abhinav I got the same error(oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match). I have valid customer key. But it shows above exception. can you help me.
Comment: @Abhinav +1 for your question.
Comment: @Ramakrishna Please refer to Kristiono's answer below. I faced the same issue. Basically you need to check atleast one service provided by Yahoo.
Answer: consumer_key_rejected means that you didn't provide valid consumer_key to Yahoo. If you do have provided the right consumer_key to Yahoo, you may check your app registration with Yahoo. Probably you need to check at least one or more services provided by Yahoo. Don't forget to also choose the type of your application whether it's web-based or client-based.
This all make sense since Yahoo wrapped the permission scope into the Consumer Key. Read this explanation for further details: Yahoo OAuth Scope.
This is the workaround example and hints that might be useful to solve your problem: Yahoo OAuth Problem - Consumer Key Rejected
Let me know if this works for you.
Comment: Thanks for the explanation Kristiono. I'm pretty sure that my Consumer Key is fine, and have tried with both Web-Based and Client-Based, with various combinations including OOB. The second link that you've given is pretty intriguing - let me try out what he's said and see if it works !
Comment: Thanks Kristiono, I'm getting the request token now. This has really helped me - I was struggling up to the point of considering writing my own OAuth client for Yahoo.
Answer: Try forcing 1.0a authentication with Provider.setOAuth10a(true).
It's also worth checking that the date, time and timezone on your client are all correct else the signature verification will fail.
Comment: Thanks. Let me try this and get back to you.
Comment: That does not work. I can't help but feel that there's something really basic I'm missing out on. My app is registered as a web-based app with my own domain as the app url, and I give that as the redirect url here also, though I've also tried registering as a desktop app and trying OOB.

Yahoo OAuth on Android - 401 error