Why don't "classical" stringed instruments mark their note positions?

Question: So, I understand why classical strings (violins, cellos etc.) aren't fretted, because of the change this makes in the tone. I've often wondered though, why the note positions aren't marked on the neck anywhere.
Wouldn't notes relative to the open string be in the same place all the time?
Wouldn't it be possible to start at a marked position and then adjust the pitch to match other instruments?
Wouldn't even a chalked-on mark would make it easier to find notes?
Any clue why it's done the way it is?

Note the question is not "why don't violins have frets?"
Comment: Holding and playing a violin is a rather unergonomic stance as it is. Holding and playing a violin *while straining your neck to see the position marks* would be **horrifyingly** unergonomic.
Comment: I drew chalk lines on a string bass when I was first learning. By the time they wore off I no longer needed them. :)
Comment: You should try to play a note on a violin, you will realize that the precision of the finger placement needed for intonation makes visual aids useless - learning the hand position is unavoidable.
Comment: @guidot fretless bass guitars are sometimes (not always) lined.   Search for 'lined fretless'.
Comment: @guidot even fretless basses without lines generally have inlays on the side of the neck that indicate the 3rd, 5th, 7th, 9th, 12th, 15th, 17th, 19th, 21st and 24th position. These are quite necessary to play most stuff, because you're usually far from both the nut and the neck joint (the main features that classical string players use for orientation). Incidentally, some double basses have such markers too, and they're not just a beginner's aid – even some virtuosic players like Paul Kowert have them. (I reckon they're rather shunned in classical music though...)
Comment: The question asks about a _visible_ mark, but how about some [Braille Bumps](http://www.braillebookstore.com/Bump-Dots.1) instead?
Comment: This is often what new players do to learn the positions, but they don't keep them on.
Comment: I was never any good at playing the violin. My first violin teacher put strips of paper underneath sticky tape on the fingerboard to show me where to place my fingers. My last violin teacher was appalled and removed them in my first lesson. I quickly adjusted and was playing just as badly as before in no time!
Comment: Your edit leaves me puzzled: What  optical markers other than frets exist on non-classical instruments?
Comment: When I was very new to violin and just learning to play in tune, a very good player suggested that I look anywhere except the fretboard to improve my intonation. Watch the bow, close my eyes, or just look somewhere other than the instrument. That helped my intonation more than any other single piece of advice.
Answer: With many string instruments, it's seen as a bad thing to need to look at the fingerboard - often, it's desirable to be able to play the instrument by feel. This is essential if you're reading music at the same time, which in most classical contexts, you would be! Even in the pop/rock world it's often seen as better to be able to play by feel - many fretless bass guitars don't have fret markers either.
With violin and viola, the player's view of the fingerboard is very foreshortened, so it might be hard to pick out an exact position even if it were marked.
It's also hard using traditional construction methods to construct a fretless fingerboard with markers in a way that the markers don't interfere with the tone, and don't wear out easily. Inlays and paint both have their own problems.
It is quite common for teachers to put stickers on the fingerboard while a student is in the early stages of learning, as a means to the end of learning to play by feel.
Comment: Yep.  It should also be mentioned that string instruments are (eventually) often played at speeds where visual aids to position are not going to help you because your fingers are moving too fast to benefit from visual feedback.  A good violinist can play sixteen notes a second or faster, which is about the so-called "ballistic speed" for human fingers: they are moving faster than their positions can be reported to the brain via the nervous system (eyes or proprioception).  If you want to play that fast, you have to have the positions by feel.
Comment: As an aside: I play rock guitar and it often astonishes me how fast classical violinists play arpeggios etc. I'd use van halen style tapping for that kind of speed, but they're fingering it directly. Amazing.
Comment: You could eliminate the word "string" in the first sentence and it would be just a true. Well.. I guess you'd have to adjust the word "fingerboard" also. A lot of instruments, you just can't see what your fingers are doing - it has to all be done by feel. I'm thinking flute and harmonica. One final note, there are cases where the intonation may be different from equal temperament, or microtonality is part of the piece. In those cases, markings would just get in the way.
Comment: @jjmusicnotes the question isn't about having frets, but purely visual lines or other markers (as per a lined fretless bass) - and the question already mentions that having such lines wouldn't prevent the player from having to make further adjustments.
Comment: When my daughter started playing violin, I started as well, having played guitar for most of my life.  We had stickers, but I very soon could play by tone and "feel", and stopped looking at the stickers.  Even without frets, you just know where the notes are.  The frets on a guitar allow you to play chords without getting your fingers exactly in the correct spot.
Comment: Odd. For all of the votes this answer received, everyone seems to have overlooked the obvious: tuning. Any string player will tell you that Ab and G# are not in fact the same note, and tune each accordingly. Also, classical strings are primarily bowed, not plucked. An inlaid metal fret provides a fulcrum that helps to amplify string resonance by providing a concrete node. Classical strings are angled and bowed; having frets wouldn't be a good idea at at.
Comment: `With violin and viola, the player's view of the fingerboard is very foreshortened, so it might be hard to pick out an exact position` Note that harpists get around this issue by coloring their strings. I'd assume a similar fix would work for violins, so I don't think the foreshortening is the leading reason as to why the violin is not marked.
Comment: @ToddWilcox It would be just as true, but to me it seems like restating the question rather than adding to the answer (this is a good answer for the rest of the content in it, IMHO).  Plenty of instruments like piano and steel pan often have note names written on the instrument, despite it being desirable to play by feel.  Slightly related, computer keyboards are also used optimally by touch, but almost universally have letter names printed on them in spite of that fact.  I think the big difference is in tone, from strings creating a continuous range of possible notes rather than discrete.
Comment: To add to this, I'd note that classical guitars frequently have no fret markers either.  The assumption is that by the time you're ready to play pieces which use the higher frets, you shouldn't need to count up from the nut to find which fret you're on.
 By that point you've built up proprioception with your hand position so you instinctively know.
Comment: @ToddWilcox - Not just that - this really goes into many activities. For example, does a hockey player have to look at the puck as (s)he's shooting? Not if they're any good. :)
Answer: FWIW,  people who play piano, harp, and the lowly :-)  trombone play largely by position-muscle-memory as well.  I've never seen a trombone slide with position markings!
It may be of interest to know that string players do on occasion put a small pencil mark if they have to "jump" to a position very far up the fingerboard,i.e. a position that's not only unusual but the note in question is a large interval from the previous notes in the piece being played.  That mark doesn't outlive the performance of said piece, obviously.
Comment: @dmbaturin  dunno 'bout that -- I can bend most clarinet notes at least a half-step.
Comment: Wind instruments are "worst of both worlds" in this regard: you get neither the automatically correct intonation of fretted instruments and keyboards, nor the total freedom of fretless instruments.
Comment: @GuySchalnat that feels like a half-truth. You say it as if it's possible to play a chromatic scale on a trombone without changing position, or on a bugle, at all.
Comment: @AJFaraday- actually, you can do just that.  Doesn't sound very good, but it's quite possible to override the resonant frequency of the length of pipe with control over your lips.  It's easier to do with instruments of larger relative bore: on a cornett, you can finger a descending scale while playing an ascending scale.  Not musically useful, but possible.
Comment: @PLL you should listen to trumpets in a swing band, or the obvious example of the clarinet intro to Rhapsody in Blue.
Comment: The difference on the trombone is that the actual note on a brass instrument is set by how fast the lips vibrate.  The slide (or valves) just let the instrument resonate better at the frequencies the lips are vibrating.  I can easily change notes on my trombone (or my trumpet) without moving the slide or valves.  String instruments are different.  The only way to change the note on my guitar (with frets) is to sharpen it by bending the string.
Comment: @ScottWallace: You can get an audible note at any pitch on any fingering, sure, but you can't get anything close to the normal sound of the instrument, either in quality or strength (unless I've been missing out on this technique somehow all these years).
Comment: @PLL - agreed.  I thought I made that clear, but perhaps I didn't.  But as I'm sure you know, it's quite possible to make fairly substantial changes in pitch (say, a quarter tone) while still maintaining good quality.  The same is true for clarinet (as Carl mentioned) or perhaps even more so with shawm.
Answer: While many of the answers already address issues such as the ergonomics of looking at the finger board and temperment (slight changes in pitch depending on the style of the music), there is also a practical reason:
The note produced depends on the length of the string - so ultimately also depends on the position of the bridge.
This can move (and does, especially on larger stringed instruments, especially when travelling/stored in a soft case) so changes the position required to generate precise intonation (albeit by very small amounts).
Also the height of the bridge has a small impact and these can be changed to suit the owner (this normally affects tone/volume but again changes the intonation by very small amounts).
However, it should be noted that these will only have very small changes (unless someone really knocks the bridge out of place (seen it..), which should be fixed before playing).
Answer: Notes are pretty close to one another and adjusted for temperament.  Play happens relative to fixed positions in certain patterns rather than absolutely and the normal playing position for a violin does not make looking at the neck of the instrument a good idea or even feasible: at the angle you'd be looking, distinguishing finger positions visually would be far too inaccurate.
You have to use your ears.
Answer: Actually in earlier times, classical instruments had frets too. The precursor of the violoncello was the viola da gamba (actually available in different sizes), which had frets. The same applies for the the baryton. Sure, it is easier with them - especially during learning phase, as long as the ear is not sufficiently trained.
But small pitch modifications are much more difficult, you are effectivly restricting the number of pitches to the differentiation of a keyboard, which prevents tweaking the minor third just the tiny little bit. Since they also affect sliding of the fingers, I guess the disadvantages were too many.
Comment: Actually, the viola da gamba was not a predecessor of the cello: the violin family (including the cello) and the gamba family evolved in parallel.  The main reason for the frets on the gamba is not to aid intonation, but to make it easier to play chords.
Comment: The question isn't about frets, but marks/indicators on the fingerboard.
Comment: It was in the original question it's made clear that I appreciate the value of a smooth fingerboard without fixed frets. And was asking why one wouldn't visibly mark the note positions on it.
Comment: @S.Burt: This was not visible, when I answered. With the edit I'm somewhat unsure, what the question is all about: A hard to see high precision marking is completely impractical.
Comment: Sorry, I must have seen it post-edit.  Removed my down-vote.
Comment: Since gamba frets are tied on, they're adjustable, so temperament can be modified.
Comment: It is important to note that the assumption that "classical" stringed instruments do not have frets is incorrect. Classical guitars also have frets! Thank you @guidot for addressing this issue.
Comment: @ScottWallace: Not sure about predecessor, but precursor (from my non-native speaker point of view) does not imply a direct inheritance. I wanted to point out, that it was simply used for the same function (bass register/string able to play continuo).
Comment: @guidot - the gamba was also not a precursor of the cello. Gamba and cello both go back to medieval roots. And you can't say in general that "in earlier times, classical instruments had frets too".  Some did, some didn't.
Answer: Actually, it's because the notes you need are NOT at fixed places.  If you play by ear, you will move the notes around a bit.  It's a good approximation to mark 12 equal temperament out.  But when playing chords, the notes need to move around dynamically to form perfect chords.
If you play major third interval like G/B together on a guitar, you need to bend up G very slightly until the beating in the chord stops (or equivalently drop B slightly if you can).  It similar for minor third interval A/C where you must slightly bend up C (or drop A slightly if you can).  A semitone needs to be slightly widened.  A tritone needs to be slightly narrowed.  A chord like E/D needs to be slightly widened to form a correct sounding chord.
Analyzing this stuff is a complex topic, but if you watch a tuner closely, you can see that the adjustments are not random.  They line up with harmonic locations on the strings.
Answer: Well one reason might be that that you do not look at the fingerboard much while you are playing.  You learn where the notes are without being able to "see" them on the instrument.
This is not the case just in "classical instruments".  Some older banjos were made without frets as are some folk instruments.
Comment: I suppose one could over-simplify any stringed instrument as being guitar-like, fiddle-like, harp-like or zither-like. Depending on how pitches are selected.
Answer: If you are using frets, you are creating a fixed tone which can't be altered - similar to a piano. Historically there were different ways to tune an instrument. Intonation like we know it today (well-tempered) changes  some of the tones in a scale (especially the third and fifth.) This intonation makes it easier to change scales (i.e C-major to b-minor) and the chords still sound good to our ears.
On an instrument that has no frets, you are able to adjust to the "correct" scale (make the 7 in a scale a little bit higher i.e.), while fixed keys won't be able to do so.
I apologize for the laymen's terms, but I didn't want to be too scientific. More details (and a better explanation) can be found here.
Comment: There question isn't about frets, but marks/indicators on the fingerboard.
Comment: And those are called frets (at least so I learned.) But whatever we call them, meant are fixed points on a string instruments neck.
Answer: It's mainly a practical issue... by the time students learn the fingerings, it's not necessary to mark anything because they now have the positions locked into their muscle memory.
I learned to play a fretless electric bass (without learning a normal fretted base prior) and I was surprised how quickly my fingers knew the right place to reach.
Answer: As Rob says correctly in the previous answer, the right positions are not fixed, but have to vary slightly depending on the context. The fixed keys of a piano with his usually equally tempered tune are only an approximation, trying to distribute equally the error for all possible musical scales. Otherwise, if you tune the piano exactly for one scale, for other scales the errors will be larger.
Singing or playing a string instrument are examples where it is expected from a good musician to hit the right note intuitively. Jazz singers are specially famous for singing far of the "official" note. And even pianists are expected to slightly influence the individual sounds, not just pressing a key like a robot.
There have even been experiments with pianos having twice as many keys.
Comment: "even pianists are expected to slightly influence the individual sounds" -- are you suggesting that pianists can make pitch adjustments when they play?
Comment: I'm talking about pitch, not dynamics or timbre. If a violinist is playing in equal temperament, they would not be expected (or at least, it's not advisable) to vary the pitch.
Comment: I remember reading in books for professionals, where the suggest this is possible. It is more complicated and very limited, but tehre is a lot of talk about how to press the keys.
Comment: The explanation being in MHO, that the spectrum of the produced sounds is influenced, e.g. when you hit a key hard or softly,  and thus the ear hears differences. Also I remember a book where they point out that additional sounds contribute, which do not stem from the chord, but from the keyboard.
Comment: But still you will find musicians which devaluate the piano as an instrument which is very practical, but more appealing to less musical persons.
Comment: In some performances of historical musical works, they use different types of tuning. The well tempered tuning is a compromise, bought with the problem that the chords and scales do not sound so pure.


