What specific advantages are there for writing the melody first vs the harmony first?

Question: In what instances would it be beneficial to choose to write the melody first or the harmony first? Are there any examples in history of a composer / songwriter favoring one method over the other? If so, what impact did it have on the character of their music?
Comment: I'm voting to close this question because it is fundamentally unanswerable. Composers have created music by every means available, and no composer has composed in only one way. All of the composers whose music has stood the test of time achieved superb results regardless the process.
Comment: If my math are correct there are two questions here which are not completely equivalent. Especially the one in the text sounds very opinion based, but maybe that's me...
Comment: It is possible to write both at the same time. At least some modern composers go measure by measure or page by page.
Comment: Different composers had different approaches, all of which led to results that have stood the test of time.
Comment: You cannot write a melody without a chord progression, they go hand-in-hand. It is like trying to build a house without a house-plan!
Comment: Which is better - chalk or cheese?
Comment: I actually disagree. When writing counterpoint, for example, you usually start with the melody only and fill in the rest as you go.
Comment: Bach had a long history of taking old religious music with a modal melody (often sung in unison or parallel intervals), and completely changing their nature by writing new counterpoint lines and giving the melody a new harmonic context.
Comment: Nice edit but it is still asking too many questions, opinionated, discussion-provoking questions at that - "what impact did it have on the character of their music?".
Answer: This kind of question is a false dilemma: it assumes one or the other is true.  But the fact is that a good composer will often be thinking about both melodic ideas and harmonic motion together.
The other problem is that you think this is a conscious, logical process.  Sometimes it is, and sometimes it isn't.  Normally, when I'm composing, I'll improvise harmony and melody together on the piano, and then I'll "feel" where some part of the thing wants to go-- it can be harmonic, melodic, some orchestral texture, pretty much anything.
This is me at random points in the process:

Oooh, that chord wants to go minor next.  How can I leap to that
flattened third in the melody?
That word needs to really punch.  What nasty chord should I throw in under this note to show I mean business?
This sounds cool, but it really feels like it should be brass and
maybe timpani.  What octave would really hit the trumpets' power zone?

