String sticking to the fretting finger - how to avoid?

Question: When raising a finger from a fret, it sometimes happens to me that a string "sticks" to the finger, producing an annoying sound (like when I would do a pull-off, but unintentional). This happens most often when I do the scales:

C D E F G (starting with the C on second string)

When playing the G (1st string, 3rd fret with 4th finger), I have to lift the 4th finger quickly from second string and put it on the first string. So, when I lift it, it does that annoying sound (of the open second string).
This happens to me 70% of the time. I have absolutely no idea how to avoid this; the following methods work but are not acceptable:

Playing slowly (not good because it's VERY slow)
Lifting the finger earlier (not good because I want that D note to ring while I am playing E and F)
Moving the finger along the string while raising it (it's absolutely awkward)

I tried cleaning fingers and strings with soap water and alcohol; doesn't help. I didn't try replacing the string. Speaking of that - I am not sure this is a new problem; maybe I was having that problem all the time and it didn't bother me; tried listening to my old recordings, but they are so awful, I couldn't determine it from them.
There are days when I don't experience this problem at all (maybe air is more dry?), but this is rare.
In addition, it's most often with the 4th finger, sometimes with 3rd finger, but never with others.
Comment: Do you think that it only happens on fingers 3 and 4 because the other fingers have better calluses?
Comment: @BenMiller It seems like your note on the callus is spot on!
Comment: Steel strings, or nylon?
Comment: @BenMiller Nylon (can I use steel in classical guitar?)
Comment: Sorry, I didn't see the classical-guitar tag.
Answer: My guess is that the direction the finger is moving is not perpendicular to the fretboard. And so you are in effect plucking the string with the small bit of flesh caused by the indentation of the string itself.
When you fret the string, the string frets you, so to speak. The string creates an indentation in the surface of the fingertip which will recover its smooth shape quickly or slowly depending on a great many factors.
But you should be able to get a clean release by lifting the finger in a strictly vertical direction. The indentations in the fingertip then have no opportunity to snag the string.
Comment: I often finish practice to find indented lines on all four of my left hand fingers!
Answer: Fingers can sometimes stick to strings if they do not have good calluses.  The third and fourth fingers might have this problem more than the index and middle fingers because they do not get used as often.  If you work on building up calluses on these fingers, the problem might lessen.
Comment: I have to dv, as I've played for many years, not had calluses for the last 50odd, and never had this problem.
Answer: I have the same problem. I see this is a very old post, but thought I may contribute anyway. It may help someone.
I have the problem not because of a lack of calluses. I have played for 40 years, and for the past several have played for hours every day.I have had well developed calluses for a very long time.
But I also have an autoimmune disease which has affected my skin. The indentations in my fingers run deeper and my fingers cling to strings galore at times, creating all kinds of miserable awful sounding unintentional "pull offs".
I can limit the damage by playing very cautiously, but there are never guarantees.
Once in a studio, it was suggested I use talc to help alleviate the problem. I did, and it kind of worked a bit, but not 100%. Found this post actually, as I was looking for a remedy, something I may be able to apply to loosen the "sticking power" of my fingers to the strings.
Putting it out there, just so people can perhaps realise that there are other issues that can cause this problem than under-developed calluses. Now, on to looking for that elusive product......


Easiest way to prove that $\int_{\pi/6}^{\pi/2} \sin(2x)^3\cos(3x)^2 \mathrm{d}x=\left(3/4\right)^4$

Question: I have been trying to evaluate this integral a few times. And my best attempt has been to rewrite is as a sum of linear combination of sine and cosine terms. Alas, this takes a couple of handwritten pages to accomplish. Is there any easier/faster/neater way to evaluate?
$$ \int_{\pi/6}^{\pi/2} \sin(2x)^3\cos(3x)^2\,\mathrm{d}x=\left(\frac{3}{4}\right)^4 $$
Thanks in advance =)
Comment: *The easiest way*, huh? What could be more subjective.
Answer: Write
$$ \sin 2x = \frac{e^{2ix}-e^{-2ix}}{2i}$$
and
$$ \cos 3x = \frac{e^{3ix}+e^{-3ix}}{2},$$
cube the first identity, square the second, and expand.
Answer: The way you describe is sensible. The notation is a little misleading, you probably intend
$$\int_{\pi/6}^{\pi/2} (\sin 2x)^3 (\cos 3x)^2\,dx.$$ If that is so, the answer is correct.
Unpleasantness is difficult to avoid here. A way to express as a linear combination is to start by using $\cos 2u=2\cos^2 u-1=1-2\sin^2 u$. Thus our integral becomes
$$\frac{1}{4}\int_{\pi/6}^{\pi/2}(\sin 2x)(1-\cos 4x)(1+\cos 6x).$$
Now continue. To save some writing, let $u=2x$. Then we want
$$\frac{1}{8}\int_{\pi/3}^\pi(\sin u)(1-\cos 2u)(1+\cos 3u)\,du.$$
using the formulas for expressing a product of sines and/or cosines as a sum of sines and cosines, which you probably already used. Easier by hand than with LaTeX!
Answer: $$\int_{\pi/6}^{\pi/2} (\sin 2x)^3 (\cos 3x)^2\,dx$$
Since $(\sin 2x)^2=1-\cos 4x$ and $(\cos 3x)^2=1+\cos 6x$
$$=
\frac{1}{4}\int_{\pi/6}^{\pi/2}(\sin 2x)(1-\cos 4x)(1+\cos 6x)$$
Substitute $u=2x$,
$$=\frac{1}{8}\int_{\pi/3}^\pi(\sin u)(1-\cos 2u)(1+\cos 3u)\,du$$
Use the formula $\sin u=\frac{e^{iu}-e^{-iu}}{2i}$ and $\cos u=\frac{e^{iu}+e^{-iu}}{2}$,
$$= \frac{1}{8}\int_{\pi/3}^\pi \frac{e^{iu}-e^{-iu}}{2i}(1- \frac{e^{2iu}+e^{-2iu}}{2}
)(1+\frac{e^{3iu}+e^{-3iu}}{2})du$$
Expand,
$$= \frac{1}{64i}\int_{\pi/3}^\pi( - (e^{6iu}-e^{-6iu})+3(e^{4iu}-e^{-4iu})-2(e^{3iu}-e^{-3iu})-3(e^{2iu}-e^{-2iu})+6(e^{iu}-e^{-iu}) )du$$
Use the formula $\sin u=\frac{e^{iu}-e^{-iu}}{2i}$, go back to $\sin$
$$= \frac{1}{32}\int_{\pi/3}^\pi(-(\sin 6u)+3(\sin 4u)-2(\sin 3u)-3(\sin 2u)+6(\sin u))du$$
Do the integral, in total five parts,
$$= \frac{1}{32}(\cos 6u/6-3\cos 4u/4+2\cos 3u/3+3\cos 2u/2-6\cos u)|_{\pi/3}^\pi$$
Calculate the value for each of the five parts,
$$= \frac{1}{32}(0-9/8+0+9/4+9)=\frac{3^4}{4^4}$$
Comment: @Peter Phipps: Thanks, I edited the answer acoording to your advice.


How to solve the following linear PDE?

Question: I want to solve the following equation

how to solve it? I know that the evolution equation can be changed to a heat equation, but the boundary condition and initial condition changes to the new space which is a moving boundary.
Answer: Hint:
With reference the substitution concept in How to solve a PDE with in which the coefficient which depends on time but singular at a point?,
Let $\begin{cases}z_1=e^{\int^v\xi(v)~dv}z\\v_1=v\end{cases}$ ,
Then $\dfrac{\partial g}{\partial z}=\dfrac{\partial g}{\partial z_1}\dfrac{\partial z_1}{\partial z}+\dfrac{\partial g}{\partial v_1}\dfrac{\partial v_1}{\partial z}=e^{\int^v\xi(v)~dv}\dfrac{\partial g}{\partial z_1}$
$\dfrac{\partial^2g}{\partial z^2}=\dfrac{\partial}{\partial z}\left(e^{\int^v\xi(v)~dv}\dfrac{\partial g}{\partial z_1}\right)=\dfrac{\partial}{\partial z_1}\left(e^{\int^v\xi(v)~dv}\dfrac{\partial g}{\partial z_1}\right)\dfrac{\partial z_1}{\partial z}+\dfrac{\partial}{\partial v_1}\left(e^{\int^v\xi(v)~dv}\dfrac{\partial g}{\partial z_1}\right)\dfrac{\partial v_1}{\partial z}=e^{2\int^v\xi(v)~dv}\dfrac{\partial^2g}{\partial z_1^2}$
$\dfrac{\partial g}{\partial v}=\dfrac{\partial g}{\partial z_1}\dfrac{\partial z_1}{\partial v}+\dfrac{\partial g}{\partial v_1}\dfrac{\partial v_1}{\partial v}=\xi(v)e^{\int^v\xi(v)~dv}z\dfrac{\partial g}{\partial z_1}+\dfrac{\partial g}{\partial v_1}$
$\therefore\xi(v)e^{\int^v\xi(v)~dv}z\dfrac{\partial g}{\partial z_1}+\dfrac{\partial g}{\partial v_1}=\eta(v)e^{2\int^v\xi(v)~dv}\dfrac{\partial^2g}{\partial z_1^2}+(\xi(v)z+\nu(v))e^{\int^v\xi(v)~dv}\dfrac{\partial g}{\partial z_1}+(\chi(v)z+\zeta(v))g$
$\xi(v)e^{\int^v\xi(v)~dv}z\dfrac{\partial g}{\partial z_1}+\dfrac{\partial g}{\partial v}=\eta(v)e^{2\int^v\xi(v)~dv}\dfrac{\partial^2g}{\partial z_1^2}+\xi(v)e^{\int^v\xi(v)~dv}z\dfrac{\partial g}{\partial z_1}+\nu(v)e^{\int^v\xi(v)~dv}\dfrac{\partial g}{\partial z_1}+(\chi(v)z+\zeta(v))g$
$\dfrac{\partial g}{\partial v}=\eta(v)e^{2\int^v\xi(v)~dv}\dfrac{\partial^2g}{\partial z_1^2}+\nu(v)e^{\int^v\xi(v)~dv}\dfrac{\partial g}{\partial z_1}+(\chi(v)e^{-\int^v\xi(v)~dv}z_1+\zeta(v))g$
With reference the substitution concept in Solving a PDE arising from physics,
Let $g=e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}h$ ,
Then $\dfrac{\partial g}{\partial v}=e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}\dfrac{\partial h}{\partial v}+z_1\chi(v)e^{-\int^v\xi(v)~dv}e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}h$
$\dfrac{\partial g}{\partial z_1}=e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}\dfrac{\partial h}{\partial z_1}+\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv~e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}h$
$\dfrac{\partial^2g}{\partial z_1^2}=e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}\dfrac{\partial^2h}{\partial z_1^2}+\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv~e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}\dfrac{\partial h}{\partial z_1}+\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv~e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}\dfrac{\partial h}{\partial z_1}+(\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv)^2e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}h=e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}\dfrac{\partial^2h}{\partial z_1^2}+2\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv~e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}\dfrac{\partial h}{\partial z_1}+(\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv)^2e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}h$
$\therefore e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}\dfrac{\partial h}{\partial v}+z_1\chi(v)e^{-\int^v\xi(v)~dv}e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}h=\eta(v)e^{2\int^v\xi(v)~dv}\left(e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}\dfrac{\partial^2h}{\partial z_1^2}+2\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv~e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}\dfrac{\partial h}{\partial z_1}+(\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv)^2e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}h\right)+\nu(v)e^{\int^v\xi(v)~dv}\left(e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}\dfrac{\partial h}{\partial z_1}+\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv~e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}h\right)+(\chi(v)e^{-\int^v\xi(v)~dv}z_1+\zeta(v))e^{z_1\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv}h$
$\dfrac{\partial h}{\partial v}+z_1\chi(v)e^{-\int^v\xi(v)~dv}h=\eta(v)e^{2\int^v\xi(v)~dv}\left(\dfrac{\partial^2h}{\partial z_1^2}+2\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv~\dfrac{\partial h}{\partial z_1}+(\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv)^2h\right)+\nu(v)e^{\int^v\xi(v)~dv}\left(\dfrac{\partial h}{\partial z_1}+\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv~h\right)+(\chi(v)e^{-\int^v\xi(v)~dv}z_1+\zeta(v))h$
$\dfrac{\partial h}{\partial v}+\chi(v)e^{-\int^v\xi(v)~dv}z_1h=\eta(v)e^{2\int^v\xi(v)~dv}\dfrac{\partial^2h}{\partial z_1^2}+2\eta(v)e^{2\int^v\xi(v)~dv}\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv~\dfrac{\partial h}{\partial z_1}+\eta(v)e^{2\int^v\xi(v)~dv}(\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv)^2h+\nu(v)e^{\int^v\xi(v)~dv}\dfrac{\partial h}{\partial z_1}+\nu(v)e^{\int^v\xi(v)~dv}\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv~h+\chi(v)e^{-\int^v\xi(v)~dv}z_1h+\zeta(v)h$
$\dfrac{\partial h}{\partial v}=\eta(v)e^{2\int^v\xi(v)~dv}\dfrac{\partial^2h}{\partial z_1^2}+\left(2\eta(v)e^{2\int^v\xi(v)~dv}\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv+\nu(v)e^{\int^v\xi(v)~dv}\right)\dfrac{\partial h}{\partial z_1}+\left(\eta(v)e^{2\int^v\xi(v)~dv}(\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv)^2+\nu(v)e^{\int^v\xi(v)~dv}\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv+\zeta(v)\right)h$
Let $\begin{cases}z_2=z_1+2\int^v\eta(v)e^{2\int^v\xi(v)~dv}\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv~dv+\int^v\nu(v)e^{\int^v\xi(v)~dv}~dv\\v_1=v\end{cases}$ ,
Then $\dfrac{\partial h}{\partial z_1}=\dfrac{\partial h}{\partial z_2}\dfrac{\partial z_2}{\partial z_1}+\dfrac{\partial h}{\partial v_1}\dfrac{\partial v_1}{\partial z_1}=\dfrac{\partial h}{\partial z_2}$
$\dfrac{\partial^2h}{\partial z_1^2}=\dfrac{\partial}{\partial z_1}\left(\dfrac{\partial h}{\partial z_2}\right)=\dfrac{\partial}{\partial z_2}\left(\dfrac{\partial h}{\partial z_2}\right)\dfrac{\partial z_2}{\partial z_1}+\dfrac{\partial}{\partial v_1}\left(\dfrac{\partial h}{\partial z_2}\right)\dfrac{\partial v_1}{\partial z_1}=\dfrac{\partial^2h}{\partial z_2^2}$
$\dfrac{\partial h}{\partial v}=\dfrac{\partial h}{\partial z_2}\dfrac{\partial z_2}{\partial v}+\dfrac{\partial h}{\partial v_1}\dfrac{\partial v_1}{\partial v}=\left(2\eta(v)e^{2\int^v\xi(v)~dv}\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv+\nu(v)e^{\int^v\xi(v)~dv}\right)\dfrac{\partial h}{\partial z_2}+\dfrac{\partial h}{\partial v_1}$
$\therefore\left(2\eta(v)e^{2\int^v\xi(v)~dv}\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv+\nu(v)e^{\int^v\xi(v)~dv}\right)\dfrac{\partial h}{\partial z_2}+\dfrac{\partial h}{\partial v_1}=\eta(v)e^{2\int^v\xi(v)~dv}\dfrac{\partial^2h}{\partial z_2^2}+\left(2\eta(v)e^{2\int^v\xi(v)~dv}\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv+\nu(v)e^{\int^v\xi(v)~dv}\right)\dfrac{\partial h}{\partial z_2}+\left(\eta(v)e^{2\int^v\xi(v)~dv}(\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv)^2+\nu(v)e^{\int^v\xi(v)~dv}\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv+\zeta(v)\right)h$
$\dfrac{\partial h}{\partial v}-\left(\eta(v)e^{2\int^v\xi(v)~dv}(\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv)^2+\nu(v)e^{\int^v\xi(v)~dv}\int^v\chi(v)e^{-\int^v\xi(v)~dv}~dv+\zeta(v)\right)h=\eta(v)e^{2\int^v\xi(v)~dv}\dfrac{\partial^2h}{\partial z_2^2}$
Which is separable.

