How to avoid the "clogged throat" feeling when singing?

Question: I really love singing. I do it quite often but I get really nervous about doing in front of an audience; even just thinking about it makes me nervous. I guess this is strictly related to everyone's personality and I've searched around for tons of helpful tips or guides to help you overcome this. But these helps were mostly on the psychological side: get on stage and you'll get rid of stagefright, forget negative thoughts, don't give too much importance to fear, etc.
My question here is mostly about a different, yet still related, problem. If the problem was only sweaty hands, shaking (usual nervous symptoms), I wouldn't mind at all. The problem is that this nervousness directly affects my singing.
My throat, and here is the problem, basically gets blocked. I can even feel it coming, a feeling of my throat getting clogged. Perhaps this is usually referred to as "throat getting dry", but I feel as it closed for a second, and after that I need to swallow before being able to continue.
Setting aside the psychological part (which I suppose is off topic here?), is there something I can try to overcome and avoid this obstacle, no matter how much I feel nervous?
Comment: I won't put this as an answer because you didn't want psychological answers - but I started to get over nervousness by filming myself performing at home, and putting it on YouTube. It was a real wrench at first, but the more I did it, the easier it became, and that translated to performing in front of live people.
Comment: This sounds like the classic 'globus hystericus'. IIRC the classic solution is *literally* to stop thinking about it, feeding the nascent neurosis more and more attention. Easier said than done, tho.
Comment: @slim It's not that I don't want psychological answers, I thought they were off topic... If they aren't feel free to elaborate on that post an answer! :D
Comment: Check into the Alexander Technique. I understand it's very helpful for many people for this exact thing and is a physical answer to what he considered a physical problem.
Answer: I think the core of your problem is psychological, and relatively common, to some degree or other, and I think there are posts on this over on Productivity.Stackexchange.com
That said, there are physical tips which can help, then as you find it easier your anxiety should also reduce - a positive reinforcement cycle:

Drink lots of water - this will help in general anyway. Hydration is very important for singers
Warm up - same as you would before running a marathon, you need to stretch and warm up the muscles and ligaments
Perhaps have a beer - My lead singer always has one or two small beers before a gig
You could look at throat lozenges - they may help, but may make it harder to hit notes correctly
Comment: I wouldn't combine beer and lozenges though, it would ruin the beer!
Comment: Also be careful with alcohol -- even a small amount can have a detrimental effect on some musician's performances (and others sing great when they're sloshed... go figure). These days I usually have half a beer or so before performing, but I used to just about go tone deaf after a single beer. Make sure it's something that works for you - with feedback from others.
Comment: +1 for the beer suggestion :-) I find one or two pints of beer (maximum) works just fine and doens't hinder dexterity or vocal ability, but just calms me down enough to get on with it. Also I like it.
Answer: One practical thing you can do is to see if you can improve the situation by experimenting with your diet. Specifically during the hours before you sing, but also in general. The throat and sinuses can react differently based on what you are eating, and what your blood sugar is like and so on.
For example, if you use a lot of caffeine, you might find that reduced caffeine or no caffeine improves things significantly. If you smoke tobacco, then not smoking might help significantly. You might try less sugar, especially right before you sing. All of these things are stimulants, and so is the nervousness you feel before singing, so you can end up essentially overdosing on stimulants before you sing. The nervousness simply pushes you over the top. If you arrive at the microphone a little lower, the nervousness may push you up into a good zone for singing effectively.
Another typical thing to look at is dairy. It will increase the amount of mucous in your throat and can make your throat react differently than otherwise. Many singers give up dairy at least for 4–8 hours before singing if not altogether.
From my own experience, when I embraced a diet that is rich in micronutrients — eating lots of raw fruits and vegetables, lots of salads — for some reason it really opened up my throat and sinuses, as though I had taken a giant hit of menthol, except healthier and the feeling lasts all day, everyday. It dramatically improved my singing experience. Not so much the way I sound, but the way I feel when I'm singing. Light instead of heavy, open instead of closed. I don't get distracted by my physicality while I'm singing. And I get fewer colds. I have more "peak voice" days.
Of course, make sure to be fully hydrated. Sipping water regularly is obvious. Another thing that is really great is fruit and vegetable smoothies made with a NutriBullet or similar device. They are very hydrating because they're like time-release water. You drink one and your body continues to gain hydration for some time afterwards. And it is a light meal to have before singing, which can also be beneficial to the way you feel at the microphone. During the hours before a recording session or show, fruit and vegetable smoothies is all I will eat because then I find my throat is hydrated and comfortable at the start of the session and I'm not constantly reaching for water, and yet also not running to the restroom all the time because I've been pounding the water. If you arrive at a session or show already dehydrated, it's basically impossible to catch up during the session. You have to maintain good hydration and nutrition when you're not singing so that it's there when you sing.
It is actually very common for people to have what they think is a psychological problem and then they cure that problem with significantly better nutrition. Even things like severe depression or severe anxiety disorders. It is worth a try because there really isn't any downside to trying. Even though healthy food can be more expensive and more time-consuming, it is still cheaper and easier than the typical psychiatrist, and much cheaper than the opportunity cost of not singing because of health problems.
Answer: Others have answered really well here (Dr Mayhem's gets my vote) but given the root of the problem seems to be nerves, here's what helped me out:
1) I read someting Keith Richards wrote:
"Look the crowd dead in the eye. If you get hurt, you get hurt."
The sheer bravery of that reminded me that no-one is going to end up in pieces. So what if you miss a note? The moment's gone. Just let it go and carry on with the rest of it.
2) A beer or two (maximum) helps calm the nerves. Don't have lots, but alcohol has a 'loosening' effect which is why it's so popular, of course. Find your own level with this, and remember that it calms you at first but will also affect your physical dexterity if you go too far.
3) Remember that the audience are on your side. This might not always seem the case but in most shows, the audience are there because they want to be, be it a pub or a stage show. They want to hear you sing your heart out, and they want both you and them to enjoy it. If they can see/feel that you're enjoying yourself, it's contageous so let it all out! This realisation was a turning point for me.
4) Go to jam nights regularly and sing/play with musicians you've never met. It's nerve-wracking at first as you have to think on your feet, but after a while you get used to it and suddenly going back to doing your thing with your rehearsed band/show feels like a doddle :-) Also it's just a jam - if it's falling apart, you can just stop the song and say "nah let's do something else". It's a jam so people realise it's a bit random.
Comment: @Olivia maybe this will help
Answer: It sounds like your nerves are causing something to tense up and close off, preventing free vibration from taking place.  Even though you don't have Tourette Syndrome (I assume), you could take a page from Comprehensive Behavioral Intervention for Tics (CBIT).  The basic idea is to find a competing response that does not allow the undesirable movement or tensing to take place.  However, it is very difficult to find a therapist trained in doing CBIT.  So, perhaps a more practical approach would be to work on relaxation exercises, especially breathing for relaxation.  It can be very helpful, before a performance, when your nerves are starting up, to do the special kind of breathing that help you relax.  Some psychologists and social workers are good at teaching relaxation exercises; some theater teachers, too.  The right kind of yoga teacher could help you with this too, I think.
I want to say something about nerves and adrenaline.  Even seasoned professional performers can experience horrible distress from nerves.  Also, performance nerves are unpredictable -- kind of like peyote!
The adrenaline can help your performance be extra special, though.  If someone performed without any of that extra oomph, it would probably be a dud of a performance.
So how do we cope?  Obviously, we want some adrenaline, but we don't want to be incapacitated by it.  What I found helpful was to spend some time in the performance space ahead of time by myself, getting acquainted with the space and the acoustics; and, the evening before, to close my eyes and think through the whole piece, away from my instrument.
I've heard about a spray singers like to use, available on the internet -- not sure if that would help.
Perhaps you could bring your question to a voice teacher.
Answer: What helps me overcome a tight throat when singing in front of others is something Barbara Hannigan mentioned in an interview. She doesn't sing to an audience, but lets the sound resonate within herself and invites the audience to share the experience. One singing teacher told me the sound is out there; you simply grab it like a ball, let it in and give it it's own space, then let it go for the next sound. It completely changes the focus and made a huge difference for me. Clowning lessons to embrace the unexpected helped as well.
Answer: I have the same exact problem. If I were you I'd try to do a longer set. When I play music, it takes me about 3 or 4 songs to get comfortable in front of a crowd and that's about when the feeling of the throat blockage goes away. Then everything after that I have full range and control of my voice again. It sucks for open mics because you only get to play like 3 or 4 songs. That's why I prefer to play 3 or 4 hour shows instead. After playing live continuously for a couple weeks it will go away completely, but it's like a muscle. You have to keep working it out to make it stronger/go away and if you take a break from playing live it will probably come back again.
Comment: Welcome to Music.SE and thanks for sharing your expertise here with your answer! Can I ask a clarifying question--does singing at home for 3-4 hours have equal benefit, or are you saying that singing *through* the lump is a form of practice which strengthens the relevant muscles and reduces future occurrence of the blockage?


Multinomial theorem for $(1+x+x^{-1})^k$

Question: Maybe this is a rather stupid question. The multinomial theorem tells us that
$$
(x_1+x_2+\ldots+x_n)^k=\sum_{k_1+k_2+\ldots k_n=k}\binom{k}{k_1,k_2,\cdots, k_n}x_1^{k_1}\cdot x_2^{k_2}\cdot\ldots\cdot x_n^{k_n}
$$
for non-negative integers $k_1,\ldots,k_n$, $k=k_1+\ldots+k_n$ and real numbers $x_1,\ldots,x_n$.
Now, if I have, for instance,
$$(1+x+x^{-1})^k,$$
this polynomial is not defined for $x=0$. Does this mean that for all $x\in\mathbb{R}\setminus\{0\}$, we have
$$
(1+x+x^{-1})^k=\sum_{k_1+k_2+k_3=k}\binom{k}{k_1,k_2,k_3}x^{k_2}x^{-k_3}?
$$
Comment: What are your doubts?
Comment: @Sisyphus The multinomial theorem says nothing about the domain of the polynomial on the left hand side. So I am not sure if we have a polynomial (as my example) which is not defined on the whole reals,  the multinomial theorem holds on this domain.
Comment: It should hold at all $x$ other than $x=0,$ but that value is already excluded by the left side anyway.
Answer: Yes, you are correct. Notice that the RHS is not defined in $x=0$ either, with (for instance) $k_1= 0,k_2 = 0,k_3 = k$ the corresponding term is $x^{-k}$, and this term is not defined in the origin.
Comment: Tell me if I misunderstood your concern.


If w is a complex root of 1. Find the value of w^4+w^8

Question:
If $w$ is a complex root of 1. Find the value of $w^4+w^8$

