How to become a good musician at a later age?

Question: I'm a soon-to-be psychology graduate, however my big passion is playing guitar, and I was wondering if I could turn my hobby into something more serious.
I've been a bedroom guitarist for about 6-7 years, and I know how to play a couple of scales and some known riffs, but I don't think I'm at a level where I could even go out on the street and play a song from start to finish. So, I thought about taking up a music degree, but this would involve creating a portfolio of music before I could attend any school.
Do you have any good advice or tips on how to approach this? Maybe just words of hope? :)
Comment: Getting in to a music program at the post-secondary level usually requires an audition and some serious proficency already on an instrument. If you can't play a song, how would you audition? My advice is to check out the questions on here about practicing effectively and then practice, practice, practice. See: http://music.stackexchange.com/questions/1338/guitar-practice-more-often-but-less-time-or-once-in-a-few-days-but-for-a-few-hou
Comment: When you say you can't play a song start-to-finish, are you saying you couldn't play an audition-piece instrumental bit? Or you couldn't bash out chords to "Louie Louie" for someone to sing along to?
Answer: I'd recommend finding some peers to encourage and push you. For instance, look for a blues society/club in your area, and get involved jamming and learning.
In particular, I mentioned the blues, because it's a very wide range of styles, and ages, and difficulties in playing. You can learn simple blues chord progressions and scales, then build on top of them, and even if you're rough, you'll still fit in nicely.
They'll have lots of informal jams and performances, and because of the simple chord progressions, you'll be able to play along soon, which will encourage you and help you get over the anxiety hump of age, and ability.
Be honest about your abilities, or better, be a bit self-depreciating, and friendly and go in with an attitude of learning, and I'm sure you'll be plenty good in no time because you'll be playing your fingers off.
Rock and jazz are built on the blues so it's a good stepping stone to the other genres.
And, if you think age is an issue, check out players like Hubert Sumlin, who we saw in concert last year, and is one of my wife's favorites or David "Honeyboy" Edwards.
Comment: Being involved with other musicians in any capacity, is a must
Comment: The thing to watch out for is that a lot of local blues clubs are filled with blues purists. You need to avoid the clubs that believe that the blues ended in the fifties. These clubs are stale to the point of being boring.  I usually play standard twelve-bar blues progressions as i7-iv7-v7 instead of the more traditional i-iv-v form.  Substituting minor 7th chords for straight minor chords opens up the progression and affords one the ability to solo in diatonic minor modes such as Aeolian and Phrygian without the result sounding weird.
Answer: The biggest difficulty for adult learners is that we're scared/embarrassed of our mistakes. Kids and teens aren't afraid of mistakes, and just practice anyway. Adults have a clear vision of what we want to sound like and when we fall short, it hurts. The primary chemical abused by adults to reduce the inhibition caused by embarrassment is also the same chemical that destroys our ability to perform and recognize that we suck - alcohol.
As for the university level instruction, if you are able to convince your music department to let you in for guitar practice, go for it. But I'd avoid the music degree idea as the incoming students will most likely be much better than you, along with the audition requirement coming in. Many music programs require a second instrument, but that's usually accommodated by voice or piano.
When I was working on a second bachelors, I was in a multidisciplinary program that I learned much later automatically allowed my to bypass requirements such as "student must be enrolled in a [specific] degree" or "student needs consent of the department". I managed to get myself into music theory courses (which is what I was interested in), but they had a requirement for sight singing, and as these were first semester courses for incoming music students, they were scarily more advanced than I was (being about 15 years older than everyone else in the class wasn't helpful either).

But I don't think I'm at a level where I could even go out on the street and play a song from start to finish.

Most American college level music courses require a recital performance at least once per semester.
Advice: practice anyway. Look for an instructor that offers adult instruction.
Answer: I'm 31 - and I've been playing the guitar on and off for 8-9 years now. I never took it seriously till around 1.5 years back. That's when I started attending classical guitar classes (actually, it was after a gap of 5 years) - since that's what I wanted to play. With a demanding day job and everything, a weekly class seemed to be the best bet for staying on track. I managed to clear a Trinity College (London) Grade 2 exam, and am planning for the next one. I don't have my sights set on a musical degree, but I'm definitely planning to clear all the Grade exams. End of story.
Here's what I have learnt about becoming a musician at a later age -

You will no longer have the time to practice leisurely you had as a kid, so you would need to carefully structure your time. A weekly class is essential as a guiding path. In your case, this might be some kind of a foundation course. Also needed is a good teacher who understands your situation and is willing to map out a musical improvement plan tailored specifically for you.
The big advantage you have over younger players is that you would (most probably) know better time management and have better focusing abilities. You would know what 'deliberate practice' (ala K. Anders Ericsson) **  can transform you into.
As the Tin Man has already mentioned, playing with other players is very important. They need not be in your age group, but it's easier if they are (in class).

I'm not sure what kind of music portfolio you require to be eligible for a music degree, but I'm sure you can get there! Hope this helps.
** K. Anders Ericcson - The Role of Deliberate Practice in the Acquisition of Expert Performance - available online here - http://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.169.9712&rep=rep1&type=pdf
Answer: There's really two keys: Playing with people and playing in front of people.
When you play with other people, the specifics of your failings -- your timing, your tendency to count to three instead of four when counting measures, your same lame licks, whatever -- come into view, usually in a fairly obvious way. You may think "Man, I want to learn how to flatpick! I want to learn how to play flashy licks!" or whatever, but when you as a new player come away from playing with others, you'll recognize issues of timing, phrasing, and other of the fundamentals.
When you play in front of people, it's a performance, when you blow a lick, you can't call time and start it over. The urgency is there.
I play for my church, and I started at 30 years old about ten years ago. I had played jams and such before, but not much, and to the extent I can play, I can play because I weekly played out in front of other people with other people.


How to combine different predictions together?

Question: Is there a way to combine different predictions to create a prediction?
The way I am thinking about it is, a lot of times while learning different things, we learn small separate parts of a subject and are able to combine them together to get "the big picture".
Similarly, if I use some algorithms to learn different small things from a dataset, can I train a separate algorithm to create a big picture out of it?
Comment: As it stands that is quite broad. Perhaps you would get better answers if you can be more specific about what algorithms you are using for what task.
Answer: What you are describing can be done with ensemble methods. Let me give you and overview. The goal is to train a classifier for subsets of the data set and combine them, such that the classification rate is optimized in some way.
Ensemble Methods
Ensemble Methods are a type of meta algorithm based on the following idea: Consider a multinational corporation facing a
difficult decision, i.e. they have to decided between going with strategy $A$, $B$ or $C$. To make an informed decision, the executive
board asks some experts for their advice. After presenting the facts to the experts, each of those then recommends a strategy. The executive board is then presented with the recommendations of the experts and decides to go with the strategy
that was recommended the most. More formally, $n$ Experts $e_i$ give $n$ responses $v_i$ (votes), which are accumulated over each of the $l$ possible decisions $d_j$:
\begin{equation}
v_{i,j} = \begin{cases}
1 & e_{i} \textrm{ votes for } d_{j}  \\
0 & \text{else}
\end{cases}
\label{eq:cases}
\end{equation}
The total votes $V_j$ for each $d_j$ is then calculated as follows:
\begin{equation}
V_j = \sum_{i=0}^{n}{v_{i,j}}, \textrm{ j = 1, ..., l}
\end{equation}
The final decision $V_{\text{final}}$ could then be made by taking the majority vote, i.e.
\begin{equation}
V_{\text{final}} = \text{argmax}(V_j)\end{equation}
How can the executive board make sure that the decisions they are presented with can be trusted? It has to be ensured that members of this ensemble are selected such that:
<code>1. They have gone through extensive training, i.e. they are truly experts
2. Each cover different areas of expertise (diversity)
3. There are sufficiently enough experts
</code>
One could imagine an example where the executive board is not trusting the experts equally. This can be expressed by weighted voting with introducing a weighting factor $\alpha_i \in [0, 1]$ for each of the $n$ experts:
\begin{equation}
V_j = \sum_{i=0}^{n}\alpha_i {v_{i,j}}, \textrm{j = 1, ..., l}
\end{equation}
Given the fact that the experts can't always be right, i.e. they make errors, one might ask how to approximate the error rate of the entire ensemble given the individual errors of the experts within. Let $p$ be the probability that any given expert is wrong. The probability of getting $m \leq n$ wrong answers can then be  seen as the probability of an event (being wrong) occurring $m$ times in a row with probability of $p$ for each trial. This can be modeled as a Bernoulli Experiment and can therefore be computed using the Binomial Distribution:
\begin{equation}
P(m) = \frac{n!}{m!(n-m)!}p^{m}(1-p)^{n-m}
\end{equation}
This concept can be directly transferred to machine learning and statistics. In this context the experts are called classifiers or (weak) learners. Ensembles can be used for classification, where the goal is to decide for a given sample the corresponding class. In the earlier example the sample would be current state of the corporation and the classes would be the possible strategies. A optimal class is then a strategy that fits the current needs and goals of the corporation the best. Ensembles are also used for regression. Regression is the task of fitting a function with minimal error.
Bootstrap Aggregation - Bagging
Proposed by Leo Breiman in 1996 [1], bagging is a meta algorithm designed to improve classification results by randomly creating subsets of the training data.
Assume we have a set $T$ of training data. The goal is to separate $T$ such that the resulting subsets approximate the underlying distribution well. After the subsets are created, one classifier (e.g. a classification tree) per subset is trained. The subsets are cre-
ated by uniformly drawing $n_B$ samples $x ∈ T$ with replacement. It follows that a given sample $x_i$ may or may not be represented. Aslam et al. [2] showed in 2007, that when $n_B = |T|$, the expected fraction of singleton samples is $1 − \frac{1}{e}$ (≈ 63%).
The resulting sample set $T_B$ is called the bootstrap sample. The set of bootstrap samples $\{T_B\}$ approximates the underlying distribution.
The following algorithm shows the complete bagging procedure:
Data: Data set $T$ , set of classifiers $L$, number of iterations $n_I$, bootstrap sample size $n_B$
Result: Trained ensemble $L_E$
<code> foreach i ∈ {1, ..., n I } do
   Ti ← bootstrap sample from T with size nB
   Train Li on Ti
   LE ← LE U Li
 end
 return LE
</code>
[1] Leo Breiman. Bagging predictors. Machine Learning, 24(2):123–140, 1996.
[2] Javed A. Aslam, Raluca A. Popa, and Ronald L. Rivest. On estimating the size and confidence of a statistical audit. EVT, 7, 2007.
Comment: How would you do this one? https://math.stackexchange.com/questions/3798022/how-to-approach-this-inference-problem-where-we-want-to-combine-predictions

Predictions must be on the same problem to make it easy.
Answer: In theory yes, there is a technique call stacking that is similar to what you said.
https://www.quora.com/What-is-stacking-in-machine-learning
You can do parts o train different classifiers of all dataset and then use their predicts like input of a new classifier (meta-classifier).


ORA-20024: REST enablement for maintained schema disallowed

Question: I have set in ORDS without APEX when I try to enable the schema, I get an error. What am I doing wrong?
BEGIN

    ORDS.ENABLE_SCHEMA(p_enabled => TRUE,
                       p_schema => 'DEVUSER',
                       p_url_mapping_type => 'BASE_PATH',
                       p_url_mapping_pattern => 'devuser',
                       p_auto_rest_auth => FALSE);
    commit;
END;

Error report -
ORA-20024: REST enablement for maintained schema disallowed : DEVUSER
ORA-06512: на  "ORDS_METADATA.ORDS", line 183
ORA-06512: на  "ORDS_METADATA.ORDS_INTERNAL", line 281
ORA-06512: на  "ORDS_METADATA.ORDS_INTERNAL", line 688
ORA-06512: на  "ORDS_METADATA.ORDS_INTERNAL", line 640
ORA-06512: на  "ORDS_METADATA.ORDS_INTERNAL", line 779
ORA-06512: на  "ORDS_METADATA.ORDS", line 167
ORA-06512: на  line 3

Comment: are you using a Oracle in multitenant mode ??
Comment: No. I have Oraсle 19c, but I did not create a container base.
Comment: try the answer I post
Answer: The most probable cause is because the schema has been created as an Oracle Maintained user. An Oracle Maintained user cannot be enabled for ORDS based REST services.
In order to correct this problem, you must delete and recreate the target schema.
1.To drop the user:
alter session set "_ORACLE_SCRIPT"=true;

drop user DEVUSER;

alter session set "_ORACLE_SCRIPT"=false;

2.Recreate the user:
create user DEVUSER identified by <PASSWORD>;
grant create session to <SCHEMA>;

Perform any other grants needed for this user. If you have data to save, export it first ( using Datapump, for example ) and import it back again.
Comment: "Show con_name"  gives the following result: "CON_NAME Non Consolidated" and I have already recreated the user this way, but the error persists.
Comment: Run this `select oracle_maintained from dba_users where username = 'DEVUSER' ;` . If it is Y, then follow the steps of recreate the user
Comment: Roberto Hernandez,  thank you!! It worked when I followed all the steps again !!
Comment: can you accept the answer, please ? it is the best way to say thank you
Comment: @AndreyGorelov , you have an icon below the arrows up and down in your question to mark the answer as accepted. That way other people will know that the solution works.
Comment: I don't have 15 reputation to cast a vote. ((


how to delete one of the two duplicate records in db2 database

Question: I have a requirement where i have two records with same value except the PK. how can i delete one of them.I have plenty of such duplicate records.
Comment: Use a DELETE statement - if you need more, you need to explain your needs better.
Answer: For each unique row, find the smallest id, then delete all remaining rows.
delete
  from MyTable
  where rowId not in (
    select max or min(rowId)
      from MyTable
      group by column1, column2 /* these are the unique columns */
   )

once the data is cleaned, add a unique constraint/index to the unique columns to, as Tom H. suggested.
Answer: delete from thetable where pk_column_name=pk_value;

Answer: DELETE
     T1
FROM
     My_Table T1
INNER JOIN My_Table T2 ON
     T2.duplicate_column = T1.duplicate_column AND
     T2.pk_column > T1.pk_column  -- You could make this "<" if you wanted too

After that, you might want to consider looking at your database design since it seems like you have columns that are supposed to be unique but for which you don't have any unique constraint. Maybe that should be your PK or at the very least there should be a unique constraint on the column(s).
Since DB2 may not support the above, another option would be to use a subquery:
DELETE
FROM
     My_Table
WHERE
     pk_column IN
     (
          SELECT
               T1.pk_column
          FROM
               My_Table T1
          INNER JOIN My_Table T2 ON
               T2.duplicate_column = T1.duplicate_column AND
               T2.pk_column > T1.pk_column
     )

Comment: Have you tried this on DB2?  AFAIK, DB2 does not support multi-table DELETE syntax.  That's a non-standard extension to SQL, supported by e.g. MySQL.
Answer: One solution is to write a procedure that opens a cursor to a query ordered by the columns that define duplicates, and use DELETE ... WHERE CURRENT OF CURSOR when the row is a duplicate of the previous row.  Here's pseudocode for what I mean:
sql [ctx] C1 = { SELECT * FROM MyTable ORDER BY dup_column };

sql {  FETCH C1 INTO row  };
while ( !C1.endFetch() )  {
    if ( row.dup_column = prevrow.dup_column ) {
        sql [ctx] { DELETE FROM MyTable
                     WHERE CURRENT OF C1  };
    }

    prevrow.dup_column = row.dup_column;

    sql { FETCH C1 INTO ...     };
}
C1.close();

Answer: If PK is different (let's suppose the name is ID) then the following statement returns IDs for deletion
select b.ID as INCORRECT_ID
  from TABLE A
  join TABLE B on a.FIELD1 = b.FIELD1 and a.FIELD2 = b.FIELD2 (all fields but ID)
  where B.ID > A.ID

so, you can delete them by
delete from TABLE where ID in ( ...aforementioned statement... )

I am not sure what DB you use so some syntax tweaking might be needed.


Add branca.colormap.LinearColormap to an folium.FeatureGroup?

Question: I have 1 folium.Map with 4 featuregroups, each folium.Featuregroup has an folium.Choropleth.
So I want to have linear scale for each featuregroup using the bins list that I've created, which include the quantile result of the columns T*_depot_0, 2_depots, 3_depots or 4_depots in my dataset.
At the moment I am able to create an linear color scale using the branca package and add this to my map. But this results in showing ALL linear scales on the map.
What I am looking for is when I change from depot 1 to depot 2 using the layer control that the linear scale of depot 2 is shown, and scales of depots 1, 3, 4 are not shown.
I've tried adding the my color_map to the specific Featuregroup or Choropleth using add_to, add_child methods, but that didnt work.
So how do add (and show) an linear scale to an specific featuregroup?
My data (Geopandas dataframe):

My code:
def add_depot_markers_featuregroup(depot_amount, featuregroup):
    for i in range(len(depots_locations)):
        if i > depot_amount:
            break
        folium.Marker(
                [depots_locations[i].y, depots_locations[i].x],
                popup="Depot_{0}".format(i+1),
                icon=folium.Icon(color='cadetblue', icon='solid fa-bicycle', prefix='fa')).add_to(featuregroup)

result_map = folium.Map(location=lat_long_groningen, zoom_start=11, tiles=None)

layer_depot_1 = folium.FeatureGroup(name="1 depot", overlay=False).add_to(result_map)
layer_depot_2 = folium.FeatureGroup(name="2 depots", overlay=False).add_to(result_map)
layer_depot_3 = folium.FeatureGroup(name="3 depots", overlay=False).add_to(result_map)
layer_depot_4 = folium.FeatureGroup(name="4 depots", overlay=False).add_to(result_map)

fs=[layer_depot_1, layer_depot_2, layer_depot_3, layer_depot_4]
for i in range(len(fs)):
    add_depot_markers_featuregroup(i, fs[i])
    depot_column_name = ""
    if i == 0:
        depot_column_name = "T*_depot_{0}".format(i)
    else:
        depot_column_name = "{0}_depots".format(i+1)

    bins = list(results[depot_column_name].quantile([0, 0.25, 0.5, 0.75, 1]))

    choropleth = folium.Choropleth(
        results,
        data=results,
        key_on='feature.properties.Postcode',
        columns=["Postcode", depot_column_name],
        fill_color="YlOrRd",
        fill_opacity = 0.8,
        line_opacity = 0,
        line_weight=1,
        bins=bins,
        highlight=True,
        legend_name = "T* per postalcode area based on depot {0}".format(i+1),
        threshold_scale=bins,
        name="T* of {0} depot per Postalcode area".format(i+1)).geojson.add_to(fs[i])

    highlight_function = lambda x: {
        'fillColor': '#ffffff',
        'color':'#000000',
        'fillOpacity': 0.1,
        'weight': 0.1
    }

    color_map = branca.colormap.LinearColormap(
        colors=['#ffffd4', '#fed98e', '#fe9929', '#d95f0e', '#993404'],
        index=bins,
        vmin=bins[0],
        vmax=bins[-1],
        caption='Routelength per postcode area based on {0} depots'.format(i+1)
    ).add_to(result_map)

    folium.GeoJson(data=results,
        name="tooltip " + depot_column_name,
        tooltip=folium.GeoJsonTooltip(fields=['Postcode', "Deliveries", "Area (km2)", "Number of cyclists", "Beardwood approx", depot_column_name], labels=True, sticky=True),
        style_function=lambda feature: {
            "color": "black",
            "weight": 0.5,
        },
        highlight_function=highlight_function
    ).add_to(choropleth)

    # add legend: https://stackoverflow.com/questions/52911688/python-folium-choropleth-map-colors-incorrect/52981115#52981115
# min_values = results[["T*_depot_0", "2_depots", "3_depots", "4_depots"]].min()
# max_values = results[["T*_depot_0", "2_depots", "3_depots", "4_depots"]].max()
# color_index = range(round(min_values.min()), round(max_values.max()), 5)
# color_map = branca.colormap.LinearColormap(
#         colors=['#ffffd4', '#fed98e', '#fe9929', '#d95f0e', '#993404'],
#         index=color_index,
#         vmin=min_values.min(),
#         vmax=max_values.max(),
#         caption='Routelength per postcode area'
# ).add_to(result_map)

folium.TileLayer(overlay=True, show=True, control=False, name="T* openstreet").add_to(result_map)
folium.TileLayer('cartodbdark_matter',overlay=True, show=False, name="T* dark mode").add_to(result_map)
folium.TileLayer('cartodbpositron',overlay=True, show=False, name="T* light mode").add_to(result_map)
folium.LayerControl(collapsed=False).add_to(result_map)
result_map.save("lastmilegroningen.html")
result_map

Current result
Answer: I think you need something like this.
Here the basic idea is to bind each colormap to your FeatureGroup.
That means you need this part of the linked post:
from branca.element import MacroElement

from jinja2 import Template

class BindColormap(MacroElement):
    """Binds a colormap to a given layer.

    Parameters
    ----------
    colormap : branca.colormap.ColorMap
        The colormap to bind.
    """
    def __init__(self, layer, colormap):
        super(BindColormap, self).__init__()
        self.layer = layer
        self.colormap = colormap
        self._template = Template(u"""
        {% macro script(this, kwargs) %}
            {{this.colormap.get_name()}}.svg[0][0].style.display = 'block';
            {{this._parent.get_name()}}.on('overlayadd', function (eventLayer) {
                if (eventLayer.layer == {{this.layer.get_name()}}) {
                    {{this.colormap.get_name()}}.svg[0][0].style.display = 'block';
                }});
            {{this._parent.get_name()}}.on('overlayremove', function (eventLayer) {
                if (eventLayer.layer == {{this.layer.get_name()}}) {
                    {{this.colormap.get_name()}}.svg[0][0].style.display = 'none';
                }});
        {% endmacro %}
        """)  # noqa

and at the end you do not add your colormap and FeatureGroup to the map but instead bind them then add them to the map like this:
m.add_child(BindColormap(color_map, i)

Answer: Managed to find a work around. For some reason Choroplet object desn´t have this kind of issue where you cant really use it in a for loop. The underlying GeoJson and StepColormap objects are reachable choropleth.geojson and choropleth.color_scale


SQL Server 2014 standard edition slows the machine when Database size grows

Question: I have a scenario where an application server saves 15k rows per second in SQL Server database. At first initial hours machine is still usable but whenever the database size increases ~20gig, it seems that machine is becoming unusable.
I saw some topics/forums/answers/blogs suggesting to limit the max memory usage of SQL Server. Any thoughts on this?
Btw, using SQL Bulkcopy to insert rows in the database.
Comment: Consider taking this to the right place (not a programming question) and providing some more information. I can only assume your "database server" is totally unsuitable to work with larger databases. But you seem to think we can magically solve this without having any background information.
Comment: Even if this was on-topic for SO, we have nowhere near enough information to help with this. There are many reasons why a database may slow down, memory, disk, cache etc.
Comment: sorry about that @TomTom , just got really confused on what is happening.
Answer: I have two suggestions for you:
1 - Database settings:
When you create the database, try to use a large initial size, and consider to have a bigger autogrowth percentage/size.
You will want to minimize the times your filegroups need to grow.
2 - Server settings:
In your SQL Server settings I would recommend that you remove one logical processor from the SQL Server. The OS will use this processor when the SQL Server is busy with heavy loads on the other processors. In my experience, this usually gives a nice boost to the OS .


No Saxophone part in band sheet music

Question: I am attempting to have my band/orchestra students learn a song for our holiday concert, but the song doesn't have a saxophone part. Which other instrument part could I have my saxophone players join in on that doesn't require a lot of transposing. I am a violinist so this is very new for me.
Comment: Can you give us a list of the instruments featured in your Arrangement (and maybe also one of the instruments your studends have available)? Alto/Baritone-Saxophone can do any sort of Eb-Instrument without transposing, soprano/tenor can take the part of Bb-Instruments (of which there are more options).
Comment: One shortcut is to have them read any bass clef part as if it was treble clef and add three sharps.  If there aren't many accidentals it's a good trick to know.  Example: cello part in key of D has A on the top line.  Saxophone players can pretend it's in treble clef, key of B, and play F# on the top line.
Comment: @nuggethead That only works for E-flat saxophones, and only baritones sax ends up in the right octave (bass parts played on an alto would probably sound very odd)..
Comment: Yes @PiedPiper you are correct.
Comment: @nuggethead: I just commented that on an answer and then realized it was here already, and also PiedPiper's observation about orchestration.  Late to the party! Lindsey: you might also take the opportunity to introduce the concept of movable clefs.  I've always found that the easiest way to approach transposition - I imagine a movable clef that points at whatever line or space I need to be C (or G).
Answer: For starters, there are two 'keys' that saxes play in. I say 'keys' as they are transposing instruments, and, yes, of course, they play in every conceivable key, but their dots need to reflect the fact that they are transposing instruments.
This means they don't read concert pitch, but compensated parts. Mostly you'll have alto saxes, transposing from E♭. and tenors, which transpose from B♭.
Consequentially, some of the parts you already have in your orchs are readily available! Those specifically being trumpet and clarinet sections, which will be written transposed for B♭ instruments. Making it easy for the tenors to play the trumpet/clarinet parts. Albeit an octave lower.
E♭? Bit more difficult. I think you're going to have to transcribe some other parts. There may be other horn parts they could play, but I think that's going to be a far cry.
Comment: Unless the absence of saxophone parts is related to the age of the arrangement, in which case there may be E-flat clarinet or cornet parts.
Comment: There is sometimes an E♭ horn part, but in my experience it is oompah accompaniment, very boring for saxes, who are used to playing an actual melody.
Answer: Alto or Tenor saxophone?  You can give a B♭ Tenor sax a Trumpet or Clarinet part, though it might be more musically useful doubling Trombone, which will require transposing and maybe some adjustment of the lowest notes  (but hey! no pain no gain...)
E♭ Alto sax could also take the Trumpet part, but will certainly need transposing.
I'm afraid running a band often means YOU putting in just as much work as the students. :-)
Comment: Given how much the typical band-student works, it would be a dream job if the director only had to work that much! :-)

No Saxophone part in band sheet music


Error in request with the auth module - Kohana

Question: I want to add the auth module in my application but when he's trying to access to the database, he doesn't use the right fields. This is the error page that I get with the request :

Database_Exception [ 1054 ]: Unknown column 'username' in 'where
  clause' [ SELECT user.id AS id, user.mail AS mail,
  user.login AS login, user.password AS password,
  user.nom AS nom, user.prenom AS prenom, user.telephone
  AS telephone, user.inscription AS inscription, user.active
  AS active, user.admin AS admin, user.rattachement AS
  rattachement, user.organisme AS organisme FROM utilisateur
  AS user WHERE username = 'l.rousseaux' LIMIT 1 ]

So in the where clause, he uses username and in my database, I use login. So my question is, where can I change this parameter for him to check the right field ?
Thanks in advance !
Comment: In Your ORM module Auth ORM has unique_key field for that.
Comment: you can find it OEM-> Model -> User line 129
Comment: did you managed to find solution?
Answer: You can update the unique value field in Modules -> ORM -> Model -> user line 129
/**
* Allows a model use both email and username as unique identifiers for  login
*
* @param   string  unique value
* @return  string  field name
*/
public function unique_key($value)
{
   return Valid::email($value) ? 'email' : 'username';
}


Almost identical map

Question: Let $f: \mathbb{R}^2 \rightarrow \mathbb{R}^2$ be bijective map with following properties:
1) $f|_{\mathbb{Q}^2}=id$;
2) Image of any line under map $f$ is again a line.
Is it right that $f=id$?
Comment: Alex: maybe you should ask over on MathOverflow (or, if you want, I can ask for you). The solution to me is not obvious, and if a counterexample were to be found, it is possible that it won't be constructive. Very interesting question, this is.
Comment: My conjecture is that (2) implies that $f$ is continuous, and that would imply that $f=id$. I think I'll ask about this more general conjecture on MO.
Comment: My question is equivalent to following one. Let $f: \mathbb{R}^2 \rightarrow \mathbb{R}^2$ be bijective map such that image of any line under map $f$ is again a line. Is it right that $f$ is affine transformation of $\mathbb{R}^2$?

