Facebook Like button - show actual numbers?

Question: I am currently using the Facebook like button on a website and when the numbers get quite high, the number becomes truncated with a 'k' for thousand or 'm' for million.
Rather than displaying '1m', is there anyway to display the actual number i.e. 1,000,543.
The documentation and demo seems to show a raw number for the standard layout but there is no mention of this in the attributes section or how to action it for the button_count layout.
Any help would be greatly appreciated.
Thanks
Answer: As answered in the https://stackoverflow.com/a/7324769/2089361,
use facebook graph API:
query http://graph.facebook.com/http://www.facebook.com/thedoors, get JSON string in response, parse it and here's the actual likes count.
Comment: Makes perfect sense. Thanks and sorry for not picking up the earlier question/answer.
Answer: function fb_like_count($facebook_name){
    $data = json_decode(file_get_contents("https://graph.facebook.com/".$facebook_name));
    echo $data->likes;
}

Will echo the number of likes. $facebook_name is the url of the page.


Comparing classification results from models selected differently with Kruskal-Wallis

Question: For a seminar at university I'm reviewing a paper that proposes a new feature selection algorithm. The authors also evaluated their algorithm by applying it beside two other feature selection algorithms on 17 datasets. In order to compare them, they used the resulting feature subsets for classification and documented the accuracy and AUROC of the different algorithms.
In order to see if the presented algorithm is doing better than the other two, I'm separating their results into three groups (one for each algorithm) with each 17 instances (since they tested them for 17 datasets). Then I use the Kruskal-Wallis test to check if there is a significant difference in the distributions of the given quality measures for the algorithms.
My question is: is this approach valid? If not, how would you approach this task?
Answer: Since the models are tested on the same datasets, they wouldn't be independent.  (Try correlating the AUCs from the different models, most likely the dataset with the highest value from one model will be the dataset with the highest value from another model.)  I might try Friedman's test instead of the KW.
However, you won't have much power this way, which is especially problematic if you want to argue for the null hypothesis (which is already problematic, see my answer here: Why do statisticians say a non-significant result means "you can't reject the null" as opposed to accepting the null hypothesis?).  The reason is that the AUC has aggregated (thrown away) a lot of information about all of the instances in the dataset and their relative rankings into a single value.  You could get somewhat more information from the model outputs by using something like the Brier score instead of the AUC.  Depending on how much work you want to do (I suspect it would be a lot), you could try to work with all the observations from each dataset in a hierarchical model rather than aggregating at all.
Comment: First of all, thanks for your answer. Since the only data I have is what the authors published in their paper, I won't be able to do much in-depth work on this.
I'll check friedman's test for now
Comment: Friedman's test is an acceptable solution. I would be wary of asserting the null, though. You might just look at descriptive statistics, plots, etc, to characterize how the distributions differ.
Comment: @gung I have a [question](http://stats.stackexchange.com/questions/188615/what-test-is-appropriate-for-comparing-the-difference-in-accuracy-between-recogn) related to your statement that "*Since the models are tested on the same datasets, they wouldn't be independent*". Could you please have a look at it?


Is calling a nonvirtual member function on a non-constructed "object" well-defined?

Question: Inside a constructor, calling non-virtual member functions is permitted.
Does from this fact follow that the following piece of code is well-defined?
struct A {
    void foo { std::cout << "Hi there! My address is: " << this; }
};

A * a = nullptr;
a->foo ();

Answer?
With the help of some links given in the comments, and the links given in the linked pages, I now think that the answer can be found e.g. in
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3035.pdf
§3.8 par. 5, p. 66:
"Before the lifetime of an object has started but after the storage which the object will occupy has been allocated ... [t]he program has undefined behavior
if [...] the pointer is used to access a non-static data member or call a non-static member function of the object"
Then it should be even more undefined to call a member function if storage has not been allocated at all.
I guess one important reason why it is a good idea to make it undefined is explained here: https://stackoverflow.com/a/3257755/1419315
Comment: http://stackoverflow.com/questions/2533476/what-will-happen-when-i-call-a-member-function-on-a-null-object-pointer?rq=1
Answer: That code is undefined behavior.
Note that inside the constructor you can also call virtual member function.
The somewhat tricky part is calling virtual member function during member initialization before the constructor code begins. Still valid but it's not obvious what happens (the point is that until the constructor code begins the object isn't considered yet an instance of its class and virtual member functions get dispatched to the base class).
Some compilers emit a warning if you use this in the member initialization list exactly because the this pointer will behave strangely at that point (it will start behave normally only after the start of the constructor).
The code apparently works because most compilers use the VMT approach for method dispatching but the VMT is not needed to call a non-virtual method and thus if the method code doesn't dereference in any way this then things seems to "work". However the fact that the code seems to work in an implementation (or even in every implementation for that matter) still doesn't make it legal C++ code.
Comment: As far I know, you shouldn't call a virtual method inside the ctor.
Comment: @Manu343726 Only because it probably won't do what you want. If it does do what you want, there's nothing wrong with it, it's valid in standard C++.
Comment: @hvd oh, because if you have a class hierarchy, you instance an object of a derived class (Which constructor calls to the base class constructor first) and in the base class ctor you call a virtual function?
Comment: @hvd what I don't understand completely is: Is not the vptr of the object initialized before the execution of any ctor and bases ctors? If that was true, there would no problem with virtual calls in base ctors.
Comment: @Manu343726 You're worrying too much about implementation details, IMO. Conceptually, it's simpler. Given `struct S2 : S`, constructing `S2` first creates an `S` subobject, and only then the full `S2`. During the construction of the `S` subobject, there is no `S2` object, and if you have no `S2` object, you cannot call `S2`'s methods, so virtual method calls have nothing else to call but `S`'s implementation. If that's what you want to call, then nothing wrong with doing so. But yes, your idea of how object construction is implemented is how it works in some other environments/languages.
Comment: @hvd I understand the concept perfectly, I was asking about how it really works and how it really performs :)
Comment: @Manu343726 Ah, okay. :) In that case... Of course, this is system dependent, but if the base class constructor sets the vtable pointer, and then starts calling virtual functions before the derived class constructor is back in control, there's no way the derived class constructor can redirect those functions to its own implementation, unless it can indicate somehow that the base class constructor should leave the vtable pointer alone, and C++ just doesn't have such a way. (This isn't the point of either the question or this answer, so perhaps we should drop it.)


Cannot add new user due to "Integrity constraint violation: Duplicate entry" error

Question: Starting December 14, 2021, my site began creating users with low user IDs, even though the highest-used user ID was 9317. I thought something had been changed in a core update to reuse IDs that had been freed up by canceling a user account. However, I discovered that since that date, the site has been trying to reuse every ID starting with 1. My error log is filled with errors like this:
Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation:
1062 Duplicate entry '281' for key 'users.PRIMARY': INSERT INTO "users" ("uuid", "langcode")
VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array (
[:db_insert_placeholder_0] => 5ff1347c-439f-437e-ba3f-762f7350fda3
[:db_insert_placeholder_1] => en ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
(line 811 of /home/drupal/webroot/rsc.byu.edu/web/core/lib/Drupal/Core/Entity/
Sql/SqlContentEntityStorage.php).

The above example says Duplicate entry '381'. The next error will say Duplicate entry '382' and so on.
I read posts suggesting the sequences table contains the next user ID value. My sequences table contains the value 9330, which would be fine if it were being used. But it's not.
Answer: After long looking, I noticed on a backup from before December 14, 2021, the users table uid field was defined as Attributes: UNSIGNED. NOW (February 18, 2022), the uid field is defined as Attributes: nothing and Extra: AUTO_INCREMENT. The AUTO_INCREMENT is new.
This led me to test with a backup copy of my site. Sure enough, prior to December 14, 2021, each time I add a user, the value in the sequences table is incremented. That no longer happens in the updated site. Instead, it crashes as described above.
The solution was to run the following query in the database:
ALTER TABLE users AUTO_INCREMENT = 3918; # highest existing ID was 3917

This solved the problem. I assume that in a core update installed on December 14, 2021, the code changed from using the sequences table to using AUTO_INCREMENT on the uid field in the users table and that somehow, I failed to do a database update that would have correctly set the AUTO_INCREMENT value in the users table to avoid this mess.
I hope this report of my pain will help someone.
Comment: Following an upgrade to Drupal 9.3.12, new users couldn't be created on the site. The error message I got when attempting to add a user either through the site or via drush was: "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '220' for key 'users.PRIMARY...". Your ALTER TABLE query saved the day and fixed the issue for me. Thanks Marshall!


Quadratic differential equation - closed form solution?

Question: Can a solution for x(t) be found from the following real valued differential equation
$$a\frac{d}{dt}\!(x(t))^2 + x(t) +b\frac{d}{dt}\!(y(t)) = 0$$
in terms of only y(t), it's integrals or derivatives and a, b ?
I tried using LaPlace operators to solve, but no luck.
Comment: What relation is there between $x(t)$ and $y(t)$? What does $\frac{d}{dt}(x(t))^2$ denote, exactly?
Comment: x and y are just real valued functions of time, bound by the mathematical expression in which they are written. The equation does represent a model of a physical system and there is causality such that x results in y, but as for the mathematics causality is not important.
Answer: $$\dfrac{2a}{b}\int x(t){dx(t)}+\dfrac{1}{b}\int x(t)dt=y(t)+C\\
\implies y(t)+C=\dfrac{a\times (x(t))^2+\int x(t)dt}{b}$$
Comment: Thanks, but nope, that's not what I was after. I'm looking for x(t) in terms of y(t) rather than the other way around. x(t) = ??


Simulating results from logistic regression

Question: After predicting the probability of success for each datapoint in a logistic regression model i would like to run a simulation to simulate the number of succeeded iterations.
Im not trying to do something super advanced so my first thought was to maybe iterade through each predicted probability and simulate a value between 0 and 1 from a uniform distribution and then compare the simulated value with the predicted probability. If the simulated value S is lesser than the probability P then this will be coundet as a success, else it fails.
I'm just wondering what types of arbitrary simulations you guys can come up with and mainly if you think that my simulation is good, bad , worthless etc
Comment: I don't know the context of what you are trying to do, but an interesting thing to try could be to simulate the data points themselves.
Answer: You're basically trying to sample $n$ independent Bernoulli trials with success probabilities given by your predictions.
Your approach is fine and can be done in one line in R.
num.successes <- sum(runif(n) < predictions).
Or you can just use the binomial random number generator
num.successes <- sum(rbinom(n,1,predictions)).
Comment: sweet, thanks for the answer and +1 for writing lines of code aswell :)


where to put the connection string in a n-tier app?

Question: I've created a DAL using the entity framwerok. I've also created a business service layer and a presentation layer(web app).
My common sence is telling me the connection string should by only in the DAL but the presentation layer needs the connection string too.
So what's the best-practice for this situation ? Is there any way to have the connection string only in the DAL?
Comment: Why does the presentation layer need the connection string?
Comment: Q:  "Is there any way to have the connection string only in the DAL?"
A:  Yes, make sure the DAL is the only layer connecting to the database.
Comment: to C.Ross: when i delete the connection string from the web.config i get an error:
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

This is grom the designer file in the DAL.

to marcc: there is the edmx file in the DAL and this layer is referenced to the business layer where I have a method that queries the entities using linq. This method is used in the presentation layer to obtian the datasource for the gridview.
Answer: You usually put the connection string in a config file, and the config file that is used is the one for the executing assembly. For a website it's going to be web.config.
Why does your presentation layer need access to a connection string?
Answer: Your connection string usually resides in and is accessed from the web.config.  You probably shouldn't ever hardcode a connection string unless you have no other choice (and I can't think of any situations where you wouldn't).
Answer: If the presentation layer needs the connection string, you have a flaw in your design.
Comment: @RichardOD -- I about put that caveat in there and now I have to upvote the obvious.  lol
Answer: The data abstraction layer should be the only place your data is accessed. Your presentation layer should use the business services layer and the business services layer should use the DAL for data access. Thus you won't need direct access to the data source from the presentation layer and the only place for the connection string will be in the DAL.
Comment: I understand the theory but it just didnt work like this in my case. In my DAL i'm using the Entity framework.This layer is referenced to the business layer.IN this layer i have a L2E query returning a IEnumerable<>. This query is called from the presentation layer and assigned as a datasource for a gridview. The strange think is i need the connection string in the presentation layer else it won't work. I also needed to reference the DAL in the presentation or else it wouldn't work. I'm doing somthing wrong but i don't know what ...
Answer: I have a DAL that takes a connection string as a parameter when it is instantiated. The layer using the DAL is responsible for getting it. This way the DAL doesn't change if it is in a Windows or web app.  My DAL is also only instantiated once per application using the singleton pattern, so the overhead of retrieving the connection string is paid only once.
<code>        public sealed class cApp
        {

        static readonly cDB _cDB = new cDB(
    ConfigurationManager.ConnectionStrings["MyConnString"].ConnectionString);

        public static cDB DB
            {
                get
                {
                    return _cDB;
                }
            }

        }
</code>
Then in code I can use it like:
<code>    GridView1.DataSource = cApp.DB.GetStages(id);
   GridView1.DataBind();
</code>


Are there pieces that require retuning an instrument mid-performance?

Question: Are there any musical pieces that call for the musician to detune/retune the instrument, not in advance like a scordatura, but mid-performance?
I think it would be a neat avant-garde concept—for example, temporarily adjusting the peg of a violin's G string to play F#3 then adjusting it back, etc. I'd imagine it would be challenging but not impossible, and I'm curious to know if such pieces exist.
Comment: Please clarify whether you're asking about instruments in general (as the title suggests) or the violin specifically (as the tags suggest).
Comment: My born-to-nitpick mind read this question and immediately jumped: "define retuning!" If you squint at it a little, every time a harpist presses a pedal they retune their strings (to a different key) :P
Comment: In the 1980s the guitarist Alex de Grassi was invited to perform at Virginia Tech, and I saw him in live performance in an intimate space. At one point in one of his pieces, he abruptly stopped and explained, "sorry, at this point I need to switch guitars; the rest requires a different tuning." Don't recall which piece.
Comment: There's a lot in banjo repertoire that uses Keith tuners, which have tuned stops that allow the quick switch between tunings. "Flint Hill Special" is one particular piece that uses this technique.
Comment: It's not that uncommon. Richard Strauss frequently demands notes below the lowest open string, which strictly speaking would require re-tuning in performances (Salome, Elektra, Alpensinfonie...) In practice, however, these are often just omitted.
Comment: @Aaron violin immediately came to mind since that's what I'm familiar with, but I never considered the other neat examples that people pointed out below. I've removed the tag.
Comment: Regarding retuning and tuning back during performance, some guitarists (at least one guitarist, anyway) do this. https://www.youtube.com/watch?v=nY7GnAq6Znw
Comment: Slightly facetiously: most pedal-steel pieces require retuning the instrument mid-note. Kind of
Comment: Impressive performance by Ed Sheeran : https://youtu.be/nUx9tNzpbbs?t=15 He moves the capo and retunes the guitar at https://youtu.be/nUx9tNzpbbs?t=60
Comment: [Wiki](https://en.wikipedia.org/wiki/Scordatura) has an long list of scordatura examples arranged by instrument.
Comment: This is becoming more common in guitar as well, with Alexandr Misko (e.g. in Careless Whisper https://www.youtube.com/watch?v=YzgTMh21zhI&ab_channel=AlexandrMisko), Jon Gomm (e.g. in Passionflower https://www.youtube.com/watch?v=nY7GnAq6Znw&ab_channel=JonGomm) and Mike Dawes all making use of this technique (most use equipment to aid in the tuning; Jon Gomm doesn't). Charles Berthoud also does it on bass (e.g. https://www.youtube.com/watch?v=SeX0Gd8zyLY&ab_channel=CharlesBerthoud).
Answer: Lots of classical music require retuning of timpani (or purchasing a larger drum set). Von Biber's Rosary Sonatas require retuning a violin between each section.
Comment: more modern timpani repertoire may require so many retunings that a larger drum set would be impractical
Comment: @phoog - I thought the third most common number of timpani in an ensemble after 0 and 4 was 8.
Comment: @PeterSmith for example, Appalachian Spring has a nearly complete diatonic scale if I recall correctly.  It's not practical to have six or seven drums within reach.
Comment: @Dekkadeci played by two players, I expect.  Appalachian Spring calls for one player.
Comment: @phoog A single player could have multiple positions on-stage (with different sets of drums at each) from which they can play any song for which re-tuning a single drum (or several) would be called for. If it requires playing an a full octave in the same section, that's a different matter. Even re-arranging the various drums sounds at least as doable as re-tuning.
Comment: Can't recall the exact pieces, but in college I played at least two performances where the timpani needed to be retuned between movements. We had 4 timpani.
Comment: I've played plenty of pieces on timpani that had changes throughout the piece (as many as 40 in a single movement!).  These can be done fairly quickly with the pedals and a bit of practice.  Some timpani have gauges on them to allow you to quickly reference what the current pitches are as well.  It's also not uncommon to have a fifth drum (20, 23, 26, 29, and 32-inch drums, pitch ranging from pedal D to middle C)
Comment: @jpaugh Timpani are heavy, awkward, and can be a bit tricky to move silently depending on the quality of the wheels and flooring. I played percussion for many years, but can't imagine a situation where you'd want to rearrange timpani during a performance. If you have enough time to do that, you have more than enough time to re-tune.
Comment: @Tristan: I saw a YouTube video of a percussionist during a performance of West Side Story, and the two Timpani were used for a lot more than two pitches.
Comment: @supercat Indeed.  Also not uncommon for pit orchestras, being severely cramped for space, to only have two timpani
Comment: @jpaugh - I played Timpani for about ten years between junior high and college.  Nobody rearranges drums.  You have a set of between two and five drums, and unless you have ancient hand-crank drums, you use a springloaded pedal mechanism to change the pitch. With practice, you can accurately get to a new pitch in a fraction of a second.  Experienced timpanists have no issue playing scales around the drums.
Comment: As a reference -- here's a sample of a wind ensemble timpani part I played.  For a set of four timpani, I counted six changes on the first page alone. https://www.sheetmusicdirect.com/en-US/se/ID_No/382585/Product.aspx
Comment: The Timpani has a gauge to help with tuning. The instrument doesn't have that precise tuning so there is a little bit more margin of error, and it's not like you need to be in tune with another set of Timpani.
Answer: In "The Rite of Spring" Stravinsky requires the celli to detune their A-strings to G-sharp for the final chord of the piece (and asks them to play a four-note chord "non arpeggiato"!):

Similarly at the end of Jörg Widmann's Viola Concerto the soloist has to detune the C-string over several measures:
Comment: @leftaroundabout I just looked at a couple of videos on YouTube (LA Phil, LSO). None of the cellists touched their tuning pegs :)
Comment: This excerpt is one of my favorite bits of musical trivia! Think about what's happening dramatically at the very end of this piece, and then spell out the bass notes from bottom to top.
Comment: I wonder what fraction of performances actually obey that instruction, instead of simply omitting one of the D's and playing the G♯ on the D string. Possibly divisi-split, so some play only the high D, some the low one. (Which would also enable actually playing "non arpeggiato"!)
Comment: You can't reliably down tune a string instrument like that. In string instruments, you always tune lower then tune back up to release any hidden tension caught in the groves. The last thing you want is for the tension to release while playing and then you're just screwed.
Comment: @Nelson That's why the cellists don't seem to follow Stravinsky's instructions (see the previous comments)
Answer: In relation to the violin (or other string instrument) the specific technique described — using the tuning peg to detune and retune a pitch — is called peg scordatura (also peg glissando and glissando scordatura).
A very clear example of this occurs in Alfred Schnittke's Stille Nacht (1978) for violin and piano. At the end of the piece, the violin detunes and retunes the open G string down to D and back to G again, creating an eerie glissando. Note also the very end of the piece, in which the tuning peg is used to create a vibrato/trill effect. The below recording is timed to the peg scordatura.

In the comments below, it's pointed out that for technical reasons, peg scordatura will only be found on the final note of a piece.
Here are some counterexamples:
György Kurtág's Kafka Fragmente (Op. 24) includes peg glissandi: for example, the section from 27:37 – 28:58 in the below recording.

Stavros Choplaros's "Sonata da Chiesa" (2015) uses peg scordatura throughout. The below images are just two examples from the score, which is included in his doctoral dissertation from King's College (PDF pages 139–150).

In Karl Gerber's "Three Formulae on One String", a computer-controlled violin employs peg scordatura. In the below Vimeo recording, the technique is first used beginning at 1:14.
Gerber, "Three Formulae on One String"
Comment: It's maybe worth adding that you're only going to see this on the very last note of a piece.  Without geared tuners or tuning levers like a harp has, it's impossible to change tuning accurately - friction pegs simply don't allow it, and the fine-tuners on a violin bridge can't be changed fast enough.  Even with geared tuners on a guitar, it's hard to do.  Violins do exist with geared tuners, but they're rare and are usually custom-made.
Comment: @Graham I think that's over-broad. For example, in "[Evolution and Notation of Glissando in String Music](https://www.jstor.org/stable/pdf/24045922.pdf)", John L. Snyder points to an example in Ligeti's _Apparitions_ that is mid-piece. (Listening to a recording, it's clearly not at the end, but I can't find for certain where it does occur.)
Comment: Everyone's examples were great but this is closest to what I was thinking of. Using peg scordatura as an eerie vibrato was just too cool. It would have been better if it happened mid-piece but oh well.
Comment: link is dead/unavailable.
Comment: @Graham FYI, I added some examples of peg scordatura occurring in the middle of the pieces.
Comment: @Aaron Thanks - interesting! I guess I've overstated the case at "impossible" when it should just say "seriously difficult". :) That said, I'd be worried about tuning stability for the rest of the piece with friction pegs. A modified instrument with guitar tuners instead of friction pegs (or motorized as per your last example) would make that more reliable. Although *that* said, if the tuning is only a little out and is stable then you certainly can accommodate that with your fingers.
Answer: The existing answers are all good - to add something else to the mix though:
For a particularly extreme example, Michael Manring the experimental bass guitarist enjoyed the expressive possibilities of retuning mid performance so much that he had an instrument purpose built to allow him to retune quickly on the fly.
This eventually has extended to whole pieces built around dynamic retuning while using natural harmonics, as heard here:

Arguably at this point that barely even counts as "retuning", it's just become another expressive capacity of the instrument.  Still, I thought it would be relevant to the discussion for an example of pushing this idea of dynamic retuning to the limit.
He talks a bit about the progression to arriving at this point here
Comment: See also g-bender modification of a guitar: https://www.youtube.com/watch?v=4OKZQSAIiyc
Comment: Oh, I see that the question was tagged "violin", sorry, I only read the title and text not the tags. If question was intended to refer only to violin pieces then my apologies.
Comment: For those who don't want to watch the entire second video, the Zon Hyperbass includes [Hipshot Bass Xtenders](https://hipshotproducts.com/collections/bass-xtenders), which serve the same function as the banjo cam tuners mentioned in another answer.  It also has a special bridge designed for easy retuning of the entire instrument at once.
Answer: Banjo is commonly played in several different tunings.
Some banjos are fitted with cam tuners (known as D tuners, Scruggs tuners or Keith tuners) which facilitate fast, accurate retuning between two fixed notes, and which are also used to good effect during playing.
Here's an except from https://en.wikipedia.org/wiki/Beacon_Banjo_Company explaining the history of their invention.

Their inspiration for going into the banjo business was Earl Scruggs' creation of homemade cam tuners, which he developed after recording "Earl's Breakdown" in 1951. Scruggs had sought to refine the way he played this tune by finding a way to re-tune more accurately during the piece. Keith was inspired by the four banjo tunes ("Earl's Breakdown", "Foggy Mountain Chimes", "Flint Hill Special", and "Randy Lynn Rag") on the 1957 Flatt and Scruggs album Foggy Mountain Jamboree, which all used Scruggs's cam tuning machines

A couple of examples of other songs where players use this technique.

Perhaps a banjo player can weigh in on this. I'm no expert (I'm a guitarist) but I note that the sound is similar to slide guitar, and both instruments are fretted, picked and played in American (country, bluegrass) folk music.
Comment: They also make D-tuners for guitar, to allow a guitarist to quickly switch between E standard and drop D tuning.
Comment: @dissemin8or they do make them for guitar (usually fitted on the 6th string for low E/D as you say)  but they're not common and I'm not aware of them being used while playing. With banjo they're usually on the 2nd and 3rd strings and it's a common thing to use them to bend notes while playing as in the videos I linked. I played a banjo once, tried to bend it in the way I would a guitar (by pushing the string sideways across the fretboard) and it didn't work out that well. Maybe that's why they bend with the tuners.
Answer: Unless I am mistaken, no one has mentioned the Schumann Piano Quartet where the cellist is asked to tune the C string down to a Bb at the end of the slow movement, in order to hold a long pedal point.
Answer: There's a song in the musical Batboy that does this. I'm forgetting a lot of the details (esp. the name of the song), but I think it was done to shift the range of the vocal melody and/or as a phrase modulation for musical interest. It just coincidentally inconvenienced the guitar player. Most of the song could be played in standard tuning except for the middle section that needed a low Eb from the guitar.
Answer: Not exactly "retuning," but lots of orchestral music has the clarinets swap between the Bb and A axe.
If one is playing all the Bach unaccompanied cello suites, one must detune for the 5th suite (A-string tuned down to G). That doesn't really count as "mid-piece."
Now, do you count using a capo on the guitar family?   Or changing settings on an autoharp?
Comment: @Aaron I plead guilty to being a cellist and not thinking there's any other set of suites by Bach :-(
Comment: I forgive you. :-)
Comment: The Bach Cello Suite #5 is the one you're thinking of.
Answer: Somewhere there's Haydn symphony where the violins are asked to retune the G string to (I think) F and then play the open string while tuning it back up to G. But I can't remember which one and I don't have the scores or time to search IMSLP.
Walton in 'Facade' asks the cello to retune the C string to B, and then notates it as a transposing instrument. I once heard a performance where the player didn't realise that and played all the C string notes a semitone sharp - not a success. That's not exactly during a piece as it's for one of the movements only so it's more like scordatura.
Comment: This is Haydn's Symphony 60 in C ("Il distratto"), and the tuning-business happens near the start of the finale, which is the 6th (!) movement.
Answer: I'm surprised no one has mentioned Nigel Tufnel's performance where he retuned the violin he was using to play his guitar with.
It's quite clear from the video that the solo really wouldn't have been the same without the retune.
Comment: What amuses me to this day is that Marshall amps since that movie do actually have an 11 on the dial, in tribute.
Comment: @Aaron Nigel Tufnel is the guitarist in the mockumentary "This is Spinal Tap" about the (fictional) metal band of the same name. Nigel is perhaps best known for being proud of his amplifier's volume control, which goes all the way up to 11 (which makes it really loud, apparently.)
Comment: Could you post a video link, or maybe an article describing the performance? Speaking for myself at least, I'm not familiar with Nigel Tufnel or his retuning bit.
Comment: Duh! Of course I know Nigel Tufnel. Oy. Anyway, I suggest you fill out your answer a bit; otherwise, i reads more like a comment. (And who wouldn't enjoy watching that scene again?)
Answer: I'm not aware of classical music pieces that require some occasional retuning, but if they exist I suspect they are written specifically for a particular virtuoso performer who can pull it off reliably every time.
On the other hand, some virtuoso performers do exist, who among other things take advantage of the possibilities offered by the instrument's tuning machines. One example is this:

A similarly gifted guitarist, Luca Stricagnoli, occasionally does something like that, but I couldn't promptly find an example.
And while this isn't strictly an answer to your question, but to give an idea of what some people can do, I once saw Vishwa Mohan Bhatt change a broken string in the middle of a long improvisation and then tune it up as needed, and throughout this process not a single bad note was heard... in fact, if I had not been watching him, just by listening I could have thought that the improvisation just changed to a slow mood for a minute before going back to normal.
Bottom line, retuning while playing can be a thing, but only for the top of the top of players.
Comment: I recommend reading some of the other answers, which are explicit in naming pieces/composers who use detuning/retuning in their pieces, many of which are considered standard repertoire.
Comment: Jon Gomm's song Passionflower combines a similar technique with guitar harmonics, which produces quite an unusual sound where the very clear harmonic "bends" up and down, something that it normally can't really do.


Mudar o Tamanho da caixa do InputQuery

Question: O InputQuery é uma mensagem onde podemos informar um determinado valor, mas alterando o valor da variável passada como referencia, veja sua estrutura :
//Função InputQuery
function InputQuery(const ACaption, APrompt: string;
  var Value: string): Boolean;

Queria saber se tem alguma maneira de diminuir o tamanho da janela da mensagem do InputQuery?
Answer: Esta função não possui um overload que disponibilize isto, o jeito é fazer uma.
Tenho diversas prontas em meu sistema para diversos formatos, seja, String, Extended, Integer, Datas etc...
Segue exemplo:
function TFormTeste.InputValor(const aCaption: String; var aValor: String): Boolean;
var
  vForm  : TForm;
  vLabel : TLabel;
  vBtnOk : TBitBtn;
  vValor : TEdit;
begin
  Result  := False;
  vForm   := TForm.Create(Application);
  vLabel  := TLabel.Create(vForm);
  vBtnOk  := TBitBtn.Create(vForm);
  vValor  := TEdit.Create(vForm);

  with vForm do
  begin
    Name           := 'FormValor';
    Position       := poScreenCenter;
    BorderIcons    := [biSystemMenu];
    BorderStyle    := bsSingle;
    Caption        := aCaption;
    ClientHeight   := 70;
    ClientWidth    := 180;
    Color          := clBtnFace;
    OldCreateOrder := False;
    PixelsPerInch  := 96;
  end;

  with vLabel do
  begin
    Name    := 'vLabel';
    Parent  := vForm;
    Left    := 8;
    Top     := 16;
    Width   := 31;
    Height  := 13;
    Caption := 'Valor: ';
  end;

  with vValor do
  begin
    Name      := 'vValorEdit';
    Parent    := vForm;
    Left      := 52;
    Top       := 11;
    Width     := 120;
    Height    := 21;
    TabOrder  := 0;
  end;

  with vBtnOk do
  begin
    Name        := 'vBtnOk';
    Parent      := vForm;
    Caption     := 'Ok';
    Left        := vValor.Left;
    Top         := vValor.Top + vValor.Height + 5;
    Width       := vValor.Width;
    Height      := 21;
    ModalResult := mrOk;
  end;

  vForm.ShowModal;

  if(vForm.ModalResult = mrOk) and
    (vValor.Text <> '') then
  begin
    Result := True;
    aValor := vValor.Text;
  end;

  FreeAndNil(vForm);
end;

Utilização da mesma forma que a Oficial:
var
  vTeste : String;
begin
  if (InputValor('Informe um texto', vTeste) = True) then
    ShowMessage(vTeste);

Comment: Opa ! isso é bom... vou testar...
Comment: Se colocar outro botão ex: Cancelar como faz para se clicar cancelar tudo?
Comment: Crie um botão = fiz com o OK, e no `ModalResult := mrCancel`, ai você testa no momento de atribuir a variável se o ModalResult foi um Ok
Comment: ta ficando bom to ajeitando para ficar do tamanho que quero. Obrigado!
Comment: Resolvendo o problema, marque a resposta como correta, isso ajuda aos futuros pesquisadores.
Comment: fiz isso só que ele está funcionando igual ao OK
Comment: Acho que é por conta do ` if (vValor.Text <> '') then
  begin
    Result := True;
    aValor := vValor.Text;
  end;`
Comment: antes do `if (vValor.Text <> '')` coloque: `if ModalResult = MrOk then...`
Comment: não vai,  o ModalResult  fica sempre   = 0
Comment: Editei a resposta, é que você não estava apontando para o `Form`, ai o Result sempre é 0.
Comment: Valeu! Ficou muito bom

Mudar o Tamanho da caixa do InputQuery


Adding html attributes for block

Question: I want to add HTML attributes for my block by using hook_block_view_alter. Any suggestions/code snippets for this?
Comment: exactly what do you want to do? add HTML markup and attributes to block content ot  to Block itself?
Answer: If you need for D7, Block Attributes module or if you just need class Block Class
Answer: Instead use Markup module. it easily integrates with the form. I am guessing u use D7...

This module adds the ability for site admins to add "Markup" widgets
  to the form. These essentially let designers of cck content-types
  insert additional markup into the node/edit form to display to
  content-authors. This is the equivalent of adding additional elements
  to $form of the type '#markup'.
The module does not add anything to the $node object for the content
  being created, and utilizes form_alter to remove unnecessary fields
  from the '_content_admin_field' form when this widget is being
  created.
Comment: @No Sssweat Then how do u plan doing it...??? The question is quite unclear....
Comment: It wasn't me who voted you down, I'll prove it by voting you up. I agree, the question is a bit broad, so this could be an option.
Comment: @NoSssweat No problem... man... i checked it... actually you were also right....the question was quite unclear so i directly wrote the module name...

Adding html attributes for block


find the values a, b for the next series to converge and for the series to diverge

Question: Determine for what values of a and b the series: $$\sum_{n=1}^\infty \frac{(ln(n))^b}{n^a}$$
a) converge
b) diverge
Comment: The question is without context; typically on this site we ask for at least your thoughts on the problem, as well as the source of the problem, your background, and any other information that might be useful. I've left a brief sketch of a solution to accompany a very brief question. Feel free to update the question or leave comments if there's places you are stuck.
Answer: Brief sketch: $b$ is irrelevant, $a > 1$ is necessary trivially since otherwise you have divergence by comparison to $p$-series. This is also sufficient:
$$\frac{\ln(n)^b}{n^{1+\epsilon}} = \bigg(\frac{\ln(n)}{n^{\epsilon/2b}} \bigg)^b \ \frac{1}{n^{1+ \epsilon/2}}$$
and we know that $\ln$ loses to any power, so the first term's contribution is negligible, and the second is summable.
Comment: No, $b$ is not irrelevant and $a>1$ is not necessary if we start the summation at $n=2.$ For example,

