Do I even need a swap partition?

Question: I have 8 gb of ram and use my machine for web browsing streaming and some light gaming. Do I need a swap partition?
Answer: No, you do not need a swap file or partition as long as

You are not going to hibernate.
You do not use RAM heavy apps such as virtualizaion or audio - video editing or burning DVD.

For "standard" desktop tasks (web browsing, email, text editing) with a single user you do not need swap.
With 4 gb and the type of apps I listed, I never even use swap.
It sort of depends on what you do with your box.
Answer: Yes. Typically I recommend 1 to 1 up to 5 Gig. I have never seen a point of having more than that available as swap on a standard computer. the point of Swap space is not to use it to expand memory since it's incredibly slow, but the point is to keep your system from crashing in the event that you run out of ram.
I have run into several situations in the last month for example where I've gotten up in the morning to find my system deep into cache because I forgot to close the website of a winner organization that hired some inept JavaScript programmer to develop them an application with a significantly reliable pool of memory leaks.
You never know what might happen, or what bug you might uncover that pushes through your ram and into cache. Without the cache in play you'll find yourself crashing. Disk space is cheap now days, it's worth having a swap partition.
Answer: It is necessary that you create a swap partition for Linux, if you intent to use suspend-to-disk, also known as hibernation.
Even if you don't, it is recommended, because a separate swap partition provides at least equal and often better performance than a swap file inside another file system.
For more info see http://www.alexonlinux.com/swap-vs-no-swap. If you need advice to choose an appropriate swap space size, refer to I have 16GB RAM. Do I need 32GB swap?.
David Foerster - Why should I partition my disk for Ubuntu 14.04?

Do I even need a swap partition?


If A is reducible to B and B is reducible to A, and A is NPC, is B also NPC?

Question: I was thinking about the max-clique problem and the k-independent set problem. You can show that k-independent set is reducible to max-clique easily and you can show that max-clique is reducible to k-independent set (with a simple for loop). And k-independent set is NPC, so wouldn't that mean max-clique is also NPC, but it's not because we can't create a verifier, so I'm terribly confused. What wrong assumption am I making?
Comment: The decision version of max-clique is actually k-clique, which is NP-complete.
Comment: @AlbertHendriks So max-clique typically asks for a set of vertices, not a yes or no answer?
Comment: Yes, or the size of the clique, as the current answer indicates. Perhaps there's another decision version that says "Does the max clique contain a specific vertex X?" but then it's not reducible to k-independent set.
Comment: @notorious The answer I gave before was downright incorrect; it's been corrected now. Sorry about that!
Answer: First, note that there are two problems frequently called the "Maximum Clique Problem".
One of them is the Clique Decision Problem: given an undirected graph $G$ and a number $k$, does $G$ contain a clique with at least $k$ vertices? This is one of Karp's 21 Problems, the original list that made NP-completeness famous. The proof involved reducing to it from the Boolean Satisfiability Problem, the very first original NP-complete problem. And a verifier for this is easy to make: check whether the set given as a solution actually does contain $k$ or more vertices, and is actually a clique.
The other is the Maximum Clique Size Problem: given an undirected graph $G$, what is the size of the largest clique in $G$? This can be shown to be NP-hard by reduction from the Clique Decision Problem, by simply comparing the size of the largest clique with $k$. And as you mentioned, it can apparently be shown to be in NP by reduction to the Clique Decision Problem: for every integer from the number of vertices down to 1, check if there's a clique of that size, and if so return that number.
So it would seem that both versions of the problem are NP-complete. But be careful about the definition of NP. NP is defined as a class of decision problems, and the Maximum Clique Size Problem is not a decision problem.
Specifically, NP is the class of decision problems where, if the answer is yes, you can be given extra information of polynomial size that lets you verify that the answer is yes in polynomial time. (If the answer is no, you can't necessarily verify it, unless NP = co-NP.) So for problems which aren't answered with yes or no, trying to put them in NP just doesn't make sense.
So while the Maximum Clique Size Problem is indeed NP-hard, and can be reduced to an NP-complete problem in polynomial time, it is not in fact in NP. And thus it cannot be NP-complete. This is why you can't make a verifier for it (unless NP = co-NP, which is an open question).


How much novelty should I add to my previous paper to get it published in New journal?

Question: I published an article in a journal, then I realized that I Can add two other ideas to it and then get it published in more sophisticated journal than previous one.
The question is : Can I publish my same previous article (same title, same sections, etc) the only diffrence would be : two added sections that represent about 30% of the article ?
Comment: In my area (electrical and electronics), a good/top journal likes fresh ideas that other people can build on.  So in your case, it will be a reject.  Also, I would also definitely reject your paper due to self plagiarism.
Answer: This seems unlikely. I doubt that an editor of a reputable journal would accept it, knowing the details. And it would be an ethical lapse to obscure the details, of course.
You can, however, write an extension of the old work, citing it as usual. But the new results would have to stand on their own to pass review. If they don't, then an option is to continue work until you have something that editors and reviewers (not readers here) find sufficiently "interesting" and novel.
Comment: @DavidWaterworth, most reviewing is single blind. The reviewer knows who the author is. Double blind occurs but is less common.
Comment: A good journal would likely sink the second submission for lack of novelty; a referee would also likely briefly scan recent work of the author to precisely check against such duplication.
Comment: How would a referee scan recent work of the author - if by referee you mean reviewer then they shouldn't know who the author is? Or is this something the journal would do before sending it out for peer review?


If i use use BERT embeddings for if cosine(sent1,sent2) > 0.9, then is it fair to assume s1 and s2 are similar

Question: According to BERT author Jacob Devlin: I'm not sure what these vectors are, since BERT does not generate meaningful sentence vectors. It seems that this is doing average pooling over the word tokens to get a sentence vector, but we never suggested that this will generate meaningful sentence representations. And even if they are decent representations when fed into a DNN trained for a downstream task, it doesn't mean that they will be meaningful in terms of cosine distance. (Since cosine distance is a linear space where all dimensions are weighted equally).
Answer: They might or might not be similar, the embeddings extracted by mean pooling the BERT output usually have high cosine similarity even though the input sentences are completely different.
Bert embeddings are not meant for sentence similarity task(SST), but there is some research combining Bert and SST.
Here are those resources,
SBERT paper: https://arxiv.org/abs/1908.10084
SBERT implementation: https://github.com/UKPLab/sentence-transformers


Very slow Wi-Fi with Intel 3165 on Ubuntu 16.04

Question: I have a Dell Inspiron 7559 with an Intel Wireless 3165-AC. I recently did a clean install of 16.04, replacing my old 14.04 installation, and have since been having trouble with my wireless card. The speed is usually very slow around 200-400 KB/s, and at times even drops to less than 100. In comparison, I used to get > 1 MB/s on 14.04 on the same network.
I tried upgrading to the latest firmware files (1.162), tried putting newer iwlwifi files in /lib/firmware, turned off power management, but nothing seems to help. Looking for some suggestions as to what could be wrong and what's the best way to fix it.
Answer: I own and use successfully two Intel wireless devices. I have honed a few techniques in several years and thousands of forum posts.
First, check the settings in the router. WPA2-AES is preferred; not any WPA and WPA2 mixed mode and certainly not TKIP. Second, if your router is capable of N speeds, you may have better connectivity with a channel width of 20 MHz in the 2.4 GHz band instead of automatic 20/40 MHz, although it is likely to affect N speeds. I also have better luck with a fixed channel, either 1, 6 or 11, rather than automatic channel selection. Also, be certain the router is not set to use N speeds only; auto B, G and N is preferred. After making these changes, reboot the router.
Next, I recommend that your regulatory domain be set explicitly. Check yours:
sudo iw reg get

If you get 00, that is a one-size-maybe-fits-all setting. Find yours here: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 Then set it temporarily:
sudo iw reg set IS

Of course, substitute your country code if not Iceland. Set it permanently:
gksudo gedit /etc/default/crda

Use nano or kate or leafpad if you don't have the text editor gedit.
Change the last line to read:
REGDOMAIN=IS

Proofread carefully, save and close the text editor.
Next, I'd set IPv6 to Ignore in Network Manager: http://docs.fedoraproject.org/en-US/Fedora/18/html/Installation_Guide/images/netconfig/network-connections-ipv6-ignore.png  This example is for ethernet, but you want wireless.
If these changes do not help, please try:
sudo modprobe -r iwlwifi
sudo modprobe iwlwifi 11n_disable=8

If it helps, make it permanent:
sudo -i
echo "options iwlwifi 11n_disable=8"  >>  /etc/modprobe.d/iwlwifi.conf
exit

Finally, Network Manager will default to ethernet if it's available. Please make your tests with the ethernet detached.


Flash BIOS before Lubuntu 12.10 install on Asus Eee PC 1015BX

Question: I would like to install Lubuntu 12.10 on an Asus Eee PC Seashell 1015BX, but have noticed that there are a number of BIOS updates on the Asus support page. Does anyone have any experience updating an Asus PC BIOS before installing Ubuntu (Lubuntu)? The laptop currently has Windows 7 Starter installed.
Answer: The short answer is if it isn't broke, don't fix it. Is there a feature that one of the BIOS updates offers that you expect to rely on? If not, don't bother. If you still feel that you should update your BIOS, generally there are a few ways of going about it. Sometimes there's a windows installer and you just run an executable that does the trick. I went to Asus's download page and all they offer is a zipped <code>.rom</code> file. That means you'll have to do it manually. I don't know the features available on your BIOS and your EEE PC probably doesn't have a disc drive, so I recommend using the Ultimate Boot CD (if you want to save the disc, you could even boot UBCD off a pen drive). Here's a forum thread that should help you on the UBCD site. Last time I flashed a BIOS was on a Pentium 4 with a CD, looks like in your case you're going to have to deal with the command prompt in freeDOS running off the UBCD (plus if you run it off a USB key, you may be able to store the BIOS rom on the same pen drive to flash the BIOS).
Comment: Thanks for your reply. I just checked the BIOS version compared to the updates and from what I can see, all of the important updates are older than my BIOS version. It looks like I dodged a bullet :-)


Sum of VLookups in Numbers?

Question: I may just be missing the right terminology, spreadsheets have never really been my thing.  But I'm struggling to combine SUM() and VLOOKUP() for my needs.  (Assuming these are even the functions I want to use, there could be something better that I'm just not noticing.)
Given a lookup table of Customers, for example:
Name  |  Miles from Office
--------------------------
Bob   |  3.4
Joe   |  9.1
Tom   |  2.9