Yes, if you will ask my question on MathOverflow I will be grateful.
Comment: Looks like the answer to my question answers yours: http://mathoverflow.net/questions/46854/continuity-in-terms-of-lines/46860#46860
Answer: (Posting this as CW so Alex can accept the answer.)
Trutheality re-asked the question on MathOverflow, and it turns out the answer is given by what is known as the "Fundamental Theorem of Affine Geometry". See https://mathoverflow.net/questions/46854/continuity-in-terms-of-lines
Comment: To minimise clickthrough: the answer turns out to be "Yes! (2) implies continuity, which together with (1) implies $f = \mathit{id}$.  Getting continuity from (2) is quite non-trivial; the Fund. Thm. of Aff. Geom. says that the only possible obstruction to continuity is an automorphism of the ambient field, but in fact $\mathbb{R}$ has no field automorphisms so for $\mathbb{R}$ (2) implies continuity."  (I would edit this in but I don't have enough rep.)
Comment: @Peter: you were just 1 rep short! I think now you can. (I don't know the proof of the Fund. Thm myself, so I didn't feel comfortable elaborating). Cheers

Almost identical map


Prediction of a MA(1) process

Question:
I was reading the book of Hamilton, time series analysis. I don't understand why in passage $4.2.3$ he expands the geometric serie with alternate signs. Shouldn't the expansion be done only with positive signs?
Answer: Please take into account that the series development in which all signs of the expansion are positive corresponds to $\frac{1}{(1-\theta)}$, so in this case the expansion is on $\frac{1}{(1-(-\theta))}$ and thus the alternate signs corresponding to $(-\theta)^i$

Prediction of a MA(1) process


Copy all "web.config" files using robocopy

Question: I need to write a robocopy command so that I can take the code (directory structure included) and copy it to another location. However, I don't need all the code. only the web.config files. I have the basic line, I'm simply unsure of what to add on the end so that it's only the specific files.
Guessing it's here but I can't decipher it.
Comment: post your actual command line
Answer: To only get web.config files, use
ROBOCOPY <your parameters> web.config

That 'web.config' is your file mask. Often, it will be something like '*.txt', but yours is so specific you won't need any wildcards.
Comment: When you post your command line, I'll amend my answer. Also, is this over a network? If so, use the /Z parameter to enable Restartable Mode.
Comment: Also, run it with /L first, to check what the output would be: it will just List the results.


use multiple ip addresses to tcp check remote server's port

Question: Im trying to tcp connect yahoo's mail server on port 25 . I have 3 public ip addresses lets say:-
(all are allowed in SPF records)
184.108.40.206
22.214.171.124
18.104.22.168

How to telnet(or other checks) using particular ip addresses to yahoos mta
(check if all three of my ip addresses are allowed to send email to yahoo)
Answer: According to the man page: -s sets the source IP address.
So you can do:
telnet -s 126.96.36.199 yahoo_mail_server 25

Comment: for centos 6.7 with telnet-0.17-48.el6.x86_64.  it has "-b"  switch instead of "-s"
Answer: nc -s 126.96.36.199 -vz mta5.am0.yahoodns.net 25

OR
telnet -b 22.214.171.124 mta5.am0.yahoodns.net 25


MC Sampling from a Posterior Distribution

Question: Bayes rule is:
$p(x|D)\propto p(D|x)p(x)$
Imagine $p(x)$ and $p(D|x)$ are both Gaussian distributed. I understand in this case that I can obtain the posterior analytically (conjugate priors). But I'm a bit confused on how to sample from the posterior distribution via an MC (Monte Carlo) method.
If $p(x)$ is Gaussian, I can easily pull a sample from there, but then do I put this sample into the likelihood function? If that's the case I'm evaluating a probability value at a particular point, and not actually "taking a sample". I'm a little confused on this front. Basically once I take a sample from $p(x)$ what is the procedure I need to do with that sample (i.e. where / how do I pass it on).
I would just like to see a histogram of this posterior distribution.
Comment: To the best of my knowledge, you can either choose a proposal distribution and do Metropolis-Hastings or sample from the prior and follow the method of the approximate Bayesian computation(ABC). But if there is only one parameter that needs to be sample, why not just use rejection sampling or importance sampling method?
Comment: Rejection sampling sounds like a good approach. However I was thinking of hopefully a way in which things work more like a graphical model. So for example if we have $p(x|a)p(a|b)p(b|c)p(c)$ can we sample from the $p(c)$ prior and then pass that through all the other probability measurements sequentially and obtain one final posterior sample? Rejection sampling would allow for sampling, but I feel there should be some way to do it in this graphical model method. :/
Comment: Actually I completely missed on that approximate Bayesian computation (ABC) method you mentioned. That sounds like what I may be looking for? In your experience will this allow for sampling in the way I described in my previous comment?
Comment: It seems like there are more than one parameter. Then you should think of MCMC algorithms like Gibbs samplers or Metropolis-Hastings updates.
Comment: actually, if you have a lot of parameters, as is the case with graphical models, you're subject to the curse of dimensionality. So you wouldn't want to do ABC in such cases.
Comment: Those are good suggestions, but going back to the $p(x|a)p(a|b)p(b|c)p(c)$ example, I'm not necessarily looking for the most efficient method, just one done "my way" to help understand a concept. So I was just wondering if it is possible to sequentially sample down this graph c -> b -> a -> x, where I first sample from $p(c)$, then $p(b|c)$, then $p(a|b)$ etc. like a chain. What confuses me is that in the simple case of $p(D|x)p(x)$, where $D$ is data so we know $D$, if sample from the prior $p(x)$ then we know some sample $x$, then $p(D|x)$ just becomes a likelihood evaluation != sampling.
Comment: So in my case if we want a "chain-like" sampling, and we have sampled from $p(x)$, and we know are data $D$, what do we then do next? That's where I'm lost, so I'm not exactly looking for the name of a general method for sampling, but I'm asking how to do my specific case of sampling even if it is inefficient / or if it's easily possible.
Comment: ah hah. My choice then would be ABC sampling. So here you should pick a sample from the prior $p\left(x\right)$. And then you plug that into the likelihood $p\left(D|x\right)$ and generate a sample of the same size as the observed data. Next you should compare the sufficient statistics of the random sample you generated and the observed data. If the sufficient statistic of the random sample is too different from the original data's, you discard the sampled point of the prior along with the random sample. You should refer to papers though for a more thorough explanantion.
Comment: You could do the same for the multiple-parameter model. Sample from $p(c)$. Plug it into $p(b|c)$ and sample from it. Again plug it into $p(a|b)$ and sample. Plug it into $p(x|a)$. There you are with your likelihood ready to be sampled from! Generate a random sample of the same size as your data and compare its sufficient statistic to the one from the original data. This is the basic concept of ABC.
Answer: You worte

If $p(X)$ is Gaussian, I can easily pull a sample from there, but then do I
  put this sample into the likelihood function? If that's the case I'm
  evaluating a probability value at a particular point, and not actually
  "taking a sample

I think you misunderstand the concept of conditional probability, when we sample from the prior and plug the sampled value into the likelihood , we do not evaluate a probability value at a particular point we just get a conditional distribution given the sampled value from the prior. Suppose that the target distribution is the joint probability distribution of
two variables, a discrete variable $\delta \in \{1,2,3\}$ and a continuous variable $\theta \in \mathbb{R}$ then the target density  will be defined as :
01-The discrete part of this density is :
$$ \{Pr(\delta =1), Pr(\delta = 2), Pr( \delta= 3)\} = (.45, .10, .45)$$
02- The continuous part of this density is
$$P(\theta|\delta) = dnorm(\theta,\mu_{\delta},\sigma_{\delta })$$,
where $(\mu_1,\mu_2,\mu_3) = (−3, 0, 3)$ and $(\sigma^2_1,\sigma^2_2,\sigma^2_3) = (1/3, 1/3, 1/3) $.
This is a mixture of three normal densities and a plot of the exact marginal density of ,$p(\theta) =\sum p(\theta|\delta)p(\delta)$ will be like that

that can  be done using the following code in R :`
mu<-c(-3,0,3)
s2<-c(.33,.33,.33)
w<-c(.45,.1,.45)

ths<-seq(-5,5,length=100)
plot(ths, w[1]*dnorm(ths,mu[1],sqrt(s2[1])) +
       w[2]*dnorm(ths,mu[2],sqrt(s2[2])) +
       w[3]*dnorm(ths,mu[3],sqrt(s2[3])) ,type="l" )

Now it is very easy to obtain independent Monte Carlo samples from the joint
distribution of $(\delta,\theta)$ First, a value of $\delta$ is sampled from its marginal distribution, then the value is plugged into $p(\theta|\delta)$ from which a value of $\theta$ is sampled (Note the sampled pair $(\delta,\theta)$ represents a sample from the joint distribution $p(\delta,\theta)=p(\delta)p(\theta|\delta)$) then the empirical distribution of the $\theta$ samples  provides an approximation to the marginal distribution $p(\theta) =\sum p(\theta|\delta)p(\delta)$ . Now a histogram of 1,000 Monte Carlo -values generated in this way or in other words the empirical distribution of the Monte Carlo samples looks like $p(\theta)$.

set.seed(1)
S<-2000
d<-sample(1:3,S, prob=w,replace=TRUE)
th<-rnorm(S,mu[d],sqrt(s2[d]))
THD.MC<-cbind(th,d)

ths<-seq(-6,6,length=1000)
plot(ths, w[1]*dnorm(ths,mu[1],sqrt(s2[1])) +
       w[2]*dnorm(ths,mu[2],sqrt(s2[2])) +
       w[3]*dnorm(ths,mu[3],sqrt(s2[3])) ,type="l" , xlab=expression(theta),ylab=
       expression( paste( italic("p("),theta,")",sep="") ),lwd=2 ,ylim=c(0,.40))
hist(THD.MC[,1],add=TRUE,prob=TRUE,nclass=20,col="gray")
lines( ths, w[1]*dnorm(ths,mu[1],sqrt(s2[1])) +
         w[2]*dnorm(ths,mu[2],sqrt(s2[2])) +
         w[3]*dnorm(ths,mu[3],sqrt(s2[3])),lwd=2 )

For more details see A First Course in Bayesian Statistical Methods the book provides also a very good comparison between MC and MCMC Chapter 6 section "Introduction to MCMC diagnostics ".
`
Comment: That is a very good way to look at it! The joint between a discrete and a continuous variable. I'm not sure how this is frequentist though, it seems very Bayesian (prior is $p(\delta)$, likelihood is $p(\theta|\delta)$)?
Comment: @pche8701 see edit
Answer: Note that you have a sample, i.e. the data, and you want to find the credibility of an unknown parameter, below I explain a special kind of MC nemely MCMC, markov Chain Monte Carlo.
Maybe it's good to make the notation a bit more explicit, and for simplicity take the one-dimensional case (this is only for simplicity, it also works in the multi-dimensional case).  You say that your likelihood is Gaussian just as well as your prior.  If we take the one-dimensional case then our goal it to estimate one parameter, e.g. the unkown mean $\mu$.
The posterior is then $P(\mu|_D) \propto P(D|_\mu) p(\mu)$
Now in MCMC (Monte Carlo Markov Chain), you start from an initial value $\mu=x_1$ and make a proposal move $x_2$, in order to decide whether the proposal will be accepted, you should evaluate the posterior at $x_1$ and at $x_2$.
So you have to compute $ P(D|_\mu=x_1) p(\mu=x_1)$ (and the same for $x_2$). The prior is known (you have chosen it yourself), so you can evaluate it at $x_1$.
The likelihood $P(D|_\mu=x_1)$ at $x_1$ is also knwown; you know it is gaussian and (in the one dimensional case) only the mean is unknown but you say that you want to evaluate it at $\mu=x_1$ so you have the mean and you can compute the value for $P(D|_\mu=x_1)$ (the data $D$ is also known of course).  Similar for $X_2$. So it is the 'Gaussian formula'' where you plug in $\mu=x_1$ and $X=D$ ($\sigma$ is known because we assumed the one dimensional case for simplicity, so only one parameter, $\mu$ is unknown, but you evaluate at $\mu=x_1$, so that's solved).
So we can compute (up to a constant) $\pi_1=P(\mu=x_1|_D)$ and $\pi_2=P(\mu=x_2|_D)$.
Remember that $x_2$ was only a proposal move.  This proposal is accepted if $\pi_2$ > $\pi_1$ , if $\pi_2 \le \pi_1$ then the move is accepted with a probablity $\frac{\pi_2}{\pi_1}$ (P.S. a symmetric transition kernel is assumed).
If the move is accepted then move to $x_2$ else stay at $x_1$ and next generate the next proposal, ...
This algorithm is constructed such that the so-called ''balance equations'' are fulfilled, and that is suffcient for the chain to converge to the posterior ''in the end''.