Why does complex root of 1 always mean that $w^3=1$ ? Why not $w^2$ ?
Back to the question, here's what I did:
$$w^8+w^4=w^2(w^3)^2+w(w^3)$$
Since $w^3=1$
$$=w^2+w$$

My book continued  this idea to :
Since $1+w+w^2=0$ (I don't know why)
Then:
$$w^4+w^8=w^2+w=-1$$
How did the book do this?
Comment: It *doesn't* always mean that $w^3=1$. You're right. There is some missing information/assumptions here.
Comment: If we accept that $w^3=1$, or that the book specifically meant a cubic root (in my opinion that is Very iffy), then
$$0=w^3-1=(w-1)(w^2+w+1).$$ So if $w\neq1$ we get $w^2+w+1=0$.
Comment: Most likely a typo/omission.
Comment: Okay, then they probably meant "complex cube root of $1$" to indicate that $\omega\neq 1$ [although $1$ is also a complex number, people often use "complex" to mean "non-real" in such situations] and forgot the "cube". You could send a report about that mistake to the authors.
Comment: So the term "complex root of 1" does not necessarily mean $w^3$ ? Because I found it weird too, why can't they just called it 3rd root of unity.
Comment: Thank you @JyrkiLahtonen , can you post it as an answer? I understood
Comment: @JyrkiLahtonen Ok thank you. But it's weird coz its repeated in many questions.
Comment: Are you absolutely sure you didn't misread "cube root of $1$"? If that happens once, such misreadings have a tendency to perpetuate.
Comment: @DanielFischer Im positive. Infact it has two types of questions. Some questions say w is a cube root of 1 and other say w is a complex root of 1.
Comment: @DanielFischer thank you alottt Daniel. Yes I will.
Comment: ...or perhaps the textbook *defined* $\omega$ as a particular cube root of unity...
Comment: @JpMcCarthy I wish they had, but No they haven't.
Answer: $\omega$ is Cube Root of unity
$$x^3=1$$
$$x^3-1=(x-1)(x^2+x+1)=0$$
$x=1$ is one solution, other two are complex
$$(z^2+z+1)=0$$
$$z=\omega,\omega^2$$
Comment: Isn't it better to replace z by x in this case?
Comment: @TheArtist we generally use $z$ for complex numbers
Comment: don't you think when you say z= $\omega$ , $\omega^2$ . Which are the two other roots. So one who sees this question might get confused with $w$ and $w^2$ In my question??
Comment: There are Exactly 3 **Cube Roots** of Unity, $1,\omega,\omega^2$, And I think your book meant **Complex Cube Roots** not just Complex Roots
Comment: And there is no variable called $x$ in my question. So I think it would be nice if you can change these conventions??


How to delete a dictionary in a list, if the same dictionary is in another list (Python 2.7)

Question: I have two lists that include same dictionaries in the format of:
List 1:
[{'url': u'http://www.bloomberg.com/news/articles/2016-08-17/you-can-get-a-50-phone-from-amazon-if-you-don-t-mind-the-ads','title': u'You Can Get a $50 Phone From Amazon, If You Don\u2019t Mind the Ads'}, {'url': u'http://www.bloomberg.com/news/features/2016-08-18/uber-s-first-self-driving-fleet-arrives-in-pittsburgh-this-month-is06r7on', 'title': u'Uber\u2019s First Self-Driving Fleet Arrives in Pittsburgh This Month'}]

List 2:
[{'url': u'http://www.bloomberg.com/news/articles/2016-08-17/you-can-get-a-50-phone-from-amazon-if-you-don-t-mind-the-ads', 'title': u'You Can Get a $50 Phone From Amazon, If You Don\u2019t Mind the Ads'}]

What I wanted to do:
I would like to delete the dictionary(both url and title) in list 1 which is also present in list2.
I have tried the following,
list1[:] = [d for d in list1 if d.get('title') != (fail for fail in list2 if fail.get('title'))]

but couldn't manage to do it
Expected Result:
list1 = [{'url': u'http://www.bloomberg.com/news/features/2016-08-18/uber-s-first-self-driving-fleet-arrives-in-pittsburgh-this-month-is06r7on', 'title': u'Uber\u2019s First Self-Driving Fleet Arrives in Pittsburgh This Month'}]

Comment: what should be the output?
Comment: Just added to the question @HarshaBiyani
Comment: Could you please restate what you would like to do? It is a little hard to understand.
Comment: I want to remove the dictionaries that are common with list2 from list1.@Mr.goosberry
Answer: Just do a simple comparison:
>>> final = [i for i in one if i not in two]
>>> final
[{'url': u'http://www.bloomberg.com/news/features/2016-08-18/uber-s-first-self-driving-fleet-arrives-in-pittsburgh-this-month-is06r7on', 'title': u'Uber\u2019s First Self-Driving Fleet Arrives in Pittsburgh This Month'}]

Then you can do list1 = final if you really want.
Comment: How neat and concise!
Comment: Note: This is `O(n*m)` (where `n` is the size of `list1` and `m` is the size of `list2`, making it `O(n^2)` for similarly sized lists), since it has to scan `list2` linearly once for each element in `list1`. Depending on requirements, it could be possible to do a `O(n)` preprocessing pass on `list2` such that the `list1` filtering step can perform lookups in `O(1)`, getting a total `O(n)`. Of course, if the lists are small, it hardly matters.
Answer: If I understand correctly, you want list1 to consist only of the entries whose title does not exist in list2. This is probably best done with a two step process, to avoid repeated linear scans of list2 for each element in list1:
# Make a set of all titles defined by the dicts in list2
titles_in_list2 = {d['title'] for d in list2 if 'title' in d}

# Filter the contents of list1 to only items with titles not found in list2
list1[:] = [d for d in list1 if d.get('title') not in titles_in_list2]

Note: The .get call in the second comprehension, and the if check in the first aren't needed if all entries are guaranteed to have a title key defined. The .get would become straight lookup, d['title'] not in titles_in_list2, and the if 'title' in d check would be dropped entirely. You also don't need the slice assignment unless other references to list1 might exist and must be changed; if that's not a concern, list1 = [...] is fine.
Comment: @Pythoner1234: This is removing the whole `dict` if the titles match, which eliminates the urls and titles at once. You could change it to construct a check set of `urls` and test against that if you want, or construct both a title and url check set and delete overlaps on either, but that just changes which `dict`s get dropped; if the `dict` is dropped, you drop all its keys and values, not just the one you tested against after all.
Comment: This code worked perfectly too. I wanted to also remove the 'urls' from the list1 as well.
Answer: Burhan Khalid's answer is perfect.
In case, you want a solution matching to your line of previous thoughts, here it is :

list1 = [d for d in list1 if d.get('title') not in [f.get('title') for f in list2]]


Outer Measure on $\mathbb R$ with trivial measurable sets

Question: This question arises from wondering how bad an outer measure can be. Some authors prefer to work with general outer measures (e.g. Evans and Gariepy), and it would be nice to be able to think of outer measures as just extensions of measures. As in every outer measure induces a measure and every measure induces an outer measure, and it would be nice if these were inverse to each other, though in general they are not. There are of course conditions (e.g. regularity) that allow you to know that this is the case, but one can wonder how nasty a general outer measure can be.
One way an outer measure can be bad is not having enough measurable sets. Hence the question is whether there is an example of the most extreme version of this (on $\mathbb R$ and maybe $\mathbb R^n$ if it's interesting): does there exist an outer measure on $\mathbb R$ such that the only measurable sets (under the Caratheodory criterion) are $\mathbb R, \emptyset$?
Answer: Yes there is! Consider the function $\mu^{*}:P(\mathbb{R})\to [0,\infty)$ given by
$$\mu^{*}(A)= \begin{cases} 1, & \text{if} \hspace{2mm} A\neq \emptyset, \\
0, & \text{if} \hspace{2mm} A=\emptyset .
  \end{cases}$$
It is easy to see that $\mu^{*}$ is an outer measure on $\mathbb{R}$. Now, I claim that the only two subsets of $\mathbb{R}$ satisfying the Carathéodory criterion are $\mathbb{R}$ and $\emptyset$. Clearly, if we let $E=\mathbb{R}$ or $E=\emptyset$ then, for every $A\subseteq \mathbb{R}$, the following equality is true $$\mu^{*}(A)= \mu^{*}(A\cap E) + \mu^{*}(A\setminus E).$$
Conversely, suppose that $\emptyset\neq E \subset \mathbb{R}$ (here the symbol $\subset$ means proper inclusion). Let $a\in E$, $b\in \mathbb{R}\setminus E$ and put $A=\{a,b\}$. Then, $$\mu^{*}(A)= 1 \neq 2 = 1+1 =\mu^{*}(A\cap E) + \mu^{*}(A\setminus E).$$
As a final comment, if we consider any set $X$ with at least two elements, then the corresponding $\mu^{*}$ produces an outer measure on $X$ such that the only $\mu^{*}$-measurable sets are the empty set and $X$ itself.


How can I declare a variable of type List?

Question: I am using TypeScript and have a C# class with a property of type List<string>. I need to have the same type of property in TypeScript.
How can I declare a property in TypeScript class of type List<string>?
Comment: His is asking how to create a member of a class that is of type List in TypeScript.
Comment: If you have a `List<>` class already defined, you already appear to know how to declare it. So, what's your question? Typescript doesn't add .NET classes.
Comment: Use: var_name: Array; or var_name: string[];
Answer: List<string> is something specific to C# and depends upon the Base class library (BCL) support in .NET.
For TypeScript by default (without an external library like https://github.com/basarat/typescript-collections) you are limited to the built in JavaScript Array type. Here is a small sample to show its usage:
var foo:string[] = ['a','b'];
foo.push('c');
console.log(foo) // [a,b,c]

Comment: This is how you declare a variable as a list.  You don't show how to create a *class member* of type list.
Comment: Class member ain't that different `class Foo { foo : string[] = ['a'] } ` @ftravers .See http://basarat.gitbooks.io/typescript/content/docs/classes.html


Why does the following Maclaurin series equal this catenary curve?

Question: Given this Maclaurin series:
$$f(x)=\sum_{n=0}^{\infty}\frac{x^{2n}}{(2n)!}$$
And the following Catenary curve, assuming that $a=1$:
$$g(x)=\frac{a(e^\frac{x}{a}+e^{-\frac{x}{a}})}{2}$$
Why does $f(x)=g(x)$ seem to hold true (at least when graphed)?
I'm looking for a purely algebraic reason here as to why these two are equal, ideally in terms that are at or around a high-school calculus level (where I'm at currently).
If I am mistaken, and these two are not equal to each other, an explanation of why that is would be great too.
Comment: Have you heard of Taylor expansions? For $a=1$, $g(x)=\cosh(x)$
Comment: For any nonzero $a$, your function $g(x)=a\cosh \frac xa$
Comment: Can you show us your own algebraic work on trying to answer the question,  first?
Comment: @amWhy That's my problem; I have no idea how to start this.
Comment: @James If the OP is working with Maclaurin series, I would venture to say he's doing the same with Taylor series.
Comment: @James Apologies for the late reply - I have heard of Taylor expansions, but I only really have a surface-level understanding of them.
Answer: Remember that $$e^x=\sum_{n=0}^{\infty}\frac{x^n}{n!}$$
Thus $$\frac{1}{2}(e^\frac{x}{a}+e^\frac{-x}{a})=\frac{1}{2}\sum_{n=0}^{\infty}\left [\left (\frac{x}{a}\right )^n\frac{1}{n!}+\left (\frac{-x}{a}\right )^n\frac{1}{n!}\right ]$$
This can be simplified to $$\frac{1}{2}\sum_{n=0}^\infty \left (\frac{1+(-1)^n}{a^n n!}\right )x^n$$
When $n$ is odd, $1+(-1)^n=0$, so we can replace $n$ by $2n$ everywhere to get $$\frac{1}{2}\sum_{n=0}^\infty \left [\frac{1+1}{a^{2n} (2n)!}x^{2n}\right ]=\sum_{n=0}^\infty\frac{x^{2n}}{a^{2n}(2n!)}$$
When $a=1$, you get the series $$\sum_{n=0}^{\infty}\frac{x^{2n}}{(2n)!}$$
Answer: The starting point is the series expansion of the exponential function:
$$
e^x=\sum_{k=0}^\infty \frac{x^k}{k!}
$$
substituting in  $g(x)$ with $a=1$ we have:
$$
g(x)=\frac{e^x+e^{-x}}{2} = \frac{1}{2}\left(\sum_{k=0}^\infty \frac{x^k}{k!}+\sum_{k=0}^\infty \frac{(-x)^k}{k!} \right)=\frac{1}{2}\left[\sum_{k=0}^\infty \left(\frac{x^k}{k!}+ \frac{(-x)^k}{k!} \right)\right]
$$
now note that the for $k$ odd the terms in the series are null and for $k$ even the terms becomes $2\frac{x^k}{k!}$, so in the series we have only the even terms $k=2n$ and the function becomes:
$$
g(x)=\frac{1}{2}\sum_{n=0}^\infty\frac{2x^{2n}}{(2n)!}=\sum_{n=0}^\infty\frac{x^{2n}}{(2n)!}
$$
Answer: Let consider the function
$$C(x)=\frac{e^x+e^{-x}}{2}$$
and let define also
$$S(x)=C'(x)=\frac{e^x-e^{-x}}{2} \implies S'(x)=C(x)$$
thus since

$C(0)=1$
$C'(0)=S(0)=0$
$C''(0)=S'(0)=C(0)=1$
...

by Taylor's expansion at $x=0$, that is Maclaurin's expansion, we have that
$$C(x)=\frac{e^x+e^{-x}}{2}=1+\frac{x^2}{2!}+\frac{x^4}{4!}+\frac{x^6}{6!}+\dots+\frac{x^{2k}}{{2k}!}+\dots=\sum_{n=0}^{\infty}\frac{x^{2n}}{(2n)!}$$
which turns out to converge for any $x\in \mathbb{R}$.


Estimating model fitness for variable importance in linear regression

Question: I am interesting in finding the relative importance of variables in a GLM model. The dependent variable is binary, while the independent variables are a mix of continuous and categorical. To do this, I would be looking at the coefficients with low p values from the GLM. The coefficients are standardized (and say uncorrelated).
My question is that do I need to assess model fitness before looking at the coefficients? I can, of course, look at predictive accuracy of the model, but the predictive accuracy might not be indicative that the individual coefficients are correct. I also thought of using R^2, but again it only measures overall model fitness. What are the recommended set of steps I need to take before I can trust the coefficients from a GLM are providing a correct estimate of relative variable importance?
Comment: To be more precise about the question, for assessing variable importance, is it enough to look at coefficients with low p-values or do we need to look at model fitness before looking at coefficients?
Answer: If I understand you correctly, you should assess how well the model fits before paying attention to the coefficients. If the model is a poor fit and the parameter coefficients are significant, then the coefficients are doing a good job at explaining a bad model.
Once you are satisfied the model fits well, you can interpret the coefficients.
If you are looking to figure out the relative importance of the predictors in your model, that's a different can of worms. The coefficient of each predictor is how much a one-unit change in it affects the outcome. But, critically, that effect is based a model that includes the other predictors you included.
This article explains some of the thorniness:
http://www.r-bloggers.com/the-relative-importance-of-predictors-let-the-games-begin/
Comment: Thanks for the response. The first part of your message addresses my question. To be more precise, for assessing variable importance, is it enough to look at coefficients with low p-values or do we need to look at model fitness before looking at coefficients?
Comment: I think you first need to look at model fitness. Then at the contribution of the coefficients. Low p-values aren't enough though, if you are looking for the relative importance. They just tell you the likelihood that you obtained a coefficient that extreme by chance.


How to publish custom jars to local Apache Ivy repository

Question:
I've read all the tutorials and examples, and still cannot publish a set of custom jars in my local Ivy repository.
 Edit: Basically I want the same behavior as maven-install-plugin.
Here's my setup. I have an Ant task which produces the jars in a given folder. The folder name is not fixed but rather passed as a property in file. I want to get all the jars in this folder and install them in my local Ivy repo so that I can use them on a next step.
Here is my Ant from where I call the ivy:publish:
<project name="Install Ivy Dependencies" xmlns:ivy="antlib:org.apache.ivy.ant" basedir="." default="publish">

    <loadproperties srcFile="path_to_folder.properties"/>

 <property name="file_pattern" value="${path_to_folder}/[artifact].[ext]" />
 <property name="pub_revision" value="1.0.0" />

   <target name="resolve">
        <ivy:configure file="ivysettings.xml" />
        <ivy:resolve file="ivy.xml" />
  </target>

 <target name="retrieve-all" depends="resolve">
        <ivy:retrieve pattern="${file_pattern}" conf="*" />
 </target>

 <target name="publish"  depends="retrieve-all">
        <ivy:publish resolver="local" organisation="myOrg" update="true" overwrite="true" pubrevision="${pub_revision}">
           <artifacts pattern="${file_pattern}"/>
        </ivy:publish>
 </target>
</project>

Here's my ivysettings.xml:
<ivysettings>
  <resolvers>
      <filesystem name="local" local="true"/>
    </resolvers>
</ivysettings>

And the ivy.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">

  <info organisation="myOrg" module="myModule" revision="1.0.0"/>
  <publications>
    <artifact name="my-custom-jar" ext="jar" type="jar"/>
    <artifact name="my-custom-jar-source" ext="jar" type="source"/>
  </publications>
</ivy-module>

The error that I am getting when I call the ant task is:
impossible to publish artifacts for myOrg#myModule;1.0.0: java.lang.IllegalStateException: impossible to publish myOrg#myModule;1.0.0!my-custom-jar.jar using local: no artifact pattern defined
Answer: I've managed to run my scenario and to resolve my issues using this tutorial There were two major issues in my code/integration.
First one is that you cannot tell Ivy to publish the artifacts in its repository without providing a path to it. I did this with the filesystem resolver:
<filesystem name="local" local="true" transactional="local">
      <ivy pattern="${ivy.default.ivy.user.dir}/local/[module]/ivy-[revision].xml" />
      <artifact pattern="${ivy.default.ivy.user.dir}/local/[module]/[artifact]-[revision].[ext]" />
</filesystem>

The stupid think about it is this should be build in. If you copy it as is, then everything works. If the config is different, or pointing to a different location - nothing works and you are not told why. I read tons of docs about Apache Ivy and it was nowhere mentioned that these patterns should point to the local Ivy repository. I thought these were the paths from where the jars should be taken. I actually complained about this, but the Ivy documentation is very confusing. Also I think the examples there are wrong. Who would like to publish the artifacts in their ivy.settings.dir. In my case this directory was in my repository!

There was a second issue. It is a smaller one and again very hard to see and fix. There's something wrong the revision param and again the documentation is messed up. If you specify one and the same string for the revision and pub revision the artifacts aren't publish without any explanation why. I fixed it by removing the revision from ivy.xml file.
Last, but not least, I didn't manage to run successfully the "thing" as Ant task, but with java -jar $IVY_JAR ... Maybe the issue was because of the versions, but I was too tired to try it with the fix.
P.S.@cantSleepNow thanks for the help.
Answer: You need to add artifact pattern to resolver in ivysettings.xml, something like (example from ivy documentation):
<ivysettings>
  <resolvers>
      <filesystem name="local" local="true">
          <ivy pattern="${ivy.settings.dir}/1/[organisation]/[module]/ivys/ivy-[revision].xml"/>
        <artifact pattern="${ivy.settings.dir}/1/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
        </filesystem>
    </resolvers>
</ivysettings>

Comment: Ok, after fixing several small bugs in my ivysettings.xml this was able to run. Anyway it didn't publish the artifacts where I wanted to. It says this: [ivy:publish] published my-custom-jar.jar to /my-custom-jar.jar. What I want is Ivy to take the artifacts from /my-custom-jar.jar and publish them in the local cache/repository - just like maven-install-plugin
Comment: @Boyan I just wrote an example resolver. Obviously you have to change the artifact pattern and ivy pattern in order to set the location. I have added a link in the answer
Comment: @canSleepNow, I know that your code is an example. My issue is that I don't fully understand Ivy publish. I have already read the Ivy documentation incl. the link you sent, but I am still not able to understand what should I put where. Should I specify the path to the local repo? This doesn't make sense since it is different for every system. Also where should I specify the path from where the local artifacts are taken and installed in the local repository? Regarding my ivy.xml file - it is static and I don't generate it.


Display image in a "fullscreen" view - when image view has been tapped

Question: In a simple test app for iPhone I display (using SDWebImage) a user avatar on the top:

When the app user taps the avatar I'd like to display that picture "fullscreen" in another view.
So I have added that view to my Xcode 5 storyboard and also tap recognizer and the push segue which I've called "pushZoom" (here fullscreen):

The tap recognizer works okay, I can see its method being called.
My question: is there maybe a simple way in Interface Builder to pass the image to the new view or do I have to go the tedious way (add ZoomViewContoller.[mh] files, define an outlet for the image view there)?
Below is the copy of my ViewController.m in case I modify it later @ GitHub:
<code>#import "ViewController.h"
#import <SDWebImage/UIImageView+WebCache.h>

static NSString* const kAppleMaps = @"https://maps.apple.com/?q=%@";
static NSString* const kGoogleMaps = @"comgooglemaps-x-callback://?q=%@&x-success=myphone://?resume=true&x-source=MyPhone";
static NSString* const kAvatar = @"https://lh6.googleusercontent.com/-6Uce9r3S9D8/AAAAAAAAAAI/AAAAAAAAC5I/ZZo0yzCajig/photo.jpg";

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self setTitle:@"Google+"];

    _firstName.text = @"Alex";

    [_cityBtn setTitle:@"Bochum" forState:UIControlStateNormal];

    [_imageView setImageWithURL:[NSURL URLWithString:kAvatar]
               placeholderImage:[UIImage imageNamed:@"Male.png"]];
}