And a table of Transactions, for example:
Date     | Customer | Amount
----------------------------
1/1/2019 | Bob      | $1.23
2/1/2019 | Tom      | $2.34
3/1/2019 | Bob      | $3.45
4/1/2019 | Bob      | $4.56
5/1/2019 | Joe      | $5.67

How can I get a sum of "Miles" for the transactions?  For any given transaction I could do:
=VLOOKUP("Bob", 'Customers'::A2:B4, 2)

And that would successfully return 3.4.  But if I were to wrap that expression in a SUM() then how would I get it to run the VLOOKUP() on each item in the range being summed?  I tried:
=SUM(VLOOKUP('Transactions'::B2:B6, 'Customers'::A2:B4, 2))

Which I didn't think would work (but was worth a try), and indeed it didn't and just returned the first value, in this case 3.4.
(Specifically using Numbers in iCloud in my browser, if that makes a difference.)
Answer: Create another column in Transactions. Put the VLOOKUP in that column. So then you have the miles for each one: 3.4, 2.9, 3.4, 3.4, 9.1. Then in another cell, use SUM(D2:D6) to add those up. If you don't want that column visible you can always hide it.

Sum of VLookups in Numbers?


How to remove the comma between Link multi-value field

Question: I am using the Link module's link field. When I create a multi-valued field, it automatically adds a comma between them. I would like to remove this comma. For some other field types, such as term reference, I believe there is a way to set this in the UI, but I don't see this for the Link field.
Answer: My suggestion would be to modify the way the links are displaying using the Display Suite module's field templates. Field templates gives you a high level of control over all the ways Drupal outputs the fields.
I found this tutorial that is pretty in depth, but in short you want to add the Display Suite module, enable it and the "Display Suite Extras" module that comes with it.
Next go to the display suite settings and enable "Field Templates." This is under Structure > Display Suite > Extras.
Once those are enabled, find the display settings for your content type (Structure > Content Types > YOUR CONTENT TYPE > Manage Display.
On that page, in the vertical tabs at the bottom you'll see an option to set a layout. Select "One column" or "Reset". Selecting a basic layout here will enable the additional features Display Suite offers.
After your layout is set, you'll see many more options on each field for how it is displayed. You can set the field template to "Expert" and you'll get control of the wrappers, prefix and suffix content (i.e. comma or no comma), and a lot of other stuff.

I hope that points you in the correct direction. Play around with DS a bit and I think you'll really like the control it gives you.
Comment: I've never used this aspect of Display Suite Extras before and it looks interesting. However, it wont work in my situation. 1) For particular reasons, I'm displaying this view with fields and not Content, so I can't set a view mode 2) I installed the module and took a look at the settings on my field, and I don't see a way to set the separator for multi-valued fields. I'm going to try doing a preprocess on the field and see if I can target it that way.
Answer: I figured it out. I forgot that I wasn't using a display mode but a views field display. I found that on the field settings, it gave you the option of setting the separator, which was a comma by default. I removed the comma and my issue was solved.
Comment: This does not answer the original question, in cases where views is not used.


What is the difference between the brock and wolf potions?

Question: What's the difference between the brock and wolf potions? They're both described as increasing critical effect chance for the same attributes but brock costs more and also has a negative effect. Wolf has no negative effects. It seems as if brock is redundant?
Answer: According to the Witcher Wiki:
<code>Brock potion:

Poison +15%
Bleeding +15%
Incineration +15%
Resistance to poison -50%
Resistance to bleeding -50%
Resistance to incineration -50%
Chance of incineration  with Igni +15%
Aard critical effects chance +15%
Toxicity: 50

Wolf potion:
Poison +15%
Bleeding +15%
Incineration +15%
Chance of incineration with Igni: +32%
Aard critical effect chance: +15%
Toxicity: 25
</code>
As you can see, there is a difference between the two potions, and that is the resistance to ... the Brock potion has. To me, it seems redundant, as it's toxicity amount is high, and it should be used perhaps together with the Golden Oriole potion, to neutralize the Brock's negative effects.
In fact, the Wolf potion has as you said:

1/2 the toxicity of Brock
No side effects (whereas Brock -50% of all resistances)
Same duration as Brock
Same 15% to all critical effects
is cheaper than Brock (formula)

Seems like a game mechanic bug to me.
Comment: wolf has double incinerationg chance with ignit, also. This looks like it might be a copy + paste error in an XML somewhere.
Comment: That is exactly what I thought. See this last post on this website, where someone has investigated the corresponding XML files: http://www.gog.com/en/forum/the_witcher_2/brock_potion_bugged_or_as_intended/page2
Answer: If you go the way of the alchemist there are some advantages to being poisoned. Also the negative effects of potions can be lessened/removed. Thus you might prefer to use a potion with higher toxicity if you specialize in alchemy.


Administrator configuration menu limited. Can't uncheck "Use system value" case

Question: I just updated magento to version 2.1.4 and this type of bug show off right after the update. (cf. screen)

This error happens on every "Store View" form.
Can you help me ?
Answer: Ok I just found the answer !
It was not a problem about Magento 2.1.4, I have to export a configuration that was saved under: "../app/etc/config.local.php". I removed it and all worked normally.


FullScreen Swing Components Fail to Receive Keyboard Input on Java 7 on Mac OS X Mountain Lion

Question: Update 12/21:
7u10 was recently released.  Confirmed that:

The issue still persists
Thankfully, the workaround still functions!

Update 11/7:
And we have a workaround!
Leonid Romanov from Oracle on the openjdk.java.net mailing list provided some insight as to what's going on:

Well, although I'm not 100% sure yet, but it looks like when we enter full screen some other window becomes the first responder, hence the beep. Could you please try the following workaround: after calling setFullScreenWindow() on a frame, call setVisible(false) followed by setVisible(true). This, in theory, should restore the correct first responder.

The snippet of code that seems to work is simply:
dev.setFullScreenWindow(f);
f.setVisible(false);
f.setVisible(true);

I have updated the sample code with the ability to toggle this fix on and off; it is required every time a window enters fullscreen.
In the larger context of my more complex application, I am still running into keyboard focus issues on subcomponents within the fullscreen window, where a mouse click causes my window to lose focus. (I'm guessing it's going to the undesired first responder window referenced above.)  I'll report back when I have more information about this case - I cannot reproduce it in the smaller sample yet.

Update 10/31:
Major update to the sample code:

Includes toggle between FullScreen exclusive and Lion-style FullScreen modes
Listens to the KeyboardFocusManager to display the hierarchy for the currently focused component
Uses both input maps and KeyListeners to try to capture input

Also did some more digging with coworkers to try to isolate issues:
On one front, we tried overriding some methods in RT.jar to see if there were problems with the way the screen device is being selected.  Also tried were the entry points to the Toolkit.beep() functionality to see if the alert sounds were coming from the Java side - appears not.
On another front, it was clear that not even the native side is receiving keyboard events.  A coworker attributes this to a switch from an AWTView to a NSWindow in 7u6.
A selection of existing Oracle bugs has been found, which you can look up here:

8000276 : [macosx] graphicsDevice.setFullScreenWindow(frame) crashes JVM
8000430 : [macosx] java.awt.FileDialog issues on macosx
7175707 : [macosx] PIT: 8 b43 Not running on AppKit thread issue again

Update 10/26:
Thanks to the comment by @maslovalex below regarding an Applet working on 7u5, I went back and painstakingly examined compatibility with the JDK versions for OSX:

10.7.1 with 7u4: Fullscreen Works!
10.7.1 with 7u5: Fullscreen Works!
10.7.5 with 7u5: Fullscreen Works!
10.7.5 with 7u6: Fullscreen Breaks :(

Combined with the other tests noted elsewhere, it's clear there was an issue introduced with 7u6 that remains in 7u7 and 7u9, and it affects both Lion 10.7 and Mountain Lion 10.8.
7u6 was a major milestone release, bringing full support of the JRE and JDK to Mac OS X and also including Java FX as part of the distribution.  Further info is available in the Release Notes and the Roadmap.  It's not tremendously surprising that such an issue could crop up as support shifts to Java FX.
The question becomes:

Will Oracle fix this in a near-term release of the JDK? (If you have links to existing bugs, please include them here.)
Is a workaround possible in the interim?

Other updates from today:

I incorporated the Apple extensions approach to fullscreen mode as an alternate path of exploration (updated sample code pending cleanup).  The good news: input works!  The bad news: there really don't seem to be any kiosking/isolation options.
I tried killing the Dock - directly or with an App - as I understand the Dock is responsible for Command-Tab app switching, Mission Control, and Launch Pad, only to find out that it's responsible for the handling of fullscreen apps as well!  As such, the Java calls become non-functional and never return.
If there's a way to disable Command-Tab (and Mission Control and Launchpad and Spaces) without affecting the Dock's fullscreen handling, that would be extremely useful. Alternatively, one can try to remap certain keys such as Command, but that will affect the ability to use that modifier elsewhere in the program and the system itself (not exactly ideal, when you need to Command-C to copy some text).

I've had no luck with KeyListeners (I'm not receiving any callbacks), but I have a few more options to try.

Based on a coworker's suggestion, I tried ((sun.lwawt.macosx.LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive() via reflection.  The idea was that it:
is a native method with the comment "Returns true if the application (one of its windows) owns keyboard focus.". Calls to this method were added in CPlatformWindow.java in the past few months related to focus logic. If it returns false in your test code, it's probably part of the problem.
Unfortunately, everywhere I checked it, the method returned true.  So even according to the low level system, my windows should have keyboard focus.

My previous optimism regarding the JAlbum fix has been dashed.  The developer posted a response on their forum that explains how they simply removed proper fullscreen support on OS X while running Java 7.  They have a bug into Oracle (and I'm hoping to get the bug number).

Update 10/25:
I have now also tried Java 7u9 on Lion 10.7.4 and have seen the exact same issue, so it's JDK- not OS-specific.
The core question has become whether you can embed in a fullscreen window core Swing Components that have default handling for keyboard input (JTextField/JTextArea or even editable combo boxes) and expect them to behave normally (without having to resort to rebuilding their basic key bindings manually).  Also in question is whether other stalwarts of windowed layouts, such as using tab for focus traversal, should work.
The ideal goal would be to have the ability take a windowed Swing app with all of its buttons, tabs, fields, etc. and run it in fullscreen exclusive/kiosk mode with most functionality intact.  (Previously, I have seen that Dialog pop ups or ComboBox drop downs do not function in fullscreen on Java 6 on OS X, but other Components behave fine.)
I'll be looking into the eawt FullScreen capabilities, which will be interesting if they support kiosk lock down options, such as eliminating Command-Tab application switching.

Original Question:
I have a Swing app that for years has supported FullScreen (exclusive) mode on Mac OS X up through Java 6.  I've been doing compatibility testing with the latest Mountain Lion release (10.8.2 Supplemental) and Oracle's JDK 7 and noticed a glaring issue while in that mode: mouse movement and clicks work fine, but keyboard input is not delivered to the components.
(I've narrowed this down in a test case below to not being able to type into a simple JTextField while in fullscreen mode.)
One symptom is that each key press results in a system beep, as if the OS is disallowing keyboard events from being delivered to the application.
Separately, my application has an exit hook installed, and the Command-Q combo will trigger that hook - it's clear that the OS is listening to standard key combos.
I have tested this separately on three different Macs with various installs:

On Apple Java 6u35 and 6u37: both windowed and fullscreen modes receive input.
On Oracle Java 7u7 and 7u9: windowed mode works as expected while fullscreen has the symptoms above.

This may have been previously reported:
Java Graphics Full Screen Mode not Registering Keyboard Input.
However, that question is not specific about the Java version or platform.
Additional searching has turned up a separate fullscreen option introduced in Lion:
Fullscreen feature for Java Apps on OSX Lion.
I have yet to try using this approach, as keyboard input seems integral to the target use cases of FullScreen Exclusive mode, such as games.
There is some mention in the JavaDoc for this mode that input methods might be disabled.  I tried to call the suggested Component.enableInputMethods(false), but it seemed to have no effect.
I'm somewhat optimistic that there's a solution to this issue based on an entry in the release notes of a Java app I came across (JAlbum). A stated fix for 10.10.6: "Keyboard support wasn't working when running the full screen slide show on Mac and Java 7"
My test case is below.  It is lightly modified from the second example in this issue (which, unmodified, also exhibits my problem): How to handle events from keyboard and mouse in full screen exclusive mode in java?
In particular, it adds a button to toggle fullscreen.
import java.lang.reflect.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.beans.*;

/** @see https://stackoverflow.com/questions/13064607/ */
public class FullScreenTest extends JPanel {
    private GraphicsDevice dev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    private JFrame f = new JFrame("FullScreenTest");

    private static final String EXIT = "Exit";
    private Action exit = new AbstractAction(EXIT) {
        @Override
        public void actionPerformed(ActionEvent e) {
            Object o = dev.getFullScreenWindow();
            if(o != null) {
                dev.setFullScreenWindow(null);
            }
            f.dispatchEvent(new WindowEvent(f, WindowEvent.WINDOW_CLOSING));
        }
    };
    private JButton exitBTN = new JButton(exit);

    private JTextField jtf = new JTextField("Uneditable in FullScreen with Java7u6+ on Mac OS X 10.7.3+");

    private JLabel keystrokeLabel = new JLabel("(Last Modifier+Key Pressed in JTextField)");

    private JLabel jtfFocusLabel = new JLabel("(JTextField Focus State)");

    private JLabel focusLabel = new JLabel("(Focused Component Hierarchy)");

    private JCheckBox useOSXFullScreenCB = new JCheckBox("Use Lion-Style FullScreen Mode");

    private JCheckBox useWorkaroundCB = new JCheckBox("Use Visibility Workaround to Restore 1st Responder Window");

    private static final String TOGGLE = "Toggle FullScreen (Command-T or Enter)";
    private Action toggle = new AbstractAction(TOGGLE) {
        @Override
        public void actionPerformed(ActionEvent e) {
            Object o = dev.getFullScreenWindow();
            if(o == null) {
                f.pack();

                /**
                 * !! Neither of these calls seem to have any later effect.
                 * One exception: I have a report of a
                 * Mini going into an unrecoverable black screen without setVisible(true);
                 * May be only a Java 6 compatibility issue.  !!
                 */
                //f.setVisible(true);
                //f.setVisible(false);

                if(!useOSXFullScreenCB.isSelected()) {
                    // No keyboard input after this call unless workaround is used
                    dev.setFullScreenWindow(f);

                    /**
                     * Workaround provided by Leonid Romanov at Oracle.
                     */
                    if(useWorkaroundCB.isSelected()) {
                        f.setVisible(false);
                        f.setVisible(true);
                        //Not necessary to invoke later...
                        /*SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                f.setVisible(false);
                                f.setVisible(true);
                            }
                        });*/
                    }
                }
                else {
                    toggleOSXFullscreen(f);
                }
            }
            else {
                dev.setFullScreenWindow(null);
                f.pack();
                f.setVisible(true);
            }

            isAppActive();
        }
    };
    private JButton toggleBTN = new JButton(toggle);

    public FullScreenTest() {
        // -- Layout --
        this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

        exitBTN.setAlignmentX(JComponent.CENTER_ALIGNMENT);
        exitBTN.setMaximumSize(new Dimension(Short.MAX_VALUE, 50));
        this.add(exitBTN);

        jtf.setAlignmentX(JComponent.CENTER_ALIGNMENT);
        jtf.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
        this.add(jtf);

        keystrokeLabel.setAlignmentX(JComponent.CENTER_ALIGNMENT);
        keystrokeLabel.setMaximumSize(new Dimension(Short.MAX_VALUE, 50));
        keystrokeLabel.setHorizontalAlignment(SwingConstants.CENTER);
        keystrokeLabel.setForeground(Color.DARK_GRAY);
        this.add(keystrokeLabel);

        jtfFocusLabel.setAlignmentX(JComponent.CENTER_ALIGNMENT);
        jtfFocusLabel.setMaximumSize(new Dimension(Short.MAX_VALUE, 50));
        jtfFocusLabel.setHorizontalAlignment(SwingConstants.CENTER);
        jtfFocusLabel.setForeground(Color.DARK_GRAY);
        this.add(jtfFocusLabel);

        focusLabel.setAlignmentX(JComponent.CENTER_ALIGNMENT);
        focusLabel.setMaximumSize(new Dimension(Short.MAX_VALUE, 50));
        focusLabel.setHorizontalAlignment(SwingConstants.CENTER);
        focusLabel.setForeground(Color.DARK_GRAY);
        this.add(focusLabel);

        useOSXFullScreenCB.setAlignmentX(JComponent.CENTER_ALIGNMENT);
        useOSXFullScreenCB.setMaximumSize(new Dimension(Short.MAX_VALUE, 50));
        useOSXFullScreenCB.setHorizontalAlignment(SwingConstants.CENTER);
        this.add(useOSXFullScreenCB);

        useWorkaroundCB.setAlignmentX(JComponent.CENTER_ALIGNMENT);
        useWorkaroundCB.setMaximumSize(new Dimension(Short.MAX_VALUE, 50));
        useWorkaroundCB.setHorizontalAlignment(SwingConstants.CENTER);
        this.add(useWorkaroundCB);

        toggleBTN.setAlignmentX(JComponent.CENTER_ALIGNMENT);
        toggleBTN.setMaximumSize(new Dimension(Short.MAX_VALUE, 50));
        this.add(toggleBTN);

        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setResizable(false);
        f.setUndecorated(true);
        f.add(this);
        f.pack();

        enableOSXFullscreen(f);

        // -- Listeners --

        // Default BTN set to see how input maps respond in fullscreen
        f.getRootPane().setDefaultButton(toggleBTN);

        // Explicit input map test with Command-T toggle action from anywhere in the window
        this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
                KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
                toggle.getValue(Action.NAME));
        this.getActionMap().put(toggle.getValue(Action.NAME), toggle);

        // KeyListener test
        jtf.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
                String ktext = "KeyPressed: "+e.getKeyModifiersText(e.getModifiers()) + "_"+ e.getKeyText(e.getKeyCode());
                keystrokeLabel.setText(ktext);
                System.out.println(ktext);
            }
        });

        // FocusListener test
        jtf.addFocusListener(new FocusListener() {
            public void focusGained(FocusEvent fe) {
                focused(fe);
            }
            public void focusLost(FocusEvent fe) {
                focused(fe);
            }
            private void focused(FocusEvent fe) {
                boolean allGood = jtf.hasFocus() && jtf.isEditable() && jtf.isEnabled();
                jtfFocusLabel.setText("JTextField has focus (and is enabled/editable): " + allGood);
                isAppActive();
            }
        });

        // Keyboard Focus Manager
        KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        focusManager.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
                if (!("focusOwner".equals(e.getPropertyName()))) return;
                Component comp = (Component)e.getNewValue();
                if(comp == null) {
                    focusLabel.setText("(No Component Focused)");
                    return;
                }
                String label = comp.getClass().getName();
                while(true) {
                    comp = comp.getParent();
                    if(comp == null) break;
                    label = comp.getClass().getSimpleName() + " -> " + label;
                }
                focusLabel.setText("Focus Hierarchy: " + label);
                isAppActive();
            }
        });
    }

    /**
     * Hint that this Window can enter fullscreen.  Only need to call this once per Window.
     * @param window
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    public static void enableOSXFullscreen(Window window) {
        try {
            Class util = Class.forName("com.apple.eawt.FullScreenUtilities");
            Class params[] = new Class[]{Window.class, Boolean.TYPE};
            Method method = util.getMethod("setWindowCanFullScreen", params);
            method.invoke(util, window, true);
        } catch (ClassNotFoundException e1) {
        } catch (Exception e) {
            System.out.println("Failed to enable Mac Fullscreen: "+e);
        }
    }

    /**
     * Toggle OSX fullscreen Window state. Must call enableOSXFullscreen first.
     * Reflection version of: com.apple.eawt.Application.getApplication().requestToggleFullScreen(f);
     * @param window
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    public static void toggleOSXFullscreen(Window window) {
        try {
            Class appClass = Class.forName("com.apple.eawt.Application");

            Method method = appClass.getMethod("getApplication");
            Object appInstance = method.invoke(appClass);

            Class params[] = new Class[]{Window.class};
            method = appClass.getMethod("requestToggleFullScreen", params);
            method.invoke(appInstance, window);
        } catch (ClassNotFoundException e1) {
        } catch (Exception e) {
            System.out.println("Failed to toggle Mac Fullscreen: "+e);
        }
    }

    /**
     * Quick check of the low-level window focus state based on Apple's Javadoc:
     *  "Returns true if the application (one of its windows) owns keyboard focus."
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    public static void isAppActive() {
        try {
            Class util = Class.forName("sun.lwawt.macosx.LWCToolkit");
            Method method = util.getMethod("isApplicationActive");
            Object obj = method.invoke(Toolkit.getDefaultToolkit());
            System.out.println("AppActive: "+obj);
        } catch (ClassNotFoundException e1) {
        } catch (Exception e) {
            System.out.println("Failed to check App: "+e);
        }
    }

    public static void main(String[] args) {
        System.out.println("Java Version: " + System.getProperty("java.version"));
        System.out.println("OS Version: " + System.getProperty("os.version"));

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                FullScreenTest fst = new FullScreenTest();
                if(!fst.dev.isFullScreenSupported()) {
                    System.out.println("FullScreen not supported on this graphics device.  Exiting.");
                    System.exit(0);
                }
                fst.toggle.actionPerformed(null);
            }
        });
    }
}

Comment: A have exactly the same issue. Couple of weeks ago I have posted bug request to Oracle (with simple Applet code to reproduce, because with 7u7 I was able to reproduce it only with applets) - so far no answer. You can also report it (maybe it will be make things happen faster). BTW. with 7u5 things are working.
Comment: Thanks for the info @maslovalex.  Very interesting that 7u5 worked for you.  I'll try testing that on another machine on my end.
Comment: Actually in jAlbum they simply do not use FullScreen for java 7 in osx (undecorated correctly sized frame) - check slide show. And if I run it with java 6 slide show goes straight to FS Exclusive)
Comment: Also @maslovalex, do you happen to have a link to that Oracle bug you mentioned?
Comment: no,there is no bug visible - it's in "internal review"
Comment: Hi. I also found some focus issues some time ago with Mac OSX and Java 7. Have a look in http://stackoverflow.com/questions/12278546/focus-issues-with-java7-modal-dialogs-on-mac-osx. There are a couple of workarounds there and that maybe can help.
Comment: You made my day! After several hours of trying and helplessness, I found this post. Thank you so much!!!
Comment: Wish I'd found this when I was experiencing this error. Unfortunately, I wasn't coming from a working program, so I figured the fault was mine, rather than it being a bug. This was my SO post from 9 months ago: http://stackoverflow.com/questions/14317352/bug-java-swing-key-bindings-lose-function-with-jdk-7-in-osx-with-awt-setfullscr/19751521?noredirect=1#19751521 and I did end up reporting it as a bug. Doesn't seem that any action has been taken, though it's good to know there is a work around!
Answer: Instead, use key bindings, as shown in this FullScreenTest. Also, consider a DocumentListener, shown here, for text components.
Comment: Thanks for the update.  The FullScreenTest you reference (and initially contributed, it appears) is exactly the example I used as a starting point for my sample above.  My first tests involved using your FullScreenTest directly and unchanged, including its use of key bindings.  Unfortunately, it exhibits the identical issues referenced above, which is why I didn't think that key bindings were the issue.
Comment: Sorry, I don't have 10.8 to test. Would maximized via `setExtendedState()` be an alternative?
Answer: This is because the component to which you added the other has now lost focus, you can fix this by either:

calling requestFocus() on the component instance to which you add KeyBindings

or

alternatively use JComponent.WHEN_IN_FOCUSED_WINDOW with KeyBindings:
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, 0),
                        "doSomething");
component.getActionMap().put("doSomething",
                         anAction);

Reference:

How to Use Key Bindings
Comment: I'll give this a shot in the morning.  One of the reasons I didn't think that focus was an issue was that the JTextField gains the focus ring when a mouse clicks in it.  Also, you can use the mouse to select text.  My understanding has been that these events would give the component focus for subsequent KeyEvents - and that JTextField would have its own bindings for basic text input/standard typing, but apparently that might not be the case by default when in FullScreen.
Answer: I think I finally found a solution, registering click listeners against to the JFrame itself. (This is a class which extends JFrame, hence all the "this" references.)
/**
 * Toggles full screen mode. Requires a lot of references to the JFrame.
 */