Summary: if you can't sample from the posterior directly, then construct a markov chain that has the posterior as limiting distribution and use this Markov chain to ' walk to' that limiting distribution. The algorithm supra defines such a markov chain using a special case of the Metropolis-Hastings procedure.

[[Note, if your data is a sample with multiple elements, then you take a product of likelihoods, assuming independence). ]]
Answer: I agree with Der Fluß's answer and just want to add some comments.
I think the key point here is:
In order to get samples from p(D|x)p(x), you cannot sample from p(x) and hope p(D|x) magically make the samples look like sampled from p(D|x)p(x). You have to directly sample from p(D|x)p(x).


Can I generate cucumber html report without command line(node cucumber-html-report.js) in cypress?

Question: Can I generate cucumber html report without command line in cypress. Instead executing in terminals
Answer: In package json file inside script add this below code
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test:open": "cypress open",
"eject": "react-scripts eject",
"start-server": "nodemon server.js",
"clean:reports": "if exist cypress\cucumber-json rmdir /S/Q cypress\cucumber-json",
"pretest": "npm run clean:reports",
"scripts": "npx cypress-tags run --env "TAGS=@SmokeTest" --headed --browser chrome",
"posttest": "node cucumber-html-report.js",
"test": "npm run scripts || npm run posttest",
},
Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).