$$\sum_{n=2}^{\infty}\frac{(\ln n)^b}{n}<\infty$$

if $b<-1.$


Problem adding "Network Policy and Access Services" role in Server 2008

Question: We are encountering an Error Code 0x80070643 when attempting to add the "Network Policy and Access Services" role on a fresh Windows Server 2008 R2 installation. Is there a known solution for this problem? Here is what information we have available so far:
From ServerManager.log...
2504: 2009-11-23 11:12:01.712 [CBS]                       installing 'IAS NT Service RasServerAll RasRoutingProtocols ' ...
2504: 2009-11-23 11:12:01.911 [CBS]                       ...parents that will be auto-installed: 'RasServer '
2504: 2009-11-23 11:12:01.912 [CBS]                       ...default children to turn-off: '<none>'
2504: 2009-11-23 11:12:01.924 [CBS]                       ...current state of 'IAS NT Service': p: Staged, a: Staged, s: UninstallRequested
2504: 2009-11-23 11:12:01.924 [CBS]                       ...setting state of 'IAS NT Service' to 'InstallRequested'
2504: 2009-11-23 11:12:01.935 [CBS]                       ...current state of 'RasServerAll': p: Staged, a: Staged, s: UninstallRequested
2504: 2009-11-23 11:12:01.935 [CBS]                       ...setting state of 'RasServerAll' to 'InstallRequested'
2504: 2009-11-23 11:12:01.946 [CBS]                       ...current state of 'RasRoutingProtocols': p: Staged, a: Staged, s: UninstallRequested
2504: 2009-11-23 11:12:01.946 [CBS]                       ...setting state of 'RasRoutingProtocols' to 'InstallRequested'
2504: 2009-11-23 11:12:01.956 [CBS]                       ...current state of 'RasServer': p: Staged, a: Staged, s: UninstallRequested
2504: 2009-11-23 11:12:01.956 [CBS]                       ...setting state of 'RasServer' to 'InstallRequested'
2504: 2009-11-23 11:12:01.967 [CBS]                       ...'IAS NT Service' : applicability: Applicable
2504: 2009-11-23 11:12:01.977 [CBS]                       ...'RasServerAll' : applicability: Applicable
2504: 2009-11-23 11:12:01.987 [CBS]                       ...'RasRoutingProtocols' : applicability: Applicable
2504: 2009-11-23 11:12:01.998 [CBS]                       ...'RasServer' : applicability: Applicable
2504: 2009-11-23 11:12:02.906 [CbsUIHandler]              Initiate:
2504: 2009-11-23 11:12:02.906 [InstallationProgressPage]  Installing...
2504: 2009-11-23 11:12:54.311 [CbsUIHandler]              Error: -2147023293 :
2504: 2009-11-23 11:12:54.313 [CbsUIHandler]              Terminate:
2504: 2009-11-23 11:12:54.316 [InstallationProgressPage]  Verifying installation...
2504: 2009-11-23 11:12:54.326 [CBS]                       ...done installing 'IAS NT Service RasServerAll RasRoutingProtocols '. Status: -2147023293 (80070643)
2504: 2009-11-23 11:12:54.329 [NPAS]                      Skipped configuration of 'Network Policy Server' because install operation failed.
2504: 2009-11-23 11:12:54.330 [NPAS]                      Skipped configuration of 'Remote Access Service' because install operation failed.
2504: 2009-11-23 11:12:54.330 [NPAS]                      Skipped configuration of 'Routing' because install operation failed.
2504: 2009-11-23 11:12:54.330 [Provider]
[STAT] ---- CBS Session Consolidation -----
[STAT] For
          'Network Policy Server',
          'Remote Access Service',
          'Routing'[STAT] installation(s) took '52.616957' second(s) total.