Or, maybe once or twice a year (and that might be a bit generous), on waking up in a cold sweat:
"Wait. . . what is that?  I don't think that's even a song yet.  I have to write it down-- dammit where's my pencil?"  and I write down a full melody and chords, never having thought about their composition at all.
(My three favorite things I've written came that way-- and I had to ask composer friends to check if it was just an accidental plagiarism, but it never was, at least that we could figure out)
Comment: A false dilemma is also called a false dichotomy
Comment: Yeah, it's only a dilemma if you're agonizing over choosing one or the other. :D
Answer: It is quite hard, in my opinion, to determine which approach is better. One might find it easier to write a melody over a given chord progression, another one the other way around.
For me in a Jazz context, it is often more fun to sit at the piano, come up with a chord progression and then write a melody. A friend of mine goes the other way around and first writes the melody and after that the chord progression.
Now consider a polyphonic piece of music, like a fugue or a canon. I would argue that the melodic idea and the melodic material determines the harmony of the piece and the melody has to fit some specific needs for your piece. (Dissonance with the counterpoint or Dux and Comes.
These are just a few examples on how different people might need different approaches to write music. As Aaron in the comments wrote: "It is an unanswerable question." And I would add that it depends on your personal preference.


Content Control and Button Flyout

Question: I am making a UWP app and I have come across a problem. I want to make a StackPanel which hosts two ComboBoxes and one TextBox. I can show it in the app if I create it inside the Grid and it works as expected. But for smaller screen devices I want to show a Button in place of the StackPanel and move the StackPanel to the button flyout.
I have tried to add the StackPanel to a ContentControl and then set it as the Flyout but it doesn't work. Flyout needs a FlyoutPresenter control to be able to show the flyout.
I don't want to create multiple StackPanel controls because of the naming collisions, but I do want it simple so I need to make changes to one side of the controls and when the user switches the screen or the view the smaller screen also shows the same stuff.
Can someone help me here? Maybe just point me in the right direction so I can figure it out on my own. Any help will be appreciated. Thanks
StackPanel control:
    <StackPanel Orientation="Vertical"
                x:Name="PageOptionsPanel"
                HorizontalAlignment="Right">
            <AppBarButton Label="Refresh"
                    Icon="Refresh"
                    Tapped="PageOptions_Tapped"/>
            <RelativePanel Margin="10,0">
                <TextBlock Text="Sort by:"
                        Name="SortText"
                        RelativePanel.AlignVerticalCenterWithPanel="True"
                        Margin="0,0,5,0"/>
                <ComboBox RelativePanel.RightOf="SortText"
                        x:Name="MSortingBox"
                        ItemsSource="{Binding EnSortList}"
                        RelativePanel.AlignVerticalCenterWithPanel="True"
                        SelectionChanged="MSortingBox_SelectionChanged"
                        Width="120"/>
            </RelativePanel>
            <RelativePanel Margin="10,0">
                <TextBlock Text="Country: "
                        Name="CountryText"
                        RelativePanel.AlignVerticalCenterWithPanel="True"
                        Margin="0,0,5,0"/>
                <ComboBox RelativePanel.RightOf="CountryText"
                        x:Name="MCountryBox"
                        ItemsSource="{Binding EnCountryList}"
                        RelativePanel.AlignVerticalCenterWithPanel="True"
                        SelectionChanged="MCountryBox_SelectionChanged"
                        Width="120"/>
            </RelativePanel>
        </StackPanel>

Flyout control:
    <Button>
        <Button.Flyout>
            <Flyout Placement="Left"
                    x:Name="MOptionsFlyout"
                    Content="{StaticResource PageOptionsFlyout}"
                    Opened="MOptionsFlyout_Opened">
            </Flyout>
        </Button.Flyout>
    </Button>

Answer: If I understand your question correctly, you want to share the XAML for your Options layout between the main page and a flyout, based on the size of the page (for phone vs tablet). You can do this by creating a DataTemplate with the layout and adding it to the page's resource dictionary. Then it can be referenced in multiple places.
Here's the code below that does that. It also hides and shows the pieces based on adaptive triggers.
<Page.Resources>
    <DataTemplate x:Key="PageOptionsTemplate">
        <StackPanel
                    x:Name="PageOptionsPanel"
                    HorizontalAlignment="Right"
                    Orientation="Vertical">
            <AppBarButton
                        Icon="Refresh"
                        Label="Refresh" />
            <RelativePanel Margin="10,0">
                <TextBlock
                            Name="SortText"
                            Margin="0,0,5,0"
                            RelativePanel.AlignVerticalCenterWithPanel="True"
                            Text="Sort by:" />
                <ComboBox
                            x:Name="MSortingBox"
                            Width="120"
                            RelativePanel.AlignVerticalCenterWithPanel="True"
                            RelativePanel.RightOf="SortText"/>
            </RelativePanel>
            <RelativePanel Margin="10,0">
                <TextBlock
                            Name="CountryText"
                            Margin="0,0,5,0"
                            RelativePanel.AlignVerticalCenterWithPanel="True"
                            Text="Country: " />
                <ComboBox
                            x:Name="MCountryBox"
                            Width="120"
                            RelativePanel.AlignVerticalCenterWithPanel="True"
                            RelativePanel.RightOf="CountryText"
                             />
            </RelativePanel>
        </StackPanel>
    </DataTemplate>
</Page.Resources>

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Button Name="OptionsFlyoutButton" Content="Show Me" Visibility="Collapsed">
        <Button.Flyout>
            <Flyout>
                <ContentControl ContentTemplate="{StaticResource PageOptionsTemplate}"/>
            </Flyout>
        </Button.Flyout>
    </Button>
    <ContentControl Name="OptionsInLine" Visibility="Visible" ContentTemplate="{StaticResource PageOptionsTemplate}" />

    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup>
            <VisualState>
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="320"/>
                </VisualState.StateTriggers>
                <VisualState.Setters>
                    <Setter Target="OptionsInLine.Visibility" Value="Collapsed"/>
                    <Setter Target="OptionsFlyoutButton.Visibility" Value="Visible"/>
                </VisualState.Setters>
            </VisualState>
            <VisualState>
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="720"/>
                </VisualState.StateTriggers>
                <VisualState.Setters>
                </VisualState.Setters>
            </VisualState>
            <VisualState>
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="1024"/>
                </VisualState.StateTriggers>
                <VisualState.Setters>
                </VisualState.Setters>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
</Grid>

You can also move the DataTemplate out to the application level ResourceDictionary, so that it can be shared between multiple pages.
Finally, another option is to create a user control (using the uwp item template) for this. I recommend creating that if you needed more control over the layout, wanted to encapsulate the logic too, and share it across multiple apps.
For your example, the shared DataTemplate is the easiest path.
Comment: Yes, Thank you for your answer. I already figured it out and it is the correct way as I did it the same way.
Comment: Great, glad that helped.
Answer: Just do this:
<Button Content="Show Me">
        <Button.Flyout>
            <Flyout>
                <StackPanel
                    x:Name="PageOptionsPanel"
                    HorizontalAlignment="Right"
                    Orientation="Vertical">
                    <AppBarButton
                        Icon="Refresh"
                        Label="Refresh" />
                    <RelativePanel Margin="10,0">
                        <TextBlock
                            Name="SortText"
                            Margin="0,0,5,0"
                            RelativePanel.AlignVerticalCenterWithPanel="True"
                            Text="Sort by:" />
                        <ComboBox
                            x:Name="MSortingBox"
                            Width="120"
                            RelativePanel.AlignVerticalCenterWithPanel="True"
                            RelativePanel.RightOf="SortText"/>
                    </RelativePanel>
                    <RelativePanel Margin="10,0">
                        <TextBlock
                            Name="CountryText"
                            Margin="0,0,5,0"
                            RelativePanel.AlignVerticalCenterWithPanel="True"
                            Text="Country: " />
                        <ComboBox
                            x:Name="MCountryBox"
                            Width="120"
                            RelativePanel.AlignVerticalCenterWithPanel="True"
                            RelativePanel.RightOf="CountryText"
                             />
                    </RelativePanel>
                </StackPanel>
            </Flyout>
        </Button.Flyout>
    </Button>

to get this:

When using the  you get an auto display flyout that is shown whenever a user clicks the button, no code needed.
but to add content to that flyout, you need to have another  element in it, then the stackpanel goes into it.
Hope this helps you.
Comment: Unfortunately you didn't understand my question, I can generate the flyout but I need this flyout also as a different control so I can show it elsewhere. Actually I want one `stackpanel` to be able to go into the flyout and out of the flyout and work as if it were the same control.

Content Control and Button Flyout


how do i avoid showing layout in internet explorer mobile

Question: I honesty don't know how to put this. In mango version of windows phone internet explorer shows a black semi transparent layer when a link is tapped how can I avoid this.
Answer: Well, I do clearly understand what you are telling, but unfortunately, you can't avoid that. It is simply an indication that the link has been clicked. For usability sake.
This is for existing web-pages/sites. But if you are trying to develop an web-app using PhoneGap or something else, then you can change these links as JavaScript/jQuery events instead, and that should probably avoid it.


How do I fix my error with scanner? java.util.InputMismatchException

Question: I am using Java (VSC is my compiler).
I try to read through a document that is in the same folder. However, just scanning causes this error:
An error has occured.
java.util.InputMismatchException
        at java.base/java.util.Scanner.throwFor(Scanner.java:939)
        at java.base/java.util.Scanner.next(Scanner.java:1594)
        at java.base/java.util.Scanner.nextDouble(Scanner.java:2564)
        at Project1.results(Project1.java:66)
        at Project1.main(Project1.java:87)

This is my whole code:
public class Project1() {

    public void results(String fileName){

            double x, y, xc, yc, rad, radius;

            int number_of_circles = 0;
            try {
              Scanner scanner = new Scanner(new BufferedReader(new FileReader(fileName)));

              while(scanner.hasNext()) {

                x = scanner.nextDouble();
                y = scanner.nextDouble();
                rad = scanner.nextDouble();
                if(rad > 0) {
                    number_of_circles++;
                }
              }

            }
            catch(Exception exception) {
              System.err.println("An error has occured.");
              exception.printStackTrace();
            }

    }
    public static void main(String args[]){
        Project1 P = new Project1();
        P.results("Project1.data");

    }
}

I tried different files with different values but it does not seem to help. Thanks. I looked at other threads, but they seem to not cover the exact same problem.
It looks like if I put only integer values inside Project1.data, then it works, but obviously I want to allow for other values
Project1.data values:
9.50 2.40 3.20
2.20 3.40 5.60
2.50 2.40 3.20
3.20 4.40 5.60

Comment: The file 'Project1.data' does not start with 3 whitespace-separated double values.
Comment: I wrote in the post how project1.data looks like.

Should I separate it in a different way? Between every 3 values, there is a space and after every set there is an enter
Answer: Is it possible that your locale expects , as separator, while your file contains . ?
Related question: Best way to parseDouble with comma as decimal separator?
Here is another related question with tips for Scanner: Java - Scanning comma delimited double and int values
Comment: Usually it's country- and language-specific. If you hard-code (define) the locale manually, the code should work on any computer.
Comment: Yes, you are right! I would not think about my VSC using , as a separator. Why does it happen? Can I change it in any way?
Comment: Updated my answer with another link - specifically for Scanner. This should help you. In short: start with defining another Locale for your Scanner instance - ENGLISH should work, for example.
Comment: Thank you. One last question - is it a problem of my locale or is it going to happen by default? This question is a part of my homework, so I am not sure if only I will have this problem on my computer, or maybe my lecturer will have a problem with running my code.


On entity save, identify the user fields that have been changed

Question: I have a need to track changes to users in a separate database, apart from Drupal. When a user changes their email address or their password, I need to communicate that change with a shadow table in MSSQL.
I've created an event and listener. The event is triggered by hook_entity_update. That works fine, but I don't know what was changed in that request. Is there a way to pass the value that was changed to that event listener?
Answer: Per the hook_entity_update() documentation:

This hook runs once the entity storage has been updated. Note that hook implementations may not alter the stored entity data. Get the original entity object from $entity->original.

In your event listener, you can compare the email/password fields on $entity & $entity->original to check if they have changed.
Comment: Thanks, Shawn. I overlooked the $entity->original yesterday. That gets me what I need.


How to select and remove all the first consonants of a word and place them at the end of the word in python?

Question: I want to remove all the first consonants of a word and place them at the end of the word
input -> "step down"
output -> "epst ownd"
this is my code so far:
def lang(text):
    alist=text.split()
    vokaler="äåöaeiouÄÅÖAEIOU"
    retText=""
    for word in alist:
        nytext=""
        nytext_b=""
        n=0
        for tkn in word:
            if not tkn in vokaler:
                nytext+=tkn
                n+=1
            else:
                for rest in word[n:]:
                    nytext_b+=rest
                    retText=nytext_b+nytext+"all"+" "

    return retText

print(lang("step down"))

Comment: So? What does your code do, and what did you expect it to instead?
Comment: Does it work as written?
Comment: The code as it is goes through every letter of a word. If it is a consonant it saves it to an empty variable. If it is a vowel then it runs through the rest of the word and saves it in another variable. Then i add them together into an empty third var. I dont know how to stop the loop from continuing after it has gone through the rest of the word
Comment: Then I suggest you learn more about [control flow](https://docs.python.org/3/tutorial/controlflow.html).
Comment: This is what i get: owndall. For some reason it skips the first word
Comment: What if the word starts with a vowel??  `...stop the loop from continuing...` - ```for tkn in word:``` will stop when the characters are exhausted.
Answer: If you want to put every letter of the string to end then you can use following code:
  a="step down"
  l=a.split()
  print l
  data1=""
  for x in l:
     data=x[1:]+x[0:1]
     data1=data1+data

     data1=data1+" "
  print data1

output:
  teps ownd

Comment: Your code does not do what you say - `put every letter of the string to end`.  Also, OP stated every `first consonant` to the end.
Comment: Can you see the output which I given in post
Comment: Probably, because it is incorrect and only works for the given example and it is not solving the problem.
Comment: CAN YOU GIVE THE STRING WHICH IS NOT WORKING?@badc0re
Comment: Thank YOU Jack! Appreciate it... i confuse myself more than often :)
Comment: @Nash if this solves your problem, you need to revise your question and the expected output.
Comment: I apologize if the question was not clear. All i wanted to do was select all the consonants of a word up to the first vowel and then add them to the end of the word. Jacks code helped me understand what i had to do!


Crash with malloc and free in android native code

Question: I am facing crash issue in native of my android code.
My app is similar to app described in this scenario (Click here).
Java layer will call the native layer by calling some native API and intiates some process.
Native call returns back immediately while launching a thread in the native for processing.
Once processing is completed, native thread will call the java function (call back function) for informing the result. This has been done by using JNI functions and making use of the *jvm->AttachCurrentThread().
What i observe from the stack trace dump in the log cat is, its not even completed the processing and it is crashing always at malloc or free (after some mallocs or after some frees and not consistent).
Is there anyway to find the memory corruption in native code of android?
As mentioned in the above link I tried with this solution by adding
<code>LOCAL_EXPORT_LDLIBS += -lc
</code>
flag in the android.mk file. But it was not helpful, still I am able to observe the crashes.
Please let me know if anyone knows solution for the same.
P.S: The code which I am using for native processing is completely tested for the other product (Which is not on android). Facing problems when trying to port to android.
Thanks & Regards,
SSuman185
Comment: Could you give the smallest workable sample ?
Comment: I tried but not able to create the workable example.
Answer: I found the problem, actually memset() was being done after freeing the memory. Astonishing thing is, this code was already released and working fine for other platform. But it is giving crashes in Android.


Why intervals are not named after distance

Question: I was wondering about the foundations of the way we name intervals.
For example, the interval between C and G is a fifth because there are five notes from C to G. But it's a common mistake of the person learning intervals for the first time to count four: one step from C to D, one from D to E, one from E to F and one from F to G. This is what I call "distance", because one intuitively counts the steps.
It seems to me that both approaches are valid if one was to rebuild the principles of music theory. So the question is, why is it the way it is? I think that advantages and disadvantages are worth mentioning but I also think that the truth behind this must be on historical reasons.
Edit: to sum up, I see there are (were) two options for naming intervals. One was counting note by note, and the other, counting the steps. My question is how and when the first one became the standard.
Please take into account that why this option was "chosen" is relevant but not the main interest, so in my opinion this shouldn't be considered a duplicate of Why aren't intervals zero indexed. It's rather a variant, with a different point of view.
Regarding motivation for the question: I saw little children getting confused because they counted four steps from C to G, and I realized that it was perfectly natural to make that interpretation. As children, they don't have their minds pre-programmed as grown ups do. We consider that calling that interval a fifth is natural exactly because of that: we got used to it.
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackexchange.com/rooms/50696/discussion-on-question-by-emilio-why-intervals-are-not-named-after-distance).
Comment: @DrMayhem I think this comments shouldn't have been moved to chat. They contained a useful link to a related post, and they didn't contain one extended discussion, but several very different comments with my replies. And they weren't a lot of comments. This motivated http://meta.stackexchange.com/questions/289025/comments-moved-to-chat-why-all
Comment: Unfortunately the end result is the same: difficult to get to the answers. If there are bits in those discussions that you think should be in answers or added to the question, please do that. Remember comments are not meant to be permanent.
Comment: @Dr Mayhem I also think this shouldn't have been closed as duplicate. I edited the post adding clarifications. I don't consider this question is the same. It's a variant, and as long as I read this can be useful. Moreover, it had a lot of answers, upvotes, and even an accepted answer
Comment: None of those would stop something being a duplicate, Emilio. And as you can see, 5 people did think it is a duplicate.
Comment: @Dr Mayhem I'm perfectly aware of that and I only mention what I think proves this question has good value. I think this is not a duplicate because it presents a different point of view, and I would like it to be reopened (provided enough people think the way I do about it)
Answer: This question is probably more about linguistics than music. This "illogical" counting system goes back at least as far as the ancient Romans, who used it for dates. In Latin, "the day before X" and "the second day before X" both refer to the same day (i.e. "day X-1") and "the third day before X" means "day X-2". This counting convention also appears the Bible, where "the third day" after Friday is Sunday, not Monday.
Also, the notion of "zero" as a number did not reach Europe until about 1200AD, and the origins of western music theory predate that mathematical innovation.
Comment: @Emilio:  The seven-tone Pythagorean scale dates back a couple thousand years.  The Greeks called the perfect fifth the "diapente", which literally means "across five" [notes].  Similarly, the perfect fourth was the "diatesseron" ("across four").  So the counting system for intervals was established well before the European Renaissance.
Comment: I like the linguistical point of view and the example about the Romans. But I think that musicians didn't start talking about intervals until a few hundred years ago
Comment: @Emilio the earliest Western writing about musical temperament and intervals (dating back to the 13th century or earlier) was linked to the Catholic church, and in Latin. The church still uses the term "octave" to mean the time interval between a two days with the same name, e.g. Wednesday to the following Wednesday, which we would call seven days not eight.
Comment: Yep- you all have it: it's a linguistic (or counting) convention, pretty obviously.  Equally obviously, we should rather call a fifth a 3/2, but as long as everyone knows what's meant, what's the big deal?
Comment: Yet in music 'an octave' works in the same sort of way; eighth note away, (hence octo) but seven spaces.
Comment: I still don't think that the notion of zero has importance here, but the point about history is very well made.
Comment: Please vote to reopen if you think it's worth it. This question has a different point of view and, in my opinion, shouldn't be considerd duplicate
Answer: It's the same reason why scale degrees start on one as the root rather then start at zero which is due to the basic ideas of counting rather than distance. The counting always starts on the first note in the interval which is considered "1".  In most other fields and with a more modern approach to it, it would be called 0. So for your example for C-D the C is 1 then we go up to 2 on the D. While counting from 0 may make more sense, it wouldn't make sense to change the terminology as every single musical text would have to change or else you would make them useless.
There are more modern approaches to intervals such as the one in set theory where the distances between notes are just enumerated and based on semitones. If you are doing any computations with distances between notes, they make things much simpler.
Comment: Distance is not a modern concept. Although you provide an excellent explanation and start numbering in 1 may be natural, the distance to the starting point could never be defined to be 1. It's again distance vs. counting. Of course once a terminology is settled changing it is not worth the effort
Comment: @Emilio I'm wondering if thinking of an increase in pitch in the same way as an increase in distance makes sense before the idea of frequency is fully understood - which inspired this question : http://music.stackexchange.com/questions/51265/at-what-point-in-history-did-the-relationship-between-pitch-and-frequency-become
Comment: @topo morto In this context, distance is a word for addressing more precisely the action of counting steps instead of counting notes. So it makes perfect sense to me without the concept of frequency
Comment: Despite what I said about distance, after thinking about it I like more the idea of counting steps, which seems more natural. Whether zero is or not a number for start counting notes, is not key here.
Answer: I wonder even whether 'interval' is the apposite word. An interval is the space in between, I think, so maybe it is a misnomer. However, the first note is always called 'one', etc., and it's probably too late in the day to change things. I remember reading somewhere that scientists actually proved that the positive terminal on a DC battery is negative, but sometimes we have to let sleeping dogs lie.
C>G is 1st to 5th, so I guess it was easier to say C>G IS a fifth.
Answer: Because one is not interested in the distance itself, but in the relationship between the two notes.
Seven semitones distance tells me nothing, but an interval of fifth rings me a bell, because it relates the root note of the interval with the fifth grade of its scale:
C - D - E - F - G - A - B - C
I ------------- V
Also worth noting, you can alter the name of the interval by appending or prepending attributes (minor, major, augmented, diminished...): minor third conveys more information than just three semitones, even if the two definitions are equivalent.
Ok, by experience I immediately know that "3 tones and a half" are a (just) fifth, but the current nomenclature helps having a better visual clue of what's going on, especially if mentally displayed on a piano keyboard.

It's like saying that the town library is 10m walking from where I live, rather than 997m far ^____^
Comment: 'Seven semitones' means a lot to me as a guitarist, 'a fifth' less so. As a muso generally, both are significant.
Comment: @Tim good point, the fretboard is much more linear than the keyboard. That's why I am learning to play guitar at the moment : ))
Answer: The name of the interval can be thought of as derived from the second note's relationship to the first note in terms of scale degrees, and where the first note is taken as "1".  So for a fifth we can think of the root of a temporary, imaginary, scale which begins on the first note of the interval.  The name of the interval then tells us scale degree of the second note (as well as the quality of the interval).
This is really just another way of saying what another answer says, which is that we start our counting by naming the first note of the interval as "1".  But we extend that concept slightly here to say that intervals names relate to the scale degrees of a scale that would begin on the first note of the interval.


What does this sentence from textbook mean "we will identify a 1x1 matrix with its single entry"?

Question: The context is about matrix-vector product
One paragraph says "we will identify a 1by1 matrix with its single entry"

A is an 1by1 matrix: [a_1_1]
a_1_1 or a_1 is its first component.

and

v is an 1by1 vector: [v_1]
v_1 is its first component.

Does "we will identify a 1x1 matrix with its single entry" mean

Av = [a_1_1 multiplies v_1]

which is still a matrix
or

Av = a_1_1 multiplies v_1

which becomes a scalar
I guess that sentence means

Av = [a_1_1 multiplies v_1]
Comment: Yes, every scalar is a $1\times1$ matrix. By abuse of language I'd say that scalars are a particular case of $\mathbb R^n\times\mathbb R^m$ matrices. So when you multiply a $1\times1$ matrix with a $1\times1$ vector, you're technically multiplying two scalars.
Comment: Okay, from the perspective of structure when we do that kind of multiplication, it seems reasonable though.
Answer: It means both of these. For any matrix $\mathbf{A} = [a_{11}] \in M_{1\times1}(\mathbb{R})$ we are defining $\mathbf{A} := a_{11}$, and for any scalar $x \in \mathbb{R}$ we are defining $x := [x]$. Similarly, for any vector $\boldsymbol{v} = [v_1] \in \mathbb{R}^1$ we are defining $\boldsymbol{v} := v_1$.
Thus, $\mathbf{A}\boldsymbol{v} = [a_{11}v_1] = a_{11}v_1$.
We are defining scalars as identical to $1 \times 1$ matrices, and $1 \times 1$ matrices as identical to scalars, and as such you may freely interconvert between them.
We may do this as under normal matrix addition and multiplication, and under componentwise addition and the normal vector dot product, $(M_{1\times1}(\mathbb{R}), +, \cdot) \cong (\mathbb{R}^1, +, \cdot) \cong (\mathbb{R}, +, \cdot)$.


Correct way of applying Bonferroni correction

Question: We are planning an experiment to study the effects of new drugs on animal models of epilepsy. The experiment will be in run in 2 phases.
The hypothesis in Phase 1 is: "Animals receiving Drug X experience a reduction in seizures." Experimental design: One group of control animals and 5 groups of test animals, each receiving a different test drug. Hence, 5 separate comparisons of Test Drug v Control.
The two best drugs from Phase 1 will be taken into Phase 2. In Phase 2, the two test drugs are withdrawn and animals are observed for any persisting benefit.
The hypothesis in Phase 2 is: "Animals that have received Drug X in the past continue to experience enduring benefit." Experimental design: One control group of animals and 2 test groups, each having received a test drug in the past. Hence, 2 separate comparisons of Test Drug vs Control.
Any drug effective in Phase 2 will be taken into human clinical trials. If no drug is effective in Phase 2, then any drug(s) effective in Phase 1 will be taken into human clinical trials. Rationale: any drug which produces enduring benefit even after stopping it would be of greatest interest. However, any drug that is effective while being administered is still of interest. (Additional detail added in response to initial replies.)
How should Bonferroni correction be applied? Separately for each phase , i.e., 0.01 (=0.05/5) for Phase 1 and 0.025 (=0.05/2) for Phase 2? Or 0.007 (=0.05/7) across both phases?
Thank you!
Comment: Researcher, @Nasif please [merge](http://stats.stackexchange.com/help/merging-accounts) your accounts
Comment: Surely there is no point in applying any form of 'correction' for multiplicity in the first experiment. How would a Bonferroni procedure alter the outcome?
Answer: When comparing groups to a control group the Bonferroni correction over corrects. The Dunnett's test has more power while still controlling the Type I error rate.
The Bonferroni corrects for the case in which the probability of a Type I error is highest (independent comparisons). Dunnett's test takes into account the fact that comparisons of experimental groups with the control group will be correlated and thus "corects" less.
Comment: I added some context. I believe others have addressed the one versus two stage issue.
Answer: As Michael Lew notes in a comment, if you are going to take the two best drugs from Phase 1 in any event then a Bonferroni or other multiple-comparison test would not affect what you do. You should of course compare the 5 treatments carefully but your point then is to see, for example, how certain you are that you really found the best 2 out of 5 drugs. For that, issues like confidence intervals are critical and multiple testing corrections are not really at issue.
To many practitioners, a small number of pre-planned comparisons as you propose for Phase 2 do not require multiple-comparison corrections. Those corrections are most important when you have no pre-defined hypothesis and your hypotheses for comparisons were developed post hoc, based on the results that you got. If you (or reviewers) nevertheless insist on doing a multiple-testing correction, David Lane is correct that Bonferroni is typically much too conservative. In any event, the correction would only be applied to the 2 cases in Phase 2.
Comment: Multiple testing is always an issue in these circumstances.
Answer: The first question to me is whether type I error rate control makes sense here, given that you really are trading of different losses (i.e. if you wrongly take a drug forward, you may needlessly expose human subjects and waste research resources, while if you wrongly stop a good drug, then you are potentially giving up on a possibly promising drug) and whether a chosen power & type 1 error rate do this in a good manner is questionable.
Secondly, if type I error rate control is what you want, then as pointed out by others for the first part you can exploit that you know the correlation between the test statistics and use e.g. Dunnett's test. With 5 groups your chance of wrongly convicing yourself that one is effective when it is in fact not is otherwise pretty high, if you do not have some form of control for this. It seems logical to first test the Phase 1 hypotheses ignoring the Phase 2 hypotheses.
The more difficult part is how to do the Phase 2 hypotheses. In particular, whether you can see that as two null hypotheses being tested, or whether that is really 5 null hypotheses - i.e. including the ones for the drugs that were not continued, for which the null hypotheses cannot be rejected, but you need to correct for their presence, anyway. In the latter case, testing the null hypothesis regarding "enduring benefit" with a Dunnett test at level $n \times \alpha/5$ across the $n$ drugs, for which  the Phase 1 null hypothesis was rejected, may make sense. There should be plenty of literature on this question in e.g. the literature on "play-the-winner" or adaptive designs.


In jersey2.x how to inject HttpRequest and HttpSession object ? how to use injected object outside

Question: Using Jersey 2.x how would I inject HttpRequest and HttpSession objects? And  how to use injected request and Httpsession object in a service class?

in jersey 2.x injected request and session objects in Resource class working fine getting request and session objects
out side like business class not working.
Answer: You can try adding @Context HttpServletRequest request to your resources method signature. That will make request available for the duration of the method.
It's not good practice to pass HttpServeltRequest / Session objects down to service or business classes. If you do this, you make it very difficult to use the service class in anything but a Web Application. You should pull the data that the service class requires out of the HttpServletRequest / Session in the Resource class and pass it to service class
For example, if your service class needs access to the userName that is held in an HttpServletRequests "userName" parameter, then the Resource class should do
String userName = req.getParameter("UserName");
serviceClass.doSomething(userName);

rather than
serviceClass.doSomething(req);

Comment: Note that in jersey with grizzly server, it is not possible to inject ``HttpServletRequest``, as it will be null. Please see http://stackoverflow.com/questions/37167921/get-client-ip-in-jersey-2-22-2/#answer-37168839
Comment: @AlexandreCartapanis [that's not true](http://stackoverflow.com/a/33684719/2587435)
Comment: @AlexandreCartapanis Can I ask if you downvoted on the basis of your assertion about Grizzly? The OP makes no mention of Grizzly in the question so if you did downvote, your downvote relates to a question that the OP didn't ask
Comment: @DaveH you are right, i tried to cancel the downvote but it not possible as it is 6 hours ago (saying "You last voted on this answer 6 hours ago. Your vote is now locked in unless this answer is edited.")... Maybe you can edit your anwser so i can cancel it ?


2D analog of standard deviation?

Question: Consider the following experiment: a group of people is given a list of cities, and asked to mark the corresponding locations on an (otherwise unlabeled) map of the world. For each city, you will get a scattering of points roughly centered at the respective city. Some cities, say Istanbul, will exhibit less scattering than others, say Moscow.
Let's assume that for a given city, we get a set of 2D samples $\{(x_i, y_i)\}$, representing the $(x, y)$ position of the city (e.g. in a local coordinate system) on the map assigned by test subject $i$. I would like to express the amount of "dispersion" of the points in this set as a single number in the appropriate units (km).
For a 1D problem, I would choose the standard deviation, but is there a 2D analog that could reasonably be chosen for the situation as described above?
Answer: One thing you could use is a distance measure from a central point, ${\bf c}=(c_{1},c_{2})$, such as the sample mean of the points $(\overline{x}, \overline{y})$, or perhaps the centroid of the observed points. Then a measure of dispersion would be the average distance from that central point:
$$ \frac{1}{n} \sum_{i=1}^{n} || {\bf z}_{i} - {\bf c} || $$
where ${\bf z}_{i} = \{ x_{i}, y_{i} \}$. There are many potential choices for a distance measure but the $L_{2}$ norm (e.g. euclidean distance) may be a reasonable choice:
$$ || {\bf z}_{i} - {\bf c} || = \sqrt{ (x_{i}-c_{1})^{2} +  (y_{i}-c_{2})^{2} } $$
There are lots of other potential choices, though. See http://en.wikipedia.org/wiki/Norm_%28mathematics%29
Comment: While the distance will be nonzero this is indeed a strange choice as it doesn't agree in the degenerate case with the usual standard deviation in one dimension. So consider $\|z_i-c\|^2$ instead.
Comment: I agree, @AlexR. Calculating the distances converts the 2D array into a 1D one. After that, the standard deviation formula could be applied
Answer: A good reference on metrics for the spatial distribution of point patterns is the CrimeStat manual (in particular for this question, Chapter 4 will be of interest). Similar to the metric Macro suggested, the Standard Distance Deviation is similar to a 2D standard deviation (the only difference is that you would divide by "n-2" not "n" in the first formula Macro gave).
Your example experiment actually reminds me a bit of how studies evaluate Geographic Offender Profiling, and hence the metrics used in those works may be of interest. In particular the terms precision and accuracy are used quite a bit and would be pertinent to the study. Guesses could have a small standard deviation (i.e. precise) but still have a very low accuracy.
Answer: I actually ran into a similar problem recently.  It sounds like you want a way to measure how well the points are scattered area-wise.  Of course, for a given measurement, you'd have to realize that if all the points are in a straight line, the answer is zero, since there's no 2 dimensional variety.
From the calculations I did, this is what I came up with:
$$ \sqrt{S_{xx}S_{yy}-S_{xy}²} $$
In this case, Sxx and Syy are the variances of x and of y respectively, whereas Sxy is kinda like the mixed variance of x and y.
To elaborate, assuming there are n elements, and $x_μ$ represents the mean value of x and $y_μ$ represents the mean of y:
$$ S_{xx}=\frac{1}{n} \sum_{i=1}^{n} (x-x_μ)² $$
$$ S_{yy}=\frac{1}{n} \sum_{i=1}^{n} (y-y_μ)² $$
$$ S_{xy}=\frac{1}{n} \sum_{i=1}^{n} (x-x_μ)(y-y_μ) $$
Hopefully this should work for you.
Also, if you're wondering how to do it in higher dimensions, like measuring volume spread or surteron bulk in 4 dimensions, you have to form a matrix like such:
Sxx Sxy Sxz ...
Syx Syy Syz ...
Szx Szy Szz ...
...    ...    ...    ...
And continue for however many dimensions you need.  You should be able to figure out the S values given the provided definitions above, but for different variables.
Once the matrix is formed, take the determinant, find the square root, and you're done.
Answer: I think you should use 'Mahalanobis Distance' rather than Euclidean distance norms, as it takes into account the correlation of the data set and is 'scale-invariant'. Here is the link:
http://en.wikipedia.org/wiki/Mahalanobis_distance
You could also use 'Half-Space Depth'. It is a bit more complicated but shares many attractive properties. The Half space Depth (also known as Location depth) of a given point a relative to a data set P is the minimum number of points of P lying in any closed halfplane determined by a line through a.
Here are the links:
http://www.cs.unb.ca/~bremner/research/talks/depth-survey.pdf
http://depth.johnhugg.com/DepthExplorerALENEXslides.pdf
Comment: Do you mind elaborating on the statements "takes into account the correlation of the data" and "is scale invariant"? What pertinence do either of these things have to the question at hand?
Comment: I understand using Mahalanobis distances when you're trying to tell whether particular points "belong" to the set, but isn't the average Euclidean distance from the centroid more closely related to the usual concept of variance/standard deviation that is used in a univariate setting?
Comment: The usual extension of standard deviation to higher dimension is of course a way to calculate the distance of a particular point from the center of the data - but here we are normalizing each point, which makes it easy to perform cluster analysis or outlier detection. Also, Mahalanobis distance is more adaptive to cases where the distribution of points is non-spherical. For spherically symmetric cases, it is same as the usual extended standard deviation - where the covariance matrix of the data points reduce to identity matrix.
Answer: For this specific example - where there is a predetermined "correct" answer - I would re-work the x/y cooridnates to be polar coordinates around the city they were being asked to mark on the map.  The accuracy is then measured agains the radial component (mean, sd, etc.).  An "average angle" could also be used to measure bias.
For myself, I'm still looking for a a good solution to when there is no pre-determined centre point, and don't like the idea of a pre-pass over the data to create a centroid.

2D analog of standard deviation?


How to submit selected value from HTML dropdown list to FastAPI backend?

Question: How do I submit the value selected from an HTML dropdown list using FastAPI in the backend and HTML-Jinja2 template in the frontend?
Here is my code for the app so far:
from fastapi import FastAPI, Request, Form
from fastapi.templating import Jinja2Templates

app = FastAPI()
templates = Jinja2Templates(directory="templates/")

@app.get('/')
def read_form():
    return 'hello world'

@app.get("/form")
def form_post(request: Request):
    result = "Select your name"
    return templates.TemplateResponse('form.html', context={'request': request, 'result': result})

@app.post("/form")
def form_post(request: Request, result = Form(...)):
    return templates.TemplateResponse('form.html', context={'request': request, 'result': result})

Here is the HTML:
<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Sample Form</title>

<form method="post">

    <select name="names" id="names">
        <option value="n1">Name 1</option>
        <option value="n2">Name 2</option>
        <option value="n3">Name 3</option>
        <option value="n5">Name 4</option>
    </select>
    <input type="submit" value="Submit">
</form>

Result: {{ result }}

Here is the error message:
{"detail":[{"loc":["body","result"],"msg":"field required","type":"value_error.missing"}]}

The goal is to select a name, then click submit, and finally, have it displayed below.
Comment: The signature of the controller function should match your select name: `def form_post(request: Request, names: str = Form(...)):` - you can then include this as `"result": names` to your template. Where `num` is from I have no idea about, since you haven't referenced that parameter in your included code.
Comment: Does this answer your question? [How to submit HTML form  value using FastAPI and Jinja2 Templates?](https://stackoverflow.com/questions/74318682/how-to-submit-html-form-input-value-using-fastapi-and-jinja2-templates)
Comment: Related answers can be found [here](https://stackoverflow.com/a/73359311/17865804), [here](https://stackoverflow.com/a/71665594/17865804), as well as [here](https://stackoverflow.com/a/70771526/17865804), [here](https://stackoverflow.com/a/74317758/17865804) and [here](https://stackoverflow.com/a/73359311/17865804).
Comment: Thanks Matslindh! Copied the wrong thing with num. I'ved edited my post.
Answer: You need to make sure that the action attribute—which specifies where to send the form-data—is included in the HTML <form> when submitting it (see W3schools <form> tag docs for examples as well). Also, in the <select> element that is used to create the drop-down list, make sure to use the same name used to define the Form parameter in your endpoint. As per W3schools <select> tag docs:

The name attribute is needed to reference the form data after the
form is submitted (if you omit the name attribute, no data from the
drop-down list will be submitted).

Each <option> element inside the <select> should have a value attribute containing the data value to submit to the server when that option is selected from the drop-down list. If no value attribute is included, the value defaults to the text contained inside the element. You can include a selected attribute on an <option> element to make it selected by default when the page first loads.
Working Example
app.py
from fastapi import FastAPI, Form, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates

app = FastAPI()
templates = Jinja2Templates(directory='templates')

@app.post('/submit')
def submit(car: str = Form(...)):
    return car

@app.get('/', response_class=HTMLResponse)
def main(request: Request):
    return templates.TemplateResponse('index.html', {'request': request})

templates/index.html
<!DOCTYPE html>

      <form method="POST" action="/submit">
         Choose a car:
         <select name="car" id="cars">
            <option value="volvo">Volvo</option>
            <option value="saab">Saab</option>
            <option value="opel">Opel</option>
            <option value="audi">Audi</option>
         </select>

         <input type="submit" value="Submit">
      </form>


How to correctly define ID and DateTime fields in Firebase Firestore database?

Question: I am using Firebase FireStore database for the first time and I have the following question.
I have created a calendar collection. This collection will contains document representing events that have to be shown into a Calendar implemented by an Angular application.
So I am defining the following fields for these documents:

id: int. It is a unique identifier of the specific document\event.
title: string. It is the event title.
start_date_time: string. It specifies the date and the time at which the event starts.
end_date_time: string. It specifies the date and the time at which the event ends.

And here I have some doubts:

Is the id field required? From what I know I will have the document UID that will ensure the uniqueness of the document. If not strongly required adopt an id field can be convenient have something like an auto increment field? (I know that I have to handle in some other way the auto increment because FireStore is not a relational DB and doesn't automatically handle it). For example I was thinking that can be useful to order my document from the first inserted one to the last inserted one.

It seems to me that FireStore doesn't handle DateTime field (as done for example by a traditional relational database). Is this assumption correct? How can I correctly handle my start_date_time and end_date_time fields? These field have to contains the date time used by my Angular application? So for example I was thinking that I can define it as string field and put into these fields values as 2020-07-20T07:00:00 representing a specific date and a specific time. It could be considered a valid approach to the problem or not?
Answer:
Is the id field required?

No fields are required.  Firestore is schema-less.  The only thing a document requires is a string ID that is unique to the collection where it lives.
There is no autoincrement of IDs.  That doesn't scale massively the way Firestore requires.  If you need ordering, you will have to define that for yourself according to your needs.
In general, you are supposed to accept the randomly generated IDs that the Firebase client APIs will generate for you.  Ordering is typically defined using a field in the document.

It seems to me that FireStore doesn't handle DateTime field

Firestore has a timestamp field type that stores moments in time to nanosecond precision.  There is no need to store a formatted string, unless that's something you require for other reasons.


Proving Cauchy Theorem

Question: This theorem says that a function $f$ is defined in the interval (a, +$\infty$) and it is bounded in every finite interval (a,b).
Then it holds that: (assume that the limit of the RHS exists)

$$\lim_{x\to \infty} \frac{f(x)}{x} = \lim_{x\to \infty}[f(x+1) - f(x)];$$
$$\lim_{x\to \infty} [f(x)]^{1/x} = \lim_{x\to \infty}\frac{f(x+1)}{f(x)}.$$

My question is how to prove the above equations. Any help will be appreciated.
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Comment: I can not get your question ,please elaborate more
Comment: $f$ should eventually be positive in order for $f^{1/x}(x)$ to make sense for all large $x$. Do you have all the conditions for $f$?
Comment: Yeah, definitely here are all the conditions.
Answer: First point: Suppose the limit of $f(x+1)-f(x)$ exists (let's call it $c$). Then for $\epsilon>0$ there is some $R$ s.t. if $x>R$ then $f(x+1)-f(x)$ deviates from $x$ by at most $\epsilon$. Then we can set
$$ f(x) = f(x)-f(x-1)+f(x-1)-f(x-2)+\ldots+f(l) $$
where $l\in(a,a+1]$, so $|f(l)|<C_1$. Also we get that the part of the sum with arguments that are smaller than $R$ is bounded by some $C_2=C_2(R)=C_2(\epsilon)$.
Thus we have
$ f(x) $ is a sum of something bounded by $C_1+C_2$ and a sum formed by $f(y)-f(y-1)$ for some $y>R+1$, so each of these summands is about $c+\delta(y)$ with $|\delta(y)|<\epsilon$. Thus this second part is within $Nc \pm N\epsilon$, where $N$ is the number of such telescope terms in the second part. Note that the number of terms in the first part is bounded by $R-a$, so we have $N(x,\epsilon)/x\to 1$ at $x\to\infty$.
Thus $f(x)/x$ is within $N/x(c\pm\epsilon) \pm (C_1+C_2)/x$ and goes with $x\to\infty$ towards $c$.
The second point follows from the first point by taking the logarithm of both sides and then confirming that $\log\circ f$ still satisfies the conditions to $f$, which is the case as long as $f(x)>0$ and it does not get close to $0$ unless it is in the limit.
Note that if the limit of $f(x+1)/f(x)$ exists this implies that if $f(x_n)\to 0$ at $x_n\to x_0$ for $x_0$ sufficiently large this must also hold true at $x_n+k\to x_0+k$ (and to some extent at $x_n-k\to x_0-k$, as long as $x_0-k$ is large enough). Thus if we take a sufficiently large $x$ and remove all points $p$ from $(x,x+1]$ where $f(p)<\epsilon$ along with all $p+k$ we can ensure that there cannot be a bounded sequence left with $f(x_n)\to 0$.
So we can at least proof it for all of these. But then by having $\epsilon$ go to $0$ we get the result for all $x$ so that $f(x)>0$.
If $f(x)=0$ for infinitely many arbitrarily large $x$ the RHS does inherently make not sense, if $f(x)<0$ for such cases the LHS does not make sense. So it is reasonable to assume that $f(x)>0$ for sufficiently large $x$.
Comment: Bravo! But I'm rather confused about the positivity of $f$ in the second point. How did u conclude that in the last but one paragraph?
Comment: @ppphy I did not conclude anything, but I stated that if we have $f(x)<0$ even for $x$ large the LHS does not make any sense. We can very well have $f(x)<0$ just from convergence the RHS, like take $f(x) = -x$. Then the RHS is $(x+1)/x\to 1$. But the LHS would be $(-x)^{1/x}$, which is not well defined in the reals.
Comment: Well, understood. Thanks so much

Proving Cauchy Theorem


SASS: Atualização do arquivo css em pastas diferentes?

Question: Estou aprendendo SASS e gostaria de saber como atualizar um arquivo .css pelo sass, quando o arquivo .scss e o .css estão em pastas diferente. Por exemplo:
O style.scss está na pasta scss e o style.css está na pasta css.
Entendi que o comando style.scss:style.css gera o arquivo na mesma pasta, qual seria o comando para ele gerar em pastas diferentes?
Grato!
Answer: sass --watch input: output

ou seja:
sass --watch scss:css

Se estiver a utilizar apenas SASS, uma sugestão seria especificar o caminho de output ao compilar:
sass file.scss ../path/to/file.css

Comment: Funcionou aqui Flávio, não estava achando essa informação, ficou claro agora.

Grato!


Git and DiffTool problems : What do LOCAL and REMOTE point to?

Question: Ive been working on getting tortoisemerge working as the difftool option in Git with my .gitconfig file currently showing :
   [diff]
        tool = tortoise

    [difftool "tortoise"]
        cmd = tortoisemerge.exe -mine:$LOCAL -base:$REMOTE

    [difftool]
        prompt = false

According to tortoise merge docs the 'mine' command states which file will be shown on the right, in a two way diff.
My question is, what do the LOCAL and REMOTE variables as provided by GIT actually point to? The documentation is a little vague stating that

LOCAL is set to the name of the temporary file containing the contents of the diff pre-image and REMOTE is set to the name of the temporary file containing the contents of the diff post-image.

The problem arises when I modify a file, and then enter 'git difftool' tortoisemerge is started with the working directory file on the LEFT and not the right as I assume.
I know I can merely switch  the 'mine' and 'local' commands but I was trying to figure out what the local/remote points to and the best way to resolve this issue
Answer: there are 4 components to this (note that before this step, you would have already done a local-checkin.)

The local-checkin that your git tree has: LOCAL
The head of the remote repository (that is going to be merged): REMOTE
common ancestor to both LOCAL and REMOTE: BASE
The file that will be written as a result: MERGED.
Comment: So if you're on master, and do `git merge branch`, LOCAL is the master copy, REMOTE is the branch copy (regardless of repository), right?
Answer: I think that means that $LOCAL is always the a/whatever in the diff output, while $REMOTE is the b/whatever.  In other words, if you do:
 git difftool master experiment -- Makefile

$LOCAL will be a temporary file showing the the state of Makefile in the master branch, while $REMOTE will be a temporary file showing its state in the experiment branch.
If you just run:
git difftool

... that shows you the difference between the index and your working tree, so for each file with differences, $LOCAL will be a temporary file that's the same as the version of the file in the index, while the $REMOTE will be the version of the file in your working tree.
Answer: I am using TortoiseSvn for merge and diff and is working as expected. While in diff, it shows my working copy on the right.
My .gitconfig with TortoiseSvn is as follows
[diff]
    tool = tortoise

[merge]
    tool = tortoise

[mergetool "tortoise"]
    cmd = TortoiseMerge.exe -base:\"$BASE\" -mine:\"$LOCAL\" -theirs:\"$REMOTE\" -merged:\"$MERGED\"
[difftool "tortoise"]
    cmd = tortoisemerge.exe -mine:\"$REMOTE\" -base:\"$LOCAL\"


ratio with 3 numbers and 1 unknown

Question:
If 6 men dig 9 holes in 10 hrs, how many holes will 10 men dig in 4 hrs if they work at the same rate?

We have 6:9:3 and 10:x:4. I formed two equations,
 $\frac{9}{6}=\frac{x}{10}$ which gives me $x=15$ and $\frac{3}{9}=\frac{4}{x}$ which gives me $x=12$. I expected to get the same result from both equations. How do I solve this kind of problem?
Comment: 6 men dig 9 holes in 10 hours means a man digs 1.5 holes in 10 hours. Can you take it from here?
Comment: "So we have 6:9:3 and 10:x:4" no. You have no such thing at all.  You have $9:6\times 3$ and $x:10\times 4$.  Btw is it 10 hours or 3 hours?
Comment: no, still in the dark
Comment: Why do you have two sets of equations. The first equation does take time into account and the second doesn't take number of men into account. You need an equation that take holes,men, and time into account at once.
Comment: Answer these questions, in order (NOT by grabbing a formula, but by thinking about what's actually going on): 1. how many holes will 60 men dig in 10 hours? 2. how many holes will 10 men dig in 10 hours? 3. how many holes will 10 men dig in 20 hours? 4. how many holes will 10 men dig in 4 hours?
Comment: Sixty "men-hours" make nine holes.  Now fourty men-hours will make two thirds of nine holes, that is six holes.
Comment: my thinking was totally off on this one, thanks for guidance
Comment: Just to be sure, is the answer 6?
Answer: Hint: Essentially, what you need to do is find the rate of each individual man. In other words, you need to figure out how many holes each man digs per hour. As mentioned in mlc's comment, 6 men digging 9 holes in 10 hours means 1 man digs 1.5 holes in 10 hours. Then the question is this: How many holes does this man dig in one hour?

ratio with 3 numbers and 1 unknown


Functor from $BG \to \text{Gpd}$ induces functors for each $g \in G$.

Question: I'm reading Groupoids and Stuff. Page 7.

Definition 1.3.1. A group action of a a finite group $G$ on a groupoid $X$ is a functor $A : B G \to \text{Gpd}$ such that $A(I) = X$ where $I$ is the unique object of $BG$ (the category with one object and morphisms elements of $G$.)

This by definition means that each element $g \in G$ induces a functor $A(g) : X \to X$.
I'm having trouble seeing this.  Can you explain?
Answer: A functor takes a morphism $f : x \to y$ to a morphism $\mathcal{F}(f) : f(x) \to f(y)$.
In $BG$, the only object is $I$ and the only morphisms are the group elements $g : I \to I$. The functor $A$ takes one of these morphisms to a morphism $A(g) : A(I) \to A(I)$. Since $A(I) = X$ we have $A(g) : X \to X$.
Comment: Oh, I see it's a groupoid morphism or a functor that it gets taken to.


iOS StoreKit - simulating incomplete and interrupted in-app purchases

Question: I have an issue with a live app where incomplete purchases are being mishandled. I am trying to test my new code to make sure that this will be taken care of, so I download the live app, cause the problem, then load my development app (or Ad-Hoc app) hoping that the StoreKit Observer will catch the incomplete purchase notification. No matter how I do this (development or Ad-Hoc) the observer does not fire a notification.
My general question is: How can I simulate incomplete and interrupted purchases in the App Store testing environment?
My more specific question is: Can I simulate the specific issue where the user must leave the app to confirm their current credit card pin number on the app store?
Answer: According to this helpful page:

Test an Interrupted Transaction
Set a breakpoint in your transaction queue observer's
  paymentQueue:updatedTransactions: method so you can control whether it
  delivers the product. Then make a purchase as usual in the test
  environment, and use the breakpoint to temporarily ignore the
  transaction—for example, by returning from the method immediately
  using the thread return command in LLDB. Terminate and relaunch your
  app. Store Kit calls the paymentQueue:updatedTransactions: method
  again shortly after launch; this time, let your app respond normally.
  Verify that your app correctly delivers the product and completes the
  transaction.

Hope this helps someone.
Answer: To your general question:
SKPaymentTransaction provides several transaction states like SKPaymentTransactionStateFailed
According to the Documentation you can check out the error property to see what happened.
For example you can check it in -(void)paymentQueue:(SKPaymentQueue *)updatedTransactions:(NSArray *)transactions callback like so
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
    for (SKPaymentTransaction * transaction in transactions) {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStateFailed:
                ...
                break;
            default:
                break;
        }
    };
}

Hope this helps.
Comment: Sorry, let me clarify: how can I *simulate* failed and interrupted transactions?


wp7 application bar without navigation

Question: My problem is that the application bar is not displayed on a page if I don't use the navigationservice to navigate to that page. My code is : frame.content = page, but I need an application bar. Any help would be appreciated.
Answer: After reading your comments to Derek's answer. can't you have the second page be a static empty XAML file with just some sort of container, a ContentPresenter for instance. Then the user generated content could be placed into that instead of a dynamically generated page.
That way, you can just navigate to the page and populate the content, instead of messing with frame's content property directly.
Comment: I agree. Messing with the frame's Content property is not going to get you to any place helpful. I'd still like to understand the whole problem better, though :)
Comment: Me too, I'm curious how this framework @Vic is creating makes life easier for a developer than just throwing together a page yourself in XAML and VS / Blend. I might want to buy it if it really does :-)
Comment: Well, it's a multiplatform framework, WP7 is only one platform, the functions are given, a virtual machine interprets the bytecode on-the-fly and makes the user-generated code work. But I take your advice and make this work via ContentPresenter.
Answer: When your page is loaded, what is the value of the ApplicationBar.IsVisible property?
UPDATE: So, I would imagine that the problem is to do with updating the Content property of the PhoneApplicationFrame, rather than navigating to it using the NavigationService. Presumably, under the hood, it's doing whatever is necessary to show the application bar.
Comment: OK, I've updated my answer a bit. Why do you need to update the Content property directly, instead of using the NavigationService?
Comment: Is there a page visible before you update the Content property, and does it have a visible application bar?
Comment: It seems to me that only the Applicationbar of the current source of NavigationService can be displayed or hidden. At first I navigate to this page, but after that I set the content of the frame to a second page, then navigate to a third page. When I set the content of the frame to the first page again, the navigationservice.currentsource contains the third page. So the answer for your modified question is yes. I cannot use navigationservice, because my second page is generated dynamically, cannot be stored in a .xaml.
Comment: Based on the information you've given so far I can't pretend to understand what you're doing in your application, but I'm pretty sure you could do whatever dynamic content generation you're doing in a page of it's own and navigate to it using the NavigationService instead. Clearly you're current approach is not working well, and I don't think you'll find a workaround. Feel free to provide more details about your application scenario so we can give a more informed solution to your problem.
Comment: The problem basically is that when I use navigationservice for a page, then load a second page by directly setting the content of frame, and then navigating back to the first page, an error is raised: the program cannot navigate to the same page (because navigationservice is at the first page already). I can handle this by setting a dummy query value (page.xaml?dummy=...) which is incremented every time I navigate to the page, but I must navigate to the first page and set the second page quite often, and every navigation opens a new page...
Comment: My second page is always a generated page (I have no influence on the content), because this is a programming framework. So the user adds controls to the page, then I must show it on the phone. Only my first (and third) page can be declared in .xaml.

wp7 application bar without navigation


Why JSP doesn't throw error for non-mapped fields in Struts 2

Question: I've my Struts 2 actions as ModelDriven. I've some fields defined on the actions themselves as well. However, if in the JSP I use wrong field names that are neither in ModelDriven model nor directly used as action member fields then I don't get any errors and it simply ignores those fields.
 <s:if test="(method == 'list')">

If method is neither a ModelDriven model field nor an action member field then it simply ignores this s:if statement and doesn't execute instructions inside this s:if statement.
Any idea on how to throw errors on JSP for fields that are non-mapped in the ModelDriven models fields or in the actions of ModelDriven models?
Comment: Read [this](https://stackoverflow.com/a/20244124/573032) answer. I'm wandering why did you use round brackets inside the test?
Comment: The parenthesis are purely for keeping up with the java convention.
Comment: It's ognl language. See [this](https://stackoverflow.com/a/16716897/573032) answer
Answer: OGNL expressions can throw exceptions but they are caught internally.

The OGNL expression is evaluated in this attribute, like in many other
  attributes of Struts tags, and if can't resolve the value it returns
  null. This value is unacceptable for the if tag.

However, if you know which expression returns null then create a boolean expression.

Any idea on how to throw errors on jsp...

The java code is encapsulated in the tags implementation. If tags cannot execute they throw 500 internal server error. You can write your custom tags to throw that errors.


unable access the inner nested datalist

Question: in my web application , there is datalist, which is inside another datalist.
i want to access that datalist . for this purpose i written this code
DataList dl = (DataList)dlPro_Details.FindControl("dlFeatures");

but when i try to run the application , then it throw Object reference not set to an instance of an object.
then set the debug the point to it , the i found my object dl is null .
i have also tried to use ItemDataBound
protected void dlPro_Details_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        int id = 8;
        string getFeatures = "";
        con = new SqlConnection(str);
        con.Open();
        SqlCommand cmd2 = new SqlCommand("select * from Products where Pro_id=" + id + "", con);

        SqlDataReader dr = cmd2.ExecuteReader();
        while (dr.Read())
        {
            getFeatures = dr.GetValue(11).ToString();
        }
        string se = ",";
        List<string> l1 = new List<string>();
        string[] featurs = getFeatures.Split(se.ToCharArray());
        for (int i = 0; i < featurs.Length; i++)
        {
            l1.Add(featurs[i]);
        }
        DataList dl = (DataList)dlPro_Details.FindControl("dlFeatures");

        dl.DataSource = l1;
        dl.DataBind();
    }

dlPro_Details is my parent datalist
this is my complete  code
<asp:DataList ID="dlPro_Details" runat="server" OnItemDataBound="dlPro_Details_ItemDataBound">
                    <ItemTemplate>

                                        <asp:Image ID="proImg" runat="server" Width="230" Height="300" ImageUrl='<%#Eval("Image") %>' />

                                        give rate
hello

                                        <asp:Label ID="lbl" runat="server" Text='<%#Eval("Name") %>' Font-Bold="True"></asp:Label>

                                                  <asp:Label ID="lblWarenty" runat="server" Text='<%#"Warranty :  "+Eval("Warranty") %>'></asp:Label>

                                                  <asp:Label ID="lblBrand" runat="server" Text='<%#"By :  "+Eval("Brand") %>'></asp:Label>

                                                  Rating

                                           <asp:Label ID="lblFeatHead" runat="server" Text="Features"></asp:Label>

                                            <asp:DataList ID="dlFeatures" runat="server" RepeatColumns="5" RepeatDirection="Vertical">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblFeatures" runat="server" Text="Label"></asp:Label>
                                                </ItemTemplate>
                                            </asp:DataList>

                    </ItemTemplate>
                </asp:DataList>

Comment: Show your markup of DataList
Comment: i have edited my question . now you can see my complete markup for datalist.
Comment: why you want to access it on page load.give some description so we can give you some other ways to perform action what you want.@Amit
Comment: I suspect the problem is that because it is in a datalist it is not a single control you are getting there. Not sure of the solution to that offhand though sadly.
Comment: @SumitPathak: as you can see from my code , i just want to assign the diffent data to label of inner datalaist . so  i want to access it on pageload . if you can suggest me diffrent idea to assign the list to inner datalist , so that when my parent datalist laod then inner datalist should also be loaded
Answer: You will find the reference to the current item using one of the arguments, and from there you can access any nested control:
protected void dlPro_Details_ItemDataBound(object sender, DataListItemEventArgs e)
{
    if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        var innerDL = e.Item.FindControl("dlFeatures") as DataList;
        if(innerDL != null)
        {
            //do something
        }
    }
}

Comment: it showing == ItemType.type ||
doesn't exist in current context
Comment: Sorry, my bad. I've corrected the code. Its supposed to be `ListItemType.Item` or likewise.
Comment: yes i got that .
but sir now how can i bind that list item to inner datalist label.
i want to show the data of list  , to show in label of datalist.
Comment: I knew this was the next problem. :) Plz refer [this](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.itemdatabound(v=vs.110).aspx)

unable access the inner nested datalist


Why does music sound bad when played backwards?

Question: I am not sure where to post this, but I hope it fits here.
If you have ever recorded music, and play the track backwards, you'll notice it sounds quite strange, almost demonic.  I have always wondered, why doesn't music sound good when played in reverse?    It just doesn't seem at all intuitive to me, if you had never heard classical music recorded and played backwards you might expect it to still sound ok.  There is so much  structure in the sound, so why does it seemingly disappear in reverse?
Why does the harmony of the notes break down, and become (what appears to sound) so chaotic.     This doesn't work the same way if I just play the notes in reverse on a piano.  Scales are a perfect example, and sound identical in either direction.
I hope this is relevant, it is something I have always found curious.
Comment: The solo of Hendrix's "Castle made of sand" was pretty cool..doesn't sound bad at all. May be if you reverse something bad or random you'll end up with something cool sounding.
Comment: Just a hint, you might try listening to some music without drums backwards, it suddenly gets a lot more pleasant. This has to do with the 'volume envelope' of sound, which is very harsh with drums, and makes a sound you wouldn't hear naturally. Tonal sounds which fade in slowly can be quite pleasant, without that harsh ending (the 'attack' of the sound when it's played forward, but in reverse, the 'decay). Give it a try. Also, singing is usually unsettling reversed, again because it's not such a natural sound.
Answer: The reason why music sounds so odd when played backwards has little to do with musical theory per se. It's all about the our psychological expectations of the physical sound phenomena.
Our brain expects instruments to sound a certain way, it expects a piano to begin with the attack, a quick rise in intensity, then stabilize somewhere along the way and then fade away smoothly. When we hear a reversed piano all these aspects are now reversed and it becomes a sound that begins quietly and ends with a powerful attack, something we're not familiar with because it's a rare thing to hear in nature (it might not even exist naturally).
The same goes for all instruments. Our brain uses the wave shape and variations in volume and other aspects of a sound to extract musical information. When it's listened in reverse the lack of familiarity with the sound structure makes it sound "odd", "scary", "demonic". This is even used as a compositional element, as you might be aware of artists recording reversed vocal tracks or instruments.
To further illustrate what I mean, listen to these sound samples generated with Timidity and the Unison soundfont. A little melody followed by some chords is played and in sequence it's played in reverse:

Piano
Flute
Strings

See how the piano sounds weird, but in turn the flute and strings are "passable"? We might notice there's something wrong but it isn't as much as the piano. Try opening these files in a program like audacity and observing the shape of the sound waves.
Comment: +1 This is a good point as well. I'm not sure it alone can explain the phenomena, especially since some instruments have a more "symmetrical" sound than others, but it certainly has a big effect in many cases. I can't imagine playing a recording of my trombone playing backwards… my attacks and releases are occasionally shoddy enough as it is!
Comment: This makes sense to me, nothing in nature smoothly amplifies to reach a sharp noise and then stop altogether.  Of the mandmade things in our society, all I can think of that would do this sound terrible anyway.  (If you use powertools, I think certain cutting noises will do it, but I believe there is concensus that powertools sound _really_ bad.)
Comment: Case study: The ending of [Pendulum-Granite](https://www.youtube.com/watch?v=UgopMlJ00Sc), when reversed, is the beginning of [Pendulum-Granite](https://youtu.be/_AGcNCmBSdI?t=48).  Except all of the sounds are backwards, making it sound really weird.
Answer: Eric,
Classical music, and really, most kinds of music, sound odd when played backwards because the harmonic progression does not lead where you expect it to. Without going to deep into music theory, I'll outline the basics.
A typical cadence, or ending of a chord progression, is a IV chord to V to a I chord. (Roman numerals signify chords built out of a major scale, starting on that degree of a major scale, so V is the fifth scale degree.)
This cadence is a very typical one, and you'll hear it everywhere. What that cadence does, is go from the chord with the most tension in the key… to the tonic, or home chord of the key. In this way, you have tension and relaxation, which is the foundation of harmony.
A more advanced chord progression might go I-vi-ii-IV-V-I. This progression sounds different, but it still ends with that characteristic IV-V-I, also called a Perfect Authentic Cadence.
Now getting into one of the reasons music played backwards sounds so odd: Our ears expect that Perfect Authentic Cadence. (Simplifying here, there are other pleasing cadences.) Sometimes, a composer will do a cadence like: IV-V-vi. This cadence is called a Deceptive Cadence, because your ear will expect the IV and V to inevitably lead to I. When it goes to the vi you get a denial of expectations. While I'm simplifying, these basic ideas of tension and relaxation are what gives music it's sound, feeling, attitude, soul, etc.
When these characteristic cadences and progressions get reversed, it essentially throws that whole system out the window. Now you're going I-V-IV-ii-vi-I and not only does that defy expectations, your brain  likely is just going WTF?!? For lack of a better term…
To hear these cadences for yourself play this on the piano:
 Courtesy this Wikipedia article:
To hear a recording of just these three chords, go here.
Hopefully this makes sense!
Answer: The above are all good points.
  Another thing I want to point out is that many instruments are in a sense defined by their attack note.  I hypothesize that by cutting off the attacks in a recording of many different instruments playing the same pitch, the tones are largely indistinguishable.
  So, if the attack is really as important as I think,  'backwards-tape' playing of a song/piece will loose much of its characteristics, as the attacks do not define the note or pitch, but only briefly punctuate them.
  The strange-sound effect is much more overwhelming this way.
Comment: Yes indeed, this seems to be the case many times. In fact the brain uses the clues given by the attack and the different volumes of the sound and its harmonics to perceive musical information. I know there's some papers analysing this somewhere but I'm not finding them now.
Answer: First, it doesn't across the board sound "bad", whatever that's supposed to mean, or else backmasking wouldn't be used.
You could say it sounds "odd" or "unnatural" - without the vague word "bad" muddying the waters - and make these two points about the nature of music:

Playing a sound backward reverses the sound envelope
Playing a sound backward reverses the 'syntax' of common harmonic progression

The sound envelope is basically how an instrument's sound changes over time. Reversing the envelope will be most noticeable for instruments with a strong attack such as plucked strings and percussion. It's easy to whack a cymbal with a stick, get a big crashing attack and slow sizzling decay. But it would be very hard to make a cymbal start to lightly vibrate louder and louder until a sudden, very high vibration that instantly stops. Reversing a recording allows you to artificially achieve that reversal. It sounds strange, because it defies the physics of how acoustic instruments normally work.
Reversing musical syntax is a bit trickier to explain. There is a technical terms for reserving the time order of musical elements, usually melody, called retrograde. In many cases melodies can be reverse with no problem. But when chord progressions are considered, they don't really work in reverse. Specifically, they don't have the same effect.
A fundamental harmonic progression would be I V I and obviously there is "reversal" happening, I goes to V and then that V just goes right back "in reverse" to I. But if we think of those two as harmonic gestures in terms of progression we can say I V is a kind of "starting", an antecedent, but the reversal V I is a "ending", a consequent. The oddness of reversing harmony comes from starting with the ending and ending with the starting
It may be a bit of a stretch, but you can compare this to the idea in physics of the "arrow of time" and entropy. Basically time moves in one direction only, forward. Play a recording backwards gives the illusion of something going backwards. We can listen to a recording of a cymbal crash played backward, but the cymbal did not actually vibrate in reverse.
Comment: Because harmonic syntax *is* a syntax. Reverse "Jim ate chicken" and... things get weird. Various languages use various orderings of components to construct meaning, and so does the western tonal system.
Comment: @AndyBonner ..."chicken ate Jim" Yikes! :-)
Comment: I think a whip or something breaking the sound barrier might produce a smooth sound ending with an attack. Not very relaxing sound though...
Comment: @Emil only in an anechoic chamber would it come close.
Comment: @Edward what do you mean? It first makes a whooshing noise when in the air, end then it makes a crackling sound when it breaks the soundbarrier. I saw it on mythbusters a long time ago.
Comment: You could probably just play the mythbuster episode in reverse, no need for fancy anechoic chambers.
Comment: And then that crackling sound reflects off of every nearby object, producing a reverb tail.  The sound doesn't end with the crack.
Answer: The answers herein all make great points, but chord progressions, ADSR envelopes, and expectations aside, the notion of music "sounding bad" is purely subjective to begin with. (Although the percentage of agreement may be higher on some pieces than others!)
Some compositions, particularly in the electronic music domain do not follow "traditional" ADSR envelope and spectral distribution expectations to begin with. There are many aesthetics of what makes a musical piece "sound good". Rhythm, spectral distribution, harmony, and balance are all still artistic tools that can be used and exploited in reverse. Don't be afraid to experiment. You may just find something new that you otherwise wouldn't have appreciated!
Answer: One point that I don't think is covered in other answers is the effect on the timing of the notes.
Musicians will generally concentrate on getting the beginning of each note to fall rhythmically at the correct time. But the timing of note endings will me much less accurate and often quite arbitrary. So when the music is played backwards the rhythm will sound odd or be lost completely.
Answer: The synth people categorize music by four categories: attack, decay, sustain and release. Attack is the initial peak when the note starts, Decay is the drop from the attack's peak to sustain's steady state, and Release is how long the note stays around when you stop playing it.
Piano and guitar are known for pronounced attack, and as lfzawacki noted, piano sounds stranger reversed. Guitar is the canonical instrument for reversing. In general, you can strike a note, get a big note that comes down and fades, or you can blow a note, which stays fairly constant until you let go. Reverse the second type and it sounds about right. Reverse the first type and you reverse the way sound works.
Answer: For one thing, attack and decay are exchanged.  For another, anticipation and resolution.  And even for instruments with continuous tone the onset is strictly on the beat but the release position depends on articulation and is rarely on the beat.  So all of the onsets in the reversed music, assuming that they are reasonably hearable, are timed fuzzily and come earlier when articulation becomes more legato and later when it gets more leggiero or staccato.  But that means that tension and tranquility are no longer having a timing matching their emotion.
And take an organ: the instrument may have on/of sound production and thus appear to be one of the better reversible ones, but the reverbation comes after the sound, not before.  You'd need to record in an acoustic studio rather than a church or hall in order to get read of the tell-tale reverb direction.
Answer: In the question several descriptive terms were used that have little to no absolute definition. However i think most of us would agree that "Bad" being a matter involving judgement to determine, and"demonic" which some may deem to be a purely imaginative term, also the word "Strange".... same thing. I would use the word "Negative" to more clearly state what is happening to the sound that is being asked about.
"Why does music sound "negative" when played backwards. This allows a much simpler explanation being "because it is "negative" The same as a ligt image reversed is a "negative" image. Looking "Bad" "Strange" and "Demonic". Nothing is created in its negative state. Music is creation. It is created. When played or listened to backwards what we are experiencing is negativity which is degenerative,we are hearing creation decay or more descriptively speakin death. We as living creatures seek life and accept life. Death, decay, pestilence, disease, all negativity is rejected and knoen to be "bad" "Strange" and even "demonic".
It sounds that way because it is.
Answer: It actually has nothing to do with the music itself, it's just how us humans work. We are used to things starting loud and then fading out or we expect something specific, then when it's reversed we don't have what we expect, and this it sounds way creepier. (My theory may be wrong since I'm not that good to how the human body works, if someone can tell me how it actually works in case my theory is wrong you can tell me.)
Comment: Welcome and thanks for contributing! In the future, though, if you're not very confident about your answer, it's okay to not post it (or to make a comment on the original question instead), especially when a question is as old as this one and has gotten so many lengthy answers. I think your theory is probably right, though. I wonder whether there's a source that could be found that says the same thing?


Black keys issues on keyboard

Question: New here.I am a keyboard player (wanted to be a pianist but couldn't afford it). I use  yamaha PSR-E403, which has non-weighted keys.Suppose, I am improvising over F# Major pentatonic scale, which has all black notes.My fingers slip if I try to go to tempo like 80BPM with 4 notes in each beat.Also, thumb on the black keys is nightmare for me and it becomes a major problem when I have to tuck it under from my 3rd finger. Same problem occurs if i am arpeggiating over F# major chord on 2-3 octaves. I do great with chords like D,E, basically, when my thumb on the white keys but whole hand on black keys feels unnatural to me. How to improve contact and controls on the black keys ? I don't have any teacher to guide me on this so, any suggestions will be appreciated.
I am not sure though but it can also be a problem of my instrument, I have seen pianos with flat shaped black keys from the top but in my instrument black keys are slight curved from the top.
P.S. I have spent quite a lot of time practicing slow.
Comment: Could you visit a music shop and compare to see what is the same and what is different when you play a piano and when you play a different sort of keyboard?
Answer: In classical music it is a general rule that the thumb always stays on the white keys. Obviously Stevie Wonder does not adhere to this rule when he plays Superstition in Eb, but there is some sense to the general rule.
Notice how short your thumb is compared to the rest of your fingers (at least mine is!). Black keys are further away than white keys so playing with your thumb on the black keys means you have to twist your wrist or go up so far on the black keys that the rest of your fingers can't play comfortably. So bringing your thumb into the mix means moving your hand around a lot more than usual, destabilizing your technique.
My technique is not particular good, so I know the issue very well. I also always feel like slipping and sliding when playing in Eb minor, so it is definitely one of the more difficult keys to play. If anyone out there have a greater way to do it, I'm all ears, but personally I've just practiced moving my hand back and forth quickly to compensate. But I am definitely adapting my soloing to the key and playing less 16th notes than I would given I was playing D minor.
Comment: What about not using your thumb on black keys when playing in E flat minor? You can thumb-over to the f and/or c-flat (in fact, you'd do both in the standard fingering for an E flat minor scale, starting with a 2 on the E flat). Also, the D flat is raised quite often for obvious reasons, providing an extra "thumb point".
Comment: That describes what I'm doing at the moment pretty well, but I was mostly talking about when you play all black keys (i.e. Eb minor pentatonic). The Superstition groove is a great example. On one hand it is great to play in Eb, because you can hit mostly any black notes and it will sound good, but I find it hard to stay stable when playing fast runs.
Comment: Ah, yeah. Pentatonic is nasty.
Answer: Muscle memory.
The idea is to do each step a few times, as opposed to the whole song, with your hand and fingers raised higher then usual.
You should ask someone before trying, as you can hurt yourself easily.

P.S.: it will be a pain in the neck, but can do miracles.

Black keys issues on keyboard


Can someone explain the concept of ancillary statistics in layman's terms?

Question: I'm having a hard time trying to relate or understand it in the simplest way (without solving).
"Without solving" in a sense that I don't have to solve for the marginal distribution of T2, if for example there are T1 and T2, and see that it is independent of the parameter. I'm just trying to find a way how to explain it to other people in layman's terms without using any technical statistical terms
Comment: Can you clarify what you mean by "(without solving)"? Also, can you include references to where you are trying to learn ancillary statistics from?
Comment: "Without solving" in a sense that I don't have to solve for the marginal distribution of T2, if for example there are T1 and T2, and see that it is independent of the parameter. So far, I've been using my lecture notes from my class, which only includes the usual definition that can be found online that T=(T1,T2) is sufficient for a parameter, where T1 is conditionally sufficient and T2 is ancillary. I also read Casella's section on Ancillarity. I'm just trying to find a way how to explain it to other people in layman's terms without using any technical statistical terms.
Answer: The way I think of ancillary statistics is: a data set has numerous sources of randomness. A sufficient statistic carries all the information that I can extract in the data about this randomness. A minimally sufficient statistic is the "smallest" sufficient statistic. Now say that this has the form $S = (T,C)$.
Now I happen to be interested only in some aspects of the randomness ($T$) in the data, and I would rather condition on the uninteresting parts (treat $C$ as actually fixed to $c$). This makes sense to do when $C$ depends only on parameters that I am not interested in, and it is especially useful when $T|C$ has a simple distribution.
For example, I carry out a linear regression. I am interested in how some covariate affects the outcome, and I assume that $Y_i \sim N(\alpha + \beta x_i, \sigma^2)$ for $1 \leq i \leq m$.  What I care about is $\alpha, \beta$ and $\sigma^2$.
But there are also other sources of randomness: $x$ is probably realization of a random variable $X$ (uninteresting). The sample size is probably random as well (if it is not fixed in advance), and $m$ is a realization of a random variable $M$ (uninteresting). When I carry out my linear regression I condition on these aspects of the data. One reason is that I am not really interested in $X$ and $M$ per se. The second reason is that it would be very complicated to write a likelihood for all sources of randomness $(Y_i, X_i, M)$, $1\leq i\leq M$ at the same time.
If there is a minimal sufficient statistic $S=(T, C)$, and $C$ describes exclusively $X$'s and $M$ then I would rather condition on $C=c$, which is the same as treating $X_i = x_i$ and $M = m$ as fixed.
Comment: (+1) Very clear account. Typo in last sentence: "Ife is a minimal". Perhaps consider adding some discussion of the consequences of conditioning on $C$ for the relevance of the hypothetical long-run properties of estimators &c.