Drupal incorrectly reporting that permissions need to be set on settings.php

Question: I've updated a site to v8.5.3.  Checking the status report I have various messages.  One says:

Not protected
Protection disabled

The file sites/default/settings.php is not protected from modifications and
poses a security risk. You must change the file's permissions to be non-
writable.
The file sites/default/settings.local.php is not protected from
modifications and poses a security risk. You must change the file's
permissions to be non-writable.

I've checked these files and they are set to 444, there are no write permissions set.  Drupal seems to be reporting this incorrectly.
Is there anything else I need to do or am I missing anything?
Answer: They keyline here is Protection disabled.
Which means you have to check your settings.php or setting.local.php for
$settings['skip_permissions_hardening'] = TRUE;

which must be
$settings['skip_permissions_hardening'] = FALSE;

instead.
If it's not there already, add it.
Flush cache, done.
Comment: @user1532669 See also https://www.drupal.org/node/244924 for the definitive reference on file permissions and ownership.
Comment: Setting skip_permissions_hardening removes the warning, but that's not very intuitive at all. Why would you want to skip the check for permissions hardening? Don't you want Drupal to always tell you if those files don't have the correct permission at all times?
Comment: @Randell – It removes the warning because the permissions now get hardened. You want that to be skipped during development because you may need to edit these files more often.


Why would you allow a static field exist twice?

Question: Here we go with my question:
I have an interface with a static variable nr
public interface TestInterface {

    public static int nr = 1;

}

And a class which implements that interface and has it's own static variable nr too.
public class TestClass implements TestInterface {

    public static int nr = 2;

}

