"Permission Denied" trying to run Python on Windows 10

Question: Seems as though an update on Windows 10 overnight broke Python. Just trying to run python --version returned a "Permission Denied" error.  None of the three updates; KB4507453, KB4506991, or KB4509096 look like they'd be the culprit but the timing of the issue is suspicious. Rather than messing with rolling back, I'm hoping there's a simpler fix that I'm missing.
The permissions on python are "-rwxr-xr-x" and I haven't changed anything besides letting the Windows update reboot machine after installing last night's patches.
According to the System Information, I'm running 10.0.18362
Should also note that this is happening whether I (try) to execute Python from git-bash using "run as administrator" or not, and if I try using PowerShell, it just opens the Windows store as if the app isn't installed so I'm thinking it can't see the contents of my /c/Users/david/AppData/Local/Microsoft/WindowsApps/ folder for some reason.
I've also tried to reinstall Python 3.7.4, but that didn't help either. Is there something else I should be looking at?
Comment: Probably worth checking the Microsoft website. I read somewhere, sorry can't remember where, that other people were having problems with this update - blank screen I think. Anyway, waiting until they fix it in a day or two might turn out to be the answer.
Comment: BTW, "permissions on python are '-rwxr-xr-x'" is probably meaningless in Windows. That's something fake reported by a Unix-like environment such as MSYS2 or git-bash.
Comment: Nope. This is the Python package from python.org. Same on that's been working for years without any issue and just started acting up with the latest Windows patch.
Comment: See also https://superuser.com/a/1576801/93082 solution #1 `mklink \Python39\python3.exe \Python39\python.exe`
Answer: As far as I can tell, this was caused by a conflict with the version of Python 3.7 that was recently added into the Windows Store. It looks like this added two "stubs" called python.exe and python3.exe into the %USERPROFILE%\AppData\Local\Microsoft\WindowsApps folder, and in my case, this was inserted before my existing Python executable's entry in the PATH.
Moving this entry below the correct Python folder (partially) corrected the issue.
The second part of correcting it is to type manage app execution aliases into the Windows search prompt and disable the store versions of Python altogether.

It's possible that you'll only need to do the second part, but on my system I made both changes and everything is back to normal now.
Comment: (Microsoft employee and CPython core developer here) You definitely only need to do the second part. There have been a couple of bugs related to upgrading apps resetting aliases which will be fixed in the next stable update, so it should be a one-time fix by then. While you're getting Insiders updates you may need to do it a couple more times.
Comment: Also, the "Access Denied" issue is a Git Bash bug (or whoever maintains their Bash port... I'm not sure myself whose it is). And launching the Store is a new feature to help people install Python - if you've added it to PATH using the regular installer it should take precedence over the new redirector, but if not you've discovered above how to disable it.
Comment: For me I had to also add python to my path (C:\Users\YourUsernameHere\AppData\Local\Programs\Python\Python37) for git bash to find python
Comment: I just had to to the second part to fix this problem for me.
Comment: Adding it to my my path and moving it to the top was my solution, just like Neils did.  The fact that I can't just rename the stub for the windows store stub is pretty annoying.
Comment: What a complete waste of humanity's time. Whichever parties conspired to make this be the case need to seriously consider their career choices. Thanks for the fixes
Comment: doing just the second part crashes git bash on startup with a "There are no available terminal" error. this kind of insanity makes dual-booting and dealing with windows 10's chronic inability to share a system nicely look inviting
Comment: Just in case it helps.. I got this to work very simply by doing alias python='winpty python.exe' on the command line in git bash... On Windows 10 and after doing parts 1 and 2 above...
Comment: For me, the problem was that python was moved to C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\python3.8 instead of the default path. I removed all paths both from sublime and env variables, reinstalled, added new paths and now it works. The only problem is that it's a clean install and I have to reinstall all dependencies
Comment: I have in my local user's path variable two references to this same folder, one with a literal path, the other with a relative path: `C:\Users\blah\AppData\Local\Microsoft\WindowsApps` is the 4th entry, and `%USERPROFILE%\AppData\Local\Microsoft\WindowsApps` is the last entry in the list. -- On the other hand, my *system* path variable contains no reference to the WindowsApps folder at all. Additionally, neither one of these contains a reference to any other Python paths.
Comment: (To clarify my own comment - "if you've added it [Python, not the Store launcher] to PATH using the regular installer...")
Comment: I never did anything with the winsows store regarding Python. Python is also not listet in 'App execution aliases'.
Comment: Adding in to the path manually and disabling those aliased did it for me Python 3.9.4
Comment: upvoted for the discovery of "manage app execution aliases"
Comment: even Windows 11 still has this issue. Followed the 2nd part and it fixed my problem. thanks ~!
Answer: Research
All of the files in %USERPROFILE%\AppData\Local\Microsoft\WindowsApps are placeholders that point to files that are actually located somewhere in C:\Program Files\WindowsApps, which happens to be denied permissions completely.
It appears I was on the right track with my statement made in my duplicate of this problem:

"Seems like they didn't really think about the distribution method screwing with permissions!"

Source: Cannot install pylint in Git Bash on Windows (Windows Store)
Permissions are screwed up royally because of the WindowsApps distribution method:

Interestingly it says that the "Users" group can read and execute files, as well as my specific user, but the Administrators group can only List folder contents for some hilariously unfathomable reason. And when trying to access the folder in File Explorer, it refuses to even show the folder contents, so there's something fishy about that as well.
Interestingly, even though executing python in CMD works just fine, the "WindowsApps" folder does not show up when listing the files in the directory it resides in, and attempting to navigate into the folder generates a "Permission denied" error:

Attempting to change the permissions requires changing the owner first, so I changed the owner to the Administrators group. After that, I attempted to change the permissions for the Administrators group to include Full control, but it was unable to change this, because "access was denied" (duh, Micro$ucks, that's what we're trying to change!).

This permission error happened for so many files that I used Alt+C to quickly click "Continue" on repeat messages, but this still took too long, so I canceled the process, resulting in this warning message popping up:

And now I am unable to set the TrustedInstaller user back as the owner of the WindowsApps folder, because it doesn't show up in the list of Users/Groups/Built-in security principles/Other objects. *

*Actually, according to this tutorial, you can swap the owner back to TrustedInstaller by typing NT Service\TrustedInstaller into the object name text box.
Solution
There is no solution. Basically, we are completely screwed. Classy move, Microsoft.
Comment: (Microsoft employee and CPython core developer here) There's a bug right now I'm working on getting fixed in Windows where you can launch executables in this location but only if you have the global alias enabled (in Manage App Execution aliases). I'm trying to get it changed so that you only need to have installed the app for the current user.
Comment: We can read the permissions via this dialog because it's owned by a dllhost.exe instance (hosting the security shell extension, rshx32.dll) that's running with administrator access and thus has "list folder contents" access (i.e. execute; sync; and read data, attributes, and permissions). The entry for the users group is not for a normal access check. It's conditional on the existence of a WIN://SYSAPPID security attribute, i.e. any app. The subfolder for each app grants read access to users, but execute access is conditional on running via the app link that sets a custom access token.
Comment: @MarkSimpson glad this thread helped. Not sure what I may have written. Be sure to thank the Microsoft employees that posted real answers in the comments here.
Comment: this bug still seems to be lurking over a year later... as far as i can tell getting GitBash, python and windows 10 to work together is still a dead end
Comment: @ErykSun That is the first informed answer I've ever seen about windows execution and permissions. Thanks.
Comment: I'm actually still dealing with the fallout from trying to change permissions on the folder. Certain WinApps stopped launching altogether, until I followed these directions: (https://superuser.com/questions/1288014/reset-default-acls-for-c-program-files-windowsapps) but now they give error messages on launching. I used an older Win10 USB image so it probably set the permissions incorrectly.
Comment: This just caught me out, thanks for the good explanation. We use git bash to run shell scripts to invoke an emscripten build, and as part of the standard emscripten scripts it tries to divine your python version via $(which python) ... which immediately blows up.
Answer: This appears to be a limitation in git-bash. The recommendation to use winpty python.exe worked for me. See Python not working in the command line of git bash for additional information.
Comment: I definitely have this issue running python from bash but not from powershell - however I don't think the bug you linked is the issue. Much more likely to be this: https://github.com/msys2/Msys2-packages/issues/1943
Comment: the thing is, microsoft has no right to invent new operating system features, since those would not be standard, thats something only linux/posix can do. so msys2, kudos to them for putting up with all the msft they have, and im sure theyll figure this one out too, but its not their fault its msft
Answer: This issue is far too common to still be persistent. And most answers and instructions fail to address it. Here's what to do on Windows 10:

Type environment variables in the start search bar, and open Edit the System Environment Variables.
Click Environment Variables...
In the System Variables section, locate the variable with the key Path and double click it.
Look for paths pointing to python files. Likely there are none. If there are, select and delete them.
Create a new variable set to the path to your python executable. Normally this is C:\Users\[YOUR USERNAME HERE]\AppData\Local\Programs\Python\Python38. Ensure this by checking via your File Explorer.
Note: If you can't see AppData, it's because you've not enabled viewing of hidden items: click the View tab and tick the Hidden Items checkbox.
Create another variable pointing to the Scripts directory. Typically it is C:\Users\[YOUR USERNAME HERE]\AppData\Local\Programs\Python\Scripts.
Restart your terminal and try typing py, python, python3, or python.exe.
Comment: What about users who installed Python via Anaconda? I did all every step, a system variable pointing to my python installation exists in system variables and the problem still persists.
Answer: Simple answer: replace python with PY everything will work as expected
Comment: Could anyone add more context on what is `PY` ?
Comment: worked for me, not sure whey
Comment: so that´s a new thing implemented in py 3.9.4?
Answer: Workaround: If you have installed python from exe follow below steps.
Step 1: Uninstall python
Step 2: Install python and check Python path check box as highlighted in below screentshot(yellow).
This solved me the problem.
Comment: THIS IS THE CORRECT WAY TO DO!! THANKS!!
Comment: I did this, after I installed Python - it was not installed initially, hence the error :)
Comment: Then you should have seen installation error.
Answer: Adding the Local Python Path before the WindowsApps resolved the problem.
Comment: this actually worked, this is like what the hell situation. lol :D
Answer: For people coming to this question wanting to use the Microsoft Store version of Python, and after the related "Manage app execution aliases" fix by @Zooba has likely happened, and are using Git for Windows git-bash (also known as BASH through msys2 mintty), the solution is likely simply to remember to make the call with winpty.'
winpty python3

However, if the system has had other versions of Python, make sure those copies have been removed (e.g. those installed from python.org) or are contained to their specific bundled application (e.g. OSGeo4W) (may require re-ordering environment variables).
Why, if winpty is forgotten, is it a permission error? For the first time it runs, the Microsoft Store stubs are conflicting with the permissions available to msys. A lot of the other answers go into the details of what is going on and why it feels weird. The short answer, is that the stub is trying to be a convenience short-cut to the Microsoft Store. If you launch it with winpty, it can do that. After that first time, it continues to need winpty for both related and unrelated reasons to the Microsoft Store.
Comment: There are other answers suggesting `winpty`, but their reasoning is unrelated, wrong, or out-dated. I felt an updated summary for 2021 could be useful.
Answer: It's not a solution with PowerShell, but I had the same problem except with MINGW64. I got around it by switching to Windows Subsystem for Linux (which I wanted to do anyways) as my terminal, just generally and in VSCode. This post describes it well:
How to configure VS Code (windows) to use Ubuntu App as terminal
In summary:
1) Install Ubuntu from the Windows App Store
2) Change the default bash from CMD -> wslconfig /setdefault Ubuntu
--- For VSCode
3) Restart VSCode
4) In VSCode change "terminal.integrated.shell.windows" to "C:\WINDOWS\System32\bash.exe" (for further details see the post above)
Running smoothly now in VSCode and WSL (Bash on Ubuntu on Windows). Might be at least a temporary solution for you.
Answer: For me, I tried manage app execution aliases and got an error that python3 is not a command so for that, I used py instead of python3 and it worked
I don't know why this is happening but It worked for me
Answer: This is due to the way Windows App Execution Aliases work in Git-Bash.
It is a known issue in MSYS2 failing to access Windows reparse points with IO_REPARSE_TAG_APPEXECLINK
As a workaround, you can alias to a function invocation that uses cmd.exe under the hood.
Add the following to your ~/.bashrc file::
function python { cmd.exe /c "python $1 $2 $3";}