- (IBAction)avatarTapped:(id)sender {
    NSLog(@"%s", __PRETTY_FUNCTION__);
}

- (IBAction)cityPressed:(id)sender
{
    NSURL* testURL = [NSURL URLWithString:@"comgooglemaps-x-callback://"];
    NSString* fmt = ([[UIApplication sharedApplication] canOpenURL:testURL] ? kGoogleMaps : kAppleMaps);
    NSString* city = [self urlencode:_cityBtn.currentTitle];
    NSString* str = [NSString stringWithFormat:fmt, city];
    NSLog(@"%s: city=%@ str=%@", __PRETTY_FUNCTION__, city, str);
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}

- (NSString*)urlencode:(NSString*)str
{
    return (NSString*)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
        NULL,
        (__bridge CFStringRef) str,
        NULL,
        CFSTR(":/?@!$&'()*+,;="),
        kCFStringEncodingUTF8));
}

@end
</code>
Answer: Why do you need another viewController. You may keep an imageView of full size over you view without any image initially and keep it hidden, and on tapping that button, remove it from hiding. and just pass the image. So it doesn't need any of these problems. It seems simple for me
Answer: In my experience is small , but I show my idea
<code>- (IBAction)avatarTapped:(id)sender {

   //here use your choice in singleton or NSUserdefaults for passing the image url from one VC to another VC. here I used NSUserdefaults

 [[NSUserDefaults standardUserDefaults]setObject:kAvatar forKey:@"userimage"];
}
</code>
in your full image show ViewController.m
<code>- (void)viewDidLoad
{
[super viewDidLoad];
NSString *userimg =[[NSUserDefaults standardUserDefaults]stringForKey:@"userimage"];

 [_imageView setImageWithURL:[NSURL URLWithString:userimg]
           placeholderImage:[UIImage imageNamed:@"Male.png"]];
}
</code>
Comment: any changes i waiting for your reply
Answer: Pass image URL as string or url  to next screen and show it in an imageView using
<code>[self.myImageView setImageWithURL:[NSURL URLWithString:photoURL] placeholderImage:[UIImage imageNamed:@"loading.png"]];
</code>
Thats what i would do.Please post here if you got some better idea.


