Not confident enough to play guitar loudly because neighbours will hear it

Question: I am playing guitar (mostly Acoustic Guitar) for like 2 years now so i wouldn't say that i completely suck. i can play numerous songs and strum chords fairly and easily. Although every day is a new day and i want to improve my guitar playing. But i live in a building where the walls are very thin and rooms are very close to each other. I can hear people even if they are just talking on the phone, so it's fair to assume that the sound of my guitar would be broadcasted to the whole building very easily. I get anxious about it and thats why i always strum and play notes slowly and quietly without aggression. Most of the time, i am playing without a pick. No one ever complained or told me to shut up though and once i even got a compliment from 1 neighbour when i was playing karma police(I love Radiohead) but that feeling still wont go away. I also believe that i have developed a bad technique on the picking hand just because of this.
I am very very very passionate about music. i even want to learn more instruments but for now i only have guitar with me. I love playing and practicing it and i want to keep on improving and learn new licks and skill but it takes a while to get the hang of it while making noise in the process and i feel that playing quietly is kinda holding me back. I know it sounds stupid but how do i get this out of my head while playing or any other alternative?.
Comment: In addition to my answer below I also wanted to share my answer to another question on Stack Exchange Music where I expand on how to develop a more relaxed mindset including tricking your own brain to overcome performance anxiety and the natural fear of being judged.  The second half of the content in the following link is all about shifting your mental focus to be less self conscious.  Click this link (https://music.stackexchange.com/a/40356/16897) and read the second half.  I think it will help with the psychology.
Answer: A lot of musicians have this problem, so you are not alone with being anxious about your playing. If you are playing rock, I guess you are using an electric guitar. So you should be able to plug headphones in your amp. The sound of an "unplugged" e-guitar is in no way a form of disturbing your neighbours.
Using headphones also gives you a more direct sound to the ears, so you can improve the quality of your playing with listening closely. Moreover the music often needs to be really loud, which can easily being achieved using headphones.
It is also of good use if you start playing over some music you are playing on your stereo. You get the flow, start to jam some guitar solo and will "warm up" yourself. After this intro it will give you some confidence and a nice way to get a groove going.
I also know a band with a DJ always giving some tunes for the band to dive in and slowly fades out the recorded music, so it is a smooth transition to the live sound.
If using headphones or using some guide track in the background still does not make feel you good, you should maybe start playing with other musicians or in front of some friends. This is much more challenging, so it will become more easy for you to just have your neighbors listening.
Making recordings of your playing and listening to it may also help. You can get some reference, and a feeling for what you sound like. Every day lets you become better, so you can look back some time and get an overview for what you have already achieved.
Some Reverb can also make you sound better when you are playing slowly to practice something. You can always try to optimize your sound, take advantage of your audience to keep your expectations high and keep on making good quality music. Most important: enjoy yourself and feel the sound you are creating.
Comment: Thank you for the suggestions. i do record my self regularly and see where i screwed up and start improving on next attempt. i am mostly into rock and metal music and i dont know anyone around who likes the same style  as me, so i am mostly playing alone in my room.
Comment: There are platforms for online collaboration, if you would like to give a try https://www.musicianwave.com/10-great-music-collaboration-websites-and-apps/
Answer: That is an excellent question and I can relate to what you are feeling. When I first started learning to play guitar and sing I got to a point where I was perfectly comfortable home alone on my couch singing and playing for the furniture. But bring an audience of even one person in the room and all of a sudden I couldn't get my fingers to work and could not even play a basic chord! It sounds like you are experiencing the same "stage fright" that I endured for a time.  Even though nobody is sitting in front of you, you perceive that they are listening and the fact that one of your neighbors commented on your playing confirms that in your mind.
The good news is those feelings are perfectly normal for most humans. And almost everyone eventually learns to overcome this natural phenomenon. Once you overcome this self conscious fear of being judged, you will relish every opportunity to perform for others (live).  Sharing your music with others and playing with other musicians will take your enjoyment of playing your instrument to a whole new level and you will become even more passionate than you are now.
I am sure you set goals for yourself in terms of improving your guitar skills.  It takes deliberate work and practice to achieve each of these goals.  Nothing comes automatically in the beginning, but the more you practice, the more automatic many aspects of your playing become.
Make it a goal to develop your confidence (along with your playing skills) to a point where you become not only comfortable playing for an audience, but seek out opportunities to share your music with others.  Consider what steps you might take towards accomplishing that goal.
One obvious first step might be get to a point where you can play loud enough for your neighbors to hear you.  You might start by playing some songs you are very comfortable playing, such as the Radiohead song you have already received positive feedback on.  What other songs can you play as well as you play that song?
Practice particular songs over and over either using a very thin pick, finger picking, or an electric guitar with a headphone amp.  Once you have 3 that you feel you can play with some level of competence, make that your first "set list".  Then conduct a performance for your unseen "audience" (neighbors behind the walls) by playing your three song set as you normally would if you were sitting in a cabin in the woods all alone.  Consider this an exercise towards accomplishing a goal.  Continue to build on your initial "set list" adding new songs regularly and extending the length of your "concerts".
Eventually you will become comfortable enough to take the next step towards your goal of loving to perform live and invite a friend over to listen to your performance. Bolstered by the inevitable positive feedback your next step will be a group of friends, eventually working up to performing a 15 minute set at an open mic.
Always keep this in mind - you play better already than almost every one of your neighbors because they don't play an instrument at all.  You will find that many folks will admire the fact that you can play even a basic three chord strumming song because most folks can't even play a C chord much less put three chords together with the proper rhythm and timing.  You are able to do something that very few if any of your neighbors can do.  They will be envious of your ability, regardless of your current skill level.
Overcoming "stage fright" is a normal part of your evolution as a musician.  Like every other skill you develop as you progress on your instrument, it will be a deliberate process and take work.  But the enjoyment you will derive from sharing your music with someone other than yourself will make it worth the effort.
Good luck and enjoy the journey.
Comment: That is what it feels like. And Thank you so much for the suggestions as i am also reading the link you shared. I play guitar because i like it and even if i am not sharing it with anyone or playing with anyone, i still enjoy it because it makes me feel good. Sadly no one in my friend circle plays any instrument or have same taste so its hard to find someone who does. I have variety of songs in my catalogue ranging from Radiohead, Arcade fire to Iron maiden. i mostly play soft stuff when i play loud because i feel that metal sound would rile up the neighbours and i don't wanna disturb them
Answer: Well, my first idea is screw your neighbors and dont care about them. Second thought would be headphones. If that still bothers you, maybe try practicing somewhere else, like at a friends house, music studio, or as a street performer. If youre good, your neighbors probably wont even mind you practicing for a little time each day,.
Comment: Thank you for the suggestions :) i mostly play on fixed schedule so they know when i am going to practice and i never really practiced outside but will try to do that
Comment: Ayy my pleasure. I like to practice instruments outside a lot. If you dont have allergies, its a pretty easy way to get some coin and make some other people happy, just as long as you're good at playing that is. ;)
Comment: So a little disclosure: I am a super introvert and with a guitar you can imagine. But playing alone outside is something i never really did but will try to do that more often
Comment: Yeah I get that. I have a lot of introvert/shy friends, but the thing with street performing its that usually people just toss money, and walk away. Theyre not gonna get into a full on conversation (unless its that drunk guy in the blue hoodie, but thats another story) or anything like that. Some people also prefer to maybe just go out to the back yard or a park. Idk what youre gonna like the most, but playing outside is definitely a lot of fun.
Answer: you can get a sound hole deadener - a rubber plug you stick in the sound hole which reduces the boom effect - easily found on ebay but measure your sound-hole carefully. You can also try sticking some foam or sponge under the strings at the bridge to reduce the noise. There are also travel acoustic guitars which only use piezo electonics and so are silent in the audible sense but use a preamp and headphones
.
Answer: Too bad for the neighbors.  You gotta practice.  If neighbors have complained I'd try asking what times would work for them.  Right now with the pandemic everyone is at home.  But in general, if you have an hour of time where they aren't home then you have no worries.
As for technique, this may be a golden opportunity for you.  Many players play TOO HARD and cannot control dynamics.  There also seems to be a natural tendency for people to correlate Fast and Hard.  So it becomes very difficult if not impossible to  play fast and soft!  There is every reason to develop the ability to separate speed and dynamics.  In fact some classical guitar instructors encourage students to intentionally play with a soft touch until a piece is mastered and memorized, then add stronger dynamics to it.  You get much better control.
Comment: I am self taught, so all the suggestions from everyone here are very helpful and i will keep that in mind.
Comment: Thank you for the suggestions. They never complained and i play on fixed schedule so they kind of know it but i still play softly. I am not trying to shred or sweep picking etc because i feel that its too early for me to do that. i am trying to improve with additional stretchy chords, fingerpicking and songs with odd time signatures.
Comment: I must have misread your post.  The comment I made about playing softly has nothing to do with shred.  It is a valid technique for any style.
Comment: Got it.  If you're worried about not sounding good you won't get better without practice.  It's a natural thing.  I am studying voice and it's very difficult to sing full volume when I'm not sure it will be in tune.  But it will sound like crap if I don't so I do it any way.
Comment: "once i even got a compliment from 1 neighbour when i was playing karma police" This is the quote.  I misread complement as complaint.
Comment: exactly. i want to practice daily and want to play to my full potential. and that compliment should have boosted my confidence but still i am very anxious about other people hearing
Comment: That is natural.  You'll get over it in time.


Freshly installed CentOS does not boot from Dell's Perc H700 RAID

Question: Installed a fresh CentOS 5.10 installation on RAID5 provided by Perc H700 Integrated RAID, however the system fails to boot.
Checked the system via recovery CD, and noticed that CentOS 5.10 now uses GPT instead of MBR. Updated H700 to latest firmware version, same result.
Previous version of CentOS (5.x circa 2011) worked just fine on this server.
Any idea how to make the RAID recognize the partition / boot record and start the system?
Comment: Um, how large were the drives?
Comment: 3TB each, if I remember correctly
Answer: Solved by splitting to two VD's, one small with just enough space to contain the boot partition, and the other with the rest of partitions.


How do I include a CSS library in my custom module?

Question: I want to include the YAMM!3 CSS library in my Drupal 8 site. To that end, I wrote a custom module following the instructions in this answer. Although that answer is in regards to a php library, I thought it would also work for a CSS library.
This is the composer.json from my custom module:
{
  "name": "drupal/my_yamm3",
  "type": "drupal-module",
  "require": {
    "geedmo/yamm3": "*"
  }
}