For python, I'd recommend just toggling off app execution aliases as in the accepted answer, but for libraries that are distributed exclusively through the windows store like winget, this is your best option.
Further Reading

bash: Local/Microsoft/WindowsApps/python3: Permission denied
Permission Denied when running from bash
winget does not run in WSL2 due to exec format error #234
Answer: The simplest thing to do would be to modify your PATH and PYTHONPATH environmental variables to make sure that the folder containing the proper python binaries are searched befor the local WindowsApp folder.  You can access the environmental variables by opening up the control panel and searching for "env"
Answer: I had this to Run /execute but was not working
python3 -m http.server 8080

after reading and trying some of the solutions above and did not worked , what worked for me was
python -m http.server 8080

Comment: huh, worked for me when running `-m venv`. Looks like I may have python3 installed in two locations causing this. I suspect one from the Windows store and one installed by vscode or something like that.

```
$ which python
/c/Users/me/AppData/Local/Programs/Python/Python39/python
$ which python3
/c/Users/me/AppData/Local/Microsoft/WindowsApps/python3
```
Answer: make sure C:\Python39\ and C:\Python39\Scripts\ are added to both system path variables and user path variables
Comment: This helped me to get python running, though python was installed in C:\Program Files\Python36\. Make sure this is added to the top (beginning) of your PATH, otherwise Windows may try to run the Windows Store versions of python instead of the version you installed. Also, I never got it working in git bash, but it will work in cmd or powershell.
Answer: I experienced the same issue, but in addition to Python being blocked, all programs in the Scripts folder were too. The other answers about aliases, path and winpty didn't help.
I finally found that it was my antivirus (Avast) which decided overnight for some reason to just block all compiled python scripts for some reason.
The fix is fortunately easy: simply whitelist the whole Python directory. See here for a full explanation.
Answer: Add the path of python folder in environmental variable and it will work
1.search environmental variable
2.look for system variable section and find variable named path in it
3.double click on path and add new path which directs towards python folder and that's it.
the python folder is usually in
C:\Users["user name"]\AppData\Local\Programs\Python\Python39
Answer: I just uninstalled the Python 3.9 Version in the Windows App and Features.
Instead I installed the latest version with everything and with adding environment variable.
This helped me directly after that.
Answer: save you time :
use wsl  and vscode remote extension to properly work with python even with win10
and dont't forget virtualenv!
useful https://linuxize.com/post/how-to-install-visual-studio-code-on-ubuntu-18-04/
Answer: In Windows 10

Open Control Panel
Click System
Click the Advanced system settings link
Click Environment Variables button
In the System Variables section find the PATH environment variable and select it
Click Edit (If the PATH environment variable does not exist, click New)
In the Edit environment variable window specify the value of the PATH environment variable
Click OK
Close all remaining windows by clicking OK
Reopen Command prompt window and run python --version
Answer: May be you can try opening command prompt with Administrator privileges. (Run As Administrator). Works for me most of the time.
Comment: The python executable works in CMD even without Administrator privileges. The problem is that it doesn't work in Git Bash, which is an essential tool for programmers and is the default, and it works with every other distribution method for Python, which means it should [be made to] work here as well.


The Lebesgue measure of the boundary of a simply connected domain

Question: Is the Lebesgue measure of the boundary of a simply connected domain in $\mathbb{R}^n$ necessarily 0?
Acturally, I want to know the sufficient condition to guarantee the measure of the boundary of a domain is $0$.
Comment: might be useful https://math.stackexchange.com/questions/1421934/set-e-subset-mathbbrn-of-positive-lebesgue-measure-such-that-the-lebesgue?rq=1
Answer: Take a fat Cantor set, $C\subset \mathbb{R}$, i.e. a closed set with empty interior and nonzero measure.  Then consider the set $$\{(x,y)\in \mathbb{R}^2: y <0\} \cup \{(x,y)\in \mathbb{R}^2: y\geq 0, x \notin C\}.$$
This set seems open, simply connected and with boundary $C \times [0,\infty)$.
Answer: Tim kinsella's answer is really fine, here is another suggestion (way more complicated).
Just take an Osgood curve (= Jordan arc of positive area)

This is an arc (continuous image of $[0,1]$ into the plane) therefore simply connected, and closed.
It is also a non self intersecting curve (an arc is the image of an injective function), so it has empty interior (see this or this, the proof is easy)
Thus the boundary of the Osgood curve is the curve itself, so it has positive measure.

See for instance this step by step construction of an Osgood curve (by Knopp, on Wolfram Demonstrations).


What's the difference between a beta coef. estimate from linear regression and a VIF value?