NET MAUI doesn't show option to compile with android

Question: I usually build apps with Xamarin, and today I decided to test MAUI, but I don't see the option to compile with Android.
I already ran the command "dotnet workload restore", and I get the message that it is already installed.
Does anyone know what can it be?
Thanks
Comment: please do NOT post errors as images
Comment: sorry, I will edit
Answer: I solved the problem with the command dotnet workload repair.


How can I automate and run post installation commands in Azure Virtual Machines?

Question: I need to deploy Azure hosts and configure them according to a pre-defined script once they are loaded.
Is there any example, guidance,or tutorial on how to modify an Azure VM once the instance is deployed... programmatically (via powershell, c# or any other means)?
So far, I've gone through the command-line deployment commands, and don't see a way that I could upload or otherwise launch a post deployment installation command.
Answer: I'm not entirely sure where you've gotten stuck or what specifically you're trying to accomplish, but I'll give it a shot anyway...
Remote Desktop
Just for kicks, let's start with remoting in to the VM. I've spun up a VM using the Azure portal. The portal asks for a username and password to be specified. Obviously, the simplest way to remote in would be using the 'Connect' button after selecting an instance of your VM:

From there you could input your credentials, log in to the VM, and open up PowerShell.
That's a bad way of taking care of it, but it is the most straightforward.
PowerShell Remoting
Starting a remote PowerShell session could be a little quicker and involve less GUI. For a quick one-liner, try this:
Enter-PSSession -ConnectionUri (Get-AzureWinRMUri) -SessionOption (New-PSSessionOption -SkipCACheck) -Credential (Get-Credential)

You'll be prompted for the service name (in my case, rtannerf) and credentials. I opted to ignore the self-signed certificate rather than importing it.
You can also use Invoke-Command:
 Invoke-Command –ConnectionUri $uri –Credential $cred –ScriptBlock { "do u liek mah hat!?" | Out-File C:\hello.txt }

More on this here. You could expand upon this and use PowerShell to both deploy your VMs and run scripts against them once deployment is finished. Might want to take a look at the Azure Management cmdlet reference page.
This approach seems a little clunky to me, but if you need to kick off just a few VMs it might work out fine for you.
Deploying via Images
If you need a heavier touch than is appropriate for Invoke-Command, you may want to look in to deploying images. Short version is you'll prepare an image the way you would just about any other Windows image, upload it to a storage account in Azure, and use the management console to add the VHD to your images. There's a short guide here.
It sounds to me like this will be the way you want to approach your problem. You could use startup scripts and whatnot to get the machine in to the state you want, but it's probably better to cut to the chase and simply deploy an image that's configured exactly how you need it.
Comment: I think PowerShell Remoting with the link you gave me is just what I needed.  Thanks!
Answer: When deploying a VM, you can specify custom data: Up to 64K of data that's injected into the VM during provisioning (API details here). You specify data in a base-64 encoded format in the <CustomData> element. This data will then appear in your VM, in:

%SYSTEMDRIVE%\AzureData\CustomData.bin (Windows)
/var/lib/waagent/CustomData (Linux)

This is currently only available via the REST API directly, but will soon also be available via the cross-platform CLI. You can see the pull request for this feature here.
Comment: It's your file to do as you wish. You could have a simple text file with a connection string; maybe a json config file; a puppet script; zip file; exe... I'd suggest trying it out with some simple text to see it in action.
Comment: Thanks for the tip!  Once I put the bin file there, what can I do with it?  Thinking out loud, perhaps I could rename it to .zip or exe and run it remotely as described in the other answer
Answer: Alternative way, use IaaS Management Studio, it generates the command line so you can connect via powershell in one click. (and generate the command lines for it)
Commercial, but maybe the free trial is enough for you.


Mudar class dinamicamente

Question: Tenho um html com ngFor:

{{cont.NOME}}

Faço uma requisição para ver se esse cont.NOME possui dados no banco, se caso não possuir, o nome ficara com a class text-light, mas se tiver dados, ficara com text-danger:
for (let index = 0; index < colabs.length; index++) {

      this.service.showResults(colabs[index].FILIAL, colabs[index].MATRICULA).subscribe(
        (res) => {
          let cont = (<any>res).length

          if (cont > 0) {
            //nome fica vermelho
            this.redName = true;

          } else {
            this.redName = false;
          }

        },
        (err) => console.log(err)
      )

    }

mas os nomes só estao ficando com a class text-danger, sendo que um deles deveria ficar com text-light.
Alguem poderia me ajudar?
Answer: Bom tente utilizar o ng-class com o if ternario .

        {{cont.NOME}}

Comment: deu erro: ERROR Error: Uncaught (in promise): Error: Template parse errors:
Parser Error: Missing expected : at column 10 in [{redName == true ? 'text-danger' : 'text-light'}]
Comment: editei a resposta, caso de erro me avise
Comment: nao deu erro, mas nao mudou a cor
Answer: Você está alterando uma variável redName que está sendo utilizada num array inteiro retornado no serviço. Ficando todos com classe danger ou light. Para que você compare cada item isoladamente, seria interessante colocar um atributo temporário.
no ts:
(res) => {
    const cont = res.length

    if (cont > 0) {
        //nome fica vermelho
        colabs[index]._redName = true;
    } else {
        colabs[index]._redName = false;
    }

    // ou apenas:
    // colabs[index]._redName = cont > 0;

},

entao no seu html:

{{cont.NOME}}

Answer: Achei a solução ideal com a ajuda da resposta do @Gaspar
Eu criei uma array global e fiz um push com os dados do colaboradores e adicionei mais 1 dados:
  this.arrayColabs.push({
    MATRICULA: colabs[index].MATRICULA,
    CCT: colabs[index].CCT,
    NOME: colabs[index].NOME,
    FILIAL: colabs[index].FILIAL,
    _redName: true
  })
  let cont = (<any>res).length

  if (cont > 0) {
    //nome fica vermelho
    this.arrayColabs[index]._redName = true;
  } else {
    this.arrayColabs[index]._redName = false;
  }

e no html deixei:

{{cont.NOME}}

        <button class="btn-primary btn button_visu" (click)="select(cont.FILIAL, cont.MATRICULA)">Visualizar</button>

Answer: Tenta assim:

Comment: os dois nomes ficaram vermelho

Mudar class dinamicamente


I want to append a string to an existing column of sqlite. Is that possible, if yes then how

Question: I want to add the strings dynamically into a single column of my sqlite database.
 please any one suggest me how to do this.
Comment: Get the value, append your string to it, then update you table with the new value
Comment: Please tell me how to append the string to a particular column.
Comment: I mean, code for how to append multiple strings to a single cell separated by commas.
Comment: What have you tried? Google Sqlite tutorials. Retrieve the string value by using a select statement, append your multiple strings to it, then update your table with the new value using an update statement. You need to show that your tried something
Answer: <code>db.execSQL("UPDATE MyTable SET MyColumn = MyColumn || ?",
           new Object[] { myString });
</code>
Answer: You can use JSON o XML in the column. Create a document JSON, add string, save the row. After, get a row, get JSON of column, add new string in JSON and save it again.


Find surface edge from signed distance function & derivative

Question: I have a signed distance function that describes a mesh in 3D space. I have a few points given in space that mark the exact location of a sign change. Additionally, to each of those points I have the normal vector of the function at that point.
Now my question is: it possible with the given data (& if so how) to calculate the underlying surface edge ?
What I am basically looking for is nothing but a directional vector. The problem is really easy to solve in 2D. Since I have the normal, all I gotta do is to calculate a vector that is perpendicular to that normal.
But there's an infinite amount of perpendicular vectors to a vector in 3D, so that doesn't seem to work here...
Here is a visualtion of what I might have. In 2D just to keep it simple. Again, I am looking for a solution in 3D space.
Example image:
Answer: No, you do need an additional vector. It can be global, one single vector that is used for all points.
Let's say you have point $\vec{p}_i$ on the surface, $\vec{n}_i$ is the normal vector at that point, and $\vec{a}$ is your global direction vector.
For each point $\vec{p}_i$ on the surface, you want to find the two tangent vectors $\vec{u}_i$ and $\vec{v}_i$. We can do this by picking $\vec{u}_i$ as perpendicular to normal $\vec{n}_i$ and $\vec{a}$, and $\vec{v}_i$ as perpendicular to normal $\vec{n}_i$ and $\vec{u}_i$:
$$\begin{aligned}
\vec{u}_i &= \vec{n}_i \times \vec{a} \\
\vec{v}_i &= \vec{n}_i \times \vec{u}_i \\
\end{aligned}$$
Unfortunately, this breaks down in the case where the normal $\vec{n}_i$ is parallel to $\vec{a}$ ($\vec{n}_i \parallel \vec{a}$): then, $\vec{u}_i = \vec{u}_i = 0$. This is trivial to solve, however, since you can simply choose $\vec{u}_i$ and $\vec{v}_i$ to be any vector pair perpendicular to each other and $\vec{a}$.)
If we consider a sphere, and pick $\vec{a}$ from pole to pole, then $\vec{u}_i$ are along latitudes, and $\vec{v}_i$ longitudes.