public void setFullScreen(boolean fullScreen){
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice dev = env.getDefaultScreenDevice();//Gets the main screen
    if(!fullScreen){//Checks if a full screen application isn't open
        this.dispose();//Restarts the JFrame
        this.setVisible(false);
        this.setResizable(true);//Re-enables resize-ability.
        this.setUndecorated(false);//Adds title bar back
        this.setVisible(true);//Shows restarted JFrame
        this.removeMouseListener(macWorkAround);
        this.pack();
        this.setExtendedState(this.getExtendedState()|JFrame.MAXIMIZED_BOTH);//Returns to maximized state
        this.fullScreen = false;
    }
    else{
        this.dispose();//Restarts the JFrame
        this.setResizable(false);//Disables resizing else causes bugs
        this.setUndecorated(true);//removes title bar
        this.setVisible(true);//Makes it visible again
        this.revalidate();
        this.setSize(Toolkit.getDefaultToolkit().getScreenSize());
        try{
            dev.setFullScreenWindow(this);//Makes it full screen
            if(System.getProperty("os.name").indexOf("Mac OS X") >= 0){
                this.setVisible(false);
                this.setVisible(true);
                this.addMouseListener(macWorkAround);
            }
            this.repaint();
            this.revalidate();
        }
        catch(Exception e){
            dev.setFullScreenWindow(null);//Fall back behavior
        }
        this.requestFocus();
        this.fullScreen = true;
    }
}