Question: I'm having trouble deciding what to do when two important variables (important to my research questions) are seemingly too related, but both need to be included in a full model (this is a longitudinal study where we repeatedly sample around the same time 2x each year, i.e. every season). I also have a related and broader conceptual question on the difference between prediction and multicollinearity (linear modeling and VIF). If my goal was to address potential multicollinearity, and/or covariate redundancy, in a full multiple linear regression model, and I do this by excluding variables that are too similar, how/why is running a simple linear model of two "trouble" covariates different from running VIF on the full model (why is prediction giving me a different answer than my check multicollinearity)? The two ideas seem similar: "how is one variable related to another?" (I'm trying to resolve my obvious ignorance of the difference between these two concepts).
If these were too continuous variables, I would simply check their correlation/collinearity and pick one, then be done, but one being categorical has thrown me down this rabbit hole. As an example, I have created a categorical variable "Season" and a continuous variable "water temperature" (variables which are both important to my research questions and representing the sample design, but are probably too closely related) to represent my actual data. There is a definite seasonal component to water temp., and if I model one with the other, that model tells me Season is a statistically significant variable for predicting water temperature. However, why wouldn't VIF tell me season and water temperature are too highly correlated in the same model together? My gut screams these are completely different things, but I don't quite understand why both wouldn't give me the same answer, at least in different ways. Shouldn't both tell me one is a "good" predictor of the other (VIF should also be high)? Both are significant in this hypothetical full model, and taking one away makes the remainder insignificant (a multicollinearity issue, no? So, why didn't VIF pick that up?). Thank you in advance and my apologies if this sounds like nonsense.
Thinking on it further lead me to posit that "high" VIF values are slightly subjective and that my results are indeed saying the two variables are related, but not so badly that it's a problem (?)
<code>> # Water temperature (actual means and SD from my data):

> df <- as.data.frame(rnorm(50, mean = 23.8, sd = 2.60))
> df2 <- as.data.frame(rnorm(50, mean = 30.2, sd = 1.62))

> names(df)[1] <- "water_temp"
> names(df2)[1] <- "water_temp"

> df3 <- rbind(df, df2)

> df3$season <- rep(c("DRY", "WET"), each=50)

> # Other random variables:
> df3$v1 <- sample(0:3000, 100, replace = TRUE)

> df3$v2 <- rnorm(100, mean = 25, sd = 5)

> # Dependent variable:
> x <- rnorm(100, mean=0, sd=1)

> df3$x <- x

> mod <- lm(x ~ water_temp + season + v1 + v2, data=df3)

> vif.cat.data <- check_collinearity(mod)
> vif.cat.data
# Check for Multicollinearity

Low Correlation

       Term  VIF       VIF 95% CI Increased SE Tolerance Tolerance 95% CI
 water_temp 3.55 [2.65,     4.93]         1.88      0.28     [0.20, 0.38]
     season 3.54 [2.65,     4.92]         1.88      0.28     [0.20, 0.38]
         v1 1.02 [1.00,    61.86]         1.01      0.98     [0.02, 1.00]
         v2 1.01 [1.00, 1.62e+05]         1.01      0.99     [0.00, 1.00]

> mod2 <- lm(water_temp ~ season, data = df3)
> anova(mod2)
Analysis of Variance Table

Response: water_temp
          Df Sum Sq Mean Sq F value    Pr(>F)
season     1 998.73  998.73  246.48 < 2.2e-16 ***
Residuals 98 397.09    4.05
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
</code>
Evidence of multicollinearity?
<code>> summary(mod)

Call:
lm(formula = x ~ water_temp + season + v1 + v2, data = df3)

Residuals:
    Min      1Q  Median      3Q     Max
-2.4745 -0.6249  0.2011  0.6579  2.0758

Coefficients:
              Estimate Std. Error t value Pr(>|t|)
(Intercept) -4.101e+00  1.251e+00  -3.277  0.00147 **
water_temp   1.387e-01  4.973e-02   2.790  0.00638 **
seasonWET   -1.044e+00  3.713e-01  -2.811  0.00600 **
v1          -5.196e-05  1.122e-04  -0.463  0.64428
v2           4.000e-02  1.836e-02   2.178  0.03187 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.9866 on 95 degrees of freedom
Multiple R-squared:  0.1331,    Adjusted R-squared:  0.0966
F-statistic: 3.647 on 4 and 95 DF,  p-value: 0.008281

# Remove "season"
> mod <- lm(x ~ water_temp + v1 + v2, data=df3)
> summary(mod)

Call:
lm(formula = x ~ water_temp + v1 + v2, data = df3)

Residuals:
    Min      1Q  Median      3Q     Max
-2.4078 -0.7440  0.1653  0.6890  2.2550

Coefficients:
              Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.553e+00  8.934e-01  -1.738   0.0854 .
water_temp   2.078e-02  2.763e-02   0.752   0.4540
v1          -5.288e-05  1.161e-04  -0.455   0.6499
v2           4.443e-02  1.894e-02   2.346   0.0211 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.021 on 96 degrees of freedom
Multiple R-squared:  0.061, Adjusted R-squared:  0.03165
F-statistic: 2.079 on 3 and 96 DF,  p-value: 0.1081

# Remove water_temp

> mod <- lm(x ~ season + v1 + v2, data=df3)
> mod2 <- lm(water_temp ~ season, data = df3)
> summary(mod)

Call:
lm(formula = x ~ season + v1 + v2, data = df3)

Residuals:
     Min       1Q   Median       3Q      Max
-2.53825 -0.71103  0.07287  0.74687  2.18310

Coefficients:
              Estimate Std. Error t value Pr(>|t|)
(Intercept) -9.134e-01  5.284e-01  -1.729   0.0871 .
seasonWET   -1.698e-01  2.062e-01  -0.823   0.4123
v1          -2.873e-05  1.158e-04  -0.248   0.8045
v2           4.315e-02  1.896e-02   2.276   0.0251 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.021 on 96 degrees of freedom
Multiple R-squared:  0.06209,   Adjusted R-squared:  0.03278
F-statistic: 2.119 on 3 and 96 DF,  p-value: 0.1029
</code>
Answer: For one thing, regression coefficients are about the relationship between independent variables and the dependent variable. VIF is only about the independent variable.
Your section starting with "Evidence of multicollnearity?" has no evidence for or against that I could see.
My dissertation (way back in 1999!) showed that condition indexes are a better way to diagnose collinearity than VIF. (If the link goes bad, just Google my name and "Monte Carlo").
For your specific problem, season and temperature are not both needed, unless season adds something that temperature does not. But they are likely to be colinear.
Finally, you imply that correlation is a measure of collinearity. While there is a relationship, it is possible to have high collinearity with low correlations. Suppose that there are 10 uncorrelated variables and one that is the sum of those 10. None of the correlations will be very high but, if the summation has no error, colinearity will be perfect.
Comment: Thanks for the authoritative answer on indices for detecting collinearity. I have never seen codition indices being recommended anywhere. Is there some (lightweight) R package that implements them?
Comment: Suspect last 3 words are a typo for "*collinearity* will be perfect"!
Comment: I am also a big fan of the approach proposed by Belsley, Kuh & Welsch. [Belsley (1991)](https://link.springer.com/article/10.1007/BF00426854) is an accessible treatment for the practitioner who would like to understand *how* this approach can actually be used, rather than the statistician who needs to understand *why* it works. It is unfortunately a bit more complex than VIFs.
Comment: The perturb package has them.  So does the olsrr package.
Comment: Just tried out condition indices on the dataset *nhospital* from the R package *GLMsData*, which has highly correlated predictors. The highest condition index for the model `MainHours ~ Cases + Eligible + OpRooms` is 16. According to Beasley (1991), this means that there is no collinearity to worry about. OTOH, VIFs of 16 and 13 are reported, which indicate strong multicollinearity. In this case, VIFs seem to be better indicators. What is going wrong with condition indices in this very simple example with obvious collinearities?
Comment: First, it is not the case that a CI of 16 indicates no problem. Between 10 and 30 is moderate collinearity, over 30 is extreme. I remember this from my research, but also found it via Google in several sources (the help for the R package seems wrong). Second, correlation is not the same as collinearity. Belsley distinguishes "problematic collinearity"  (see his books).
Comment: I was referring to the thresholds given by Besley 1991, who calls values between 30 and 1000 moderate, and values less than 30 "not really a major problem" (p. 42). I was just wondering, why in this case of an almost perfect collinearity, condition indices indicate only a minor collinearity. As condition indices are also more difficult to interpret, it seems better (from a didactical point of view) to stick to VIF as a collinearity measure in my course.
Comment: "values between 30 and 1000 moderate" Sorr for the typo: This should read: "values between 30 and 100 moderate".
Answer: It seems you are confused both about beta and VIF:

Beta gives some strength in the relationship, indicating how much the target move with the feature, but it is not really related to the quality of the predictor / model. The quality of a predictor / model would be evaluated by looking at how much of the variance is explained by the predictor instead of noise, that is using R2. (Another way to see this is considering rescaling features: rescaling change beta but should not generally change the quality of the model, hence beta is not really linked to quality of the model).

VIF relates to the correlation of one variables to the others. That is how the remaining features could explain one given feature. It generally gives an idea on how you can remove that feature (because it can be explained by the others), but not the link between that feature and the target. It is a bit dangerous as the target may lie in the difference of features. The edge exemple is trying to predict y from X and X+y. A model would give: y = X + y - X. But VIF could remove X + y before modelling.


Proving (disproving?) a statement when its condition is not satisfied

Question: Consider the following implication.

Let $k\in \mathbb{Z}$. If $k^{2} + 5k$ is odd, then $k^{2}+5k+1$ is odd.

At first it seems to be false, and one could proceed easily to prove it false directly by assuming that the premise ($k^{2} + 5k$ is odd) is true. However, there is no integer $k$ such that $k^{2} + 5k = k(k+5)$ is odd, and the premise is false in all posible cases, and so the implication follows vacuously (true).
I do have a lot of questions about this issue. But I want to  be concise. Does the statement is true or false? and why?
Comment: It is vacuously true, exactly as you suggest.
Comment: Of course.  The statement admits no counterexamples, because the premise is impossible.  That makes the statement true, though not terribly interesting because there are no examples either.
Comment: Thanks for your answer. Yes! That was what made sense to me. But the process of direct proof (which proves it wrong) is correct as far as I'm aware, That's the problem I have. Does this has to do with the premise being false??
Comment: False $\Rightarrow$ True is always True, by definition.
Comment: Usually $A \Longrightarrow B$ simply means, that **if** $A$ is true, so is $B$. It doesn't say anything if $A$ doesn't hold. Then $B$ may or may not be true.
Comment: Oh I see. So the process of direct proof is correct but it assumes the premise to be true and since it is impossible for the premise to be true, it follows that the implication is false. So this has to do with proof methods focusing more on the processes of deduction than in the truth of the premises.
Comment: @Kr'aamkh The question asks for the truth value of the *implication*, which is (vacuously) true, as already explained. Note, however, that the implications "*if $k^{2} + 5k$ is odd, then $k^{2}+5k+1$ is* ***even***" and "*if $k^{2} + 5k$ is odd, then* $1+1=3$" are *also* true for the same reason. Also note that if you slightly change the question to "*what is the parity of $k^{2}+5k+1$ if $k^{2} + 5k$ is odd*" then the answer "*even*" is wrong.
Answer:

Let $k\in \mathbb{Z}$. If $k^{2} + 5k$ is odd, then $k^{2}+5k+1$ is odd.

So the process of direct proof is correct but it assumes the
premise to be true and since it is impossible for the premise to be
true, it follows that the implication is false.
However, there is no integer $k$ such that $k^{2} + 5k =
> k(k+5)$ is odd, and the premise is false in all possible cases, and so
the implication follows vacuously (true).
But the
process of direct proof (which proves it wrong) is correct

To be clear,  formally, the implication here is

if $\bigg(k\in\mathbb Z\:\:$ and  $\:\:k^{2} + 5k$ is odd$\bigg),$ then $\bigg[k^{2}+5k+1$ is odd$\bigg]$

rather than

$\bigg[k^{2}+5k+1$ is odd$\bigg],$

which is just its consequent/conclusion. And the statement to be proved is this:

for each $k$, if $\bigg(k\in\mathbb Z\:\:$ and $\:\:k^{2} + 5k$ is odd$\bigg),$ then $\bigg[k^{2}+5k+1$ is odd$\bigg].$

(Informally, "implication" has a second meaning as a synonym of consequent, and conflating these two meanings is causing confusion, I think.)

So this has to do with
proof methods focusing more on the processes of deduction than in the
truth of the premises.

Yes, proving an implication is typically a sequence of derivations that begins by assuming that its premises are true and ends by deducing its conclusion. In other words, the process is showing that whenever its premises are true, its conclusion must be true. There are two exceptions:

showing that its conclusion is true immediately (logically) derives the implication, even if none or only some of its premises are assumed: \begin{align}∀xCx &⊨ ∀x\big(Px → Cx\big)\\C&⊨P→C ;\end{align}
showing that its premise is false immediately (logically) derives the implication as being vacuously true: \begin{align}¬∃xPx &⊨ ∀x\big(Px → Cx\big)\\¬P &⊨ P→C.\end{align}

Thus, when we know that an implication's premise is false, we can just show this, even when it's possible to assume (against the facts) its premise as true then using axioms to deduce its conclusion, that is, even when we can, for example, exhibit the (vacuously true) chain $$-2=2\implies(-2)^2=2^2\implies4=4$$ or the (vacuously true) chain $$-2=2\implies-2+5=2+5\implies3=7.$$

the statement is true or false? and why?

Your given statement is vacuously true.


Como mudar valor de variavel depois que o usuario enviar um formulario?

Question: Esse código abaixo vai imprimir  se o rowCount == 0 e se for > 0 vai imprimir , depois que o usuario envia o formulario eles não poderam ver o  ao menos que ele atualize a página, depois que o usuario envia o formulario a página atualiza sozinha, mas ele precisa atualizar a página mais uma vez para poder ver o :
if ($rowCountFav == 0) {
  $favIcon = '';
}else{$favIcon = '';}

if($_SERVER['REQUEST_METHOD'] == 'POST'){
  if(isset($_POST["fav"])){
    if ($rowCountFav == 0) {
      $favorito = $conn->prepare("INSERT INTO `favorito` (user_id, nameItem) VALUES (:user_id, :nameItem)");
      $favorito->bindParam(':user_id', $user_id, PDO::PARAM_INT);
      $favorito->bindParam(':nameItem', $nameItem, PDO::PARAM_STR);
      $favorito->execute();
    }
  }
}
?>
<form action="" method="post" autocomplete="off">
  <button class="btnSub btnA" type="submit" name="fav" />
    Favorito <?= $favIcon;?>
  </button> -
</form>

O que eu quero: Eu quero que imprima o  depois que o usuario enviar o formulario.

EDITADO, SUGESTÃO DE RiscadoOoOoO e RabisCadoO

PRECISO QUE ESSE  SEJA EXIBIDO DENTRO DO FORMULARIO APÓS O SUBMIT.

FINAL DA EDIÇAO.

Então eu tentei isso, mas nada mudou:
if($_SERVER['REQUEST_METHOD'] == 'POST'){
  if(isset($_POST["fav"])){
    if ($rowCountFav == 0) {
      $favorito = $conn->prepare("INSERT INTO `favorito` (user_id, nameItem) VALUES (:user_id, :nameItem)");
      $favorito->bindParam(':user_id', $user_id, PDO::PARAM_INT);
      $favorito->bindParam(':nameItem', $nameItem, PDO::PARAM_STR);
      $favorito->execute();
    }else{$favIcon = '';} ## eu apenas add essa linha ##
  }
}

Alguem pode me ajudar?
Answer: A solução foi declarar o valor do $rowCount depois da query de INSERT, agora o icone é trocado logo depois que o usuario enviar o formulario, e não precisa atualizar a página.
if($_SERVER['REQUEST_METHOD'] == 'POST'){
  if(isset($_POST["fav"])){
    if ($rowCountFav == 0) {
      $favorito = $conn->prepare("INSERT INTO `favorito` (user_id, nameItem) VALUES (:user_id, :nameItem)");
      $favorito->bindParam(':user_id', $user_id, PDO::PARAM_INT);
      $favorito->bindParam(':nameItem', $nameItem, PDO::PARAM_STR);
      $favorito->execute();
      $rowCountFav = 1;
    }
  }
}

if ($rowCountFav == 0) {
  $favIcon = '';
} else {
  $favIcon = '';
}

?>
<form action="" method="post" autocomplete="off">
  <button class="btnSub btnA" type="submit" name="fav" />
    Favorito <?= $favIcon;?>
  </button> -
</form>

Answer: Natalie, tente assim:
form action="" method="post" autocomplete="off">
  <button class="btnSub btnA" type="submit" name="fav" />
    Favorito <?= if(isset($favIcon)){echo $favIcon;}?>
  </button> -
</form>

Se der certo, avise a gente, por favor ;)


Saving File Space with Drupal 8

Question: I have a hosting account which has a maximum of 250 MB total space. I have installed Drupal 8 and I'm using the bootstrap theme and already my host has warned me that I am nearing my limit for file space. This is only going to be a small site, so it really shouldn't need that much space. Is there any way I can clear up space by deleting unused files in the Drupal 8 system?
For instance, is it possible for me to disable themes and then delete those folders? And also to uninstall core modules that I'm not using and delete those folders as well? Or are there any other ways I can clear up space?
If it is not possible then I will probably switch to using Drupal 7, which would be my 2nd option.
Comment: Deleting modules/themes will only get a few kilobytes back - the weight of a D8 site is in the vendor folder, which core needs to function. I don't think it's a stretch to say that any Drupal 8 site will require more than 250mb of disk space, if you can't provide that, Drupal 7 might indeed be an option
Answer: While you could uninstall and delete core modules, I wouldn't recommend it.  They will be restored during updates and you'll have to constantly be vigilant to not go over your space limit.
Over time, the size of the site will probably grow slightly due to additional updates, and you may add files of your own (images, etc.) that also increase the site's size.
Drupal 8 requires significantly more space than Drupal 7 and is a very tight squeeze if you only have 250 MB.  Hosting recommendations are off topic for this site, but there are many hosts that offer more file space (say, 1 GB) at a reasonable rate.  If Drupal 8 otherwise fits your needs, I would pay more to increase the disk space, but if that's not an option, go with Drupal 7 since it's smaller, even with a fair number of contrib modules.

Saving File Space with Drupal 8


Number of ordered sets of integers

Question: How many ordered sets of integers $(x,y,z)$  satisfying $$x,y,z \in [-10,10]$$  are solutions to the following system of equations:
                           $$x^2y^2+y^2z^2=5xyz$$
                          $$y^2z^2+z^2x^2=17xyz$$
                           $$z^2x^2+x^2y^2=20xyz$$
By a quite cumbersome method, which is too long for me to type down here, I arrived at the answer 5: the ordered sets being $(0,0,0), (8,2,4), (-8,-2,4), (-8,2,-4)$ and $(8,-2,-4)$. But this does not seem to be the right answer. What I basically did was divide the system of equations with $(xyz)$, then by a process of elimination of the variables, found the possible values of x, y and z. However, it seems I've somehow missed out other solutions as well. Can anyone help me out with this?
Thanks!
Answer: The discriminant of the first equation with respect to $z$ is $x^2y^2(25-4y^2)$. This must be a square, so we must have $y\in\{-2,0,2\}$ or $x=0$. If one variable is $0$, one of the others must also be $0$, and we get the solutions that Johan pointed out. If $y=\pm2$, we need $x=\pm8$ or $x=\pm9$ to get a factor of $17$ from $x^2+y^2$ in the second equation. Substituting this into the second equation yields integer $z$ only for $x=\pm8$, and this yields the solutions that you found. Thus the solutions found by Johan and you are the only ones.
Answer: If two of the variables are zero, then the third one can be anything. So $(0,0,z)$, where $z$ is anything, is a a set of solutions, as is $(0,y,0)$ and $(x,0,0)$.
Answer: Let $(x,y,z)$ be a solution. Then the three numbers
$$
u_1=x^2y^2+y^2z^2-5xyz, \ u_2=y^2z^2+z^2x^2-17xyz, \ u_3=z^2x^2+x^2y^2=20xyz
$$
are all zero.
Now
$$
\begin{array}{lcl}
(1) \ -u_1+u_2+u_3 &=& 2x^2z^2-32xyz=32xz\bigg( \frac{xz}{16}-y\bigg) \\
(2) \ u_1-u_2+u_3 &=& 2x^2y^2-8xyz=8xy\bigg( \frac{xy}{4}-z\bigg) \\
(3) \ u_1+u_2-u_3 &=& 2y^2z^2-2xyz=2yz\bigg( yz-x\bigg)
\end{array}
$$
If $x,y$ and $z$ are all nonzero, we see that $x=yz, y=\frac{xz}{16}$ and $z=\frac{xy}{4}$. Multiplying, we deduce $xyz=\frac{(xyz)^2}{64}$, so $xyz=64$. Using
$x^2=xyz, y^2=\frac{xyz}{16}$ and $z^2=\frac{xyz}{4}$, we deduce $x^2=64,y^2=4,z^2=16$.
This produces four solutions : $(8\varepsilon_1,2\varepsilon_2,4\varepsilon_1\varepsilon_2)$ where each of $\varepsilon_1$ and $\varepsilon_2$ can be $+1$ or $-1$.
If $z=0$, then by (2) we have $2(xy)^2=0$ and hence $x=0$ or $y=0$. Similarly when $x=0$ or $y=0$ : this will produce the solutions found by Johan.
Comment: I had suggested a slight edit in your answer, but it doesn't seem to have come through; didn't you mean 4ε1ε2, and not 16ε1ε2?
Comment: @JobinIdiculla : Corrected, thanks.
Answer: If any two of $x,y,z$ are $0$, all the equations say $0 = 0$.
On the other hand, if only one is $0$, it's easy to see that another must also be $0$.
So now let's assume none of them are $0$.
Then we can cancel a $y$, $z$, or $x$ respectively from each equation, leaving
$$ \eqalign{(x^2 + z^2) y &= 5 x z\cr
            (x^2 + y^2) z &= 17 x y\cr
            (y^2 + z^2) x &= 20 y z\cr}$$
Next, notice that changing signs of any two of the variables preserves all three equations.  Thus we may assume, say, $x > 0$ and $y > 0$, and get the other solutions by symmetry.
Now $x z \le (x^2 + y^2)/2$ (because $x^2 - 2 x z + y^2 = (x-y)^2 \ge 0$), and similarly $-x z \le (x^2 + y^2)/2$, i.e $|x z| \le (x^2 + y^2)/2$.
So from the first equation we get
$$|y| = \frac{5 |x z|}{x^2 + y^2} \le \frac{5}{2}$$
Since at this point $y$ is a positive integer, the only possibilities are $y= 1$ and $y = 2$.
If $y = 1$, the second equation says $z (x^2 + 1) = 17 x$.  Since $x^2 + 1$ and $x$ are relatively prime, this implies that $x$ divides $z$.  So let $z = m x$.  We then
have $m (x^2 + 1) = 17$.  Since $17$ is prime, one of $m$ and $x^2 + 1$ must be $1$ and the other $17$.  But $x \ne 0$ so it must be $x^2 + 1 = 17$ (i.e. $x=4$), and $m= 1$ so $z=4$.  But $x=4,y=1,z=4$ doesn't satisfy the first or third equation.
The remaining possibility is $y=2$.  Then the second equation says $z (x^2 + 4) = 34 x$.  If $x$ is odd, so is $x^2 + 4$, and that is relatively prime to $x$ so it divides $34$.  The only odd factors of $34$ are $1$ and $17$, so we'd need $x^2 + 4 = 17$, but that doesn't work since $17-4=13$ is not a square.  So $x$ must be even: say $x = 2 t$.  Now the second equation, after dividing by $4$, becomes $z (t^2 + 1) = 17 t$.  As in the previous paragraph, we conclude that $t=4$ (so $x=8$) and $z=4$.  Thus we have $(x,y,z) = (8,2,4)$, which is a solution.  By symmetry (changing any two signs) we also have solutions $(-8,-2,4), (-8,2,-4)$ and $(8,-2,-4)$.
Summing up, we have the solutions $(x,y,z) = (0,0,z)$, $(0,y,0)$, $(x,0,0)$, $(8,2,4)$,  $(-8,-2,4), (-8,2,-4)$ and $(8,-2,-4)$.
Comment: Thank you all for your answers! They were all quite helpful. I found Robert's answer the most elegant though, and hence my "accepted answer" goes for the same. I've upvoted all of you. Thanks again!
Comment: I think joriki's is more elegant.  Maybe mine is more elementary.

Number of ordered sets of integers


How to run survival analysis on big dataset?

Question: I have recently been involved in a project that needs me to analyze the survival time of objects. Therefore, I plan to use the rms package to build a Cox model. The problem is, since the dataset I have is so big (about 450,000 instances, and each has 9 covariables), the R environment fails to handle this. Does anyone have suggestions as to how to fit these models?
Comment: I do not have an answer for you... However, I think you should clarify whether the problem arises when your model is fitted or if it arises sooner (e.g., at the importation step)? Also, do you have any reason for not using 'coxph' from the survival package?
Comment: Does working with all 450,000 cases really figure to give you much more useful information than analyzing a random subset of, say, 20,000?
Comment: I fit Cox models on data that have over 50 variables and over 2,000,000 observations on a laptop. I don't understand why this is an issue. How does the R environment "fail"? Something else is going on here.
Comment: maybe this question is more suitable for stackoverflow?
Comment: I don't know why R can't handle this, but I am fairly sure SAS could, if you have access to it.
Comment: Are you able to store the data and the error occurs when you run the survival function?  What is the error message?  Or are you not able to store a matrix that big which would be surprising...
Comment: How much RAM do you have?  Maybe using a machine with more RAM will allow you to fit the model.
Comment: I am not sure this is about the limitation of R or about the time complexity of the Cox model. Therefore I put it here.
Comment: @ocram Thanks for your reply. I using the rms package because the validation function provided there can output the Dxy measure directly. No, the dataset can be imported smoothly, and I can even "summary(data)". So, I think it should be related to the complexity of the Cox algorithm. Is there any conclusion or report mentioned the scale ability of Cox model?  Thank you
Comment: "I think it should be related to the complexity of the Cox algorithm" ---> In order to validate this hypothesis, maybe you can try to fit your model with 'coxph' or with proc phreg (SAS) just to check whether your problem is related to 'rms'...
Comment: @ocram um... Let me check the combination of an external package for calculating the Dxy measure and the 'survival' package instead of the directly & lazy use of rms package. :-)
Comment: Have you tried a non-Cox survival model, like a parametric model? I'm not sure if they're any easier to compute, but it's worth a shot.
Answer: Using h2o is an option now: Cox PH function is available with nightly build (in R only) and soon to be released with 3.20.x version. You can monitor this feature here: PUBDEV-5019
Obviously, with R you would need to install h20 package by following instructions in 'INSTALL IN R' link above (copied below for clarity):
# The following two commands remove any previously installed H2O packages for R.
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }

# Next, we download packages that H2O depends on.
pkgs <- c("RCurl","jsonlite")
for (pkg in pkgs) {
  if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
}

# Now we download, install and initialize the H2O package for R.
install.packages("h2o", type="source", repos="var url = location.href; var url2 = url.substring(0, url.lastIndexOf("/")); document.write(url2);http://h2o-release.s3.amazonaws.com/h2o/master/4305/R")

# Finally, let's load H2O and start up an H2O cluster
library(h2o)
h2o.init()

Now, running survival model with h2o would be as straight forward as with survival package:
lung.hex = as.h2o(survival::lung)

covariates = c("age", "sex",  "ph.karno", "ph.ecog", "wt.loss")
lung.coxph.model = h2o.coxph(x=covariates, event_column = "status", training_frame = lung.hex,
stop_column = "time")

# print model coefficients
lung.coxph.model@model$coefficients_table

The code Cox PH above is equivalent to survival code:
res.cox <- coxph(Surv(time, status) ~ age + sex + ph.karno + ph.ecog + wt.loss, data =  lung)
summary(res.cox)

Answer: You can try the survival package in R-core.
library(survival)
fit <- coxph(V1+V2, data=data)

Not sure how it compares to rms.
Comment: `cph` in `rms` is identical (the fitter and everything) to `coxph` unless the user specifies time-varying strata in an Anderson-Gill model. Those kinds of problems would present fairly readily as a bottleneck, I would presume.
Answer: logistic regression might be one way to go. given the construction, you need to add time variables (most likely in spline form) into the model setup, the it can give you hazard ratio as well.
in practice, logistic regression will yield similar answer to cox model -- in many cases, even more stable.
Comment: ...unless there is censoring.