In the composer.json in the root of my Drupal codebase, I have this:
"extra": {
    ...
    "merge-plugin": {
        "include": [
            "core/composer.json",
            "modules/custom/my_yamm3/composer.json"
        ],
    ...

I updated my codebase with this commands:
$ composer update
$ composer dumpauto

And I noticed this line in composer's output:
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing geedmo/yamm3 (1.1.0): Loading from cache

Which is confirmed by an examination of the filesystem:
$ ls vendor/geedmo/yamm3/
bower.json  composer.json  demo/  gulpfile.js  index.html  LICENSE.txt  package.json  README.md  yamm/

I've enabled the my_yamm3 module on my site, and under admin/config/development/performance, I've disabled css aggregation.
However, when I load the page, I do not see the yamm libraries being loaded in the network tab in my browser.
Am I using the correct method to load a third-party css library? What am I doing wrong?
EDIT osman asked for some confirmation of the state of my environment. In my drupal project root, while I do have /composer.json and the directories /drush/ and /vendor/, I don't have /scripts/ nor /web/. I guess that means I am not using the drupal-composer/drupal-project project.
Regarding his recommended additions to composer.json, this is what I had:
"extra": {
    "installer-paths": {
        "core": ["type:drupal-core"],
        "modules/contrib/{$name}": ["type:drupal-module"],
        "profiles/contrib/{$name}": ["type:drupal-profile"],
        "themes/contrib/{$name}": ["type:drupal-theme"],
        "drush/contrib/{$name}": ["type:drupal-drush"],
        "modules/custom/{$name}": ["type:drupal-custom-module"],
        "themes/custom/{$name}": ["type:drupal-custom-theme"]
    }
},

So again it looks like I don't have the composer project?
Comment: You were already on the right way. `composer-merge-plugin` plus `custom-installer`. Then you define a location for third party theme libs like for example `web/themes/custom/MYTHEME/libs/{$name}`. And in your custom module's `composer.json` you reference the library directly from GitHub tagging it with the `custom-installer` type defined before. See step-by-step https://drupal.stackexchange.com/a/260766/15055
Comment: Ah OK, sorry, now I see your main problem actually is that all you've forgotten is to bind the lib from `MYMODULE.libraries.yml` and then simply attach it to every page with `hook_page_attachments` from within `MYMODULE.module`. See [Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 module](https://www.drupal.org/docs/8/creating-custom-modules/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-module).
Answer: Fundamentals
To bind a CSS library into your Drupal installation, it should be defined and exposed via a *.libraries.yaml file.
For example (taken from core's classy theme):
book-navigation:
  version: VERSION
  css:
    component:
      css/components/book-navigation.css: {}

defines that there is a library called book-navigation that when included in a page will deliver the css/components/book-navigation.css css file.
Using composer with 3rd-party CSS libraries
Composer works easily and reliably for PHP dependencies, using the merge-plugin in the way you started working in the OP. But, CSS and Javascript libraries, especially when some preprocessing or building step is required, are a different story.
This is an open and unsolved (to my knowledge and to the date) problem, you can read this issue to get an idea of what problems arise:

https://www.drupal.org/project/drupal/issues/2873160

The main problem is, that when you import the library as a composer dependency, as you did, the library is installed inside the vendor directory wherever that is located. So, you cannot assume much inside your *libraries.yaml file about the file path to the CSS/JS file(s) you want to use.
Alternative (A) without composer: using CDN / externally hosted libraries definitions
For you case, and taken that you want to include this file:
https://raw.githubusercontent.com/geedmo/yamm3/master/yamm/yamm.css

you could define it inside your *libraries.yaml file as an externally hosted library (see #external):
my_module.yamm3:
  remote:  https://raw.githubusercontent.com/geedmo/yamm3/master/yamm/yamm.css
  version: VERSION
  license:
    name: MIT
    url: https://github.com/geedmo/yamm3/blob/master/LICENSE.txt
    gpl-compatible: true
  css:
    theme:
      https://raw.githubusercontent.com/geedmo/yamm3/master/yamm/yamm.css : { type: external }

N.B.: This approach should always deliver the latest yamm.css version.
Alternative (B) without composer: keeping a local copy in your own module's folder
If you place the CSS file inside your module's folder, e.g. css/yamm.css, you will be able to use the following yaml definition in your *.libraries.yaml file in order to be able to use it:
my_module.yamm3:
  version: VERSION
  css:
    theme:
      css/yamm.css : {}

Attaching a library to page(s)
Finally, after you are done defining your library, you can start using it.
This is documented extensively here (https://www.drupal.org/docs/8/creating-custom-modules/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-module) and I would recommend reading that if you haven't already.
Good luck!
Comment: for Alt. B, is one of the `css` lines supposed to be the name of my current theme? I used `hook_page_attachments_alter` and I'm getting this `User warning: The following theme is missing from the file system: css in drupal_get_filename() (line 268 of core\includes\bootstrap.inc).

drupal_get_filename('theme', 'css') (Line: 291)
drupal_get_path('theme', 'css') (Line: 394)
...
Drupal\Core\Asset\LibraryDiscovery->getLibraryByName('css', 'yamm.css') (Line: 54) ...`
Comment: Nope, this approach is theme independent. Can you give an example of how you call `hook_page_attachments_alter`?
Comment: Looke like this: `function my_yamm3_page_attachments_alter(&$build) {
  $build['#attached']['library'][] = 'css/yamm.css';
}`
Comment: That should be `$build['#attached']['library'][] = 'my_module/my_module.yamm3';`: you need to use the machine name of the module and the library, not the filepaths or filenames. See https://www.drupal.org/docs/8/creating-custom-modules/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-module#pages
Answer: More likely your vendor directory is off of the web root. Could you confirm that?
If you by any chance using drupal-composer/drupal-project project, it would have a folder structure like this:
/composer.json
/drush/
/scripts/
/vendor/
/web/
/web/core/
/web/libraries/
/web/modules/
/web/profiles/
/web/sites/
/web/themes/
...

The libraries folder is the folder you need your YAMM!3 CSS library placed in. So that it could be accessible via web also.
In my composer.json file I have Drupal specific folders defined in extra.installer-paths:
...
"extra": {
    "installer-paths": {
        "web/core": ["type:drupal-core"],
        "web/libraries/{$name}": ["type:drupal-library"],
        "web/modules/contrib/{$name}": ["type:drupal-module"],
        "web/profiles/contrib/{$name}": ["type:drupal-profile"],
        "web/themes/contrib/{$name}": ["type:drupal-theme"],
        "drush/contrib/{$name}": ["type:drupal-drush"]
    }
}

With the help of composer/installers package and the configuration in extra, each package required by composer is copied to their own dedicated folders. So, yours could be copied into libraries folder.
Check out the code and documentation at https://github.com/drupal-composer/drupal-project
It should provide all the details for you to update your project to support what you need. Otherwise come back for more :)
Comment: Thanks for clarifying. Loading a (CSS or JS) library would easily be done via implementing `hook_page_attachments()` hook. This could be done more easily if you define a `yourmodule.libraries.yml` file for the YAMM!3 library. @Stefanos Petrakis's answer covers that part. And my answer was focusing on how to define an external Composer package as a dependency and install it as a library item.
Comment: I made an update to my question, from what I understand, it looks like I don't have the drupal-composer project. Is that necessary for this to work? Is there another way to install a CSS library?
Comment: Hi user1359, is the real issue not being able to install YAMM!3 CSS library via composer, or once installed not being able to load the library on required pages?
Comment: of course, my ultimate goal is to get the YAMM!3 library loaded. How I do that, I don't really care. I googled how to do that, and found the instructions that I linked, and the only way I can tell whether it worked or not is if the library loads or fails to load. I am not aware of any other way to test that.
Comment: thanks for taking the time to write out this very detailed answer and help me understand my situation : )
Answer: Drupal 8 does not allow for an easy way to set up libraries that use files in the vendor directory. To get around this, I just created the Vendor Stream Wrapper module, which creates a vendor:// stream wrapper, allowing for linking to files in the vendor folder, even if it is outside the webroot.


Jekyll remote theme "Could not find compatible versions" issue

Question: I was about to install Jekyll theme using Remote Theme Method, but couldn't install with this message:
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Could not find compatible versions

    Because github-pages >= 135, < 178 depends on minima = 2.1.1
      and github-pages >= 44, < 147 depends on liquid = 3.0.6,
      github-pages >= 44, < 178 requires minima = 2.1.1 or liquid = 3.0.6.
(1) So, because github-pages >= 178 depends on jekyll-sass-converter = 1.5.2
      and github-pages >= 28, < 44 depends on jekyll = 2.4.0,
github-pages >= 28 requires minima = 2.1.1 or liquid = 3.0.6 or
jekyll-sass-converter = 1.5.2 or jekyll = 2.4.0.

    Because github-pages >= 9, < 14 depends on kramdown = 1.2.0
      and github-pages < 9 depends on kramdown = 1.0.2,
      github-pages < 14 requires kramdown = 1.0.2 OR = 1.2.0.
    And because github-pages >= 14, < 32 depends on kramdown = 1.3.1,
      github-pages < 32 requires kramdown = 1.0.2 OR = 1.2.0 OR = 1.3.1.
And because github-pages >= 28 requires minima = 2.1.1 or liquid = 3.0.6 or
jekyll-sass-converter = 1.5.2 or jekyll = 2.4.0 (1),
one of minima = 2.1.1 or liquid = 3.0.6 or jekyll-sass-converter = 1.5.2
or jekyll = 2.4.0 or kramdown = 1.0.2 OR = 1.2.0 OR = 1.3.1 must be true.
    And because jekyll >= 4.3.0 depends on jekyll-sass-converter >= 2.0, < 4.0,
jekyll >= 4.3.0 requires minima = 2.1.1 or liquid = 3.0.6 or kramdown =
1.0.2 OR = 1.2.0 OR = 1.3.1.
    And because jekyll >= 4.3.0 depends on kramdown >= 2.3.1, < 3.A
      and jekyll >= 3.5.0 depends on liquid ~> 4.0,
      jekyll >= 4.3.0 requires minima = 2.1.1.
    So, because Gemfile depends on jekyll ~> 4.3.2
      and Gemfile depends on minima ~> 2.5,
      version solving has failed.

How can I solve this problem?
I tried to change version numbers of following code in Gemfile, but it doesn't work. Do I change into wrong number? Or this solution is wrong?
gem "jekyll", "~> 4.3.2"

Answer: https://pages.github.com/versions/
Dependency  Version
jekyll      3.9.3

Change to gem "jekyll", "~> 3.9.3" and you should be good to go.


What are Android Architecture Components,LiveData and ViewModel?

Question: As a  beginner it is very hard to understand what are these things
Is there any resource which can give a grasp knowledge of  things in easy language?
Comment: Have you looked at https://developer.android.com/topic/libraries/architecture/index.html ?
Comment: yes but it is hard to understand
Answer: In simple words:
For a long time Google didn't give any indication to developers on how they should write (architecture wise) their apps. But last year they've released a set of libraries that guide developers on how to structure their code by structuring the app in clear layers and reinforcing good practices. That's what they call architecture components.
LifeCycle, LiveData, ViewModel and Room are the main classes in these libraries. They go well with a MVVM architecture and if you apply them correctly (according to Google) your app will be easy to maintain and test.
As for resources, you can check the Google I/O release talk and the documentation. You can also find many online tutorials to get you started.
If you know nothing of android development it will be hard to understand the use of these components so I would advise you to study more about the SDK and then go back to these components. Note as well that you need to know about Reactive Extensions for android and java/kotlin too because these libraries rely a lot on them.


This residues calculation is correct?

Question: We have $f(z)=\dfrac{1}{\sin(z)}$ in $z = k\pi , k = 0 , \pm 1 , \pm 2 , \dots$
I used the formula: $Res(f/g, a)=\dfrac{f(a)}{g'(a)}$
Then
$Res(f, k\pi)= \dfrac{1}{\cos(k\pi)}=(-1)^k$.
is correct?
Answer: Answer for earlier version: what you have calculated is the residue of $\frac 1 f$ at $k\pi$. $f$ itself has no poles so residue of $f$ at any point is $0$. Answer for new version: yes, your calculation is correct.
Comment: I had written wrong. The function is $f(z)=\dfrac{1}{senz}$
Comment: Is that correct?

This residues calculation is correct?


Choosing the right threshold for a biometric trait authentication system

Question: I have a biometric authentication system that is using a person's gait to authenticate them. I extract features from gait, run it through a comparison versus a template and produce a similarity score (where if this similarity score is below a certain threshold, then the user is authenticated). So, I have 72 trials total (36 trials containing a positive case and 36 that contain a negative case). What I want to do is graph the ability of this system to authenticate people by illustrating it with a ROC graph.
Unfortunately, I don't quite understand how to choose a threshold. Is there some mathematical procedure involved for choosing a threshold for the similarity scores? Do I just choose a bunch of different thresholds, and graph the corresponding ROC curves for all these different threshold values? The resulting similarity scores vary from [0.6,1.2] where the positive cases tend to lie around 0.6. All my coding is being done in Matlab.
Comment: Have a look at the answers to [this question](http://stackoverflow.com/questions/2018178/finding-the-best-trade-off-point-on-a-curve) on Stackoverflow to find the 'elbow' in the ROC.
Answer: Generally, the cut-off value is chosen such as to maximize the compromise between sensitivity (Se) and specificity (Sp). You can generate a regular sequence of thresholds and plot the resulting ROC curve, as shown below, based on the DiagnosisMed R package.

Actually, the raw data looks like
<code>  test.values TP FN FP TN Sensitivity Specificity
1       0.037 51  0 97  0           1      0.0000
2       0.038 51  0 96  1           1      0.0103
3       0.039 51  0 91  6           1      0.0619
4       0.040 51  0 84 13           1      0.1340
5       0.041 51  0 74 23           1      0.2371
6       0.042 51  0 67 30           1      0.3093
</code>
and the optimal threshold is found as
<code>   test.values TP FN FP TN Sensitivity Specificity
47       0.194 43  8  8 89      0.8431      0.9175
</code>
To sum up, I would suggest to generate a regular sequence of possible thresholds and compute Se and Sp in each case; then, choose the one that maximize Se and (1-Sp) (or use other criteria if you want to minimize FP or FN rates).
Comment: Shouldn't "optimality" take into account the cost of false positives versus false negatives? I can imagine a scenario where a false negative is far more costly than a false positive, which should call for a criterion biased towards capturing as much as the true distribution as possible. Also, I believe you mean "sensitivity" and not "sensibility" in your answer.
Comment: @Mike Yes, your comment is really welcome and this was what I tried to point to in my last sentence (optimize FN/FP rates depending on the context). Thanks for noticing the typo (which was already addressed in a preceding post...)!
Comment: So just to clarify, I have my data in the range of [0.6,1.2], then I calculate the corresponding ROC curve for a bunch of thresholds in that range. I find the cut-off points in each of those ROC curves and I try to pin-point the one that has the maximum Sensitivity/Specificity combination. Is that correct or have I completely misinterpreted you?
Comment: @rohanbk Yes, that's basically the idea; e.g., compute Se/Sp and the four cells of your two-way table (TP, FN, etc.) in the range [0.6,1.2] (say with an increment of .05 or less -- it depends on the precision you can/want to attain in the future). Choose the compromise Se/(1-Sp) that best reflects your classification objective. Some references were provided to you in earlier threads. I don't really know if there are good MATLAB functions for ROC analysis, but I just found this page, http://j.mp/ekzg3m. HTH


OpsHub Team Project not found

Question: Earlier this week, we performed a migrated a Team Project from TFS 2010 to Visual Studio Online using the OpsHub Visual Studio Online Migration Utility.  We performed the migration as a test.  During this test migration we did not properly all of the users since we had yet to add everyone's Microsoft accounts to Visual Studio Online.
Our intentions were to run the migration as a test, verify that the changesets and work items were migrated properly, then delete and re-create the Team Project on Visual Studio Online.  At that point, we would migrate the Team Project again, over the weekend, and start active development against the new Visual Studio Online Team Project on Monday.
When I try to run the migration again, however, an exception is thrown when it's trying to create the configuration:

I can assure you that the Team Project exists on Visual Studio Online.  I can see it on the portal, and I can see it if I connect using Visual Studio.
What am I missing?  Why did the migration work initially, but fail when I try to migrate again, after deleting the initial Team Project and re-creating it?
Answer: I am not sure how my Visual Studio Online Team Project got into the state that it was in, however I was able to finally re-migrate. Once again, I deleted my Team Project, this time also deleting all of the associated Team Rooms (I'm not sure that this made any difference, but since they were named after the Team Project, I went ahead and deleted them). I then recreated the Team Project.
At this time, the OpsHub configuration was successful and the migration was able to start and proceed as expected.
Comment: Hi, It is quite likely the issue might be due to insufficient permission to the end point user for that project. Nevertheless, glad you could get it working. - OpsHub

OpsHub Team Project not found


drupal running really slow on apache mac os x

Question: I'm running drupal sites on my localhost with virtual host.
everything was running perfect but then it suddenly stopped working, I tried to restart apache to fix the error but still not working.
It takes about 30 seconds to load the home page, and about the same for other pages.
I'm running mac os x with Apache MySQL "no MAMP".
thats really confusing me more is that it runs only on firefox, on safari it takes forever and never loads.
Comment: Did you check the error logs? Disable non core modules and theme enable the moules one by one.
Comment: apache log shows no erros.
Comment: plus that its happening on all of my drupal sites on local machine, other non drupal sites work normally.
Comment: I mean drupal error log at your_drupal_site/admin/reports/dblog It will give you an idea.
Comment: dblog shows nothing out for the ordinary. the only thing logged is a notice of 404 page which i intentionally directed to to test it.
Comment: Which macos version are you using? In lion you can't use the .local domains anymore because lion will load very slow. more info here:
http://itand.me/mac-os-x-lion-local-domains-and-etchosts-oh-m
Comment: I'm using .dev, plus the problem only occurs with drupal sites. all of them
Answer: Install devel module in your drupal site. After enabling devel module, you need to enable query log and page timer in devel configuration page. by doing this you will see how much time each function is taking to load and will able to analyze you site.
Comment: devel module didnt catch any query with more than 5ms, but sometimes when I keep refreshing, it shows some queries of over 45ms.
Comment: Yes.. Mostly process is that you need to note down those query and search on drupal.org. Because its little difficult to imagine what problem you would be having from here. I think drupal.org would have some solution on that query. Just copy those query and paste into drupal.org search bar.
Answer: First thing I would check is the apache error log, for any ressource that is 404. It very well could be a logo or an image that is 404 (not found),  your page request will try loading the ressource for a certain time depending on your time-out settings,  before giving up and closing the request.
Comment: this is not the case since its a fresh installation of drupal.
Answer: I went to /etc/apache/users/saad.conf and added the virtual host in this form "www.x.dev" to the top of my virtual hosts list.
this temporarily fixed the problem.
hope this helps


How to get nested key value pair from dictionary with linq

Question: I have a lstSubs List<KeyValuePair<string, string>
which contain value

FNAME, "ABC"
LNAME ,"XYZ"
VAR001, "VAR002"
VAR002 , "ActualValueforVAR001"
VAR003, "VAR004"
VAR004 , "VAR005"
VAR005, "ActualValueforVAR003"

I have a String like envelop "Hello [FNAME] [LNAME] you have created a request for [VAR001] which got assigned to [VAR003]"
 var regex = new Regex(@"\[(.*?)\]");
                    var matches = regex.Matches(envelop.ToString());
                    foreach (Match match in matches)
                    {
                       columnValue = linq to get the value from the list based on key;
                       envelop.Replace(match.Value, columnValue);
                    }

in this, The straight Key,Value pairs are easy to get via Linq but I am getting tough time to fetch the complex values which are nested in terms of connected Key, Value.

is there any way in LINQ or have to go with a loop.
Expected Output : Hello ABC XYZ you have created a request for ActualValueforVAR001 which got assigned to ActualValueforVAR003
Thanks,
PS. The code is not complete. it's a part of entire code edited with an intention to make it concise to issue
Edited: some of my text was not visible due to formatting.
They Dictionary values are nested as I am creating them based on some conditions in which they got configured
Comment: You don't have a dictionary.
Comment: VAR001 points to VAR002, so do you expect the when string is replaced, VAR001 should replace with actual value of VAR002 and VAR003 should replace with actual value of VAR005?
Answer: First, let's turn initial List<T> into a Dictionary<K, V>:
  List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>() {
    new KeyValuePair<string, string>("FNAME", "ABC"),
    new KeyValuePair<string, string>("LNAME", "XYZ"),
    new KeyValuePair<string, string>("VAR001", "VAR002"),
    new KeyValuePair<string, string>("VAR002", "ActualValueforVAR001"),
    new KeyValuePair<string, string>("VAR003", "VAR004"),
    new KeyValuePair<string, string>("VAR004", "VAR005"),
    new KeyValuePair<string, string>("VAR005", "ActualValueforVAR003"),
  };

  Dictionary<string, string> dict = list.ToDictionary(
    pair => pair.Key,
    pair => pair.Value,
    StringComparer.OrdinalIgnoreCase); // Comment out if should be case sensitive

  // Some values can be nested
  while (true) {
    bool nestedFound = false;

    foreach (var pair in dict.ToList()) {
      if (dict.TryGetValue(pair.Value, out var newValue)) {
        dict[pair.Key] = newValue;
        nestedFound = true;
      }
    }

    if (!nestedFound)
      break;
  }

Then for a given envelop
  string envelop =
    @"Hello [FNAME] [LNAME] you have created a request for [VAR001] which got assigned to [VAR003]";

you can put a simple Regex.Replace:
  string result = Regex
    .Replace(envelop,
           @"\[[A-Za-z0-9]+\]",
             m => dict.TryGetValue(m.Value.Trim('[', ']'), out var value) ? value : "???");

  Console.Write(result);

Outcome:
  Hello ABC XYZ you have created a request for ActualValueforVAR001 which got assigned to ActualValueforVAR003

Comment: sorry for the trouble. but I think I wasn't able to put that up clearly. I need to traverse to find the ActualValue via keys.Thanks
Comment: @Amit Singh: I see; you have *nested* values; need some loop after initial dictionary creation; I've edited the answer
Comment: awesome, I actually did something the same, but your code is very clean. would be using this. Thanks for the help :)


Get a field from a table when using MAX function

Question: I have the following MySQL statement which is working well.
SELECT c.id, IFNULL(MAX(l.id), 0) as level_id
FROM course c
LEFT JOIN level l ON c.level_id = l.id
WHERE c.user_id = '123'
GROUP BY c.id

A course can have multiple levels so the IFNULL(MAX(l.id), 0) works by selecting the highest.
However, instead of returning the id of the highest level, I would like to get the name. I tried the following but MySQL doesn't like joining using a value in the select.
SELECT c.id, IFNULL(MAX(l.id), 0) as level_id, l2.name
FROM course c
LEFT JOIN level l ON c.level_id = l.id
INNER JOIN level l2 ON level_id = l2.id
WHERE c.user_id = '123'
GROUP BY c.id

I have simplified my statements in my questions (for readability), so hopefully the problem still makes sense.
Comment: The first query should give you an error as you have a WHERE clause in the middle of the JOINs (code looks the same as you 2nd query to me).
Comment: @Kickstart thanks for spotting, updated my question
Answer: With this type of query, I think the easiest method is the substring_index()/group_concat() trick:
SELECT c.id, COALESCE(MAX(l.id), 0) as level_id,
       SUBSTRING_INDEX(GROUP_CONCAT(l2.name ORDER BY l.id DESC), ',', 1) as name
FROM course c LEFT JOIN
     level l
     ON c.level_id = l.id INNER JOIN
     level l2
     ON level_id = l2.id
WHERE c.user_id = '123'
GROUP BY c.id;

Note that the WHERE is misplaced in your query.
Caveats on this approach:

You need a different separator if name might have commas.
There is an internal limit on the length of the group_concat() intermediate result.  If this is an issue, the length can be increased.
Comment: I do wonder if the 2nd join on to to the level table is necessary (would be if there is a dummy level with an ID of 0). However think the join condition will struggle anyway as I think it is meaning to use the result of an aggregate function (ie, to cope with the l.id of 0)
Answer: An alternative is to do a sub query and join the results of that back against the level table to get the level name:-
SELECT sub0.id, sub0.level_id, l2.name
FROM
(
    SELECT c.id, IFNULL(MAX(l.id), 0) as level_id
    FROM course c
    LEFT JOIN level l ON c.level_id = l.id
    WHERE c.user_id = '123'
    GROUP BY c.id
)
LEFT OUTER JOIN level l2 ON l2.id = sub0.level_id


Proof of Convergence of K-means

Question: $T(e_1) = e_1+5e_2$ $T(e_2) = 2e_1+4e_2$
$T(e_2-e_1) = e_1 - e2$.
What is the rank and nullity of T? Isn't this the rank and nullity of $e_1-e_2$?
Is this asking what the rank and nullity of  $[1 ,-1]'$ is? Isn't the nullity just 0. And isn't the rank $1$?
Answer: If you write down the matrix of $T$ in $e_1, e_2$ basis, you will get
$$
T=\begin{bmatrix}
1&2\\
5&4
\end{bmatrix}
$$
Matrix $T$ is non-degenerate $\det T = -6$, so matrix $T$ is of full rank, hence ${\rm rank} \; T = 2$.
According to rank–nullity theorem, nullity is zero.
Comment: Why is it not [1 5; 2 4]?
Comment: $T e_1 = [1\ 2;5\ 4] \cdot [1;0] = [1; 5]=e_1+5e_2$

Proof of Convergence of K-means


Exibir player na área de notificações do Android

Question: Criei um aplicativo que transmite uma Streaming da rádio, porem se eu "minimizar" o aplicativo ele continua tocando.
Então eu gostaria de saber como posso fazer para que abra uma box na lista de notificações do Android, tipo o aplicativo Play Música

Só que acredito que a verdadeira e maior diferença entre os aplicativos é que o meu da rádio é feito pelo Phonegap que se resume a HTML5 ao invés de java puro.
Comment: Sugiro fortemente que você leia: [Quando se deve colocar o nome da linguagem no título?](http://meta.pt.stackoverflow.com/questions/297)
Comment: Editei a pergunta, pois o problema e totalmente orientado ao phonegap e deve-se evitar usar tags irrelevantes, outra coisa retirei o link pois nao ajuda em nada com a duvida. Uma duvida Pedro, voce quer colocar o player aonde fica as notificacoes? Porque se for isto, entao pushs nao parecem fazer parte do problema (apesar de ficar no mesmo local), poderia explicar melhor?
Comment: Guilherme Nascimento, queria simplesmente que quando a pessoa minimizar o APP da rádio apareça uma cixa como a do Play Música só que somente com o botao de pausa e play e o ícone da radio?.. Sacas??
Comment: Por isto perguntei, o titulo fala sobre pushs, mas você da a entender que quer criar um Widget na lista de notificações. Ou seja a unica coisa que lhe perguntei amigo é "o que notificações tem haver com o problema", não perguntei por mal é que eu queria tentar melhorar o titulo da tua pergunta pra que mais pessoas possam se interessar e tentar responder a tua duvida :)
Comment: Resolveu seu problema?
Comment: De uma olhada neste exemplo no GitHub. Nele, possui o que você busca. https://github.com/iammert/RadioPlayerService
Answer: Você pode usar o Cordova Music Controls Plugin
cordova plugin add https://github.com/homerours/cordova-music-controls-plugin

É muito fácil de fazer a integração dele com seu app.
Answer: Você pode montar uma notificação personalizada, podendo acrescentar mais informações uteis para o usuário.
Ao montar sua notificação, caso deseje colocar seu proprio layout (e com isso mais informações pro usuario) precisaria adicionar a função "Builder.setStyle()".
Um exemplo seria assim:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
    .setSmallIcon(R.drawable.notification_icon)
    .setContentTitle("Event tracker")
    .setContentText("Events received")
NotificationCompat.InboxStyle inboxStyle =
        new NotificationCompat.InboxStyle();
String[] events = new String[6];
// Sets a title for the Inbox in expanded layout
inboxStyle.setBigContentTitle("Event tracker details:");
...
// Moves events into the expanded layout
for (int i=0; i < events.length; i++) {

    inboxStyle.addLine(events[i]);
}
// Moves the expanded layout object into the notification object.
mBuilder.setStyle(inBoxStyle);
...
// Issue the notification here.

A Google possui uma boa documentação para isso:
https://developer.android.com/guide/topics/ui/notifiers/notifications.html?hl=pt-br
Comment: Talvez este link seja uma boa dica, mas para uma resposta, seria importante transcrever as partes mais relevantes para que o essencial possa ser lido aqui no site mesmo. Dois links que podem ajudar a aproveitar melhor o SOpt: [Tour], [Answer] .
Comment: seria mais legal ainda ajudar com resposta que tenham haver com a duvida colocada, CITO 0 original "....maior diferença entre os aplicativos é que o meu da rádio é feito pelo Phonegap que se resume a HTML5 ao invés de java puro.",   sempre me parecceu que se manter dentro do topico eh importante @Bacco.
Comment: Olá, @CamilaYamamoto, note que meu comentário havia sido feito antes da edição do autor: https://pt.stackoverflow.com/posts/150911/revisions - Nos casos em que entender que o post não é resposta, lembre-se de usar as sinalizações do site (link "sinalizar", logo abaixo da postagem).
Comment: Entendi, voce esta muito correto. Mas nao percebi qualquer orienteacao para o @Nimai Marchiori com relacao a ele tratar de android , quando a duvida eh derecionada para cordova... ou ele esta bem colocado dentro do assunto?  Veja, pergunto porque gostaria de saber mais da politica do SO.


No route to host : ssh Error

Question: I have a laptop and a PC (email@example.com) , I usually connect the laptop to PC via ssh. But now when I try ssh -X email@example.com , it is showing the following error ssh: connect to host 172.16.13.151 port 22: No route to host. What could be the possible problem ?
Output of ifconfig is the following:
eth0
Link encap:Ethernet  HWaddr 2c:41:38:0d:bb:a2
UP BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo
Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:65536  Metric:1
RX packets:1750 errors:0 dropped:0 overruns:0 frame:0
TX packets:1750 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:134949 (134.9 KB)  TX bytes:134949 (134.9 KB)

wlan0
Link encap:Ethernet  HWaddr d0:df:9a:76:18:1e
inet addr:172.16.101.213  Bcast:172.16.111.255  Mask:255.255.240.0
inet6 addr: fe80::d2df:9aff:fe76:181e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:595855 errors:0 dropped:0 overruns:0 frame:0
TX packets:37917 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:138691381 (138.6 MB)  TX bytes:4733835 (4.7 MB)

output of route is the following :
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.16.96.1     0.0.0.0         UG    0      0        0 wlan0
link-local      *               255.255.0.0     U     1000   0        0 wlan0
172.16.96.0     *               255.255.240.0   U     2      0        0 wlan0

Output of traceroute 172.16.13.151 gives
traceroute to 172.16.13.151 (172.16.13.151), 30 hops max, 60 byte packets
1  172.16.96.5 (172.16.96.5)  456.381 ms  457.461 ms  457.448 ms
2  172.16.96.5 (172.16.96.5)  5007.656 ms !H  5007.665 ms !H  5015.906 ms !H

Comment: You can diagnose this further with `traceroute` command. Most likely your gateway router `172.16.96.1` is missing the route to `172.16.13.0/24` network.
Comment: @TeroKilkanen If it was missing the route it shouldn't take 5 seconds to respond. More likely it does have a route and sends ARP queries for the destination. But nobody answers the ARP queries so after 5 seconds it times out.
Comment: Please edit debug output like this always into the question, it is difficult to read from the comments.
Comment: I've modified the question including the `traceroute` part
Answer: The source 172.16.101.213 and the destination 172.16.13.151 are not on the same network (based on the netmask 255.255.240.0). Thus your laptop is sending the packets to the default gateway 172.16.96.1, which apparently does not know the route to your PC.
Comment: In hex notation the netmask is `ff.ff.f0.00`, the source address is `ac.10.65.d5` and the destination address `ac.10.0d.97`. The first five hex digits should be equal for the addresses to be on the same subnet.
Comment: `@Johan Myréen`I think you are making a mistake here `https://en.wikipedia.org/wiki/IPv4_subnetting_reference`, both source and destination are on the same network here . Subnet mask is `255.255.240.0` not `255.255.255.0`, both are different. Here the default gateway is the IP of the router and it should be able to find out the PC. Please correct me if I am wrong. I also don't think taht host and the destination has to be on the same network inorder for SSH connections.
Comment: `@Johan Myréen` Thank you for correcting my mistake. But it is not  necessary that the host and the destination should be on the same network inorder for ssh connection, right ?
Comment: No, of course it's not necessary for the the source and destination to be on the same subnet, otherwise ssh would not go very far. I jumped to this conclusion based on that you had two similar addresses and just a default route in addition to that. Btw, what is the 172.16.96.5 address in your traceroute listing above?
Comment: `@Johan Myréen` Actually I'm using my college wifi here and the routers are DHCP servers. So the gateway changes as I move around.
Comment: Ok, here's one more wild guess: maybe the subnetworks don't "see" each other, and your PC and laptop were originally on the same subnetwork by pure luck.

No route to host : ssh Error


Add action link from js script

Question: I have js code in view file:
function getAuthorData(id) {
    $.get("/web/review/authordata",
        {id: id},
        function (data, status) {
            $(".modal-content #fio").text(data.fio);
            $(".modal-content #email").text("Email: " + data.email);
            $(".modal-content #phone").text("Телефон:" + data.phone);
            $(".modal-content #link").attr("href",
                "<?= Url::toRoute(['/review/getreviewsbyautor']);?>" + "?id=" + id);
        });
}

But how ann link to yii2 action from script.js file?
My attempt:
$this->registerJsFile('@web/js/userData.js');

userData.js:
function getAuthorData(id) {
    var id2 = id;
    $.get("/web/review/authordata",
        {id: id},
        function (data, status) {
            $(".modal-content #fio").text(data.fio);
            $(".modal-content #phone").text("Телефон:" + data.phone);
            $(".modal-content #link").text("Телефон:" + data.phone);
            $(".modal-content #link").text("href",
                "<?= Url::toRoute(['/review/getreviewsbyautor']);?>" +  id2);
         //   $(".modal-content #link").attr("href", );
        });
}

But the link looks like this:

/web/site/%3C?=%20Url::toRoute([%27review/getreviewsbyautor%27]);?%3E?id=8

How to get a normal route in the script?
Comment: u can't use php inside js
Comment: are you talking about pretty urls like `mysite.com/site/index` then you might have to turn on the `urlManager` component settings.
Answer: You can generate the URL in your view and attach it to one of your elements, like the body:
<body data-my-url="<?= Url::to(..) ?>">

Then read it from your JavaScript file like this:
var url = $('body').data('my-url');

Add action link from js script


Why does the continuity correction (say, the normal approximation to the binomial distribution) work?

Question: I wish to better understand how the continuity correction to the binomial distribution for the normal approximation was derived.
What method was used to decide we should add 1/2 (why not another number?). Any explanation (or a link to suggested reading, other than this, would be appreciated).
Answer:
In fact it doesn't always "work" (in the sense of always improving the approximation of the binomial cdf by the normal at any $x$). If the binomial $p$ is 0.5 I think it always helps, except perhaps for the most extreme tail. If $p$ is not too far from 0.5, for reasonably large $n$ it generally works very well except in the far tail, but if $p$ is near 0 or 1 it might not help at all (see point 6. below)

One thing to keep in mind (in spite of illustrations almost always involving pmfs and pdfs) is that the thing we're trying to approximate is the cdf. It can be useful to ponder what's going on with the cdf of the binomial and the approximating normal (e.g. here's $n=20,p=0.5$):

In the limit the cdf of a standardized binomial will go to a standard normal (note that standardizing affects the scale on the x-axis but not the y-axis); along the way to increasingly large $n$ the binomial cdf's jumps tend to more evenly straddle the normal cdf.
Let's zoom in and look at this in the above simple example:

Notice that since the approximating normal passes close to the middle of the vertical jumps*, while in the limit the normal cdf is locally approximately linear and (as is the progression of the binomial cdf at the top of each jump); as a result the cdf tends to cross the horizontal steps near $x+\frac{_1}{^2}$. If you want to approximate the value of the binomial cdf, $F(x)$ at integer $x$, the normal cdf reaches that height near to $x+\frac{_1}{^2}$.
* If we apply Berry-Esseen to mean-corrected Bernoulli variables, the Berry-Esseen bounds allow for very little wiggle room when $p$ is near $\frac12$ and $x$ is near $\mu$ -- the normal cdf must pass reasonably close to the middle of the jumps there because otherwise the absolute difference in cdfs will exceed the best Berry-Esseen bound on one side or the other. This in turn relates to how far from $x+\frac{_1}{^2}$ the normal cdf can cross horizontal part of the binomial cdf's step-function.

Expanding on the motivation that in 1. let's consider how we'd use a normal approximation to the binomial cdf to work out $P(X=k)$. E.g. $n=20, p=0.5, k=9$ (see the second diagram above). So our normal with the same mean and sd is $N(10,(\sqrt{5})^2)$. Note that we would approximate the jump in cdf at 9 by the change in normal cdf between about 8.5 and 9.5.

Doing the same thing under the less formal but more "usual" textbook motivation (which is perhaps more intuitive, especially for beginning students), we're trying to approximate a discrete variable by a continuous one. We can make a continuous version of the binomial by replacing each probability spike of height $p(x)$ by a rectangle of width 1 centered at $x$, giving it height $p(x)$ (see the blue rectangle below; imagine one for every x-value) and then approximating that by the normal density with the same mean and sd as the original binomial:

The area under the box is approximated by the normal between $x-\frac12$ and $x+\frac12$; the two almost-triangular parts that lie above and below the horizontal step are close together in area. Some sum of binomial probabilities in an interval will reduce to a collection of these approximations. (Drawing a diagram like this is often very useful if it's not instantly clear whether you need to go up or down by 0.5 for a particular calculation ... work out which binomial values you want in your calculation and go either side by $\frac12$ for each one.)
One can motivate this approach algebraically using a derivation [along the lines of de Moivre's -- see here or here for example] to derive the normal approximation (though it can be performed somewhat more directly than de Moivre's approach).
That essentially proceeds via several approximations, including using Stirling's approximation on the ${n \choose x}$ term and using that $\log(1+x)\approx x-x^2/2$ to obtain that
$$P(X=x)\approx \frac{1}{\sqrt{2\pi np(1-p)}}\exp(-\frac{(x-np)^2}{2np(1-p)})$$
which is to say that the density of a normal with mean $\mu=np$ and variance $\sigma^2 = np(1-p)$ at $x$ is approximately the height of the binomial pmf at $x$. This is essentially where de Moivre got to.
So now consider that we have a midpoint-rule approximation for normal areas in terms of binomial heights ... that is, for $Y\sim N(np,np(1-p))$, the midpoint rule says that $F(y+\frac12)-F(y-\frac12) = \int_{y-\frac12}^{y+\frac12}f_Y(u)du\approx f_Y(y)$ and we have from de Moivre that $f_Y(x)\approx P(X=x)$. Flipping that about, $P(X=x)\approx F(x+\frac12)-F(x-\frac12)$.
[A similar "midpoint rule" type approximation can be used to motivate other such approximations of continuous pmfs by densities using a continuity correction, but one must always be careful to pay attention to where it makes sense to invoke that approximation]

Historical note: the continuity correction seems to have originated with Augustus de Morgan in 1838 as an improvement of de Moivre's approximation. See, for example Hald (2007)[1]. From Hald's description, his reasoning was along the lines of item 4. above (i.e. essentially in terms of trying to approximate the pmf by replacing the probability spike with a "block" of width 1 centered at the x-value).

An illustration of a situation where continuity correction doesn't help:

In the plot on the left (where as before, $X$ is the binomial, $Y$ is the normal approximation), $F_X(x)\approx F_Y(x+\frac12)$ and so $p(x) \approx F_Y(x+\frac12)-F_Y(x-\frac12)$. In the plot on the right (the same binomial but further into the tail), $F_X(x)\approx F_Y(x)$ and so $p(x) \approx F_Y(x)-F_Y(x-1)$ -- which is to say that ignoring the continuity correction is better than using it in this region.
[1]: Hald, Anders (2007),
"A History of Parametric Statistical Inference from Bernoulli to Fisher, 1713-1935",
Sources and Studies in the History of Mathematics and Physical Sciences,
Springer-Verlag New York
Answer: I believe the factor arises from the fact that we are comparing a continuous distribution to a discrete. We thus need to translate what each discrete value means in the continuous distribution. We could choose another value, however this would be unbalanced about a given integer. (ie you would weight the probability of being at 6 more toward 7 than 5.)
I found a useful link here: link


Residue theorem for rational function

Question: I try to get the following result but I don't see how to choose the integration paths to apply the residue theorem:
Let $R(z) = \frac{P(z)}{Q(z)}$ a rational function for polynomials $P, Q$ with $\operatorname{deg} Q \geq \operatorname{deg} P + 2$ which has no pole in $(0, \infty)$. Further $R$ is holomorphic in a neighbourhood of $z = 0$ or has a pole of order $1$ in $z = 0$. Let $z_1, \dots, z_n$ all singularities of $R$ in $\mathbb C \setminus \{0\}$ and $\theta \in (0,1)$. Then it holds that
$$\int_0^\infty x^\theta R(x) \, dx = \frac{2 \pi i }{1 - e^{2 \pi i \theta}} \sum_{j = 1}^n \operatorname{res}_{z_j}(z^\theta R(z)).$$
I tried to use a semicircle from $0$ to an abritrarily large $r > 0$ as integration path but I dont get all residues like this. Honestly I have no idea how to get the residue theorem involved here. I would love to see some solutions to the problem :)
Answer: Hint: Use a keyhole integration path:

Besides, define $z^\theta$ as $e^{\theta\log z}$, where $\log$ is the determination of the logarigthm defined on $\mathbb{C}\setminus[0,+\infty)$.

Residue theorem for rational function


Find all the numbers obtainable via $+$ and $\times$ on 10 to 1

Question: Happy New Year 2024!
I got to know that
$$(10 + (9 + 8 \times 7) \times 6) \times 5 + 4 \times 3 \times 2 \times 1 = 2024.$$
I am wondering how many numbers can be represented by similar arithmetic operations ($+$ and $\times$) on the numbers from 10 to 1.
We can definitely write code to enumerate all the possible cases, but can we have better ways to find the numbers?
More specifically, I mean
$$10 \operatorname{op}_1 9 \operatorname{op}_2 8 \operatorname{op}_3 7 \operatorname{op}_4 6 \operatorname{op}_5 5 \operatorname{op}_6 4 \operatorname{op}_7 3 \operatorname{op}_8 2 \operatorname{op}_9 1$$
with legal parentheses,
where each $\operatorname{op}_i \in \{+, \times\}$ (we can consider "$-$" and "$/$" too! but less us stay with $\{+, \times\}$ first).

Naive idea: If I am correct, we have at most $9! \times 2^9 = 185794560$ possible situations, where $9!$ is the number of different orders of operators that might be changed by parentheses, and $2^9$ is the number of combinations of operators.

Reduce the cases: Ideas and techniques for improving the efficiency of enumeration are also appreciated!
For example, we can find all the full binary trees with $10$ leaves and use reserve Polish to compute the numbers.
Each case can be represented by a full binary tree, where the $10$ leaves are numbers and the $9$ non-leaves are operators.
Hence, the number of cases can be further bounded by
$$C_9 \times 2^9 = 2489344,$$
where $C_9 = 4862$ is the $9$-th Catalan number.

Moreover, even finding the maximum possible number seems interesting and nontrivial.

Related question: When considering all four arithmetic operations, the question would be equivalent to an existing question on the site (Construct numbers using digits $123456789$ and the operations $+,-,×,÷$).
When only considering two operations ($+$ and $\times$), the question accepts unique techniques mentioned in the answer by @Misha Lavrov, which is also mentioned by @Benjamin Wang.
Comment: @bumblebee Thanks! The question is very related! But they didn't discuss any way to find such numbers other than using DP
Comment: I believe this question is not a duplicate since the linked question doesn't really have a full answer. This question is also slightly different, amenable to a different strategy as shown in the top answer.
Comment: @Benjamin I agree with you that with only two associative operators, the top answer provides essentially different insights. But I also admit that if we consider all for arithmetic operators, two questions are equivalent
Answer: We can think of the associative operations $+$ and $\times$ as operations which can take any number of arguments, representing the example in the question as $${+}\Bigg({\times}\bigg({+}\Big(10, {\times}\big({+}(9,{\times}(8,7)),6\big)\Big), 5\bigg), {\times}\bigg(4,3,2,1\bigg)\Bigg).$$
Now our expression tree is no longer a binary tree: each non-leaf node can have degree $2$ or higher. There are more such trees. But the advantage of this representation is that the operations no longer need to be chosen independently: they must alternate at each level, or else we'd combine the levels together. So there is only a $2$-way choice for the operations: is the top level $+$ or $\times$?
The number of trees we can build is given by OEIS sequence A001003, and for $10$ elements there are $103049$ trees. Multiplying by $2$, we get an upper bound of $206098$ possible numbers we can obtain.
This is actually the exact answer for how many possible expressions we can get with variable inputs $x_1, x_2, \dots, x_{10}$ instead of numerical inputs $10, 9, \dots, 1$. Past this point, the only improvement we can make to the count comes from identifying the places where fundamentally different operations give us the same answer. (For three inputs rather than ten, an example of this is $3+2+1 = 3\times 2\times 1$.)
It goes against the spirit of the question, but a brute-force search of these trees finds that there are

 $35869$ different numbers that can be obtained in this way; the smallest is $$54 = 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 \times 1$$ and the largest is $$5443200 = 10 \times 9 \times 8 \times 7 \times 6 \times 5 \times 4 \times 3 \times (2 + 1).$$ When it comes to years, we'll be able to find an expression for every year until the end of the century except for $2048$.
Answer: What about if I say ...
10_9_8_7_6_5_4_3_2_1 (assuming they have to be in descending order)
9 slots with 2 possibilities (× or +).
Total number of possibilities = $2^9 = 512$
The smallest number = $10 + 9 + \dots + 2 + 1 = 55$
The largest number = $10! = 3628800$
The maximum number of such numbers = $3628746$ (assuming we include parentheses to increase the range e.g. $4 + ( 3 \times 2) = 10$ and $(4 + 3) \times 2 = 14$)
Signing off ...


pip won't upgrade awscli

Question: I haven't found any references to this from Google, but I am having this issue on literally dozens of AWS EC2 CentOS instances. The awscli installs fine if it does not already exist. However, starting with v1.4.3, any attempt to upgrade to >=1.4.4 ('pip install --upgrade awscli') results in the following errors:
Downloading/unpacking awscli from https://pypi.python.org/packages/source/a/awscli/awscli-1.4.4.tar.gz#md5=3e9defe3470db63b88f91ab236dcfec2
  Running setup.py egg_info for package awscli
    warning: no files found matching 'LICENSE.txt'
    warning: no files found matching 'requirements.txt'
    warning: no files found matching '*.rst' under directory 'awscli/examples'
    warning: no files found matching '*.json' under directory 'awscli/data'
Requirement already up-to-date: botocore>=0.63.0,<0.64.0 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already up-to-date: bcdoc>=0.12.0,<0.13.0 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already up-to-date: six>=1.1.0 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already up-to-date: colorama==0.2.5 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already up-to-date: docutils>=0.10 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already up-to-date: rsa==3.1.2 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already up-to-date: argparse>=1.1 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already up-to-date: jmespath==0.4.1 in /usr/lib/python2.6/site-packages (from botocore>=0.63.0,<0.64.0->awscli)
Requirement already up-to-date: python-dateutil>=2.1 in /usr/lib/python2.6/site-packages (from botocore>=0.63.0,<0.64.0->awscli)
Requirement already up-to-date: ordereddict==1.1 in /usr/lib/python2.6/site-packages (from botocore>=0.63.0,<0.64.0->awscli)
Requirement already up-to-date: simplejson==3.3.0 in /usr/lib/python2.6/site-packages (from botocore>=0.63.0,<0.64.0->awscli)
Requirement already up-to-date: pyasn1>=0.1.3 in /usr/lib/python2.6/site-packages (from rsa==3.1.2->awscli)
Installing collected packages: awscli
  Found existing installation: awscli 1.4.3
    Uninstalling awscli:
      Successfully uninstalled awscli
  Running setup.py install for awscli
    error: file '/tmp/pip-build-root/awscli/bin/aws' does not exist
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/awscli/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-V1jT9z-record/install-record.txt --single-version-externally-managed:
    running install

running build

running build_scripts

error: file '/tmp/pip-build-root/awscli/bin/aws' does not exist

----------------------------------------
  Rolling back uninstall of awscli
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/awscli/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-V1jT9z-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-root/awscli
Storing complete log in /root/.pip/pip.log

And then, from the /root/.pip/pip.log:
  Running setup.py install for awscli

    Running command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/awscli/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-1n2lji-record/install-record.txt --single-version-externally-managed
    running install
    running build
    running build_scripts
    error: file '/tmp/pip-build-root/awscli/bin/aws' does not exist

The same errors occur on machines with aws version upgrades 1.4.3 -> 1.4.4, 1.4.3 -> 1.5.0 and 1.4.4 -> 1.5.0.
Answer: Turns out that there were other dependencies of awscli that were not upgrading if I attempted to upgrade them directly, each failing with the same basic problems. I'm not sure what exactly the problem was, but deleting the /tmp/pip-build-root folder fixed all the issues.

pip won't upgrade awscli


Rationale for Multi-Label vs. Single-Label learning?

Question: I have not seen any research that compares the effects of single-label versus multi-label learning. What I mean by this is not comparing various types of evaluation metrics - such a comparison does not make sense, as single and multi-label learners use different evaluation metrics for test error.
But what I want is an example of how multi-label learning improves the application of classification, in any context. I know the rationale in general is "more, correct information will be better discriminatory information than less information", and I would expect to see better discrimination between classes separated by multi vs. single label learning methods. But where is the empirical evidence?
Can anyone help me out?
Clarification: I am referring to multi-class multi-label learning methods as opposed to normal single-label supervised learners. Examples of each are below:
<code>Multi-class multi-label learners:
multi-label kNN (ML-kNN)
multi-label backpropagation (ML-BP)
rank SVM
binary relevance
classifier chains
random k label sets

Multi-class Single-label learners:
1 vs. 1 SVM, 1 vs. all SVM
</code>
Answer: Note that there is a subtle but important difference between multilabel problems, in which each instance may belong to several classes, and multiclass problems, in which each instance belongs to one of $\geq 2$ classes. I will discuss both briefly, but based on the question I suspect you are referring to multiclass problems.
Multilabel problems can essentially be broken down into sets of binary problems without much loss of information. The only situations where a true multilabel formulation has advantages, at least in theory, is when some combinations of labels are simply not possible, which you cannot enforce cleanly in a set of binary learning problems.
Multiclass problems are often best not split up into a set of binary problems because some information may be lost. Ofcourse, this only applies if the learning technique effectively has a natural multiclass formulation (e.g., SVM does not, but neural networks and decision trees do). One of the big benefits of doing pure multiclass classification is that you typically have more data to learn from, which allows better discrimination between subtlely distinct classes. Additionally, there is often an obvious computational advantage in multiclass formulations which features no redundancy in contrast to sets of binary formulations (regardless of your binarization scheme, be it 1-v-1, 1-v-all, ...).
Comment: Splitting multilabel problems into 1-vs-all binary problems is usually not very problematic, this also applies to MCML. Better alternatives would be to explicitly model potential label combinations, e.g. via [structured output](http://www.cs.cornell.edu/people/tj/svm_light/svm_struct.html).
Comment: Thanks for your answer, Marc. I am, however, referring to multi-class-multi-label (MCML) problems. Sorry for the confusion. Does this change your answer?


Text's `fill` color is overriden by `stroke` in Konva

Question: I have some Konva Text node, whose fill attribute is set to black and stroke is set to some other color.
In my canvas it looks as expected. The problem happens when I convert the canvas to base64 image to download it as an image file - in that case the downloaded image looks like in the screenshot below:
(the canvas is on the left side, the right one is the downloaded image)

As you can see, the stroke color is applied to the text's own color as well.
I created a Codesandbox example with a Text node that has the same attributes as in my environment, here is how that node is created:
const text = new Konva.Text({
      x: 26.330053300533024,
      y: 128,
      text: "Add a body text",
      defaultText: "Add a body text",
      fontSize: 22,
      fontFamily: "Montserrat",
      draggable: true,
      name: "text",
      fontStyle: "300",
      id: "textkgrsl68w",
      is_settings: true,
      wrap: "word",
      padding: 5,
      fill: "black",
      opacity: 1,
      isPremium: false,
      width: 183.5,
      visible: true,
      rotation: 0,
      scaleX: 1,
      scaleY: 1,
      offsetX: 0,
      offsetY: 0,
      skewX: 0,
      skewY: 0,
      stroke: "rgba(255,0,0,1)",
      strokeWidth: 3.75
    });

As you can see, it has the same (incorrect) look - without the inline color. I played with fontSize in Codesandbox and when I set it to very big value (like 100), the text's inline color became visible.
I assumed it can be some ratio problem, but as we see on the screenshot, the text's size is similar in both canvas and downloaded image.
How can this be fixed, maybe there is some extra attribute that should also be set?
konva: 7.1.4
react-konva: 16.12.0-0
Answer: UPDATED:
You can use text.fillAfterStrokeEnabled(true); to draw fill over stroke.
Old answer:
By default Konva is drawing fill first then stroke. So it will be a text itself and then stroke around it (that goes overfill part).
Probably one-day Konva will support a different order, but at the current moment firstname.lastname@example.com can't do that.
As a workaround just use two Konva.Text instances. First for stroke, second for fill.
https://codesandbox.io/s/download-konva-text-node-with-stroke-as-base-64-image-forked-w0z4v


LINQPad script directory?

Question: Does anyone know how to get hold of the path to the directory where the LINQPad script file (.linq) resides?
Or to the script itself for that matter.
Note that I'm not talking about the location of the "My Queries" folder, the one shown inside LINQPad.
I can save a .linq file anywhere on disk, and open it by double-clicking on it.
For instance, if I save the file to C:\Temp\Test.linq, and execute the program, I'd like to have either C:\Temp or C:\Temp\Test.linq.
Basically I'd like something akin to Environment.CurrentDirectory or Assembly.GetEntryAssembly().Location, just for the .linq file.
Things I've tried:

Looking through environment variables
Looking through the LINQPad assembly that is given to my script
Throwing an exception and looking at the stacktrace (contains a link to a temporary copy of my script somewhere else)
Environment.CommandLine.Dump(); - gives LINQPad executable
Environment.CurrentDirectory.Dump(); - gives C:\windows\system32
Assembly.GetExecutingAssembly().Location.Dump(); - gives temp directory
Comment: Yes, I was kinda wondering if someone know what that was :) (assuming there is one)
Comment: The execution context is always going to be the program location.  You need a specific LinqPAD API if one exists for the file location.
Answer: I've just added a feature to address this. You can test it now by downloading the 2.27.1 or 4.27.1 beta build.
To get the current query's folder, use the following expression:
Path.GetDirectoryName (Util.CurrentQueryPath)

Comment: There are many reasons why I just love LINQPad, and you seem to have no problem coming up with new reasons :) Thank you so much!
Comment: Have you saved your query? (If not, there will be no query path)
Comment: How is it I only just found the `Util` type?!
Comment: Linqpad v5.x `Util.CurrentQueryPath ` returns null.
Answer: I presume you mean programatically and not through the UI itself.
The path to the linq file directory is held in
%APPDATA%\LINQPad\querypath.txt
Comment: No, that contains the path to the "My Queries" directory. I can easily save .linq files everywhere else, and it's the real location I want, I'll edit the question to clarify. I want the full path to the .linq file of the currently executing script.
Comment: Ah ok - the question is clearer now. I don't know the answer but what would you like returned when you execute a query that hasn't yet been saved?
Comment: Anything basically, temp, whatever. It would probably in that case be logical that it returned the path to a temporary copy of the script. For instance, for some reason I might be interested in reading the source, but my primary use is to access data files in the same directory as the script itself, without hardcoding the path to where the script lives.
Comment: I've posted the question on the forum of the LINQPad authors book, so I'll see if that can give me the specifics, or perhaps a feature request :)
Answer: The next question after "How do I get LinqPad script directory" is "How do I set it?" below is how you do it and link to where I found the answer
Directory.SetCurrentDirectory (Path.GetDirectoryName (Util.CurrentQueryPath));

Comment: That changes the "current directory" of the process, it does not change the LINQPad script directory location.
Comment: Good to know. Thanks for the clarification.

LINQPad script directory?


Why can't a set {(1,1)} be an equivalence relation of set A={1,2,3}?

Question: I know that {(1,1),(2,2),(3,3)} is an equivalence relation of the set A. But I am not sure why can't the set{(1,1)} be an equivalence relation? I think it is because the equivalnce relation is specified for all (a,a) which belong to set A so elemnt 1,2 and 3 should all belong to the set and not any one or two(2 or 3 for example) only.Is this correct? (I am only taking pairs with same elements here on purpose to clearly elucidate my point).
What if I have to create an equivalence class such that neither a nor b is equal to 3 or 3 is not a factor of a (in (a,b) where both a and b belong to set A). Will such an equivalence relation ({(1,1),(2,2),(1,2),(2,1)}) exist or not?
Comment: it's not reflexive
Comment: What if I want to create an equivalence relation with my own conditions like a is not equal to 3. Is it possible to do so?
Comment: @Peter Sure, by reflexivity. Each element must be related to itself. When presenting an equivalence relation as a set of ordered pairs, its $$\{(a,b):a\sim b\}.$$
Comment: @TanishkGoyal In any equivalence relation (as you hinted at yourself in the body of the post), there are always the pairs $(a,a)$ for $a$ in the set, so the answer to your last question is no, as it seems you already knew...
Comment: Perhaps you mean something like $$\{(1,1),(2,2),(3,3),(1,2),(2,1)\}?$$ That is an equivalence relation, where $1 \sim 2$ and $3$ is in its own block alone.
Comment: @amrsa how about in your equivalence relation, I put the condition a is not equal to 3, or a mod 3 is not equal to 0. Is it possible to exclude (3,3) from the set then.If yes, then will the resultant relation an equivalnce relation? Is it at all possible to create equivalence relation with our own conditions? Or do we have to first create all the equivalence relation and see what other relation they have apart from reflexivity,transivity and symmetricity?
Comment: @amrsa Does that mean that (1,1) , (2,2) , (3,3) are always pairs in a set being an equivalence relation on $A$ ?
Comment: @TanishkGoyal I think this completely answers your question.
Answer: Not only is it not reflexive,  as mentioned in the comments,  your proposed equivalence relation doesn't partition the set $A$.  That means that each element of the set needs to be in a unique equivalence class. $2$ and $3$ from $A$ are left out,  so it's not an equivalence relation.


Responsive Text Drei

Question: I have a scene with some Text components from Drei that I'd like to make responsive (smaller text size and max-width on mobile.  Also since they are stacked vertically, I'm currently eyeballing the size and manually moving the text down the y-axis.
How should I go about having the text resize when the window changes?  How do you get the height of the Text component so you know where to place the next one?
import { Float, Text } from "@react-three/drei"

export default function AboutText() {
  const text = [
    "Blah blah",
    "Yada Yada",
    "Lorem Ipsum",
    "More Text"
  ]

  const TextJSX = text.map((paragraph)=>{
    return(
      <Float rotationIntensity={0.2} floatIntensity={0.5}>
        <Text color="white"
        anchorX="center"
        anchorY="middle"
        fontSize={.2}
        position={[0,5,1]}
        maxWidth={6}
      >
        <meshBasicMaterial
          color={"#FFF"}
          fog={false}
        />
          {paragraph}
        </Text>
      </Float>
    )
  })

  return (
    <>
      {TextJSX}
    </>
)}

Desktop

Mobile
Answer: I figured out a solution, the bounding box calculation is async, so it's not available right away, but there is an 'onSync' callback from Text that you can tap into:
onSync={(mesh)=> {
  const visibleBounds = mesh.textRenderInfo.visibleBounds;
}

You can adjust the maxWidth and the fontSize by taking the viewport width and dividing by some number:
 <Text color="white"
   anchorX="center"
   anchorY="top"
   fontSize={viewport.width / 100}
   position={[0,startingPosition - (offset),1]}
   maxWidth={viewport.width / 3}

For the margins between text, I pushed the size of the text plus a margin to a state array, and when iterating over the jsx took the sum of the heights at the current index as the start position.
The whole thing looks like this:
import { useThree } from "@react-three/fiber";
import { Float, Text } from "@react-three/drei"
import { useState, useEffect } from "react";

export default function AboutText() {
  const text = [
    "1. sample text",
    "2. sample text",
    "3. sample text",
  ]

  const [heights, setHeights] = useState([])
  const startingPosition = 5
  const { viewport } = useThree();

  useEffect(() => {
    console.log('heights updated:', heights);
  }, [heights, viewport]);

  const TextJSX = text.map((paragraph, i)=>{
    const offset = ((i > 0) && heights.length > 0 ) ? heights.slice(0, i).reduce((a, b) => a + b, 0) : 0
    console.log(viewport.width)
    return(
      <Float rotationIntensity={0.2} floatIntensity={.5} key={i}>
        <Text color="white"
        anchorX="center"
        anchorY="top"
        fontSize={viewport.width / 100}
        position={[0,startingPosition - (offset),1]}

        //width of text object
        maxWidth={viewport.width / 3}

        //text is async, will run onSync when it gets a height
        onSync={(mesh)=> {
          console.log("onsync")
          const visibleBounds = mesh.textRenderInfo.visibleBounds;
          const top = Math.abs(visibleBounds[1])
          const bottom = Math.abs(visibleBounds[3])
          const margin =  + 0.2

          //heights state will keep building unless it's cleared out.
          setHeights(prevHeights => {
            if(prevHeights.length === text.length){
              return [(top + bottom + margin)];
            } else {
              return [...prevHeights, (top + bottom + margin)]}
            }
          )
        }}
      >
        <meshBasicMaterial
          color={"#FFF"}
          fog={false}
        />
          {paragraph}
        </Text>
      </Float>
    )
  })

  return (
    <>
      {TextJSX}
    </>
)}

Responsive Text Drei


Proportional odds logistic regression with nominal (unordered) categories

Question: Suppose that you've got a logistic regression with multiple nominal outcomes that cannot be ordered in a theoretically meaningful way. Assume further, however, that the proportional odds assumption nonetheless holds true for these categories for a given order. In this scenario, would it be possible to fit an ordered logistic regression model?
What I'm really asking is if there's any reason, apart from the proportional odds assumption, for why a ordered logit needs ordered categories? Is it simply a mathematical assumption or is there something else to it that I'm presently missing?
Answer: The short answer is that you need ordered categories for the model to fit accurately.  You raise an interesting question of whether you can solve for a reordering of categories to satisfy the proportional odds assumption will you get a good-enough model fit and can you adjust inferential quantities for such data dredging.  That's worth a simulation study.
There is a blend between the prop. odds model and the polytomous logistic model called the partial proportional odds model.  See http://www.citeulike.org/user/harrelfe/article/13264679.  I believe the R vgam package can fit it.  But it needs some kind of prespecification.
A useful exercise is checking the ordinality and proportional odds assumptions separately for each predictor as examplified in my course note handouts available as a link from http://biostat.mc.vanderbilt.edu/rms (R function plot.xmean.ordinaly).
Comment: I understand. Is there any benefit in also considering the nonproportional odds model, or is that simply an extension of the PPO model that implies that the proportional odds assumption has been relaxed for every independent variable?
Comment: If by nonproportional odds you mean polytomous (multinomial) logistic, there is a disadvantage because of the huge number of parameters required when you don't have an ordinal outcome.
Comment: It was a term I encountered [here](http://support.sas.com/documentation/cdl/en/statug/65328/HTML/default/viewer.htm#statug_logistic_examples23.htm), but I believe it simply referred to a partial proportional odds model with the parallel lines assumption nullified for every predictor. I agree about the disadvantage of the multinomial model; in fact it was the reason for which I posted this question in the first place.
Comment: Partial proportional odds with the proportionality assumption made for none of the predictors is equivalent to polytomous logistic regression.


Libgdx use ScreenUtils asynchronously and don't stop the game loop

Question: I want to capture the screen. Libgdx provides some functions defined in the ScreenUtils class.
For instance final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h);
My problem is that it takes about 1-3 seconds to get that information. During that time the game loop is blocked and the user will define it as a lag.
Internally the ScreenUtils class, uses Gdx.gl.glReadPixels. If I run the ScreenUtils.getFrameBufferPixmap method in a thread, there is no lag, but it captures the screen at the wrong method, which is logical since the game loop runs and changes stuff.
Is it somehow possible to copy the GL context or save it and generate the Pixmap at a later point of time with the help of a Thread? Of course the copy/save operation should be done instantly, otherwise I don't spare anything.
I use ShapeRenderer to render my stuff onto the screen.
Comment: Sorry, didn't mean to down vote (clicked by accident) but I can't undo it.
Answer: After little research I have found faster alternative to glReadPixels - Pixel Buffer Object which is available since Android 4.3 - https://vec.io/posts/faster-alternatives-to-glreadpixels-and-glteximage2d-in-opengl-es
It is not possible to call glReadPixels on other thread than render thread - https://stackoverflow.com/a/19975386/2158970
Comment: Well this may work but I have to use the OpenGL stuff which is provided by LibGDX and I am not quite sure how to wire it up.
Answer: I have found a solution, which works in my case since I have only minor graphics / shapes. Basically I copy all the objects, which are drawn to the view, as described here. In a background thread I generate a Bitmap programmatically and use the information stored in my objects to draw to the bitmap.


What to do with a lmer model that violates the assumptions of normal residuals?

Question: I have the following lmer model:
    ball6lmer=lmer(Width_mm~Buried+(Buried|Chamber), data=ballData,control=lmerControl(optimizer="optimx",optCtrl=list(method="nlminb")), REML=FALSE)

Width_mm is the diameter of dung balls made by dung beetles
Buried is whether or not a dung ball was buried by a beetle (0=no, 1= yes).
26 chambers were included in the experiment and multiple dung balls came from the same chamber, so I have included the random term ~1|chamber to account for the non-independence of data. Furthermore, log likelihood tests showed that the model was improved by allowing the slopes of the Buried term to vary over chambers (random=Buried|Chamber). The output looks like this:
    Linear mixed model fit by maximum likelihood  ['lmerMod']
 Formula: Width_mm ~ Buried + (Buried | Chamber)
    Data: ballData
 Control: lmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb"))

      AIC      BIC   logLik deviance df.resid
    668.4    689.9   -328.2    656.4      260

 Scaled residuals:
     Min      1Q  Median      3Q     Max
 -2.7717 -0.3993 -0.1455  1.0212  2.4765

 Random effects:
  Groups   Name        Variance Std.Dev. Corr
  Chamber  (Intercept) 0.009828 0.09914
           Buried1     0.182687 0.42742  1.00
  Residual             0.625589 0.79094
 Number of obs: 266, groups:  Chamber, 26

 Fixed effects:
             Estimate Std. Error t value
 (Intercept) 11.14463    0.06689  166.60
 Buried1     -0.92226    0.13534   -6.81

 Correlation of Fixed Effects:
         (Intr)
 Buried1 -0.270
 >

My residual plots do not look so good though:

The residuals are clearly not normal. I am now stuck as to how to proceed with this analysis. I could do a simple Mann–Whitney U test to test for a difference between Buried, however this would ignore the non-independence of dung balls from the same chamber.
The next option that I am considering is to bootstrap the regression coefficients, and obtain 95% confidence intervals for the regression coefficients. However I have never done this before and would not know where to start. So I am looking for a bit of guidance on how to proceed. Specifically:
1)  Would a simple Mann–Whitney U test be an appropriate alternative or is it incorrect to ignore the non-independence of the data?
2)  Is trying to bootstrap this model something that a novice like me could try or is it something best left to the professionals? If it is a relatively straight forward thing to do, could anyone recommend any basic resources to get me started?
3)  Are there any other options for dealing with lmer models that violate the assumptions of normal residuals? My response variable only has 5 possible variables (width of 9,10,11,12 or 13mm) so I don't think transforming the response variable will help.
Any guidance would be much appreciated. Thanks.
AN UPDATE:
John as correctly pointed out that I have been using the wrong predictor variable. I have now respecified the model to predict ball width based on whether or not an egg was laid in a dung ball (EggLaid, a 2 level predictor)
The model is now:
    lmer(Width_mm~EggLaid+(1|Chamber), data=ballData, REML=FALSE)

With the following output:
    Linear mixed model fit by maximum likelihood  ['lmerMod']
    Formula: Width_mm ~ EggLaid + (1 | Chamber)
       Data: ballData

         AIC      BIC   logLik deviance df.resid
       712.8    727.1   -352.4    704.8      262

    Scaled residuals:
         Min       1Q   Median       3Q      Max
    -2.35659 -0.57566 -0.06791  0.79089  2.62157

    Random effects:
     Groups   Name        Variance Std.Dev.
     Chamber  (Intercept) 0.1059   0.3254
     Residual             0.7636   0.8739
    Number of obs: 266, groups:  Chamber, 26

    Fixed effects:
                Estimate Std. Error t value
    (Intercept)  11.0697     0.1078  102.65
    EggLaid1     -0.5620     0.1119   -5.02

    Correlation of Fixed Effects:
             (Intr)
    EggLaid1 -0.593

The QQ plot of residuals look much better, however I still have an odd looking residual vs fitted plot, which I assume reflects the 5 values of the response variable:

Is this residual plot "passable" given the 5 values of the reponse variable, or is this model not OK and I need to bootstrap the coefficients?
Also to clarify, the values for width (the response) are rounded to the nearest mm.
A FURTHER UPDATE:
I have had a go at bootstrapping the regression coefficients (using parametric bootsrap) using some helpful info here. My code and output is as follows:
    ball2=lmer(Width_mm~EggLaid+(1|Chamber), data=ballData, REML=FALSE)
    #This is the same model as the one above (output is above)

    #With 5000 bootstrapped replicates
    b_par<-bootMer(x=ball2,FUN=fixef,nsim=5000, use.u = FALSE, type="parametric")

    #Bootstrapped CI for the intercept
    boot.ci(b_par,type="perc",index=1)

    #Bootstrapped CI for the EggLaid1
    boot.ci(b_par,type="perc",index=2)

    BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
    Based on 5000 bootstrap replicates

    CALL :
    boot.ci(boot.out = b_par, type = "perc", index = 1)

    Intervals :
    Level     Percentile
    95%   (10.86, 11.28 )
    Calculations and Intervals on Original Scale

    BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
    Based on 5000 bootstrap replicates

    CALL :
    boot.ci(boot.out = b_par, type = "perc", index = 2)

    Intervals :
    Level     Percentile
    95%   (-0.7781, -0.3469 )
    Calculations and Intervals on Original Scale

I am a complete newbie to bootstrapping, so if I have made an error in the code, any suggestions would be graciously welcomed
Comment: Why are you predicting width with burial? Simply based on order wouldn't one expect the burial to be dependent in width and not the other way around? But if you really want to predict width with burial are you sure there aren't some measurement issues? You have a large gap in your fitted values and it seems like there are 5 groupings of measures. I'd check my data coding at least.
Comment: @John you raise a very good point. The female buries a ball, and then hollows out a chamber to lay her egg into the ball. The hollowing out by the female (i.e. egg laying) changes the size of the ball. I have updated the analysis accordingly. The QQplot looks alot better, but the residuals v predicted are still a bit squiffy (see above). To clarify, there are only 5 values of the reponse variable because the measurements were rounded to the nearest mm
Answer: The funny residuals almost certainly relate to the quantization of the response to the set $\left\{9, 10, 11, 12, 13 \right\}$.  A normal distribution, conditional on covariates, can't do that--the event has probability zero.
As you've said in your update, this quantization is due to rounding (ie, the actual values are not exactly $9.0$ or $13.0$ but were just rounded to those values).
I think this is a bit of a case of "good news/bad news." On the one hand, if the outcome has been rounded, that's really a complicated form of interval censoring, so non-parametric inference won't help.  I hypothesize that the point estimates will be at least somewhat biased due to the censoring, and you would need to use a method that models this in order to reduce this bias.  FWIW, I don't see any readily available software that does this for mixed models.  The R package grouped fits these models for vanilla GLMs.
On the other hand, the rounding may not be a huge issue.  In the first residuals vs fitted plot in which you regress Buried there seems there was a tendency to avoid prediction of non-integer values, which makes me worry that the model could be optimistic with its standard error estimates due to the quantization.  This doesn't seem to be so true in the second model where EggLaid was the predictor.  It might be worth running a simulation study to bound the bias, because I don't have a great intuition about how small or big this bias might be.
In conclusion, I would say yes, you should bootstrap, and that ideally you should use a semi-parametric bootstrap that jitters the response variables with a bit of noise.  It looks like this happen already if you use the function bootMer in lme4.  From the docs:

If 'use.u' is 'FALSE' and 'type' is '"parametric"', each simulation
  generates new values of both the "spherical" random effects u and
  the i.i.d. errors epsilon, using 'rnorm()' with parameters
  corresponding to the fitted model 'x'.

These iid errors epsilon will mean that the bootstrapped sample is no longer quantized.  So as long the the initial residual variance is approximately correct, the bootstrap will do something reasonable.
Comment: The Bayesian R package `brms` has a `brm` function that can include censoring. This might address some of your comments. Of course, it's slower than lmer -- MCMC sampling and all -- but more flexible as well.
Comment: The width measurements were measured to the nearest mm, so the quantization is due to rounding (for example a ball could have been 10.3mm, but was recorded as 10mm). I have updated the residual plots after realising that I used the wrong predictor. The updated plot is above. Based on this plot, would you recommend bootstrapping? Or can I use the current model?
Comment: Hi Andrew, I have had a crack at the semi parametric bootstrapping as you suggested and my code is above. Could you please clarify what you mean by "jitters the response variables with a bit of noise. The 1 mm rounding suggest that you should add at least .25 mm since that is within the measurement limits"? Thank you for your suggestions so far, they have been very useful.
Comment: I took a closer look at the lmer docs and the "parametric" bootstrap actually nearly does what I suggested regarding the jittering.  I also revised the answer to reflect a bit more of my uncertainty about exactly how big of an effect the rounding could have.  If I were you, I would run a simulation to better understand the impact.
Comment: Thanks Andrew. I have altered the code above to perform a parametric bootstrap. Thank you for your time to look over my code and offer your thoughts, it was very helpful and much appreciated.