[STAT] Configuration(s) took '0.0004948' second(s) total.
[STAT] Total time: '52.6174518' second(s).

From System Event Viewer...
Log Name:      System
Source:        Service Control Manager
Date:          23/11/2009 11:12:23
Event ID:      7023
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      Av7Analytics
Description:
The Network Policy Server service terminated with the following error:
%%-2147013892
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Service Control Manager" Guid="{555908d1-a6d7-4695-8e1e-26931d2012f4}" EventSourceName="Service Control Manager" />
    <EventID Qualifiers="49152">7023</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8080000000000000</Keywords>
    <TimeCreated SystemTime="2009-11-23T11:12:23.653578500Z" />
    <EventRecordID>1317</EventRecordID>
    <Correlation />
    <Execution ProcessID="468" ThreadID="2308" />
    <Channel>System</Channel>
    <Computer>Av7Analytics</Computer>
    <Security />
  </System>
  <EventData>
    <Data Name="param1">Network Policy Server</Data>
    <Data Name="param2">%%-2147013892</Data>
  </EventData>
</Event>

From Setup Event Viewer...
Log Name:      Setup
Source:        Microsoft-Windows-ServerManager
Date:          23/11/2009 11:12:56
Event ID:      1616
Task Category: None
Level:         Error
Keywords:
User:          AV7ANALYTICS\RenamedAdmin
Computer:      Av7Analytics
Description:
Installation failed.