How to solve the following linear PDE?


Weird interaction with systemctl with Haproxy on CentOS 7

Question: Running haproxy through systemctl is different than running it manually.

on manual start, everything works.
starting through systemctl, haproxy is not able to find the service it proxies, and answers with a 503.

Here's the output when starting through systemctl:
> sudo systemctl status  -l haproxy.service
haproxy.service - HAProxy Load Balancer
Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled)
                Active: active (running) since Wed 2014-12-24 08:08:49 EST; 4min 59s ago
                Main PID: 20307 (haproxy)
                CGroup: /system.slice/haproxy.service
                └─20307 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid

                Dec 24 08:08:49 localhost.localdomain systemd[1]: Starting HAProxy Load Balancer...
                Dec 24 08:08:49 localhost.localdomain systemd[1]: Started HAProxy Load Balancer.

Like this, haproxy just says 503 for my backend.
If I now stop the haproxy service, and instead run it manually on the command line, like so:
sudo /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid

it proxies fine to my server.
I've installed haproxy through yum, and I'm using an exceedingly simple configuration:
# defaults above

frontend  main *:80
    default_backend app

backend app
    option httpclose
    option forwardfor
    server web1 127.0.0.1:8001

Any idea what the difference could be? I've tried running it both daemonized and not.
This is the log when running with systemctl:
Proxy app started.
127.0.0.1:44391 [24/Dec/2014:09:01:42.403] main app/web1 0/0/-1/-1/0 503 212 - - SC-- 0/0/0/0/3 0/0 "GET / HTTP/1.1"

This is the log when running manually:
Proxy app started.
127.0.0.1:44393 [24/Dec/2014:09:02:11.758] main app/web1 0/0/0/2/2 200 5699 - - ---- 1/1/0/0/0 0/0 "GET / HTTP/1.1"

To be clear, I can successfully curl 127.0.0.1:8001 as both my deploy user, with sudo and the haproxy user.
Edit with more info
I tried using nginx as a proxy instead, to no avail. So it is not haproxy that is at fault here. nginx says 502 Bad Gateway, and the logs says:
2014/12/24 16:57:04 [crit] 23214#0: *1 connect() to 127.0.0.1:8001 failed (13: Permission denied) while connecting to upstream, client: 192.168.34.1, server: www.zombieclj.local, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8001/", host: "www.zombieclj.local"

So yeah, there is some security thing going on. I am still able to curl to 127.0.0.1:8001. Stopping the firewall doesn't change anything.
Comment: When you start haproxy manually, what user account do you use?
Comment: What did haproxy log?
Comment: @JasonAzze I run it with sudo.
Comment: @MichaelHampton I've only seen it log something along the lines of "Proxy app started", which isn't very useful.
Comment: @MichaelHampton I've got some more logs now. The first is started from systemctl (503), the second is manually (200): https://gist.github.com/magnars/0dbf5d37f9c25b630f07
Answer: The problem was SELinux only allowing the web server to make outbound connections to a limited set of ports.
Fixed by doing:
semanage port --add --type http_port_t --proto tcp 8001

after installing semanage with
yum install policycoreutils-python

Nodejs Nginx error: (13: Permission denied) while connecting to upstream
Comment: This solution solved my problem. it should be marked as solution.
Comment: I ran into this issue when installing haproxy on a stock RHEL 7 image, for me the the port I wanted to use "8000" was already taken up by soundd_port_t so my solution involved some research using the Audit2Allow answer below.
Answer: I used the Audit2Allow function found on the centos wiki
Review the rule:
grep haproxy /var/log/audit/audit.log | audit2allow -m haproxy
Create a policy file (*.pp).
grep haproxy /var/log/audit/audit.log | audit2allow -M haproxy
now when installing the package I also include the haproxy.pp file and load it to selinux with
semodule -i haproxy.pp
Comment: The port I was running the backend service on "8000" was already taken by something called soundd_port_t, I used the solution documented at https://www.mankier.com/8/haproxy_selinux#Booleans which is to allow haproxy to connect to any tcp port.


Quais as diferenças entre Thread e promise

Question: Sou mais do mundo desktop, mas estou querendo saber mais de WEB.
E gostaria de saber se tem diferença entre promise do javascript e thread do C#.
Comment: Tem diferença sim, são duas coisas completamente distintas.
Answer: Thread e Promise são coisas completamente diferentes.
O motor que roda o js no browser é single-thread, como o javascript é guiado por eventos geralmente não trabalhamos diretamente com a thread e sim com o eventloop.
Promise é um recurso que veio para acabar com a chamada excessiva de callbacks, onde vai executar um processamento de forma assíncrona. Segundo a documentação: Um Promise (de "promessa") representa um valor que pode estar disponível agora, no futuro ou nunca.
Um promise pode assumir 4 estados. ( pendente, realizada, rejeitado, estabelicida)
Para ver as informações completas, acesse a documentação: https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Promise


How to add categories' separation lines

Question: I have a column chart with multiple categories:
        xAxis: {
            categories: cat,
            labels: {
                enabled: true
            }
        },

The var cat is a dynamically generated array of categories [cat1, cat2, cat3...].
How can I add vertical lines or bands to separate categories on the X-axis?
Answer: Something like this here:

var cats = ['One', 'Two', 'Three', 'Four', 'Five', 'Six',
            'Seven', 'Eight', 'Nine'];

var colors = [
   '#2f7ed8',
   '#0d233a',
   '#8bbc21',
   '#910000',
   '#1aadce',
   '#492970',
   '#f28f43',
   '#77a1e5',
   '#c42525',
   '#a6c96a'
];

var bands = [];

for (var i=0; i < cats.length; i++)
{
    bands.push({color: colors[i],
                from:i-0.5,
                to:i+1});
}

$(function () {
    $('#container').highcharts({
        chart: {
        },
        xAxis: {
            categories: cats,
            plotBands: bands
        },

        series: [{
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4],
            color: 'black'
        }]
    });
});

Answer: To create vertical lines, just set your x axis gridline width to something greater than 0.
http://api.highcharts.com/highcharts#xAxis.gridLineWidth
Bands can much more easily be accomplished with the alternateGridColor property, as here:
http://jsfiddle.net/yPLVP/53/

How to add categories' separation lines


lme4: adding covariates and interpreting output

Question: I am new to mixed models and lme4 package. I think my data is too complicated for me to understand things using it... what I want is for someone to please explain this to me in layman's terms using a simple example (if one exists).
My data: I have a lot of data (multiple experiments), but generally speaking... response variables = continuous, normally distributed (some are not, I will get to those later), explanatory variables = mostly discrete. Random effects = group/individual (I "nest" these).
First, in model setup, I need to add mass as a covariate for one of my models. I don't know how to do that, so a basic example (with code) of how one adds a covariate to a lmm (with lme4 package) would be great. I read their help manual on this but it wasn't very helpful to me.
Second, I get the output from lme4 and I have no idea what it is telling me. When I rerun lme4 things with the afex package for the oh-so-controversial p-values, it tells me everything is significant but I still don't know what that means.
Any help or any direction toward a YouTube video, website tutorial, etc. that can explain this to a complete idiot (which is what I feel like I am at the moment) would be greatly appreciated.
Thank you!
Comment: "response variables = continuous, normally distributed (some are not, I will get to those later)" This quote is already concerning. Before you proceed to mixed-effects models, you need to understand that the distribution of your repsonse variable is generally irrelevant for regression analysis. What is important is the conditional distribution (conditional on the predictors). For a model with a Gaussian distribution family this means you need to check the distribution of the residuals because that is assumed to be a normal distribution.
Comment: Adding a covariate just means adding another independent variable.
Answer:
I need to add mass as a covariate for one of my models. I don't know how to do that

If your model looks something like
y ~ x1 + (1 | G)