private MouseAdapter macWorkAround = new MouseAdapter(){
    public void mouseClicked(MouseEvent e){
        MainGUI.this.setVisible(false);
        MainGUI.this.setVisible(true);
    }
};


Phase lock loop frequency of reference signal

Question: I am writing code for a phase locked loop in MATLAB.  Up to now, I assumed that the frequency of the input signal is given (known) and I choose the frequency of my VCO close or exactly the same as the reference signal. What if I do not know the reference signal frequency? How can I approach the problem in that case?  How can I choose the frequency of the VCO?
Comment: The whole point of the reference signal is that it is one known frequency from which to stabilize the frequency of the VCO at the desired value using the PLL. You have to assume that the reference is one value and compute VCO and PLL parameters from there.
Answer:
However I am wondering what if I do not know the reference signal frequency, how can I approach the problem in that case ? How can I choose the frequency of VCO?

The VCO frequency should be equal to the desired output frequency, or cover the range of desired output frequencies. It isn't related to the reference frequency.
But to go any further, you do have to know your range of accepted reference frequencies. Because you'll need to choose a divide ratio to divide down the output frequency, and possibly the reference frequency, to obtain two equal frequencies for comparing to each other.


Why does minimum pressure point move towards leading edge with aoa?

Question: why is it that the minimum pressure peak over the top surface moves towards the front of the aerofoil with angle of attack increase?
Answer: The minimum pressure point -- the suction peak -- is the location of the highest velocity around the airfoil.
The flow must accelerate to get around a turn, so this ends up correlating with the curvature of the airfoil.
At zero alpha of a symmetrical airfoil, there is a streamline that hits the leading edge exactly -- this streamline comes to a stop and is called the stagnation streamline.  Every streamline above the stagnation streamline goes over the airfoil.  Every streamline below, goes under.
The streamline immediately above the stagnation streamline can be thought of as the streamline 'nearest' the airfoil all the way around.  It does the tightest turning.  When the airfoil is at zero degrees alpha, its path is somewhat mild as it accelerates up and around the airfoil.
When the alpha increases, the stagnation point (where the stagnation streamline meets the airfoil) moves to the bottom surface (below the leading edge).  The streamline just above now must flow up, around the leading edge, and then down the top surface of the airfoil.  It has to make a very sharp turn all the way around the leading edge.  This requires a lot of acceleration and leads to very high velocity -- a very strong suction peak.
Comment: Hi Rob, how does the flow accelerate over the leading edge itself please?
Comment: @MintyPythonn Somewhat sloppy description (exact description is with a set of differential equations) is that the air can't go through the wing, so it is deflected up. It then tries to continue straight by inertia as the wing curves away from it, but then there is less of it near the wing, so low pressure region forms and the pressure gradient accelerates the air towards the wing and aft. The flow has to obey the Bernoulli's principle that lower pressure means higher velocity, but note that that is an equivalence, not cause and effect and the pressure gradient is closer to being the cause.
Answer: Whomever drew those "pressure distribution" vectors doesn't know what he/she is doing.
Two points: 1. Sometimes we "normalize" pressure values by subtracting the absolute value, so we can represent lower than free stream pressure as suction, (which it is not). To accurately portray pressure vectors,  you need to display their absolute values. They should all point towards the wing surface.
2. Secondly, pressure is the result of aerodynamic force of air molecules impacting and rebounding off the wing. The force exerted on a wing from the result of the impact of those fluid particles on a surface is caused directly by the change in momemtum of the particle when it changes direction.
<code>F=ma, or.
F=m(dV/dt) or.
F=d(mV)/dt i.e.,
F=dP/dt  (P is mV momentum)
</code>
Understanding this makes it much more intuitive, (qualitatively), why the pressure distribution diagram looks like it does, and why it changes as AOA changes. Molecules impacting a surface are no different in this regard than a baseball impacting a bat. The steeper the impact angle, and/or the higher the velocity, the higher the force will be.
Comment: Hi, sorry I still don't get why the point of  minimum pressure moves towards the leading edge with aoa? I just found them online
Comment: @Minty Python, If the higher pressure occurs at the higher impact angles and velocities, then the higher the AOA, the higher impact angles (and the higher velocities at impact), occur in *front* of the aircraft, not at the rear.


Finding Sphere radius given radius of intersecting circle and distance from the top of the sphere