Roles:

Network Policy and Access Services
   Error: Attempt to install Network Policy Server failed with error code 0x80070643.  Fatal error during installation
   Error: Attempt to install Remote Access Service failed with error code 0x80070643.  Fatal error during installation
   Error: Attempt to install Routing failed with error code 0x80070643.  Fatal error during installation
   The following role services were not installed:
   Network Policy Server
   Routing and Remote Access Services
      Remote Access Service
      Routing

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-ServerManager" Guid="{8C474092-13E4-430E-9F06-5B60A529BF38}" />
    <EventID>1616</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x4000000000000000</Keywords>
    <TimeCreated SystemTime="2009-11-23T11:12:56.046431200Z" />
    <EventRecordID>115</EventRecordID>
    <Correlation />
    <Execution ProcessID="2504" ThreadID="2344" />
    <Channel>Setup</Channel>
    <Computer>Av7Analytics</Computer>
    <Security UserID="S-1-5-21-2753803390-1569373846-1208217686-500" />
  </System>
  <UserData>
    <EventXML xmlns:auto-ns3="http://schemas.microsoft.com/win/2004/08/events" xmlns="Event_NS">
      <message>

Roles:

Network Policy and Access Services
   Error: Attempt to install Network Policy Server failed with error code 0x80070643.  Fatal error during installation
   Error: Attempt to install Remote Access Service failed with error code 0x80070643.  Fatal error during installation
   Error: Attempt to install Routing failed with error code 0x80070643.  Fatal error during installation
   The following role services were not installed:
   Network Policy Server
   Routing and Remote Access Services
      Remote Access Service
      Routing

</message>
      <identifiers>14, 206, 207, 208, 205</identifiers>
    </EventXML>
  </UserData>

Thanks in advance for any help.
It's quite shocking that we're already having problems with Microsoft's "latest and greatest".
Update:
I have no idea what caused this error, but it eventually went away. I think it was when I installed other roles first (maybe Application, can't quite remember). It's certainly a weird bug! But I do have NPAS installed on my 2008 machines now, so it worked in the end. Sorry that's not anymore help :( –
Answer: Fixed!
I have no idea what caused this error, but it eventually went away. I think it was when I installed other roles first (maybe Application, can't quite remember). It's certainly a weird bug! But I do have NPAS installed on my 2008 machines now, so it worked in the end.
Sorry that's not anymore help :(


How to check if a library is present during installation?

Question: How can I check if the library, which is required by my module, is present while the module is getting installed?
I have used hook_requirements with the libraries_detect function with REQUIREMENT_ERROR severity. This restricts the module from getting installed irrespective of the library is present of not.
Here is my code:

function hook_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if ($phase == 'install') {
    if (function_exists("libraries_detect") && !libraries_detect('external-lib-api')) {
      $requirements['library_api'] = array(
        'severity' => REQUIREMENT_ERROR,
        'description' => $t(
          'The required Libarary is not installed.'
        )
      );
    }
  }

  return $requirements;
}

Am I doing something wrong in this? Is there any other way of doing it?
Answer: this is one of the working example from my module. I hope this helps you
function sfs_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if ($phase == 'install' && function_exists('libraries_get_path')) {
     $plupload_path = libraries_get_path('plupload');
     $chosen_path = libraries_get_path('chosen');
     if (!$plupload_path) {
       $requirements['plupload'] = array(
         'severity' => REQUIREMENT_ERROR,
         'description' => $t('Secure File Share module requires !plupload, which is missing. Download and extract the entire contents of the archive into the %path directory on your server.',  array('!plupload' => l($t('Plupload Library'), 'https://github.com/moxiecode/plupload/archive/v1.5.8.zip'), '%path' => 'sites/all/libraries/plupload')),
       );
     }
     if (!$chosen_path) {
        $requirements['chosen_js'] = array(
          'severity' => REQUIREMENT_ERROR,
          'description' => $t('Secure File Share module requires !chosen, which is missing. Download and extract the entire contents of the archive into the %path directory on your server.', array('!chosen' => l($t('Chosen Library'), 'https://github.com/harvesthq/chosen/releases/download/v1.3.0/chosen_v1.3.0.zip'), '%path' => 'sites/all/libraries/chosen')),
        );
      }
  }
  return $requirements;
}

Karthik
Answer: You should change
hook_requirements($phase)

into this
 Name_of_your_module_requirements($phase)

"library_api" is not a Library is a module https://www.drupal.org/project/libraries
for create a module dependency you can add a line into your module .info file like this :
dependencies[] = libraries

Answer: You may want to look at how module Forena is handling this, around line 429
of forena.module:
function forena_library_file($library) {
  $libraries = array(
      'dataTables' => 'dataTables/media/js/jquery.dataTables.min.js',
      'mpdf' => 'mpdf/mpdf.php',
      'SVGGraph' => 'SVGGraph/SVGGraph.php',
      'prince' => 'prince/prince.php'
  );
  $path = isset($libraries[$library]) && file_exists('sites/all/libraries/' . $libraries[$library]) ? 'sites/all/libraries/' . $libraries[$library] : '';
  return $path;
}

FYI: Forena interfaces with up to 4 libraries, which is why you'll 4 such entries around there.


How do we conclude that a statistic is sufficient but not minimal sufficient?

Question: I want to show that the statistic $\left(\sum_{i = 1}^n Y_i, \sum_{i = 1}^n Y_i^2 \right)$ is sufficient for $\mu$ but not minimal sufficient where $(Y_1, \dots, Y_n)$ is a random sample from $N(\mu, \mu)$ for $\mu > 0$.
I have already shown that the statistic $\sum_{i = 1}^n Y_i^2$ is minimal sufficient for $\mu$ where $(Y_1, \dots, Y_n)$ is a random sample from $N(\mu, \mu)$ for $\mu > 0$.
I began by calculating the joint density for $N(\mu, \sigma^2)$:
$$L(\mu, \sigma; \mathbf{y}) = \dfrac{1}{(2 \pi \sigma^2)^{n/2}} \exp{\left\{ -\dfrac{1}{2 \sigma^2} \sum_{i = 1}^n (y_i - \mu)^2 \right\}}$$
Switching to $N(\mu, \mu)$, I calculated the likelihood ratio to be
$$\dfrac{L(\mu; \mathbf{y_1})}{L(\mu; \mathbf{y_2})} = \exp{\left\{ \dfrac{1}{2 \mu} \left( \sum_{i = 1}^n y_{2i}^2 - \sum_{i = 1}^n y_{1i}^2 \right) + \left( \sum_{i = 1}^n y_{1i} - \sum_{i = 1}^n y_{2i} \right) \right\}}$$
This likelihood ratio does not depend on the parameter $\mu$ when $\sum_{i = 1}^n y_{2i}^2 = \sum_{i = 1}^n y_{1i}^2$:
$$\exp{\left\{ \dfrac{1}{2 \mu} \left( \sum_{i = 1}^n y_{2i}^2 - \sum_{i = 1}^n y_{1i}^2 \right) + \left( \sum_{i = 1}^n y_{1i} - \sum_{i = 1}^n y_{2i} \right) \right\}} = \exp{\left\{ \left( \sum_{i = 1}^n y_{1i} - \sum_{i = 1}^n y_{2i} \right) \right\}}$$
So, assuming I am understanding this correctly, if $\sum_{i = 1}^n Y_i^2$ was the only test statistic, then we could say that it is minimal sufficient.
Now, to account for $\sum_{i = 1}^n Y_i$, if we use $\sum_{i = 1}^n y_{2i} = \sum_{i = 1}^n y_{1i}$, then we get
$$\exp{\left\{ 0 \right\}} = 1$$
So, clearly, nothing changed between our calculations for the test statistic $\sum_{i = 1}^n Y_i^2$ and our calculation for the test statistic $\left(\sum_{i = 1}^n Y_i, \sum_{i = 1}^n Y_i^2 \right)$ – the likelihood ratio does not depend on the parameter $\mu$. What exactly are we supposed to do to show that $\left(\sum_{i = 1}^n Y_i, \sum_{i = 1}^n Y_i^2 \right)$ is sufficient but not minimal sufficient? What exactly is the argument that we're supposed to present?