where x1 is a fixed effect and G is a grouping variable for which you want to fit random intercepts, then if mass is the name of the mass variable you would fit:
y ~ x1 + mass + (1 | G)

When I rerun lme4 things with the afex package for the oh-so-controversial p-values, it tells me everything is significant but I still don't know what that means.

Each p-value refers to a statistical test of a null hypothesis - for example, a test of whether a regression coefficient is zero or not. The p-values tell you the probability of observing your data, or data more extreme, if (and only if) the null hypothesis is true. If this doesn't make sense to you, then you are not alone, and that is part of the reason for the controversy surrounding p-values. Another issue regarding mixed models in particular is that the p-values are actually just approximations, because the number of degrees of freedom for the relevant test is not known and can only be approximated (eg Satterthwaite's or Kenward-Roger's method), so the idea of using p-values with respect to some arbitrary cut-off value for "significance", is folly. I suggest erring on the side of caution and don't use p-values.  Or if you really want a probability that makes sense, then you can obtain probabilities that the null hypotheses are true (which is typically what most people would like to know, rather than what a p-value tells them), then you can adopt a fully Bayesian approach using a package like brms.
Once final point on your model. You mention that you fit nested random effects for individuals within groups. Depending on how many groups you have, this probably does not make sense. Eg if it's a treatment group where participants are nested within 1 of 2 groups, then the group variable should be a fixed effect, not random. 2 is too few levels to fit random intercepts.
Answer: I hope this helps:
Question 1:
This is code assuming you have 3 predictors (pred1, pred2, pred3). A'covariate' is just treated the same as other predictors in the code.
I use 'Response' as your dependent (outcome) variable. I use 'X' for your grouping variable. 'data.df' is your data frame, with a column
for each of the predictors, outcome variable, and random effect
variable.

#Load the packages needed for the analysis

library(lme4) # for running the mixed model
library (lmerTest) # for obtaining p-values in the output tables

# Run the first linear mixed effects model

model1 <- lmer(Response ~ pred1+(1|X), data = data.df ,control=lmerControl(optimizer="bobyqa"))

summary(model1) #prints the model output table

# Run the second model, with added covariates

model2 <- lmer(Response ~ pred1+pred2+pred3+(1|X), data = data.df ,control=lmerControl(optimizer="bobyqa"))

summary(model2)

Additional Considerations:

You can add in interactions between variables using * (e.g., Response ~ pred1*pred2+pred3)

1|X is a random intercept. Where theoretically appropriate, you can add in random slopes. For example, if  individual participants in a study complete a spelling test under 2 conditions, then you could run the model
lmer(Spelling_performance ~ condition + (condition|participant),data = data.df ,control=lmerControl(optimizer="bobyqa"))

This would include a random intercept for participants (assuming participants each have a different 'baseline' performance, i.e., spelling ability). It would also include a by-participant random slope for condition, meaning that the effect of condition varies between participants: some participants might perform similarly in both conditions, while others might be more susceptible to changes in condition.

If you have convergence problems, you may need to consider scaling the variable or centering (particularly if you have interactions as this can reduce multicollinearity between main effects and interactions). See references 1 and 2 below. You can also look to simplify the random effects structure.

Question 2:
I would need to see your code and output table in order to interpret the results. However, I have made some points below that might help. I have also attached a general tutorial for mixed modelling in lme4.

If you have a predictor with more than 2 levels (e.g., 'Colours' with levels green, blue, pink) then dummy coding is automatically used for contrasts in R (e.g., blue vs pink, blue vs green in the output table). If you want to compare different groups, there are many in-built functions in R that you can use to get different contrasts. See reference 3 below.

Tutorial: https://jontalle.web.engr.illinois.edu/MISC/lme4/bw_LME_tutorial.pdf
References:

https://rstudio-pubs-static.s3.amazonaws.com/33653_57fc7b8e5d484c909b615d8633c01d51.html
https://www.theanalysisfactor.com/when-not-to-center-a-predictor-variable-in-regression/
https://marissabarlaz.github.io/portfolio/contrastcoding/


Docker - require specific docker service version

Question: Currently I have a bug, maybe in my code, maybe in docker base images, maybe even in docker itself, but I know for sure, that my app works great on docker-ce 17.09 and hang up after some time on docker-ce 17.12
Is there any way to specify docker version in Dockerfile or in docker-compose.yml so app will throw error while trying to build it on not supported docker version.
I understand this is not a good idea, and I need to find out this bug, but for temporary workaround this error message is enough for me.
Comment: after hangup issue  docker ps -a  then issue   docker logs container-id-hung-one   ... update your question with output ... sometimes this log is helpful
Comment: Take a look at docker version manager https://howtowhale.github.io/dvm/ so you can switch between versions and try commands
Comment: Yeah, I already seen logs and there is no error, just logs stopped at some time, but container is running
Comment: @slashpai yeah thanks, but I'm not have trouble installing older version of docker (it's pretty easy on ubuntu), but my trouble is prohibit using newer version for current app.
Answer: i think there is no docker direct approach to it. But you can pass the docker version with ARG to your Dockerfile and then add RUN command that checks if it is the required version. To cancel the build process you have to exit with other number than 0.
build your image with this line
docker_version=`docker version --format "{{.Server.Version}}"` \
&& docker build -t my_image --build-arg DOCKER_VERSION=$docker_version .

then in your Dockerfile check if it is required docker version
FROM debian

ARG DOCKER_VERSION

RUN [[ $DOCKER_VERSION == "17.12.0-ce" ]] && echo "YES" ||  exit 1

Comment: Yeah, seem like this would work, but looks a lot of troubles :) Thanks anyway


Codeigniter: Is this suitable use of a view as opposed to a controller?