Question: How can I find the radius of a sphere if I am given the radius of an intersecting circle- 24cm. The only other unit I am given is the distance from the center of the circle to the  top- most point of the sphere- 32cm. How would I go about solving this problem.
Answer: In the picture below, you are given that the length in green is $24$ cm and that the length in blue is $32$ cm. You want to calculate the length in red which is the hypotenuse of the triangle with sides $24$ cm and $32$ cm. So the length in red is equal to $(24^2+32^2)^{1/2}=40$ cm.
Comment: Thanks for the help, but what is to say that hypotenuse is the radius of the sphere, there is nothing saying the intersecting circle is the midpoint.
Comment: The hypotenuse starts at the center of the sphere and ends at a point in which the circle is intersecting the sphere which must be part of the boundary of the sphere. Therefore, it is the radios of the sphere.
Answer: The equation of a sphere can be given by
$$x^2+y^2=r^2-z^2$$
where  $r^2-z^2$ is the square of radius of any intersecting circle at height $z$ from center of sphere
Hence
$$r^2-z^2=24^2$$
and $r-z=32$.
Solving simultaneously
\begin{align}
r&=25 \text{ cm (radius of sphere)} \\
z&=-7 \text{ cm}
\end{align}


No sound while "listening" to the radio

Question: Mplayer opens a link and it seems to be running smoothly. The only problem is that there is no sound to listen to. Apart from this there are no problems with sound in system.
Comment: Can you provide an example of a link that you try?
Comment: Yes, of course: mplayer mms://stream.polskieradio.pl/program3
Answer: I did some testing.
There is no problem with your ubuntu or mplayer.
The stream you mentioned just consists of silence.
if you want to doublecheck, try another stream like, for example, this one:
mplayer mms://a1075.l1062331074.c10623.g.lm.akamaistream.net/D/1075/10623/v0001/reflector:31074