(a∙a)×a, a = (1,1,1) how to get cross product with a result from a dot product

Question: i know how to do the dot and cross product, but it was my understanding that cross product has to be done between two vectors, however i have a question of this form on my assignment, and i dont understand how to do it as the result of a dot product is a single number.
Comment: $(a\cdot a)\times a$ is almost certainly a typo, perhaps for $a\cdot (a \times a)$.
Answer: $(a\cdot a)\times a$ is definitely wrong.
Email your lecturer or teacher or whatever you call them where you live, they'll send out a correction.
It's most likely $(a\times a)\cdot a$, but I would still get in contact with whoever set the assignment, just to be sure.
Comment: i had a feeling this would be the case, thank you!


duvida firebase com ionic (ion-select)

Question: Tenho uma aplicação, e quero saber como faço para inserir informações no database do firebase e depois colocar esses dados dentro de um ion-select, minha aplicação usa um select de profissoes como: "mecanico", "pedreiro", "professor" e etc, e quero que isso fique dentro de um ion-option do ion-select, porém não sei como fazer. No meu codigo fiz assim:
<ion-select [(ngModel)]="profissoes1" okText="Salvar" cancelText="Cancelar">
    <ion-option *ngFor="let items of items">{{items}}</ion-option>
  </ion-select>

e quero uma dica de como usar no typescript, para pegar as profissões do firebase ficarem no lugar do {{items}}, e como inserir as profissoes no firebase tambem
Answer: Neste link há um tutorial de firebase, com certeza irá te ajudar.
Este outro link refere-se a documentação de ion-select.
A vantagem de se usar FireBase é que você não precisa codificar o back-end. Entretanto, antes de fazer as requisições, você tem que se lembrar de alterar a autorização default para liberar essas requisições para outros usuários.
Recebido o resultado dessa requisição, o que você tem que fazer é armazená-lo numa variável e fazer uma iteração (repetição) com o *NgFor e passar o valor e nome mostrado, exemplo:
<ion-select [(ngModel)]="data.person" multiple>
  <ion-option *ngFor="let name of namesList" [value] = "name.firstName" [checked]="false">{{name.firstName}}</ion-option>
</ion-select>