Note that if the surface is a polygon mesh (say, a triangle mesh), this will not find the edges of the surface. To do that, you find the discontinuities in the normal vector: at an edge or vertex, the normal vector changes discontinuously.
Comment: I don't understand how to choose the a vector. Does that vector need to have any relation to the surface ? How do I choose this vector ?
Also, what do I do with those 2 resulting tangent vectors ? I am only looking one 1 vector.
Comment: @PAThePianoDude: In 3D, a tangent to a surface is a plane. You can describe it with a normal vector, or two tangent vectors. All three are orthogonal (perpendicular to each other). If you ignore lengths, any two suffice, because the third is their cross product. What you are asking for makes no sense, unless there is an underlying problem you want to solve, but have not described yet. Care to edit your question, to describe what you intend to achieve with this? What problem does it solve?


C program not reaching For loop

Question: I'm currently trying to write a C program using the NetBeans IDE.The goal is to take input from the user on the amount of sticks they want drawn on the screen where the Letter "I' is a stick as noted in the for loops. The thing is, I use scanf to get the user input for each row , but the program executes and runs but never actually seems to reach the for loop, since it doesn't do any of the print statements within it. My IDE doesn't print any of my print statements in the for-loops, which is why I'm assuming it isn't reaching them.
I have tried simply assuming values for user input, instead of using scanf, but that also does not seem to reach the for loop. Any input on what I could do to fix this, would be much appreciated!
#include <stdio.h>
int main(void) {
    int length1, length2, length3;
    int inputRow1, inputRow2, inputRow3;
    printf("Please enter the number of Sticks you would like per row\n");
    scanf("%d%d%d", inputRow1, inputRow2, inputRow3);
    for (length1 = 0; length1 < inputRow1; length1++) {
        printf("I");
        for (length2 = 0; length2 < inputRow2; length2++) {
            printf("I");
            for (length3 = 0; length3 < inputRow3; length3++) {
                printf("I");
                return (0);
            }
        }
    }
}

Answer: While using scanf you should store the values in the variables using &.
Change
scanf("%d%d%d",inputRow1,inputRow2,inputRow3);

to
scanf("%d%d%d",&inputRow1,&inputRow2,&inputRow3);

And your return statement should be before exiting from the main().

For example:
#include <stdio.h>

int main()
{
    int length1,length2,length3;
    int inputRow1,inputRow2,inputRow3;
    printf("Please enter the number of Sticks you would like per row\n");
    scanf("%d%d%d",&inputRow1,&inputRow2,&inputRow3);
    for(length1=0;length1<inputRow1; length1++)
    {
        printf("I");
        for(length2=0;length2<inputRow2;length2++)
        {
            printf("I");
            for(length3=0;length3<inputRow3;length3++)
            {
                printf("I");
            }
            printf("\n");
        }
        printf("\n");
    }
    printf("\n");
    return(0);
}

Comment: Cheers Mate! Almost face-palmed in forgetting the '&'.

C program not reaching For loop


JavaScript custom module is not working, some help please

Question: I'm making a JavaScript Module that imports a popup box and the import doesn't seem to work. I need some help making my javascript program work
https://github.com/Daniel4-Scratch/JuiceBox
<!DOCTYPE html>

<link rel="stylesheet" href="module/pack.css">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<button id="jb-btn">Open Box</button>

Comment: Where have you placed the pack.js file?  The code needs it to be in a sub-folder called "module" - is that where you have it?
Comment: Yes I have it in a folder in another repo on glitch.com
Comment: Look in the console, there's an error message there. :-)
Comment: :/ JavaScript console disabled Shared computer.
Comment: Look in the console of your _browser_ (Developer Tools (F12) -> Console)
Comment: I swear it's disabled.
Answer: There are two problems:

You can't use import in a script, only in a module. To indicate your inline code is a module, you need to add type="module" to the script tag:


How can I prove that $\forall x \in D (P(x)\implies Q(X))$ is not equivalent to $(\forall x \in D, P(x))\implies (\forall x \in D, Q(X))$?

Question: How can I prove that $\forall x \in D (P(x)\implies Q(X))$ is not equivalent to $(\forall x \in D, P(x))\implies (\forall x \in D, Q(X))$?
Would I prove the negation of this?
$\big(\forall x \in D ,(P(x)\implies Q(x))\big) \iff \big((\forall x \in D, P(x))\implies (\forall x \in D, Q(x))\big)$
If so, how would I do that?
Comment: Then, to show they are not equivalent it is enough to find a set $D$ and two predicates $P(x)$ and $Q(x)$ in $D$ such that one of the propositions is true and the other is false.
Comment: Why the variable for Q is in upper case? Are X and x different variables?
Comment: @Wore Oops. They are meant to be the same. I have updated the post.
Comment: Proving the negation would mean that those two formulas will never be both true or both false. What you want to prove is that sometimes (i.e. in some structures), one is false while the other is true. $\forall x, x = f(x)$ is not equivalent to $\top$ the true formula (because interpreting $f$ with something other that the identity will make $\forall x, x = f(x)$ false) but you can't prove the negation of $(\forall x, x = f(x))\iff \top$ because it is true when $f$ is interpreted as the identity.
Comment: Then, to show they are not equivalent it is enough to find a set $D$ and two predicates $P(x)$ and $Q(x)$ in $D$ such that one of the propositions is true and the other is false. It might be good to notice that the proposition $[\forall x(P(x)) \Rightarrow \forall x(Q(x)) ]$ can be true in $D$, even if $\forall x(P(x))$ is false in $D$
Comment: @Wore That's what I was thinking at first, but I couldn't seem to find a set of variables that could work. Could you give me an example of a domain and predicates that would show them not to be equal?
Comment: I can give you the set: the natural numbers. What do you think $P(x)$ and $Q(x)$ can be for this to work? Remember, you want that for a specific $x$, being in $P$ implies $Q$, but you also want $\forall x(P(x))$ to be false.
Comment: @Wore are you sure that they are actually not equivalent? I think they might be equivalent
Comment: I am sure, but the only possible counter examples are those cases that I described before: a proposition of the form ($A\Rightarrow B$ being true because $A$ is false. This kind of reasoning is highly not intuitive, and if you don't know it then is difficult to convince yourself. Recall the truth table for the proposition $A\Rightarrow B$, which is false only when A is true and B is false.
Answer: It is true that, if all people are left-handed, then all people are Chinese (because the hypothesis, "all people are left-handed," is false and therefore implies every statement). But it is not true that all left-handed people are Chinese.
Comment: So the domain D is: "all people", P(x) is "x is left handed" and Q(x) is "x is chinese"?
Comment: @JohnSmith12345 Right.
Comment: I don't see how it makes sense then. LHS: "For all people, if a person is left handed, they are chinese" RHS: "If all people are left handed, then all people are chinese". How are those two not equivalent?
Comment: @JohnSmith12345 The LHS is false, and the RHS is true, so they are not equivalent.
Answer: Left to right is true; assume that P always implies Q. Then if P is universally true, then Q must also be, trivially. Right?
But right to left is false. Say D has two elements, A and B, and P is true only of A, while Q is true nowhere.
It is false that "P is universally true" so the implication "if P is always true, then Q is always true" holds. However, the left hand side is false: it requires "everything which satisfies P must also satisfy Q," so which is false (for A).
In general finite domains (usually very small!) are enough to find counterexamples for this sort of thing. In fact, properly stated, there is a theorem to this effect (since you're only talking about unary relationships) but I don't know any constructive bounds off the top of my head.
But to approach these problems, if you think two statements are inequivalent, just try different small finite domains until you find a counterexample (or accidentally convince yourself such an example is impossible).
Hope this helps!
(sorry for lack of TeX, I'm on mobile at the moment)


git not detecting directory moved into another directory

Question: Given a file foo/example.txt, git doesn't seem to detect the new file when it's moved into a newly created parent directory, i.e. foo/bar/example.txt, by moving the directory.
mkdir foo/bar
mv foo foo/bar

In particular, git status shows that foo/example.txt is deleted, but not that foo/bar/example.txt is create. git status --ignored will show foo/bar as an ignored dir, even though it's not in .gitignore. In fact, even renaming the directory doesn't change its ignored status.
This doesn't happen when using git mv. I don't understand why.
This is git version 2.13.0 on Darwin C02RW05YFVH6 15.6.0.
Answer: It will detect it when you git rm the old directory and git add the new one.
Comment: Why? And is there a setting to make Git always detect such changes without extra steps?
Comment: The thing is that you "moved" the directory behind git's back. If right after moving the directory (without using git) you had checked status git would have told you something like "this directory is missing... and there's this other directory I don't know anything about is also there". That should be enough to make you realize that git noticed there's something fishy. If at this point you had "added" the directory git would think the files are "new" because you wouldn't have notified git about the removal. If after adding you had deleted the old directory then git would say "aha!".... 2bcont
Comment: ... and it would then tell you that the files have been moved..... _or_ instead of using "mv; git add; git rm", you could have let git do the movement for you and you would get the same result in a single shot: ```git mv originaldir bar/newdir```
Comment: > and there's this other directory I don't know anything about is also there That's the thing, Git *ignores* the new dir. Is that expected behavior?
Comment: yep. It will show up as a directory with "untracked" files inside (git will report that on status).


What is the correct definition of a Power Function?

Question: In Casella Berger's Statistical Inference, they define a power function of a hypothesis test with rejection region $R$ to be the function of $\theta$ define by $\beta(\theta) = P_\theta(X\in R)$ for some data $X$. Suppose that $H_0: \theta\in \Theta_0$ and $H_1: \theta \in \Theta_0^c$.
Furthermore, they state that:
$$
P_\theta(X\in R) = \begin{cases} \text{probability of a Type 1 error} &\mbox{if } \theta\in \Theta_0\\
\text{one minus the probability of a Type 2 error} & \mbox{if } \theta\in \Theta_0^c\end{cases}
$$
However, my understand is always that the power function is the probability of rejecting the null, given that the null is false. This doesn't match the above. What is wrong here? Thanks!
Answer: Power is the probability that the observation is in the rejection region when some value in the parameter space of the alternative is correct (falsely rejecting the null hypothesis).  But when the two distributions are identical, the rejection region for the null hypothesis also corresponds to the non-rejection region for the alternative, so $\alpha =1-\beta$. Think of the case of two univariate normal distributions with variance 1 and mean 0 under the null hypothesis and a one-sided alternative mean >0. Then as the alternative mean gets closer to zero, the power drops all the way down to $\alpha$. A drawing showing the critical region with the standard normal and the normal shift to the right of a mean $\mu>0$ should make this clear.
Comment: *"Power is the probability [of] [...] (falsely rejecting the null hypothesis)"* - sorry if I'm misinterpreting, but isn't power correctly rejecting the null hypothesis?
Answer: Consider if you have a simple null, like $\mu=\mu_0$ against a two-sided alternative. Then your power function has a "hole" at $\mu_0$.
The usual definition of power function fills in the hole, making the power function defined for all possible values of $\theta$.
Sure, at that point it's not power, but calling it a "rejection rate function" just because you defined the function at one point where it isn't measuring power is a little clumsy.


Android - how to lay out a list view item similar to iOS table view cell with image, title and subtitle?

Question: I'm trying to lay out an Android list view cell similar to the common iOS design - an image on the left, and two labels next to the image:

How can I achieve an Android cell layout like the basic iOS cell with image, title and subtitle?
However, I'm not sure what is the proper layout to use to accomplish this task. Here's what I'm trying, and it does not align elements properly:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1">

    <TextView
        android:id="@+id/api"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.47">

        <ImageView
            android:layout_width="@dimen/side_button_size"
            android:layout_height="@dimen/side_button_size"
            android:id="@+id/image"
            android:layout_gravity="left|top"
            android:background="@drawable/close_red" />

        <TextView
            android:id="@+id/title"
            android:layout_width="246dp"
            android:layout_height="82dp"
            android:layout_gravity="center_horizontal|top"
            android:text="This is title label" />

        <TextView
            android:id="@+id/subtitle"
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:layout_gravity="left|center_vertical"
            android:text="This is subtitle label" />
    </FrameLayout>

</LinearLayout>

Comment: Use this tutorial from Vogella: [Custom ListView](http://www.vogella.com/tutorials/AndroidListView/article.html)
Answer: Use an horizontal LinearLayout that contains an ImageView and another (vertical this time) LinearLayout that contains the 2 TextViews.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:layout_width="96dp"
        android:layout_height="96dp" />

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <Space
            android:layout_width="match_parent"
            android:layout_height="4dp" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

</LinearLayout>

Simply put:
+-----------+-----------+
|           | TextView1 |
| ImageView |           |
|           | TextView2 |
+-----------+-----------+

Answer: When using a RelativeLayout, you can specify each child's relative position. Here's an example:
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:layout_width="@dimen/side_button_size"
        android:layout_height="@dimen/side_button_size"
        android:id="@+id/image"
        android:background="@drawable/close_red" />

    <TextView
        android:id="@+id/title"
        android:layout_width="246dp"
        android:layout_height="82dp"
        android:layout_toLeftOf="@id/image"
        android:layout_toStartOf="@id/image"
        android:text="This is title label" />

    <TextView
        android:id="@+id/subtitle"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_below="@id/title"
        android:text="This is subtitle label" />
</RelativeLayout>


Calculating probability from Markov Chain

Question: I have a Markov Chain with states {1,2,3,4,5} which has the following transition matrix below:
$$P= \begin{bmatrix} 0.3 & 0 & 0.7 & 0 & 0\\ 0 & 1 & 0 & 0 & 0\\ 0.5 & 0 & 0.5 & 0 & 0\\ 0.2 & 0 & 0 & 0.5 & 0.3\\ 0 &1 & 0 & 0 & 0\\\end{bmatrix}$$
From here, I need to calculate:
1) $P(X_6=1 | X_4=4,X_5=1, X_0=4)$
What I have tried so far is that I believe that this is same as $P(X_6=1 | X_4=4,X_5=1)$ which is $$0.2 * 0.3 = 0.06$$
Is this correct? or please help me if I am wrong here.
2) $P(X_2=3, X_1=3 | X_0=1)$
What I have tried is rearranging the formula to: $P(X_1=3, X_2=3 | X_0=1)$ and then I get $$0.7 * 0.5 = 0.35$$
I think my answer to question 2 is correct but not really sure for question 1.
I would appreciate any help here please:)
Answer: The Markov property says the distribution given past time only depends on the most recent time in the past.
1) $P(X_6=1 | X_4=4,X_5=1, X_0=4) = P(X_6 =1 | X_5 =1)$ which is the 1->1 transition entry (in position (1,1) which is $0.3$. The Markov property told us that the conditional property only depended on $X_5=1$.
2) $P(X_2 = 3, X_1 = 3 | X_0 = 1) = P(X_2 = 3 | X_1 = 3 , X_0 = 1) P(X_1 = 3 | X_0 = 1) = P(X_2 = 3 | X_1 = 3) P(X_1 = 3 | X_0 = 1)$ so this is the probability of transitioning from 3->3 times the probability of transitioning from 1->3. I don't know if your probabilities evolve from the left or right (i.e. if you left or right multiply by transition matrix for a probability vector, but once you know that you can look at either the (3,3) and (1,3) locations of the matrix or (3,3) and (3,1) entries of the matrix). We just used definition of conditional property and the Markov property here.