I want to use the Fisher–Neyman factorization theorem, of the form $L(\mu; \mathbf{y}) = g(T(\mathbf{y}), \mu) \times h(\mathbf{y})$, to factor $\exp{\left\{ \dfrac{1}{2 \mu} \left( \sum_{i = 1}^n y_{2i}^2 - \sum_{i = 1}^n y_{1i}^2 \right) + \left( \sum_{i = 1}^n y_{1i} - \sum_{i = 1}^n y_{2i} \right) \right\}}$ and show that the statistic $\left(\sum_{i = 1}^n Y_i, \sum_{i = 1}^n Y_i^2 \right)$ is sufficient for $\mu$. So we immediately know that we have $T(\mathbf{Y}) = \left(\sum_{i = 1}^n Y_i, \sum_{i = 1}^n Y_i^2 \right)$. And since $\dfrac{1}{2 \mu} \left( \sum_{i = 1}^n y_{2i}^2 - \sum_{i = 1}^n y_{1i}^2 \right)$ has the parameter $\mu$, and $\left( \sum_{i = 1}^n y_{1i} - \sum_{i = 1}^n y_{2i} \right)$ has the data for $\sum_{i = 1}^n Y_i$, I would say that we require $g(T(\mathbf{y}), \mu) = \dfrac{1}{2 \mu} \left( \sum_{i = 1}^n y_{2i}^2 - \sum_{i = 1}^n y_{1i}^2 \right) + \left( \sum_{i = 1}^n y_{1i} - \sum_{i = 1}^n y_{2i} \right)$, and so we require that $h(\mathbf{y}) = 1$. This way, we get the Fisher-Neyman factorization
$$L(\mu; \mathbf{y}) = \left( \dfrac{1}{2 \mu} \left( \sum_{i = 1}^n y_{2i}^2 - \sum_{i = 1}^n y_{1i}^2 \right) + \left( \sum_{i = 1}^n y_{1i} - \sum_{i = 1}^n y_{2i} \right) \right) \times 1 = \left( \dfrac{1}{2 \mu} \left( \sum_{i = 1}^n y_{2i}^2 - \sum_{i = 1}^n y_{1i}^2 \right) + \left( \sum_{i = 1}^n y_{1i} - \sum_{i = 1}^n y_{2i} \right) \right)$$
And so this shows that $\left(\sum_{i = 1}^n Y_i, \sum_{i = 1}^n Y_i^2 \right)$ is a sufficient statistic.
Comment: The result is immediate from the definition of a minimal sufficient statistic: the second statistic is an (obvious) function of the latter but not *vice versa.*
Comment: @ThePointer. Yes all clear - I will put a formal definition in the answers of what whuber is saying from the notes I use. Perhaps that may clarify things.
Comment: Please may you clarify what it is you are conveying when you opt to represent the mean and variance parameter of the Gaussian $N(\mu, \sigma^2)$ with the single parameter $\mu$ in "$N(\mu, \mu)$"? Are you implying that they are equal? Or is it the case that one of the $\mu$ and $\sigma^2$ is known and the other known? In particular I am confused by the problem setup in the first line "I want to show...is sufficient for $\mu$ but not minimal sufficient...from $N(\mu, \mu)$ for $\mu > 0$.
Comment: @microhaus I just used the $N(\mu, \sigma^2)$ random variables to more easily compute the joint distribution, since this is the conventional parameterisation. I then switched it to $N(\mu, \mu)$, which, I think, is just unknown mean and variance, but *both* mean and variance are equal to the unknown $\mu$ parameter. See this question https://stats.stackexchange.com/q/484819/163242 That user seems to be doing the same distribution, but their goal is different. In the beginning, they thought that the sufficient minimal statistic was $\{\sum x_i^2 , \sum x_i\}$, but then they realised [...]
Comment: [...] that it was $\sum x_i^2$. The difference is that I'm trying to show that the statistic $\{\sum x_i^2 , \sum x_i\}$ ($\left(\sum_{i = 1}^n Y_i, \sum_{i = 1}^n Y_i^2 \right)$ in my notation) is sufficient but not minimal. So it seems that we're using the same distribution (that user calls theirs $N(\theta, \theta)$) but have different goals.
Comment: @microhaus Is that clear, or would you like further clarification?
Comment: Your first two lines fully answer your question.
Comment: @whuber Hmm, how so?
Comment: @whuber You mean $\sum_{i = 1}^n Y_i$ is the square root of $\sum_{i = 1}^n Y_i^2$ (since the other way around would be squaring, and squaring is not a function)?
Comment: @microhaus With regards to the definition, my textbook uses some terrible "equivalence class" terminology, so I wasn't able to understand it well. Are you referring to 1. and 2. here https://en.wikipedia.org/wiki/Sufficient_statistic#Minimal_sufficiency ? It seems that the function part refers to 2. On the other hand, 1. requires that $\sum_{i = 1}^n Y_i$ be a sufficient statistic, which we don't know either (unless there's something else I'm missing?).
Comment: No, I mean that your first statistic is of the form $(t,s)$ ($s$ is the sum of squares) and the second is $s,$ which is a function of $(t,s).$ (It's the *canonical projection* onto the second coordinate, which is part of the definition of the ordered pair.) It is immediate that $(t,s)$ cannot be minimal sufficient, no matter what.
Answer: Proof strategy.

Show that $T = \sum Y^2_i$ is minimal sufficient.

Show that $U = (\sum Y_i, \sum Y^2_i)$ is sufficient.

Use the following theorem to show that $T = g(U)$ for some function $g$.

Show that you cannot find a function $h$ such that $U = h(T)$.

In order to supplement what @whuber is saying formally, here is a definition from Wasserman's All of Statistics:

Definition 9.3.5
A statistic $T$ is minimal sufficient if (i) it is sufficient, and (ii) it is a function of every other sufficient statistic.

In symbols, a statistic $T$ is minimal sufficient if it is the case that both:

$T$ is sufficient.
If $U$ is any other sufficient statistic, then $T = g(U)$ for some function $g$.

Once you have shown that $T$ is minimal sufficient and $U$ is sufficient, notice that if you define a scalar function $g : \mathbb{R}^2 \rightarrow \mathbb{R}$ that is the dot product between the row vector $(0, 1)$ and column vector $U \in \mathbb{R}^2$ like so:
$$g(U) = (0, 1) \cdot U$$
then $T = \sum_i Y^2_i = (0, 1) \cdot (\sum_i Y_i, \sum Y^2_i)^T = g(U)$.
In words, this function $g$ bins the redundant component (from the perspective of minimal sufficiency) of $U$ containing $\sum_i Y_i$.
How can we interpret this? You have already shown that $T$ is minimal sufficient in step 1. So this is not supplying any additional information on the minimal sufficiency of $T$.What this reveals however is an interpretation concerning minimal sufficiency as opposed to sufficiency.
Now $T$ and $U$ are similar in that both are sufficient. Informally, a sufficient statistic $S$ means that after computing $S = S(y_1,... y_n)$ to yield $S$, we can throw away the observations of the data set $Y_1 = y_1, \dots, Y_n = y_n$, and with the retention of the sufficient statistic $S$ alone, still be able to compute the likelihood function $L(\mu; y_1, \dots, y_n)$. As we have thrown the data away, we can no longer compute $L(\mu; y_1, \dots, y_n)$ directly, but can do so indirectly using $L(\mu; S)$.
So clearly, as both $T$ and $U$ are sufficient, we can use either to compute the likelihood function after having thrown away the data $y_1, \dots, y_n$, that is, we can compute $L(\mu; T)$ or $L(\mu; U)$. Imagine if we now ask, can we find a sufficient statistic that achieves the greatest possible reduction of the data and yet still allows us to compute the likelihood function? You can think of this as finding the most compressed summary of the data, with "minimal redudancy", in the sense that it contains just enough information to compute the likelihood function, and no more. This is an informal characterisation of minimal sufficiency.
Notice that the only difference between $T$ and $U$ is that $U$ contains an extra component containing $\sum_i Y_i$. From the perspective of minimal sufficiency, this additional component in $U$ is redundant, we can throw this component away and can still compute the likelihood function using $L(\mu; T)$. Hence $T$ achieves a more "compressed summary" of the data than $U$, but no so much that we cannot compute the likelihood function.
Now, is it possible to find a similar function $h$ such that $U = h(T)$? Notice if you give me $T = (\sum Y^2_i)$ and ask me to apply a function $h$ to this that gives me $U = (\sum Y_i, \sum Y_i^2)$, no such function $h$ exists. In particular, given only a statistic $T$ that is the sum of the squared observations, I cannot recover the sum of observations $\sum_i Y_i$. I therefore cannot recover the 1st component of $U$, and therefore I cannot recover $U$. Hence no function $h$ exists such that $U = h(T)$.
Now as we have established $U$ is sufficient, and because $T$ is also sufficient (being minimal sufficient), but we cannot find a function $h$ such that $U = h(T)$, we can conclude that $U$ is sufficient but not minimal sufficient.

Further comments.

Your current proof of step 1. to show $T = \sum Y^2_i$ is minimal sufficient is missing a small formality. You also need to acknowledge the reverse implication (even if it's by inspection) that

$$T(Y_{11},..., Y_{1n}) = T(Y_{21}, ..., Y_{2n}) \implies L(\mu; \mathbf{y_1}) / L(\mu; \mathbf{y}_2) = c$$

Use the factorisation theorem to show $U$ is sufficient.
Comment: @ThePointer. Have edited to address your comments, and to show explicitly what it means to find a function $g$ such that $T = g(U)$, and how this relates to binning redundant parts of the sufficient statistic to get the minimal sufficient statistic.
Comment: Small error - you need to apply factorisation theorem on $L(\mu; \mathbf{y})$. If I am correctly ascertaining that you've erroneously applied this to the ratio $L(\mu; \mathbf{y}_1) / L(\mu; \mathbf{y}_2)$, then this will need to be corrected. Note that the test for minimal sufficiency (via likelihood ratio) and sufficiency (via factorisation theorem) are distinct tests that shouldn't be confused.
Comment: No sweat. It helps me too, as I am also studying this material.
Comment: Thanks for the answer! How do we go from 1. to 2.? That is, how do we show that $U = (\sum Y_i, \sum Y^2_i)$ is sufficient?
Comment: Thanks again! I have edited my main post with my attempt at using the Fisher–Neyman factorization theorem. Is that correct?
Comment: Ahh, yes, you're right. Thank you for taking the time to explain all of this!


Prove $f'(1)\ge 0$ when $f$ holomorphic in $B(0,1)\cup \left\{ 1 \right\}$ and $f(1)=1$

Question:
Let $f$ be a function holomorphic in $B(0,1)\cup \left\{ 1 \right\}$ with
  $$f(B(0,1))\subset B(0,1),\ \ f(1)=1$$
  Prove that $f'(1)\ge 0$.

My attempt: I have tried to find some property of $f$ when $f'(1)\neq 0$, and guessed if I can prove $\operatorname{arg}f'(1)=0$, but don't know how to proceed specifically. Thanks for any help.
Comment: Have a look at the first part of http://math.stackexchange.com/a/1953895/42969, where it is shown that $f'(1) = u_x(1)$.
Comment: @MartinR one more question: why $\exists r>0$ such that $f$ analytic on $B(0,1)\cup D(1,r)$?
Comment: $f$ being holomorphic at $\left\{ 1 \right\}$ means that it is holomorphic in a small neighbourhood of that point. Holomorphy is only defined on open sets.
Answer: Here is a proof based only on the existence of derivative in the sense that
$$
f'(1) = \lim_{z\to 1,\ z\in B(0,1)}\frac{f(z)-f(1)}{z-1}
$$
exists. For every $\theta \in (-\pi/2,\pi/2)$ the point $1-re^{i\theta}$ lies in $B(0,1)$ when $r>0$ is small enough. By the definition of derivative,
$$
f(1-re^{i\theta}) = 1 - f'(1) re^{i\theta} + o(r),\qquad r\to 0
$$
Since $|f|<1$, the real part of $1 - f'(1) re^{i\theta}$ cannot exceed $1$; this implies $\operatorname{Re}(f'(1) e^{i\theta})\ge 0$. Writing $f'(1)$ in polar coordinates, $f'(1) = \rho e^{it}$, makes it clear that $t=0$, for otherwise $\exp(i(t+\theta))$ has negative real part for some $\theta\in (-\pi/2,\pi/2)$.


How do I display a username on their profile pages?

Question: Using Drupal 8, I simply want a user's profile (or account) page to show its username, like so:
For username "bob":
Username: bob
Do I add a computed field? What's a line of code would I use?
Answer:
Do I add a computed field?

No

What's a line of code would I use?

In your theme's <code>.theme</code> file add:
<code>/**
 * Implements hook_preprocess_HOOK().
 */
function THEMENAME_preprocess_page_title(&$variables) { // your theme might already have this function/hook.
  $user = \Drupal::request()->attributes->get('user');
  if ($user instanceof \Drupal\user\UserInterface) {
    $variables['title'] = t('Username') . ': ' . $user->getAccountName();
  }
}
</code>
Note: Clear/flush the cache for changes to kick in.
Comment: Thanks for the reply! Didn't work though. I'm using Bartik. I copied it under where that first line is.
Comment: @nittyjee I assume you're using Bartik for quick testing purposes. You need to put it in `function bartik_preprocess_page_title(&$variables) {` and don't forget to save the file and flush the cache.
Comment: Yeah, I did all that, I put it below that line and flushed all caches, still not appearing.
Comment: Here's a screenshot:
https://nahc-mapping.org/mappingNY/encyclopedia/temp_delete_anytime/Screenshot_1.jpg
Comment: Still not working :/
Screenshot:
https://nahc-mapping.org/mappingNY/encyclopedia/temp_delete_anytime/Screenshot_2.jpg
Comment: Saved, flushed cache? O_o
Comment: Yes. Saved and flushed :/
Comment: Hello world does appear.
I'll take a look in the next day, there may be something blocking it, I'll see how far I get.
Comment: @nittyjee try it on the actual theme you plan to use. You're not suppose to use Bartik anyways, nor touch anything inside the `/core` folder because you'll lose the changes every time you update core.


How to calculate $ a^b $ where a, b $ \in \mathbb{R} $ for my own RealNumber class in Python?

Question: I'm writing my own RealNumber class in Python to manage the digits after decimal point perfectly without losing any data. I don't want to use Decimal class in Python. But I'm stuck in the pow() function.
I want to calculate $ a^b $, where $ a, b \in\mathbb{R} $. Now, both $ a $ and $ b $ are objects of my RealNumber class. I'm using the $ \frac{P}{Q} $ Rational Number form to perform the power calculation.
I'm taking $ a = \frac{a_P}{a_Q}$, $ b = \frac{b_P}{b_Q} $. So, my calculation is -
$ a^b = \left(\frac{a_P}{a_Q}\right)^\frac{b_P}{b_Q} = \frac{\left(a_P\right)^{\frac{b_P}{b_Q}}}{\left(a_Q\right)^{\frac{b_P}{b_Q}}} = \frac{\sqrt[b_Q]{(a_P)^\left(b_p\right)}}{\sqrt[b_Q]{(a_Q)^\left(b_p\right)}} $.
But, using this, $ (-2) ^ {1.6} $ is giving a Real value, where it's value should be in Complex.
$ (-2)^{1.6} = \left(\frac{-2}{1}\right)^\frac{16}{10} = \frac{\left(-2\right)^{\frac{16}{10}}}{\left(1\right)^{\frac{16}{10}}} = \frac{\sqrt[10]{(-2)^{16}}}{\sqrt[10]{1^{16}}} = \frac{\sqrt[10]{65536}}{1} = \sqrt[10]{65536} =3.0314331330207964 $.
But, the value given by Python itself is $ (0.9367643554147161-2.8830642348724616j) $.
Where I'm making the mistake? Can anyone please help me to figure this out??
Comment: $(-2)^{16/10} \neq \sqrt[10]{(-2)^{16}}$ - in complex numbers, in general $a^{bc} \neq (a^b)^c$.
Comment: Also, the value given is the principal branch.
Comment: Thanks @mihaild and @copper.hat!
Answer: You can't do what you want with non positive numbers
$$\begin{align}
(-2)^{1.6}&= (2e^{i\pi})^{1.6} = 2^{1.6} e^{i\frac{16\pi}{10}} \\
&= 2^{1.6} \cos\left(\frac{16\pi}{10} \right) + 2^{1.6} i\sin\left(\frac{16\pi}{10} \right)\\
&=\text{ the result python gave you.}\end{align}$$
So as expected python was right, and $j$ denotes the $i$ of math.
Comment: Got it, @julio! Thanks!


Do I have a problem in my ring finger?

Question: I play piano, guitar violin and other instruments.
I have a little weakness in my ring finger, especially the left one.
Instrumently-agnostic speaking, to reproduce what I'm talking, place your left hand on the table as if you were holding a tennis ball in it. Raise each finger individually. How high are you able to lift your ring finger?
I'm able to life all my fingers high (all the fingers go up, third finger straight), but the ring finger wont go any higher than 1 inch (I have long fingers). And this disturbs my playing, and I'm sure if I take care of this, my playing will definitely improve.
Any advice?
Comment: Your ring finger and little finger share a tendon, that's why you can't raise it more than an inch whilst your little finger is still on the table.
Answer: I am not an expert in human physiology, but I believe the constraint you describe is completely normal. I think it has something to do with a shared tendon? Needless to say, my hands behave the same way. You should be able to lift the fourth finger higher if you raise the pinky at the same time, yes?
What I do know about human physiology is that each joint has two muscles that contract at different times to actuate the joint in one direction or another. So, an inability to raise the finger alone very far is using a completely different muscle from that which would close the joint, as if to fret a string or press a key.
What technique specifically are you having trouble with, that you feel this physiological constraint is hindering? Chances are you will see this improve with time and continuous practice. The Hanon exercises can be good for basic muscle building.
Comment: Yes, completely normal - in fact, place your hand on the table, fingers spread out, with your middle finger tucked right in under your palm. You'll be able to raise all your other fingers independently, but your ring finger won't budge.
Comment: Thanks. It's just I'm trying to work on finger independence and wanted to make sure I'm not crippled.
Answer: There's no such thing as finger independence(read finger equality most of the time).  All our fingers are different, and they're all connected too!  For instance, would you ever expect any of your fingers to match your thumb in strength?  Or take your index finger and press it to your palm. Your other fingers will move as well.
The key to evenness and equality in your playing is being aware of the differences in your fingers' strengths and movements so that you can balance the sound by adjusting how you move them.
Typically you wouldn't need to lift a finger very high at all.  Just even to clear the string, key, etc. Lifting any higher than that will slow you down and introduce tension.If I move my finger in a range this big:
<------->
I can move it much faster than if I move it in a range this big:
<-------------------->
Comment: I really agree with the explanation about height. I think this is a key to finger speed. Focusing on finger strength not lifting it high.
Answer: Just to clear up on the confusion wrought by the other answers, for the future readers of this question: exercises for finger independence DO exist, and some experienced guitarists actually can move their ring finger much more freely than we mortals.
In fact, I came upon this question while googling for 'ring finger exercises'. I'm sure that the original author has done his research by this time, but as an example, here's a page on some guitar exercises: http://resource.takelessons.com/guitar-exercise-strengthening-the-ring-finger-pinky/
Most probably there also are exercises that are not related to any instrument at all and just let anybody improve finger agility and control.
My friend, who isn't even a professional musician but has played classical guitar (by chords) for many years, can move his ring finger practically as good as any other. He has shown me another pretty impressive test for finger agility: from the closed fist, move your pinky up at the lowest joint while keeping it bent otherwise. Then, keeping all other fingers in place, extend the ring finger and straighten it all the way up. (Alternatively, from the ring and pinky straight, try to bend the pinky without moving the ring finger.) Chances are that a non-musician like me won't be able to do it more than halfway through—and my friend can do it all the way.
Answer: Here's an instructional video showing some pretty great exercise routines for fingers. (Was advised to me by a guitarist very good with his finger control, so I believe the exercises are effective.)
For the record, the name of the video is "Greg Irwin - Finger Control & Fitness".

Do I have a problem in my ring finger?


Finding a matrix for orthogonal reflection

Question: Linear Algebra problem here. I was given the equation of a line and told to find a matrix for it; I found the matrix for orthogonal projection... not reflection.
Here's the problem:
Let W be the line $x = 2t$; $y = -t$; $z = 4t$; $w = -3t$ in $\mathbb{R}^4$. Find the matrix for orthogonal reflection on W in the standard basis.
When finding the projection matrix, I just created a vector out of the equation for the line, normalized it, then multiplied it by itself to produce the $4\times 4$ matrix. This worked, but I don't know a way (if one exists) to convert that matrix into one for reflection instead of projection.
I know that the first column of the matrix is based off the equations for the line, so the first vector is $(2, -1, 4, -3)$. And I know that I use the equations to find the other three vectors for the matrix. Each vector $(x, y, z, w)$ has to be such that:
$2x - y + 4z - 3w = 0$.
But I can't just pick any number and find the other values. How do I use this equation in a way that will produce vectors that form a basis for reflection and not just a projection?
Comment: What's the matrix of a line?
Comment: Think about how reflection in a line relates to projection onto it. What happens to the component of the vector that's orthogonal to the line?
Comment: [Welcome to Math.SE!](https://math.meta.stackexchange.com/a/4928/290189) Please use MathJax.
For some basic information about writing math at this site see e.g. [basic help on mathjax notation](/help/notation),
[mathjax tutorial and quick reference](//math.meta.stackexchange.com/q/5020),
[main meta site math tutorial](//meta.stackexchange.com/a/70559)
and [equation editing how-to](//math.meta.stackexchange.com/q/1773).
Comment: The vector component that's orthogonal doesn't change, and if it's reflection it would be reversed, but I'm pretty sure I can't just flip some signs in the orthogonal projection matrix.
Comment: Good. Try writing what you've just said out as an equation and see if you can factor out the vector being reflected.
Answer: You're very close. You've already worked out $P_W$, the orthogonal projection onto $W$, and know that a reflection reverses the component of a vector orthogonal to the reflector. With that in hand, you can construct the reflection matrix. Let $\mathbf v_\parallel = P_W\mathbf v$ and $\mathbf v_\perp = \mathbf v-\mathbf v_\parallel = \mathbf v-P_W\mathbf v$. Then the reflection of $\mathbf v$ in $W$ is $$R\mathbf v = \mathbf v_\parallel - \mathbf v_\perp = \mathbf v_\parallel - (\mathbf v - \mathbf v_\parallel) = 2\mathbf v_\parallel - \mathbf v = 2P_W\mathbf v-\mathbf v = (2P_W-I)\mathbf v.$$ Observe that we haven't made any assumptions about the subspace $W$. This construction works whether $W$ is a line, plane, &c.
The approach you mention toward the end of your question has some good ideas, but it looks like you might be getting some of them mixed up. The columns of a transformation matrix are the images of the basis vectors. Unfortunately, this means that the first column of the reflection matrix is not $\mathbf w = (2,-1,4,-3)^T$, the direction vector of the line. If it were, that would mean that the standard basis vector $(1,0,0,0)^T$ gets mapped onto the line, which isn't at all what you want. On the other hand, if you take $\mathbf w$ as your first basis vector, then relative to that basis the first column of the reflection matrix is $(1,0,0,0)^T$. As stated previously, the reflection reverses orthogonal rejections from $W$, so to continue this construction, find a basis for $W^\perp$ and adjoin it to $\mathbf w$. Relative to this basis, the reflection matrix is simply $\operatorname{diag}(1,-1,-1,-1)$ and a change of basis back to the standard basis will give you the required reflection matrix. All that remains is to find three linearly-independent vectors that are all orthogonal to $\mathbf w$, which can be done by inspection.
Comment: I don't understand what you mean by the vectors you list. (1,0,0,0) can't be in the reflection matrix because it isn't orthogonal to (2,-1,4,-3), which you say should be used as a basis instead of a vector in the matrix.
Comment: @Sabrina You build the reflection matrix in a basis different from the standard basis, one in which it has a very simple form. Relative to a coordinate system in which $(2,-1,4,-3)^T$ is the first basis vector, its own coordinates are $(1,0,0,0)^T$ and it gets mapped to itself by the reflection, so *relative to that basis* the first column of the matrix is $(1,0,0,0)^T$.
Comment: What does it mean for the coordinates to be (1,0,0,0) relative to that basis?


Convex hull of set of points inside a half-space

Question: We place ourselves in $\Bbb{R}^d$, for $d\geq 1$. Let $\mathcal{h}$ a hyperplane, and let $S$ be a finite set of points that all lie in one of the (closed) half-spaces limited by $h$.
Let $C$ denote transformation that to one set assigns its convex hull.
Prove that $C(S)\cap h=C(S\cap h )$.
Comment: What is $\mathcal H$?
Comment: @mathcounterexamples.net Sorry, $\mathcal{H}$ is the hyperplane limited by $h$ containing $S$. I also edited the second part.
Comment: Then the question is trivial... If all the points in $S$ are contain in one of the half-space, $S \cap h =\emptyset$
Comment: @mathcounterexamples.net I mean the closed half-space.
Comment: Please try to be more precise! Then my answer below is correct.
Comment: Please re-read the edited question
Answer: As $S \cap h \subseteq h$ we have $C(S \cap h) \subseteq C(h)$ as $h$ is convex. And obviously $C(S \cap h) \subseteq C(S)$. Therefore $C(S \cap h) \subseteq C(S) \cap h$.
Regarding the converse inclusion. As $S$ is included in a half space having $h$ for boundary, a point $x$ belongs to $C(S) \cap h$ only if is is a convex combination of points of $S$. Otherwise it's coordinate over a line not included in $h$ won't vanishes in contradiction with $x \in h$. Hence $x$ is a convex combination of points of $S \cap h$ which means that $x \in C(S \cap h)$.
Comment: Sorry, I made a typo. I edited the question.
Comment: I updated my answer ... according to your question new version.


Group generated by pile shuffles

Question: I can find plenty of questions relating to riffle shuffles, but none about the simple pile shuffle. My question is about the permutations possible on eight cards by pile shuffling.
Eight cards are dealt into two piles. Cards $1,3,5$ and $7$ are dealt into the first pile; cards $2,4,6$ and $8$ into the second pile. The two piles are stacked on top of each other. If the first pile is placed on top of the second, the cards are rearranged according to the permutation:
$$\alpha := (1)(253)(467)(8)$$
If the second pile is placed on top of the first, the cards are rearranged according to:
$$\beta := (157842)(36)$$
Let $G$ be the group generated by these two permutations. My questions: what is $|G|$? What is $G$ isomorphic to?
Both $\alpha$ and $\beta$ are even, so $G \le A_{8}$. I think $|G| = 24$, by working through permutations by hand (and noting identities such as $\alpha \beta \alpha \beta = \beta^{2} \alpha^{2}$, $\alpha \beta^{2} \alpha = \beta^{4}$ and $\alpha \beta^{3} = \beta^{3} \alpha$ ). But I'm not certain that I haven't missed something.
The permutations have an interesting property that a composition of any three (except for $\alpha^{3} = e$) gives a permutation comprised of disjoint transpositions, for example:
$$\alpha \beta^{2} = (14)(23)(58)(67)$$
... and any transposition (on eight elements) can be found in one of these compositions. (This relates to Gergonne's card trick - any of the cards can be moved to any position with three pile shuffles.)
Comment: A boring answer, but: have you tried using [GAP](https://www.gap-system.org/), or other computer algebra software? This is an ideal problem for these systems.
Comment: Thanks! GAP looked a little intimidating to an amateur like myself, but I found [this app](https://wims.univ-cotedazur.fr/~wims/wims.cgi?session=SFD005C395.5&+lang=en&+module=tool%2Falgebra%2Fpermgroup.en&+cmd=reply&+job=group) online, based on the software. Alongside the subgroup diagrams provided by [this other app](https://hobbes.la.asu.edu/groups/groups.html), I've come to an answer, which I'll post.
Comment: Yes, GAP can certainly be intimidating, and my comment nearly had a warning about this. But the first app you give in particular is brilliant, thanks for linking to it! It would be great though if you could add what you did, e.g. link to the first app in your answer to get the order. I'm also unsure how you used the second app.
Answer: Thanks to the comment by user1729, I've come to an answer.
$$G \cong A_4 \times Z_2$$
I used the 'PermGroup' app from Université Côte d'Azur to confirm that $|G|=24$. The app also provided details of the normal subgroups of $G$. I compared these details with the subgroup diagrams provided by this app, for each of the fifteen groups of order 24, to find that $G$ had the same subgroup structure as $A_4 \times Z_2$.
Some other details... The center of $G$ is $\{ e,\beta^{3} \} $. The largest subgroup in $G$ is:
$$H=\{e, \alpha, \alpha^2, \beta^2, \beta^4, \beta^2 \alpha^2, \alpha \beta^4, \alpha^2 \beta^2, \beta^4 \alpha, \alpha \beta^2, \beta \alpha \beta, \beta^2 \alpha  \}$$
(all elements with an even number of $\beta$s in their compositions). $H$ is normal and $H \cong A_4$.
My task now is to relate this back to the cards: does this give me any 'intuitive' understanding of the permutations of the deck possible by pile shuffling? Also, how might it generalise to other deck sizes?
Edit: gathering together some bits from the comments below this answer (thanks to Jaap Scherphuis)...
'Intuition': $\alpha$ and $\beta$ (hence all elements of $G$) permute the card pairs $\{1,8\}$, $\{2,7\}$, $\{3,6\}$ and $\{4,5\}$, but never intermingle these pairs. For example, $1 \mapsto 2$ iff $8 \mapsto 7$. The permutations of these pairs are given by $H \cong A_4$. The element $\beta^3 = (1,8)(2,7)(3,6)(4,5) \in G \backslash H$ swaps cards within each pair, leaving all pairs in place; this is 'responsible' for the $Z_2$ part of $G \cong A_4 \times Z_2$.
Generalising: Writing a subscript for the deck size (so the original $G$
becomes $G_8$), I have found: $$\begin{aligned} G_2 &\cong Z_2 \\ G_4 &\cong D_4 \\ G_6 &\cong S_4 \\ G_8 &\cong A_4 \times Z_2 \end{aligned}$$
... and then they get big. $|G_{10}|=1920$ and  $|G_{12}|=7680$.
I searched for the sequence of orders of these groups ($2,8,24,24,1920,7680$) in the OEIS, and found the 'Order of group generated by perfect shuffles of 2n cards'! This led me to a (now seemingly obvious) realisation... that the pile shuffle is just the inverse of a perfect shuffle. If pile shuffles permute cards by $\alpha$ and $\beta$, then perfect shuffles permute cards by $\alpha^{-1}$ and $\beta^{-1}$. The groups generated by pile shuffling are hence exactly the groups generated by perfect shuffling.
This paper (Diaconis, Graham & Kantor, 1983) gives the groups generated by perfect shuffles (hence also pile shuffles), for all decks of size $2n$, in terms of semidirect products. It gives:
$$\begin{aligned} G_8 &\cong (Z_2)^3 \rtimes Z_3 \\ G_{12} &\cong (Z_2)^6 \rtimes PGL(2,5) \end{aligned}$$
(I'm not proficient enough with semidirect products to understand why $(Z_2)^3 \rtimes Z_3 \cong A_4 \times Z_2$.)
Geometrical interpretations: Given $G_4 \cong D_4$, pile shuffling $4$ cards can easily be interpreted as symmetries of a square (with cards mapped to vertices). Jaap Scherphuis, in the comments, gives an interpretation of $G_6 \cong S_4$, with cards mapped to faces of a cube. $G_8 \cong A_4 \times Z_2$ relates to pyritohedral symmetry; cards can be mapped to the vertices of a cube, where each face of the cube is painted with a line segment that divides the face into two equal rectangles, such that the line segments of adjacent faces do not meet at the edges. Permutations of the cards correspond to symmetries of the cube.
Comment: Aha, so $\beta^3$ is responsible for the $Z_2$ part of the group. It doesn't permute the pairs, only swaps the cards of each pair in place.
Comment: Writing a subscript for the deck size (so the original $G$ becomes $G_8$), I have... $G_2 \cong Z_2$, $G_4 \cong D_4$, $G_6 \cong S_4$, $G_8 \cong A_4 \times Z_2$... and then they get big. $|G_{10}| = 1920$ and $|G_{12}| = 7680$. Both $G_{10}$ and $G_{12}$ include odd permutations. I might have reached the limit of what I can do with my current understanding of group theory...
Comment: The cards split into 4 pairs, $\{1,8\}$, $\{2,7\}$, $\{3,6\}$, and $\{4,5\}$. The shuffles permute those pairs, but never intermingle them. This will generalize to larger even numbers of cards, because the shuffles are symmetric - you can reverse the card order, do a shuffle, and reverse the card order again, and you get the same effect as the shuffle alone.
Comment: This is lovely; explaining why $\beta^3$ commutes with all elements of $G$ ($\beta^3$ being the element that reverses the card order).
Comment: Yes! $A_4$ comes from the possible permutations of the four pairs, and $\beta^3$ swaps the cards within each pair.
Comment: Have you found the groups for larger numbers of cards yet? For $2n$ cards, do you get a factor $S_n$ when n is odd, or is it always only even permutations?
Comment: It took me a while to see why $G_6 \cong S_4$, but you can map the 3 card pairs to the three pairs of opposite faces of a cube. The two shuffles then correspond to rotations of the cube (a quarter turn around a face axis or a third of a turn around a corner axis), and together generate the whole group of rotations of the cube, which is $S_4$ and can be seen as permutations of the four main diagonals of that cube. The $|G_{12}|=5!\cdot 2^6$ surprises me, and it may be that the card pair permutations are $PGL(2,5)$, a transitive group on 6 elements isomorphic to $S_5$.
Comment: You are correct! See edited answer.

Group generated by pile shuffles


Using Notepad++ to compile Java code

Question: I've been trying to set up Notepad++ as a little Java environment, mainly for learning Java as I was having some difficulty getting a simple program to work with NetBeans, unfortunately all the advice on setting up Notepad++ to call the Java code is not working.
I guess notepad++ has changed or the Java development Kit has been massively modified because all examples I have used result in errors, even though there is little room for error.
to begin I found this site:
http://blog.sanaulla.info/2008/07/25/using-notepad-to-compile-and-run-java-programs/
this is the code to run Javac to compile the code:
javac "$(FILE_NAME)"

and
java "$(NAME_PART)"

to run the resulted byte code, however this has absolutely no success at all anymore. Java is properly setup and I can call the Java program to do its thing through CMD.
Using a plugin called npp and called through F6 and run with this code (given in the comments) succeeds in compiling the Java program into the correct .class file, however the command failed in running the program
cd "$(CURRENT_DIRECTORY)"
javac $(FILE_NAME)
java $(NAME_PART)

errors from the console in Notepad++ are:
java.lang.NoClassDefFoundError: first
Caused by: java.lang.ClassNotFoundException: first
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: first.  Program will exit.
Exception in thread "main"

I figured setting up Notepad++ to compile and run the code would be easy and fun, but its seems all documentation on the internet is outdated as nothing works.
I would like a easy way to compile and run Java code from within Notepad++
I could just used CMD but i'd rather it be more integrated into notepad++
Thanks for any possible help. cheers :)
EDIT: I'm using the latest version of Java, notepad++ and have Windows 7
EDIT 2: the code:
 //A Very Simple Example
 class ExampleProgram {

   public static void main(String[] args){

        System.out.println("I'm a Simple Program");
   }
 }

Comment: Try using an IDE, i.e. Eclipse, which is built for writing code. Will teach you a lot more then notepad will.
Comment: I posted a earlier question about how to get netbeans to work with simple single java files and I was advised to use notepad or notepad++ as there is a learning curve to using Netbeans.
Comment: The obvious question is: Why use Notepad++ when you have NetBeans installed?
Comment: Netbeans will make your life much easier. If you are having problems with it, just ask here
Comment: http://stackoverflow.com/questions/4309402/trying-to-follow-along-with-simple-java-tutorial-netbeans-not-compiling-code
Comment: post the java code you are trying to compile; debugger is trying to say that it can't find your main file. Make sure that classpath is set ofc
Comment: Netbeans and Eclipse might have a bigger learning curve, but it saves you a lot of frustration.
Comment: In your example, make sure that your file is named ExampleProgram.java
Comment: I changed the name to the correct one but no difference, i think i'll stick with Netbeans, thanks for the effort though, cheers
Comment: http://www.cs.auckland.ac.nz/courses/compsci101s1c/resources/Notepad/Notepad++.pdf This is it!
Comment: [This](http://blog.prateeksingla.com/2013/06/compile-and-run-java-programmes-in.html) might be helpful.
Answer: The 'learning curve' associated with IDEs like Eclipse or Netbeans initially mostly involves what you already have above - knowledge of setting class paths, environment variables and so on.  Instead of Notepad++ (which I love, but it's not 'made' for Java), I'd recommend Eclipse especially if you have a grunty PC (it's a bit memory hungry).  Aside from getting the paths setup, after that you'll be ready to rock.
And Eclipse being actively and openly developed is one of the most documented IDEs out there. The tutorials are bound to work correctly for it :). But seriously, it's pretty good. And then when you want to expand to Android development in Java, or some other type of Java programming, you just load up the add-ins required, and you're away laughing. It also supports debugging, the likes of which Notepad++ certainly cannot compete.
Comment: while i agree w/ Mark about the overall utility of an IDE, but I surely feel that it's quite an overkill to launch a bulky IDE, create a project, to do something as simple as writing a single class to check something.
Comment: I disagree. I do simple concept testing all the time in Eclipse. In fact, I have a project called Test, with a single class, called Test, with a single function, main(), to do exactly that. Easy as pie.
Comment: I think is a good practice for beginners to learn how to compile programs at hand, without the help of an IDE. After you know it well you can save time and effort using the IDE.
Comment: However, in theory, Java should not "BE" Eclipse, just like Visual Studio should not "BE" VB or C#. Yet that does seem to happen. By contrast, I haven't yet heard which IDE is going to "BE" javascript. Is that simply a matter of compiled vs. interpreted? A modern nodejs and jquery-lib web app can have 100s of source code files, but the IDE is usually, still, a slim text editor. Why the diff?
Comment: Don't forget IntelliJ , its my favorite. I believe Eclipse is recommended by Oracle but there are a few IDE's that work well with Java.
Answer: Probably changing the last line to:
java -cp . $(NAME_PART)

will work for you. The problem is that you aren't setting up the classpath.
Notepad++ will be fine for compiling a single file project. For anything more than this you will need an IDE or at least integrate with ant instead of java compiler.
Comment: Joseph, my friendly advise as programmer to programmer, is never to think that something is broken in the program/api/language you are using. In 99.999% of situations the problem is in what you are doing with it.
Comment: I suppose it would be best to go back to NetBeans, getting the feeling that notepad++ is quite limited for larger projects, hmmm
Comment: the edit made no difference, exactly the same error, I think that the function in NPP, $(NAME_PART) is broken
Answer: Set the classpath in the java command like this:
java -classpath "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

Answer: Although I'm convinced that you have to work with an IDE (NetBeans, Eclipse, IntelliJ IDEA (which I use), I think it's always good to know and learn what is failing in your small example.
With an IDE, the compile and runtime environment are configured, but as a developper, it's important to understand the basic concepts hidden.
Anyway,
From the link you've posted, here are the environnement variables you must define
FULL_CURRENT_PATH: C:\Documents and Settings\Administrator\My Documents\JavaP\ExampleProgram.java
CURRENT_DIRECTORY: C:\Documents and Settings\Administrator\My Documents\JavaP\
FILE_NAME: ExampleProgram.java
NAME_PART: ExampleProgram
EXT_PART:java

Make sure that all is named according to these settings, ie:
- your source file is under C:\Documents and Settings\Administrator\My Documents\JavaP\
- your source file is named ExampleProgram.java

Comment: His class name is `ExampleProgram` so the file name should be `ExampleProgram.java`, not `NotHelloWorld.java`. Did you just copy-paste file names from the link he provided?
Comment: I copy-paste for the example. If it's better I make the adaptation. it's made :), thx
Answer: I agree with the accepted answer but I sometimes use Textpad to quickly write/compile/run small java programs.
Textpad has this built-in (Tools/External Tools).
If you don't see this options I think you have to go to Configure/Preferences/Tools and add them.
Then you can just hit Ctrl-1 to compile and Ctrl-2 to run.
This is useful for very small quick tests, no libraries or anything.
Answer: You can use eclipse as suggested above, and just create a java project. After you create the project just drag and drop the java file you want to work with into the project and select the link file option. That way eclipse will create a copy of your file and link it to your file, meaning every change you make to one file will be copied to the other.
Answer: I've recently run into this situation in Windows 7 64-bit. Notepad++ is a 32-bit program, so Windows has enabled "File System Redirection" on it and its plugins (including NppExec), as per http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx. I also had the latest 64-bit JDK 8.xx installed but an earlier 32-bit JRE 7.xx installed.
Now the JRE 7.xx installer had placed a copy (or hardlink, I haven't checked) of java.exe in its C:\Windows\system32 -- which is actually C:\Windows\SysWOW64\java.exe. This is not in the PATH of 64-bit applications like cmd.exe, but is in the (redirected) PATH of 32-bit applications.
Then after I installed JDK 8.xx, the installer did not update my PATH so I added the JDK install location to the end of my PATH. From that point on the behavior I observed was:

From the Windows Command Prompt (cmd.exe, 64-bit) -- both javac.exe and java.exe were from the JDK 8.xx location (C:\Program Files\Java\jdk1.8.0_05\bin).
From within Notepad++ (32-bit), the JDK version of javac.exe was getting invoked but the java.exe was actually being run from C:\Windows\SysWOW64\java.exe -- leading to this kind of loading problem.

The fix was to update or remove the 32-bit JRE.
Answer: You can try to add the system environment variable for the jdk bin path. when i ran java on notepad++ for first time, i also encountered similar issue.
Answer: My situation is similar to yours,
I compiled and run the "hello world" application in cmd correctly, but in notepad++, I can only do the compile but can't run the class file。
The reason is that I installed jdk1.7, set the PATH to jdk1.7, and then I installed jdk1.6 too. So the jdk1.6 installer add java.exe to %systemroot%\System32 (SySWOW64 in x64 environment) but no javac.exe.
While in cmd modem, system called javac.exe and java.exe in PATH, notepad++ called javac.exe in PATH because there are no javac in system32 and java.exe in system32. (You can run "javac -version" and "java -version" in notepad++ to find out)
So I deleted java.exe in system32 and then npp compiled and run perfectly.
Hope this can help anyone.
Answer: you can use this little code in "run" module of notepad ++:
cmd /k "cd /D "$(CURRENT_DIRECTORY)" & java "$(NAME_PART)""

note: this is the almost same code solution they used to run python in notepad++
as explained in this topic: How to Execute a Python File in Notepad ++?
Answer: I found this link useful.
However, the NppExec seems comes with its own JRE, so I have changed the scripts to this (means you need to hard code java location):
cd $(CURRENT_DIRECTORY)
C:\App\Java\jdk1.8.0_112\bin\java -version
C:\App\Java\jdk1.8.0_112\bin\javac $(FILE_NAME)
C:\App\Java\jdk1.8.0_112\bin\java $(NAME_PART)

Answer: cmd /k "cd /D "$(CURRENT_DIRECTORY)" & javac "$(FILE_NAME)" & java "$(NAME_PART)""

Add above to Run commands
It worked!
Answer: Here are the steps that will help you compile and run Java program in Notepad++.

Install Java Development Kit and Java Runtime Environment Requirements
Install NPPExec Plugin in Notepad++
Add a script for Compiling and Running Java
Add Menu Item for NPPExec script (Optional, but nice to have).

NPPExec Script
Make sure that the Java JDK path is correct in the script below.
// save program
NPP_SAVE

// change directory
cd "$(CURRENT_DIRECTORY)"

// compile
"C:\Program Files\Java\jdk1.8.0_301\bin\javac.exe" $(FILE_NAME)

// execute
"C:\Program Files\Java\jdk1.8.0_301\bin\java.exe" -cp  "$(CURRENT_DIRECTORY)"  "$(NAME_PART)"

Here is the step-by-step video demonstrating all of the above steps. (disclaimer: I am the owner of this channel)

Using Notepad++ to compile Java code