Question: I have a controller with an index function which can take three parameters
<code>function index($name,$date1,$date2){
</code>
Within the controller i have if statements such that if $date1 is set, set a variable ($data['one']), and if $date2 is set, set a variable ($data['two']).
$data is then passed to my view ('result') where there is various levels of processing depending on what is/is not set.
Should i rather have the processing within my controller, and then call multiple views depending on what is/is not set or does it not matter?
Thanks
Answer: Let's say you created multiple views. If there is any duplication whatsoever - it's wrong. Always keep the DRY - Don't Repeat Yourself - principle in mind and you can't go wrong. Generally you shouldn't need more than one view per controller. Also, when you say processing, I wonder what that means. All logic should go in the controller, while your views should be reserved for simple if statements to prohibit things from being outputted that due to the logic in the controller is not deemed neccessary, or perhaps a foreach to loop through an array and print its content.


What is the effect of "bounding the range" for a prior distribution?

Question: Below is a material about the prior disribution for the proportions.

The appropriate prior distribution for the parameter $\theta$ of a
  Bernoulli or binomial distribution is one of the oldest problems in
  statistics. ... We denote $\phi=logit(\theta)$.
an (improper) uniform prior on $\phi$ is formally equivalent to the
  (improper) Beta(0,0) distribution on the $\theta$ scale, i.e.,
  $p(\theta)\propto \theta^{-1}(1-\theta)^{-1}$:the code below
  illustrates the effect of the bounding the range for $\phi$ and hence
  making these distributions proper.

The code in WinBUGS is:
<code>model{
  phi   ~ dunif(-5, 5)
  logit(theta) <- phi
}
</code>
The empirical distributions (based on 100,000 samples) corresponding to the priors is shown in .
I am not sure what "the effect of the bounding the range" is reflected?
Comment: In most cases you know more about the problem that such priors would indicate, hence the popularity of Gaussian priors for log odds or $\beta$ priors for probabilities.  You can also use a truncated distribution, e.g., a Gaussian prior for the logit, truncated to logits that create the needed truncation in the probabilities.
Answer: Using the improper uniform prior, the parameter $\phi$ can take any value in $(-\infty, \infty)$. A logit transform $\theta = \textrm{logit}^{-1}(\phi)$ would make $\theta \in (0, 1)$ with the density $f(\theta) \propto \theta^{-1} (1-\theta)^{-1}$, which is improper as well because $$\int_{0}^{1} \theta^{-1} (1-\theta)^{-1} d\theta = \infty.$$
If we restrict $\phi$ to the range $(-5, 5)$ then $f(\phi)$ is not improper. We still have $f(\theta) \propto \theta^{-1} (1-\theta)^{-1}$ but now the range for $\theta$ is $(\textrm{logit}^{-1}(-5), \textrm{logit}^{-1}(5)) \approx (0.993, 0.007)$, which is a proper distribution because $$\int_{\textrm{logit}^{-1}(-5)}^{\textrm{logit}^{-1}(5)}\theta^{-1} (1-\theta)^{-1} d\theta < \infty.$$
The purpose of this is to approximate the improper distributions with close-enough proper distributions.


How do I get all available form field types?

Question: How do I get all form field types (e.g. "textbox," "select") available in Drupal 6?
Comment: You can find the list of all core elements here: [Drupal 6](http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6) [Drupal 7](http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/7)
Answer: The core fields are provided by hook_elements so you can just invoke that hook to get a list of all field types in the site using module_invoke_all():
 $all_types = module_invoke_all('elements');

The array keys of $all_types are the machine names of the elements, each of those points to another array containing the element information.


Large, regular product import for Commerce

Question: I am in the process of developing a new site using Commerce Kickstart.
The site needs to import a fairly large amount of data from a CSV on a regular basis - perhaps 50,000 to 100,000 products at a time, at least every week. (And maybe more often than that.)
I have tried to use Feeds to do a test import of around 30,000 products. (So this creates 30,000 product variations and 30,000 display nodes.) This has proved to be far too slow for my purposes, taking around 18 hours.
So I see my options as follows:

Run some profiling to attempt to see why the import is slowing down
so much (It starts off at around 200 products / minute and slows
down to 10-20 by the end of the import run.)
Following the strategy here, import into a single table, and use entities to do what I need to do. With this approach, I am concerned about losing or having to re-implement the functionality I need to make the site work - namely faceted search / unknown regular commerce functionality. Each product - each line of the CSV - has numerous fields of data that would have to be stored, so I'm not even sure if this approach would work.

Does anyone have any advice on the best way to progress? Or any hints about the above? Or strategies to import the data that I might not have considered?
Thanks in advance.
EDIT:-
Looking at the Feeds log, it looks like the product variations imported in 1 hour 20 mins, whereas the product display nodes took 17 hours to create.
Comment: The slowness is probably coming from somewhere inside node_save(), I would suggest profiling it and finding out what's going on.

The single table strategy won't work with Commerce and makes very little sense there (by bypassing the storage you will also bypass the entire commerce api)
Comment: With modules like Elysia Cron you could set the job of rules to be executed every X minutes, or hour, etc, so it could be faster. Did you try it?
Comment: Thanks for the comment. I used Drush to to execute the Feeds import via Elysia Cron.
Comment: Thank you, Bojan. I *might* be able to use a single table solution - there are around 70 base products that remain the same and can be customised by the 30,000 imported products. (So buy one of 70 items, add a reference to one of the 30,000.) My concern would be that I still need faceted search on there too. At the moment, I'm treating the 30,000 as individual products, with the "base" product as an option.
Answer: Hopefully this helps someone else.
I used XHProf in an attempt to figure out why the Feeds import was slowing down so much. It appears that the culprit is DrupalDefaultEntityController::cacheGet.
As the number of entries in DrupalDefaultEntityController's entityCache increases, performance drops off a cliff.
I resolved the issue by importing the nodes manually.


$[2]Q=P$ with the rational coordinate of $Q$ in an elliptic curve

Question: Let
$$\tag{1} y^2=x^3+Ax+B $$
be an elliptic curve, $A, B$ are integers and $P$ is a point on the curve with rational coordinates. Is there always a point $Q$ such that $[2]Q=P$ such that the $x$-coordinate of $Q$ is rational?
The formula we get form doubling points, tells us coordinates of $Q$ depends on $a$ and the coordinates of $P$, if we put those values in the formula, we get the value of x coordinate of $Q$, and thus get $y$ coordinate of $Q$ from equation $(1)$,  , we see from the forumula given below in image, x coordinate of $Q$ is always rational (Given that the x-coordinate of $P$ and $a$ are rational), is it correct? am I missing something ?

Here, $f(x)=y^2.$
Comment: There is always a point $Q$ such that $[2] Q = P$ as you say, but it is not necessarily true that $Q$ has rational coordinates.
Comment: I don't see why that would be true. In general, the $x$ coordinate of $Q$ can be obtained by solving a degree $4$ equation in the $x$ coordinate of $P$ with coefficients depending on $A$ and $B$, (See page 54 of Silverman, for example).
Comment: @user45878 the x coordinate of $Q$ is rational, the y coordinate might not be, right?
Comment: @user45878 I have attached an image, note that if $X, a$ are rational  then the formula of doubling point gives us a rational x-coordinate of $Q$, because the slope $\lambda$, even if it is not a rational becomes rational by squaring it, note $\lambda$  becomes irrational because of $Y$, if $\lambda$  is irrational then there is a chance of getting irrational x-coordinate of $Q$, please check.

For the formula, see page 10 of :http://math.uchicago.edu/~may/REU2013/REUPapers/Galperin.pdf
Answer: For an elliptic curve over $\mathbb{Q}$, then $E_{\text{tor}}(\mathbb{Q})$ can be $\mathbb{Z}/4\mathbb{Z}$(see this), so $E(\mathbb{Q})=\mathbb{Z}/4\mathbb{Z}\bigoplus\mathbb{Z}^N$. Let $P$ be $(\bar{1},0,...0)$, then there doesn't exist such a $Q\in E(\mathbb{Q})$ such that $2Q=P$.
But as you see, by solving these equations, we get these roots in $\bar{\mathbb{Q}}$, so there does exist a point $Q\in E(\bar{\mathbb{Q}})$ such that $2Q=P$.
Answer: Let $E$ be the elliptic curve $y^2=x^3-2x$. Then, one can easily show that $E(\mathbb{Q})\cong \mathbb{Z}/2\mathbb{Z}$, so that the only points on $E$ with rational coordinates are the point $\mathcal{O}$ at infinity and $P=(0,0)$. If there was a point $Q$ with rational coordinates such that $2Q=P$, then $4Q = 2(2Q)=2P=\mathcal{O}$, so the order of $Q$ would be $4$. However, that would imply a few contradictions (with the size of $E(\mathbb{Q})$, with the isomorphism type of the torsion subgroup, etc), so it is impossible, and no such point $Q$ can exist.
Edit to add: the $x$-coordinates of the points of order $4$ on $E$ are given by the quotient of the $4$-division polynomial, by the $2$-division polynomial, which is
$$(x^2 - 4x + 2)(x^2 + 2)(x^2 + 4x + 2),$$
and all three irreducible polynomial divisors over $\mathbb{Q}$ are of degree $2$, so no point $Q$ of order $4$ has an $x$-coordinate that is rational.
Comment: @Andrew I've added an explanation that no point of order $4$ in this case has a rational $x$-coordinate.
Comment: In this post only the $x$ coordinate has to be rational, $y$ might be irrational, I am not sure Mazur's theorem (where both $x, y$ are rational) agrees with this condition, also plz see this post,according to which $x$ is rational point on elliptic curve: https://math.stackexchange.com/questions/3580905/determining-rational-number
Comment: Hello, I am thinking about the above problem again, if I try to check in an algorithmic way, whether a point $P$ with a rational $x$ coordinate exists or not, when $x$ coordinate of $Q,$ and coefficient $ A, B$ are given, it should be easy, but I couldn't find the algorithm, could you please hint me how should I try? Thank you.
Comment: @ConsiderNon-TrivialCases you can simply check if $x^3+Ax+B$ is a square in the rationals.
Comment: Hi! Is there a way to know the percentage of such $P$ that will have an elliptic curve and a point $Q$ on the curve as described in the post? So, we can say, for example, at-least $20 \%$ out of all pairs of rational number have an elliptic curve such that $P=[n]Q, n\geq2$ (note it could be part of infinite order, I don't mean torsion-group points only).


base64 limitations not showing up

Question: Simple question that I am unsuccessful in finding a simple answer for. I have an image editor as a part of a text editor. After the user is done editing the image they can save it to the server. In order to do this, I have to use base64 decoding on the PHP side. However, when the dataURL info reaches a certain size, the ajax request fails. The thing about it... the size that it starts failing at is less than 1MB. When it is less than that, the ajax sends it and everything works.
I have the site hosted on godaddy. I tried to find "POST" size limitations, but I can't seem to find anything. I have also tried
echo ini_get('post_max_size');

to see if I can figure out what the limit is set to. But when I run the page, nothing is printed.
Any help or advice would be much appreciated!
Comment: Simply running `echo ini_get('post_max_size');` should print the given limit, with the exception of if your host has disabled `ini_get();`. Try turning up `error_reporting`. Also, bear in mind that the base64-encoded data is going to be about 30% larger in size than the original form. That is the price you have to pay to make your data 7-bit safe.
Answer: Set post_max_size = 8M; with a size of your choice, in php.ini. Otherwise, it could be a problem with what you are trying to decode. The base64 characters must be as follows: http://www.garykessler.net/library/base64.html .
Comment: I set the post_max_size to 96M and it's still doing it. I viewed phpinfo() and it says the max size is 96M, like it should, but it still won't work.

I added an xrh to the ajax to see if it is working at all. The percentage gets to 100%, but then the file doesn't save. I'm guessing there's something wrong with the php file? But I don't get why it works with a slightly smaller file

base64 limitations not showing up


.NET Why does "Anchor" not take Toolstrip into account?

Question: I have created a form and added a ToolStrip to it.
Then I added a big button and anchored it to all sides.
Then I created a second button that would set the ToolStrip visible and invisible:
 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Me.ToolStrip1.Visible = Not Me.ToolStrip1.Visible

End Sub

However, when I make the ToolStrip invisible, the big button does not change its size and position.
Does anybody know why?
Thank you!
Comment: Why would it?  Hiding the tool strip does not change the size of the form, and the button is anchored to the form.
Comment: Show us enough of the code so we can see the order of creation and all the properties of these two controls.
Answer: You can make things work as you expect by using a Panel to host the controls, rather than the Form.
From the perspective of an empty form:

Add the ToolStrip
Add a Panel
Set the Panel.DockStyle to Fill
Add all the rest of your controls to the Panel

Now the panel will automatically resize based on the visible status of the ToolStrip.
Comment: Using a TableLayoutPanel is even better!


Authorize.Net Change Information

Question: I have created the sandbox account of authorize.net and during the information filling it is not asked me for the any security question to answer.
I created the account successfully but when I go to get the transaction key then it is asking for the security question to answer that I did not enter.
I go through the entire documentation but still not able to resolve it
Your help in this matter will be highly appreciated. I need to change this security question or get rid of it.
Comment: The default security answer is "Simon"
Comment: unable to get any solution
Comment: You have asked a lot of question and have yet to accept any answers. This site goes both ways. If you expect help you should reward those who help you by accepting their answer. Read [How does accepting an answer work?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) and start giving back to the community.
Answer: For new Authorize.Net sandbox accounts, the default security answer is "Simon"
Comment: Hi @UmairKhan. If this, or any answer, has solved your question please consider [accepting it](//meta.stackexchange.com/q/5234/179419) by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answer-er and yourself. There is no obligation to do this.

Authorize.Net Change Information


How to calculate the number of graphs without vertices of degree 0 using inclusion-exclusion principle?

Question: So there is this homework question where we have to determine the number of graphs with no vertices of degree 0 using the inclusion-exclusion principle. With $V = {1, 2, ... n}$ and the answer should be a function of n.
I know this is the inclusion-exclusion principle rule and that the total number of graphs possible is $2^{\binom{n}{2}}$. So that would be $|A_1| + |A_2| + ... + |A_n|$.
$$\left| \bigcup_{i = 1}^{n} A_i \right| = \sum_{k = 1}^{n} (-1)^{k - 1} \sum_{I \in \binom{\{1, 2, \ldots, n\}~}{k}} \left| \bigcap_{i \in I} A_i\right|$$
But I don't really know what $|A_1 \cap A_2|$ is supposed to mean/be in this example and neither the others. Can someone help me with this?
Comment: Please read this [tutorial](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference) on how to typeset mathematics on this site.
Answer: You can think $|A_i|$ as the number of graphs that for the vertex $i$ with $1 \le i \le n$, $d(i)=0$. In this case, if we give an example, $|A_1 \cap A_2|$ is the number of graphs that vertex $1$ and $2$ both has degree of $0$. What you want to do is to find the number of graphs with at least one vertex with degree zero and subtract it from the number of total graphs you can have, which is as you stated, $2^{\binom{n}{2}}$. Here, I can say that for each $i$, $|A_i| = 2^{\binom{n-1}{2}}$ because we are removing all the edges connected to $i$ in order to make $d(i) = 0$ and construct a new graph with remaining edges and $n-1$ vertices. Similarly, $|A_1 \cap A_2| = 2^{\binom{n-2}{2}}$ and so on. Now you can use Inclusion-Exclusion Principle to find the number of bad graphs (the graphs that have at least one vertex with degree zero). So your answer should be $$2^{\binom{n}{2}} - |\bigcup \limits_{i=1}^{n}A_{i}| =\sum \limits_{k=0}^{n}{(-1)^k\binom{n}{k}2^{\binom{n-k}{2}}}$$
Note that I also included the term $2^{\binom{n}{2}}$ to the sum.
Comment: Very clear answer thanks! But the d(i)=0 means the incoming/outgoing lines of the vertex is 0 right? I'm used to a slightly different notation
Comment: Yes, that's exactly what degree (d) means.
Comment: @ArsenBerk I can't understand what am I missing? Does that formula work for $n = 2$? There are obviously only $2$ graphs on $2$ labeled vertices ( only one possible edge to be included / excluded ) hence there is only one graph with vertices of degree $0$. But formula gives $2$ as the answer
Comment: @ioleg19029700 for $n=2$, formula gives $+2-2+1=1$. I think you miscalculated some terms in the sum.
Comment: @ArsenBerk ooh, yes i did. My bad
Answer: Assuming we're not considering if graphs are isomorphic, here is my attempt at a formal proof:
Let $C = \{ G = (V, E) : \forall v \in V(G),$ $\deg_G(v) \neq 0\}$, which is the set of all graphs that have no vertices of degree $0$. Now consider the complement of this set $\overline{C} = \overline{C}_1 \cup \overline{C}_2 \cup \cdots \cup \overline{C}_n$ where $\overline{C}_i = \{ G = (V,E) : \deg_G(v_i) = 0\} \: (i \in \{1,...,n\})$. In other words $\overline{C}$ is the set of all graphs that have at least one vertex of degree $0$. Since for all $G \in \overline{C}_i$, $G$ has an edge set such that $\forall j \in \{1,...,n\} \setminus \{i\}$, $\{v_i, v_j\} \notin E(G)$ (i.e. $v_i$ is fixed with no edges), we can instead consider the number of possible graphs on $V(G) \setminus \{v_i\}$ since there are no combinations of edges containing $v_i$ that will induce a new graph. Thus, $$|\overline{C}_i| = 2^{{|V(G) \setminus \{v_i\}| \choose 2}} = 2^{{n - 1 \choose 2}}.$$
We apply the same intuition to some arbitrary intersection $$\overline{C}_{i_1} \cap \overline{C}_{i_2} \cap \cdots \cap \overline{C}_{i_k} \: (i_j \in \{1, ..., n\}, \: j \in \{1,...,k\}, \: k \leq n).$$ Since $\overline{C}_{i_1} \cap \overline{C}_{i_2} \cap \cdots \cap \overline{C}_{i_k} = \{ G = (V, E) : \{v_{i_1},...,v_{i_k}\} \subseteq V(G) \text{ and } \displaystyle\sum_{v \in \{v_{i_1},...,v_{i_k}\}} \deg_G(v) = 0\}$, we need only consider the number of graphs on the vertex set $V(G) \setminus \{v_{i_1}, ..., v_{i_k}\},$ since all $v \in \{v_{i_1},...,v_{i_k}\}$ are fixed with degree $0$. Consequently,  $$|\overline{C}_{i_1} \cap \overline{C}_{i_2} \cap \cdots \cap \overline{C}_{i_k}| = 2^{{|V(G) \setminus \{v_{i_1},...,\: v_{i_k}\}| \choose 2}} = 2^{{n - k \choose 2}}.$$
We define such a property because there is, of course, overlap between the sets $\overline{C}_{i}$, so we apply the inclusion exclusion principle as follows:
$$|\overline{C_1} \cup \overline{C_2} \cup \cdots \cup \overline{C_n}| = \displaystyle\sum_{k = 1}^{n} (-1)^{k - 1} \displaystyle\sum_{I \in \binom{[n]}{k}} \left\lvert \bigcap_{i \in I} \overline{C_i} \right\rvert = \displaystyle\sum_{k = 1}^{n} (-1)^{k - 1} {n \choose k} 2^{{n - k \choose 2}}.$$
(We multiply $2^{{n - k \choose 2}}$ by ${n \choose k}$ because there are ${n \choose k}$ ways to choose a $k$-element subset $\{v_{i_1},...,v_{i_k}\} \subseteq V(G)$ such that $\displaystyle\sum_{v \in \{v_{i_1},...,v_{i_k}\}} \deg_G(v) = 0$).
Recall, however, that this is the number of graphs with at least one vertex of degree $0$. Thus, the number of graphs with no vertices of degree $0$ is
$$|C| = 2^{n \choose 2} - \displaystyle\sum_{k = 1}^{n} (-1)^{k - 1} {n \choose k} 2^{{n - k \choose 2}}.$$
Side note:
In this proof, I'm assuming you know that the number of possible graphs on some vertex set $V$ is $2^{{|V| \choose 2}}$. If you aren't familiar with this, the basic idea of proving this would be to understand that ${V \choose 2}$ gives us all possible edges on the given vertex set $V$, so to find the number of possible graphs on $V$, we are counting the number of possible mappings, $f$, such that each mapping uniquely maps the set ${V \choose 2}$ to the set $\{1, 0\}$ (for some $e \in {V \choose 2}$, $f(e) = 1$ denotes the edge is included in the edge set of the graph and $f(e) = 0$ denotes it is not). This would be $$|\{1, 0\}|^{|{V \choose 2}|} = 2^{{|V| \choose 2}}$$.
More on total mappings from an m-element set to an n-element set: How many functions are there from a set with $m$ elements to a set with $n$ elements?


Critical Error Linting URL: An internal error occurred while linting the URL

Question: I tried to create a post (using a blogger URL) in the Facebook Power Editor.
Result:

Error creating posts. Please retry later. You can also go to your Page and post from there. (OAuthException) (#1500) The url you supplied is invalid

Then tried to install Facebook's Open Graph tags into Blogger to see of that would fix the problem.
To test the OG tags I used Open Graph Object Debugger.
Here are the results:

Critical Errors That Must Be Fixed, Error Linting URL, An internal error occurred while linting the URL.

How do I fix the invalid URL and the Critical: Error Linting URL?
I am not tech savy so this issue is way over my head but I would like to get it fixed. Please help.
Thanks
Comment: Can you share the URL you're testing with the debugger tool?
Answer: I had a problem like this with the og:image pointing to an image hosted on Rackspace.  The URL was something crazy like
http://1234567890abcdef1234-1234567890abcdef123456780123412b.r23.cf5.rackcdn.com
I think the Facebook linter was seeing this as spam, because if I actually embedded the image in my app/assets it worked fine, so it wasn't the image that was the problem.
The solution was to set up a CNAME on my hosting provider that pointed to the hideously long Rackspace URL, e.g.

CNAME  Value
images  http://1234567890abcdef1234-1234567890abcdef123456780123412b.r23.cf5.rackcdn.com

Then I changed the og:image meta tag to be
meta property="og:image" content="http://images.mydomain.com/relative_rackspace_imagepath.jpg"
Comment: I could kiss you right now mdenomy! A quick note on this: I had to turn on the static web hosting for my media CDN container for this to work. Just making a CNAME wasn't enough.
Comment: This worked perfect for me too.  Amazing find @mdenomy
Comment: @mdenomy, It will takes how much time to display image make changes?
Answer: I wanted to contribute a little data point here as this is currently the top google result for this error and there is little useful info out there.
In my case, the page was a post on a wordpress blog that happened to begin with a twitter post embed, and the twitter post happened to contain an url.  My og tag plugin grabbed the embed and managed to place the url along with a little other cruft in og:description, and once I cleaned that up manually the error disappeared.
I think the lesson is that when this happens take a look at your og tags for the page for ANYTHING unusual.  That's the place to start.
Answer: Happened to me once my og:image pointed to this url:
http://xxxxxxx.appspot.com.storage.googleapis.com/IsraelFlag.jpg
I just changed it to:
http://storage.googleapis.com/xxxxxxx.appspot.com/IsraelFlag.jpg
and it works
probably very poor software parses the html
Comment: @MosheShaham, It will take how much time to display image make changes?
Answer: I spent hours trying to debug why this was happening for our site.  It turns out it was because of the og:locale:alternate meta tags we had.
<code><meta property="og:locale:alternate" content="cs_CZ" />
<meta property="og:locale:alternate" content="de_DE" />
...
</code>
When Facebook sees this in your tags they subsequently hit your og:url with '?fb_locale=[lang]' where [lang] is each of your alternates.  There is one request per alternate.  In our case, we had code that was returning back a 302 on that request.  As a result, the Facebook Open Graph Object Debugger kept saying "Error parsing input URL"
Once I fixed the responses to the alternate requests to actually return internationalized content, the issue was fixed.


What's the most "functional" way to select a subset from this array?

Question: I'd like to get more comfortable with functional programming, and the first educational task I've set myself is converting a program that computes audio frequencies from C# to F#. The meat of the original application is a big "for" loop that selects a subset of the values in a large array; which values are taken depends on the last accepted value and a ranked list of the values seen since then.  There are a few variables that persist between iterations to track progress toward determining the next value.
My first attempt at making this loop more "functional" involved a tail-recursive function whose arguments included the array, the result set so far, the ranked list of values recently seen, and a few other items that need to persist between executions. This seems clunky, and I don't feel like I've gained anything by turning everything that used to be a variable into a parameter on this recursive function.
How would a functional programming master approach this kind of task? Is this an exceptional situation in which a "pure" functional approach doesn't quite fit, and am I wrong for eschewing mutable variables just because I feel they reduce the "purity" of my function? Maybe they don't make it less pure since they only exist inside that function's scope. I don't have a feel for that yet.
Here's an attempted distillation of the code, with some "let" statements and the actual components of state removed ("temp" is the intermediate result array that needs to be processed):
let fif (_,_,_,_,fif) = fif

temp
|> Array.fold (fun (a, b, c, tentativeNextVals, acc) curVal ->
    if (hasProperty curVal c) then
        // do not consider current value
        (a, b, c, Seq.empty, acc)
    else
        if (hasOtherProperty curVal b) then
            // add current value to tentative list
            (a, b, c, tentativeNextVals.Concat [curVal], acc)
        else
            // accept a new value
            let newAcceptedVal = chooseNextVal (tentativeNextVals.Concat [curVal])

            (newC, newB, newC, Seq.empty, acc.Concat [newAcceptedVal])

) (0,0,0,Seq.empty,Seq.empty)
|> fif

Answer: Something like this using fold?
let filter list =
    List.fold (fun statevar element -> if condition statevar then statevar else element) initialvalue list

Answer: Try using Seq.skip and Seq.take:
let subset (min, max) seq =
  seq
    |> Seq.skip (min)
    |> Seq.take (max - min)

This function will accept arrays but return a sequence, so you can convert it back using Array.ofSeq.
PS: If your goal is to keep your program functional, the most important rule is this: avoid mutability as much as you can. This means that you probably shouldn't be using arrays; use lists which are immutable. If you're using an array for it's fast random access, go for it; just be sure to never set indices.
Comment: This question isn't about taking a block from an array


Problema no Google Maps JavaScript API V3 com WebApp em MVC

Question: Quero fazer com que um simples Mapa apareça quando o usuário clicar no (Menu>Localizar), o problema é que o controlador recebe os dados e me envia e não retorna o Mapa.
Estou usando em meu projeto, padrão MVC.

O código, disponibilizei no repositório do aplicativo.
Comment: Você se refere ao item em vermelho na imagem da direita? Ela não tem nenhuma relação com o Google maps.
Comment: @bfavaretto Coloquei essa imagem apenas para mostrar que os arquivos são carregados. Aquele item em vermelho não está sendo o problema. Meu problema é o carregamento do mapa.
Comment: Então, fica difícil ajudar com essas informações. A gente teria que olhar todo o seu código em detalhes até achar o problema. Você conseguiria isolar o problema e postar um exemplo pequeno que reproduza o que está ocorrendo?
Comment: @bfavaretto O que você acha, vou editar o que postei isolando apenas o problema reduzindo os códigos e postando eles aqui. Ok!
Answer: Então, baseado no arquivo que está no seu GitHub em ' boasaude / assets / js / controllers / MapaController.js',
Percebi que na linha 17

'google.maps.event.addDomListener(window, 'load', initialize);'

Depis de baixar o ser código fiz a seguinte alteração:
Troquei a linha 17 por uma chamada a função e ficaou assim:

"initialize();"

Obs.: Porque não funciona? a janela (window) já está carregada por isso o "initialize" do addDomListener não fazia a função iniciar.
Mesmo assim o mapa não apareceu.... mas notei que conteúdo dentro da  que carrega o mapa tinha mudado...
Fiz um teste colocando altura e largura e trocando o código que estava em index.html, ficando assim:
<code><style>
         html, body, #map-canvas {
          /*height: 100%;  Código antigo */
          height: 600px; /* Novo */
          width: 600px; /* Novo */
          margin: 0px;
          padding: 0px
         }
</style>
</code>
E pronto... o mapa apareceu.
Espero que tenha ajudado.
Comment: fiz o que você falou e resolveu! Obg


C# e MySQL com AspNetUsers, tabelas apagadas

Question: Estou desenvolvendo um sistema com C# (MVC) e MySQL. Tudo funciona perfeitamente bem quando utilizo minha instância local do Banco de Dados.
Eu dupliquei este banco de dados no UolHost e é aí que acontece algo bizarro.
Quando eu mudo a connection string (apenas o endereço) para se conectar ao banco do UolHost, ao tentar logar no sistema, todas as tabelas do banco são apagadas e são criadas novas tabelas AspNetUsers automaticamente.
Porque o sistema está apagando o banco de dados e construindo apenas estas tabelas? E porque isso só acontece no banco de dados do servidor, enquanto que na máquina funciona normalmente?
Alguém, por favor, teria uma dica?
Comment: Você está usando Simple Membership?
Comment: Esta situação ocorre após você publicar o site? Verifique se não está enviando o banco de dados mais de uma vez.
Comment: Eu nem chego a publicar... só de rodar no VS isso já acontece...
Comment: Cigano, estou usando a autenticação que o próprio VS coloca quando você cria o projeto...
Answer: Creio que deve estar usando o EntityFramework. Essa coisa bizarra pode vir dele, por causa da configuração ao inicializar um banco de dados. Tem quatro opções para inicializar o banco de dados:

CreateDatabaseIfNotExists - Esse é o default, e cria o banco de dados caso não existe
DropCreateDatabaseIfModelChanges - Esse modo dropa o banco de dados completo se os modelos foram modificados.
DropCreateDatabaseAlways - Esse moda dropa o banco de dados completo sempre.
Personalizado - Pode criar seu próprio inicializador se um desses não satisfaz

Verifique se está usando algo como o DropCreateDatabaseIfModelChanges, pois é capaz do sistema achar que os modelos mudaram quando você muda o seu connection string.
Procure uma função chamada:
.SetInitializer<T>()

Comment: Não era bem isso, mas sua dica me ajudou a descobrir!!! Valeu!!!
Comment: @FelipeBulle Que bom! Se quiser, pode postar uma resposta com qual era a solução mesmo!
Answer: O problema era que a tabela __migrationhistory estava com letras maiúsculas no banco... e como não era encontrado no InitializeDatabase, ele limpava e criava novamente!
var migrationHistoryTableExists = ((IObjectContextAdapter)context).ObjectContext.ExecuteStoreQuery<int>(
            string.Format(
              "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{0}' AND table_name = '__migrationhistory'",
              "superacrm"));

            // if MigrationHistory table is not there (which is the case first time we run) - create it
            if (migrationHistoryTableExists.FirstOrDefault() == 0)
            {
                context.Database.Delete();
                context.Database.Create();
            }


ClickHouse error: DB::MutatePlainMergeTreeTask::executeStep(): Code: 47. DB::Exception: Missing columns

Question: In clickhouse-server.err.log every second an error appears:
<Error> virtual bool DB::MutatePlainMergeTreeTask::executeStep(): Code: 47. DB::Exception: Missing columns: 'purchase_number' while processing query: 'SELECT purchase_number FROM rad_reports_api_release_2.purchase_notices_v1 WHERE region = 'Test'', required columns: 'purchase_number' 'region', maybe you meant: 'region': While processing (purchase_number IN ((SELECT purchase_number FROM rad_reports_api_release_2.purchase_notices_v1 WHERE region = 'Test' ) AS _subquery8297539)) OR (purchase_number IN ((SELECT purchase_number FROM rad_reports_api_release_2.purchase_notices_v1 WHERE region = 'Test') AS _subquery8297540)) OR (purchase_number IN ((SELECT registration_number FROM rad_reports_api_release_2.purchase_ notices_v1 WHERE region = 'Test') AS _subquery8297541) ).(UNKNOWN_IDENTIFIER)

However, in the purchase_notices_v1 table there is no 'purchase_number' field at all. Please tell me what is the reason and how to fix this problem?
Updating the clickhouse version did not help. Current version is 220.127.116.1111
Answer: The error message is because you have an unfinished mutation ALTER table ... UPDATE. And in this mutation, the query reference an non existing column purchase_number.
CREATE TABLE example_table
(
    `Date` Int64,
    `name` String
)
ENGINE = MergeTree()
ORDER BY Date;

-- Here nameccc is not existing.
ALTER TABLE example_table
UPDATE name = 'John Doe'
WHERE Date in (SELECT nameccc from example_table);

-- Since this query is executed, the error log of Missing column is repeated as you described.

The way to get rid of this is to find the mutation causing the issue, and then kill it.
select * from system.mutations
Row 2:
──────
database:                   default
table:                      example_table
mutation_id:                mutation_3.txt
command:                    UPDATE name = 'John Doe' WHERE Date IN (SELECT nameccc FROM default.example_table)
create_time:                2024-03-12 20:35:49
block_numbers.partition_id: ['']
block_numbers.number:       [3]
parts_to_do_names:          ['all_1_1_0_2']
parts_to_do:                1
is_done:                    0
latest_failed_part:         all_1_1_0_2
latest_fail_time:           2024-03-12 20:41:37
latest_fail_reason:         Code: 47. DB::Exception: Missing columns: 'nameccc' while processing query: 'SELECT nameccc FROM default.example_table', required columns: 'nameccc': While pro
cessing Date IN ((SELECT nameccc FROM default.example_table) AS _subquery1637). (UNKNOWN_IDENTIFIER) (version 22.214.171.124)

KILL MUTATION WHERE mutation_id = 'mutation_3.txt' ASYNC

Query id: 3e210be1-880d-4952-bce7-b9f52aefa08f

┌─kill_status─┬─database─┬─table─────────┬─mutation_id────┬─command────────────────────────────────────────────────────────────────────────────┐
│ waiting     │ default  │ example_table │ mutation_3.txt │ UPDATE name = 'John Doe' WHERE Date IN (SELECT nameccc FROM default.example_table) │
└─────────────┴──────────┴───────────────┴────────────────┴────────────────────────────────────────────────────────────────────────────────────┘

1 row in set. Elapsed: 0.019 sec.


About the sub-mean value property

Question: Let $\Omega$ be an open subset of $\mathbb{R}^N$. We say that a function $u\in C(\Omega)$ has the (surface) sub-mean value property in $\Omega$ if (1) $u(x)\leq\frac{1}{|\partial B_r(x)|}\int_{\partial B_r(x)} u(y)dSy$ for any ball $\bar{B}_r(x)\subseteq\Omega$.
We say that a function $u\in C(\Omega)$ has the (volumetric) sub-mean value property in $\Omega$ if (2) $u(x)\leq \frac{1}{|B_r(x)|}\int_{B_r(x)} u(y)dy$ for any ball $\bar{B}_r(x)\subseteq\Omega$.
A function that satisfies the condition (1) is called subharmonic on $\Omega$. I know that this is equivalent to (if $u\in C^2(\Omega)$) $\Delta u\geq 0$, and that (1) implies (2), but what i wish to know is if (2) implies (1). I think that is not the case but i cannot find a counterexample (The analogue version in which there is the equalities are equivalent).
Comment: You don't want $dS$ for volume. And no, (1) does not imply $u\in C^2;$ example $u(y)=|y|.$
Comment: Thanks for the comment, i corrected.
Comment: Can someone answer the question?
Answer: I am not sure about the case $u \in C(\Omega)$ but if $u \in C^2(\Omega)$, then (2) does indeed implies (1). So, in all what follows, let us assume that $u \in C^2(\Omega)$.
Since you already know that $\Delta u \geq 0$ implies (2), I assume that you also know the implication
$$\Delta u \leq 0\phantom{a}\text{on }\Omega \phantom{aaa}\Longrightarrow\phantom{aaa}u(x) \geq \frac{1}{|B_r(x)|}\int_{B_r(x)} u(y) d y\phantom{aa}\text{for all }\overline{B_r(x)} \subseteq \Omega$$
This follows from "$\Delta u \geq 0$ $\Rightarrow$ (2)" by multiplication with $-1$.
Now assume (2) holds. It is sufficient to show $\Delta u \geq 0$ since you already know that this is equivalent to (1).
Let's prove $\Delta u \geq 0$ by contradiction: Assume this is false. Then, by continuity of $\Delta u$, there is an open $\Omega_0 \subseteq \Omega$ such that $\Delta u < 0$ on $\Omega_0$. By my remarks above, this implies
$$u(x) \geq \frac{1}{|B_r(x)|} \int_{B_r(x)} u(y) d y\phantom{aa}\text{for all }\overline{B_r(x)} \subseteq \Omega_0$$
If we combine this with (2), we get
$$u(x) = \frac{1}{|B_r(x)|}\int_{B_r(x)} u(y) d y\phantom{aa}\text{for all }\overline{B_r(x)}\subseteq\Omega_0$$
But this means $\Delta u =0$ on $\Omega_0$ which contradicts our hypotheses.

About the sub-mean value property


Parse PFFile progressBlock:^(int percentDone) { } is not getting called

Question: I am saving a PFFile on Back4App server with Parse SDK, here is the code snippet
PFFile *videoFile = [PFFile fileWithName:@"video.mp4" data:data];
[videoFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {

    if (succeeded) {
        handler(obj,nil);

    } else {
        handler(nil,error);

    }

} progressBlock:^(int percentDone) {
    progress(percentDone);

}];

But in the above code, I am not getting progress in the progressBlock. I have put a breakpoint there but this block is not getting executed.
Also, I have checked the object of PFFile and the object is valid.
Parse SDK Version - 1.14.2
Xcode Version - 8.0
Comment: and success block is called?
Comment: @NeilGaliaskarov Yes Success block is getting called
Answer: Can you please check the guide: http://docs.parseplatform.org/ios/guide/#the-pffile
Also, can you please confirm if the size from the file is less than 20MB?
If you prefer, you can open the Logs at Server side, to find a message error or check if the POST method is called or it is not being executed.


maintain the selected options and checkboxes after submit

Question: I have checkboxes and select options inside a form.

            <input type="checkbox" name="checkedBoxes" value="Reseller"checked />
            Reseller

            <input type="checkbox" name="checkedBoxes" value="SI" checked/>
            SI
         //selects
...

Checkboxes are displayed as checked.

This is what my controller looks like:
 public IActionResult combinedForm(string[] checkedBoxes, string SelectOption, string SelectOptionComp, string SelectOptionSer, string SelectOptionSoft, string SelectOptionApp)
        { //viewModel=...

          var deneme = viewModel.Where(x =>x.Companies.company_type.Contains(checkedBoxes[0]));
        }

How can I keep the state of checkboxes, preferably with the selected select options on view when I clicked the submit button?
Comment: explore ViewData
Comment: @letsdoit I saw binding but couldn't understand how to apply to my project to keep selected values.
Answer: Used viewbags for both
 @if (((string[])ViewBag.checkedBoxes).Contains("Component provider"))
        {

            <input type="checkbox" name="checkedBoxes" value="Component provider" checked  />
            Component provider

        }
        else if (!((string[])ViewBag.checkedBoxes).Contains("Component provider"))
        {

                <input type="checkbox" name="checkedBoxes" value="Component provider" />
                Component provider

        }

<select style="width:100px" id="SelectOption" name="SelectOption" value="a">

            <option>@Html.Label("-",(string)ViewBag.Name,new {@class = "mylabel" })</option>


Estimating mortality using Cox model with baseline

Question: I have been reading online notes and papers on how to build survival models using CPH, and I think I've a good idea how things work. However, there are two questions I still have in mind:
1) let's say I have some mortality data (the probability of survival) by age (e.g., for 55 years old, the probability of survival next year is 0.855, and so on). How can I incorporate this piece of info in my model (with different covariate: age, sex, income, etc.) . Is it something like this:
Let $S(t) = p$ be the survival probability.
Then, by the definition of CPH, we have
$S_i(t)=S_0(t)e^{(x′_i \bf{\beta})}$
Let's say I fit the model and obtained the parameters estimate, and now I need to perform prediction for 55 y.o. person as follows
$\hat{S}(t)=(0.855)e^{(age \times\hat{\beta}_{age} + \; sex\times\hat{\beta}_{sex} +\;income\times\hat{\beta}_{income})}$
Is that correct?
2) How can I include an intercept in my model (i.e., $\beta_0$).
Comment: Can you be more specific about what is given in part 1? What is the sex, income, etc distribution of the population for which the survival is known?
Comment: My data set is typical. My response is the survival time for $n$ individual over $t$ years, and I have for each individual their age, sex, and income. In addition to that, I've the the survival time for each age as mentioned in my question. Now I need to fit cox model and use my baseline data about age. Hopefully this answers your question.
Answer: The Cox model is not evaluating the survival function $S(t)$ but the Hazard function $h(t)$, which gives the instantaneous probabilities of the event, given that the individual has survived up to time $t$.
It is called proportional hazard (PH) model because the hazard at any time $t$ is the product of two quantities: the baseline hazard, $h_0(t)$, and the exponential expression to the linear sum of $\beta_iX_i$:
$h(t, X) = h_0(t)e^{\sum\limits_{i=1}^p \beta_iX_i}$
This construction implies that the baseline hazard $h_o(t)$ is a function of $t$ but does not involve $X$'s; we do not need to assume a specific shape for the baseline hazard function.
For this reason the model is semiparametric and has no intercept. The intercept would correspond to the hazard when all covariates are equal to 0 - that is - the baseline hazard.
You can use the Cox model when your interest is in evaluating hazard ratios between different groups of individuals. If the baseline hazard is a quantity of interest in your study you may consider fully parametric approaches to survival data.


Selecionar determinada quantidade de dados para cada tipo status

Question: Billy Jow aqui!
Na minha tabela historico eu tenho um campo status que pode assumir quatro valores possíveis:
'AVALIAR', 'FRACASSO', 'REAVALIAR', 'SUCESSO'
Desejo selecionar 20 registros de cada status onde a data seja mais recente.
Sendo que desejo apenas os status 'Fracasso', 'Reavaliar' e 'Sucesso'.
Como ficaria minha query para retornar todos os campos?
campos importantes:
historico(codigo, data, status)
Comment: Já tentou um UNION com 4 `SELECT`?
Comment: Sim, chegou a retornar 50 de cada um, porém quando fiz a query pra retornar todos os campos da tabela não funcionou. Por algum motivo retorna menos valores para o fracasso.
Comment: Eu fiz uma resposta, a sua SQL do comentário se assemelha a essa ?
Answer: Utilize o comando SQL UNION ALL exemplo:
(SELECT codigo, data, status
 FROM historico WHERE status = 'AVALIAR' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT codigo, data, status
 FROM historico WHERE status = 'FRACASO' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT codigo, data, status
 FROM historico WHERE status = 'REAVALIAR' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT codigo, data, status
 FROM historico WHERE status = 'SUCESSO' ORDER BY DATA DESC LIMIT 20)

Quando se utiliza o UNION ALL, não faz distinção no resultado obtidos (distinct)  e traz tudo que aquela SQL satisfaça.
Essa dúvida seria a sua da pergunta, mas, no comentários precisa de todos os campos, então:
(SELECT * FROM historico WHERE status = 'AVALIAR' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT * FROM historico WHERE status = 'FRACASO' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT * FROM historico WHERE status = 'REAVALIAR' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT * FROM historico WHERE status = 'SUCESSO' ORDER BY DATA DESC LIMIT 20)

Referencias

18.104.22.168 UNION Syntax
SQL: Utilizando o Operador UNION e UNION ALL
Answer: SELECT h.*
FROM historico h LEFT JOIN historico h2
    ON h.his_status = h2.his_status
       AND (h.his_data
 h2.his_codigo))