And I can actually do this without an error!
public static void main(String args[]) {

        TestClass test = new TestClass();

        System.out.println(TestClass.nr);

    }`

Question: Why would this be allowed?
As far as I understand static fields should be universal through a class instances but what about the superclass - subclass relation?
Comment: Why wouldn't it be allowed?
Comment: `superclass - subclass relation` This relationship doesn't exist here, it's just a class implementing an interface.
Comment: Because this is confusing from a "revisiting this code" point of view. By not being possible imposes better practices.
Comment: The Interface variable should be spelled in all upper case by convention, because it's a constant.
Answer: It's explicitly allowed by the language.

If the class declares a field with a certain name,
  then the declaration of that field is said to hide
  any and all accessible declarations of fields with
  the same name in superclasses, and
  superinterfaces of the class.

http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.3
Answer: In your code, both of the static fields are actually defined/meant for separate types i.e., one for TestInterface interface type and other for TestClass class type.
One point you need to understand is that, when it comes to static, there is no overriding, so they will be treated as separate fields.
Comment: @LewBloch What I mean by inheritance is that we can't override, corrected to make it more clear
Comment: It is incorrect that static fields are not inherited. The JLS mandates, `"A class inherits from its direct superclass and direct superinterfaces all the non-private fields of the superclass and superinterfaces that are both accessible to code in the class and not hidden by a declaration in the class."` Static fields are shown in that section's examples.
Answer: In superclass - subclass relation the super class's static variables is shadowed by sub class's static variables if they have same name. Because the static variables aren't polymorphic.
Comment: Hidden, not shadowed.


C++ - Gettings size from vector in FOR loop

Question: I have a loop that asks for user input, and adds it too a vector, then when if they type "EXIT" it will stop and display the list. What I am trying to do now is determine the number of elements with size()
This is what I have:
#include <iostream>
#include <string>
#include <unistd.h>
#include <iterator>
#include <vector>
using namespace std;

int main()
{
    write(1,"\E[H\E[2J",7);
    vector<string> list;
    cout << "Enter UIDs: \n\n";
    for(string uid ; cin >> uid && uid != "EXIT"; list.push_back(uid))
        cout << " \n";
    copy(list.begin(), list.end(), ostream_iterator<string>(cout, "\n\n"));
    cout << "Vector size: " << uid.size() << endl;
    return 0;
}

When attempting to compile that I get the error:
g++ sof.cpp -o sof

sof.cpp: In function 'int main()':
  sof.cpp:16:32: error: name lookup of 'uid' changed for ISO 'for' scoping
  sof.cpp:13:16: error:   cannot use obsolete binding at 'uid' because it has a destructor
Comment: `uid` doesn't exist on line 16; it's only within the scope of the `for` loop.  (HINT: you don't have any braces around your loop stuff).
Comment: I have edited to format your code apropriatley.  This should highlight the point made by @OliCharlesworth that you are missing braces for the body of the for loop.
Comment: @JonTaylor Not really, the code needs no braces. The error is the `uid.size()` call, which should be `list.size()`.
Comment: @OliCharlesworth actually, there's no need for braces here.
Comment: @juanchopanza yeah I realised once I looked at the code again, but the format still helps.
Comment: Your code will break as soon as you decide you need to `#include ` for something.
Answer: You're querying uid.size() instead of list.size()


Page not found error when using plus"+" sign in the url alias

Question: I am trying to create a new simple node with url alias as test+node. when i save the node the page is not showing the node, the url changes as
http://server/packets/test%2Bnode
but it only shows the following error
Page not found
The requested page "/packets/test%2Bnode" could not be found.

Can anyone help me to fix this issue out...
Comment: I had the same issue but the "+" signs were on old URLs that I can't change. We have, on our current platform, old URLs that are going to be decommitioned when we change for Drupal, but I want the SE to be able to find the new links. By changing the "+" for " " in the source old links worked as expected. Thank's for the question!
Answer: Drupal url do not accept the + sign, so it will convert the url into "space" so that only i t return page not found value.
Please remove the + sign from url.
Comment: the url changes as `http://server/packets/test%2Bnode` and its not a pblm. I need the created node to be shown. But its showing as `Page not found The requested page "/packets/test%2Bnode" could not be found.`
Comment: but the drupal read your url like http://server/packets/test node
Comment: when u change the seperator  as '+' in the settings the url will be shown as u said. without changing it will look like `http://server/packets/test%2Bnode`.
Comment: Its the url was encoded using urlencode() method, but the drupal again decode the url with urldecode(). it agian read your existing url with + sign
Answer: RFC 2396 defines how URI works. URL is just a special case of URI, so all rules apply. See section 2.2:

2.2. Reserved Characters
Many URI include components consisting of or delimited by, certain
     special characters.  These characters are called "reserved", since
     their usage within the URI component is limited to their reserved
     purpose.  If the data for a URI component would conflict with the
     reserved purpose, then the conflicting data must be escaped before
     forming the URI.
 reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                "$" | ","

The "reserved" syntax class above refers to those characters that are
     allowed within a URI, but which may not be allowed within a
     particular component of the generic URI syntax; they are used as
     delimiters of the components described in Section 3.

On the other hand, as you can read here:

RFC 1738 (as modified by 2396 and 3986) defines the scheme (http:), authority (//server.example.com), and path (/myfile/mypage.htm) component, and does not define any special meaning for the + character.  The HTML spec defines the query component to be mime type application/x-www-form-urlencoded which is defined as "replace spaces with + and other special characters as in RFC1738".

This means that when you use +, Drupal tries to prevent it from being interpreted as space, so it encodes it. And then it fails to recognize your alias properly.
Probably you should file a bugreport. Given that Drupal 8 is almost out of beta, I highly doubt it will be fixed, though. So consider simply avoiding special characters in your aliases.
Answer: Special characters and few other characters are not accepted by the url.
So it encode these characters to a plane string by replacing space and + (and special characters) by other characters.
So better to enter alias that will remain simple or let drupal generate alias itself first and then edit it later nearly similar to your format.


How to secure a a Linux user account so only SSH tunneling is possible?

Question:
Possible Duplicate:
ssh tunneling only access

I'm thinking about using TightVNC's java client to allow customers to access a virtual server. TightVNC supports tunneling the connection using SSH.
To make things more secure, I'd like to have the account used for this to only allow tunneling, but nothing else (ie. no shell). What is required to have tunneling work, but blocking everything else?
Comment: Duplicate: http://serverfault.com/questions/56566/ssh-tunneling-only-access
Comment: Indeed, Gilles, you're right. Is there a way to mark it as a duplicate, or should I just delete the question?
Answer: Set account shell to <code>/usr/sbin/nologin</code>


Problem with enumerating formulas

Question: Let $P_0, P_1, P_2, ...$ be an enumeration of all logical formulas with one free variable $n$ (countable since they're finite strings of a countable alphabet). Let $Q(n) \iff \lnot P_n(n)$. For any $n$, $Q$ is not $P_n$ because they don't agree on $n$. But $Q$ is a logical formula so it should be in the enumeration...
What's going on?
Comment: How are you going to write $Q(n)$ as a single logical formula when it has to refer to infinitely many formulas $P_n$?
Comment: $P_n$ is a function which enumerates all strings that are valid logical formulas with one free variable $n$.
Comment: Just found a question asking the same thing: https://math.stackexchange.com/questions/2976937/where-is-the-mistake-in-this-proof-of-the-inconsistency-of-zfc
Comment: And the answers there point out the same problem that I did, but in much more detail.
Answer: This will come down to the following: what is the precise definition of "logical formula?" The point is that although the $Q$ you've described is definitely "meaningful," it is of greater complexity in a sense than any of the $P_i$s. When we pin down a precise notion of "logical formula" and an enumeration of such, e.g.  "first-order formula in the language of arithmetic" ordered lexicographically via some reasonable ordering on the symbols involved, the corresponding $Q$ will turn out to not be expressible by a formula in that particular sense.
For a concrete example of how this plays out, see e.g. Tarski's undefinability theorem. And compare this to similar "paradoxes of expression:" Berry's paradox, Richard's paradox, and Grelling's paradox.
Answer: It's important to distinguish between strings representing valid formulas and the formulas themselves.
See the following:

Richard's paradox (the paradox and an explanation)
Tarski's undefinability theorem (there's no way to encode truth of a formula-string in a consistent logical system)
Godel's incompleteness theorem (provability can be encoded, but that's different from truth)

Problem with enumerating formulas


Worklight app: huge amount of requests to server after authentication

Question: I'm using Worklight Adapter based authentication for m y app. After success response from server about the good passing the authentication test, the application starts to send the request to server over and over.
Logs from server says, that user is login and logout in the loop.
<code>{
    "message": "invoke logout request [project ProjectName]",
    "sourceClass": "com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation",
    "sourceMethodName": "info",
    "level": "INFO",
    "source": "server",
    "threadId": 19,
    "loggerName": "com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation",
    "server": {
      "ip": "--"
    },
    "timestamp": "---"
  }
  {
    "message": "Setting active user [project ProjectName]",
    "sourceClass": "com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation",
    "sourceMethodName": "info",
    "level": "INFO",
    "source": "server",
    "threadId": 19,
    "loggerName": "com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation",
    "server": {
      "ip": "--"
    },
    "timestamp": "---"
  }
  {
    "message": "invoke logout request [project ProjectName]",
    "sourceClass": "com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation",
    "sourceMethodName": "info",
    "level": "INFO",
    "source": "server",
    "threadId": 21,
    "loggerName": "com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation",
    "server": {
      "ip": "--"
    },
    "timestamp": "---"
  }
  {
    "message": "Setting active user [project ProjectName]",
    "sourceClass": "com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation",
    "sourceMethodName": "info",
    "level": "INFO",
    "source": "server",
    "threadId": 21,
    "loggerName": "com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation",
    "server": {
      "ip": "--"
    },
    "timestamp": "---"
  }
</code>
This change of the source code helps to avoid this activity. (Deleting the challengeHandler.submitSuccess() calling)

But in this way, callback function from challendeHandler.submitAdapterAuthentication and WL.Client.logout are not called.

All activities are showed in the logs package.

Please help me to release this problem.
Comment: We need more code form your application to see where it happens.
Comment: Have you taken a look at any of the existing authentication samples and compared it with yours?
Answer: Invoking Wl.Client.login("realmname") before submit user credentials helped me.


Solve the follwing system of equations for $x, y$ and $z$

Question: $$\frac{y+z}{5}=\frac{z+x}{8}=\frac{x+y}{9}$$ and $$6(x+y+z)=11$$
My teacher told me that I would have to get $3$ different equations to get $x, y$ and $z$. I've tried many methods and I'm confused as to how to do this problem.
Comment: The first line is two equations.
Answer: assume that
$$\frac{y+z}{5} = \frac{z+x}{8} = \frac{x+y}{9} = k$$
    where k is a real number
now you can write three equations by cross-multiplying each denominator by k, that yields.
(1) y + z = 5k
(2) z + x = 8k
(3) x + y = 9k
when you add all of these three equations you will get
2(x + y + z) = 22k
i.e. (a) x + y + z = 11k
but you already have an equation that says
 6(x + y + z) = 11
i.e. (b) x + y + z = 11/6
there fore by considering (a) and (b) you can say that k = 1/6
now we have to find the values of x, y and z.
(1) - (2) implies
 (4) y - x = -3k