How to find by xpath with Selenium Webdriver? (Python)

Question: I am creating a program that scrapes dictionary definitions. I am using LINE Dictionary, which can be found here: LINE Dictonary. I type in the word "汤" like so:
Image of current state
As you can see, the word has 2 definitions. How do I grab both of them using Selenium Webdriver? Here is a snippet of the HTML for them. If it is not enough, I recommend going to LINE Dict and typing in "汤". Thank you!
snippet of the definition's HTML
Comment: What have you tried so far?
Comment: definition_list = browser.find_elements_by_css_selector('ol.lst_defin>li span.cn')
Answer: Try this XPATH :
//div[@id='autocplt_wrap']//descendant::span[@class='word']//a[text()='汤']

CSS_SELECTOR for grabbing those two element would be :
ol.lst_defin>li span.cn

UPDATE :
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
driver.get("http://ce.linedict.com/#/cnen/home")

input = driver.find_element_by_css_selector("input[type='text']")
input.send_keys("汤")
input.send_keys(Keys.RETURN)

asian_text= WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH,"//div[@id='autocplt_wrap']//descendant::span[@class='word']//a[text()='汤']")))
asian_text.click();

WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'ol.lst_defin>li span.cn')))

definition_list = driver.find_elements_by_css_selector('ol.lst_defin>li span.cn')
print(len(definition_list))

for element in definition_list :
 print(element.text)

This will print :
[??] hot water
soup
Comment: It works! However, the value is hard coded :/ how would you make it so that this part: //a[text()='汤'] works with any other word inside?
Comment: You can have a[text()='"+any_word+"']
Comment: where any_word will be a variable.
Comment: For using the css selector, would I use : find_elements_by_css_selector('ol.lst_defin>li span.cn')?
Comment: Yes , remember that will return a list of web element , then you can iterate over that list and extract the value of each web element.
Comment: Hm, for some reason it returns an empty list :(
Comment: you can have explicit wait before retrieving the web element.
Comment: Sorry to ask, but may I please see how that would be integrated? I am new to selenium, thank you so much for the help sir.
Comment: when you print this : len(definition_list ) , could you tell me the output. and please avoid saying sir.
Comment: Here: browser.find_elements_by_css_selector('ol.lst_defin>li span.cn') OUTPUT: 0
Comment: you can something like : WebDriverWait(browser, 10).until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, 'ol.lst_defin>li span.cn'))
)
Comment: for more on explicit wait, you can refer : http://selenium-python.readthedocs.io/waits.html
Comment: Ah! here is the new output now:  How would I extract the definition now? Hm..
Comment: @BryanThai : I have updated my answer under update section , you can get it from there. and the length of list is 2
Comment: Your code works beautifully! Thank you very much. The thing is, I still have a question about how to grab the right data. For example, I want to grab the word "tang" which appears under the Asian text. How would I use a CSS selector like you did with 'ol.lst_defin>li span.cn'? EDIT: I want to learn how to write something like "ol.lst_defin>li span.cn". How did you arrive at this? Thank you!
Comment: use this css selector :   div.prnc_area>span
Comment: right_side_word = driver.find_element_by_css_selector(" div.prnc_area>span") , then using text method you can get the text
Comment: Thanks again. You've helped me so much with this :D
Comment: @Bryan :no problem.


How can I indicate "NEW" content in faq module after updating an entry?