WHERE h.his_status IN ('FRACASSO', 'REAVALIAR', 'SUCESSO')
GROUP BY h.his_codigo
HAVING COUNT(*) < 50
ORDER BY h.his_status, h.his_data DESC, h.his_codigo;

Otimização de código SQL
Comment: @VirgilioNovic O propósito da otimização do código é o desempenho. Volta lá na outra pergunta e leia meus comentários na resposta do Antony.
Comment: Comentario para VirgilioNovic, por dizer besteiras.
"O código na resposta que você deu eu já havia feito antes, porém com algum tipo de erro que não permitiu a execução, portanto não há solução na sua resposta. Você ainda editou para ficar igual a minha solução (com os parênteses). Quanto à redundância de resposta em duas perguntas, creio que isso não seja crime algum, pois o importante é manter o histórico para que outros venham ser ajudados. Você deve estar mais preocupado com sua pontuação no fórum e, por isso não está pensando na lógica das coisas. – Billly Jow 13/11 às 20:58 "


How to access emp table in oracle 10g

Question: When I execute select * from emp SQL*Plus hangs even I logged in through run as administrator also.
But when I do desc emp and when I insert a record and select count(*) from emp  it works fine.
Comment: Post result of `select owner, object_name from all_objects where object_name='EMP';`
Comment: Can you explain more detail about "it is not responding"? Is there any error message??
Comment: Post what I asked. And, how are you executing the query, SQL*Plus or any GUI based client tool?
Comment: When I execute select * from emp I am not getting any error message nothing is coming means it become hang.
Comment: In SQL*Plus I am executing the query select * from emp;
Comment: when I am executing any other table like dept,salgrade or my own created tables then it works fine but only emp table getting problem.
Comment: take a screenshot of your sqlplus screen and update your question, that would provide clarity on what you actually mean by "not responding"
Comment: Try a `;` at the end of your select statement: `select * from emp;` without it SQL*Plus is waiting for you to complete the statement.
Answer: It might be because of oracle error during the execution of creation of the table.
Try droping the table and creating  the table.
delete from emp;
drop table emp;