(4) + (3) implies
2y = 6k
i.e y = 3k = 3 x 1/6 = 1/2
there fore y = 1/2
(3) implies
x + y = 9k = 9 x 1/6 = 3/2
but y = 1/2
so x = 1
(2) implies
x + z = 8k = 8 x 1/6 = 4/3
but x = 1
so z = 1/3
Answer: Hint
$$\frac{y+z}{5} =\frac{z+x}{8} =  \frac{x+y}{9}$$ is the same as
$\color{red}{\large{\frac{y+z}{5} =\frac{z+x}{8}}}$ and $\color{red}{\large{\frac{z+x}{8} =  \frac{x+y}{9}}}$
Which is also the same as $\color{blue}{\large{\frac{y+z}{5} = \frac{x+y}{9}}}$ and $\color{blue}{\large{\frac{z+x}{8} = \frac{y+z}{5}}}$
And so you can break it into two equations.
$\color{blue}{\large{\frac{z+x}{8} = \frac{y+z}{5}} \implies 5(z+x)=8(y+z)} \implies 5z + 5x =8y + 8z \implies 5x -8y -3z = 0$
and $\color{blue}{\large{\frac{y+z}{5} = \frac{x+y}{9}}} \implies 9(y+z) = 5(x+y) \implies 9y  + 9z = 5x + 5y \implies 5x + 9z + 4y = 0$
and you have the 3rd equation which is $6(x+y+z) = 11 \implies x + y + z = \frac{11}{6}$.
Now can you solve this system of equations
$$5x -8y -3z = 0, 5x  + 9z + 4y= 0,  x + y + z = \frac{11}{6}$$
Now you can use this link here linear algebra tool kit to check your work
Comment: after I break it into two equations then what do I do?


LSTM and Time series: My statements are corrects about those concepts?

Question: I'm having some problems to understand LSTM theory and how exactly works a time series data in a Deep learning. To see if my thoughts are correct, I will make some statements (explanation) about how I think it's works and if I'm made mistakes, please corrects me! After that I will make some questions:
Let's say that I want to create a time series regression based on this data:

To evaluate my model, after the yellow line will be my validation set, which means that my training set will be the sequence before that line. To train my model, I will follow the same steps as in DNN (Dense Neural Network) model:
Feed the data in B batchs >> Evaluate the loss >> apply Backpropagation
But, to do this in a sequential data I need to create my samples, following the image bellow:

Where X is in red and Y is in green. Basically I will feed [X1, X2, X3] and evaluate my loss in Y. Considering a time step equals to one, my training set will become something like this:
(([X1, X2, X3], Y)
 ([X2, X3, X4], Y)
 ...
)

Where X4 in the first row was Y, X5 will be Y in the second row and so on...
Now I get stuck:

1 - let's say that I just have one LSTM layer with just one cell and considering the ([X1, X2, X3], Y) I will insert X1, process (gates magic), insert X2, process, insert X3, process and then compare Yprediction to Y, take my loss and apply backpropagation? or I just insert [X1, X2, X3] at the same time as a vector(because as I discovered each LSTM gate is a small DNN) and then evaluate my loss?
2 - As I said earlier, each gate is indeed a DNN? Their architectures are defined or I just need to specify (how many layers and so on)?
3 - Following DNN model, the so called LSTM cells are fully connected? lets say that I have two LSTM layers, they will follow this same structure where every cell from first layer is connected to each cell from the second one?

PS: Yes, I read colah post, but I did not figure out those points.
Answer: Answering out of order:
2 - Each gate is NOT a DNN, it is an LSTM Cell, which is a single neuron, albeit one whose inner workings are more complex than the basic neurons used in DNN. There are two key concepts in LSTM:

Recurrence, where the output is fed back to the input. This is a property of RNN's in general, of which LSTM is a special case. DNN cannot have the recurrence feature, which is why they are sometimes referred to as feed-forward networks - the signal goes in only one direction. In RNNs on the other hand the signal can flow backwards. Recurrence allows the storage of "short term memories", by the previous values of the sequence in with the current values of the sequence.
The memory cell: This is unique to LSTM, and allows the LSTM to store not just short term interactions, but also long term ones.

The reason why it is easy to confuse a single LSTM cell with an entire DNN (I had this misconception myself when I first started studying them) is that LSTM are typically represented as rolled out over time. A single LSTM cell, because of its recurrence relation, can take in a sequence step by step and hence is functionally equivalent to multiple DNN inputs taking in each value of the sequence simultaneously.
From Chris Olah's post, the single LSTM cell is rolled out over time, so that it looks like multiple DNN cells:

Why do we not just stick to DNN then? Well, with the LSTM cell, the sequence can be arbitrarily long, whereas for the DNN the length of an input sequence is limited by the number of neurons you defined in your DNN's input layer.
1 - Here, it gets little confusing: as mentioned above, LSTM are supposed to handle arbitrarily long sequences, compared to DNN, which have the sequence length predefined by the network architecture. And this is indeed the case for LSTM applied to language problems. In theory this should work for LSTM applied to time series as well. But in practice, it doesn't give good results, so instead we feed the LSTM sequences of fixed length, or sequence windows (see here for how input and output windows are used for forecasting with LSTM). So to answer your question: Do you insert [X1, X2, X3] in one pass, or do you insert the sequence one by X1, then X2, then X3, etc...? You insert them one by one in sequence, but the sequence is a fixed window length sequence, so from the outside they look like they are [X1, X2, X3] vectors, even though they are not. So yeah, your data looking like this:
(([X1, X2, X3], Y)
 ([X2, X3, X4], Y)
 ...
)