Question: I use the faq module in Drupal 7.
After I update an entry, I want to display a visual indicator (e.g. "NEW!) if the node has been changed/updated recently.
if I don't use views module.
Comment: Dont understand, please elaborate?
Comment: i want show mark(exemple "NEW!") after i post new faq or update faq
Comment: like Content content:has new in views module
Answer: To do this you can use the Computed Field module.
Add a field to your FAQ content type and select Computed Field as the type.
In the Computed Code (PHP) box add the following code:
<code>$entity_field[0]['value'] =node_mark($entity->nid, $entity->changed);
</code>
In the Display Code (PHP) box, enter the following:
<code>$display_output=theme('mark', array('type'=>$entity_field_item['value']));
</code>
Set the field NOT to store the value in the database.
Go to admin/structure/types/manage/faq/display, move your field above the answer field, set the label to Hidden and the display format to Unsanitized.
This will display either 'New' or 'Updated' as the case may be for the FAQ page, just as it is displayed on the content list..
Comment: node_mark not show on anonymous user.


Routing from one router to another?

Question: I'm trying to route from one basic router to a pfsense box. It's basically so that I can have VPN users on both router aswell as VPN tunnels to test which router performs best. I am also trying to segregate the network with VLANS and the existing router doesn't perform this job very well.
At the moment the network looks like this:
Draytek (existing router)
192.168.1.99
Network is 192.168.1.0/24

LAN port connected to WAN port on new router

pfSense (new router)
10.1.1.1
Network is 10.1.1.0/24
WAN port of this router has an IP of 192.168.1.115

I've set routes up on both routers. On the existing router I have the following:
10.1.1.0/24 routes to gateway IP address 192.168.1.115.

On the new router I have the static routes of:
192.168.1.0/24 routes to gateway IP address 192.168.1.99

Routing is not working between them, am I doing something obviously wrong. I think it's a case of not seeing the wood for the trees.
Neither router can ping the other at all.
Comment: the Draytek (from what you've described) isn't acting as a router since it is only connected to 1 network (192.168.1.0/24)
Comment: You don't need a route on the pfsense for 192.168.1.0/24 as the WAN interface is already on that network. Have you enabled ping on the WAN interface? What is the general FW setup. I would expect the WAN to be blocking most traffic by default
Answer: Well for a start why would the pFsense route through the draytek if it is directly connected to (192.168.1.0)? You need 3 networks, 1 behind each router, and the third in the middle where they will talk.
Comment: Don't worry, I know by having done these sort of things myself :)
Answer: if the pfsense is getting it's IP (1.115) from the Draytek (1.99), and the 10.x.x.x is only a DHCP pool issued from pfsense, you probably won't be able to reroute to 1.115 since it is itself.

Routing from one router to another?


Projectile not shooting direction of my weapon

Question: So my game is sort of like a 3d top down shooter, so I want my gun to shoot wherever the mouse is and it wont go to the mouse unless im shooting down. If you've seen brackyes game called ball wars, im sort of trying to replicate one like that but the projectile is not shooting the right way.
I got my script from blackthornprods ranged combat tutorial (which is for 2d so maybe thats the issue but I dont know how to solve it) :
public float speed;
public float lifeTime;

private void Start()
{
    Invoke("DestoryProjectile", lifeTime);
}

private void Update()
{
    transform.Translate(transform.up * speed * Time.deltaTime);
}

void DestroyProjectile()
{
    Destroy(gameObject);
}

Appreciate anyone to try!
Here is my other script:
 Camera mainCam;
public GameObject projectile;

public Transform shotPoint;

private float timeBtwShots;
public float startTimeBtwShots;

void Awake()
{
    mainCam = Camera.main;
}

void Update()
{
    float objectDepthFromCamera = Vector3.Dot(
            transform.position - mainCam.transform.position,
            mainCam.transform.forward);

    Vector3 cursorWorldPosition = mainCam.ScreenToWorldPoint(Input.mousePosition
            + Vector3.forward * objectDepthFromCamera);

    Vector3 localUpNeeded = Vector3.Cross(Vector3.forward,
            cursorWorldPosition - transform.position);

    transform.rotation = Quaternion.LookRotation(Vector3.forward, localUpNeeded);

    if(timeBtwShots <= 0)
    {
        if (Input.GetMouseButtonDown(0))
        {
            Instantiate(projectile, shotPoint.position, transform.rotation);
            timeBtwShots = startTimeBtwShots;
        }
    }
    else
    {
        timeBtwShots -= Time.deltaTime;
    }
}

Comment: Did you try to add `Input.mousePosition` anywhere else on your code, or this is your entier projectile class ?
Comment: The problem is in the code spawning the bullet. We need that code.
Comment: I edited my question, u should find it there
Answer: Projectile not shooting direction of my weapon. Simple solution -

First instantiate or pool the instance of projectile.
Set rotation of projection from the rotation of weapon & set location to spawn point
Now fire, or whatever strategy you are using

Consider Global rotation, if you need help, tell me, I will edit and give a snippet of code.
This should work. If doesn't post all necessary code, I will give a better solution.
Here is sample github project I created, just for you. I opened Unity nearly after a year. Please check all the versions.
Must check :
firing in facing direction
just instantiate at spawn point
just added some rotation

I think this should give you concept.
Press X for a rantom rotation
Press Space to shoot a projectile :lol:
The white cube shows that it always shoots at a constant direction

Comment: Since I am not sure how to do this since I started unity 2  months ago, I will edit my question and put the script the instantiates the projectile, can you please edit that and show me how to do what you are saying above
Comment: i will add a sample project, as soon as possible
Comment: @Moodie i have updated the answer and added github project link, don't forget to upvote and accept answer, you can mail me if encounter more problem...
Comment: Okay thank you I really appreciate it! I will chack it out soon!!
Comment: I actually dont really know how to use git hub, so can you can explain what im supposed to do with that link? Lol I feel stupid.
Comment: click on [this](https://github.com/maifeeulasad/Simple-Shooter/archive/master.zip) link the project will be download, open in unity, try to learn from those codes, modify... there is a single file to control the gun..


O que significa <<- em R?

Question: O que significa o operador <<- em R, quais são suas diferenças com relação a <- e em que circunstâncias ele pode ser útil?
Answer: Vou explicar com um exemplo.
> objeto_fora_da_funcao <- 1
> f <- function() {
    objeto_fora_da_funcao <- 10
    return(objeto_fora_da_funcao)
}

Saídas
> f()
# [1] 10

> objeto_fora_da_funcao
# [1] 1

Agora, vamos mudar <- por <<- dentro da função f:
> objeto_fora_da_funcao <- 1
> f <- function() {
    objeto_fora_da_funcao <<- 10
    return(objeto_fora_da_funcao)
}

Repare nas saídas agora:
Saídas
> objeto_fora_da_funcao
# [1] 1

> f()
# [1] 10

> objeto_fora_da_funcao
# [1] 10

O que está por trás disso é o jeito que o R guarda os objetos em "environments", que poderia ser visto como conjuntos de objetos (números, vetores, data.frames, funções, etc.).
<<- é geralmente útil dentro de funções, pois as funções trabalham com "environments" próprios, temporários. Apesar das funções de acessarem objetos globais, o operador <- está programado para criar (ou redefinir) objetos dentro do "environment" da respectiva função, apenas. E é exatamente por isso que existe o <<-. Ele irá procurar objetos com aquele dado nome em todos os "environments" do mais específico até o mais abrangente (conhecido como "Global environment").
Isso é útil quando vc quer que uma função altere variáveis globais.
Comment: Athos, eu somente alteraria a última frase para: "Isso é útil quando vc quer que uma função altere variáveis **de seu ambiente pai**." Abraços!
Comment: @LucasSoares É que a principal vantagem não é necessariamente alterar as variáveis globais, mas sim as variáveis dentro do próprio ambiente da função, vou colocar um exemplo.
Comment: Só que alterar variáveis globais de dentro de uma função vão contra as boas práticas de programação da maioria das linguagens modernas :P
Comment: @Athos, continua sendo uma violação das boas práticas. Para facilitar o entendimento do código, a localização de bugs e uma eventual paralelização, o ideal é que cada função altere apenas o seu ambiente.
Answer: Complementando a resposta do Athos, seguem alguns exemplos em que o uso do <<- pode ser útil para alterar variáveis dentro do próprio ambiente da função sem alterar variáveis globais:
Gerando um contador que acumula o valor de i no ambiente da função (baseado no livro do Hadley):
contador <- function() {
  i <- 0
  function() {
    i <<- i + 1
    i
  }
}

cont1 <- contador()
cont1()
[1] 1
cont1()
[1] 2
cont1()
[1] 3
cont2 <- contador()
cont2() # note que o contador de cont2 é separdo de cont1
[1] 1
cont1()
[1] 4

Implementando memoization com local e <<- na sequência de fibonacci (exemplo adaptado do R Inferno):
fibonacci <- local({
  memo <- c(0, 1, rep(NA, 100))
  f <- function(x) {
    if(x == 0) return(0)
    if(x < 0) return(NA)
    if(x > length(memo))
      stop("'x' too big for implementation")
    if(!is.na(memo[x])) return(memo[x])
    ans <- f(x-2) + f(x-1)
    memo[x] <<- ans
    ans
  }
})
fibonacci(10)
[1] 34

Gerando uma seqüência de fibonacci com replicate e <<-
fibonacci <- function(n){
  x0 <- 0
  x1 <- 1
  x <- numeric() # para assegurar que <<- não altere a variável global
  fib <- function(){x <<- x1 + x0; x0 <<- x1; x1 <<- x}
  c(x0, x1, replicate(n-2, fib()))
}

fibonacci(10)
[1]  0  1  1  2  3  5  8 13 21 34

O que significa <<- em R?


Why is a bronze medal not awarded when two silvers are awarded in the Olympic Games?

Question: I'm curios why a bronze medal is not awarded in 100m butterfly swimming Rio 2016 award ceremony. Michael Phelps and two other swimmers got silvers but no bronze was awarded.
So I assume

If there are three or more gold medals are awarded, silver and bronze medals are not
  awarded.

or

If there are two gold medals and one silver are awarded, no bronze is awarded.

Is my assumption correct?
Answer: You can look at it this way:

The Gold Medal is awarded to the athletes who have no other athlete before them, in this case Joseph Schooling.
The Silver Medal is awarded to the athletes who have one athlete before them, in this case Michael Phelps, Chad le Clos, and László Cseh.
The Bronze Medal is awarded to the athletes who have two athletes before them. In this case, there is nobody who has two athletes before him: Michael Phelps, Chad le Clos, and László Cseh all have only one athlete before them, and Li Zhuhao has four athletes before him.
Fourth Place is awarded to the athletes who have three athletes before them. In this case, there is nobody who has three athletes before him: Li Zhuhao has four athletes before him.
Fifth Place is awarded to the athletes who have four athletes before them, in this case Li Zhuhao.
… and so on.

So, Li Zhuhao is in Fifth Place, because there are four swimmers faster than him. There is nobody in Third Place, because there is nobody who has two swimmers faster than him.
Comment: @JorgWMitting Good Explanation..
Answer: Each ex aequo "removes" one of places.
So if A is first, B and C are ex aequo second and D is third, the final places will be
First. A
Second. B and C
Fourth. D
And no third place.
Comment: I think that's the functionality of making a numbered list rather than you doing anything wrong (I remember dealing with the same issue in the past).
Comment: Formatting correctly is too difficult on my phone, since the list automatically re-numbers 1, 2, 3 even when I wrote 1,2,4...


Is it possible Fisher information matrix be indefinite?

Question: I`m using the Newton-Raphson method for obtaining MLE for parameters for maximizing my objective function.
At each iteration, I want to check that is the Hessian matrix negative definite or not and I see the Hessian matrix is not negative definite at some iterations. So, I want to use the Fisher scoring algorithm (https://en.wikipedia.org/wiki/Scoring_algorithm#Sketch of derivation)
In this situation, the Fisher information matrix is indefinite!! Is it possible? What are the reasons for this? Are the second-order derivatives wrong? Or are values of expectations incorrect?
Comment: Could you clarify what you mean by "Fisher information matrix"?  As [usually defined,](https://en.wikipedia.org/wiki/Fisher_information#Definition) this doesn't depend (in any way) on "iterations" towards a solution: it depends only on the likelihood function at the optimal parameter.
Comment: I can refer you to this link : https://en.wikipedia.org/wiki/Scoring_algorithm. I mean expected the observed information matrix calculated at obtained parameter value in previous iteration.
Comment: Thanks.  That's a gradient descent algorithm.  Refer to posts about these algorithms for the (many) problems they can have.
Comment: @whuber Thank you.
Comment: You need to be aware of the difference between the Fisher Information  and the Observed Fisher Information,  see for discussion https://stats.stackexchange.com/questions/154724/why-exactly-is-the-observed-fisher-information-used   and   https://stats.stackexchange.com/questions/188251/expected-and-observed-fisher-information
Comment: @ kjetil b halvorsen Thank you. I studied your suggestions. please tell me what do we calculate in the **"Fisher Scoring Algorithm"**? <(https://en.wikipedia.org/wiki/Scoring_algorithm#Fisherscoring)>
Answer: From https://en.wikipedia.org/wiki/Observed_information the observed Fisher information matrix is just the negative Hessian of the log likelihood function. If your log likelihood function is not convex then the hessian will not be positive-definite (and thus indefinite).
This is the case if you are using the "Observed Fisher Information Matrix" from https://en.wikipedia.org/wiki/Scoring_algorithm. If you are using the canonical notion of the Fisher Information Matrix (https://en.wikipedia.org/wiki/Fisher_information#Matrix_form) then it must be positive semi-definite.
Comment: Thanks a lot.  At the first iteration in Newton-Raphson method, I see that the observed fisher information matrix (negative Hessian) from (https://en.wikipedia.org/wiki/Scoring_algorithm ) is positive definite (for maximizing problem) and after the first iteration it becomes indefinite!! In this situation, Is it correct that I say my log likelihood function is not concave? Does it depend on staring values?
Comment: Yes it is correct that your log likelihood function is not concave; if it were concave then it would be everywhere negative semi-definite. A function is concave if it is everywhere negative semi-definite (and convex for everywhere positive semi-definite). This does not depend on the starting value for the algorithm.
Comment: It's worth noting that since your function is not convex, this algorithm will (almost certainly) not find the global minimum; instead I would recommend some sort of stochastic descent algorithm if a local minimum will not suffice for your use-case.
Comment: @ Jspang  Thank you.


C comparison 'x < 0' where type of 'x' is arbitrary, i.e. might be unsigned

Question: GIVEN:
A type defined as TheValueT that may be arbitrarily configured, e.g. as uint8_t or int64_. Let there be some code:
TheValueT   x = ...;

... do something to 'x' ...

if( x < 0 ) {
   /* Do something. */
}

PROBLEM:
It happens that if TheValueT is defined as an unsigned type, the compiler complains about 'condition always true because of limited range of type ...'.
QUESTION:
How can the compiler warning be avoided whilst letting TheValueT still be of arbitrary integer type? The solution should be applicable to the widest range of C compilers.
Comment: In parallel with `INT_MIN` implement `THEVALUET_MIN` and use `if ((THEVALUET_MIN < 0) && (x < 0)) /* ... */;`
Comment: https://stackoverflow.com/questions/6259224 is not exactly the same, but may give you some ideas.
Comment: @rtoijala: It does not.
Comment: You could try conditionalizing the code so that it is removed when you use an unsigned type for `TheValueT`, although that would entail adding a macro definition at the place where you define `TheValueT`.
Comment: Detail "It happens that if TheValueT is defined as an unsigned type" and the type is/as  narrower as `int`... the compiler complains
Comment: I'm not getting a warning anyway but does `if(TheValueT < TheValueT - TheValueT)` give you a warning?
Answer: A simple and safe way to write your test would be this:
TheValueT x = /* ... */;

if (x < 1 && x != 0) {
    // do something
}

It is possible that a clever enough compiler would warn about that anyway, but the same is true of any correct alternative that can be written to cover all possible integer types (including extension types).  That does work around the warning in my implementation.
No alternative requiring an arithmetic computation involving the value of x definedly produces the correct result in all cases -- these run into problems with values of x at the extremes of its or other types' ranges.
This does assume that TheTypeT must be an integer type.  If floating types are a possibility, too, then your best bet may be to just live with the warning, or to use a compiler flag to turn off that particular warning during production builds.
Comment: Since `x` can be "arbitrarily configured", what if `x` is a `double`, and has value `0.25`?.  It would pass your test (`x < 1 && x !=0`) and treat `0.25` as if it were a negative value.
Comment: This is by far the most elegant, most comprising solution!
Comment: Yes, @abelenky.  I address this issue in the last paragraph of the answer: the proffered solution explicitly addresses integer types only.
Comment: My answer handles floating-point types too. There is no need to just "live with the warning".
Answer: Variation on a theme. Works for FP too.
if (x <= 0 && x != 0) {

Comment: Certainly, it has some charm to it. I could imagine, though, that constant value reduction of some compilers might be able to figure that out. John's solution with the 'x<1' contains a '-1' operation. Since for unsigned types the result is something void, constant reduction might be prevented from happening.
Answer: Perhaps a Generic solution?
#include <stdio.h>
#include <stdlib.h>

#define less_than_zero(x) _Generic((x) + 0, \
  int: (x) < 0, \
  long: (x) < 0, \
  long long: (x) < 0, \
  default: (x) * 0 \
  )

#if 1
int main(void) {
  short sh = -1;
  int i = -1;
  long long ll = -1;
  unsigned short us = -1u;
  unsigned u = -1u;
  unsigned long long ull = -1u;

  if (less_than_zero(sh)) puts("sh");
  if (less_than_zero(i)) puts("i");
  if (less_than_zero(ll)) puts("ll");
  if (less_than_zero(us)) puts("us");
  if (less_than_zero(u)) puts("u");
  if (less_than_zero(ull)) puts("ull");
  return 0;
}

No condition always true because of limited range of type warning.
Output
sh
i
ll

Comment: @Frank-ReneSchäfer If a compiler restriction exists, that should be part of the question.
Comment: Correct, I will add the note.
Comment: I like it, but it does not accommodate `TheTypeT` being a signed extension type.


InputStream won't open a stream to a specified URL

Question: I'm simply trying to load a URL into an InputStream but it never seems to manage.
<code>private void getWebpage(String url)
{
    URL myFileUrl = null;

    try
    {
         myFileUrl= new URL(url);
    }
    catch (MalformedURLException e)
    {
        System.out.println("Malformed URL Exception");
    }
    catch (Exception e)
    {
        System.out.println("Some URL Exception");
    }

    try
    {
        InputStream in = myFileUrl.openStream();
        System.out.println("Does it get here?");
        is = new BufferedInputStream(in);
        in.close();
        is.close();
    }
    catch (IOException e)
    {
        System.out.println("Some IO Exception");
    }
    catch (Exception e)
    {
        System.out.println("Some Exception");
    }
}
</code>
It never prints out "Does it get here?" to the console but it does print out Some IO Exception. There aren't the best error messages in the world I know.
Comment: Use `e.printStackTrace` instead of `System.out.println` to get a more useful error message
Comment: Are you sure your app has the permission  ?
Comment: I have the user permission line in my manifest file.
Answer: Is it breaking out to one of the exceptions instead then? If it cannot open the file then it will jump down to the catch statement
EDIT: Actually are you trying to load a webpage?
Comment: Yes it is being caught by the IOException
Comment: There is something wrong with the string value you are passing to it. What is it your trying to do?
Comment: I'm trying to load the contents of a webpage into a string.If the URL is incorrect then I should be able to set myFileUrl to be something like http:// www.google.com and it should then work. I tested that but it still does the same thing.
Comment: have you looked at what exception it is throwing
Comment: request time failed: java .net .SocketException Address family not supported by protocol
Answer: In general the code is working fine.
So there must be a problem with your network connection. Do you have a direkt connection to the internet or do you have to pass a proxy?
Comment: I guess you are testing with the emulator, aren't you? In this case, you should try to recreate a new AVD. ("Have you tried to turn it off and on again?" --The IT crowd)


Panels "custom content" argument formatting

Question: I'm using Drupal 7.4 with Panels 7.x-3.0-alpha3.  When creating a "New custom content" and using context keywords (eg %node:field-integer), the numeric integer field I'm adding gets pulled through with a comma (eg 7,234 instead of 7234).  This also happens when adding Node (tokens) items.
The field in question does not have it's display formatted like that in Content Types > Manage Display either.
I believe that Tokens and Panels Context/Arguments is pulling this from the same location, but I'm not sure where it is configured like that.
I've also tried %node:field-integer-raw and -unformatted, as well as %node:field-integer:raw and :unformatted, but neither of those worked.
Comment: This is a module-specific bug question, and I see you already have [an issue open on Drupal.org](http://drupal.org/node/1224702).

I really think in this case you would be better off taking [the advice on that issue](http://drupal.org/node/1224702#comment-4761158), or re-opening it if you still cannot get it to work. According to the [Drupal Answers FAQ](http://drupal.stackexchange.com/faq#questions), this kind of question is beyond the scope of this site.
Answer: Just in case someone came here through a Google search, there is an answer to the specific question.
You can specify the default formatting of tokens by going in the Content Type in question, then in "Manage Display" tab, at the bottom of the page under "Custom Display Settings" you will have to enable the "Tokens" display.
The formatting that you choose for each field in this display will be used whenever you print the field through a token.
You could also use the Advanced Entity Tokens module, which allows you to specify a different view as an "extraction base" for your field formatters.
Edit:
Note that you can also create specific token formatters for profile2 entities by following the exact same method explained above. By default profile2 creates a single Display but there is still a Custom Display Settings option at the bottom of the page where you can enable the Tokens display and specify the formatters that you want to use for your Profile2 tokens wherever you use them (including Panels).


How is it that dot product does projection but so does division?

Question: Can anyone explain how it is that dot products can perform projection but so can division, and how the processes are related (or not)?
With dot product, you can project one vector onto another vector:
$\hat{v} = \hat{a} \cdot \hat{b}$
Where $b$ is normalized and you want to project $a$ onto that vector direction.
Division can be used to do projection too though.  In the case of converting 3d coordinates to 2d coordinates (like in computer graphics for rendering 3d geometry on a 2d screen), that can be done by dividing x and y by z:
$x' = x / z$
$y' = y / z$
Where $x$, $y$ and $z$ are the 3d coordinates of a point, and $x'$ and $y'$ are the 2d coordinates of the point.
In the dot product case, one vector has to be normalized, is that where the equivalent division is happening maybe?
Thanks!
Comment: What does $x/z$ even _mean_ when $x$ and $z$ are vectors? Usually that is not a defined notation -- but it may be that you have a definition in your particular context that unfolds to something involving dot products.
Comment: The question is less than perfectly clear, but my first guess is that you're using "projection" to mean two different things. One is the orthogonal projection of a high-dimensional vector space to a lower-dimensional subspace.  The other is either the conversion from homogeneous coordinates in a projective space to affine coordinates in one of the affine patches (of the same dimension as the projective space) or the radial projection of an affine space minus one of its points $P$ to an affine hyperplane not passing through $P$.
Comment: I edited the question, can you guys let me know if you have any more feedback about the clarity of what I'm asking? thank you!
Answer: "Projection" can mean many things, and about the only feature they have in common is that it's about an (idempotent) transformation that moves points somewhere along straight lines. (And even that is not fully general -- although some "map projections" can be explained as moving points along straight lines from the surface of a sphere to an image plane, there are many that cannot).

The kind of projection done by $\vec y=\vec a\cdot\vec b$ is a projection that moves points from space onto a line, according to the rule that each point must move along a line that intersects the given line perpendicularly. If the given line goes through $(0,0,0)$ in the direction of $\vec b$ where $\|\vec b\|=1$, then the projection moves the point $\vec a$ to $(\vec a\cdot \vec b) \vec b$. (If $\vec b$ is not necessarily normalized, the correct formula is $\frac{\vec a \cdot \vec b}{\vec b\cdot\vec b} \vec b$).
The projection you get by computing $\frac xz$ and $\frac yz$ is a central perspective, where each point in space moves to an image plane, according to the rule that each point must move along a line that passes through the camera point. In your case the camera is at $(0,0,0)$ and the image plane is $z=1$, so the projection is actually $(x,y,z)\mapsto (\frac xz,\frac yz, 1)$.

As can be seen, these two projections do fairly different things -- there is not much in common between "the set of lines that intersect $\vec b$ perpendicularly" and "the set of lines that pass through the camera point", and the rule for where on the projecting line each point ends up is different too. So there is no particular reason to expect that the formulas for doing either would be similar.


The diophantine equation $\dfrac1a=\dfrac{1}{x_1}+\dfrac{1}{x_2}+\cdots+\dfrac{1}{x_n}$ for arbitrary integer $n$.

Question: NOTE.- Looking for information on Egyptian fractions, I find that, contrary to what I believed, this interesting property of unit fractions has already been established previously. So I edit this post giving the easy solution before deleting it tomorrow.
We consider the diophantine equation $$\dfrac1a = \dfrac{1}{x_1} + .... + \dfrac{1}{ x_n}\tag 1$$  A trivial solution comes from $\dfrac1a=\dfrac{n}{na}$ but finding a non-trivial solution could be very difficult even when $n$ is small. However, there is a very easy deductible way that leads us to state the following problem:
Let $a$ and $n$ be arbitrary positive integers. Prove that equation $(1)$ has at least $n-1$ non-trivial solutions $(a_1, ...., a_n)\in\mathbb N^n$.
Solution.- We have the identity $\dfrac{1}{a}=\dfrac{1}{a+1}+\dfrac{1}{a(a+1)}$ .
By iteration there are 2 distinct ways to solve the equation for three unit fractions, 3 ways for four, 4 ways for five and so on.
Comment: This is not a place to suggest problems you know the answer to.
Comment: @kp9r4d That is just flatly untrue. For instance, on the page where you would compose your question post, it gives you the option to "Answer your own question – share your knowledge, Q&A-style". So this is very much a site where you can do that, and you are even explicitly encouraged to do so. It would be nice to point that out in the question post, though, if that's what you're doing.
Comment: @Piquito The fact that $1/a = 1/(2a) + 1/(2a)$ *is not* a "beautiful result" nor a "nice property of integers"...
Comment: @Arthur It is not a question of level or difficulty : you are right, a problem can be very easy and have a really interesting and deep solution, or be very beautiful, as Piquito says. In that case, it would be justified to post it on the site knowing the answer. I just find that this is not the case for this particular problem, which (in my opinion) brings nothing interesting. If someone posts "I know the answer but please prove that for all $x$, one has $x^2+2 \geq \cos(x)$", you will undoubtedly think that it has not its place here. I feel the same with this question.
Comment: What is the point of this question?
Comment: @Piquito I downvoted. In my opinion, you can post questions you know the answer iff you think the problem is really interesting (for example, if you want to share an unknown method or to enlight a specific point of view). Here obviously, it is not the case : your question is very easy and every teenage student, as you said, can solve it.
Comment: Can you find **one** solution? What about two solutions? From there, finding $n-1$ solutions is probably not that difficult.
Comment: @Arthur.- Give me a pair $a,n$ (obviously not $n$ big) and I give you a solution. I repeat, the problem is elementary.
Comment: You seem quite certain you can find a solution no matter what $a$ and $n$ are. How exactly would you do that? Can you describe an approach without actually knowing $a$ and $n$ beforehand? You do that, and you are very close to an answer to your problem.
Comment: @Piquito What did you try, where are you stuck ?
Comment: @Arthur.- Yes, absolutely yes. If you give me, for example $(a,n)=(7,5)$ you can write    $$\frac17=\frac{1}{9}+\frac{1}{57}+\frac{1}{73}+\frac{1}{3192}+\frac{1}{5256}$$
Comment: @The Silver Doe.- I am not stuck and sure my problem is easy to solve. That is why I have proposed it here.
Comment: @kp9r4d.-I think the downvotes for this post are totally unjustified. I will not erase it until they accumulate as much as those who cannot solve it want. In the meantime, I am waiting for a likely answer from a teenage student who can see how easy it is.
Comment: @TheSilverDoe.- If you have no sensitivity to the exposed property, then act as you want unjustifiably with your downvote. I do feel the beauty of that property of the reciprocals of integers and that is why I wanted to share it with other people.
Comment: @TheSilverDoe Whether a problem is interesting is really not a question of its level, or how difficult you find it. This site is explicitly stated to be for _all_ levels. I think this problem is cool, if a bit unrefined in its presentation.
Comment: @Arthur.- Thank you very much. You have understood the essentials of the situation. It is very true about the deficient language but the fact is that without the Google translator I could neither solve nor propose problems in MSE. I only speak Spanish and French.
Comment: @TheSilverDoe I agree with the trig question. But I believe that this problem is qualitatively different. Other than "it's not a standard school algebra problem, you actually have to think a little outside the box" I couldn't tell you why, though. It is a very standard competition type problem, though. Maybe I'm just a sucker for those.
Comment: @Arthur Well, everyone has his opinion ;) I just downvoted, and I explain why (which is better, I think, than downvoting without explanation). I don't want to discourage anyone to think about the question.
Comment: @Arthur.- Dear friend, I think, perhaps exaggerating, that this beautiful result should be taught to first-level children, as a nice property of integers (the most elusive of mathematical objects according to the well-known British mathematician J.W.S. Cassels). I give you (and other people who read this comment) the easy key to the solution: it is enough to solve for $n = 2$ and the rest comes out immediately (surely you realize why).
Answer: Your solution works, but obviously, there are in general much more than $n-1$ solutions to your equation. As TheSilverDoe's pointed in the comment, you can generate a lot of solutions just using the property that $$1 = \frac{1}{2} + \frac{1}{2}$$
Here's a sketch on how to find easily a lot a solutions. First note that the $a$ is useless : indeed, if you can prove the property for $a=1$, then multiplying all the $x_i$'s by $a$, you get the property for $a$. So it is enough to prove it for $a=1$.
For $n=2$, you have the obvious decomposition $$1 = \frac{1}{2} + \frac{1}{2}$$
and for $n=3$, you have the two decompositions $$1 = \frac{1}{2} + \frac{1}{4} + \frac{1}{4} = \frac{1}{3} + \frac{1}{3} + \frac{1}{3}$$
Now, let me explain how you can generate a lot of solution, by induction. If you have a certain solution for $n$, let's say that
$$1 = \frac{1}{x_1} + ... + \frac{1}{x_n}$$
you have to ways to generate a solution for $n+1$. The first one is two divide one of the term in two equal parts (so you can generate $n$ new solutions, even if they can be the same) :
$$1 = \frac{1}{x_1} + ...+ \frac{1}{2x_i}+\frac{1}{2x_i}+ ... + \frac{1}{x_n}$$
The second one is to divide all the terms by $2$, writing
$$1 = \frac{1}{2} +\frac{1}{2x_1} +  ... + \frac{1}{2x_n}$$
You can check that this algorithm lets us construct a very high number of solutions, and can answer your original question. Moreover, if I come back to the original problem with the $a$, all the solutions constructed this way involve only multiples of $a$ (whereas your solution does not involve necessarily multiples of $a$) : that means that there are much more solutions than the one you constructed.
Asking exactly  (or estimate precisely) how many solutions the equation has could be an much more interesting problem, in my opinion.
Comment: Why deleting ? Your original question is not interesting (that's why it has been poorely received, I guess), but I would say that the question of estimating the number of solutions to the equation can be very interesting and far more difficult. In my opinion, leaving this question open is a good thing, if people want to give some thoughts.
Comment: According to what I said in the post yesterday, I thought about deleting this today but the existence of an answer (yours, somewhat naive I think) prevents me from doing so by rules prevailing in MSE. I'm sorry, I would like to erase it for being so badly interpreted by some people.
Comment: Think as you see fit, dear friend.


Retornar "alert" se uma IF não for executada

Question: Como posso verificar se um if foi executado ou não, e se não foi ele exibir um alert?
Veja o exemplo:
if ($newtime!=0) {
   $qryupd = "update registration set dados=" . $dadosnew . " where id=$id";
   $result2 = mysqli_query($db, $qryupd);
   if (!$result2) {
      rollback();
      echo '[{"resultado":"falhou","total_lances":"' . $bal . '","motivo":"Falha ao executar lance, por favor tente novamente! Código: LW102"}]';
      exit;
   }
}

Nesse exemplo ele já faz isso para a query que atualiza no DB, se não atualizar ele mostra o alert. Eu preciso fazer a mesma coisa, porém preciso que ele verifique a primeira condição IF, no caso: if ($newtime!=0) {
É possível fazer isso?
Answer:             if ($newtime!=0) {
        $qryupd = "update registration set dados=" . $dadosnew . " where id=$id";
        $result2 = mysqli_query($db, $qryupd);
        if (!$result2) {
            rollback();
            echo '[{"resultado":"falhou","total_lances":"' . $bal . '","motivo":"Falha ao executar lance, por favor tente novamente! Código: LW102"}]';
            exit;
        }
        }else{
    echo "newtime é igual a 0";
    echo ";

}

Acho que isso vai resolver seu Problema.
Você pode usar o IF/ELSE .
if(condicao)
{
entrou na condição
}else{
não entrou na condição
}


Super Bowl MVP winners from the losing team

Question: How many times a player from the losing team was named the super bowl MVP?
Please list all these MVP winners, year it occurred, as well as the team and position they played.
Answer: There is only currently one instance by the player "Chuck Howley"

Super Bowl Players that were voted MVP of the game, but were on the opposite team:
Year- 1971
Super Bowl- V
Player- Chuck Howley
Position- Linebacker
Team-   Dallas Cowboys

Source:

https://en.wikipedia.org/wiki/Super_Bowl_Most_Valuable_Player_Award


Proof of density inequality

Question: I was wondering if there is an easy way to find sufficient conditions for the following inequality to hold
$$
\int f(x,y)^2 \:\mathrm{d}x \:\mathrm{d}y - \int f(x)^2 f(y)^2 \:\mathrm{d}x\:\mathrm{d}y \geq 0,
$$
where $f$ is the density function. Do you have any suggestions?
Comment: _Equality_ will hold if $X$ and $Y$ are _independent_ random variables.
Answer: For the case of continuous r.v.'s, we are asking under which conditions
$$\int\int f(x,y)^2 \:\mathrm{d}x \:\mathrm{d}y - \int\int f(x)^2 f(y)^2 \:\mathrm{d}x\:\mathrm{d}y \;\;?\geq ? \;\;0$$
Obviously, it holds trivially as an equality if the r.v.'s are independent. If they are not independent we ask, using $f(x,y) = f(x\mid y)f(y)$,
$$ \int\int f(x\mid y)^2f(y)^2 \:\mathrm{d}x\:\mathrm{d}y  - \int\int f(x)^2 f(y)^2 \:\mathrm{d}x\:\mathrm{d}y \;\;?\geq ? \;\;0$$
$$\Rightarrow \int\int [f(x\mid y)-f(x)][f(x\mid y)+f(x)]f(y)^2 \:\mathrm{d}x\:\mathrm{d}y \geq 0$$
All these are densities, and so non-negative. This means that a sufficient (although not necessary) condition is that
$$ f(x\mid y)-f(x) >0$$ for the whole support,
while a necessary (but not sufficient) condition is that this inequality holds for at least some of the support (the inequality is strict because we are in the sub-case of dependent r.v.s).
This sufficient condition can be written as
$$ f(x, y) > f(x)f(y)$$
for the whole support. But if it should hold for the whole support, then we should also have
$$\int \int f(x, y)\mathrm{d}x\:\mathrm{d}y > \int \int f(x)f(y)\mathrm{d}x\:\mathrm{d}y$$
$$\Rightarrow 1 >1 $$
which is impossible. So at least at such level of generality, it appears that no sufficient conditions may be stated.
Comment: Could you explain how you got from $$p(x,y) \leq p(y), \;\; p(x,y) \leq p(x),\;\;\forall x, y$$ to $$p(x,y)^2 \leq p(y)^2p(x)^2,\;\; \forall (x,y)$$ a little more? For example, if $p(x,y) = 0.1, p(x)=p(y)=0.2$ then $$p(x,y)^2 = 0.01  \geq p(y)^2p(x)^2 = 0.04^2 = 0.0016$$ and not the other way around.
Comment: @DilipSarwate I cannot explain it because it obviously does not hold in general. Thanks. I am editing the answer.
Comment: Exactly, it should not hold in general, but it can be verified that it hold if $f$ is Gaussian density. So there has to be a broader set of function for which it holds and I hoped that this set can be represented by some sufficient conditions.
Comment: However, maybe it can be easier to show the if the following holds $\int f(x,y)^2dxdy - \int f(x,y)f(x)f(y)dxdy\geq0$???.
Comment: It will lead you to the same prospective sufficient condition, which cannot hold. I cannot see any possible sufficient condition at that level of generality at least, although, there are certainly, wiser people here.
Comment: I see that. But how can it be true for the Gaussian distribution? Could that be possible that it holds for the whole expnential family?
Comment: Can you provide a reference for the case of the Gaussian distribution? I would like to search this a bit more.
Comment: For the Gaussian density: assume that $\sigma_x$ is the st. deviation of X and $\sigma_y$ of Y, and $\rho$ is the correlation between variables. Then using the multivariate normal (see page 6 from https://www.cis.rit.edu/class/simg713/Lectures/Lecture713-11-4.pdf), we can find that $\int f(x,y)^2 dxdy - \int f(x)^2f(y)^2dydx$ is equal $(4\pi\sigma_x \sigma_y)^{-1} [(1-\rho^2)^{1/2}-1]$, which is equal 0 only for independent variables.

Proof of density inequality


Making Monic polynomial problem

Question: Problem) Determine whether $2^{-1/3}+2^{-2/3}$ is rational or irrational.
The problem is to be solved by using monic polynomial's property
Which is that 'IF the root of monic polynomial is rational, then the root is integer'
I think that by using contraposition, if we can find monic polynomial for given number,   then by 'the given number is not integer.', we can prove given number is irrational.
but i don't know how can i find the monic polynimial for give number...
Comment: Compare with [this question](http://math.stackexchange.com/questions/95918/minimal-polynomial-of-1-21-3-41-3).
Answer: Hint:
Let $x=2^{-1/3}+2^{-2/3},$ then $x^3=\frac12+3\cdot\frac12\cdot x+\frac14$.
Comment: And also p|3 therefore everyting is solved  thank you
Comment: Coefficients of monic polynomial must be integer.
Comment: If this rational polynomial (Monic or otherwise) has no rational roots, your number cannot be rational.
Comment: How can we determine your 3-order equ has no rational roots?
Comment: Check https://en.m.wikipedia.org/wiki/Rational_root_theorem
Comment: In interger coefficients monic polynomial, we can check whether the root is integer or not but rational.coefficient equ .. i dont know how to do
Comment: Did you check the link I posted? It's for rational polynomials (or integer polynomials which are not necessarily monic). It is more general than the one you seem familiar with.
Comment: Wowowow you right i thought that the same thing yours is more.general i found that q|4 in your equ ( changing to.integer coefficients ex).multiply 4 )

Making Monic polynomial problem


When using "Evans" jazz voicings what voicings should I use for half-diminished ii chord in minor and tritone substitution chords?

Question: Below is a chart I made of the standard Evans A and B forms (which I have only seen in method books using major key harmony) and my own possibilities for voicings for half-diminished and tritone substitution chords. Are my voicings OK? Are there other standard fingerings I should use?
Note: in the minor key chart I used the flat sign for the 5th and 6th chord tones, but not for the 3rd and 7th where they are assumed to be minor intervals.
EVANS STYLE CHORDS

Major Keys --------------------------------------------

CHORD   TYPE A      TYPE B

ii m9   3 5 7 9     7 9 3 5
 V 9    7 9 3 6     3 6 7 9
 I Δ9   3 5 6 2     6 2 3 5

Minor Keys --------------------------------------------

CHORD   TYPE A      TYPE B

ii m7♭5 3 ♭5 7 1    7 1 3 ♭5
 V 7♭9  7 ♭9 3 ♭6   3 ♭6 7 ♭9
 i m9   3 5 7 9     7 9 3 5

Tritone substitution for V7 ---------------------------

CHORD   TYPE A      TYPE B

♭II 7♭5 3 ♭5 7 1    7 1 3 ♭5

Answer: You seem to favour voicings based on stacked thirds. The book:
Frank Mantooth Jazz Piano Voicings
says to avoid stacked thirds in favour of voicings based on descending fourths.
This descending fourths structure is exactly the chord shape used by Bill Evans in his performance of 'So What' with Miles Davis.
I've had a printed copy of the book on my piano music stand for years. The chord spellings are brilliant and systematic and they sound proper. Third-based voicings can sound twee.
Two of its chapters are devoted to diminished chord spellings and tritone substitution respectively.
Comment: I don't favor those voicings. It's just that the Evans voicings seem to be a staple of jazz so I want to study them. My question is if there are Evans voicings for minor and the tritone substitute. But I appreciate the resource about harmony in fourths.
Comment: The idea of Evans voicings is generally to bring out the dissonances peculiar to jazz chords more - and in particular there are usually some 2nds moved inside a 4th instead of being put outside as a 9th.  (I'm not usually a jazz musician and never learned the details, but got the general idea.)
Answer: From Jerry Coker's Jazz Keyboard:
Section 2, the rootless II-V-I
First to establish Coker's major forms with other "standard" voicings...

Coker's minor forms are...

For some reason Coker doesn't show any tritone substitutions in section 2 of the booklet. He shows an example in the previous section about rootless voicings for a 12 bar blues where a G7 in bar 4 is substituted with a Db7. He uses an enharmonic spelling to maintain the same spelling for the 3 and 7 between the G7 and Db7 which I find hard to read in staff notation (the 9th of Db7 is spelled D# rather than Eb!) Regardless, the substitutions are basically the same voicings as the V7 in II-V-I of section 2...

...rather than ♭II 7♭5 it seems that ♭II 7♯5♯9 would be Coker's tritone substitution in minor.
Comment: Feels silly answering my own question, but these are the "standard" rootless voicings I am interested in. Coker covers II-V-I in major _and_ minor, and he has a section specifically about these voicings for 12 bar blues. I wish I had found this book sooner.


Anonymous user can view unpublished content

Question: Is there any way anonymous users can access unpublished pages using view?
I have a REST api for a custom content type that has setting of unpublished content and I want anonymous users can access it.
Answer: Yes, You can enable module Workflows which is currently packed in core since 8.3 and check for permission for anonymous user

View any unpublished content

in /admin/people/permissions
Note: Not to confuse about the permission when enable only Workflows. You need to enable module Content Moderation(Core module) to make Workflows work. Once go to /admin/config/workflow/workflows you will see the the default workflow. Here is the permission after enable Content Moderation.
Comment: I didnt see that in the list of permissions after enabling it. Even without the module enabled, it has *View own unpublished content* but doesnt seems to work when I allow anonymous on it.
Comment: Surely you cannot see it, because to let Workflows module work you need to enable another module --> Content Moderation (in core too) to define a workflow. Then it will appear in permission
Comment: Thanks! But I found another module I posted in the answer without any configuration and it solves my prroblem.
Answer: Found this module and solves my problem View Unpublished.

This module allows you to grant access for specific user roles to view
  unpublished nodes of a specific type. Access control is quite granular
  in this regard.


circulo com varias barras com jquery e css

Question: eu to tentando criar um circulo com barras dentro que acompanha a borda do circulo, eu estou a horas quebrando cabeça com isso.
Aqui tem o código que eu levei o dia todo pra fazer, mas ainda não é isso,

$(function(){
  var left = 50,
   rotate = 0,
   top = 0,
   tX = 0,
   tY = 100;
  for (var i = 0; i <= 32; i++) {
   var li = $('
',{class:'bar_'+i});
   li.css({
    'left': left+'%',
    'top': '0',
    'transform': "translateY(-"+tY+"%) translateX("+tX+"px) rotate("+rotate+"deg)",
    'margin-top':top
   });
   top +=  5.46875;
   rotate += 2.8125;
   left += 1.5625;
   tX += 1.5625;
   tY -= 1.5625;
   $('.circle').append(li);
  }

 })
ul.circle { width: 310px; height: 350px; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: #aaa;
 border-radius: 100%; }
 ul.circle li { position: absolute; width: 3px; height: 100px; background-color: #60f; list-style: none; box-sizing: border-box;
 border: none; margin-left: -1.5px;  }

Aqui o código
Eu quero que a barra roxa siga a borda do circulo ... ta tentei de tudo, até pensei em fazer tudo só no css, mas eu vou utilizar 128 barras dessa, então estilizar 128 barras n vai da certo kkk, fico no aguardo, abraço!
Comment: Porque você quer fazer isso utilizando `` e `` ?
Comment: na vdd não tem um porque, só achei melhor utilizar ambos pra manipular a  com jquery
Comment: Não entendi o modo que vc quer que as barras acompanhem o círculo.
Comment: Cara, o que eu quero fazer é tipo isso: http://prntscr.com/ifsf6k,
Comment: Só que em html, jquery e css, eu sei que é possível, mas ainda n descobri como, ja rodei a net toda atras de algo que me ajudasse, mas n achei nada
Comment: Mas qual é a manipulação que você pretende com esse código? não seria mais prático utilizar um svg, canvas ou uma imagem de fato?
Comment: Eu pensei nisso, conheço nada sobre canvas ou svg, eu to achando que vou ter q fazer isso com css puro msm, poq n acho nada
Answer: Você pode conseguir o efeito usando transform-origin: bottom; e um pseudo-elemento.
Suponhamos que tenha apenas 1 barra no círculo, com altura de metade do raio + 2%, totalizando 52% (os 2% será o excesso que irá ficar fora do círculo) posicionado no meio com a ponta de baixo saindo do centro:

Gerar as várias barras fazendo a inclinação pela ponta de baixo:

Você conseguirá obter o efeito. Porém não use ul nem li para isso. Esses elementos possuem um espaçamento padrão que irá atrapalhar. Mesmo você podendo eliminar esses espaçamentos pelo CSS, é desnecessário. Use div e span, seu código vai ficar muito mais limpo e preciso.
Outro ponto é que você precisará de 128 barras para completar o círculo com a rotação especificada no jQuery.
Veja:

$(function(){
   var rotate = 0;
   for (var i = 0; i <= 128; i++) {
      var li = $('',{class:'bar_'+i});
      li.css('transform','rotate('+rotate+'deg)');
      rotate += 2.8125;
      $('.circle').append(li);
   }
})
div.circle {
   width: 350px;
   height: 350px;
   position: fixed;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
}

div.circle::after {
   content: '';
   width: 100%;
   height: 100%;
   position: absolute;
   top: 0;
   left: 0;
   background-color: #aaa;
 border-radius: 100%;
}

div.circle span {
   position: absolute;
   width: 3px;
   height: 52%;
   background-color: #60f;
   left: 50%;
   margin-left: -1.5px;
   transform-origin: bottom;
   top: -2%;
}

Comment: CARA QUE PERFEITO, era isso que eu tava tentando fazer, muito obrigado mesmo!


Multiple *Almost* identical processes on a Linux Server

Question: What is the best way to run multiple Almost Identical Java processes on the same Linux server?
Explanation of the environment:
We are running a set of Java processes that provide a calculation grid. The only difference between the processes, is the command line parameter that Identifies the node name. Something like:
(Process 1)   Java -DNodeNumber=1 CalculationNode
(Process 2)   Java -DNodeNumber=2 CalculationNode
(Process 3)   Java -DNodeNumber=3 CalculationNode
(Process 4)   Java -DNodeNumber=4 CalculationNode
The script that starts up a each process is relatively simple, but not trivial since there are around 15 other parameters that are needed - THEY ARE IDENTICAL FOR ALL PROCESSES
I need to be able to restart a process if it fails with the SAME NodeNumber parameter. In other words - if Node 3 fails, I need to restart it as Node 3.
Answer: I'd argue that if a process fails, you need to fix it in order to not fail anymore.
To do what you expect, something like this would suffice (untested, use at your own risk):
<code>#!/bin/bash
for i in $(seq 1 4)
do
  (
    echo "Starting node $i..."
    while ! java -DNodeNumber=$i CalculationNode
    do
      sleep 1
      echo "Restarting node $i..."
    done
  ) &
done
wait
</code>
Each process has to finish with exit code zero in order to break the loop. Otherwise, it is restarted by the script.
Answer: Juliano's solution might work in simple cases, but it doesn't cover every situation. For example, one of your processes could exit with exit status 0 even though an error occured, if there is an error in the error handling code. Or it could deadlock or run into some other kind of infinite loop without doing anything useful.
So if you want a fancier solution, try Nagios. It allows you to write plugins for special monitoring tasks.
Answer: You could always use daemontools to monitor and restart your processes.


Why does returning a String not count as an expression of type Show x?

Question: Can anyone help me understand why this code produces a compilation error?
hello :: (Show x) => x
hello = "Hello"

I thought String had the properties of Show, so the function should be able to return a String? Here is the error message:
• Couldn't match expected type 'x' with actual type '[Char]'
  'x' is a rigid type variable bound by
    the type signature for:
      hello :: forall x. Show x => x
    at script.hs:160:1-25
• In the expression: "Hello"
  In an equation for 'hello': hello = "Hello"
• Relevant bindings include
    hello :: x (bound at script.hs:161:1)

Comment: `"Hello"` is a *string*. By using a signature `Show x => x`, you promise that for *any* `x` that is a member of the `Show` typeclass, your function will produce a value, but that promise does not hold, since you only do this if `x ~ String`.
Comment: What are you trying to accomplish? Print out the message? Cast the string to any `Show` type? Cast any `Show` type to a string?
Comment: See also [Why can a Num act like a Fractional?](https://stackoverflow.com/q/42820603/791604).
Comment: @Aplet123 I was just playing around with generic type signatures, I wasn't trying to cast anything. My only goal was to get it to compile :) But I misunderstood what generic types signatures actually mean in Haskell. It's cleared up now.
Answer: Your type signature doesn't mean what you think it means.
From your explanation it seems that you read this signature something like "I'm going to return you a value of some type x that has an instance of Show. I'm not going to tell you what type it will be exactly, but I promise it will have an instance of Show"
But what it really means is "pick a type, any type, just make sure it has an instance of Show, and I promise I will return you a value of that type"
In other words, when a function is generic, it's the caller of the function who chooses what the generic type will be, not the implementer.
Comment: This makes a lot of sense. I was conflating the concept of Haskell type classes with interfaces from imperative languages like Java
Comment: Well, type classes actually _are_ very much like interfaces in Java, especially in this particular case where the type class has a single parameter. Your function would be roughly equivalent to something like `X hello()` in Java.
Comment: @FyodorSoikin they're not the same in this case, actually. Java doesn't support return type polymorphism except as the OP understood it.
Comment: Isn't [this](https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#emptyList()) an example of return type-polymorphic method @is7s?
Comment: I didn't say Java does not support return type polymorphism at all. I said it only supports it in the way the OP understood it. In the example you linked to, `emptyList()` will always return a concrete value and does not depend on the context. Which is equivalent to the 1st definition in your answer. And is not equivalent to how return type polymorphism works in type classes.
Comment: Actually, `emptyList()` will return a value of type that _the caller chooses_. I mean, it will be wrapped in `List<>`, but the element of the list, which is the generic parameter of the function, is chosen by the caller. `emptyList` itself doesn't choose its generic parameter, the caller does. This is equivalent to my second definition, not first.
Comment: In my comment, I said `emptyList()` will always return a _concrete value_ and not a _concrete type_. Which is still not how type classes operate and still equivalent to your 1st definition :)
Comment: That only means that Java doesn't have type classes - i.e. different behavior depending on types. But it still has parametric polymorphism, including in return type. And it's the exact same as in Haskell. Compare Java's `emptyList()` to `emptyList :: [a]; emptyList = []`
Comment: I think we are in agreement here. One of the main differences between OOP interfaces and type classes is how they behave with return type polymorphism. And the reason why I started this was your statement above _"type classes actually are very much like interfaces in Java, especially in this particular case where the type class has a single parameter"_, which is not accurate. And I also never stated that Java does not support parametric polymorphism. Cheers.
Comment: The difference between return types in Haskell and most OOP languages is also nicely explained [in this answer](https://stackoverflow.com/a/33702641/9992041) to a similar question


How to combine a continuous effect into a function that is for discrete outcome

Question: I have a function like this:
log (P(1)/P(0))= a+ sum(h(x))+ g(x),
where a is the intercept, h(x) is a binary outcome: 1, or 0.
g(x) is a continuous variable that contribute to the log of a correct response over an incorrect one.
However, the sum(h(x)) is discrete, while the g(x) is continuous.
How can I change this function to incorporate both.
Should I change it to log (P(1)/P(0))= a+ sum(h(x))+ log(g(x))?
Answer: You don't have to change anything. What you described is logistic regression, which is for binary outcome variables. However, g(x) is not an outcome variable so it does not matter whether it is binary, discrete, or continuous.


What is the earliest compatible version of Rails with Bundler 2.0.1?

Question: What is the earliest version of Rails I need to use in order to be compatible with bundler 2.0.1?
Answer: Rails 5.1.3
In Rails 5.1.2 and below, the following incompatibility error appears upon running bundle install:
Bundler could not find compatible versions for gem "bundler":
  In Gemfile:
    rails (= 5.1.2) was resolved to 5.1.2, which depends on
      bundler (< 2.0, >= 1.3.0)

  Current Bundler version:
    bundler (2.0.1)
This Gemfile requires a different version of Bundler.


Client packets not arriving to wireguard server

Question: This is my wireguard client config:
[Interface]
Address = 184.108.40.206/32
PrivateKey = <private>

[Peer]
PublicKey = <server-pubkey>
Endpoint = <server-ip>:50123
PersistentKeepalive = 25
AllowedIPs = 22.214.171.124/24

I see in wireshark Handshake Initiation and Source and Destination addresses are correct, but I am not getting responses from server.
But when I run tcpdump -n -X -i ens160  udp port 50123 on server I see nothing.
I thought there was a problem with the firewall, but no. I tried to send something over socat
socat udp:<server-ip>:50123 -  and it worked (tcpdump printed results).
But server cant still receive packets (datagrams) from wireguard client.
I tried workaround using socat as a relay:
socat udp-listen:50123  udp:<server-ip>:50123

and changed Endpoint = <server-ip>:50123 to Endpoint = 127.0.0.1:50123
And it started to work. But why it works over socat and not using direct connection?
I have this versions:
client: wireguard-tools 1.0.20210914-1 (archlinux)
server: wireguard-tools 1.0.20200513-1~20.04.2 (Ubuntu 20.04 LTS)
PS: I tried same client setup on android and it worked, there must be some problem with archlinux version.
Dmesg says this (on achlinux):
[12592.005135] wireguard: wg0: No peer has allowed IPs matching 188.8.131.52
[12595.005999] wireguard: wg0: No peer has allowed IPs matching 220.127.116.11
[12595.006217] wireguard: wg0: No peer has allowed IPs matching 184.108.40.206
[12595.014611] wireguard: wg0: No peer has allowed IPs matching 126.96.36.199
[12595.777939] wireguard: wg0: No peer has allowed IPs matching 220.127.116.11
[12596.007290] wireguard: wg0: No peer has allowed IPs matching 22.214.171.124
[12596.007428] wireguard: wg0: No peer has allowed IPs matching 22.214.171.124
[12596.817910] wireguard: wg0: Handshake for peer 43 (<server-ip>:50123) did not complete after 5 seconds, retrying (try 2)
[12596.817942] wireguard: wg0: Sending handshake initiation to peer 43 (<server-ip>:50123)

Where <server-ip> is IP of server but I must keep ip secret so I replaced it with this keyword.
Comment: Nikita Kipriyanov, what do you think? I have problem that I described above and I need help. I am newbie in wireguard configuration and I dont know any reasonable information technology management practices about that problem.
Comment: It's probably not related, but do you really use `188.8.131.52/24`? Do you represent [IBM](http://ibm.com/) (who owns this address block)? If not, you are not allowed to use this address range for anything. You only allowed to use public addresses which you bought or private addresses described in RFC1918. And no, this is not a minor issue.
Comment: "Questions should demonstrate **reasonable information technology management practices**."
Comment: I changed ip number from 9 to 10, but problem persist.
Comment: But that doesn't explain the problem of why it works over socat.
Comment: I tried exactly same setup as described above without socat on mobile LTE (over hotspot) and it worked. There must be some problem with my router or ISP.
Comment: Problem might be with my asus RT-AC750 router.
Answer: I think your problem is in the /32 in the client address. That way the interface can only reach itself. Try it like this:
[Interface]
Address = 10.0.0.2/24
PrivateKey = <private>

[Peer]
PublicKey = <server-pubkey>
Endpoint = <server-ip>:50123
PersistentKeepalive = 25
AllowedIPs = 10.0.0.0/24

Comment: But this does not explain why I can connect using lte network, but not over my ISP. It also works over socat with my ISP.
Comment: are you using wg-quick @T0maas ?
`# wg-quick up /etc/wireguard/`
Comment: Yes i am using wg-quick
Comment: There may be problem with TTL, how can I set TTL in wireguard config?
Comment: Can you try to upgrade the server version? It could be the problem.. If you have virtualbox, just run archlinux live and try it without installing new OS - just get the latest iso and `pacman -Sy wireguard-dkms wireguard-tools`


A multi-label classification for tagging short text

Question: I am fairly new in the area of text mining and want to practice my skills a little. I have the following task at hand which I want to work on. I have a large list of short texts (~100.000) and every text has on average 3 tags / labels assigned to it. What I want now is train a predictive model, with which I can assign labels to new unseen texts. The assumption about the labels is, all existing labels are included in my dataset.
I started with python sklearn and a basic tf.idf matrix representation combined with an one-vs.-rest support vector classification for each label, but the mean f1 score for that model are very low. Are there better ways of creating a predictive model for that kind of task?
As I mentioned before, this area is quite new to me so a little advice on how to tackle this problem would be more than welcome (e.g. some literature ?).
Comment: A similar (?) problem was once a [Kaggle competition problem](https://www.kaggle.com/c/facebook-recruiting-iii-keyword-extraction), so check the forums to learn more what approaches were used by participants.
Comment: Excuse me, I am also very interested in this topic, so can you share your multi-labeled short text database? Thanks so much!
Answer: You'll want to familiarize yourself with multi-label classification, to better understand the problem you're working on. Tsoumakas et al is a good review to start with. Python scikit actually has multilabel classification functionality built in, so that might be a good out-of-the-box solution for you!
Answer: Make sure to remove stopwords and useless terms before training the model. I usually run such a classification model using Rapidminer and a single label, it works fine.
Answer: Take a look at Andrea's Esuli MP-Boost [LINK]. It is a multi-label variant of AdaBoost. It scales pretty well to large datasets and is quite efficient. The only downside perhaps is that you cannot restrict natively which label combinations are authorized (e.g. you may not want to label X and Z to be predicted at the same time for a short text). This might not be a problem for your application, though.
Answer: You can use SVM to build a one-vs-all classifier based on collection of labels that you can use to train the algorithm.
here is a couple of links that might help you.
http://www.sanjivk.com/pSVM_ICML13.pdf
http://www.icmla-conference.org/icmla10/CFP_Tutorial_files/hakan.pdf
Cheers!
Comment: Could you add a few more details about your suggested approach to help the OP understand where this recommendation is coming from?
Answer: If you feel like throwing Deep Learning at it might be a good idea, feel free to look at Magpie. Bear in mind though, that you need large labelled dataset in order for it to work well.