After that create the table again.

How to access emp table in oracle 10g


Media Queries Problems With Bigger Phone Screens

Question: I seem to be having issues with my styling, when I check my styling on my Samsung galaxy S4 it seems to apply the same styles as on my desktop.
Is this because the S4's resolution is very high?
I can't seem to get around it, as the handheld query doesn't seem to apply itself to it.
CSS Code:
<code>@media screen {
    //Desktop Screens
    * {
        margin: 0;
        padding: 0;
        border: 0;
    }
    .clear {
        clear:both;
    }

    .right {
        float: right;
    }

    .left {
        float: left;
    }
    p.title {
        font-size: 18px;
        font-weight: bold;
    }
    body
    {
        font: 80% / 1 "Lucida Grande", "Lucida Sans", Tahoma, Verdana, sans-serif;
        background: #877781;
        color: #0c0c0c;
        text-align: center;
    }
    .login_cont {
        height: 80%;
        width: 15%;
        font: 80% / 1 "Lucida Grande", "Lucida Sans", Tahoma, Verdana, sans-serif;
        min-height: 200px;
        margin-top: 5%;
        margin-left: auto;
        margin-right: auto;
        padding: 20px;
        background: #dadada;
        border: 1px solid #0c0c0c;
        box-shadow: 1px 1px 3px #0c0c0c;
        border-radius: 5px;
    }

    .login_cont label{
        margin: 5px;
        padding: 5px;
        margin-top: 10px;
        font: 150% / 1 "Lucida Grande", "Lucida Sans", Tahoma, Verdana, sans-serif;
    }
    .login_cont h1 {
        margin: 5px;
        padding: 5px;
        margin-top: 10px;
        font: 250% / 1 "Lucida Grande", "Lucida Sans", Tahoma, Verdana, sans-serif;
        font-weight: bold;
    }
    .login_cont input {
        height: 20px;
        width: 50%;
        margin: 10px
    }
    .login_cont input[type='submit'] {
        height: 20px;
        width: 50%;
        margin: 10px;
    }
}
@media screen and (max-width: 480px) {
    //Traditional phones
    .login_cont {
        height: 70%;
        width: 80%;
    }
    .login_cont input {
        height: 20px;
        width: 1px;
        margin: 10px
    }
    .login_cont input[type='submit'] {
        height: 20px;
        width: 1px;
        margin: 10px;
    }
}
@media screen and (-webkit-min-device-pixel-ratio: 3.0) and (max-width: 1080px) {
    //Bigger phones
    .login_cont {
        height: 70%;
        width: 80%;
    }
    .login_cont input {
        height: 20px;
        width: 80%;
        margin: 10px
    }
    .login_cont input[type='submit'] {
        height: 50px;
        width: 70%;
        margin: 10px;
    }
}
</code>
Would it be better to use the media queries to include different stylesheets or is this way just as good?
Answer: media queries check on screenwidth in pixels.
so, if the desktop layout fits, it fits. easy as that.
What's the problem? Looking different on different cellphones? That's no problem.
Creating layouts for your site, does not mean it must always look exactly the same, it means it must be looking good as possible in all cases:)
[edit]
Resolution of S4: Size  1080 x 1920 pixels, 5.0 inches (~441 ppi pixel density)
So you have to adjust your media screenwidth properties. But that certainly becomes a problem with a horizontal view of 1920....
else you give desktop viewers (how many are there nowadays) a cellphone view too?
So i think you dont solve it with the mediaqueries alone. I know that there exists a PHP-class for recognizing cellphones. maybe someone else has a better solution.
[/edit]
[2nd edit]
with this php script you could recognize all mobile devices: http://mobiledetect.net/
[/2nd edit]
Comment: The problem is that I need the divs to expand on mobile devices and the text to be larger. I want a different set of styles for mobile devices.
Comment: I added a link to my answer for checking mobile devices server side with php
Comment: Sadly this app isn't in PHP so that script isn't much use, I was just wondering if CSS was finally able to solve the long fight between different screen sizes, but it doesn't quite seem to be full proof yet sadly.