Spotting that $\,x^8 + x^7 + 1\,$ is reducible.

Question: I saw a puzzle recently that came down to spotting that $\,x^8 + x^7 + 1\,$ is reducible — namely, we have
$$x^8 + x^7 + 1 = \left(1 + x + x^2\right)\left(1-x+x^3-x^4+x^6\right)$$
After playing around a bit, I noticed that this is a special case of the fact that
$$\left.\Phi_m\left(x\right) \quad \big| \quad x^{mk} \big[\Phi_m\left(x\right) - 1\big] + 1\right.$$
for each $k$, which holds since
$$x^{mk} \big[\Phi_m\left(x\right) - 1\big] + 1 = x^{m k} \Phi_m\left(x\right) + \left(1 - x^{m k}\right)$$
and of course both terms on the RHS are divisible by $\,\Phi_m\left(x\right)$.  In the cases $\,m = 1, 2, 3\,$ this recovers the statements:

$x-1\;$ divides $\;x^{k+1} - 1$
$x+1\;$ divides $\;x^{2k+1} + 1$
$x^2 + x + 1\;$ divides $\;x^{3k+2} + x^{3k+1} + 1$

Of course the first two are very well-known.  Is it simply the case that many people also know the third statement off the tops of their heads?  Or is there some other way of spotting that $x^8 + x^7 + 1$ is reducible?
Comment: If you normally test the reducibility by putting in roots of unity, can't you do so?
Answer: The trick is that $8 \equiv 2 \pmod 3$ and $7 \equiv 1 \pmod 3.$ That means that, if we take a cube root of unity, say
$$  \omega = \frac{-1 + i \sqrt 3}{2}, $$
we get
$$ \omega^8 + \omega^7 + 1 = \omega^2 + \omega + 1 = 0. $$
The same holds for
$$ \bar{\omega } = \omega^2. $$
That means that
$$ (x - \omega)(x - \bar{\omega}) = x^2 + x + 1  $$
divides the original polynomial,
as the quadratic is the minimal polynomial for $\omega.$
As you noticed, the same thing can be done with other roots of unity. If we had
$$ x^{1347} + x^{949} + x^{216} + x^{98} + 1, $$
the exponents are $2,4,1,3 \pmod 5,$ and the displayed polynomial is divisible by
$$ x^4 + x^3 + x^2 + x + 1 $$
Answer: Consider the ring of polynomials modulo $\sum_{i < m} x^i$. As $\sum_{i < m} x^i$ divides $x^m - 1$, we have in this ring that $x^m = 1$, and thus, more generally, that $x^{p}$ depends only on the remainder of $p$ modulo $m$. In this way, we can reduce any polynomial modulo $\sum_{i < m} x^i$ to a polynomial of degree $\lt m$ (i.e., degree $\leq$ that of $\sum_{i < m} x^i$ itself). And, of course, the only polynomials of such degree which are divisible by $\sum_{i < m} x^i$ are its scalar multiples.
Thus, we find that a general polynomial $\sum_{i} a_i x^i$ is divisible by $\sum_{i < m} x^i$ if and only if $\sum_{i \in C} a_{i}$ is equal for each choice of residue class $C$ modulo $m$.
All the observations in the question for $m > 1$ are special cases of this (keeping in mind that $\Phi_m(x)$ divides $\sum_{i < m} x^i$ for $m > 1$). The remaining observation is that $x - 1$ divides $x^{k + 1} - 1$, which is trivial (by explicit calculation or by considering in the same way as above that $x = 1$ in the ring of polynomials modulo $x - 1$, and thus $\sum_{i} a_i x^i$ is divisible by $x - 1$ just in case $\sum_i a_i = 0$).
Comment: (I recognize that this answer is essentially equivalent to the earlier answer phrased in terms of complex roots of unity; though therefore redundant, I am nonetheless cross-posting here in continuation of the discussion which originated at https://www.quora.com/Given-that-468751-5-8-+-5-7-+-1-is-a-product-of-two-primes-what-are-the-two-primes/answer/Daniel-McLaury and was then directed here)


Change android app language when Phone language is changed from Settings

Question: i want to change my app string language, when language from settings is changed.
Like, right now it's english.
When I siwtch to hindi language from settings, the text in my android app should also be in hindi.
How to do that?
Answer:
Create values-xx where "xx"is any language code like "en", "fr", "sp", "ar" .... and so on
create an xml with name of string.xml in the same folder.
create string in that xml
<string name="welcome">write in the language which you put as the language code</string
Answer: You shoul this site:
http://developer.android.com/guide/topics/resources/localization.html
You must create values folders in res folder for localization.And you must create string.xml in your values folders.  For example:
values-tr for Turkish
values-fr for French
Answer: values-hi/strings.xml

<string name="welcome">स्वागतम</string>
<string name="email">ईमेल पता</string>
<string name="password">पासवर्ड</string>
<string name="login">लॉगिन</string>
<string name="signup">खाता नहीं है? साइन अप करें</string>

Answer: use
Locale.getDefault().getLanguage();

to get the device language for your device.(e.g en)
then make a switch to swap between ur "string" Values in ur app.(values/string.xml)
reference:
Get the current language in device
quote:
Locale.getDefault().getLanguage()       ---> en
Locale.getDefault().getISO3Language()   ---> eng
Locale.getDefault().getCountry()        ---> US
Locale.getDefault().getISO3Country()    ---> USA
Locale.getDefault().getDisplayCountry() ---> United States
Locale.getDefault().getDisplayName()    ---> English (United States)
Locale.getDefault().toString()          ---> en_US


When testing for a difference between effect sizes, is test power affected by their respective magnitude?

Question: When comparing two effect sizes with a statistical test, does it matter for the test's power whether these effect sizes themselves are large or small?
Imagine you are planning an experiment in which you compute an effect (difference between two conditions) for two groups (A,B). You want to show that the effect is larger in one group than the other, i.e. your hypothesis is effect(A) > effect(B). Assuming that the difference between the groups is equivalent to Cohen's D = 0.5, what is the required sample size to reach a power of 0.8?
In hypothetical experiment I the effect sizes in both groups are 1 and 1.5, the difference between them is 0.5.
In hypothetical expeirment II the effect sizes in both groups are 0.1 and 0.6. Again, the difference is 0.5.
Although the difference between the two groups is the same in both experiments, I would assume that experiment II requires a larger sample size. After all, the effects are located on a much smaller scale than in experiment 1. I have been told an a priori power analysis needs to take this into account (the magnitude of the effects that are being compared), but I do not really know how, and it's hard to find answers to this very specific problem on the web.
How can I take this into account in my a priori power analysis? I'm using G*Power and unfortunately, I can't simply answer this by simulating data (have to use a validated method).
Comment: Forgot to mention - for the sake of a priori power analysis, both groups would have the same variance and N; it's just their means that are different, and thus they show different effect sizes for a manipulation.
Answer: You seem to be mixing together these two things

the sample size needed to detect an effect of a certain size
the sample size needed to detect a difference of two effects being equal to a certain value

The difference between two effects is a different statistical animal than the effects themselves. So you need the same sample size in both cases to detect a difference of .5. But if your goals also include making inferences about the effects themselves, you need more data to detect smaller effects.
Comment: I will specifiy my case.

We know that our control group will show a certain effect (quite a strong one, _d_ = 0.88). We want to test whether another group shows the same effect, or a weaker one. We're interested in differences if they are relevant, which we defined as _d_ = 0.5 (for _the difference between two effects_).

You say:
'You need the same sample size in both cases to detect a difference of 0.5'.

Does that mean that it does not matter how large the effects in both groups are, as long as they are 0.5 apart?
Comment: I think you're making things a bit too complicated by looking at the effect within groups as effects, by measuring them in e.g. Cohen's d. Think of them simply as values, whatever the unit may be. The effect you're interested in (for which you care about the *d*) is the difference between these values.
Comment: "Does that mean that it does not matter how large the effects in both groups are, as long as they are 0.5 apart?" Yes, that's what I'm saying. I also agree with @jonas. I think an emphasis on standardized effect sizes obscures meaning, and people are better off talking about real differences of real measurements, in the units in which they are made.
Comment: Using real units isn't always that straightforward. In our case, the units from previous research are all kinds of biophysical measures as well as derived ones - so the only way to make these studies' results comparable was by looking at their test summary statistics (in t and F). And the reason that I went through the ordeal of collecting all that information was so I could construct hypothetical data for my power calculation. But if the effect strenghts in either group don't matter for testing the difference, that's fine by me. I'll verify ASAP and mark 'answered' or post on. Thanks already!
Comment: Verification was succesful, the _level_ on which effects are located does not matter, only their difference :)