Comment: Agreed. Even on a Fedora machine it does not work. A quick Google found [this](http://forums.screamer-radio.com/viewtopic.php?f=3&t=12292) though.
Answer: The asx file for Polskie Radio Program III shows 3 URLs:
<ref href = "mms://stream.polskieradio.pl/program3">
<ref href = "rtsp://stream.polskieradio.pl/program3">
<ref href = "http://stream.polskieradio.pl/program3">

and certainly at the moment all 3 work for me with MPlayer, a slightly edited example using the http file:
andrew@skamandros~$ mplayer -quiet 'http://stream.polskieradio.pl/program3'
MPlayer SVN-r37183-4.8.2 (C) 2000-2014 MPlayer Team

Playing http://stream.polskieradio.pl/program3.
Resolving stream.polskieradio.pl for AF_INET6...
[...]

Cache size set to 185 KBytes
Cache fill: 18.05% (34013 bytes)

ASF file format detected.
[asfheader] Audio stream found, -aid 1
==========================================================================
Trying to force audio codec driver family ffmpeg...
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 55.60.103 (internal)
AUDIO: 48000 Hz, 2 ch, floatle, 96.0 kbit/3.12% (ratio: 12000->384000)
Selected audio codec: [ffwmav2] afm: ffmpeg (DivX audio v2 (FFmpeg))
==========================================================================
AO: [alsa] 48000Hz 2ch floatle (4 bytes per sample)
Video: no video
Starting playback...

Perhaps try again and all will be well now...

No sound while "listening" to the radio


Will a deactivated SIM card continue to improve location accuracy?

Question: I'm wondering if a prepaid SIM card that ran out of funds still in my iPad will continue to improve the devices location accuracy (by scanning nearby cell towers and apply triangulation)?
Answer:
Will a deactivated SIM card continue to improve location accuracy?

It doesn't matter because it's a moot point.  The cellular location services improves the performance of your location tracking by augmenting the GPS data, but it cannot improve the accuracy.

Improve GPS accuracy by disabling cellular data

If you were just going off of the location data provided by the carrier, it would be at best "broad stroke" in terms of accuracy.  Existing GPS is already accurate down to the cm (centimeter) range; how well your phone performs depends on the GPS chip that your phone uses.  Roughly speaking, it'll give you accuracy within a couple of meters.


Are there any stats for local Google v. Google.com usage?

Question: Are there any stats for web usage which have attempted to measure how many users in a given country use Google.com and how many use the local Google (e.g. Google.co.uk)?
Answer: Checkout the Experian Hitwise Stats:
US:
http://www.hitwise.com/us/resources/data-center
UK:
http://www.hitwise.com/uk/resources/data-center
The "Top Websites and Search" report should be of interest.
Comment: thanks. they say 85% google.co.uk, 5% google.com, 10% the rest. i'll go with that.


Conditions needed to approximate a Binomial distribution using a Normal distribution?

Question: Okay. So, many sources state different conditions for approximating binomial using normal. Variations I've seen are as follows. Assuming that we have Bin(n,p):
1. np and n(1-p) are both large (say, 20 or bigger)
2. large n, p close to 0.5
3. large n, np>9(1-p)
My questions:
1. Are all 3 of these valid? Justify your answer.
2. Is there a set of conditions which can summarise all 3 given above (if they are valid)?
Note: Before any of you say "First, what is your opinion about this?", I personally don't know much about these distributions since I'm studying stats at a basic level. I know quite a few distributions and a bit about pdf's, cdf's, mgf's but not really that much more
Answer: First, versions of all three of your conditions can be useful. Practically speaking, the main goal is to keep the approximating normal distribution from putting much of its probability below $0$ or above $n.$
This idea gives rise to your #3 as follows: To keep most of the normal probability above $0$, you want normal parameters $\mu$ and
$\sigma$ to satisfy
$$ 0 < \mu - 3\sigma = np - 3\sqrt{np(1-p)}$$
Which implies
$ np > 3\sqrt{np(1-p)}$ or $np/(1-p) > 9.$ Some authors are happy enough
with $np/(1-p) > 5.$  In the best case, you can expect only about two-place accuracy when approximating binomial probabilities by normal ones.
Rhe stricter rule usually makes the approximation a little better. [A similar argument to ensure $n > \mu - 3\sigma$ gives the same kind
of bound: $n(1-p)/p > 9$ (or 5).]
The rule that the smaller of $np$ and $n(1-p)$ should exceed some number
is just a simplified version of the above where the denominator in the previous argument is set to 1. I have seen suggested bound as small as 5, but 20 will
usually give better results.
The rule that $p \approx 1/2$ just recognizes that the approximating normal
distribution is symmetrical, and the binomial is also symmetrical when $p=1/2.$
Saying that $n$ should be 'large' is always a safe suggestion.

Three further comments on normal approximation to the binomial are also relevant.
(a) It is important to use the continuity correction unless $n$ is several hundred.
(b) A Poisson approximation is often better than a normal approximation,
especially if $n$ is large and $p$ is small.
(c) Nowadays, modern software (R, SAS, Minitab, MatLab, etc.) provides the opportunity to get exact binomial probabilities. In practical situations
the normal approximation is usually avoided.
[But the approximation persists
in theoretical probability texts: It is a nice
illustration of the Central Limit Theorem. It makes doing
exercises possible by using the (still ubiquitous) printed table of the normal
CDF in the 'back of the book'.]

Some illustrative examples using R statistical software.
Breaks all the rules except $p = .5$, yet the normal approximation
happens to work quite well.
Let $X \sim Binom(3, .5).$ Find $P(X = 2) = P(1.5 < X < 2.5).$
<code>  dbinom(2, 3, .5)
  ## 0.375       # exact
  mu = 3*.5;  sg = sqrt(3*.5*.5); diff(pnorm(c(1.5, 2.5), mu, sg))
  ## 0.3758935   # norm aprx
</code>
Large $n$ and small $p$. Satisfies all rules, but normal approximation is
relatively poor and Poisson approximation is better.
Let $X \sim Binom(1000, .03)$ Find $P(X \le 2)$.
<code> pbinom(20, 1000, .03)
 ## 0.03328078      # exact via binom CDF
 sum(dbinom(0:20, 1000, .03))
 ## 0.03328078      # exact via binom PDF
 mu = 1000*.03; sg = sqrt(1000*.03 *.97);  pnorm(20.5, mu, sg)
 ## 0.03911311      # relatively poor normal aprx
 ppois(20, mu)
 ## 0.03528462      # better Poisson aprx
</code>
Rules satisfied and normal approximation gives 2-place accuracy.
Let $X \sim Binom(100, .3).$  Find $P(24 < X \le 35) = P(24.5 < X < 35.5).$
<code> diff(pbinom(c(24, 35), 100, .3))
 ## 0.7703512       # exact
 sum(dbinom(25:35, 100, .3))
 ## 0.7703512       # exact
 mu = 100*.3;  sg=sqrt(100*.3*.7);  diff(pnorm(c(24.5, 35.5), mu, sg))
 ## 0.7699377       # relatively good normal aprx
 diff(ppois(c(24, 35), mu))
 ## 0.6853745       # inappropriate Poisson 'aprx'
</code>

The figures below show blue bars for binomial probabilities, smooth curves for
normal densities, small circles for Poisson probabilities, and vertical dotted lines to bound approximating areas. Red indicates a relatively poor fit.
Answer: The usual conditions are that $n\geq 50$ and both $np$ and $n(1-p)>5$.
Note that if $p$ is close to $0.5$ your third condition is inconsistent with your first condition.
Answer: The Berry-Esseen theorem says that the uniform CDF error for approximating a sum of $n$ iid variables with 3 moments is bounded by $\frac{C \rho}{\sigma^2 \sqrt{n}}$, where $\rho=E[|X_i-m|^3]$ and $C$ is a universal constant. We do not exactly know the best possible value of $C$ but we do know that $0.4<C<0.5$. For the binomial distribution this gives a bound of
$$\frac{1}{2} \frac{p^3(1-p)+p(1-p)^3}{p^{3/2} (1-p)^{3/2} n^{1/2}}.$$
This bound is not tight, as can be checked by some direct calculation, but it is not bad (it is more pessimistic than the true error by a factor of maybe 4 or so). Cancelling as is possible, you get a bound of
$$\frac{1}{2} \frac{p^2+q^2}{(npq)^{1/2}}$$
where $q=1-p$. The numerator there is between $1$ and $1/2$, so we can intuitively understand this bound
$$\frac{C}{(npq)^{1/2}}$$
where what I have said so far tells us only that $C$ can be chosen to be smaller than $1/2$, though in actuality for the binomial distribution it can be chosen to be a fair bit smaller than that.
So if, say, you want a uniform error of at most $0.01$ then it will be enough (by the above analysis) to have $n>\frac{10000}{16 pq}$. In actuality the cutoff is probably more like $n>\frac{100}{pq}$.


How to set QMMP to play - not enqueue - with double click?

Question: On Lubuntu 14.04.4 -
When double-clicking on an MP3 file, I'd like it to rightaway load and play in QMMP, but instead it QMMP opens and then I have to click "play". If I right click an MP3 file and select "open with QMMP" it does play upon opening.
QMMP is set as my default audio player in Lubuntu's default preferences. But the default program settings switches from just QMMP to "enqueue in QMMP".
How would I go about setting it to open and play on double-click? Thanks for any input!
Answer: Set you music default app to "qmmp" not "enqueue to qmmp"


From spins to fields

Question: In statistical field theory, one usually considers the so-called Landau Hamiltonian:
$$\beta H = \int d^{d}x\bigg{[}\frac{t}{2}m^{2}(x) + \alpha m^{4}(x)+\frac{\beta}{2}(\nabla m)^{2}+\cdots+ \vec{h}\cdot \vec{m}(x)\bigg{]}$$
This Hamiltonian seems to be general enough to study Landau's theory on phase transitions. The process of constructing the above Hamiltonian is to coarse-grain the spin system and consider the order parameter (in my case, the magnetization) as a field. I'd like to better understand the motivations of such procedure: why to turn spin systems into fields? Does it improve our results? Does our models become more realistic this way? What kind of objects are we aiming to study with this field theory? And so on.
Answer: If we were to consider spins individually, then what we would have is an Ising model; the problem with this is that to get analytic solutions of Ising at 2D or above is really difficult. The benefit of a Landau formulation is that we can just work directly from the symmetries of the system to get a Hamiltonian, which we can then use; for example, this theory assumes a symmetry in spin all up or all down, which is why we exclude the odd powers. This formulation also has the benefit that corrections can quite easily be added by considering higher powers or excluding certain powers.  So the overall reason we convert to mean field formulations is really a simplification to make the problem solvable.
The general idea of field theory is that we create a framework to study things, rather than a model for a specific system; for example, Landau theory was originally created for continuous first order transitions. This means any systems that exhibit such a transition can be studied with this theory; the obvious application may be to magnetic materials, but as someone who works in soft matter I have used it in nematic liquid crystal systems and bacterial swarms as well.
This does not mean the model is more accurate than, say, Ising, in any sense; in fact, due to the assumption that we can expand the free energy as a power series, we make the implicit assumption that the free energy is analytic, which may not be the case at the transition point. So it is important to note that field theory may not always work, but generally they can give a good idea as to, say, when a phase transition may occur.

From spins to fields


Why all the photos from 67p are black and white?

Question: I was wondering why every picture we saw on internet about Rosetta's landing on 67p just black and white ? Is there something i should know ?
Comment: Not worth writing as an answer, but keep in mind that the data transfer rates are *incredibly* low. So having multiple colour filters might be a luxury they can't afford.
Comment: Relevant: http://photo.stackexchange.com/a/56720
Comment: They said there's some reddish there, for as much colours you could see in that dark. Btw, is the subject clearer to you now or do you need further explanations?
Answer: True fact is that most of the images seen so far are taken from the navigation camera (NAVCAM) of the orbiter, Rosetta, and that takes black&white pictures.
Here is a very interesting article about how these pictures are taken (ironically it is on a NASA blog). They state that they show pretty much what you would see with a human eye from there, even thought the comet is actually all very dark. The white parts are due to the contrast with the very dark surroundings.
I'm not sure about the images received by the lander. They are captured by the CIVA cameras, where CIVA stands for Comet Infrared and Visible Analyser. So I guess they might show some infrared light not visible to the human eye, then processed to be in b&w. Unfortunately, I could not find a precise explanation on ESA's website so far. (here their page for Philae instrumentation).
Anyway, as a general rule you should not expect that all images from spacecraft are in true colors.
Answer: Regular digital cameras color filter arrays that put the pixel sensors so that it only detects a particular color. Therefore, there is a trade-off, because without the filter array, you would have a significantly higher-resolution black-and-white image.
However, most scientific digital cameras work differently. Rather, the usual technique is to put filters over the entire image, and switch out the filters if a different color is required. Subsequent differently-filtered images can then be combined into one image. But there's still a trade-off: putting in filters decreases the dynamic range of the camera significantly. Additionally, this approach does not require one to use the usual red, green, blue scheme; e.g., and IR filter would allow one to emphasize different features.
It is very likely that they simply didn't bother to put color filters in the cameras. Why would they? The colors are probably rather drab on the comet anyway, and it unnecessarily increases the complexity of the cameras (which is already a quite complicated panoramic array).
Comment: I think that the three wavelengths of human eye (red, green, blue) are not so important for scientific examination of the pictures. I can imagine that much more important could be filters designed for certain wavelengths to detect certain properties from the picture.


Why hasn't anyone won Fanatic yet?

Question: I recently got W00T (Enthusiast) and am now looking to Fanatic.  I saw on another post that SO has been open for 11 months but no one has won Fanatic yet.  Is it broken or just a coincidence?
Comment: A better question is why wasn't it made retroactive?
Comment: Yup, I agree - why should days before the badges introduction be worth any less than days after?  If anything, being an early adopter of SO would make you more of a fanatic.
Answer: The Fanatic badge was just unveiled and started tracking around 6/26/09. It'll be September before anybody gets it.
Comment: That would explain it, I must have joined and started visiting days after they were unveiled.
Answer: Today's the day.
Front page is stacked with them.
alt text http://img30.imageshack.us/img30/4804/fanaticbadge.png
Comment: hooray for the i-have-no-life badge. my 1st gold
Comment: Wohoo, got mine today! First gold on SO, second gold overall. Now that I think about it---why do I even care? Cursing you, Jeff Atwood, you and your stupid addictive ideas...
Comment: Awwwwwwwwwwwwwwww hell yeah, just got mine.
Comment: Me too. I have the flair enabled on my blog, and I saw a gold on it. I was confused until I came to SO. Now I'm proud. :)
Answer: Enthusiast and Fanatic was recently added badges. And the time period started after they have been added.
Answer: Assuming that the count for the Fanatic badge started at the same time as the Woot! badge, I would expect the first round to be awarded on or around September 4th.
Comment: September 4th UTC! Who called it? (I did)
Answer: Ding Fanatic!  (It's an mmo thing)

Why hasn't anyone won Fanatic yet?


Sending a RAM kit (electronic device) that was bought in the US to the EU, any special customs/papers?

Question: I'm an US citizen, currently in the EU. My friend has bought a RAM kit for me (PC - electronics computers) and is planning on shipping it to me through UPS. I was wondering if, besides the basic customs that UPS generates, I would need something else specifically for this piece of hardware.
Answer: You will have to pay VAT, which amount is 20% of the product value. The transporter might add a 'custom processing' fee.
There does not seem to be special custom tariff for RAM (see https://trade.ec.europa.eu/access-to-markets/en/results?product=85423239&origin=US&destination=FR for example)


Size of the Fermi surface of hole and electrons

Question: The image below shows the shape of a Fermi surface of Cr metal measured by Angle resolved photoemission spectroscopy. (not important) The question is why does the Fermi surface shrink for the electrons and expand for the holes?
This leads me to think that the holes have negative energy and electrons have positive energy... so the smaller the energy, the smaller the Fermi surface for electron, and the larger the energy for holes (being less negative?)
I am really not sure what happens here!
Answer: If I correctly understand the caption of the picture the surfaces in (b) are not proper Fermi surfaces, because they are taken

0.3 eV below the Fermi energy

We can imagine the Fermi surface as the surface of the 3D shape that we would build in the $k$-space (or reciprocal space) if we filled with conduction electrons the available states, by proceeding in order of increasing energy and continuing until we finish all the electrons. The electrons on the Fermi surface would all be at the Fermi energy $E_F$, that is the energy of the highest occupied state (at $0K$ to be precise).
In the case of figure (b) though we did not "place" all the available electrons but we left out the ones with energy higher than $E_F-0.3eV$: the shape we built is then smaller.
As for the holes instead we must consider that lowering the energy for the electrons correspond to increasing the potential (given that $\Delta E=-e\Delta V$ for the electrons) which means higher energies for the holes. So if we build in the same way as above a surface for the holes it would be bigger, as we would have more holes to place.
Answer: This question may have more to do with definitions (although I am not an expert, only a graduate student, so I may be wrong).  Let me try to explain what I am thinking:
The Fermi Surface is a construction that signifies an equipotential surface whose energy is the Fermi Energy.  Beneath the Fermi energy the states are defined to be occupied whereas above the fermi energy the states are defined to be unoccupied.
A hole is a quasiparticle symbolizing the "absence" of an electron.  It is not a real particle, but rather a convenient alternative method of describing the motion of electrons.  The filled and unfilled states of an energy diagram where the charge carriers are designated to be electrons would therefore correspond to the unfilled and filled states of an energy diagram where the charge carriers are designated to be holes.
The difference in size of the fermi surface corresponding to electrons vs. holes might therefore have to do with "reversing" the definition of what states are occupied vs. unoccupied.
Comment: Both holes and ''electrons'' are quasiparticles in a solid. Holes don't deserve to be treated inferiorly.


Canvas app oauth with Partner Users post Winter 2016

Question: I have a Force.com Canvas component inside an ApexHTML page, and it works just fine for regular user licenses, and prior to the Winter 2016 release, it worked fine for Partner level licenses (Community Partner and Gold Partner), but as of last week, it's no longer loading at all for Community Partner and Gold Partner licenses. Does anyone know anything about why and if there's any way to fix it, enable something for those licenses, or otherwise help with this?
Comment: Have you seen this post http://salesforce.stackexchange.com/questions/92812/winter-16-canvas-iframe-behavior-change ... it might be relevant ... is it IE or all browsers?
Comment: Saw it in Chrome, haven't checked if it's browser-specific. I'm not doing anything that should be affected by the double iframe, and if the double iframe were breaking things, it should break all user types, I would think. But I'll look further at the double iframe.
Answer: See Known Issue Force.com Canvas App Issue after Winter '16 Upgrade

Summary
  In Winter' 16, sandboxes, there is a Canvas session issue in all the browsers when accessing via community.

I though I saw some comments from Jay Hurst (Director, Product Management for Enterprise API and Enterprise Messaging at Salesforce) that is was actively being worked on. I can't find the reference right now.


How to tell if certain pre-2015 app is 64 bit?

Question: As there are quite some rumors, about iOS 11 dropping support for 32 bit apps, I need to know, how to tell if an app is 64-bit. I know, that if it was published after february 2015, or if it was updated after june 2015, it has to have 64-bit support. But the app in question - IPELA Communication Mobile by Sony Corporation - was last updated on June 10th 2015. How can i be absolutely sure, that - just in case the rumors come true - I can still use it?
Comment: I'll assume you're ruling out contacting the vendor of specific apps for support and want to know a way you can measure or determine this?
Comment: I did not rule it out, but I can't find any support on SONY website, that is responsible for their mobile apps.
Answer: The easy way for me is to install the app on iOS 10.3 (or later) device.
Then open the settings app.

tap general
tap About
tap Applications

iOS will report on the possibility to update all 32 bit apps you have installed on the device by letting you tap to each entry in the App Store where the developer web site is another tap away.
Comment: Tapping "applications" doesn't do anything on my device. It's an iPhone SE with iOS 10.3
Comment: iPhone SE clearly has 64 architecture in the processor - I wonder if it rolled out in 10.3.1 instead of 10.3 @kjubus. Any chance you can update to the current build of 10.3 ? Also, a clean reboot of the device can help if the settings app gets mixed up and doesn't compile the list as shown above.
Comment: Nope, doesn't work either on 10.3 or 10.3.1.

If you can do it, could you install the IPELA app yourself and let me know? it's free on app store.


On a scale, why does the heavier object go down?

Question: When you balance a pencil on your finger, I have always wondered, "Why does the heavier part go down, and the lighter, up?"
Comment: I'm not even sure where to start with this question... Just for reference, have you taken an intro physics class?
Answer: I'm assuming you haven't taken any physics courses, so let's start by explaining the concept of a force. Forces are the central focus of classical mechanics. Basically, a force is a push or pull on an object as a result of its interaction with another object. When applied to an object with mass, a force causes the object's velocity to change in some way. Gravity is just the force of two masses attracting each other--in this case, the earth and your balanced pencil. The heavier side of the pencil has more mass, so the force of gravity on that side is stronger, causing it to "go down". There's actually a better explanation of this using rotational mechanics, but this should help!
Answer: Your finger+pencil form a lever. Your finger is a Hinge. The pencil is a Beam (structure).
The mass is distributed in the beam (pencil). The gravity pull the beam (pencil) at each side of the lever down. As consequence of the coherence of (beam) pencil and the presence of the hinge (your finger), the more heaviest side "wins" and the other side "lose".
Answer: In a tug of war, why does the stronger side, pulling with more force, win?
Both sides are pulling against each other, but in the end one always finds itself being dragged along.
It's the same principle here - each side of the pencil is being pulled towards the earth. Both sides would like to fall, but your finger prevents them - it plays the role of the rope in the tug of war.
There can be only one winner, and the heavier side, which is more strongly attracted to the earth (is pulled with more force), will win.
The force is greater, it's as simple as that.
(Though of course, it's never really as simple as that. Why does your pencil rotate? And how does the downward force on the heavier side lead to an upwards force on the lighter side? The mechanics of rigid bodies like your pencil can get very complex very quickly.)


Automator: Open the current PDF file in Preview with another app

Question: After I open a PDF file with Preview, I want to open the same file in another PDF viewer (Skim or Adobe Acrobat).  How can Automator do this?
Answer: Here is an Automator Service/Quick Action that will open in Skim the front opened PDF document in Preview from the Preview > Services menu, or a keyboard shortcut if assigned in System Preferences > Keyboard > Shortcuts > Services.
This Automator Service was tested and works for me under macOS High Sierra assigning it a keyboard shortcut of ⌥⌘S, but should work as a Quick Action in macOS Mojave and later.
Example AppleScript code:
on run {input, parameters}
    tell application "Preview" to ¬
        set pdfDoc to (path of front document)
    tell application "Skim" to open pdfDoc
end run

Here is an Automator Service/Quick Action that will open the same PDF document(s) in both Preview and Skim from Finder.
In Finder, select one or more PDF documents, or a folder full of PDF documents and then right-click and select, e.g., Open PDF in Preview and Skim from the Services context menu.
This Automator Service was tested and works for me under macOS High Sierra, but should work as a Quick Action in macOS Mojave and later.
Example AppleScript code:
on run {input, parameters}
    tell application "Preview" to open input
    tell application "Skim" to open input
end run

Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.
Comment: @Chang, As not all _applications_ use (or expose) the `path` _property_ to show the _path_ of the opened _document_ and some are not directly scriptable, so it would take considerable coding to make it work for any _application_. For example, while you could open the **PDF** _document_ in **Adobe Reader** you could not get the `path` _property_ of that _document_ from **Adobe Reader** to then open it in a different _application_. Not every widget can be a universal widget and sometimes you just have to build a widget to do a specific task.
Comment: Thanks. Is there any way to open Skim from Preview, not from Finder?
Comment: @Chang, I've updated my answer to accommodate your comment and is in line with your original question. I've left the other **Automator** _Service/Quick Action_ as you may find it useful too.
Comment: I really appreciate it. It works great. One more question. If I want to enable this service in any application, instead of just Preview.app, how can I modify the AppleScript part?


Pictures are not deleted from "Photos" iphone app when deleted from "Google Photos"

Question: When I delete a picture from "Google Photos" on my iphone it is not deleted from the "Photos" app. How to fix this?
Thank you
Answer: When deleting on my iPhone, it asks if I will "Allow "GooglePhotos" to delete this photo? This photo will be deleted from iCloud Photo Library on all your devices." I can choose not to allow it and it will only be deleted on my Google Photos app.
I evidently have iCloud Photo Library turned on, and backup and sync on the Google Photos app turned on as well.
Also, check on Settings > Privacy > Photos to see if Google Photos is allowed to access your pictures.


How would I express that I'm an American with Indian heritage?

Question: I'm an American citizen, born and raised here, who speaks English as my only native language. Both my parents are Indian and I look Indian. What is a natural way of conveying all this? Saying just that I'm an アメリカ人 seems like it might cause confusion, but saying that I'm an インド人 doesn't seem right either.
Comment: Is there any word in English that conveys all this?
Comment: @jarmanso7 I don't think they expected it to be one word. They wanted to know the natural way to say it.
Comment: @Leebo fair point, yet "American with Indian heritage" does not sound like an idiomatic expression, it's pretty literal.
Comment: @jarmanso7 That's true, it's not particularly elegant. In English I wouldn't usually bother to specify that I'm Indian-American, since it's usually pretty evident from my look and name. I suppose I'm mainly concerned that saying just that I'm an American would be somewhat confusing, and I'm not confident in my ability to explain the details of my circumstances naturally.
Comment: @Mycroft I might have come across as a pedant. I apologize. I don't know either America nor Japan particularly well, but given that the first country is more diverse in cultures and races than the second, it makes sense to be concerned with specifying your heritage to avoid confusion while in Japan or talking to Japanese people.  Probably "Indian-American" is the answer to my question, anyway.
Comment: @jarmanso7 No worries man.
Answer: You would be インド[系]{けい}アメリカ人. It says nothing about your linguistic abilities, of course.


How to load kernel from GRUB

Question: Elementary OS is hosted on sda5. Win 10 was on sda1(?). I deleted BOTH partitions to resize sda5. I restarted my laptop and was greeted with the GRUB2 interface. I have no clue how to get back into elementary OS.
Answer: Wait, you deleted both your Win/eOS partitions? If so, you shouldn't have anything to boot to.... Or do you have any other OS in another partition?
If you still have anything in there, you should be able to run a shell from GRUB2 and list running the 'ls' command (shell> ls)  and see what's still there. Then you should be able to edit on of your boot settings to assign the right partition to your boot command.
You might want to grab some references from here

How to load kernel from GRUB


Coolant leaking into engine

Question: I had my truck in for service - 2006 Sierra Denali - due to an oil leak. They replaced the "engine oil cooler lines to pan gasket". Within a couple of days had a major issue - coolant had gotten into my engine. This seems too coincidental - could the problem have been caused by the part replacement being installed incorrectly?
Answer: This should be what your engine oil cooler lines look like in the vehicle:

If the oil leak was coming from the block (middle of the vehicle), part #1 should be what they changed to stop the leak. This would be the most likely place for a leak to occur in this system. The lines going forward should carry oil to the radiator, where heat is exchanged. In order for their to get coolant into the engine from anywhere in the cooler loop, it would have to come from the radiator. If this is the case, the shop which worked on your vehicle should not have even been touching the forward area at the radiator to fix the leak. Realistically, if they just replaced the "gasket" as you said, there should be no real reason for their work to have caused the issue.

Coolant leaking into engine


Global Search Bar component not available in Build Your Own community template

Question: I have configured a Lightning Community using the Build Your Own template. I wish to add a global search box like the ones in the headers of most of the built in templates, to allow my users to search for CMS content.  This documentation implies that I should be able to use the Global Search Box component, however, it's not available for me to drag into the builder. Does it need to be activated or enabled?
Answer: So as it appears that you would need a custom one to place in here. Else it will use the default search component. You can try, if you're not seeing anything search related on your page, to update the settings to show all components but it also notes that some may not function well depending on page types.
Comment: So it looks like this should work - my problem is (and I probably should have explained this use case) that this search box is only supposed to display ManagedContent objects (CMS articles) and currently they can't be queried (see here: https://salesforce.stackexchange.com/questions/261274/which-sobjects-represent-native-cms-content-in-communities-and-can-they-be-acces), which I would need to do when implementing the custom search.  However, it looks like the native search supports them: https://help.salesforce.com/articleView?id=community_managed_content_search_content.htm&type=5
Comment: Then i would have to move to say that if these are not supported in a custom one to replace it, then the answer is that you cannot, at this time, do it with these objects.
Answer: If your template has a placeholder for search, then you can add the search via navigating to

Setup >All Community > Builder > Settings (4th Icon on left)

There, expand the theme by clicking setting icons next to the Theme Layout Component and choose the global search component or your custom search component.
Comment: This template neither has a placeholder for search (it's just an empty Build Your Own template), nor a custom search component.  I want to use the default global search box component (see the link in my question) and be able to put it anywhere in my community.


Use of expression "out of"

Question: Which expression is correct: "he ran out the house" or "he ran out of the house"?
Comment: One goes/jumps/hangs/looks _out the door/window/exit_ but _out of the house/building/hut/barn._ The _of_ is not necessary for object locatives denoting normal exits.
Comment: *Out of* seems more natural to my native ear.
Comment: @John: Or *ways in* ("normal" or not). I could (just about) live with *"He came in the window and switched off the alarm so she could come in the door"*. I don't really require ***through*** there any more than I require ***of*** in OP's case.
Comment: _In_ is completely different; there's _into_ as well to account for.
Comment: In American English, *go out the house* would mean that he started somewhere, went out *though* the house, and ended up outside. You wouldn't use it except in some very strange circumstances (and it's such a weird expression it'd be a good idea to say "*out **through** the house*" instead).
Comment: Some people say "get out the way!" Saying it doesn't make it grammatically correct.
Answer: The normal thing is "out of", especially in BrE,  as in
1 He looked out of the window.
AmE tends to shorten "out of" sometimes to "out" as in
2 He looked out the window.
Answer: The statement suggests,
"out of : from within to the outside of",
grammatically, the second statement fits better.
Answer: "He ran out of the house" is correct.
"He ran out the house" is similar to "he ran out the clock" and might imply something to do with time as it is an unusual construction.
Answer: "He ran out of the house" is correct.
run out simply means to use all of something and not have any more left.
I've got money you can borrow if you run out.
But, you still say 'run out of money/ideas/thoughts etc'
Answer: "He ran out of the house" is correct.
In the sentence "He ran out the house", 'out' is an adverb modifying the verb 'ran'. The subject 'he' carried out an action 'ran' ON the object 'house'. In effect, you are saying "he ran the house" and you are just modifying how he ran it.
By using 'out of' it becomes a preposition and links the action of the verb 'ran' in space and time, to the object 'house'.

Use of expression "out of"


How do shared folders work with Lastpass

Question: I was wondering how the concept of shared folders work with Lastpass. As I understand from their site, Lastpass has a master password, which acts as the encryption key (say MK) for all data stored in Lastpass. However this key is only available on the client side. In addition the users can generate their own key pair (PKI). What is the relationship between the MK and the PKI? When a folder is shared by a user, I am wondering how the recipient would be able to decrypt the data that is being shared as the MK is not available for the recipient. Any thoughts?
Answer: From https://lastpass.com/support.php?cmd=showfaq&id=2456:

Every LastPass user generates a public/private key pair once (client side). The public key is sent to the server, the private key is encrypted (with their standard local encryption key) and sent to the server.  Roles and shared folders are implemented a little different, but they both follow the same general model -- When you want to share data with someone else, you pull their public key and use that to encrypt the data. The other person is the only one that can decrypt it (using their private key).  All this ensures that users can securely access the information stored in Shared Folders.
Comment: So if I understand the above statement, a copy of the folder is made for the recipient user and is then encrypted with the recipient users key. So if the original folder changes then these copies would have to be synchronized again.


Update order status with administrator comment

Question: I need a way to be able to allow an admin user post an order comment when they update the order status that the owner of the order would then get posted on their order. This would both be viewable from the owner of the order, when the owner of the order was logged in under their order history view of that particular order, but would at the same time, get an email with these update comments. Ubercart 2 did this quite well. I imagine Drupal Commerce is capable, but how?
Answer: In Commerce this is not provided as a part of core.
It is provided by the Commerce Message module.
In addition to that, the Commerce Backoffice module provides an improved view that allows you to view a summary of an order (and send a message) directly from the order view.
Both are included in Commerce Kickstart, in case you want a quick demo.
Comment: Thank you much, Bojan!

In fact, I am using Commerce Kickstart right now, but I do not see simple settings to make this happen. As I overlooking something?

Tom
Comment: What is also strange is that an an "admin" user, I can create an order for myself, go to "Order History" > "View order", and the "Order History" info is displayed at the bottom. This is NOT the case for an authenticated user. Where is the permission set for this?

Tom
Comment: I suppose if it was listed in bright red and blinking text, I would have found it quicker. The answer to my own question is this:

!. go to permissions
2. go to the "filter" section
3. under "Use the Commerce Order Message text format", choose "authenticated user"
4. save

Done.

Tom
Comment: A few more details I forgot to add. You also have to go into views and edit the "Commerce Message: Order messages" (this is of coarse if you have wisely pre-installed Kickstart Commerce as I have), under "Entity content settings", change "access" from "Administer orders" to "View own Order orders". Apply and save.


Conjoint Analysis in R and SPSS result in Different Standard Errors using Same Data

Question: I have been going through the tutorial by the author of the conjoint library in R (Tomasz Bartłomowicz) which can be found here. Specifically I have been going through example 1 (Ice Cream) and trying to replicate it in SPSS. I succeed in getting the same results in terms of coefficients and intercept values in both. However the standard errors reported in R differ from those reported in SPSS. Why should this be, considering the analysis is done on the same data set?

Answer: The R implementation seems to be giving results for the separate subjects stacked on top of one another and run in a single regression using all 54 observations (nine from each of the six subjects).
In SPSS, the overall results are equivalent to averaging the data (after transforming rankings to scores) across subjects and running a single regression, with nine cases. This accounts for the larger standard errors.
The equality of the regression coefficients is due to the orthogonality built into the design. You can stack the data and run one regression on all 54 observations, you can run the model for each subject individually and average the coefficients, or you can average the scores and run a single regression, and all will give the same coefficient values.
Note that this is not true of the importance values, which have to be calculated separately for each subject and averaged over subjects to get reasonable values.
Comment: But they both _are_ measuring a score, not a ranking or sequence. The tutorial (R Conjoint) has the data converted from ranking to rating. I then use the same converted preferences in SPSS, as scores. Or did I misunderstand your comment?
Comment: All such analyses that I'm aware of analyze scores, but these data were in the original form of ranks, which means that the means and variances of the data for each subject were the same. That would be true of sequence data as well, which are just another way of expressing rankings. If the original input data were arbitrary scores that were not to be transformed for analysis, then the means and variances might not be the same. That was what I was saying in the previous comment.
Comment: Thank you very much for providing this clarity.
Comment: Is the R implementation, then, the more "correct" of the two?
Comment: Yes, the SPSS results are conservative here. If the outcome were measured as a score rather than a ranking or sequence, then there might be subject-to-subject variability that the R approach would not capture, so I wouldn't call it unconditionally correct, but the SPSS approach would likely remain more conservative.


How to know why a pgRouting function returns "FAIL"?

Question: I am getting a "FAIL" message back when executing pgr_createTopology on a particular table, but the reason is not obvious. Is there any way to know precisely why the function is failing? Perhaps some sort of pgRouting log?
Answer: There should be a message for each failure, but eventually one (or more) have been forgotten?
You could try do debug the problem by modifying the pgr_createTopology function, for example by adding more intermediate output to the pgsql function.
There is no pgRouting log, except the messages generated with raise notice.
Comment: These messages are coming up as notices, now I know what is wrong.


Central banking in Saudi Arabia

Question: People say that central bank with autonomy is needed to avoid political business cycle but then how do we explain the existence of central bank in arab oil exporting countries like saudi arabia where government has no election to run periodically?
Why can't the government do the work of central bank in such countries ?
Answer: Government (meaning here executive branch of government since in most countries central bank is already government institution just independent like courts) could do that, in fact in many dictatorships/monarchies central banks are not properly independent so governments are de facto doing it if not de jure. In many such places central bank as an institution exists only nominally the same way as many dictatorships hold elections or have parliaments.
This being said historical experience shows governments are very bad at managing money supply because there ultimately complicated monetary decisions are being made made by people who don't understand them at all. Historically, politically independent central banks perform much better at keeping prices stable and also actually better job at stimulating economy exactly when it's needed. Hence to the extend that dictators care about having good monetary policy they would opt to have independent central bank. Although let me again reemphasize that in most dictatorships/monarchies central banks are not really independent and they are de facto controlled by dictator/monarch.

Central banking in Saudi Arabia


Turning dirt into white phosphorus?

Question: If you had the power to transmute any element you touch into one of the two immediately adjacent to it on the periodic table by adding or removing one proton and you tried using it on the silicon in dirt/bedrock to create white phosphorus, what would happen? Would the transmuted earth immediately react with the air and ignite like I want, or would the effects be weirder/less useful?
Answer: Nope ... as sorry I am to disappoint you, thing is, it would not immediately turn ablaze because silicon is not found in free state in the soil, but rather as dioxide (SiO$_2$).
Phosphorous ignites in air to form pentoxide (P$_2$O$_5$). So while silicon converted into phosphorous would not be completely saturated with oxygen already, it is hard to say if it would ignite instantaneously or would it rather be a slow (spanning several minutes at least, if not hours) oxidation reaction.
If you are keen to turn things on fire with touch, you would have more luck with sulfur instead. Since it is easily available and is cheap, you can just keep some of it handy in your pocket and convert it into pure phosphorous and turn it ablaze any time.
Also, although unrelated to your question, I might remind you that there is a little fallacy in your world. The wizards of your world would be able to turn any element into any other element as they see fit, not just one element before or after in the periodic table. The reason being, that they can continue to deduct or add protons (and neutrons) with their touch until they obtain the element of their choice. If they can do this once (convert an element to previous or next element), they can keep doing this over and over again with the converted element(s).
Comment: Assuming the new element was not a gas and then goes away before the next transformation is performed. Darn those noble gasses, messing up everything!
Comment: As an alternate solution, Z. Schoeder might be able to avoid the fallacy you mention by having the atoms "remember" what they were originally and only support transmutation within the window of +/- 1 proton.  That doesn't challenge your point about atomic structures (though it does bring up the question of what chemistry happens when you suddenly make something very unstable by changing its atoms)
Comment: @CortAmmon: Does atomic _memory_ exist? Even in fiction ... If that be the case, then the converted atoms would not be "normal" atoms and would depict some really wonderful and bizarre characteristics with regard to their memory skills :p I'd love to know scientists have found such atoms :D
Answer: Keep in mind that the variation in number of protons is not the only change between Si and P.
The most common form of Si is 28Si which has 14 protons, 14 neutrons, and 14 electrons (in non-ionic form).
The most common form of P is 31P which has 15 protons, 16 neutrons, and 15 electrons (in non-ionic form).
So in addition to adding a proton you'd also need to come up with 2 neutrons and an electron (which might be capture-able from the environment).  There's no known isotope of P with only 14 neutrons.  Such an element would almost certainly have a very short radioactive half life and decay into 29Si (through beta emission of a positron, thus converting a proton into a neutron).  There is 30Si which has 16 neutrons, it would be much more amenable to conversion to P but it also only makes up 3% of Si in general.

Turning dirt into white phosphorus?