Number of ways to order a set of interdependent tasks

Question: I am aware that this question has been asked and answered before here.
(Combinatorics/Task Dependency)
I'd like some help understanding a part of the answer.
Consider the graph shown there:
<code>  1
 / \
2   4
|   |
3   5
 \ /
  6
 / \
7   \
|    9
8   /
 \ /
  10
</code>
The calculations given check out, but I can't understand why $4\choose2$ is the number of ways to order the tasks 2, 4, 3 and 5. Doesn't $4\choose2$ count all ways to choose the first two tasks to undertake, including the disallowed orderings (35)24 etc?
Answer: ${4\choose 2}$ cannot be interpreted as the number of ways to choose the first two tasks without restriction; this would be $4\cdot 3 = 4!/2!$. Instead, ${4 \choose 2}$ represents the number of ways we can choose, among the four positions, to place the two objects in the left chain (2,3).
This uniquely determines the ordering, since those objects must be ordered properly, the remaining spaces must be filled from the right chain (4,5), and they too must be ordered properly.
Comment: Thanks, but I still don't get it :/ Can you explain further (especially the last line)?
Comment: @SohamChowdhury: Not sure what else to say in general, so let me provide an example. The 2-subset $\{1,3\}\subset\{1,2,3,4\}$ corresponds to the ordering $(2,4,3,5)$ because we fill locations $1$ and $3$ with the objects 2 and 3; of course we must put 2 before 3. Then the remaining locations ($2$ and $4$) will be filled with the remaining objects (4 and 5)$; similarly we must put the 4 before the 5.
Comment: I think I understand now. Thanks! :)


Refresh em div sem carregar outro conteúdo

Question: Bom dia pessoal!
Possuo uma página em ASP que tem basicamente 2 divs. Uma div onde há um painel que se conecta à um banco de dados e retira 3 informações de lá (uma espécie de dashboard) e uma div onde há um painel de mensagens que ficam passando (slider).
O que ocorre: essa página está atualmente com um refresh automatico por HTML (tag) e até que funciona bem! Mas, por questões de chegar uma hora que haverá maior número de mensagens neste painel, não vai dar tempo de ler todas antes da página carregar. Gostaria de ver se há alguma forma de recarregar somente o conteúdo da DIV do painel que pega os dados do banco. Vi algumas formas com JQuery, mas a maioria utiliza uma função "load" que precisa carregar um conteúdo dentro, por exemplo um html. Não haveria uma forma de fazer isso direto no documento sem qualquer load de outro arquivo?
Comment: Rodrigo dá uma olhada a esta pergunta/resposta: http://pt.stackoverflow.com/q/6626/129
Comment: Provavelmente Ajax + javascript resolva o seu problema...
Comment: Você precisa usar Ajax + JSON + JQuery. Seus dados devem ser dinâmicos ao ponto de consumir objetos JSON.
Answer: Existem 2 modos de se fazer isso.
1 - Através de Ajax (pode ser com jQuery ou não) considerando esta a melhor opção

Documentação do método em jquery http://api.jquery.com/jQuery.ajax/
2 - Através de iframe (não é elegante, mas também funciona)

Comment: Gildonei, muito obrigado pelo seu feedback e explicação. Só uma duvida: ali onde tem "url", como posso fazer? Porque por exemplo, é uma página apenas que tenho, neste caso uma página chamada "painel.asp", todo conteúdo está nessa página e nenhum conteúdo é retirado de outra página, no entanto, somente a DIV que aqui chamo de "dashboard" precisa ser atualizada a todo momento. Já a DIV "mensagens" deve permanecer rodando (slider) sem ser atualizada de tempos em tempos.
Comment: @RodrigoBRF Ali onde tem url:, vc vai substituir o 'nome-da-pagina.asp' por 'painel.asp'. Lembrando que painel.asp deve conter apenas o conteúdo que deverá ser carregado, sem layout ou formatações, apenas o texto/imagens que devem aparecer.
Comment: Entendi, mas no caso aqui, por exemplo, esse painel faz uma conexão com um DB para puxar alguns dados. Funcionaria?
Comment: Sim, funciona normalmente, continua sendo uma página asp normal, você pode fazer tudo normalmente nela, mas considere que ela deve mostrar apenas o conteúdo, pq se vc colocar layout, vai abrir uma página com layout dentro da div, entendeu?
Comment: Perfeito! Obrigado!!


Probability distribution vs. probability mass function (PMF): what is the difference between the terms?