Neste exemplo, entende-se que você armazenou o resultado da requisição na variável namesList e para cada item, você chama de "name", e para acessar os atributos deste objeto, usa o nome do objeto (name) seguido do nome do atributo (firstName), ficando 'name.firstName'
Comment: é que eu to realmente perdido no ion-select, e no firebase eu so uso o push e pego os dados pela referencia, porém nessa situação, eu quero que as informações sejam inseridas manualmente no banco e fique dentro do ion-option
Comment: Certo, para adicionar dado manualmente no seu banco de dados Firebase, veja [este link](http://mariechatfield.com/tutorials/firebase/step2.html).
Para popular os seus ion-options com os dados vindos do banco, você tem que montar um serviço que faça uma requisição trazendo os dados dessa rota (/usuarios, por exemplo), e retornar essa promise para a sua página, e por fim, atribuir essa promise no atributo que vai estar no ng-model

duvida firebase com ionic (ion-select)


Debug log4j Configuration in a spring boot webapplication

Question: I am developing a multimodule webapp with spring boot. My webapplication always takes the log4j config from the dependend submodule, which is not desired. Is there a way to show debug info, which logback or log4j file is used?
Answer: You need to exclude default by adding these to pom
<code><dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
</code>


How to find the mode of these AC/DC songs?

Question: I'm trying to learn music theory while learn some simple rock songs, such as AC/DC's. For example "Highway to Hell" and "Girls Got Rhythm".
I know these notes are used: G - A - B - C - D - E - F# - G, which looks like a G major scale and I also read that AC/DC is known for using the mixolydian mode. For this G major, this would mean a D mixolydian mode.
But why is it D mixolydian and not E aeolian? Or any other relative mode? I try to find a concrete answere, not something that relies on "feeling". Like what is the moment in those songs that proves it is D mixolydian?
Comment: 'I try to find a concrete answers, not something that relies on "feeling"' - This is understandable and also problematic when analyzing any kind of art. There is no part of music theory that does not eventually get down to how something sounds and how it feels. This means that music theory is always at least a little bit subjective.
Comment: Ultimately the feeling is what matters.  A concrete, logical answer would just be trying to categorize what causes the feeling.  The feeling largely depends on what music you've been exposed to prior to listening to the song.  I (rock, metal, prog, marching percussion background) have definitely had disagreements over e.g. what the time signature of a song is with someone who had a different background (e.g. classical).
Answer: The first thing is checking wich note would turn as tonic, wich notes avoid as the possible 2nd or 7th, i knwo it is very basic, so as alternate answer, We can see it from the guitar perspective, maybe play it on the guitar and check if it fits into the digitation of certain mode.
Answer: Finding the "tonic"
"The" moment is most often going to be the final chord. More often than not, a song ends at a moment of rest, where the music feels like it has arrived "home". The root of that chord will be the home bass for the mode.
"Highway to Hell", for example, ends on an A. (Hear, for example:

)
Given the notes listed in the question, that would suggest A Dorian. (It's not — the song uses C# more than C, making it A Mixolydian — but Dorian would be the conclusion based on the information given in the question.)
Characteristic sound
Each diatonic mode has its notes and intervals that distinguish it from the others. So to get the sound of that mode, the music will tend to emphasize its unique features.
We know "Highway to Hell" is not Lydian, for example, because it doesn't call attention to the #4 Lydian has relative to major. It's not Phrygian, because it doesn't make use of the b2.
The problem of modes and popular music
"Highway to Hell" is in A Major; however, it avoids G# in favor of G. This is a characteristic quirk of rock. When the song goes to the V chord, it uses the leading tone rather than the lowered seventh of mixolydian. That consistent presence of the leading tone is what makes the song major despite the frequent use of the b7.
One common place for the b7 to appear is in the VII chord itself. This is often used to move to the I chord (the "backdoor cadence"). A song that uses this progression and avoids the V chord with the leading tone (i.e. avoids the chord altogether or uses the minor V) could be more properly said to be in Mixolydian.
Comment: "the song uses C# more than C" - I'm trying to find the C# in this song, but I can't. But C is definitely used during the solo, which I understood uses notes from both A Major Pentatonic and A Minor Pentatonic.
Comment: @AcidMammoth It's in the A chords, which are clearly major rather than minor.
Comment: Yeah... I heard them as power chords (just A and E notes), but I guess a C# can be heard sometimes (or is just that the chord overall "sounds" major in the context of the song?).
Comment: @AcidMammoth I'm inclined toward the latter. The C# might just be an overtone or something, but clearly singing a C# against the chord "works" where C doesn't.
Comment: Another way to view the problem of rock in terms of major versus minor is often there are elements of both, similar to blues and jazz and some Beethoven.
Answer: The 'home' chord is the most telling part of what a key is. In Highway to Hell, it's definitely an A chord - it re-appears all through the song, and is used as the last chord. The next tell is that E chord - the dominant, which most often heralds the root/home chord by a feeling of building up to reach it - and that's present too.
So far, it's in key A. But there's that G chord ever present, which isn't diatonic to key A. The G note itself tells us that. Even though it's there in the E chord (so much distortion it's hard to tell!).
So, the song is more likely in A Mixolydian, although the key signature when written could be either 2 or 3 sharps - that's down to whoever writes it. With, of course, the appropriate accidentals either ♯ or ♮ on the G notes involved. Suffice to say, with modern pop music 'it's in A'.


Conservation Law for Heat Equation on Infinite Domain

Question: Let $$ u_{t}(x,t) = \Delta u(x,t) \space \space \space \text{ for } \space t \ge 0 \space \space\space\space , \space x \in \mathbb{R}^{n} $$
and $$ u \rightarrow 0 \space \text{ as }  \space ||x|| \rightarrow \infty $$
Show $$I(t) =  \int_{\mathbb{R}^{n}} {u(x,t) } dx = constant $$
What i have attempted so far is to apply Lipschitz and the Divergence Theorem on a finite sphere and then try and show the limit comes out as zero. This works up until the limit part, then i get a bit  stuck. Maybe i'm missing something obvious.
thanks for any hints/advice you can provide!
EDIT: very grateful for the solutions you provided
Comment: By $u$ do you mean $u(x,0)$?
Comment: i think i have for all  $t \ge 0 $
Answer: For given initial conditions $u(x,0)$, you can write the solution as a convolution against the fundamental solution as
$$
u(x,t) = \int_{\mathbb{R}^n}\frac{1}{(4\pi t)^{n/2}}e^{-||x-x'||^2/4t}u(x',0)dx'
$$
You can verify that such a representation matches your boundary condition at infinity. Then integrating over x:
$$
\int_{\mathbb{R}^n} u(x,t)dx = \int_{\mathbb{R}^n}\int_{\mathbb{R}^n}\frac{1}{(4\pi t)^{n/2}}e^{-||x-x'||^2/4t}u(x',0)dx'dx
$$
If the initial condition is well behaved enough, we can switch the order of integrations:
$$
\int_{\mathbb{R}^n} u(x,t)dx = \int_{\mathbb{R}^n}u(x',0)\left(\int_{\mathbb{R}^n}\frac{1}{(4\pi t)^{n/2}}e^{-||x-x'||^2/4t}dx\right) dx'
$$
The inner integral is unity, leaving
$$
\int_{\mathbb{R}^n} u(x,t)dx = \int_{\mathbb{R}^n}u(x',0)dx'
$$
The heat equation "smears out" the initial condition in time, but conserves it's total integral as time goes on. All that's left is to decide what is regular enough to justify switching the integration order.


$\sigma$-algebra generated by random variable : Show that if $\sigma(X)=\sigma(Y)$ then $\sigma(X+Y)\subseteq \sigma(X)$

Question: Let $(\Omega,\mathcal{F},P)$ be a probability space and $X$ be a random variable. The $\sigma$-algebra generated by $X$ is defined as
$$\sigma(X):=\{X^{-1}(B)\; | \; B\in B_{\mathbb{R}}\}$$
where $B_{\mathbb{R}}$ is the Borel $\sigma$-algebra of subsets of $\mathbb{R}$. The problem statement is as follows :
Let $(\Omega,\mathcal{F},P)$ be a probability space and $X,Y$ are random variables such that $\sigma(X)=\sigma(Y)$. Show that $\sigma(X+Y)\subseteq \sigma(X)$.
I can show that $X+Y$ is a random variable. So, how do I go about proving this?
Answer: By definition, $\sigma(Z)$ denotes the smallest $\sigma$-algebra $\Sigma$ on $\Omega$ such that $Z: (\Omega, \Sigma) \to (\mathbb{R},\mathcal{B}(\mathbb{R}))$ is measurable.
This means in particular that $X:(\Omega,\sigma(X)) \to (\mathbb{R},\mathcal{B}(\mathbb{R}))$ is measurable. Since $\sigma(Y) = \sigma(X)$, we also have that
$$Y: (\Omega,\sigma(X)) \to (\mathbb{R},\mathcal{B}(\mathbb{R}))$$
is measurable. Consequently, the sum
$$X+Y: (\Omega,\sigma(X)) \to (\mathbb{R},\mathcal{B}(\mathbb{R}))$$
is measurable as a sum of two measurable random variables. Since $\sigma(X+Y)$ is the smallest $\sigma$-algebra $\Sigma$ such that
$$X+Y: (\Omega,\Sigma) \to (\mathbb{R},\mathcal{B}(\mathbb{R}))$$
is measurable, this shows $\sigma(X+Y) \subseteq \sigma(X)$.


Como posso enviar um objeto JSON do meu android para o php?

Question: Preciso enviar um objeto JSON do meu app android para a minha api em php. Como posso fazer isso?
public void btnCadastrar(View view) throws JSONException, IOException {

    final EditText edtNome = ((EditText) findViewById(R.id.edtNome));
    final EditText edtSobrenome = ((EditText) findViewById(R.id.edtSobrenome));
    EditText edtCelular = ((EditText) findViewById(R.id.edtCelular));
    EditText edtCep = ((EditText) findViewById(R.id.edtCep));
    EditText edtLogradouro = ((EditText) findViewById(R.id.edtLogradouro));
    EditText edtBairro = ((EditText) findViewById(R.id.edtBairro));
    EditText edtLocalidade = ((EditText) findViewById(R.id.edtCidade));
    EditText edtUF = ((EditText) findViewById(R.id.edtUF));

    final String nome = edtNome.getText().toString();
    String sobrenome = edtSobrenome.getText().toString();
    String celular = edtCelular.getText().toString();
    String cep = edtCep.getText().toString();
    String logradouro = edtLogradouro.getText().toString();
    String bairro = edtBairro.getText().toString();
    String cidade = edtLocalidade.getText().toString();
    String uf = edtUF.getText().toString();

    JSONObject dadosJsonObject = new JSONObject();
    dadosJsonObject.put("nome", edtNome.getText().toString());
    dadosJsonObject.put("sobrenome", edtSobrenome.getText().toString());
    dadosJsonObject.put("celular", edtCelular.getText().toString());
    dadosJsonObject.put("cep", edtCep.getText().toString());
    dadosJsonObject.put("logradouro", edtLogradouro.getText().toString());
    dadosJsonObject.put("bairro", edtBairro.getText().toString());
    dadosJsonObject.put("cidade", edtLocalidade.getText().toString());
    dadosJsonObject.put("uf", edtUF.getText().toString());
    dadosJsonObject.toString();
    //Toast.makeText(getBaseContext(),"Dados retornados: "+dadosJsonObject, Toast.LENGTH_LONG).show();

    //String url =  "http://reservacomdomanda.com/areaAdmin/api/area_admin/usuario.php?dados="+dadosJsonObject;
    URL url = new URL("http://reservacomdomanda.com/areaAdmin/api/area_admin/usuario.php");

}

PHP:
<?php
header("Access-Control-Allow-Origin: *");
ini_set('display_errors', true);
error_reporting(E_ALL);

include_once("con.php");

$pdo = conectar();

$data = file_get_contents("php://input");
$data = json_decode($dadosJsonObject);

print_r($data);
?>

Answer: A grosso modo seria algo do tipo
public class MyAsyncTask extends AsyncTask<String, String, String> {
    @Override
    protected String doInBackground(String... params) {
        URL url = null;
        try {
            String path = (String) params[0];
            String json = (String) params[1];

            url = new URL(path);

            HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();

            httpURLConnection.setRequestMethod("POST");
            httpURLConnection.setReadTimeout(30000);
            httpURLConnection.setConnectTimeout(30000);
            httpURLConnection.setDoInput(true);
            httpURLConnection.setDoOutput(true);

            httpURLConnection.connect();

            OutputStream outputStream = httpURLConnection.getOutputStream();
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, "UTF-8");

            outputStreamWriter.write(json); //dados a seram enviados

            outputStreamWriter.flush();
            outputStreamWriter.close();

            String inputLine = "";

            InputStreamReader streamReader = new InputStreamReader(httpURLConnection.getInputStream(), "UTF-8");

            BufferedReader reader = new BufferedReader(streamReader);

            StringBuilder stringBuilder = new StringBuilder();

            while ((inputLine = reader.readLine()) != null) {
                stringBuilder.append(inputLine);
            }

            reader.close();
            streamReader.close();

            return stringBuilder.toString();

        } catch (MalformedURLException e) {
            e.printStackTrace();
            return null;
        } catch (ProtocolException e) {
            e.printStackTrace();
            return null;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }

    }
}

E chamada algo do tipo:
MyAsyncTask myAsyncTask = new MyAsyncTask();
myAsyncTask.execute("http://reservacomdomanda.com/areaAdmin/api/area_admin/usuario.php", dadosJsonObject.toString()); // trocar pelos seus dados

Lembrando que criei essa AsyncTak dummy que de ve funcionar só para exemplificar.
Sugiro que dê uma olhada em AsynkTask para adaptar às suas necessidades
Comment: OK, verei isso.
Comment: Cara, achei várias coisas sobre AsyncTask, mas nenhuma que fosse clara, nada que eu entendesse


Rules for notating rests in tuplets

Question: Here are some examples of rhythms with rests in tuplets:

The first line shows 3 ways to notate the same rhythm.
The second line shows 2 ways to notate another rhythm.
The third line shows 4 various tuplet rhythms.

Are these tuplets all notated correctly?
What rules apply to notating groups of notes and rests in tuplets?
Comment: Actually I can't recognize, how the the rythm in the second line is different from the first.
Comment: Related: [How to write rests in triplet semiquaver groups](https://music.stackexchange.com/questions/116385/how-to-write-rests-in-triplet-semiquaver-groups)
Answer: Yes, those tuplets are all notated "correctly". Notating tuplets is the same as notating any sort of rhythm; make the subdivisions as clear as possible. This depends on how you want the tuplet to be subdivided. It could be subdivided into 2 quarter notes, 4 eighth, 1 dotted quarter/1 eighth, etc. It depends on the song and arrangement. If all the voices are playing that rhythm together the subdivison isn't as important, while if it were an independent line clearer subdivision is much more important.
On the first line, first measure you can see how all 4 eighth notes are expressed in the tuplet clearly. If this were a repeating line it might be best to notate the first bar this way while using a more compact version, such as the third measure, for the rest of the repeats. However, the third bar is not bad either, especially if you're subdividing it as dotted quarter/eighth the whole time.
For the second line either one would work, though the two eighth rests would be clearer at first glance.
On the third line, measure 7, it might be wise to notate the dotted quarter note as a quarter tied to eighth to make it clearer, but again it depends on how you want to subdivide it. If measure 8 were following the same subdivision as written in 7 I would divide the dotted quarter into eighth and quarter.
Measures 9 and 10 are interesting in that you could justify further dividing them into sixteenth note 8-tuplets, especially measure 10. Turning the rests into sixteenth rests would more clearly show that. Since there are only 3 sixteenth notes it's not as important, but the more you add the more important I would rate it.
To reiterate, notating tuplets involves identifying their weak and strong beats and emphasizing those, both of which depend on the type of musical line you wish to write and what effect you're going for. If all the beats are relatively equal, or only the first is, then you should make it clear how the full tuplet is laid out. Since this is a 4 note tuplet made of eighth notes the standard procedure would be to make sure all 4 of them are clearly marked rather than obfuscate them with longer rhythms.
Comment: @Tama, I disagree. 3, 4, 8, 9 are all pretty poorly notated. Also, disagree with your second point; putting it in 2/4 with 16ths and triplets would sound exactly the same and would be much easier to read, thus a better performance. It doesn't matter if it's a motive or not.
Comment: It may be easier to read in 2/4 for most people but if this rhythm is intermittent to the rest of the piece being in 6/8 then it makes less sense to switch back and forth, especially since a tempo change would also be necessary. These rhythms aren't written in isolation.
Comment: Thanks. Here is an [expanded example](https://imgur.com/a/XGYYl) --- Bar 11 shows one of my original examples, bar 12 shows one of your suggestions and bar 13 shows another possibility ---

Can you please further explain why you think bar 12 may be clearer than bar 11?
Comment: You seem to have a grasp of subdivision, but I disagree that they're all notated correctly. If the composer is writing dotted rhythms in tuplets un compound meter, I'd challenge them to rewrite it. Much clearer then to use simple meter with triplets as necessary if they feel compelled to go that route. Also, as you said, metric subdivision. Some of those examples improperly subdivide the rest, so they couldn't be correct
Comment: Thanks @jjmusicnotes. Can you please explain with more specifics on why some of my examples are incorrect? What divisions need to be shown in these tuplets? Should they be notated like they are in 4/8?
Comment: @jjmusicnotes Improperly subdividing the rest would be something like three 16th note rests with a dotted 8th note. None of these are egregiously bad like that, and the dotted 4th/8th rhythm does sound distinct enough to use, esp if this is a motif. It really depends on the melody he's going for.
Comment: @JySmith Bar 12 may be clearer than bar 11 if you're subdividing the tuplet into two groups of 8th notes like most people would. It's like writing any syncopated rhythm, you want the groupings to be consistent. Bar 13 would be unnecessary since we usually group two 8th notes together anyway and would be less clear. Bar 11 is what you would do if that is your main rhythm for the line.
Answer: The rules for notating your irregular groups in the time of a dotted crotchet/quarter are the same as for notating a regular group that lasts a minim/half.
The first is wrong; the second and third are correct. The fourth is correct; the fifth is wrong. It is OK to write a syncopated crotchet/quarter note that way, but a rest must be split.
In your last two examples, the notes and rests are OK but the numeral should be 8, not 4.
Comment: Sorry, they're not. You need to be cognizant of metric subdivision. You're assertions here are incorrect.
Comment: Thanks. Doesn't the way a "regular group that lasts a minim/half" get notated depend on the time signature?

Where would you normally see a dotted crotchet/quarter rest followed by a quaver/eighth note? (like the rest and note under the tuplet bracket in bar 3)
Comment: @jjmusicnotes Please could you clarify which of my assertions are incorrect and why?

Rules for notating rests in tuplets


tuning of marimba in a jazz band

Question: I started playing the marimba and although it seems a bit unusual I wish to be part of a jazz band with that instrument. Fortunately, before buying my own instrument I found out that marimbas have different pitches, some really nice ones are A=443. But I do need to get an instrument that is tuned at A=440 to fit in with a band, right?
Comment: This Q&A may shed some tight: [Why is A=442 the common tuning for percussion instruments?](https://music.stackexchange.com/questions/40605/why-is-a-442-the-common-tuning-for-percussion-instruments).
Answer: Although lots of bands choose A=440Hz as their tuning base, it doesn't have to be.
Marimbas are not possible to tune up/down, so they are what they are. However - all other instruments (discounting pianos/organs/Fender Rhodes et al) can be adjusted. Decades ago, in bands, where there was a piano at the venue that was enough in tune to be playable, my band would tune to it - inevitably a bit low - so at least everyone was in tune. Even if there's an electronic keyboard to be part of the band, most have the facility to be fine-tuned.
So, whilst it would seem advisable to have a marimba in 'standard' tuning, if A=443Hz provides a far better instrument, I'd have thought all the other band members would be able to match that with no real problems, except perhaps for those with AP.
Comment: @Edward I suppose it was a reference to the OP saying "some really nice ones are A=443", even if it's not clear if that's an assumption based on availability, maker production or just misunderstanding.
Comment: Vibraphones appear in orchestras, and part of the vibraphone market (probably a large part) is high school marching bands, where they will be played alongside marimbas.
Comment: "If A=443 provides a far better instrument"  I don't see how tuning a bit sharp would change the quality of the instrument at all.
Comment: @Edward - not tuned sharp, as such, but tuned to a different A pitch. Probably for a market in a different part of the world.
Comment: With "nice" I meant that I found an affordable instrument with bars made of palisander. The sound of those bars is supposed to be the best. As to the "different markets": It seems to be more a question of whether playing in a classical orchestra, where the standard tuning in many countries is A=442 (even 443) or playing Jazz, Pop etc. where the standard tuning in any country is A=440. On the other hand even Vibraphones - and they are pure Jazz, aren 't they? - come in 442 and 443.
Answer: Not all instruments are at the same pitch. I heard a piano tuner interviewed, who tuned pianos for the big concert halls, and he said for piano concertos he tuned the piano 1.5 cents sharp. Certain instruments are tuned slightly sharp, I think the accordion is for ensembles. Also 440 is not universal, in Vienna I believe it is 442-444.
If the marimba or vibraphone is flat in relation to the the ensemble it is not a good sound. An example was on British light music radio programmes. The style many years ago was to finish a piece on a rising violin scale, followed by a vibraphone chord. Because the violins would rise in pitch throughout the performance the final vibraphone added 6th chord was often flat.
I would suggest you go on a specialist tuned percussion forum, or talk to a marimba technician. My guess is the marimba is deliberately tuned slightly sharp.
Comment: 1.5 cents would hardly be noticeable -- A4 would be 440.38 Hz, so it would beat against 440 Hz slightly faster than every three seconds.
Comment: I'd love to hear an example of that flat marimba in a "British light music radio programme". Any chance of a link? Thank you.

tuning of marimba in a jazz band


Spring MVC @ModelAttribute getting filled Entity

Question: Today I am stuck with the spring-form with the POST method which doesn't give posted item to the Controller which I wanted. Here is my code.
Controller.java
@Controller
@RequestMapping("/cart")
public class CartController extends CommonController
{
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ModelAndView addCart(@ModelAttribute("productList") Item item, BindingResult result,Model model){
         System.out.println(item.getId()); /// <-- doesn't gives me the ID
         return new ModelAndView("cart");
    }
 }

ProductList.jsp
/// Loop through the products of search itemlist and generates the forms with the correct items
<c:forEach var="item" items="${productList.items}" varStatus="status">
                    ${item.name}

        <c:url value="/cart/add.html" var="addURL" />
            <form:form method="POST" action="${addURL}" modelAttribute="productList">
                <form:hidden path="items[${status.index}].id"/>
                <input type="submit" class="addCartBtn" value="Add to cart" />
            </form:form>

BackingBean.java
public class SearchForm implements Serializable
{
   private Collection<Item> items;
   private String term;
   // getters and setters
}

The ${productList} is the backingbean which loops through all items.
I don't really know what the problem is why it isn't giving me the correct data it passed through the POST.
Many thanks.
Answer: Covert your spring:hidden tag to normal html hidden tag:
<form:hidden path="items[${status.index}].id"/>

to
<input type="hidden" name="id" value="${item.id}"/>

Comment: Have replaced it to what you said but still ain't getting the item through the post method. The item is still with no content.
Comment: It does fill in the item id in the Item now but it's not getting all the item data out. Or I am just misunderstanding the attribute of @ModelAttribute :(.
Comment: Sorry I completely lost you!!
Comment: The thing I wanted is that if I press on the submit button that it is going pass the whole item with all the data that the item has. But with the input type hidden you gave it only pass the id from the item but not all the data from the item.
Comment: oh my bad i have misunderstood the functional thing but :) haha your answer is right. So many thanks ^^ for your answer =D. I just need to use an converter to parse the data into it after the post. thanks thanks :)


Unable to trigger custom validation function on a FilteringSelect input

Question: The following code works for a textbox , I am able to override the default validator function with my own and force it to return false, making the input invalid.  However this does not work at all with FilteringSelect inputs.  The following code always returns true - in fact it never enters my custom validation function.
Which means it is executing a different validator than expected, OR I am setting the validator on the wrong input (there are multiple when rendered).
var customValidator = function (value) {
    console.log("custom validator: ", value);
    return false;  //force an invalid result
};

formelement.theInput.set('validator', customValidator);

var res = formelement.theInput.validate();
console.log("res: ", res);

The widget template looks lke this

    <select data-dojo-type="dijit/form/FilteringSelect" data-dojo-attach-point="theInput"
            data-dojo-props="labelAttr:'text', searchAttr:'text', required:false, "   >
    </select>

Which when rendered looks like this

        <input class="dijitReset dijitInputField dijitArrowButtonInner" value="▼ " type="text" tabindex="-1" readonly="readonly" role="button presentation" aria-hidden="true">

        <input class="dijitReset dijitInputField dijitValidationIcon dijitValidationInner" value="Χ " type="text" tabindex="-1" readonly="readonly" role="presentation">

        <input class="dijitReset dijitInputInner" type="text" autocomplete="off" data-dojo-attach-point="textbox,focusNode" role="textbox" aria-autocomplete="both" tabindex="0" id="dijit_form_FilteringSelect_28" aria-required="false" value="" aria-invalid="false" maxlength="25" style="font-family: Arial; font-weight: 400; font-style: normal; color: black; text-decoration: none; text-align: left; background-color: transparent;">
        <input type="hidden" value="CA">

Answer: Ithink this due to isValid function , it is overrided in the  FilteringSelect , so it wont have same behaviour as the textBox .
What I suggest is to ovveride the isValid again , after setting your custom validator as bellow :
formelement.theInput.isValid =
    function() {
          return this.validator(this.textbox.value,this.get('constraints'));
         // force new validator above
    }

Bellow is a sample snippet:

require(["dijit/registry", "dijit/form/FilteringSelect","dojo/on","dijit/form/Button","dojo/ready"],
  function(registry,dom,On,Button,ready){
      ready(function(){
          var customValidator = function (value) {
              console.log("custom validator: ", value);
              return false;  //force an invalid result
          };
          formelement = registry.byId("formelement");
          formelement.set('validator', customValidator);

          formelement.isValid = function() {
            return this.validator(this.textbox.value, this.get('constraints'));}

          var res = formelement.validate();
          console.log("res: ", res);

          var btn = registry.byId("btn");
          On(btn,"click",function(){
            console.log(formelement.validate());
          });
        })
    });

<link href="//ajax.googleapis.com/ajax/libs/dojo/1.10.0/dijit/themes/claro/claro.css" rel="stylesheet"/>

 Validate

    <select id="formelement" data-dojo-type="dijit/form/FilteringSelect" data-dojo-attach-point="theInput"
            data-dojo-props="labelAttr:'text', searchAttr:'text', required:false, "   >
    </select>

Comment: interesting use of validator
Comment: I tested this code and yes this worked (for all input types that use validator, textbox, filteringselect, numbertextbox, etc), thank you.
Comment: does it make sense ?


toggle div on hover of one element, and off another?

Question: What I am trying to achieve is showing the "menu" span, when I hover on the "title" span, but only have it disappear when I leave the "header".

            title etc

            menu content etc

I wrote this jquery code, and it works, except the "menu" span disappears when I leave the "title" span, not the "header"
$('#title').hover({
    $('#menu').toggle();
});

Any idea how I could fix this?
Answer: One way you can achieve this is by restructuring your menu a bit, in your real world scenario positioning can take care of how it appears.

            title etc

            menu content etc

Fiddle
here is an example with a more complex one.

            title

                 menu11
                menu12
                 menu13

            title2

            menu21
                menu22
                 menu23

Fiddle
And with just css for the above structure:
.menu {
    display:none;
    position:absolute;
    top:10px;
    left:0;
}
.title {
    position:relative;
}
.title:hover .menu{
    display:block;
}

Fiddle
Comment: With this, instead of using jquery, I would suggest css :hover instead to avoid javascript as a "dependency".
Answer: How about:
$('#title').mouseenter(function(){
    $('#menu').show();
});

$('header').mouseleave(function(){
    $('#menu').hide();
});

Here is a jsfiddle for it: http://jsfiddle.net/5sL5g/
Comment: Was just about to post more or less the same as an answer, for reference and example: http://api.jquery.com/mouseenter/


Derivative of a Wiener integral using Ito formula

Question:
Given the process $X_t=\int_0^t g_s\,dW_s$, compute $dX_t$ using the Ito formula.

The Ito formula says that, given:
$$f(t,X_t)=f(0,X_0)+\int_0^t\frac{\partial f}{\partial s}(s,X_s)\,ds+\int_0^t\frac{\partial f}{\partial x}(s,X_s)\,dX_s+\frac{1}{2}\int_0^t\frac{\partial^2 f}{\partial x^2}(s,X_s)\,d\langle X \rangle_s$$
it holds:
$$df(t,X_t)=\frac{\partial f}{\partial t}(t,X_t)\,dt+\frac{\partial f}{\partial x}(t,X_t)\,dX_t+\frac{1}{2}\frac{\partial^2 f}{\partial x^2}(t,X_t)\,d\langle X \rangle_t$$
I already know the result, that is $dX_t=g_t\,dW_t$, but I would like to understand how Ito formula works. I guess that first and third terms in the formula for $df$ are zero, but I don't get why. Why is $\frac{\partial f}{\partial t}(t,X_t)=0$ ? Since $X_t$ is a definite integral, I thought that it should be equal to $G(t)-G(0)$, where $G$ is the primitive of $g$, and so, since $G(t)$ is a function of time, its derivative is not zero.
So the question is how to compute these terms:
$$\frac{\partial f}{\partial t}(t,X_t),\quad\frac{\partial f}{\partial x}(t,X_t),\quad \frac{\partial^2 f}{\partial x^2}(t,X_t)\quad ?$$
Answer: You should put $f(t,x) = x$. It follows immediately that
$$
\frac{\partial f}{\partial t}(t,x) = 0, \;\frac{\partial f}{\partial x}(t,x) = 1, \; \frac{\partial^2 f}{\partial x^2}(t,x) = 0.
$$ By Ito's formula, we have
$$
X_t = \int_0^t dX_s = \int_0^t g_sdW_s,
$$ which is an obvious result.
Comment: Perhaps using $x$ as a variable is confusing you. To see those examples clearly, I will write as $ f(t,w) = e^{\alpha w} \rightarrow X_t = e^{\alpha W_t}=f(t,w)|_{w=W_t} $ and $f(t,x) = x^2 \rightarrow Z_t = X_t^2 = f(t,x)|_{x= X_t}$. In this case, $f(t,x) = x \rightarrow X_t = X_t = f(t,x)|_{x=X_t}$.
Comment: I'll elaborate on what you are missing. If we put $f(t,x) = x$, then what follows from $X_t = f(t,x)|{x=X_t}$ is $dX_t = 0dt + 1dX_t + 0 d\langle X\rangle_t = dX_t$, not $dX_t = 0dt + 1dW_t + 0d\langle W\rangle_t$. (so the result is correct.) If we let $f(t,w) = e^{\alpha w}$ and $X_t = f(t,w)|_{w=W_t}$, then what follows is $dX_t = 0dt + \alpha e^{\alpha W_t}dW_t + \frac{1}{2}\alpha^2 e^{\alpha W_t}dt.$ You may see that both results are not contradictory.
Comment: Yes, it's right. $f(t,x) =x$ can only give us a trivial result. Ito's lemma is useful when $f(t,\cdot)$ describes a non-trivial relation between two (usually different)  stochastic processes. It allows us a stochastic integral representation.
Comment: Thank you for the answer. Could you please explain why you put $f(t,x) = x$ ? From other exercises I learned to substitute the process with $x$, for example: $$\begin{align*}X_t=e^{\alpha W_t} \quad &\to f(t,x) = e^{\alpha x}\\ Z_t=X_t^2, \text{ with }dX_t=\alpha X_t dt+\sigma X_t dW_t \quad &\to f(t,x) = x^2\end{align*}$$ So in this exercise I did put $f(t,x)=\int_0^t g_s\,dx$, but I was not able to compute the three partial derivatives. Could you help? Where am I wrong?
Comment: Thank you for the clarification. But I still don't uderstand how it is possibile to make that choice. If we have $X_t=e^{\alpha W_t}$, and we put $f(t,x) = x$ (i.e. $X_t = f(t,x)|_{x=X_t}$), then we have $$\frac{\partial f}{\partial t}(t,x) = 0, \;\frac{\partial f}{\partial x}(t,x) = 1, \; \frac{\partial^2 f}{\partial x^2}(t,x) = 0.$$ but it is not correct because in that case $dX_t=\alpha X_t dW_t+\frac{1}{2}\alpha^2 X_t dt$. I am missing something I guess.
Comment: Thank you, ok maybe now I'm understanding. But letting $f(t,x)=x$ give us $dX_t=dX_t$ so we don't have the explicit result; while letting $f(t,w)=e^{\alpha w}$ we are able to compute $dX_t$. Is this right?
Comment: Thank you. So to be more clear, shouldn't you put $s$ instead of $t$ in the first two rows of your answer? Because then you plug the partial derivatives (with $s$ instead of $t$) in the formula of $f(t,X_t)$ written in my answer, and finally we obtain the final result. Isn't it?


Ssl reverse proxy from IIS to Node on same server. Ok to redirect internally over http?

Question: I've got IIS exposed to the internet. On the same server I've got a NodeJS-app running (port 8080). I need to expose the node app over SSL to the internet.
Is it possible to just switch from Https -> http when doing the reverse proxy call from IIS -> Node?
This would make my life easier because I don't need to support https directly on Node. Hence, I'd only need to install a SSL-cert on the IIS-server.
So in short my plan is:
ssl (443) -> IIS ->  - (https -> http) -> NodeJS (8080)
Is this possible?
Answer: If you redirect your HTTP requests to the loopback address 127.0.0.1:8080 it can be considered pretty secure as it will not pass through the network at all (TCP/IP stack wont send it to the physical network). Just make sure you only expose the IIS SSL port to the external network (blocking 8080 with the firewall).


Python: Set Color for Tkinter Button using .grid()

Question: using the Python 2.7 Tkinter Grid Layouter, i would like to do something like
root.button = Button(root, bg = 'green', ....)
root.button.grid(...)

in order to get a green button.
Running this, it doesn't bring up any errors, but the button does not take the desired color.
Any suggestions greatly appreciated!
EDIT:
thanks for the code, i copied it and run it, here is what i get: still a white button ..?
Comment: Are you running this on OSX?
Answer: Passing bg keyword argument works as expected. Try following:
from Tkinter import *
root = Tk()
button = Button(root, text='buggton', bg='green')
button.grid(row=0, column=0)
root.mainloop()

Comment: @BuroBernd, Ahh, you use osx. See [How do I change the foreground or background colour of a Tkinter button on Max OS X 10.6 with Python 2.6.1?](http://stackoverflow.com/questions/1529847/how-do-i-change-the-foreground-or-background-colour-of-a-tkinter-button-on-max-o)


Multiple bags Exception / Buscando várias coleções com JPA

Question: Estou com um problema com JPA na hora de fazer uma consulta.
Quero consultar a Entidade A que possui uma List de Entidade B e List de Entidade C (quero consultar a Entidade A trazendo os relacionamentos com as Entidades B e C em uma mesma query).
Quando tento executar essa query a exceção de multiple bags é lançada.
Tem alguma forma de fazer essa consulta sem ter que usar @IndexColumn, Fetch.EAGER ou alterar List para Set? (Soluções que encontrei na internet)
OBS: não coloquei o código aqui pois só quero saber se existe uma outra alternativa além dessas que citei anteriormente.
Comment: Já resolvi, e obrigado à quem votou negativo ;)
Answer: A causa mais comum para este erro é quando você tenta fazer 2 (ou mais) JOINs usando FETCH, sendo que cada um destes JOINs é por meio de uma List.
Vamos a um exemplo. Dada as (pseudo) entidades:
@Entity
class Entidade1 {
    private List<Entidade2> entidades2;
}

@Entity
class Entidade2 {
    private List<Entidade3> entidades3;
}

O seguinte JPQL irá reproduzir o problema:
SELECT e1 FROM Entidade1 e1
JOIN FETCH e1.entidades2 e2
JOIN FETCH e2.entidades3 e3

A solução mais comum é esta: alterar de List para Set o mapeamento de entidades2 e entidades3. A solução com EAGER eu nem consideraria, tamanha as consequência que ela pode trazer para a aplicação.
Ou, se possível, evite usar um JOIN FETCH a partir de outro. Até onde sei, apenas o Hibernate suporta alias em JOIN FETCH, permitindo este tipo de situação e erro.
Assim, a solução que recomendo é considerar o uso de um VO, trazendo apenas o que precisa das 3 entidades:
SELECT new br.com.EntidadeVO(e1.id, e1.nome, e2.id, e3.nome) FROM Entidade1 e1
JOIN e1.entidades2 e2
JOIN e2.entidades3 e3


What is the most popular running (and fitness) application for mobile devices?

Question: I have used runtastic and Daily Mile and of course there is Garmin, but what mobile applications besides these are most popular for running and/or fitness and why? I'm looking to see what other features are out there that I don't have.
Comment: Voted as off-topic as running for recreational and fitness purposes is off-topic for this site and should be asked in [F&N](http://fitness.stackexchange.com). Running questions must specifically relate to competitive running.
Comment: Voted to close as not constructive since questions of type "What is the best..." typically yield subjective answers and a long discussion instead of a definitive answer.
Comment: @Dmitry but it's not asking for the best. It's asking for the most popular, which has an objective response. Although there are multiple ways to measure popularity (user count, average satisfaction rating, average word-of-mouth recommendations) answers can be grounded in facts and references.
Comment: @glowcoder I can see where you are coming from and I tried arguing this before but most of the time questions like this turn into a mess unfortunately.
Comment: @MarcusSwope You seem to imply that for competitive sports - here running - you will not be using these applications? Is that really true? I expect many to use their mobile devices instead of a dedicated device such as Garmin. Or? I vote to re-open.
Comment: How can we compare this question to http://sports.stackexchange.com/q/86/38
Comment: @TonnyMadsen this question isn't constructive because it ask for a product recommendation. Its a shopping question, not because it has to do with running.
Comment: @TonnyMadsen it's not because of what the question is about, it is what it isn't about. Running and applications that help people run are definitely on topic, but I don't see in the question where this has to do specifically with competitive running, it seems to me to be more about running for recreational or fitness purposes. If the question was edited to address competitive running (as well as not be a shopping question as wax eagle noted) then I would vote to re-open.
Comment: @MarcusSwope - If you keep closing topics stating that they aren't constructive and/or should be located elsewhere, what's the purpose of the site? Most of the questions asked can be defined as not constructive. Many have wikipedia answers and/or can be found using a simple Google search.
Comment: @DmitrySelitskiy - If you keep closing topics stating that they aren't constructive and/or should be located elsewhere, what's the purpose of the site? Most of the questions asked can be defined as not constructive. Many have wikipedia answers and/or can be found using a simple Google search.
Comment: @JasonN.Gaylord this was discussed [in meta](http://meta.sports.stackexchange.com/questions/30/competitive-or-recreational-running), we are still trying to come up with clear definition of what is on-topic and what is off-topic, especially with running.
Comment: @Marcus: and I don't feel that "it has to be competitive" is as clear a consensus as you imply in your first comment.
Comment: @JasonN.Gaylord I'm not _closing_ but am _voting_ to close which is how this site is designed: we as a community decide which questions we want to encourage and which ones not to.
Comment: @DmitrySelitskiy But for a new stack exchange site to have 10%+ of it's questions closed, I think the moderators (in which I felt I should be one as the running proposal was mine) need to clearly define what should be in here.
Comment: @JasonN.Gaylord see the note under the question: not moderators close questions - community does collectively (i.e. 5 people voted to close and the system closes it automatically). It's not a mod's decision.
Answer: There's the Nike+ iPod/iPhone app, which according to Nike:

Nike+ has 5 million users.

There are a number of Nike shoes that contain the requisite sensor/chip, and some third parties, such as Polar, have provided accessories that work with the Nike system.
Comment: There's also a Nike+ GPS app which doesn't require an external sensor.
Comment: The Nike+ app is great, but still is a very bad choice, because the day you will need to ski or bike you will have to find another app.
Comment: You don't need to have Nike+ specific shoes now either, both Marware (big fan of theirs) and SwitchEasy make accessories that can fit with any shoe.


Is there a corpus specifically for categories like sports, entertainment, or health?

Question: I am experimenting with Classification algorithms in ML and am looking for some corpus to train my model to distinguish among the different text categories like sports, weather, technology, football, cricket etc.
Where I can find some dataset with these categories?
An option would be to crawl Wikipedia for these 30+ categories. Is there  a better way to do this?
Edit: I want to train the model using the bag of words approach for these categories, then classify new/unknown websites to these predefined categories depending on the content of the webpage.
Comment: @learner could you give a description of what such a dataset would look like?
Answer: scikit-learn 20-newsgroups-text-dataset has
11314 train + 7532 test samples with 10,000 or more sparse features.
The newsgroup categories are:
alt.atheism
comp.graphics
comp.os.ms-windows.misc
comp.sys.ibm.pc.hardware
comp.sys.mac.hardware
comp.windows.x
misc.forsale
rec.autos
rec.motorcycles
rec.sport.baseball
rec.sport.hockey
sci.crypt
sci.electronics
sci.med
sci.space
soc.religion.christian
talk.politics.guns
talk.politics.mideast
talk.politics.misc
talk.religion.misc

For 2, 3, 4, 5 of these newsgroups (the worst ones) I get
83.2 82.6 82.2 80.6 % correct,
using the fast
sgd classifier.
(The first run of fetch_20newsgroups will take a while to download and cache the data.)


Blank page after save amazon s3 configuration

Question: I open configuration http://www.mysite.gr/admin/config/media/amazons3 and I put Amazon S3 API Key * Amazon S3 API Secret * and Default Bucket Name *
When I push the save button I get blank page
Answer:
Make sure your environment enable php "curl" extension.
Check your s3-php5-curl library is right place folder
check user have Amazon S3 Full Access Permission。
Answer: I've installed composer and it's working


Convergence of non-negative $(a_n)^p$ series if the series $a_n$ converges

Question: I tried to prove the following:
Suppose that $a_n$ is a sequence of non-negative numbers and that the series $\sum a_n$ converges. Prove that the series $\sum a_n^p$ converges for p>1.
How should I start this prove? Should I break down $a_n$ into three cases: $a_n$ equals 1, less then 1, greater than 1? or Should I use comparison test?
Answer: Well, you already gave the answer in your question.
If $\sum a_n$ converges, $\{a_n\}$ converges to zero. As we're dealing with non negative series and $p \gt 1$, we have for all $n $ large enough
$$0\le a_n^p \le a_n$$ and therefore $\sum a_n^p$ converges.
Answer: Hint:
There exists $\;N\in\Bbb N\;$ s.t. $\;n>N\implies a_n<1\implies a_n^p<a_n\;$ for $\;p>1\;$ ...