Is fine, just think of them as windowed sequences.
(If you wondering how the hell are you going to code this windowing protocol, don't worry: Keras handles it for you).
3 - "Following DNN model, the so called LSTM cells are fully connected? lets say that I have two LSTM layers, they will follow this same structure where every cell from first layer is connected to each cell from the second one?" - No, that is not the case. As explained above, LSTM cells are different from normal neurons in that they are inherently sequential. If you want to connect two LSTM layers, the issue is not whether they are fully connected or not. The detail you have to be careful about is that you are feeding sequences to the second layer, not just individual values (In Keras, this is done by setting the "return sequences" argument to true when specifying an LSTM layer which connects to another LSTM layer).
Chris Olah's post on LSTM is excellent, but it focuses mostly on the internal mechanics of a single LSTM cell. For a more comprehensive functional view of LSTM, I recommend Andrej Karpathy's blog on the topic: The Unreasonable Effectiveness of Recurrent Neural Networks, even though it focuses mostly on language examples, not time series.
Comment: First, thanks to answer! @Skander H. - Reinstate Monica
Could you implement those infos? (A)In Q2, where can I find more about how those gates works? (B) Let's say that I have one LSTM layer with 2 cells, each **cell** will receive the [X1, X2, X3]. What I'm saying is: each cell receives the same input? (C) Related to backpropagation, will work as I said? (feed my input sequence, predict Y and then apply backpropagation)


Add items from ArrayList to Array and show in JList

Question: I am trying to add all the items from ArrayList<String> to String[] array which is in another class but i am fail to do that. I have tried many of the ways but to not avail. The String[] array in another class does not display any item. Hence, I was fail to add the array to the JList. I have no idea to deal with it. Here is my code:

public class bookbook extends JFrame{
  java.util.List<String> timeList = new ArrayList<String>();

  public bookbook(){
    selectTime.timeArr = new String[ timeList.size() ];
    timeList.toArray(selectTime.timeArr);
  }
}

public class SelectTime extends JFrame{
  String[] timeArr = {};
  private JList jlstTime = new JList(timeArr);

  public SelectTime(){
    jpTicket.add(jlstTime);
  }
}

I really need your help. Thanks!
Answer: You are modifying the JList array directly, which, as the documentation states, will result in an undefined behaviour. Try this code: Added the function updateList to the class SelectTime to do it using the appropiate methods
 public class bookbook extends JFrame{
      java.util.List<String> timeList = new ArrayList<String>();

      public bookbook(){
        String [] timeArr = new String[ timeList.size() ];
        timeList.toArray(selectTime.timeArr);
        selectTime.updateList(timeArr);
      }
    }

-
public class SelectTime extends JFrame{
  String[] timeArr = {};
  private JList jlstTime = new JList(timeArr);

  public SelectTime(){
    jpTicket.add(jlstTime);
  }

  public void updateList(String [] array)
  {
      jlstTime.setListData(array);
      jlstTime.invalidate();
  }
}

Comment: It's really work! The JList is now filled with ithems. Thanks for your help!


Divergence of double integral $\iint_{x^2 + y^2 \leq 1} \frac{\mathop{d}x\mathop{d}y}{(x^2 + xy + y^2)^p},\quad p \geq 1$

Question: How to prove the divergence of the integral
$$
\iint_{x^2 + y^2 \leq 1} \frac{\mathop{d}x\mathop{d}y}{(x^2 + xy + y^2)^p},\quad p \geq 1
$$
without transition to generic polar coordinate system?
Answer: Consider $$
I=\iint_{x^2 + y^2 \leqslant 1} \frac{\mathop{d}x\mathop{d}y}{(x^2 + xy + y^2)^p},\qquad J=
\iint_{x^2 + y^2 \leqslant1/4} \frac{\mathop{d}x\mathop{d}y}{(x^2 + xy + y^2)^p},$$ then these are integrals of positive functions hence $J\leqslant I$. Furthermore, the change of variable $(x,y)\mapsto(2x,2y)$ shows that $$I=\frac{2^2}{2^{2p}}J,$$ thus, $$I=4^{1-p}J\leqslant4^{1-p}I.$$ If $p\gt1$, this shows that $I$ is infinite. If $p=1$, the finiteness of $I$ would imply that $J=I$, hence the integral on the annulus $1/4\leqslant x^2+y^2\leqslant1$ would be zero, which is absurd.
Comment: Wow! Very nice and tricky approach, thank you.


Which one is larger, $\int^1_0 f(x) \ln f(x) dx\,$ or $\int^1_0 f(s) ds\, \int^1_0 \ln f(t) dt\,$?

Question:
If $f$ is a positive measurable function on $[0,1]$, which one is larger, $$ \int^1_0 f(x) \ln f(x) dx\,$$ or $$ \int^1_0 f(s) ds\, \int^1_0 \ln f(t) dt\,$$

I tried putting in some functions and found that $$\int^1_0 f(x) \ln f(x) dx\,$$ is larger , but I'm not able to prove in general.
Comment: It can go either way depending on what function you are having.
Comment: what will be the function for other way around?
Answer: Let $g(x) = \log f(x)$ and notice $\log z$ is increasing for $z \in (0,\infty)$, we have:
$$( f(x) - f(y) )(g(x) - g(y)) \ge 0,\quad\forall (x,y) \in [0,1] \times [0,1]$$
This leads to
$$\begin{align}
& \int_0^1\int_0^1 ( f(x) - f(y) )(g(x) - g(y)) dx dy \ge 0\\
\iff &
\int_0^1\int_0^1 ( f(x)g(x) + f(y)g(y) ) dxdy \ge \int_0^1\int_0^1 ( f(x)g(y) + f(y)g(x) ) dxdy\\
\implies & \int_0^1 f(x)g(x) dx \ge \left(\int_0^1 f(x)dx\right)\left(\int_0^1 g(x)dx\right)
\end{align}
$$


Why don't guitar chords and staff notations match each other?

Question: The G7 chord in root position on a fretboard diagram for guitar looks like this:

But in staff notation, the G7 chord in root position looks like:

The correct representation of the notes on the fretboard when written on the staff is G, D, F, and then B (a 10th higher).
I wonder why the note B is more than octave higher than G on the fretboard whereas on the staff B is only a 3rd higher?
Answer: Good question! They do!
The situation you're running into is that your chord diagram doesn't match the G7 you've provided on your music staff.
On the staff you provided, the notes are all separated by the distance of a third- G B D F. I have provided a picture of what the G7 on the staff is telling us to play on the guitar:

The chord diagram that you have provided is of a completely different layout on the staff. The yellow fretboard diagram you have shown will look like this, as per the staff:

Finally, "root position" only means that the note the chord is named after is in the bass: The root note! You can put that note in the bass and play the remaining notes any which way you want, as long as the "root note" is in the bass.
I hope this helps!
Comment: An easier, albeit wacky, way of playing the close voicing is with open g and b string, d on the A-string way up on the 17th fret and f on the d-string 15th fret. A more reasonable alternative is of course to just omit the d and play the f on the e-string.
Comment: Observe how the staff representation comes (or may come) from taking the G one octave down from the second inversion closed voicing (DFGB -> GDFB). Since G was the second voice from the top, it's called a **Drop2 voicing** - super useful in guitar, works for all kind of chords!
Answer: "Root position" means that the lowest pitch is the root of the chord, but it says nothing about the other notes. The staff-notation chord is shown in "close position" – the most compact arrangement of notes – which is impractical (if not impossible) on guitar. The guitar voicing is in "open position", so the pitches are more spread out.
Answer: Very simple answer is - they don't have to. Root position tells one fact only - the lowest note - of any chord in root position, is the root. That's how inversions work as well, 1st inversion has ^3 as the lowest note, 2nd inversion has ^5, and so on. It's become convention.
What you're trying to understand is open and closed voicing. Given that the chord is in root position (root= lowest note), the other notes, be they triad or more, can be spread how one would like - and that fact won't affect the fact that it's still root position.
Couple of other considerations: guitars aren't famed for capability to produce certain voicings easily, so will use whatever they can. Part of their beauty - or otherwise! And it's easier to portray (as in your pic. of the stave) to write chords out in closed position.
Answer: The arrangement of strings on the guitar means that certain voicings are difficult to achieve whereas others are easier. This also leads to the fact that several voicings, or as we call them, chord shapes, are available for most chords.
As it happens, the other day I was required to play a C7b5 chord: C E Gb Bb. It was imperative to find a shape that does not have two strings with a single tone differing between them (i.e. E and Gb, aka F#, Bb and C). In the end, I found a voicing 3rd fret on the fifth string (C), 4th fret on the fourth fret (Gb), 3rd fret on the third string (Bb) and 5th fret on the second string (C). This is a completely different voicing from the chord in root position, and in fact helps by moving the E from its position where it might clash with the Gb, to the top.
Not connected: this is an interesting chord in that it is made up of two tritones.
Answer: A complete G7 chord in staff notation would contain an arbitrarily-selected "G" note, an arbitrary (possibly empty) subset of the "G" notes that appear in higher octaves, an arbitrary non-empty subset of the "B" notes that appear above the lowest "G", and an arbitrary non-empty subset of the "D" notes that appear above the lowest "G", and an arbitrary non-empty subset of the "F" notes that appear above the lowest "G".  While many depictions of G major triads simply include the lowest note that's above the root for each pitch and omit the rest, the "real" chord might be more usefully viewed as including all such notes, with the common staff notation opting to use one acceptable subset of them, and the common guitar fingering opting to use a different--but still valid--subset.
Answer: Contrary to what was said above, "root position" of that chord means all the notes are a third apart and the root of the chord is the lowest note.  I realize guitar players sometimes have their own terminology, but this is what root position means.
Comment: Part of this answer is inaccurate and untrue.-1. There is absolutely no reason for all notes to be a third apart, except in *closed* position.
Comment: In what area of terminology does "root position" mean that?  It is certainly not the usual meaning of "root position" in classical theory.
Comment: @Tim It's *close* position.
Comment: @ElementsInSpace - it very much depends on where one looks. Either makes sense. Closed, as in no spaces in between, or close, as in not far away. Never can make up my mind. Maybe a question is due...


How to check if help button is pressed on wizard page programatically in java

Question: I have created a Wizard with four Wizard pages.On the second page , I want to do some action only when the help button is pressed, is there a way where i can check programatically if the help (F1) button is pressed?While Creating the wizard page i am trying to extend "Wizard" which inturn extends "DialogPage".
Comment: send your code so that we can help you
Comment: where is your code ?
Answer: On your WizardPage you can override the performHelp method to do something when the Help button is pressed:
@Override
public void performHelp() {
   ... your code ...
}

Comment: Yeah I know this method Greg.But my requirement is , There is a radio button on click of radio button ,inside the event listener i have to check if the help button is pressed , if it is already pressed then have to perform some actions.
Comment: So set a flag to remember that performHelp has been called.


Paired difference t-test vs independent two sample t-test to assess means difference

Question: If I want to compare two sets of measurements, i.e., how much their means differ or how much the sets differ, I would say I have two options:

Paired difference t-test: Calculate the differences to get the change score for each element and then use the set of differences to build the t statistic (with the mean and standard deviation of the differences) and compare with the t-distribution. The degrees of freedom would be n-1.
Similar approach, but calculating means and standard deviation separately for both samples. Build the the statistic using the two means and standard deviations. The degrees of freedom would be 2n-2.

What are the differences between these two approaches?
Answer: To readers : please note the hierarchy of the answer :-)
Suppose $X\sim N(\mu_x,\sigma_x^2)$ and $Y\sim N(\mu_y,\sigma_y^2)$.
For simplicity, suppose $\sigma_x^2=\sigma_y^2=\sigma^2$, which is unknown. Suppose the two samples are $\mathbb{X}=\{X_1,\dots,X_m\}$ and $\mathbb{Y}=\{Y_1,\dots,Y_n\}$. We are testing $H_0: \mu_x-\mu_y=0$

when $m\neq n$

paired t-test is not applicable.
2-sample t-test is applicable if $\mathbb{X}$ and $\mathbb{Y}$ are independent.

when $m=n$

if $\mathbb{X}$ and $\mathbb{Y}$ are matched and thus not independent, then

paired t-test is applicable
2-sample t-test is not applicable as it assumes independence

if $\mathbb{X}$ and $\mathbb{Y}$ are independent, then

both paired t-test and 2-sample t-test are applicable.
paired t-test

Let $Z_i=X_i-Y_i$, where $i=1,2,\dots,n$, and $X_i$ and $Y_i$ are $i$-th observations in $\mathbb{X}$ and $\mathbb{Y}$ respectively. Then test statistic is $t_1=\frac{\bar{Z}}{S_z/\sqrt{n}} = \frac{\bar{X}-\bar{Y}}{S_z/\sqrt{n}}$, where $S_z$ is the sample standard deviation of $Z_i$'s. When $H_0$ is true,  $t_1 \sim t(n-1)$. Note that the value of $Z_i$'s depends on the ordering of observations in $\mathbb{X}$ and $\mathbb{Y}$, so does $S_z$. Since $X_i$ and $Y_i$ are not paired, we can arbitrarily re-order the observations in each of $\mathbb{X}$ and $\mathbb{Y}$, and get different values of $Z_i$'s, $S_z$ and thus $t_1$. This is the most obvious disadvantage of applying paired test to unpaired data. To make the test "objective", let's order the observations in $\mathbb{X}$ and $\mathbb{Y}$ in a completely random manner.

2-sample t-test

test statistic is $t_2= \frac{\bar{X}-\bar{Y}}{\sqrt{S_x^2+S_y^2}/\sqrt{n}}$. When $H_0$ is true, $t_2 \sim t(2n-2)$.

What is the difference between $t_1$ and $t_2$?

Theoretically, both tests work, but they have different derivations. $t_1$ is based on one normal random variable $\bar{Z}$ and one $\chi^2_{n-1}$ random variable $(n-1)S_z^2$ which is independent of $\bar{Z}$. $t_2$ is based on difference between two independent normal variables $\bar{X}$ and $\bar{Y}$, and addition of two independent $\chi^2_{n-1}$ random variables $(n-1)S_x^2$ and $(n-1)S_y^2$ which are both independent of $\bar{X}$ and $\bar{Y}$.
What is the relationship between $S_x^2$, $S_y^2$ and $S_z^2$?
$S_z^2 = \frac{1}{n-1}\sum\limits_{i=1}^{n}(Z_i-\bar{Z})^2$
$ = \frac{1}{n-1}\sum\limits_{i=1}^{n}(X_i-Y_i-\bar{X}+\bar{Y})^2$
$ = \frac{1}{n-1}\sum\limits_{i=1}^{n}[(X_i-\bar{X})-(Y_i-\bar{Y})]^2$
$ = \frac{1}{n-1}\sum\limits_{i=1}^{n}(X_i-\bar{X})^2 + \frac{1}{n-1}\sum\limits_{i=1}^{n}(Y_i-\bar{Y})^2 - 2\frac{1}{n-1}\sum\limits_{i=1}^{n}(X_i-\bar{X})(Y_i-\bar{Y})$
$ = S_x^2 + S_y^2 - 2S_{xy}$, where $S_{xy}$ is the sample covariance between $\mathbb{X}$ and $\mathbb{Y}$, which again depends on the ordering of observations in $\mathbb{X}$ and $\mathbb{Y}$.

Which test should we choose?

key word : statistical power of test, which is the probability for a test to reject $H_0$ when $H_0$ is false.
Situation 1: If $S_{xy} = 0$, then $S_z^2 = S_x^2 + S_y^2$ and $|t_1| = |t_2|$. Since $t_2$ has larger degree of freedom, the corresponding p-value is smaller than $t_1$. Hence, when $H_0$ is false, 2-sample t-test has larger statistical power (making you more confident in rejecting $H_0$) than paired t-test. Since $X$ and $Y$ are independent, we know their population covariance is $\sigma_{xy} = 0$. When the observations in $\mathbb{X}$ and $\mathbb{Y}$ are randomly ordered, intuitively, we have a good reason to believe that the sample covariance $S_{xy}$ is not far from the population covariance $\sigma_{xy}=0$, and thus believe $S_{xy} \approx 0$ is the most likely situation.
Situation 2: If $S_{xy} < 0$ (we can always achieve this by cheating: order the observations in $\mathbb{X}$ in ascending order and $\mathbb{Y}$ in descending order, which is the reason why we should use random ordering), then $S_z^2 > S_x^2 + S_y^2$ and $|t_1| < |t_2|$. Since $t_2$ also has larger degree of freedom than $t_1$, the 2-sample t-test has smaller p-value than paired t-test. When $H_0$ is false, 2-sample t-test has larger statistical power.
Situation 3: If $S_{xy} > 0$ (we can always achieve this by cheating: order the observations in both $\mathbb{X}$ and $\mathbb{Y}$ in ascending order, which is the reason why we should use random ordering), then $S_z^2 < S_x^2 + S_y^2$ and $|t_1| > |t_2|$. Now $|t_1| > |t_2|$ but $t_2$ has more degrees of freedom than $t_1$, so it is hard to say which  test statistic gives larger p-value or which test should be preferred.
Conclusion: Considering all 3 situations, overall, when $X$ and $Y$ are independent, it is better to choose $t_2$ (two-sample t-test) rather than $t_1$ (paired t-test) if we use statistical power as the criterion. Especially, since $S_{xy} \approx 0$ is the most likely situation, we simply choose the test having larger power in situation 1, which is two-sample t-test.
A simulation study is conducted to compare the two test procedures in term of statistical power. Let $X\sim N(0, 1)$, $y\sim N(\mu_y, 1)$, let $n=10$ and let $\alpha = 0.05$. The x-axis represents the true value of $\mu_y$ ($H_0: \mu_x = \mu_y$ is true when $\mu_y = 0$), and the y-axis shows the percentages of rejecting $H_0$ using the 2 test procedures. As you can see, when $H_0$ is true ($\mu_y=0$), the two procedures have almost the same type I error; when $H_0$ is false, 2-sample t-test has more chance of rejecting $H_0$.
<code>n.rep <- 10000
n <- 10
alpha <- 0.05
mu.y.seq <- seq(0, 2, 0.1)
len.mu.y.seq <- length(mu.y.seq)
pct.rej.mat <- matrix(0, nrow = len.mu.y.seq, ncol = 2)
for(mu.y.index in 1:len.mu.y.seq){
  n.rej.1 <- 0
  n.rej.2 <- 0
  for(rep in 1:n.rep){
    set.seed(rep)
    X <- rnorm(n = n, mean = 0)
    Y <- rnorm(n = n, mean = mu.y.seq[mu.y.index])
    Z <- X - Y
    t1 <- t.test(x = Z)
    t2 <- t.test(x = X, y = Y)
    if(t1$p.value < alpha) n.rej.1 <- n.rej.1 + 1
if(t2$p.value < alpha) n.rej.2 <- n.rej.2 + 1

  }
  pct.rej.mat[mu.y.index, ] <- c(n.rej.1, n.rej.2)/n.rep
}
plot(pct.rej.mat[ ,1] ~ mu.y.seq, ylim = c(0, 1), xlab = expression(paste(mu[y])), ylab = "percentage of rejecting H0", main = "comparing paired t-test with 2-sample t-test for independent X and Y")
lines(pct.rej.mat[ ,1] ~ mu.y.seq)
points(pct.rej.mat[ ,2] ~ mu.y.seq, col = "red")
lines(pct.rej.mat[ ,2] ~ mu.y.seq, col = "red")
legend(x = c(0,0.5), y = c(0.84, 1), legend = c("paired t-test","2-sample t-test"), col = c("black", "red"), pch = c(1,1) )
</code>
Comment: Also, $t_1\approx t_2$ would only hold **if X and Y are in fact independent**. While you give this as one of your assumptions, if you have paired measurements there should be **at least some** dependence due to correlation between X and Y measured in the same element [sampling unit] (which is reflected in the variance formula for the paired estimate), and the paired t-test will return a higher t-value than running an unpaired t-test on the same data...
Comment: @JellicleCat I still think that the decision is more simply based around your initial two subheadings under point #2 (that is, whether data are paired or unpaired.) Note also that imposing arbitrary 'pairing' on unpaired data means that the estimate of $S_z^2$ is dependent on the ordering of 'pairings' selected, which is a second reason not to select unpaired tests. ($S_{xy} \approx 0$ is the expected long-run value of $S_{xy}$, rather than the value in any given arbitrary pairing.)  see http://stats.stackexchange.com/q/47453/16974 for an R example of this.
Comment: The case not considered in this answer is what happens if you do an independent test on paired data.  This is suboptimal, but sometimes you do not have the pairing information, e.g. a before and after measurement collected from an anonymous survey, you know the design is paired, but don't know which values pair together.  In this case if the correlation is positive then the independent test is conservative (p-values will be larger, confidence intervals will be wider) and so you can still make reasonable conclusions in this case.
Comment: I'm not sure how the calculations factor into the decision about which test to choose: the decision should be based around whether the data are in fact paired observations or not?
Comment: @JamesStanley Please notice the hierarchical structure of the answer.
Comment: @JellicleCat Ah ok, though the structure is quite hard to read (which is how I missed the pertinent points.)
Comment: @JamesStanley Thank you very much. You comments are very helpful. I have modified the answer accordingly :)
Comment: @GregSnow Thanks for your comments. Very constructive. But I don't have knowledge of handling the case in which the pair information is not given, so I don't know how to modified the answer.