Question: Consider a discrete case. PMF is the probability each value of random variable gets. So, for example, X ~ Poisson(2). I plot these probabilities (below), so I can say that I show the PMF of X. But on the other hand I show the distribution of X. For example, I can say whether the distribution I have is symmetrical or not. So, what is the difference between probability distribution and PMF terms (in discrete case)? Below I also bring the definitions from Wikipedia, but it is not helpful either.
Many thanks!

A probability mass function (pmf) is a function that gives the probability that a discrete random variable is exactly equal to some value.
A probability distribution is a mathematical function that provides the probabilities of occurrence of different possible outcomes in an experiment.
Comment: Does this answer your question? [Concept of Probability distribution](https://math.stackexchange.com/questions/57027/concept-of-probability-distribution)
Comment: The "discrete case" only admits probability distributions that are indeed given by probability mass functions.  I'm not strongly in favor of closing as duplicate, but with my comment posted here it seems reasonable.
Answer: The word "distribution" gets thrown around loosely sometimes, which can cause confusion.
The distribution of a random variable $X$ is the function that takes a set $S \subset \mathbb R$ as input and returns the number $P(X \in S)$ as output. (Technically I should assume that $S$ is a "nice" subset of $\mathbb R$ in some sense, but let's not worry about that.) I think the Wikipedia article would be more clear if it just gave us this definition up front.
The probability mass function (PMF) of a random variable $X$ is the function that takes a number $x \in \mathbb R$ as input and returns the number $P(X=x)$ as output. If $X$ is a discrete random variable, then the PMF of $X$ is a convenient way to specify the distribution of $X$.
Here is one way to describe the relationship between the distribution of $X$ and the PMF of $X$, in the case where $X$ is a discrete random variable. Suppose that the possible values of $X$ are $x_1,x_2,\ldots$ If $f$ is the distribution of $X$, then
$$
f(S) = \sum_{i : x_i \in S} P(X = x_i)
$$
for any set $S \subset \mathbb R$.
Comment: Thanks. But is not the definition of PMF by itself exactly as you described for "distribution of a random variable X"? If not, how they are different?
Comment: No, those definitions are not the same. For example, the PMF of $X$ takes a *number* as input, but the distribution of $X$ takes a *set* of numbers as input.
Comment: Thank you a lot, for clarification. But I am still a bit confused regarding your statement "the distribution of X takes a set of numbers as input". Suppose I flip a coin twice, X is number of tails.  My PMF is: 0: 1/4, 1: 1/2, 2, 1/4. So, for each value X (0,1,2,) the PMF returns the P(X=x). How will look the distribution function? It would help you can update your answer. Thanks!
Comment: Let $f$ be the distribution of the random variable $X$ that you mentioned. Then for example, if $S = (-7,1.3)$ (that is, $S$ is the open interval from $-7$ to $1.3$), then $f(S) = 3/4$. We could attempt to describe $f$ more explicitly but I'm not sure that it would be useful. The definition of $f$ is just that $f(S) = P(X \in S)$ for any set $S \subset \mathbb R$.
Comment: OK. I see. Thanks a lot.
Comment: It's misleading because then people think that's how the probability density function is defined.
Comment: @John Sure. I added a paragraph that describes the relationship between the distribution of $X$ and the PMF of $X$ a bit more explicitly (in the case where $X$ is a discrete random variable).
Comment: To the downvoter, I'd be genuinely interested in knowing the reason for the downvote; I might learn something.
Comment: Didn't downvote, but you probably mean "The distribution of a random variable X is the function that takes a set $S \subset \mathbb{R}$ as input and returns the number $P(X \in S)$".

Also, first you define a PMF, and then you say that in the specific case of $X$ being discrete, it is a useful way of obtaining the distribution. This is misleading. The PMF is only defined for discrete random variables.
Comment: Thank you @snarski. I just changed it to $X \in S$. Regarding the definition of the PMF, I believe that [Blitzstein's probability book](https://www.amazon.com/Introduction-Probability-Chapman-Statistical-Science/dp/1466575573) defines the PMF as I have here, so that the input can be any real number (but the output might be $0$). In this approach, technically any random variable has a PMF, but PMFs are only interesting / useful for discrete random variables. However, maybe that way of defining the PMF is not standard.
Answer: I'm not aware of an agreed upon definition/meaning for probability distribution.
On the other hand, probability mass functions and probability density functions have agreed upon definitions and are used to describe probability distributions.
A probability density function is the generalization of probability mass functions to random variables which are not strictly discrete.
In the case of a discrete random variable, the main difference is that the probability density function should integrate to one, while the probability mass function should add to one.
Suppose $X$ is a discrete random variable taking values $S=\{x_1,x_2,\ldots\} \subset \mathbb{R}$.
The probability mass function is a function $p : S\to [0,1]$ where
$$
p(x) = \mathbb{P}(X=x)
$$
On the other hand, the density function (of any RV) can be thought of as,
$$
f(x)dx = \mathbb{P}(X\in[x+dx])
$$
In integral form you could write this as,
$$
\int_{x}^{x+dx} f(z)dz = \mathbb{P}(X\in [x,x+dx])
$$
That is, the density times the width of a small interval gives the probability that $X$ is in that small interval $X\in[x,x+dx]$.
If the random variable is discrete, then the probability that $X$ is in this interval is the same as the probability $X=x$ for small enough $dx$. So you have $f(x)dx = \mathbb{P}(X=x)$ (or in integral form, $\lim_{dx\to 0}\int_{x}^{x+dx} f(z)dz = \mathbb{P}(X=x)$).
In particular, if $p(x)$ is the pmf for a discrete random variable $X$, then we can write the density function as:
$$
f(x) = \sum_{i:p(x_i)\neq 0} p(x_i) \delta(x-x_i)
$$
where $\delta(x)$ is the delta distribution; i.e. $\int_a^b f(x)\delta(c)d x = f(c)$ whenever $c\in[a,b]$
Comment: Only a continuous random variable has a density function. Note that $\lim_{dx \to 0} \int_x^{x+dx} f(z) dz = 0$, so your final equation states that $P(X = x) = 0$. This is true for a continuous random variable but not for a discrete random variable. (Discrete random variables don't have density functions.)
Comment: You can write the density of discrete random variables using [delta distributions](https://en.wikipedia.org/wiki/Probability_density_function#Link_between_discrete_and_continuous_distributions).
Answer: I provide a simple explanation of this here: Difference between "probability density function" and "probability distribution function"?. In short, a probability mass function is a discrete probability distribution function, where discrete is often implied.
Answer: Probability Mass Function.
I would say pmf of a discrete random variable is a graph or a table or a formulae that specifies the proportion or probabilities associated with each possible value the random variable can take.
It is a function that gives the probability that a discrete random variable is exactly equal to some value.


Simulate GARCH volatility conditional on return series

Question: Is it possible to simulate GARCH volatility series conditional on observed return series? What I want is that my simulated GARCH volatility will incorporate uncertainty of the estimated parameters but will not simulate the return series (it will use the observed return in the equation).
Answer: This should be possible. Suppose for simplicity we are dealing with a GARCH(1,1) model a with constant mean:
\begin{aligned}
x_t &= \mu+\varepsilon_t, \\
\varepsilon_t &= \sigma_t z_t, \\
\sigma_t^2 &= \omega+\alpha\varepsilon_{t-1}^2+\beta\sigma_{t-1}^2, \\
z_t &\sim i.i.D(0,1)
\end{aligned}
where $D(0,1)$ is some distribution with zero mean and unit variance. For a given parameter vector $(\mu,\omega,\alpha,\beta)$ and an initial estimate of the conditional variance $\hat\sigma_0^2$, you can "filter" the series (not sure "filter" is the right term) starting from
\begin{aligned}
\hat\sigma_1^2 &:= \omega+\alpha\hat\varepsilon_0^2+\beta\hat\sigma_0^2, \\
\hat\sigma_2^2 &:= \omega+\alpha\hat\varepsilon_1^2+\beta\hat\sigma_1^2, \\
&\dots \\
\hat\sigma_T^2 &:= \omega+\alpha\hat\varepsilon_{T-1}^2+\beta\hat\sigma_{T-1}^2. \\
\end{aligned}
This way you get the fitted conditional variances $(\hat\sigma_1^2,\dots,\hat\sigma_T^2)$. You can write a simple for loop from 1 to T for that. Let us call it the inner loop.
To incorporate the uncertainty of estimated parameters, you need to obtain a set of $M$ parameter vectors $(\mu_1,\omega_1,\alpha_1,\beta_1), \dots, (\mu_M,\omega_M,\alpha_M,\beta_M)$ and do the above for each of them. This could be done by writing an outer for loop from 1 to M around the previous loop.
The remaining question is, how do you obtain the parameter vectors.

If you have estimated your GARCH model in a Bayesian way, you have a joint distribution of the parameter vector; just sample from it.
If you have estimated the model using maximum likelihood, you could think in a fiducial way. Invoking asymptotics, you have a joint normal distribution with a mean vector equal to the point estimates $(\hat\mu,\hat\omega,\hat\alpha,\hat\beta)$ and a covariance matrix given by the estimated covariance matrix of the parameters. Sample from it.
Alternatively, you could use some version of bootstrap appropriate for time series to obtain a bootstraped distribution of the parameters. Sample from it.


Selection of alpha in elastic net: overfitting?

Question: Earlier I asked whether grid fineness of $\lambda$ is related to overfitting in LASSO, ridge regression and elastic net models. I got an answer that it is not the case. Now I am asking,
Question: Is grid fineness of $\alpha$ in elastic net related to overfitting?
($\alpha$ is the parameter governing the balance between $L_1$ and $L_2$ penalty.)
The argumentation in the answer to the linked question goes like this:

we definitely want to optimize our penalized likelihood function for values $\lambda$, and it doesn't matter how many values of $\lambda$ we test, because out-of-sample performance for a fixed data set and fixed partitioning is entirely deterministic. More to the point, the out-of-sample metric is not at all altered by how many values $\lambda$ you test.

I would guess that the same applies to $\alpha$ in place of $\lambda$, and hence a finer grid can only help but not hurt. Is that right?
(A note may be due that when doing cross validation, I fix $\alpha$ first and then do a search over a grid of $\lambda$s.)
Some related questions are this, this and this.
Answer: It is true that the out-of-sample performance on a fixed data set is deterministic, the question is whether the performance is generalizable. And that is not the case if you optimize your model to perform best on that fixed test data set.
Whenenver you optimize hyperparameters (here lambda) by checking the out-of-sample performance on a specific data set, you can no longer use that data set to get unbiased performance estimates. This does not mean that you don't want to optimize the parameter, it just means you can't use the performance estimates.
But don't believe me blindly, better to run a simulation yourself.
In the case of the grid size, you won't make overfitting much worse by making it finer. The important thing is whether you tune $\lambda$.
Comment: I think the other answer is more precise than you give it credit for. It correctly states that the grid size has relatively little impact; it's optimizing the parameter at all which causes some optimism in the estimates.
Comment: Thanks for your answer! Would you consider answering the linked question, too, for those who will only see *that* question without seeing your answer *here*? It should be easy to do as the argument is the same (basically, it will be copy-paste). Now regarding whether I understand you correctly, you stress that the *performance* metric can be overly optimistic. I get this. But I do not care about assessing performance. I care about selecting an optimal alpha (in this post) or lambda (in the other post). Do you agree that in order to find an optimal lambda and/or alpha a fine grid is no problem?
Comment: Also, I do not quite understand the idea of the last paragraph in your answer.
Comment: Your question is actually an interesting observation and I am not sure it is correct to say that the grid of lambda is not related to the overfitted solution. Suppose you have a way to tune lambda to get a 'non-overfitted' solution, call it method X (e.g. cross-validation may be a method although one may argue it is not the case). Typically we grid search lambda over some grid values of it. This means that method X finds 'optimal' lambda within the epsilon, where epsilon is the grid length.
Comment: Continued: This implies: 1. gird length matters and coarser grid may lead to overfitted solution, 2. you may want to take lambda+epsilon as the optimal lambda.