New Page error using Multicell of the library Python PyFPDF

Question: I am creating a program that generates a translation sheet for a language. It uses the python FPDF module. I utilise pdf.multicell() to create a page with two columns for the English word, and then the foreign equivalent
I am using pdf.set_auto_page_break() to create  a new page whenever I reach the page limit. However, I am experiencing some problems with this.
The new page is always created after one line has been written on a new page. This means that I have mismatched translations, and lots of empty whitepsace.
This is my code:
data = [['le bus', 'the bus'], ['le train', 'the train'], ['la gare', 'the train station']] etc

def write_to_pdf(data):
    pdf = FPDF()
    pdf.set_auto_page_break(True, 2)
    pdf.add_page()
    pdf.add_font('DejaVu', '', 'filepath/font', uni=True)
    pdf.set_font('DejaVu', '', 14)

    pdf.cell(200, 10, txt = title,ln = 1, align = 'C')
    pdf.cell(200, 10, txt = subtitle,ln = 2, align = 'C')
    pdf.set_font('DejaVu', '', 10)

    for section in data:
        try:
            top = pdf.y

            offset = pdf.x + 100

            pdf.multi_cell(100,10,section[0],0,'L')

            pdf.y = top

            pdf.x = offset

            pdf.multi_cell(100,10,section[1],0,'R')

        except:
            pass

    pdf.output("Output.pdf")

And this is the result

Thank you in advance for any help
Answer: I think that the explanation of the problem is that before you save the y with the instruction: top=pdf.y and after you execute the instruction:
pdf.multi_cell(100,10,section[0],0,'L')

so when the bottom of the page is reached y value is high (near 300 mm) so the adding of a new multi_cell of 10 mm causes the creation of a new page.
The multi_cell which contains the sentence òu est-ce que tu va ? is placed at the top of the second page.
After this, the program executes the instruction pdf.y=top so the cursor is moved to the bottom of the second page where is inserted the new multi_cell with the english translation where are you going ?, but this is placed in the third page as you can see in your PDF file.
The solution is to add a if condition to test the value of y before to set its value. All changes are showed by the following code (which is your write_to_pdf function modified):
def write_to_pdf(data):
    pdf = FPDF()
    pdf.set_auto_page_break(True, 2)
    pdf.add_page()
    pdf.add_font('DejaVu', '', 'filepath/font', uni=True)
    pdf.set_font('DejaVu', '', 14)

    pdf.cell(200, 10, txt = title,ln = 1, align = 'C')
    pdf.cell(200, 10, txt = subtitle,ln = 2, align = 'C')
    pdf.set_font('DejaVu', '', 10)

    for section in data:
        try:
            top = pdf.y

            offset = pdf.x + 100

            pdf.multi_cell(100,10,section[0],0,'L')

            # ---> add this if <---
            if pdf.y > top:
                # we are always in the same page
                pdf.y = top
            else:
                # creation of a new page => y must be go back of the
                # height of a multi_cell (that is 10)
                pdf.y -= 10

            pdf.x = offset

            pdf.multi_cell(100,10,section[1],0,'R')

        except:
            pass

    pdf.output("Output.pdf")

I have tried the code on my system and seems working correctly.

This is an other post with an analog problem but where it is used the method cell() instead of multi_cell().


Dependências do NetFramework na pasta do projeto?

Question: Gostaria de saber se é possível embutir, de alguma maneira, as <code>.dll</code> que o meu projeto usa do NetFramework em sua própria pasta. Dessa forma não seria necessário a instalação do NetFramework no computador do cliente, visto que todas as dependências se encontrariam na pasta do programa.
Percebi que a grande maioria dos softwares de grande marca utilizam desse artifício, só não sei ainda como realizá-lo.
Obs: Utilizo a versão 13 do Visual Studio.
Answer: Isto é uma funcionalidade fresquinha (na data desta resposta). Será inclusa no Visual Studio 2015 e se chama Microsoft .NET Native.
Se for anterior ao Framework 4.5.2, não tem como. Tem que instalar o Framework mesmo.
Comment: Entendi, muito obrigado pela resposta Cigano!
Só que eu já fiz um projeto com a versão 2013, devo refazê-lo agora com a versão 2015 ou eu posso de algum jeito migrar o meu projeto sem causar danos ?
Comment: É possível a migração. Não sei como fazer.


Nearby Connections Advertise method

Question: Does the Nearby Connections API advertise through Wifi and Bluetooth, or just Bluetooth? My experimentation with the API shows that I can't find any device beyond ~30 meters which makes me think that it's using Bluetooth.
I know that the Cluster strategy is Bluetooth only, but if the strategy is set to Star, will the API use wifi for advertise?
Answer: As of today, all 3 strategies (CLUSTER, STAR, POINT_TO_POINT) only use Bluetooth for advertising and discovery.
No promises that this will always be the case. More technologies (like WiFi) may be added in the future.
Comment: Currently audio is only used in Nearby Messages. There has been talk about adding it to Connections eventually, but you can only send a couple bytes over it (which is much shorter than our supported Endpoint name length), so it would have to be used for ranging rather than data transmission.
Comment: There is documentation that suggests high-frequency audio is used somehow as well.  Is this with Nearby Connections?  Is it used for advertising/discovery?

Nearby Connections Advertise method


Is AI capable of separating instruments from a track?

Question: At some point of my life I want to become a DJ (self-development).
I have in mind various approaches to it, both artistic and technical.
I'd like to ask on the latter, is it feasible as for 2022 to pick a track and separate the instruments in it using AI? If so, to what degree of audio quality can I aspire?
Comment: Actually, legality aside, the once "Holy grail of the misinformed" is now quite possible. Separating a track into rough components - vocals, drums, bass, 'other' is now quite feasible. Izotope RX can do it, so can various online structures. Legally, you'd need to ask permission & pay an agreed royalty to use anything extracted this way [the details of which are quite beyond this stack's remit]..
Comment: With that being said, the inability to cleanly remove the vocals out of pretty much any track is infamous.
Comment: Welcome! Please read a bit about [the questions that are on topic here](https://music.stackexchange.com/help/on-topic) and then use the "Edit" button to update the question. A question about exactly how to separate parts is good. Asking for specific software recommendations isn't covered here, and "give me all the advice about DJing that you can think of" is too broad. But feel free to open a separate question asking for more focused advice about specific musical aspects of DJing.
Comment: When you write "separate the instruments", do you mean "remove the vocals", or do you mean "separate each individual instrument into its own track"?
Comment: I strongly suspect that the OP used "AI" to mean "an automated process whereby I can simply push a button and the computer works magic." In much the same way that an electric can opener is "AI." Yes, I think the OP's focus is on the output rather than the means, so if a simple EQ filter did the trick, I suspect that's what they're looking for. But the OP hasn't weighed in since they edited three days ago.
Comment: @ElementsinSpace I think, in a computing sense, "AI" is more narrowly defined as something relying on "machine learning"; I suspect the OP has misused it. And there's no indication from the OP that MIDI is part of the equation. But I think all this discussion is splitting hairs, and the question should be read as "Can I use a computer to separate instruments from a single mixed audio track, and how well can it be done," and if anyone has an answer (I don't) they should go ahead and give it.
Comment: Why use AI? Karaoke music publishers either license the original tracks or have musicians re-perform them all the time and they make money doing it. There isn't really any need or market for this in either the business or artistic senses.
Comment: thank you all for your suggestions, the question is now more aligned with the comunity subject
Comment: Does it have to be "AI" specifically, or is any computer software ok? How does one tell if a piece of software is "AI" or not, and why do you care? :)
Comment: @piiperiReinstateMonica - Software that receives a MIDI file composed of many instrument tracks can separate them without AI.  But an analogue audio signal would require some form of AI to separate it into instrument tracks.
Comment: @ElementsinSpace I can divide an audio signal to frequency components, it's called FFT. Is that AI? I can separate out frequencies from it, it's called a filter. Is that AI? I can find fundamental frequencies from audio, from peaks in the FFT output or from autocorrelation. Is that AI? Is digital signal processing AI? If a Hidden Markov Model is used, is that AI? If statistics are used, is that AI? If a probability model is used, is that AI? Is Antares Autotune AI? What is AI? Why is MIDI processing not AI? If it can calculate with nice certainty what they key of the tune is, isn't that AI?
Comment: @piiperiReinstateMonica - I would say that all of those are a form of AI, because they are taking a mixed-up signal and processing it (in a language other than which it was composed) to hopefully arrived at a clean signal.  But splitting up a midi track into instrument parts is different, because the instruments' parts are not mixed up at all, they are stored as discreet channels already.
Comment: @AndyBonner - I think of ML, as AI that is capable of changing the parameters and variables in the algorithms it is using, as it processes data. But I do agree that AI and ML aren't particularly relevant to the question. I think OP just wants to know if there is some computer software that can "somehow" separate an audio track into instrument parts.
Answer: The Stems feature in Serato DJ Pro 3 Beta seems to offer what you're asking about.
Just yesterday youtube suggested I watch this video demonstrating the feature.
Remixing Thriller with Serato Stems
Answer: There's a lot of software out there that can pull out stems. If you're interested in the code aspect of it, Spleeter is the place to start. It's used in iZotope's RX8, Unmix, VirtualDJ, and some other major pieces of commercial software, and you can also try it out on sites like Vocali.se to test the quality (though if you work with the project yourself you can get better results than you would from a website). If you don't want to shell out money for software yet, I'd definitely recommend poking around with some of the open-source projects in that space (especially Spleeter) to see if what's out there already suits your needs — but lots of folks are already using this stuff to get stems for remixes and whatnot.
Comment: Update: FL Studio also now has stem-extraction built in, and I'm sure many more programs have come out with that feature, since it's incredibly valuable.
Answer: Current technology seems to have reached the point where re-balancing a mix is possible - see the new version of 'Revolver'.
https://en.wikipedia.org/wiki/Revolver:_Special_Edition
I don't think we can yet completely extract/remove instruments.   But it will doubtless come.  Maybe by actual analysis and isolation, maybe by artificial intelligence reconstruction of what it GUESSES was played.  Frightening things are being done with old photographs...


nested cross validaiton vs train-test split

Question: I am trying to understand the main benefits of conducting a nested cross-validation compared to a simpler train-test split. Let us say I would like to build a prediction model. I initially split my data so that 80% of it is used for training and the remaining 20% of it for testing. Then, I run CV on the 80% to tune the hyperparameters and finally run the model using the optimal hyperparameters on the test sample, in order to get an unbiased estimate of my model performance.
Now, my understanding is that nested-CV has two main benefits:

You get to use the entire data you have as part the training process (so the inner CV would essentially get to see all the data at some point).

The model performance estimate you get could be more stable (in the sense that it is not based on a single run using the test data, but on multiple runs.

Am I missing something? And from a practical standpoint, assuming a large-enough database, does one really gain much from adding the computational complexity of a nested-CV compared to a simpler train-test split?
Thanks a lot.
Comment: [Cross-posted on Data Science](https://datascience.stackexchange.com/questions/97825/nested-cross-validation-vs-train-test-split/97828#97828)
Answer: Just to make it clear, the procedure given in your first paragraph is train/test split followed by a cross-validation. Nested CV is obtained by looping through the train/test split multiple times. This is to get more stable performance estimates, and it has diminishing returns as the data gets bigger, and may not be worthy of the complexity. But, with small data sets, it can be of paramount importance.

You get to use the entire data you have as part the training process (so the inner CV would essentially get to see all the data at
some point).

Yes, but the main duty of the outer process is to stabilize the performance measurement.
Note that, nested CV is sometimes used in hierarchical model selection, e.g. the outer CV loops through the algorithms (random forest, logistic regression etc.) and the inner CV loops through the hyper-parameters.


jQuery swap text field for password field not working in IE8

Question: In a login form in my web application, I'm using jQuery to swap a text field for a password field once it gains focus. It's working everywhere except in IE8 (and, I'm assuming, below -- though I haven't checked.)
var originalField = $(this);          // Original field
var newField = $(this).clone();       // New field, cloned from the old one
newField.attr("type", "password");    // Change the new field's type to password
newField.insertBefore(originalField); // Insert the new field
originalField.remove();               // Remove the old one
newField.attr("id", "password");      // Give new field the id "password" (for CSS)
newField.select();                    // Bring focus to the new field

Thoughts?
EDIT: Sorry I didn't specify, but "not working" in IE means that the field simply isn't getting replaced. When I type in the password field in IE, I can read its contents.
EDIT 2: Here's the fiddle with the HTML and the JS: http://jsfiddle.net/franktisellano/v5D9W/3/
Comment: What exactly is it doing instead of working? Should newField.select() be newField.focus() ?
Comment: Why does it not work in IE8? Does it not clone the element, does it not insert the clone? Does it error?
Comment: Can you setup a fiddle that includes the HTML as well as the JS?
Comment: Added the fiddle to the main question.
Answer: IE8 doesn't allow you to change the type of an input. You get an error like this in the Dev Tools Error: This command is not supported.<input class="custom" title=Password value="" type=password name=password placeholder="Password">.
The jquery.placeholder plugin works around this by just creating a new element and copying attributes from the old element.
function extractAttributes(elem) {
    var attr = elem.attributes, copy = {}, skip = /^jQuery\d+/;
    for(var i = 0; i < attr.length; i++) {
        if(attr[i].specified && !skip.test(attr[i].name)) {
            copy[attr[i].name] = attr[i].value;
        }
    }
    return copy;
}

$clone = $('<input/>')
  .attr($.extend(extractAttributes(this), {type: 'text', value: placeholder, 'data-password': 1, id: cid}))
  .addClass('placeholder');

https://github.com/matoilic/jquery.placeholder/blob/master/jquery.placeholder.js#L80-L82


Forecast encompassing test for cointegrated time series

Question: I am forecasting an integrated time series variable $y_t$. I have two competing forecasts, $f^1_t:=f^1_{t|t-h}$ and $f^2_t:=f^2_{t|t-h}$. I would like to test whether $f^1_t$ forecast-encompasses $f^2_t$.
The length of $f^1_t$ and $f^2_t$ time series (the number of out-of-sample forecasts) is between 80 and 90.
I am following Diebold's Forecasting textbook Chapter 12.1, pages 463-464.
If I had cross-sectional data, I would run a test regression
$$y_t = \beta_1 f^1_t + \beta_2 f^2_t+\varepsilon_t$$
and test $H_0$: $\beta_1=1$ and $\beta_2=0$ using an F-test.
If I had stationary time series $y_t$, $f^1_t$ and $f^2_t$, I would run the same test regression but allowing for autocorrelated errors; that would amount to an ARMAX model with $f^1_t$ and $f^2_t$ as exogenous regressors; I would use a likelihood ratio test to test the null hypothesis.
However, I have time series $y_t$, $f^1_t$ and $f^2_t$ that are integrated and cointegrated. I am afraid I cannot use an ARMAX model as with stationary time series. I have thought of using a vector error correction model (VECM) but I cannot figure out what parameter restrictions would correspond to the hypothesis of interest. The hypothesis could be formulated using a structural VECM (SVECM); however, I am not sure if I could test it without making a bunch of identifying assumptions that might not hold in reality.
I have overviewed a number of journal articles about forecasting in cointegrated systems. Most of them seem to ignore the problem of integrated variables and basically use the equation above when testing for forecast encompassing. I think that is incorrect.
Question: how can forecast encompassing be tested in the spirit of Diebold's Forecasting textbook Chapter 12.1, pages 463-464 (see the equation above), when $y_t$, $f^1_t$ and $f^2_t$ are integrated and cointegrated?
References are welcome.
A related question is here. However, it does not address the case of integrated and cointegrated time series.
Comment: Somewhat related: https://stats.stackexchange.com/questions/623754
Answer: I hope that the following resources will be helpful (I ranked them per my fuzzy understanding):

Paper by Jiang, Zhang and Song (2014) <= describes the encompassing test;
Paper by Duy and Thoma (1998);
Book by Pfaff (2008); two of the R packages, listed here, are complementary to the book.

References
Duy, T. A., & Thoma, M. A. (1998). Modeling and forecasting cointegrated variables: Some practical experience. Journal of Economics and Business, 50, 291-307. Retrieved from http://pages.uoregon.edu/mthoma/Papers/Modeling%20and%20Forecasting%20Cointegrated%20Variables.pdf
Jiang, C., Zhang, J., & Song, F. (2014). Selecting single model in combination forecasting based on cointegration test and encompassing test. The Scientific World Journal, 2014, Article ID 621917. doi:10.1155/2014/621917 Retrieved from http://www.hindawi.com/journals/tswj/2014/621917
Pfaff, B. (2008). Analysis of integrated and cointegrated time series with R (2nd ed.). Springer.
Comment: Thanks! These sources were among the ones I had overviewed before with no luck; I did not list them in the OP, though, so thanks for pointing out. Jiang, Zhang and Song (2014) is quite messy and does not seem to provide a solution the problem of cointegrated forecasts and realized values (see p. 6 in their paper). Duy and Thoma (1998) seem to ignore the problem altogether (see the description on p. 296). Pfaff (2008) does not discuss it at all.
Comment: @RichardHardy: You're welcome! I see. It's a pity I couldn't help.
Comment: @RichardHardy: No problem at all. Thank you. Upvoted yours.
Answer: I figured out that even though $y_t$, $f^1_{t|t-h}$ and $f^2_{t|t-h}$ are cointegrated, there are cases when the test regression in the original post can be used with first differences instead of levels of variables:
$$\Delta y_t = \beta_1 \Delta f^1_t + \beta_2 \Delta f^2_t + \varepsilon_t$$
allowing $\varepsilon_t$ to follow an ARMA($p,q$) process.
The main argument is that in many practical applications, $y_t$ is not likely to adjust to some long-run equilibrium constituted by $y_t$, $f^1_{t|t-h}$ and $f^2_{t|t-h}$ together. Unless the forecasts $f^1_{t|t-h}$ and $f^2_{t|t-h}$ influence the formation of $y_t$ (which may be more likely in some situations than in other), I do not see much reason for $y_t$ to react to forecasts at all.
For example, if one considers historical data, makes some forecasts (emulating real time forecasting) and wishes to examine the performance of the forecasts, one knows that $y_t$ cannot have been influenced by the (currently made) forecasts in any way -- unless historically the actors were incidentally using the same kind of forecasts which then influenced the development of $y_t$.
This may be a messy formulation, but the idea is that often no error correction is happening in $y_t$. (The contrary is likely true with regards to forecasts themselves; here full error correction in $f^i_{t|t-h}$ towards $y_{t-h}$ over one period could be expected. With each new data point of $y_t$, the forecasts likely fully adjust to the change $\Delta y_t$; this can be reformulated as adjustment through error correction term.)
Using first differences in place of levels of variables is also suggested in Clements and Hendry "A Companion to Economic Forecasting" (2008) (Chapter 12.3, p. 275).
Of course, there may be cases where forecasts do influence the development of $y_t$ considerably, and then the problem outlined in the original post remains unsolved.
Answer: According to my understanding, the reference in Clements and Hendry is to Fair and Shiller "The informational context of ex ante forecasts". However, they do not suggest regression in first differences of the competing forecasts, but rather regression of actual changes to predicted changes which is something different:
$y_t - y_{t-1} = \beta_1 \cdot (f^1_t - y_{t-1}) + \beta_2 \cdot (f^2_t - y_{t-1}) + \epsilon_t$
Comment: Good idea, though some more details would be nice to have. This is also in line with my recent answer [here](https://stats.stackexchange.com/questions/623754/mincer-zarnowitz-test-with-cointegrated-time-series/632437#632437).


Area of the surface generated by revolving curve around y-axis

Question:
So I did something wrong in my solution because I'm not seeming to get the right answer.
$$\int_c^d 2\pi (4 \sqrt{9-y}\sqrt{1-\frac{4}{9-y}})~\mathrm{d}y$$
combine square roots and move out constants
$$\int_c^d 8\pi (\sqrt{5-y})~\mathrm{d}y$$
indefinite integral of $\sqrt{5-y}$ is $-\frac{2}{3}(5-y)^\frac{3}{2}$
move out constant $$-\frac{16}{3}\pi[(5-y)^\frac{3}{2} ]$$ from zero to $\frac{135}{16}$
$$-\frac{16}{3}\pi\left(-\frac{55}{16}^\frac{3}{2}-5^\frac{3}{2}\right)$$
 Anyway this is supposed to come out as $-\frac{73\pi \sqrt{73}}{12}+\frac{208\pi \sqrt{13}}{3}$ and I can't even fathom how to put it in that form.
Comment: 136 in the image should be 135, right? And your $dx$'s should be $dy$'s.
Comment: Yeah, sorry it was late when I typed all this
Answer: $\sqrt{1-\dfrac{4}{9-y}}$ should be $\sqrt{1+\dfrac{4}{9-y}}$


Files deployed all over my BizTalk servers, in each user's "Project Folder"

Question: When I deploy applications to our BizTalk server, we deploy to a test machine, add all the necessary resources and then export an MSI that we import on our production servers (we have two). The other day I noticed that there are dozens of folders on our production servers that appear to be copies of each developer's source code location.
For example:

C:\Development\MyProject1
C:\Projects\SomeProject
C:\Users\Ryan\My Documents\Visual Studio Projects\Another Project
Many others

They're all projects we've deployed to BizTalk and the folders don't contain source code, just the "Deployment" folder of each BizTalk project with DLL files in it. However, I thought the MSI packages were adding the DLL files to the GAC, or at the very least, were putting them in the MSI install target folder (all MSI files are installed to "C:\Biztalk\ProjectName").
Can somebody shed some light here? Are these extra copies safe to delete, and will that stop my BizTalk applications in their tracks?
Answer: I wouldn't delete them until you did a redeployment.  BizTalk is remembering the location the resource was initially added to the resource meta data source. For purpose of generating an MSI you should add the resources from where you want them to reside on the production server.
Comment: I'll bet that's exactly what's happening, though it's odd behavior - I'd expect every resource in the application to be deployed to the folder to which I'm installing the MSI, but this explanation makes sense. I'll try adding the resources from the "correct" folder and see what happens.
Answer: (I just reread your question and see that my answer may need some more context. Before you deploy the next time, have the developers follow the steps below so that you won't end up with the folders you mentioned in your question.)
You have control over the installation folder - you just need to change your resources' destination using BizTalk Administrator. You can also control installation in the GAC.

Use the following steps to modify the installation folder (things get installed in the folder that the user specifies when running the MSI):

In BizTalk Administrator, under your Application's Resources folder, review the values under the Source and Destination Location columns - you'll see folders and drive letters that exist on your system.
For each item in the list, right-click and select Modify
Change the Destination location - the path part of the location - to **%BTAD\_InstallDir%** (include the % symbols and separate the last % from the file name (probably a DLL) with a back-slash character ( \ ). So, it might look similar to this when you are finished: **%BTAD\_InstallDir%**\MyStuff.DLL
Export your application
Run the MSI on your target systems - things get installed in the folder that the user specifies when running the MSI

This is the essence of the solution - I coincidentally wrote a brief blog post about this last month.
Comment: Oddly enough, it seems that this only occurs with the resources added to the Biztalk application on initial deployment. If I add additional resources to the application post-vs-deployment and pre-msi-export, it automatically makes then "%BTAD_InstallDir%". Funny.


How to add class method to prototype in ES7

Question: I am confused about one of the syntaxes in ES7. I define a class as:
class Employee2 {
  Ename = "Rahul";
  printName =  () => {
    console.log(this.Ename);
  }
}

Since classes are syntactical sugar over existing prototype concept, I expected that the method 'printName' would actually go to function prototype. But that did not happen, the method is an object property.
However, if I do:
class Employee {
  Ename = "Rahul";
  printName () {
    console.log(this.Ename);
  }
}

this works as expected where printName goes to the prototype.
Now my query:
ES7 suggests using the syntax as in first code Employee2 class, if I use that I miss the method definition on the prototype. Is there a way to achieve the method on function prototype?
Comment: *"ES7 suggests using the syntax as in first code Employee2 class"* Where did you read that? In the first, `printName` is an *own* property of the instance, just like `Ename`. [Class field proposal](https://github.com/tc39/proposal-class-fields)
Answer:
ES7 suggests using the syntax as in first code Employee2 class

No. Use if appropriate. I'd go with the second version as often as possible. The first version barely equals:
 function Employee2() {
   this.Ename = "Rahul";
   this.printName =  () => {
     console.log(this.Ename);
   };
 }


The difference between convergence in $L^{\infty}$ and almost uniformly

Question: I am reading these notes http://terrytao.wordpress.com/2010/10/02/245a-notes-4-modes-of-convergence/ by Terry Tao. I have a question about the difference between convergence in $L^{\infty}$ and convergence almost uniformly.
Is the difference that convergence almost uniformly guarantees that you can get uniform convergence outside a set of arbitrarily small but still positive measure, while convergence $L^{\infty}$ gets uniform convergence outside a set of exactly measure zero? Formal definitions follow to make ideas precise.
Let $(X, \mathcal{M}, \mu)$ be a measure space. Let $f, f_1, f_2, \ldots$ be a measurable functions.
We say that $f_n \to f$ in $L^{\infty}$ if for all $\varepsilon > 0$ there is an $N_{\varepsilon}$ such that $|f_n(x) - f(x)| \leq \varepsilon$ $\mu$--a.e. when $n \geq N_{\varepsilon}$.
We say that $f_n \to f$ almost uniformly if for all $\varepsilon > 0$ there is a set $E \in \mathcal{M}$ with $\mu(E) \leq \varepsilon$ such that $f_n \to f$ uniformly on $E^c$. I.e., for each $\delta > 0$ there is an $N_{\delta}$ such that $|f_n(x) - f(x)| \leq \delta$ for all $x \in E^c$ when $n \geq N_{\delta}$.
Answer: Yes, that is right.
It is a good exercise to prove that your definition of $L^\infty$ convergence is equivalent to:

There is a set $E \subset \mathcal{M}$ with $\mu(E) = 0$ such that $f_n \to f$ uniformly on $E^c$.

The thing to notice is that your definition should be expanded as:

For all $\epsilon > 0$ there exists $N$ such that for all $n \ge N$ there exists $F \in \mathcal{M}$ such that $\mu(F) = 0$ and $|f_n(x) - f(x)| \le \epsilon$ for all $x \in F^c$.

That is, the set $F$ may depend on $\epsilon$ and $n$.  In showing the equivalence with my statement, you have to find a single set $F$ that works for all $\epsilon,n$.
Comment: Thank you @Nate Eldredge for the comment and the exercise.  Shouldn't the end of your definition read $x \in F^c$ instead of $x \in F$.
Comment: @AlexOlssen: Indeed, thanks.  Fixed.
Answer: Here's an example to see the difference:
Consider the sequence of functions $f_n$, where  $f_n(x)= 1$, whenever $\frac{-1}{n}<x<\frac{1}{n}$ and zero otherwise. These functions are clearly measurable. Also, the point-wise limit is the function $f$ which is zero on $R \backslash\{0\}$ and $f(0)=1$. Finally, one can show that that this converges almost uniformly (By chopping of small intervals centered around $0$), but not in $L^\infty$(Since we can do no such chopping).
Since I am in a hurry, I could only give a sketch. Perhaps I could try and clarify any doubts you have in the comments?
Comment: I thought that I would spell out why the example works. To see convergence almost uniformly we can pick $N > 2 / \varepsilon$. Then $\mu(\{x: |f_n(x) - f(x)| > \varepsilon\}) < 2 * (1 / (2 / \varepsilon)) = \varepsilon$. However no matter what $N$ we pick there is still a set with positive measure where $|f_n(x) - f(x)| = 1$ so that we do not get convergence $L^{\infty}$.
Comment: Thanks a lot for the example!
Comment: @AlexOlssen Perfect.Couldn't have said it better myself. :)


Oracle clob field val

Question: I have an issue getting a specific value of clob field.
(I can't create functions) this would be easy.
So assuming a clob field:
key1+val1;key2+val2;key3+val3;key4+val4
Here I wanted to get the value of key3 for instance
I tried to archieve it with dbms_lob.substr & dbms_lob.instr with no success.
Can one maybe help me here?
The order of the values cane be different (key2+val2;key1+val1;key4+val4;key3+val3)
Thanks a lot,
Comment: Regexp_* functions work with clob the same way as with varchar2.
Comment: You shouldn't be storing data like that. Read up on normalization.
Answer: <code>regexp_replace(clob_column, '^(.*?;)*key3\+([^;]*).*$', '\2')
</code>
fiddle

Oracle clob field val


What does $TM$, $T^*M$ and $*$ mean?(Definition Check)

Question: I was reading Hamilton's Ricci Flow by Bennett Chow Peng Lu and Lei Ni.
However, I encountered some notation confusion:

What does $TM$ mean? Does $T$ stands for tensor or tangent, "M" for metric?
What's the difference between $TM$ and $T^*M$?
Also, there seemed to be a custom to use $*$ for either space or functions, i.e. $V^*$ or $\varphi_*$. What does $*$ indicate here? Does it indicate dual space or something else?

(The preview of the material is available on amazon. )
Image I:

Image II:
Comment: $T^*M$ is the cotangent bundle; $\varphi_*$ usually will denote an induced map on tangent bundle, homology, fundamental group, or some other derived object.
Comment: On a vector space, a superscript $*$ usually indicates the dual.
Comment: $TM$ is the tangent bundle of the manifold $M$.
Comment: @MattSamuel Thank you, so what does $*$ stands for?
Comment: Why would someone downvote this question?
Comment: The objects for which you are confused about typically take some time to understand, considering a lot of specific examples and working many exercises. If you find difficulty understanding this text, I recommend taking a step back and gaining more familiarity with these objects first.
Answer: $T_pM$ is the space of vectors tangent to $M$ at $p$, and $T_p^*M=(T_pM)^*$ is the corresponding dual space.
$TM$ is the  tangent bundle of manifold, $T^*M$ is the cotangent bundle of the manifold.
$$ TM=\bigsqcup_{p\in M} T_pM$$
subject to the "gluing" conditions that $TM$ is "locally" of  the form $U\times \mathbb{R}^n$ for $U$ an open neighborhood of $M$. These objects are called smooth vector bundles and you can read more about them in a book like
$(1)$ Lee's Introduction to Smooth Manifolds
$(2)$ Tu's An Introduction to Manifolds.


What is a certain way to make Git diff and merge use opendiff?

Question: I am using the github advice to make it work:  https://gist.github.com/329690
and right now my global config file contains:
[merge]
        tool = opendiff
        external = /Users/mike/bin/git-diff-cmd.sh

[diff]
        tool = opendiff
        external = /Users/mike/bin/git-diff-cmd.sh

However, when I use gif diff, the output still comes out as text output, and so is any merge conflict when using git merge <branch>.  Is there a sure way to make them use opendiff?  (when using git diff and git merge and preferably not by other commands)
Answer: EDIT: full change
Not only you need merge.tool as you already set, you also need mergetool.<tool>. In the following you see the code you need (the options --merge and --result depends on opendiff):
[merge]
    tool = opendiff
[mergetool "opendiff"]
    cmd = \"/Users/mike/bin/git-diff-cmd.sh\" --merge --result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"
    trustExitCode = true
    keepBackup = false

See this Reference and search for "mergetool"
EDIT: according to the author's comment (sorry I can't spell your name) the [merge] tag is mandatory even for diff.
Comment: actually there are already answers:

http://stackoverflow.com/questions/12175867/setting-diffmerge-as-visual-git-difftool-not-working

http://stackoverflow.com/questions/9627670/git-merge-compare-tool-setup
Comment: how is that done for opendiff?  Also, `merge.tool` is already set, as you see in the config file: `[merge]` and `tool` under it, meaning it is `merge.tool`
Comment: ok, click on the first link to another question I provided in a comment. I made a mistake, I meant you need both merge.tool and mergetool.. I copy it here for "opendiff": `[merge]
    tool = opendiff
[mergetool "opendiff"]
    cmd = \"path/to/opendiff\"  --result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"
    trustExitCode = true
    keepBackup = false`
Comment: ok it seems to work... the code in comment and code in answer now are the same?  For one thing, the backslash shouldn't be needed, as it is already in the text file but not for the shell command line.  Another thing is that, even though it is for `git diff`, the `[merge]` section actually affects it, it is strange.
Comment: yes I edited so that the post has the right code. you can edit the post to specify the exact syntax if you want.


How we get registration id from c2dm (Android)?

Question: On Android applications, how to get Registration Id?
Answer: From the C2DM documentation
This is the sequence of events that occurs when an Android application running on a mobile device registers to receive messages:

The first time the application needs
to use the messaging service, it
fires off a registration Intent to a
C2DM server. This registration Intent
(com.google.android.c2dm.intent.REGISTER)
includes the sender ID (that is, the
account authorized to send messages
to the application, which is
typically the email address of an
account set up by the application's
developer), and the application ID.
If the registration is successful,
the C2DM server broadcasts a
REGISTRATION Intent which gives the
application a registration ID. The
application should store this ID for
later use. Note that Google may
periodically refresh the registration
ID, so you should design your
application with the understanding
that the REGISTRATION Intent may be
called multiple times. Your
application needs to be able to
respond accordingly.
To complete the registration, the
application sends the registration ID
to the application server. The
application server typically stores
the registration ID in a database.
The registration ID lasts until the
application explicitly unregisters
itself, or until Google refreshes the
registration ID for your application.
Answer: Here is a link to the C2DM page. http://code.google.com/android/c2dm/index.html#registering
At the bottom of the page there are links to an example app which uses C2DM.
Basically you need to declare a receiver to receive the registration_id from Google and then fire off a registration request like so:
<code>Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); // boilerplate
registrationIntent.putExtra("sender", emailOfSender);
startService(registrationIntent);
</code>


Subcategory of a category consisting of collection of objects

Question: The following is Exercise 3.7 from Aluffi's Algebra: Chapter Zero (available here):

A subcategory $C'$ of a category $C$ consists of a collection of objects of $C$, with morphisms $\operatorname{Hom}_{C'} (A,B) \subseteq \operatorname{Hom}_C (A,B)$ for all objects $A, B$ in $\operatorname{Obj}(C')$, such that identities and compositions in $C$ make $C'$ into a category. A subcategory $C'$ is full if $\operatorname{Hom}_{C'} (A,B) = \operatorname{Hom}_C (A,B)$ for all $A,B$ in $\operatorname{Obj}(C')$. Construct a category of infinite sets and explain how it may be viewed as a full subcategory of set.
Comment: On second thoufgt, you are right. One would actually *define* the category of infinite set as the full subcategory of **Set** whose objects are the infinite sets ... Hm, just write that down, i.e. "Let $Obj(C')$ be ... and for infinite sets $A,B$ let $\operatorname{Hom}_{C'}(A,B)=\operatorname{Hom}_{\mathbf {Set}}(A,B)$ ..."
Comment: Yes, that works well. What have you tried? There is almost nothing to do.
Comment: That is the question. I am confused because the question does almost all the work
Comment: Let $Obj(C')$ be what?
Comment: Let $Obj(C')$ be the class of infinite sets.
Answer: In general, if $C$ is a category and $S \subseteq \mathrm{ob}(C)$ is a subclass of its objects, there is a unique full subcategory $C' \subseteq C$ with $\mathrm{ob}(C')=S$. This is trivial - nothing has to be proven. In the "exercise", $C$ is the category of sets, and $S$ is the class of all infinite sets. We get the category of infinite sets with maps betweem them.
Comment: Done? Is that all to the exercise


Xgboost Feature Importance shift

Question: If I plot the feature importance of my xgboost model I get for example f10,f3,f7,f99,... as the most important features.
Now I decided to remove f3 and I imagined the new feature importance would be f10,f7,f99,... but what happened is: f10,f18,f99,f50,...
Xgboost seems to choose an entire different approach or something.
Can someone clarify? How can f7,f99 be such important feature but if I remove f3 they become useless????
Comment: Is the shift you observed even real?  Have you quantified the variance in your feature importances using, for example, the bootstrap?  You could very easily be reacting to natural uncertainties in the quantities being estimated.
Answer: You should consider the interaction or combined effect between features, so is very reasonable to you results. But if the features is redundant (highly correlated with other features) , remove it will not affect the results.
Answer: XGBoost website answers your question with a good example, which is partially answered by jumboRumbo. As it says:

In boosting, when a specific link between feature and outcome have been learned by the algorithm, it will try to not refocus on it (in theory it is what happens, reality is not always that simple). Therefore, all the importance will be on feature A or on feature B (but not both). You will know that one feature have an important role in the link between the observations and the label. It is still up to you to search for the correlated features to the one detected as important if you need to know all of them.

So, as you remove one feature, you don't get to keep the exact order for feature importance again, unless the features were completely orthogonal (uncorrelated).

Xgboost Feature Importance shift


Example of Darmois Skitovitch theorem

Question: In looking at something, I stumbled across the awesome Darmois-Skitovitch theorem:
Define two random variables $y_1$ and $y_2$ as linear combinations of independent random variables $s_i$ $(i=1, · · · , q)$:
$$y_1=\sum_{i=1}^q\alpha_i s_i$$
$$y_2=\sum_{i=1}^q\beta_i s_i$$
Then, if $y_1$ and $y_2$ are independent, all variables $s_j$ for which $a_jb_j \neq 0$ are Gaussian.
Although not explicit in the theorem, this seems to indicate that if some of the $s_j$ are Gaussian, you can have some of those $a_jb_j \neq 0$ and have $y_1$ and $y_2$ be independent. I tried to create some simple examples of this, but have not been successful. It is easy to do if the $s_j$ are not independent, but that's not what I'm looking for. Anyone have a good example (or way of looking at it)?
Comment: @Xi'an yes, I'm looking for an example where $y_1$ and $y_2$ are independent but where they are each linear combinations of random variables with some coefficients for both being non-zero.
Answer: Let $X_1, X_2$ be iid $\mathcal{N}(0,1)$
Then $Y_1 = X_1 + X_2$ and $Y_2 = X_1 - X_2$ are independent.
This is also an example of the stricter Kac-Bernstein theorem.
Example: Throw two darts at a 1D target. Each throw is independent. If the distance between the two darts and the summed distance of the two darts from the center are independent then the distance of each dart from the center is a Gaussian variable.
Comment: This is literally just repeating the theorem; I think he wants examples of $X_1$ and $X_2$ that can produce the phenomenon
Comment: Added concrete example
Comment: Thanks! Can I look at it this way? If $X_1$ and $X_2$ are both, for example $N(0, 1)$ then $Y_1 = X_1 + X_2$ and $Y_2 = X_1 - X_2$ are independent, right? If that's right, I'll need to work out some examples why that works when $X_1$ and $X_2$ are Gaussian, but not when they are other distributions.
Comment: @roundsquare yes, see Kac-Bernstein theorem and https://math.stackexchange.com/questions/1091111/independence-of-sum-and-difference-for-random-vectors
Comment: very nice example
Comment: @PierreGourseaud thank you very much! This is a great example - once I worked it out (not that hard as it turns out), it also helped me to see why the normal distribution is "special" as relates to the Darmois-Skitovitch theorem.
Answer: It works when they are Gaussian because they have zero covariance, and zero covariance implies independence for Gaussian distributions. It is not independence for non-Gaussian distributions. For example, if the variables are uniform.

Example of Darmois Skitovitch theorem


Do you need to look at keys for intervals?

Question: Say you have a starting note that is written on B. Would you have to fill out all of the sharps that the key of B has to find out the interval?
Like if you had one note on B and the other was on D sharp, would that mean it would be an augmented third, because of the key?
Comment: your question seems unclear to me: 1. what instrument do you play? what do you know about chords and intervals? and your example: do you mind a tune  or a chord? more information would avoid "wrong" answers, (a. not concerning your question.
Answer: Yes, the typical approach is to determine the interval based off of the major scale of the bottom pitch.
Given the interval from B up to D♯, we would first conceptualize B major, which has five sharps: F♯, C♯, G♯, D♯, and A♯. Since the D♯ is in the key of B major, this is a major third above B.
In order for this to be an augmented third, we would have to raise this D♯ one half step further to D (D doublesharp).
Comment: Wouldn't B to D# be an augmented third? Because it is an extra half step up. If it was B to D natural that would be a major third right?
Comment: B to D would not be a major third, because D is not in the major scale of B; only D♯ is. B up to D is only a *minor* third, since D is in the B-*minor* scale.
Comment: I understand. Would you have to mark the D sharp in the interval, or would you leave it blank?
Comment: I'm not sure what you mean. If you're writing a major third above B, you need to clarify D♯. If you're asked to notate the interval from B up to D, this would just be a minor third, and you would *not* write in a ♯ for the D, because that would change it to a major third.
Comment: Okay, do you also have to think about the E to F being half steps (and B to C) as well with this method?
Comment: Unfortunately I'm not sure what you mean here, either. It's important to know that those two are half steps, but we can determine B up to D♯ without knowing those two half steps.
Comment: If you had note B and wanted to go up to C, would that be a major second? Since B to C is a half step, and since there is another half step from the sharp from the key. Thanks for the help.
Comment: Always remember to *think of the major key of the lower note*. If we're measuring B to C, think of B major. Since B has a C♯ in it, a major second above B would be C♯. Since this is just C natural, this will be a *minor* second.
Comment: It's a bit dangerous stating 'B>D is a *minor* 3rd because D is in the B*minor* scale'! That bit is true, but - the statement is implying that all minor intervals are minor because they're in the minor scale. Not necessarily a criticism, but no doubt someone will go away with that impression!
Comment: I'd like to know which piece contains an augmented 3rd - except one by Bela Bartok ;)
Answer: Just adding notation visuals - otherwise @Richard answered the question.
You must consider both key signatures and accidentals.

With no key signature and no accidentals, B natural and D natural, minor third

With no key signature and accidental sharp on D, B natural and D sharp, major third

With key signature of 5 sharps and no accidentals, B natural and D sharp (from the key signature), major third

With key signature of 5 sharps and accidental double sharp on D, B natural and D double sharp, augmented third (enharmonically a perfect fourth)
Bonus items!

Key signature of two flats and accidental sharp on D, B flat (from the key signature) and D sharp, augmented third (enharmonically a perfect fourth)

Key signature of two flats and no accidentals, B flat (from the key signature) and E flat (from the key signature), perfect fourth

Minor third = 3 half steps
Major third = 4 half steps
Augmented third/perfect fourth = 5 half steps

Notice how the combination of key signatures and accidentals of notation make clear and unambiguous whether two pitches are one of two enharmonic possibilities.

EDIT
A small addition to address directly the OP's original scenario: a B majro key signature with notes B natural and D sharp notated.

one note on B and the other was on D sharp, would that mean it would be an augmented third, because of the key [B major]?

This is literally what the question posed. The sharp on the D is redundant, because there is already a sharp in the key signature. It's the exact same meaning as...

If the D sharp had been altered, then the sharp could be used to restore it back to the D sharp of the key signature.

If the D was lowered with a natural sign, it will stay D natural until the end of the bar. If you want to set it back to D sharp before the end of the bar, add the sharp.

When the bar with D natural ends, the D is assumed to go back to the key signature as a D sharp. A sharp in parenthesis can be used after a new barline and reminder. This is called a courtesy accidental.
Comment: Bonus point: In some countries classical players know Bb as B and B as H.
Answer: Intervals seem to confound many of us. And to make it worse, each pair of notes when played, can be called at least two different names.
The actual key any two notes, therefore the interval between them, can help, but that in itself can bring confusion. Minor intervals are found in major scales, and vice versa.
Intervals are always calculated from the lower note. In your case, it's B. Two factors are needed to establish an interval's name. The first is the letters themselves. Here we count B - C - D. Never mind ♯s and ♭s: just simple letter counting. So, we establish it's a third - of some kind.
Next we address how many semitones are keeping the two notes apart. So counting - B, C, C♯, D, D♯. that's four. 4 semitones makes it a major third.
If you wanted to, you could reason that in key B major, going from B to D♯, you reach the third note in that scale, so yes, it is a major third. But beware, not every interval in a major scale/key will be major. Unless the lower note is root. But even then, P4 and P5 are neither major nor minor! And the same stands for minor. Without getting too deep, D♯ and F♯ are both in B major, but their interval is minor third.
Answer: Intervals are absolute.  They do not change with different key signatures.  B to D♯ is a major 3rd whether the ♯ came from a key signatore or an accidental.
Accidentals are not cumulative.   If there's a B major (5 sharps) key signature, a notated D will be D♯.   Put a ♯ accidental in front of it (maybe as a reminder after a previous D♮) and it's still just D♯, not D doublesharp.
Yes, a useful way to work out intervals is to consider the major scale rooted on the lower note.  If the upper note fits this scale, the interval is major (or perfect if it's a 4th, 5th or octave).  Note that it matters whether you call the note D♯ or E♭.   B to D♯ will be some kind of a third because there are three letters included in B, C, D.    B to E♭ will be some kind of a fourth, because B, C, D, E.    You may feel this is an arbitrary distinction!  But as you continue your development in reading and analysing music you'll probably see why.
Answer: The written notes in the staff system are not so helpful to understand the intervals (minor, major, diminished or augmented.
You better draw a keyboard and the interval patterns, the note names on the right side of the sheet notation or below of the system.
https://www.musictheory.net/lessons/31
If you tip on an interval in the posted link the keys and the notations will be shown.
Always keep in mind the bc and ef are half steps (in the staff this is not obvious- but on the keyboard by the structure of white and black keys it is evident: 2 white keys in neighborhood, no black key between them = steps of half tones in the root scale are minor seconds!
while all other steps of white keys - with a black key between - them are major seconds.
You have to know by heart where there are minor seconds in the staff system otherwise you won't be able to develop all the other intervals.
(Then you'll notice that B-D is  a minor 3rd and B-D# is a major 3rd. To answer your question: If the starting note is B and the next D# we are probably in B-major and you have to play F#,C#,G#,D#,A#.
But a sequence B - D# in the beginning of a tune could also be the upbeat of a song in E-major or e-minor! The latter would only need a F# and probably the augmented 7th and 6th (D#, C#)  while E-Major would have 4 sharps: F#,C#,G#,D#.)
Answer: It all depends on the way it's notated, the key is irrelevant (there might not even be a key). If you notate notes as B and D (whether those notes are sharp, natural or flat) then this is always a third. The nature of the interval (major, minor etc.) depend on the number of semitones between the notes.
So we have

B-flat to D-flat, B to D, B-sharp to D-sharp ==> minor third
B-flat to D, B to D-sharp, B-sharp to D-double-sharp ==> major third
B-flat to D-sharp ==> augmented third
B-sharp to D ==> diminished third

Or you can take the same interval, notate it in different ways and the name changes:

B to D-sharp (or C-flat to E-flat) ==> major third
B to E-flat ==> diminished fourth
Answer: Ignore the confusing standard notation, ignore the confusing sharps and flats, ignore the confusing key signatures, and ignore the confusing black/white piano keys.  Restrict yourself to only the confusing note names and confusing interval names, and then simply look at the sequence of consecutive notes:
A   B♭  C♭  C   D♭  D   E♭  E   F   G♭  G   A♭  A
G♯♯ A♯  B   B♯  C♯  C♯♯ D♯  D♯♯ E♯  F♯  F♯♯ G♯  G♯♯
0   1   2   3   4   5   6   7   8   9   10  11  12

|                             0 steps — unison, diminished second

|___|
    |___|
        |___|                 1 step — minor second, augmented unison, semitone

|______|
    |_______|
        |_______|             2 steps — major second, diminished third, tone

|___________|
    |___________|
        |___________|         3 steps — minor third, augmented second

|_______________|
    |_______________|
        |_______________|     4 steps — major third, diminished fourth

|___________________|
    |___________________|     5 steps — perfect fourth, augmented third

|_______________________…     6 steps — augmented fourth, diminished fifth
|_______________________…     7 steps — perfect fifth, diminished sixth
|_______________________…     8 steps — minor sixth, augmented fifth
|_______________________…     9 steps — major sixth, diminished seventh
|_______________________…    10 steps — minor seventh, augmented sixth
|_______________________…    11 steps — major seventh, diminished octave
|_______________________…    12 steps — perfect octave, augmented seventh

Comment: Confusing is the right adjective to use! I'm confused by this! OP started at B, not A.
Comment: Why is standard notation, sharps and flats etc. confusing?  Been around for hundreds of years and seems to have worked pretty well up to now.  Sorry, but I think this is bad advice.
Comment: "Ignore the confusing standard notation..." bad advice. Reading from staff make _immediately_ apparent the basic intervals like third, fourth. The specific quality like major, minor, diminished, or augmented then come from the key signature and accidentals.
Comment: @MichaelCurtis, that after seeing the obvious part one then has to look at the key signature and figure it out just illustrates how overly complex standard music notation is.  I'm not suggesting that this notation will ever be redesigned to be based on 12-semitones rather than on the current black/white piano keyboard. But when learning, until one is very familiar with the standard notation it is a lot easier to work out and understand what is actually going on if one discards the additional complexity.
Comment: "...until one is very familiar with the standard notation..." if you don't learn the keys and don't learn notation, of course it will be confusing. I think the better advice it: learn to read.
Comment: @MichaelCurtis, I'm not saying not to learn standard notation.  I'm saying that there are two ways of learning, some preferring one and some the other.  I myself like to start with a mathematical understanding of the simple principles (e.g. 12 semitones, and intervals that add obviously (4+5=9 vs. 3rd+4th=6th) and principles that apply generally (major chord intervals are …5-4-3-5-4-3…, and minor …3-4-5-3-4-5…) before learning notation that is based on tradition and the artifacts of keyboards.  For someone like me, understanding the principles without the "confusing" notation makes it easier.


Server 2012 GPO: PowerShell Script on Computer Startup not running

Question: I've got a couple of Server 2012 instances on Amazon EC2 and I'm in the process of setting up the GPOs. All of the settings of the GPOs are being applied fine, except none of the PowerShell scripts specified on computer startup are actually being executed. The scripts are sitting on a UNC share which has Authenticated Users applied to it with full permissions. I'm assuming it probably has something to do with the Execution Policy, but I'm not sure how to automatically bypass it. I could just go in each instance and bypass the Execution Policy, but that's obviously not a good idea, plus I'm eventually going to connect Windows 7 computers that will be running the same scripts.
How can I get the scripts to actually run? Google searches hasn't yielded a whole lot...
Current Permissions
Share - Authenticated Users (Full)
NTFS - Everyone (Full); CREATOR OWNER (Special); SYSTEM (Full)
Comment: What is the output from Get-ExecutionPolicy, and does the script run if you launch it from the shell prompt?
Comment: Because I overwrote it with a GPO, Get-ExecutionPolicy says Unrestricted. If I open PowerShell and manually run it, the script works fine.
Answer: Late reply, but your problem is probably the default of 2012 to delay logon scripts. Try a lower setting at:
Computer Configuration\Policies\Administrative Templates\System\Group Policy\Configure Logon Script Delay
Answer: If its a computer policy, authenticated users isn't what you want. You need to give Domain Computers read access.
Comment: Computers are a member of Authenticated Users.
Comment: I swear I've tried that before... I'll give a shot again, brb.
Comment: Nope, this did not work. The share permissions give `Domain Users` and `Domain Computers` full access and the NTFS permissions give `CREATOR OWNER`, `SYSTEM`, `Domain Users` and `Domain Computers` full access as well. Is there anything else? Manually running the script works fine if that matters...
Comment: All that means is that you had more than one problem :) Are you sure your script executes correctly as `SYSTEM`, which is the context that it will run as in this case? Grab a copy of `psexec` and run `psexec -s cmd` and call your PS script from there. It will execute as `SYSTEM` and hopefully give you some useful output.
Comment: So, using `PSEXEC -S CMD` followed by `POWERSHELL -Command "Test-Path '\\2012-F-01\Software$\Scripts\Computer Startup.ps1'"` results in `Test-Path : Access is denied`. It's gotta be permissions, but I'm not sure what else to add in the permissions...
Comment: Changing the share permissions to `Authenticated Users` allows the `Test-Path` to work, but the script still doesn't run...
Comment: I got `POWERSHELL -File "\\2012-F-01\Software$\Scripts\Computer Startup.ps1"` to work by bypassing the Execution Policy, so I set it to Unrestricted through a GPO and it still does not work... I just don't get it...
Comment: Wait, you're using share permissions *and* NTFS permissions? Generally, share permissions are set to `Everyone - Full Control` and you use NTFS permissions to control access. Can you update your question with both the Share *and* NTFS ACLs?
Comment: I've updated my question with the ACLs.
Answer: I think PowerShell scripts run remotely from a Windows share are considered part of the Internet, so you have a few options:

The Execution Policy needs to be Remote Signed and you have to sign the scripts.
The Execution Policy needs to be Unrestricted.
Copy the script locally, at which point you can run it if your Execution Policy is Remote Signed or Unrestricted.
When calling powershell.exe, use the -ExecutionPolicy parameter with a value of Unrestricted
Comment: I'm in this exact situation, but can't find any Microsoft documentation advising powershell computer startup scripts need special consideration since the batch scripts work fine. Can you cite any official sources on the topic?
Answer: You could instead store the files with the GPO files. when you go in to put in the script you should see a "show files" button.  Click that to bring up the folder in which the scripts should be placed.  Once in that folder you can simply click "Add" and choose the file.
Otherwise, you can add Domain Computers with read access, as the computers will be the ones authenticating against the share at startup, not the users.
Comment: Domain Computers are a member of Authenticated Users.
Answer: This is an old topic but the answer most likely is there are SPACES in the filename and/or path of the PowerShell script in the Startup Properties of the GPO.  To fix simply put double quotes around the full path of the PowerShell Script Name that is not running in the Startup Properties of the GPO.
Startup "Script Name" before:
\\SERVERNAME\Scripts\Install KBs\Install KBs.ps1
This shows no Last Run in GPResults.  The EventLog is no help it shows ErrorCode 0 ScriptElaspedTimeInSeconds 0.  However in the registry at
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\#\#, where # is numbers, it shows the real ErrorCode 0xfffd0000 (4294770688).  This is due to the script not being found - due to the space(s).
Startup "Script Name" after:
"\\SERVERNAME\Scripts\Install KBs\Install KBs.ps1"
Now in GPResults the Last Run for the script shows it ran.  The registry, at the key above, shows ErrorCode 0x0, which is normal.
This solved and fixed solution is tested on Windows 7 Enterprise.  I did not need to change permissions but AUTHENTICATED USERS with Read permission was present which allows the Computer Object to Read the PowerShell script.
Answer: I ran into the same issue. When I attempted to run the script from the \domain.local\netlogon folder, it gives me an error that the execution policy doesn't allow running remote scripts. I ran get-executionpolicy and it's set to "Restricted". I ran set-executionpolicy remotesigned but that didn't help because it's not digitally signed.
I ran get-help about_signing and it tells me i have to sign the script with a digital certificate from a CA or self-signed cert. A lot of work just to write a Windows 7 powershell logon script. However, it runs without a problem on systems with a higher version of Powershell (Server 2012 R2, Windows 7 with PS5). Now I have to figure out how to install WMF5.0 on each workstation without WSUS or suck it up and sign the stupid script.
Thanks Bill Gates...


Kruskal-Wallis and Mann-Whitney U give different results

Question: For my thesis, I am comparing the importance of "comfort" (measured using a 6-point Likert scale) among four groups of people (participants who prefer traveling by plane, by train, by coach and by motor vehicle). However, I get different significance levels when doing the Kruskal-Wallis test and the Mann-Whitney U test.
In the Kruskal-Wallis test I get:
chi-squared = 12.262, df = 3, p-value = 0.006537
When performing the Mann-Whitney U test (with "bonferroni" correction), however there is no statistical difference among the groups:

How should I interpret the data & is there another test that could give me better results than the two I performed?
May I note that the number of data sets highly varies between the 4 groups (n=272, n=68, n=9, n=140).
Comment: Bonferroni adjustments to guard against 'false discovery' are based on an inequality and are often quite conservative ('reluctant' to find significant differences). So it often happens that K-W finds significant differences, but Bonferroni-adjusted MWW tests do not. // In your case, the very small sample size (for coach?) results in very small power for MWW. // My guess is that your most extreme difference is btw Plane and Train (with sample sizes 272 and 140?). This may drive the KW result, and the unadjusted P-value btw Plane and Train for MWW must also be near 0.01.
Comment: You have not shown much details, so one can only speculate what is going on. If you are free to share more details (e.g, summary statistics for the four levels), maybe one of us can give a more detailed explanation.
Comment: The post hoc pairwise comparison test after the omnibus KW is called Dunn test. It is not just MW but a version of MW.
Comment: [Mann-Whitney is an inappropriate test following rejection of the Kruskal-Wallis](https://stats.stackexchange.com/questions/25815/post-hoc-tests-after-kruskal-wallis-dunns-test-or-bonferroni-corrected-mann-wh/95270#95270).
Answer: Here are simulated data that may be sufficiently similar to yours to
illustrate my Comments. Likert scores are simulated in R, using various
vectors of preference for the four modes of transportation. If you use
the same seed I used, you will get the same hypothetical data. [R converts
these vectors to probabilities before use in sample.]
set.seed(2020)
plane = sample(1:6, 272, rep=T, p = c(1,2,2,3,3,3))
auto  = sample(1:6,  68, rep=T, p = c(1,2,3,3,2,1))
coach = sample(1:6,   9, rep=T, p = c(1,2,3,3,2,1))
train = sample(1:6, 140, rep=T, p = c(1,2,3,2,2,1))
all = c(plane,auto,coach,train)
gp = rep(1:4, c(272,68,9,140))

In the boxplot below, widths of boxes indicate varying sample sizes, and notches
in the sides of the boxes are approximate nonparametric confidence intervals for
group medians (calibrated so that two nonoverlapping intervals suggest a significant
difference in location). [The sample size for Coach is too small for a meaningful
CI.]
boxplot(all ~ gp, varwidth=T, col="skyblue2", notch=T,
        names=c("Plane","Auto","Coach","Train"))

A Kruskal-Wallis test finds significant differences among the centers of the populations at the 5% level.
kruskal.test(all ~ gp)

        Kruskal-Wallis rank sum test

data:  all by gp
Kruskal-Wallis chi-squared = 8.6787, df = 3, p-value = 0.03388

However, a nonparametric Mann-Whitney-Wilcoxon (rank sum test) between
Plane and Train give P-value about $0.012,$ but one version of
the ad hoc Bonferroni P-value is about $0.07$ (not significant at 5%).
wilcox.test(plane, train)

        Wilcoxon rank sum test with continuity correction

data:  plane and train
W = 21863, p-value = 0.01212
alternative hypothesis: true location shift is not equal to 0

Moreover, MWW comparisons of Coach with other groups shows no significant
difference (even without a Bonferroni adjustment), on account of the small
sample size for Coach.
wilcox.test(plane, coach)

        Wilcoxon rank sum test with continuity correction

data:  plane and coach
W = 1318, p-value = 0.6913
alternative hypothesis: true location shift is not equal to 0

Note: In these circumstances, my personal opinion is that it it's OK
to declare a significant difference between Plane and Train because
the K-W test finds 'difference(s)', of which at least this difference must be one.
But I would not feel comfortable finding differences involving Auto and Coach without Bonferroni (or some other) protection against 'false discovery'.


Combining a linear Kalman Filter with additional linear constraints?

Question: This question contains a relatively long prelude, since I want to explain as clearly as possible the motivation for the question. It may well be the case that I am asking the wrong question (i.e. there is a better way of solving the problem than what I am attempting) and I would welcome any good answers along those lines.
I have implemented a real time map for a physical quantity over a large region (a continent) that combines many hundreds of data points and uses a Kalman Filter to jointly estimate the coefficients of a linear combination of basis functions (the map) plus a large number of instrumental biases and other nuisance parameters.
A problem with this approach is that the data points are distributed in a very uneven way; some regions have a lot of closely spaced data points and other regions are much more sparse. Since the map is represented by a global set of basis functions, there is no real happy medium in choosing the best order of expansion for the generating function. I either have a too high order for the sparse regions leading to spurious artefacts, or too low order for the data rich regions, smoothing out real structure that is supported by the data.
In order to be more adaptive to local data density, I am thinking of using some kind of radial basis function (RBF) approach utilising unsupervised clustering (e.g. K-means) to distribute a set number of basis function origins to match the local data density. I still need to use some kind of filtering to estimate the nuisance parameters along with the map, but this RBF approach maintains the linearity of the system so the Kalman Filter can be used. I'd 'just' need to experiment with different forms of the basis functions and their parameters, the number of basis functions to use etc.
However, it would be ideal to also incorporate a smoothness constraint, as in the case of a thin plate spline (TPS). This can be expressed as an additional set of linear constraints on the map values at each basis origin and the standard TPS formulation has a closed form solution. What I would like to do is incorporate these linear constraints into the filtering mechanism, as is required due to the noisiness of some parts of the system, rather than the one off minimisation of the TPS. I can vaguely conceive of how this might be done, but my linear algebra skills are not up to the task of fully deriving this (or even demonstrating that it can be done).
So my question is whether this approach is feasible and if so what the form of the resulting filter looks like. Is there a specific piece of terminology that succinctly describes what I am trying to do? Is there a standard result out there for this situation?
Comment: Among other spatio-temporal techniques, the *Kriged Kalman filter* can
be a solution. The spatial smoothing captures the spatial low
frequencies thanks to the *Principal Kriging Functions* and seems
comparable to that of thin plate splines. RBF are used if the covariance
kernel is square exponential.

http://www.southampton.ac.uk/~sks/research/papers/sahumardia05.pdf
Comment: @Yves did you want to make that an answer?
Comment: Thank you, Bogdanovist. I soon edit the text and turn it into a answer.
Answer: Kalman filtering with constraints on the elements of the state vector has been dealt with in the literature and is easy to implement. A few references follow:
Chia, T.L. and Simon, D. and Chizeck, H.J (2006) Kalman Filtering With
   Statistical State Constraints, Control and Intelligent Systems, vol. 34(1),
   doi 10.2316/Journal.201.2006.1.201-1556.
Simon, D. (2002) Kalman filtering with state equality constraints,
   IEEE Transactions on Aerospace and Electronic Systems, vol. 38(1),
   p. 128--136. doi 10.1109/7.993234.
Simon, D. (2010) Kalman filtering with state constraints: a survey of linear and
   nonlinear algorithms, IET Control Theory & Applications, vol. 4(8), p. 1303.
   doi 10.1049/iet-cta.2009.0032
Also the book by Simon, D. Optimal State Estimation: Kalman, H Infinity, and
Nonlinear Approaches, Wiley, 2006 contains a summary on the topic.
Answer: Among other spatio-temporal techniques, the Kriged Kalman filter can
be a solution. The spatial smoothing captures the spatial low
frequencies thanks to the Principal Kriging Functions and seems
comparable to that of thin plate splines. RBF are used if the covariance
kernel is square exponential.
See
Sujit K. Sahu and Kanti V. Mardia
A Bayesian kriged Kalman model for short-term forecasting of air pollution levels Applied Statistics 2005, vol. 54 pp. 223–244.
as well as later papers by the authors on spatio-temporal modeling.


A simple question about a simple ODE

Question: Consider $\frac{dy}{dx}-\frac{y}{x}=0$. Rewritten as $\frac{dy}{dx}=\frac{y}{x}$ we instantly see the equation satisfying the ODE is $y=Cx$, which we would also get by separation of variables followed by integration, with $C$ the constant of integration.
The only constraint on the linear solutions in this case is that they must include the origin. If we decided to actually evaluate the ODE at any point on a function solving it, we would have $C-\frac{Cx}{x}=0$, but this equation becomes undefined at the origin, which happens also to be the only point in the plane required to be in the solution for $y(x)$.
My question: Is there a convention to ignore points where the ODE becomes undefined (if evaluated) so long as wherever it is defined the ODE is satisfied, even if $y(x)$ is defined at that point? It seems that the closest fitting function is $y=\frac{Cx^2}{x}$ in terms of being defined anywhere the ODE is defined. But that also seems like a silly solution compared to the linear one. Sorry this is such a basic question, but I'm trying to carefully check my understanding of how setting up simple ODEs affects the classes of satisfying equations.
Answer: First of all simply put  $\dfrac{y}{x}$ has the form $\dfrac{0}{0}$ but is well defined, no singularity at the origin, being equal to slope constant $C$.
This constant need not be a priori known, it can as well be a result of the subsequent integration process.
A  similar curve $y= \dfrac{\sin x}{x} $ has form $\dfrac{0}{0}$ at the origin which also evaluates similarly to $1,$ using the L'Hôpital's Rule.
Comment: Next please read about L'Hôpital's Rule to evaluate indeterminate quotients/forms.
Comment: I accept without understanding, am looking at calculus for the first time in 20 years and no longer remember why this would be, this question occurred to me in a first chapter on integration. If you cared to elaborate a bit, I'd appreciate it, though I'm sure this will make sense in a few chapters.

A simple question about a simple ODE


How to notate this two-voice syncopation in 12/8 time?

Question: Currently working on this composition which is in 12/8 time. I want the rhythm in the left hand to be like this:

But the notation looks difficult to read. Also tried this:

But the C octave chord is a bit too short (I want it to be sustained the length of 10 eighth-notes). How should I best notate this without making the notation look messy?
Comment: Welcome to Music.SE! Great first question.
Answer: Yes, this is tricky. It may depend on what you have in the remaining voices/hands/parts, but one possible solution is to use stem direction to your advantage:

By using stem-down notes for the held Cs and stem-up notes for the moving line, it minimizes the confusion on the large beat 3 (where earlier the E looked as if it came after the dotted-quarter Cs).
There are a few weaknesses here:

The dots on beat 3, which can certainly be moved closer to the Cs as desired.
The hidden dotted-quarter rest on beat 1 looks a bit swallowed up here. But I'm assuming that a moving line in another voice will clarify where this first E is placed. If not, I'd recommend making that rest visible.
Lastly, these stem directions may not make any sense with your composition; if the held Cs are really viewed as an "upper voice" in this staff, then this may not be an ideal solution.

A scorched-earth solution may be to just briefly include a third staff (think of the famous Rachmaninoff C-sharp prelude here), but that should probably be your last resort.
Alternatively, you could write one of the voices with smaller notes.
I'd be curious to hear what recommendations others have. My sense is that this may just be one of those examples that will always look a little wonky, but I'd love to be proven wrong!
Comment: @PiedPiper Yes, I tried to address that in my discussion on the weaknesses of this approach.
Comment: @PiedPiper No worries, I get a bit long-winded sometimes ;-)
Answer: @Richard makes some very good points and suggestions but because of the voices overlapping in note length AND register it's going to be messy no matter what. These two may not be ideal but they are possible solutions:

On the first the slurs suggest holding the note till beat 10.
The second using the sustain pedal wont work if you do not want the E on beat 5 to ring out till beat 10.
Like Richard I'm curious to see what other solutions are offered.
Comment: Strongly favour this version. The content isn't really that involved, no point writting it in a cluttered style. If afraid that the performer might not perform the long-ringing Cs right, better to just write a clarifying remark.
Answer: Here are my preferred options, one a variation on Richard's solution.

I think the first option is cleanest, though could give pause at first sight.
The second option is explicit, but I think a bit visually complex. The variation on Richard's solution I propose is keeping the "smaller" tied notes contained within the larger ties -- i.e., not crossing the chord stems. I also lengthened the stems a bit to help clarify visually.
I'm largely agnostic on the rest placement, though I tend to prefer the initial dotted-quarter rest be hidden, and a quarter rest at the end rather than two eighth rests. The "inner" eighth rest is the only one that is absolutely necessary, and I've played with its vertical placement a bit.
Comment: I think option 1 looks the cleanest of all so far. Crossing the imaginary bar lines on the syncopations improves the look drastically. I personally would prefer to see the dotted quarter rest on beat 1 for clarity. Nice work.
Comment: @JohnBelzaguy That initial dotted-quarter rest is problematic. Above, below, between...? Maybe placing it immediately adjacent to the initial chord, opposite the stem?
Comment: I'd personally go with above since it's part of the "up" stems. You're right though, seems like there's no good place to put it!
Comment: FWIW: this was made with MuseScore 3.
Answer: This is somewhat cleaner and makes it clear where the E begins:
Comment: This looks very good. The only issue is the duration of the dotted half note C on the D.B. goes all the way to the end of the bar instead of ending on beat 10.
Comment: @JohnBelzaguy Since that C is re-struck on beat 11 the first C ends with beat 10.
Comment: I thought of that, it worked out well this time around!
Answer: Change to 3 staves
For the densest parts, you can add staves, e.g.
Comment: If you wrote out the original like this, it would be a good answer.
Comment: This is a confusing answer. The example you give is written on three staves because it's for organ. The lowest stave is played by the feet, and the two upper staves are played by the hands. Putting a piano part on three staves to express a complicated rhythm is a completely different idea.


Simulating state space model with AR(1) dynamics

Question: I asked a question similar to this previously:
https://stats.stackexchange.com/questions/99282/check-that-state-space-model-implemented-correctly
However I think I have a better handle on it now and want to re-ask it:
I simply want to simulate data from a state space model where the state variables follow an AR(1) process (see the code in the first link above).
Given the burn in issues (see link below) I assume it's better to determine empirically how many observations are required until the system reaches its theoretical unconditional variance then ensure that I simulate at least 2 times that amount before using the x(t) generated by the AR(1) process in my state space model.
http://www.mathworks.co.uk/help/econ/simulate-stationary-arma-processes.html
Q1.) If I want to simulate data from my state space model is it necessary to ensure that the AR(1) process is in it's equilibrium state first?
Q2.) From the simulated data I will be able to estimate the observation and state error variances as well as the AR(1) parameters and the unconditional  mean and variance of the process (averaged over many sample runs). Assuming these empirical values all match their corresponding theoretical ones, can I then be fully satisfied that the state space model which is based on the AR(1) process has been implemented correctly?
Q3.) How can I estimate what the likely error bounds should be on the parameters that I propose to estimate in Q2?
Baz
Comment: By 'simulating from a state space model' do you mean simply adding additive independent observation error?
Comment: yes I simply draw a set of normal N(0,\sigma_s^2) to add to the state equation to create the time series of the state variables (X(t)). I then take these and calculate the simulated data by multplying the X(t) by a known weighting matrix and adding observation errors N(0,sigma_o^2). I just wanna make sure that the series I have produced is "correct". I will then attempt to fit the data using a max likelihood.
Comment: The goal is to obtain simulated data which can then be used to test different fitting procedures.
Comment: What is the purpose of the weighting matrix?
Comment: The weighting matrix (which is constant) is simply matrix "B" shown on p35 here: http://pure.au.dk/portal-asb-student/files/48326397/Thesis_Jonas_M_ller_Christensen_284033_.pdf
Comment: I want to simulate data from the DNS model on p34 and then use the Kalman filter to fit it. Obviously by generating the series with known parameter values I can test how well the optimization scheme is working. It seems there are two possible "burn-in" issues. 1 The underlying AR(1) process requires a certain number of steps to reach it's equilibirium state 2.) The Kalman Filter itself has a burn in period before it converges. Up till now the convergence has not been very fast or even that accurate so I'm just wondering if one or both of these burn-in issues is causing the problem?
Comment: Yes I see. (no eq. on p34, however, I suspect you mean eq. 3.1 on p35). So you will simulate the process X_t according to the AR(1) representation and then you will add noise such that Y_sim = BX_t + e_t, where e_t follows N(0, sig^2). I will post a tentative answer to your questions below.
Answer: You are correct in that the AR(1) has a steady-state unconditional distribution that takes some time to equilibrate. The answer to whether you should only estimate parameters from a steady-state AR(1) process is negative, in general. E.g. you can start an AR(1) far away from its equilibrium, never allowing it to reach its steady-state, and still reliably recover the AR(1) parameters and error statistics. However, there ARE cases where it only makes physical sense to talk about the AR(1) at its steady state. For example, in linear stability analysis where the equilibrium deviations are described by an AR(1) model.
That said, you should be clear w.r.t what you are trying to estimate. I suspect you are, at least, trying to estimate the AR(1) matrix elements and the matrix $\textbf{Q}$? Because, conditional on those estimates (assuming all other error statistics are known), the 'process' (which I believe you mean $\textbf{X}_t$) is completely specified by running the Kalman filter.
However, that brings us to the question of the steady-state variance in $\text{Var}(\textbf{X}_t)$, as estimated from the Kalman filter. In a Bayesian context, the variance of $\textbf{X}_t$ early in the series is a function of your prior distribution at $\textbf{x}_0$ (i.e. you have to specify a mean and variance for $\textbf{x}_0$ to begin the filter). Then, after some number of iterations (i.e. after some number of data are used to sequentially update the prior distribution), $\text{Var}(\textbf{X}_t)$ will forget the prior and converge to its steady-state. The amount of time required to forget the prior is related to the relative contribution of process and observation error. If you have low relative observation error, the updating has a strong effect and the memory of the initial conditions is lost quickly; while oppositely, if the observation error is high, the initial conditions persist and steady-state is approached more slowly. There may be analytical results to make this more precise, but I don't know them from the top of my head. In my practise, I often do a suite of simulations to tease these effects apart.


Discrete Mathematics: $x\leq y+\epsilon \implies x\leq y$

Question:
Let $x$ and $y$ be real numbers. Prove that if $x\leq y + \epsilon$ for every positive real number $\epsilon$, then $x\leq y$.

I would like a hint as to how to prove this. Thank you. Pictorial proof would be nice too.

So this is how I word-smithed the answer given by the author of my accepted answer:
We will proceed by showing the contrapositve. We are given that
$$x\leq y+\epsilon \implies x\leq y,$$
so the contrapositive is resolved as
$$x > y \implies x>y+\epsilon,$$
or by substituting $x-y = \omega$ simply
$$\omega > 0 \implies \omega > \epsilon,$$
but if $\omega >0$, then $\epsilon = \frac{\omega}{2} > 0$; however, $\omega \leq \frac{\omega}{2}$ is false. Therefore, we can assert that for all $\epsilon > 0$
$$\omega\leq\epsilon \implies \omega \leq 0;$$
quod erat demonstrandum.
Here is my pictorial representation:
Comment: What is "discrete" about this?
Comment: Suppose it weren't so, i.e. $y < x$. Look for an $\epsilon$ violating the constraints.
Comment: @Trancot I have seen textbooks for linear give a definition and some properties of injective functions, should a question of this kind have a title "linear algebra:If we have an injective function bla bla"?
Comment: It is from a discrete mathematics textbook. Should a student studying discrete mathematics also have this problem in their discrete mathematics textbook, then they will find this of interest.
Answer: The claim is equivalent to showing that if $\omega\leq \epsilon$ for each $\epsilon >0$, then $\omega\leq 0$.
But, if $\omega>0$, then $\epsilon=\frac \omega 2 >0$ and $\omega \leq \frac\omega 2$ does not hold. Having proven the contrapositive, we can assert that $$(\forall\epsilon >0\;:\;\omega\leq\epsilon )\implies \omega \leq 0$$
Now let $\omega =x-y$.
Pictorially If for any $\color{green}{\epsilon >0}$ we choose, $\omega$ is to the left of  $\color{green}{\epsilon}$, it must be the case $\omega$ is to the left of the green bar, that is, on the red side $\color{red}{\omega <0}$ (strictly negative numbers) or that it is on the breaking point, that is $\color{orange}{\omega=0}$.

ADD The contrapositive of the assertion is $$\omega >0\implies (\exists \epsilon >0:\omega\not\leq \epsilon)$$ or, which is the same, $$\omega >0\implies (\exists \epsilon >0:\omega> \epsilon)$$
We proved the contrapositive with $\epsilon =\omega /2$.
Comment: Should not $\omega \leq 0$ be $\omega < 0$? Actually, no I guess not.
Comment: The claim is true if $\omega =0$. See how the proof of the contrapositive breaks down in such case, @Trancot.
Comment: See my most recent edit.
Comment: Fancy answer...+1.
Comment: @Trancot I added something.
Comment: That is right. $\neg(\forall)$ := $\exists$.
Answer: Consider $x,y$ be universally quantified, then
$$\forall \epsilon\ (x\leq y+\epsilon) \implies x\leq y$$
$$\neg (x\leq y)\implies \neg\forall \epsilon\ (x\leq y+\epsilon)$$
$$\neg (x\leq y)\implies \exists \epsilon\ \neg(x\leq y+\epsilon)$$
$$x>y\implies \exists \epsilon\ (x>y+\epsilon)$$
For $x>y$, we know $x>\tfrac{x+y}{2}=y+\tfrac{x-y}{2}$ and $\tfrac{x-y}{2}>0$, so it fits the bill.
Comment: @Angelo I edited it back out of principle. Can you please not randomly go and edit my answer without a warning? Yes, OP speaks of the situation the quantifier over $\epsilon$ goes over just positive numbers.
Comment: Really I do not understand what you mean. Anyway, your answer is correct and I like it, in fact I upvoted it.
Comment: @Angelo I don't think it's a common habit on this site to edit other people's words, unless it's a buggy or unreadable opening question
Comment: @Angelo Grumpy un-vote now? Well it's not a Wiki with textbook information, it's people posting text in their own name.
Comment: I just wrote that $\varepsilon>0\;$ and $\;\varepsilon=\frac{x-y}2$. I apologise if it bothered you so much. I did not have the slightest intention of annoying you. Sorry !
Comment: No, I have not un-voted, indeed your answer is correct and I like it.


Importing a 12gb MySQL database into PHPmyAdmin

Question: SO guys, we had legacy website that has a 12GB MySQL database. We decided to port the legacy website to WordPress and need to import the database into PHPmyAdmin without breaking the database and to implement this in the shortest possible time (although time is not such a critical matter if this can be done painlessly but correctly). So would appreciate if someone can guide me in the right direction and provide detailed instructions.
Thanks guys.
Comment: Do not import a 12 GB file through phpmyadmin, it was not designed to handle this amount of data. It will time out long before the script would be done.
Comment: Thanks for the reply. Yes I am aware of that and hence looking for an alternative.
Answer: I dont know much but i can recommend to back up you're files befored doing any transfers. If you have a fast internet speed then you guys can try to download the SQL database as a compressed file and dump it into the wordpress new database. The database for mysql should be in your cpanel folder (since all cpanel folders/designs are different it would be best to look up "where to find the msql database on hosting company name's cpanel" and once you find it then you can transfer it whereever is possible)
Answer: This is the easiest and most correct way.
<code>mysql -u username -p "dbname" < "path/to/bigdata.sql"
</code>
If you have FTP/SSH access, then this is the most probable way.

Upload your .sql via FTP
If you have access to CLI , just run the command above
Normally , this will be fast, but since its 12GB, it might take 30min-1hour depending on server resources.

You can also use other options like this one .
I've already experienced importing 61GB before with just this one-liner.
Comment: Thanks Ralph, I was not sure if I could use the command for such a large import. Will update tomorrow on how it went. Also please let me know if the command includes the "<" symbol?
Comment: @Tavy, yepp .. `<` is needed to tell mysql that you are doing an import.


Failing Fermat Primality Test

Question: Consider the following algorithm:
Suppose $n\geq 2$, and let FermatTest be an algorithm such that if $a^{n-1}\not\equiv 1\mod n$ then return composite.  If FermatTest yields $a^{n-1}\equiv 1 \mod n$, then it returns possibly prime.
Let $n\geq 2$ be a composite integer that is not a Carmichael number.  Let $a \in \{1,2,\cdots n-1\}$. Why is it that if I randomly select $a$, there is a 1/2 chance that the test will say that it is composite.  I understand the group theoretic reason, but I was hoping for a number theoretic argument.
This question is inspired by this one here.
Comment: I am a bit puzzled about the statement of the problem. There are $n$ such that $\frac{\varphi(n)}{n}$ is quite small. The test returns composite for any $a$ not relatively prime to $n$, which can be much more than "at most $1/2$ of the time." Anyway, I do not think you intend "at most."
Comment: I guess I'm wondering why the Fermat test will say that this is possibly prime 1/2 of the time whenever $n$ is a composite, non Carmichael number.
Comment: @AndréNicolas I think I fixed my question and made it more clear.
Answer: Let $n$ be composite. Consider the $\varphi(n)$ numbers in the interval $1\le a\le n-1$ such that $a$ is relatively prime to $n$.
Call such a number good if $a^{n-1}\not\equiv 1\pmod{n}$. So $a$ is good if using $a$ in the Fermat test we find that $n$ cannot be prime.  Let the set of good numbers be $G$.
Call $a$ bad if it is not good, meaning that if we apply the Fermat primality test, we get the answer "possibly prime." Let the set of bad numbers be $B$.
We want to show that if $n$ is not a Carmichael number, then at least half of the $\varphi(n)$ numbers $a$ in our interval are good.
Since $n$ is not a Carmichael number, there is a good number $g$.  Note that $gb$ is good for any bad number $b$. For
$$(gb)^{n-1}=g^{n-1}b^{n-1}\equiv g^{n-1}\not\equiv 1\pmod{n}.$$
The values of $gb$ as $b$ ranges over $B$ are distinct modulo $n$. Thus there are at least as many good numbers as there are bad. This completes the argument.
Remark: Let $n$ be composite but not Carmichael. The above result shows that even if $n$ is very large, repeated use of the Fermat Primality Test, with randomly chosen $a$, will, with probability close to $1$, quickly detect the compositeness.
Comment: Is the proof that there is a good number $g$ such that $gb$ is good for any bad number $b$?
Comment: Not "there is a good number such that" although that happens to follow. It is "if $g$ is any good number, then $gb$ is good for all bad $b$.
Comment: How does this show that there is are at most half bad numbers?
Comment: The total number of numbers is $n$. Suppose that there are more than $n/2$ in $B$, and that there is at least one good $g$ ("not Carmichael"). We have shown that all the $gb$ are good, and they are distinct, so we have $\gt n/2$ good. Add. Altogether, the sum of the number of bad and the number of good would be greater than $n/2+n/2$, which is impossible, since there are only $n$ numbers altogether.
Comment: Let me make sure I understand.  First we fix a composite non-Charmichael $n$.  Then we consider the set $\phi(n)$.  Out of all these relatively prime integers to $n$ we partition them into the Good and Bad set.  To show are at most half bad numbers we fix a $g$ where $g$ is a good number and consider $(bg)^{n-1}\not\equiv 1 \mod n$.  My last issue is why are they distinct as you range over $b$.
Comment: For any bad number $b$, we have shown that $gb$ is good. If $b_1$ and $b_2$ are "different" bad numbers (incongruent modulo $n$), then $gb_1$ and $gb_2$ are "different." To prove this, suppose to the contrary that $gb_1\equiv gb_2\pmod{n}$. Since $g$ is good, it is relatively prime to $n$. Thus from $gb_1\equiv gb_2\pmod{n}$ we can conclude that $b_1\equiv b_2\pmod{n}$.

Failing Fermat Primality Test