Customize create content page

Question: I'm wondering if there's a way to customize the create content page (not the content display page), including recordering and repositioning things.
ATM it's "Title" on top, followed by "Body" on the bottom, followed by other fields like "Upload" and "Save".
Is there a way to customise the labels, reorder and repositon this page?
For example: To move "Upload" on top and in the middle, followed by "Title" and "Body" below it while changing the label of Body to "Description", and changing the caption of the "Save" button to "Submit"?
Thank you very much.
Answer: Yes, it is possible. Firstly you need to read and understand the Drupal 7 Template (Theme Hook) Suggestions documentation to render and rearranging field items.To alter Title , Body, Save etc you will need to understand hook_form_alter, it is used for altering a form and hook_form_FORM_ID_alter is a smarter way to do the same as hook_form_alter.There is a cool hook_form_alter tutorial hope will help you.
Answer: I looked around for a long time and found that the very powerful Display Suite module that has a great screencast series covering it here on youtube was what I was looking for.

Customize create content page


gspread reading a google sheet file using python 3

Question: I'm using Python 3 running Pycharm and the module gspread to read google sheet files in my google drive. Well, I've followed all steps from this link  about how to read a file. Unfortunately, my code here below doesn't work yet.
 import gspread
 from oauth2client.service_account import ServiceAccountCredentials

 scope =['https://docs.google.com/spreadsheets/d/1xnaOZMd2v93tY28h_hsuMnZYXC9YqCfFpQX70lwpN94/edit?usp=sharing']
 credentials = ServiceAccountCredentials.from_json_keyfile_name('distech-c1e26e7150b2.json',scope)
 gc = gspread.authorize(credentials)

 wks = gc.open("POC").sheet1

 for temp in wks:
     print(temp)

How could I read the google sheet file using this module guys? thanks so much
Answer: I got it after a deep research I realize two things.

the scope in my code was wrong cause the scope is just one provided by Google API to grant right access permissions under spreadsheet.
The right scope for me was: scope =['https://spreadsheets.google.com/feeds']

the opener it's just to open the spreadsheet that will return the worksheets within my file.

So solutions thanks to @Pedro Lobito in his post here.
Solution:
I had the same issue with just a couple of spreadsheets on my account, the problem was solved by:

Opening the json key file (projectname-ca997255dada.json)

Find the value of client_email , i.e.: client_email": "firstname.lastname@example.com

Share your sheet(s) with that email

Now my code looks like:
import gspread
from oauth2client.service_account import ServiceAccountCredentials

scope =['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('xxx.json',scope)
gc = gspread.authorize(credentials)

spreadsheet = gc.open("POC")
wks = spreadsheet.worksheet('test1')
wks2 = spreadsheet.worksheet('test2')
out = list()
out = wks.col_values(1)
for temp in out:
    print(out)


stability of the problem

Question: Let we  solved an equation (for example Poisson equation) by a numerical method,
$$-\Delta u=f,~in~\Omega $$
$$u=g
,~on~ \partial \Omega $$
so we want to find the error ($u-u^h$),
we say a problem is unstable if a bit change in data leads to a large change in  the solution, my question is:
If by a little change in the data, the answer be much better (unexpectedly),
can we say the problem is unstable? For example if the rate of convergence is $2$ and for one step it is $60$.
Thanks for your help,
Answer: Stability means that the mapping from data $f$ to solution $u$ is continuous. Since this mapping is linear for linear problems, it is enough to
show the existence of a constant $c>0$ such that $\|u\|\le c\|f\|$ for appropriate norms.
If for two different right-hand sides $f_1,f_2$ the solutions $u_1,u_2$ are much closer than expected, i.e., $\|u_1-u_2\|<<\|f_1-f_2\|$ this is not a contradiction to stability.
If on the other hand you can make $f_1-f_2$ arbitrarily small but $u_1-u_2$ does not vanish, this is a sign of instability.

stability of the problem


Laravel 5.2.x Password Broker using Username as the Email Column name

Question: We're inheriting a CakePHP code base, and a schema.  Porting it to Laravel 5.2.x, but we have to maintain the schema where they use username in the schema instead of email.  So I'm trying to get password reset to work using the username column instead.
I've pulled in ResetPasswords::sendResetLinkEmail into the PasswordController to overwrite it and validate on username instead of email, and pass in username to sendResetLink so the user can be authenticated:
public function sendResetLinkEmail(Request $request)
{
    $this->validate($request, [
        'username' => 'required|email',
    ]);

    $broker = $this->getBroker();

    $response = Password::broker($broker)->sendResetLink(
        $request->only('username'), $this->resetEmailBuilder()
    );

    // ...

But, it throws an error after invoking the method on line ~91 in the PasswordBroker:
$token = $this->tokens->create($user); // line 91

Now I have no idea where this goes since it appears to be invoking an interface that is dependency injected into the PasswordBroker, but it is responsible for saving the password reset record.
Answer: Okay, after a lot of fussing around I figured it out.  In order to keep the semantic column username instead of using email for password reset:
There are two steps:
1) You need to pull up ResetsPasswords::sendResetLinkEmail into your PasswordController, and have it validate and pass in username to sendResetLink, which is in the question, but also included below for completeness:
/**
 * Send a reset link to the given user.
 *
 * @param  \Illuminate\Http\Request $request
 * @return \Illuminate\Http\Response
 */
public function sendResetLinkEmail(Request $request)
{
    $this->validate($request, [
        'username' => 'required|email',
    ]);

    $broker = $this->getBroker();

    $response = Password::broker($broker)->sendResetLink(
        $request->only('username'), $this->resetEmailBuilder()
    );

    switch ($response) {
        case Password::RESET_LINK_SENT:
            return $this->getSendResetLinkEmailSuccessResponse($response);

        case Password::INVALID_USER:
        default:
            return $this->getSendResetLinkEmailFailureResponse($response);
    }
}

2) The key to this, which seemed to take a while to figure out yet is quite simplistic in nature, but completely undocumented as far as I can tell is changing the trait CanResetPassword::getEmailForPasswordReset used on the User model to also use username instead of email, which you don't want to overwrite within CanResetPassword so I removed the trait from the User model and applied my own copy of it within the application namespace:
namespace App\Traits\Auth;

trait CanResetPassword
{
    /**
     * Get the e-mail address where password reset links are sent.
     *
     * @return string
     */
    public function getEmailForPasswordReset()
    {
        return $this->username;
    }
}

Now you can send password reset links, and reset passwords.  Hope this helps.