How can I add a point to an sf object?

Question: I have an sf object that stores point data. But I am having trouble understanding how to add a point to this object.
I know how to create two points in separate objects:
# Create sfg objects with coordinates of Los Angeles and Amsterdam
la_sfg <- st_point(c(-118.2615805, 34.1168926))
amsterdam_sfg <- st_point(c(4.8979755, 52.3745403))

And I know how to combine these two objects into one geometry set:
# Create sfc object with multiple sfg objects
points_sfc <- st_sfc(la_sfg, amsterdam_sfg, crs = 4326)
points_sfc

And I know also how to add attributes to these points using a dataframe:
# Create a data frame of attributes for the two points
data <- data.frame(name = c("Los Angeles", "Amsterdam"),
                   language = c("English", "Dutch"),

                weather = c("sunny", "rainy/cold"))

# Make sf object from separate data frame and sfc objects
city_profiles <- st_sf(data, geometry = points_sfc)

Now let's say I have another point coordinate with the following information:
name = Toronto
language = English
Coordinates =   c(-79.450717,43.691589)
weather = hot

I'm having trouble figuring out how to create an sfg object and then add it to my pre-existing feature collection. For example, intuitively I feel like I'd do something like this:
# Create sfg object
toronto <- st_point(name = "toronto", language = "English",weather = "cold", geometry=c(-79.450717,43.691589))

and then use rbind to add this feature to city_profiles. However this is not the correct syntax and only returns errors.
Comment: you need to follow your process again of starting from an `sfg` (`st_point()`), then to `sfc`, then to `data`, and **then** `rbind` the new row of data
Comment: so you'll have something like `toronto <- sf::st_sf(data.frame(name = "toronto", language = "English",weather = "cold", geometry = st_sfc(st_point(c(-79.450717,43.691589)))))`
Answer: As SymbolixAU said you have to go all sf steps from all points and then rbind the results. Or bind it first and then go all the sf steps with all points in the same data.frame. For example:
library(tidyverse)
library(sf)
library(rnaturalearth)

world <- rnaturalearth::ne_countries(scale = "small",
                                     returnclass = "sf")

la_ams <- data.frame(name = c("Los Angeles", "Amsterdam"),
                     language = c("English", "Dutch"),
                     weather = c("sunny", "rainy/cold"),
                     lon = c(-118.2615805, 4.8979755),
                     lat = c(34.1168926, 52.3745403))

la_ams <- sf::st_as_sf(la_ams,
                       coords = c("lon", "lat"),
                       crs = 4269)

ggplot() +
  geom_sf(data = world,
          mapping = aes(geometry = geometry),
          fill = "white") +
  geom_sf(data = la_ams,
          aes(geometry = geometry),
          size = 3,
          color = "red") +
  theme_bw()

Add another point:
toronto <- data.frame(name = c("toronto"),
                     language = c("English"),
                     weather = c("cold"),
                     lon = c(-79.450717),
                     lat = c(43.691589))

toronto <- sf::st_as_sf(toronto,
                       coords = c("lon", "lat"),
                       crs = 4269)

cities <- rbind(la_ams, toronto)

ggplot() +
  geom_sf(data = world,
          mapping = aes(geometry = geometry),
          fill = "white") +
  geom_sf(data = cities,
          aes(geometry = geometry),
          size = 3,
          color = "red") +
  theme_bw()

How can I add a point to an sf object?


Why is my code combining instead of adding numbers?

Question: I'm not sure why this is happening but when I run this it takes the numbers and combines them rather than adding them.
For example, if I type 1, 2, and 3 for each of the inputs, it will output $123 instead of $6.
This program calculates how much a garden center needs to spend for a flower garden display.
#include <iostream>
using namespace std;

int main()
{
    // Get the cost of soil.
    std::string Soil;
    std::cout << "What does the soil cost? " <<std::endl;
    std::cin >> Soil;

    // Get the cost of flower seeds.
    std::string Flower;
    std::cout << "What do the flower seeds cost? " <<std::endl;
    std::cin >> Flower;

    // Get the cost of the fence.
    std::string Fence;
    std::cout << "What does the fence cost? " <<std::endl;
    std::cin >> Fence;

    // Calculate the total cost.
    std::string total;
    std::cout total = Soil + Flower + Fence;

    // Display the total cost
    std::cout << "The total cost is $" << total;
    std::cout << "." << std::endl;

    return 0;
}

Comment: That is because `Soil`, `Flower` and  `Fence` are all strings. Surprisingly there is `operator +` for strings as well as for numbers. It will return a new string by concatenating operands. Also `std::cout total ` does not seem to be valid at all because `std::cout` and `total` are both variable names.
Comment: How do you add "hi", "I'm", "thebluefish" together? They aren't numbers, they're **strings**. What you're trying to combine are text strings, and so concatenation is a natural result. You might instead look for a way to convert them to numbers.
Answer: Use int instead of string.
#include <iostream>
using namespace std;

int main()
{
int soil, flower, fence, total;

// Get the cost of soil.
std::cout << "What does the soil cost? " <<std::endl;
std::cin >> soil;

// Get the cost of flower seeds.
std::cout << "What do the flower seeds cost? " <<std::endl;
std::cin >> flower;

// Get the cost of the fence.
std::cout << "What does the fence cost? " <<std::endl;
std::cin >> fence;

// Calculate the total cost.
total = Soil + Flower + Fence;

// Display the total cost
std::cout << "The total cost is $" << total;
std::cout << "." << std::endl;

return 0;

Answer: You use data type string, and operator + for strings does string concatenation. For arithmetic calculations, use a numeric data type, e.g. double:
int main()
{
    // Get the cost of soil.
    double Soil;
    std::cout << "What does the soil cost? " <<std::endl;
    std::cin >> Soil;

    // Get the cost of flower seeds.
    double Flower;
    std::cout << "What do the flower seeds cost? " <<std::endl;
    std::cin >> Flower;

    // Get the cost of the fence.
    double Fence;
    std::cout << "What does the fence cost? " <<std::endl;
    std::cin >> Fence;

    // Calculate the total cost.
    double total =Soil + Flower + Fence;

    // Display the total cost
    std::cout << "The total cost is $" << total;
    std::cout << "." << std::endl;

    return 0;
}

Answer: Your three variables are typed string, and + is the concatenation operator for strings.
Replace std::string Soil; with int Soil; and the same with Flower and Fence and go from there.
Answer: Well, look at types you're using:
std::string Soil;
[...]
std::string Flower;
[...]
std::string Fence;

You're using text types instead of numbers, and standard sum operator + is by default overloaded to concatenate strings. Just change them to int or try converting.
Answer:
Why is my code combining instead of of adding numbers?

Strings concatenate.

Another c++ approach to consider.
using std::stoi() to convert strings to int and provided in header < string >
int main(int, char**)
{
   // Get the cost of soil.
   std::string Soil;
   std::cout << "What does the soil cost? " <<std::endl;
   std::cin >> Soil;

   // Get the cost of flower seeds.
   std::string Flower;
   std::cout << "What do the flower seeds cost? " <<std::endl;
   std::cin >> Flower;

   // Get the cost of the fence.
   std::string Fence;
   std::cout << "What does the fence cost? " <<std::endl;
   std::cin >> Fence;

   // Calculate the total cost.
   int  total = (std::stoi(Soil) +
                 std::stoi(Flower) +
                 std::stoi(Fence));

   // Display the total cost
   std::cout << "The total cost is $"
             << total
             << "." << std::endl;

   return(0);
}

Comment: You need to evaluate how stoi handles the mistake when you typo an invalid decimal input,  For formatted input, you need to evaluate how the stream handles invalid decimal input.  IMHO - I think the stream formatted input is somewhat easier to recover, if that is what you want.  This means that your solution is not yet complete.
Answer: C++ is type safe, meaning that when you declared Soil, Flower and Fence as type string, the standard input had to save them as strings. Therefore, the "+" is interpreted as concatenation, not addition.
I would either declare them as integer or unsigned integer and the same with total.
Or you could cast the values as integers or unsigned integers. I am too many years away from C and C++ to get syntax.
I think it might be:
std::string total = NumberToString((int)Soil + (int)Flower + (int)Fence);

Comment: `(int)Soil` tells the compiler to treat the `string` variable as an `int`.  There is no trivial conversion between `string` and `int` because most `string`s can't convert to `int`. Frankly I don't know what you will get from this, but it won't be pretty. Look into `std::stoi` for a function that will convert a `string` into an `int`.


Class 'Drupal\user\Entity\User' not found when running drush

Question: I am trying to run a drush on functional Drupal 7 site, however, the attempt of run drush ends with an error saying: Class 'Drupal\user\Entity\User' not found in /usr/local/share/drush/lib/Drush/Boot/DrupalBoot.php, line 571.
Any idea what may be happening?
Full output:
vagrant@1843vm:/var/www/drupalvm/drupal/web$ drush
PHP Fatal error:  Class 'Drupal\user\Entity\User' not found in /usr/local/share/drush/lib/Drush/Boot/DrupalBoot.php on line 571
[error]  Drush command terminated abnormally due to an unrecoverable error.
Error: Class 'Drupal\user\Entity\User' not found in /usr/local/share/drush/lib/Drush/Boot/DrupalBoot.php, line 571
[error]  Drush was not able to start (bootstrap) Drupal.
Hint: This error can only occur once the database connection has already been successfully initiated, therefore this error generally points to a site configuration issue, and not a problem connecting to the database.

Drush was attempting to connect to:
 drupal-version         :  7.50
 drupal-settings-file   :  sites/default/settings.php
 uri                    :  http://default
 db-driver              :  mysql
 db-hostname            :  localhost
 db-username            :  root
 db-password            :  123
 db-name                :  il
 db-port                :
 install-profile        :  standard
 db-status              :  Connected
 theme                  :  intelligent_life
 admin-theme            :  seven
 php-bin                :  /usr/bin/php
 php-os                 :  Linux
 php-conf               :  /etc/php/5.6/cli/php.ini
 drush-script           :  /usr/local/share/drush/drush.php
 drush-version          :  9.0-dev-g1c91f8b
 drush-temp             :  /tmp
 drush-conf             :
 drush-alias-files      :  /home/vagrant/.drush/drupalvm.aliases.drushrc.php
 root                   :  /var/www/drupalvm/drupal/web
 site                   :  sites/default
 modules                :  sites/all/modules
 themes                 :  sites/all/themes
 files                  :  sites/default/files
 temp                   :  /tmp
 %paths                 :  /var/www/drupalvm/drupal/web
                       sites/default
                       sites/all/modules
                       sites/all/themes
                       sites/default/files
                       /tmp`

Answer: I had the same problem, it's related to the Drush version used by the DrupalVM.
You can change the Drush version in the config.yml file.
More info: https://github.com/geerlingguy/drupal-vm/issues/1020
Comment: Where is this `config.yml` supposed to be and what should it look like to fix this?
Comment: I don't see a config.yml file either


Can't see the button at the buttom of my div when using tailwind

Question: I am creating a dashboard with a header and under it, a fixed sidebar and main section that is scrollable on the vertical. Using tailwind, i set full page to have a height of screen, then the header to have a height of 10% and the sidebar/main section to have a height of 90%. the problem is that at the bottom of my sidebar, i have a logout button, but i cant seem to see the button except i remove the header altogether and make the sidebar main-section be 100% of the height.
This is what i mean:

As opposed to this, after i remove the header:

As you can see from the images, the logout button is meant to be showing even when the header is present but it isnt. I didnt set a specific height to the sidebar, just set it to 90% of the screen, meaning it should be able to scale. I also didnt add any padding or anything so im not sure what is happening.
DashboardLayout :

        <DoctorDashboardHeader openSideBar={openSideBar} setOpenSideBar={setOpenSideBar} />

          <SideBar/>

          <Outlet/>

Sidebar:

                <NavLink to={'/dashboard'}  end>
                    {({ isActive}) => (

                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className={isActive? "w-5 h-5 text-blue-900 z-10": 'w-5 h-5'}><path strokeLinecap="round" strokeLinejoin="round" d="M3.75 6A2.25 2.25 0 016 3.75h2.25A2.25 2.25 0 0110.5 6v2.25a2.25 2.25 0 01-2.25 2.25H6a2.25 2.25 0 01-2.25-2.25V6zM3.75 15.75A2.25 2.25 0 016 13.5h2.25a2.25 2.25 0 012.25 2.25V18a2.25 2.25 0 01-2.25 2.25H6A2.25 2.25 0 013.75 18v-2.25zM13.5 6a2.25 2.25 0 012.25-2.25H18A2.25 2.25 0 0120.25 6v2.25A2.25 2.25 0 0118 10.5h-2.25a2.25 2.25 0 01-2.25-2.25V6zM13.5 15.75a2.25 2.25 0 012.25-2.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-2.25A2.25 2.25 0 0113.5 18v-2.25z" /></svg>

                            Dashboard

                    )}
                </NavLink>
                <NavLink to={'/dashboard/products'} className=' w-full h-[30px] flex items-center space-x-4 '>
                    {({ isActive}) => (

                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className={isActive? "w-5 h-5 text-blue-900": 'w-5 h-5'}><path strokeLinecap="round" strokeLinejoin="round" d="M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 002.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 00-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.3126.96.36.199h4.5a.75.75 0 00.75-.75 2.25 2.25 0 00-.1-.664m-5.8 0A2.251 2.251 0 0113.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25zM6.75 12h.008v.008H6.75V12zm0 3h.008v.008H6.75V15zm0 3h.008v.008H6.75V18z" /></svg>

                            Products

                    )}
                </NavLink>
                <NavLink to={'/dashboard/addproducts'} className=' w-full h-[30px] flex items-center space-x-4 '>
                    {({ isActive}) => (

                                <svg fill="none"  viewBox="0 0 22 28"  xmlns="http://www.w3.org/2000/svg" className={isActive? "w-5 h-4 text-blue-900": 'w-5 h-4'}><path d="M5 6H15" stroke="currentColor" strokeLinecap="round" strokeWidth="2"/><path d="M5 11H15" stroke="currentColor" strokeLinecap="round" strokeWidth="2"/><path d="M5 16H12" stroke="currentColor" strokeLinecap="round" strokeWidth="2"/><path d="M17 26V18" stroke="currentColor" strokeLinecap="round" strokeWidth="2"/><path d="M21 22H13" stroke="currentColor" strokeLinecap="round" strokeWidth="2"/><path d="M12 27H5C2.79086 27 1 25.2091 1 23V5C1 2.79086 2.79086 1 5 1H15C17.2091 1 19 2.79086 19 5V14.5" stroke="currentColor" strokeLinecap="round" strokeWidth="2"/></svg>

                            Add Products

                    )}
                </NavLink>
                <NavLink to={'/dashboard/profile'} className=' w-full h-[30px] flex items-center space-x-4  '>
                    {({ isActive}) => (

                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className={isActive? "w-5 h-5 text-blue-900": 'w-5 h-5'}><path strokeLinecap="round" strokeLinejoin="round" d="M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z" /></svg>

                            Profile

                    )}
                </NavLink>

                <button className='w-full pl-9 flex space-x-4 ' onClick={handleLogout} >
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className="w-6 h-5"><path strokeLinecap="round" strokeLinejoin="round" d="M15.75 9V5.25A2.25 2.25 0 0013.5 3h-6a2.25 2.25 0 00-2.25 2.25v13.5A2.25 2.25 0 007.5 21h6a2.25 2.25 0 002.25-2.25V15m3 0l3-3m0 0l-3-3m3 3H9" /></svg>
                    Log Out
                </button>

if i add "overflow-scroll" to the sidebar, it shows that there is nothing to scroll, so i am so confused right now. Is this just a laptop issue?
Comment: Could you create a code snippet for us to run?
Answer: When comes to CSS there are many ways to achieve the same result. This is how I would do.
You don't need the fixed position for the sidebar, so you can remove it and also the margin for the main content.

    <SideBar/>

    <Outlet/>

But now you will face the overflow problem in the main content when with lengthy content. So add overflow-x-auto to the main content class

    <Outlet/>

Sample result:
https://play.tailwindcss.com/sYrkm7gPIY


Multiple input fields with the same name C# .NET Core

Question: I'm using VS for Mac, .NET Core 2.0, MVC.
I'm trying to make a form that accepts multiple input parameters for text under the same name.
My view contains the following:

     <input asp-for="Email" class="form-control" type="email"/>
     <input asp-for="Email" class="form-control" type="email"/>
     <input asp-for="Email" class="form-control" type="email"/>
     <input asp-for="Email" class="form-control" type="email"/>

This gives me errors, I've read something about naming the inputs Email[] but I cannot make it work.
How do I put my view in order, and how do I receive the email addresses later in the controller?
Thanks in advance!
Comment: I do not understand. How did you resolved this?
Answer: Email[] is a class (assuming from your notation - if you were talking about the action declaration), the input is most likely just a string.
So change the action parameter to string[] Email.
ASP.NET Core model binder will treat multiple equally named parameters as array, so either Email or Email[] should work in your View.
HTML has no notion of "arrays", from  HTML point of view Email[] is just a normal name as Email. It only depends on the backend technology how this naming conventions will be interpreted.
i.e. PHP will treat multiple Email values (i.e. Email=abc@xyz&Email=def@ghx) as one single value (using the first or last parameter), whereas ASP.NET & ASP.NET Core interpret it as array.
Comment: Hi Tseng, thanks for your reply.

It's good to know that HTML makes no distinction between types; Email[] is the same as Email.

It's also good to know that the ASP.NET Core model binder will treat multiple equally named parameters as array. That helps me ahead.

In my code, Email is a string property of my model, but I have to change this to an array of strings, correct?

Still, if I now try get access to the array in the controller via model binding I find that Email = null..
Comment: Is there a code example?