Asking about writing techniques

Question: Could you please help me..I have ideas of writings and stories, but..when I come to start writing, I can't find what I need to write the plot and that's leads me to think about giving up
Comment: Does [this](https://writing.stackexchange.com/questions/1781/how-do-i-construct-a-plot-out-of-my-many-setting-character-details) help?
Comment: https://writing.stackexchange.com/questions/50892/how-can-i-begin-writing-a-short-story
Answer: A useful classification for ideas is their level of detail. Depending on which class best describes your ideas, some methods to formulate a story might come more naturally to you than others.
On one end of the spectrum exist 'big picture' ideas that encompass your entire story but only in broad strokes. If you can prepend "the story is about" to the idea, it probably is part of this class. A few concrete examples:

A man who searches for his wife in an abandoned holiday town after receiving a letter, three years after her death
A young girl who sues her parents for forcing her to donate a kidney to her dying sister
A coke-snorting hacker who travels into outer space to stop two AIs from merging and becoming sentient

'Big picture' ideas can be turned into full stories by adding layers of detail. Take your one-sentence summary and expand it into a hundred words. Paint broad strokes; now's not the time to describe the protagonist's difficult childhood. Also, don't be afraid to rewrite those hundred words until you have something you like.
The next stage is to divide your story into three acts, and from there, to start work on an outline. This technique is called the snowflake method, and I encourage you to read the linked article because it goes into much deeper detail.
On the other end of the spectrum exist fragmented ideas. Perhaps for characters, items, locations, half the set-up for a scene that looks cool in your head. Each a puzzle piece, though not all necessarily from the same set. Examples:

Protagonist befriends a talking cat (character)
Temple on the moon built by ancient Egyptians (location)
Character goes through experimental chemotherapy and becomes violently ill (scene)

If you have a large number of these ideas, your job is to find out how they piece together, if at all. Write each idea on a Post-It. Rearrange your Post-Its in groups that make the most sense to you. See if a possible narrative begins to form. For instance, using bullet points #1 and #2:

On a school trip to the British Museum, Lydia meets a talking black cat who claims to be a reincarnation of the Egyptian goddess Bastet. Bastet convinces her to board a NASA rocket, and they travel to the moon to reclaim her lost temple.

The emerging narrative need not and will not be perfect. You'll have many questions. Why does Bastet want her temple back? Why is Lydia the only person who can help? How does an eleven-year-old travel from Britain to the US, alone, sneak onto a rocket ship unseen, and survive the massive g-forces involved in lift-off? Write all questions down in a notebook and answer them. When answering one question creates another, answer it as well until none remain. What remains is a document with all the facts you need to write an outline.
Comment: Thanks so much.. but I don't know why while I'm writing, I think that this gonna be useless and thoughts about giving up start overwhelming me. Is this a lack of confidence or maybe because it's the first time I write ?
Comment: @NourFourti That voice is called your 'inner editor' and it is both your best friend and worst enemy. The editor insists you write well as a self-defense mechanism against criticism both real and imagined. Problem is, the editor is a little too overprotective and will prevent you from writing so much as a single word if you don't put it on a leash. While writing the first draft, ignore whatever the voice says. Your first draft will be trash, but every author faces this problem. The editing comes later.
Comment: @NourFourti If you use the search bar, you'll probably find a question or two about how to effectively shut down the editor. I like this post by Chris Sunami: https://writing.stackexchange.com/a/30983/41082
Answer: You already know how to write stories.
You've been listening to them your whole life, and maybe telling a few.
Simply sit and start writing your stories.
Then rewrite your stories to make them better.
Then keep writing and rewriting your stories.
Comment: Trust your intuition: https://www.cnbc.com/2018/05/23/how-to-trust-your-intuition-like-apple-co-founder-steve-jobs.html

Asking about writing techniques


What is stereo separation?

Question: I am struggling to understand the difference in audio mixing between stereo separation, delay, and mid/side EQ when it comes to widening a sound.  Can someone explain these in laymen terms, specifically stereo separation?
Answer: WE humans have two ears, and are accustomed from very early in life into hearing really small details that one ear hears different from the other. Stereo separation is used in editing with different objectives, being mostly creating a sorrounding feeling to what is being listened. There are different techniques, the first one being one sound going through the left speaker and not the right speaker, or difference in the volume level between these two. But there are some other techniques as well that you can look into, like retarding a sound several miliseconds and giving the brain the feeling that the sound comes (spatially speaking) from one side or the other -of course, the side that is reproduced early is the source of the sound where it should be coming. This is using very little time separation (between 0.1 miliseconds (specially in headphones) to around 20 or even more miliseconds). So the delay is closely related, but it is usually used more time separation, therefore creating an even more "wider" sound. Sometimes this is overused sort to speak because in reality you only get some time separation, but you also may take into account the reflections that the walls, ceiling, or floor of the enviorment is directioning the original sound to your ears a bit later than the first wave of sound you heard directly from the source.
All these times separation have different ranges to create different effects. The smallest separation are usually creating a left to right sensation, while repeating sounds with a time separation of more than 40 miliseconds generate a reflection of the enviroment feeling.
Mid/side eq refers to adjusting only the sounds that are being reproduced from both speakers, or only one of the speakers (may be the right or left, but only one of them) So when you select mid, you are only affecting sounds that come from both speakers, and when you select side, you are only affecting sounds which are only being reproduced from one of the speakers.
I also recommend you to using headphones and listening to binaural sounds and looking into that a bit, which takes the surrounding feelings to the limit, making incredible inmersive sounds, very natural to hear. Here is a fantastic example:

Also here's a link with something I myself made with a binaural plugin: Again, headphones are NEEDED:
Answer: I think the other answers deal pretty well with the topic of stereo, but if I am reading your question correctly, they miss the mark a little: "stereo separation in the context of mixing" is simply taking the recording(s) of the different instruments and panning them a little left and a little right in the stereo field (as described int he other answers) so that you wind up "carving out" a spatial location for that instrument. This gives the instrument a little clarity over having all the frequencies fighting for the middle.
Another technique that is used to help with clarity is to use EQ to "duck" or lower the other instruments' audio in the main frequency range of the current instrument so that each instrument has more ownership of that particular frequency (i.e. bass owns the low end, the guitar owns a chunk of the mid-range etc.) this lessens the overlaps in frequency range between instruments and provides for a little more clarity.
Obviously, both of these are mostly useful if you have isolated recordings of each instrument.
Answer: stereo separation, or stereo split, is basically the act, of grabbing the two individual audio channels of a stereo file, which basically contains two mono files, and rendering them as a individual files
Comment: Though you describe something that is done and related to separating out the channels within a stereo audio file, this answer does not stereo separation as used/intended by the OP.

What is stereo separation?


Dry baked goods

Question: I've recently purchased new ovens and was excited to bake in them as the heating circulation was supposed to be superior and temperature more accurate.  Most of the baked goods in the new ovens are not as moist as previous goods, particularly items made with yeast dough but cookies seem to be drier as well.  Any ideas as to why this may be happening?
Answer: Have you made any adjustments for the new ovens?
One thing is checking if the temperatures are the same as what's indicated (which is most helpful if you also checked that the temperatures on the OLD ovens were the same as indicated, or know how far and in what direction they were not.)
In addition, if you have moved from a "conventional" to a "convection" oven (which sounds like what you are describing) it is often necessary to compensate  for the better heat circulation by shortening the cooking times appropriately. Goods cook faster in a convection oven.
Comment: Yup, it does kind of sound like the old oven was undershooting temperatures, and the new one is more accurate and thus hotter.
Comment: Shortening cooking times yes, but another option is lowering the temperature
Answer: Different oven designs are differently sealed, and keep a different level of humidity inside them; this is most obviously evident when opening the oven with your face near the oven door - some (very dry, well ventilated) will hardly do anything to you, others will burn your nose hair clean off (hot steam).

Dry baked goods


How could I use machine learning to detect text and non-text regions in scanned documents?

Question: I have a collection of scanned documents (which come from newspapers, books, and magazines) with complex alignments for the text, i.e. the text could be at any angle w.r.t. the page. I can do a lot of processing for different features extraction. However, I want to know some robust methods that do not need many features.
Can machine learning be helpful for this purpose? How could I use machine learning to detect text and non-text regions in these scanned documents?
Answer: TextDetector, Tesseract and other open source packages implement text detection (object detection for text). There's also a pretrained Tensorflow model that does text detection. A text detector will give you the bounding boxes in your image for any text that it recognizes. In the case of Tesseract, it will also output the text (OCR is built in). So you can read the code in these packages to get ideas for your own machine learning pipeline. Basically you need both a regressor (for the bounding boxes) and a classifier (to detect whether the box contains text or not).
Answer: Since the document is scanned, it will not be in an open document format so no associated API can be used.
Approach 1
Evaluate TextBridge Pro, FreeOCR, and other alternatives that purport page layout detection.  If any of them work, drive them programmatically (preferably headless) to read the scanned document, detect page layout and OCR the text, export to a document with an open format, and then use the API
With this approach, the object recognition AI is in the product and development time and resources are saved.
Approach 2
Do a 2D FFT windowing through the page in both directions.  See the cosine, trapazoidaly, Hamming, and Hanning windows and apply them in horizontal and vertical directions.  Use Approach 1, assuming those products work with the scanned documents to label the examples, and then train a DCNN (deep convolutional NN) to recognize from the 2D FFT output spectra where the pictures are.  By interpolation, close to a perfect crop of the images and the text regions can be obtained with some hyper-parameters on the model obtained.
Approach 3
This approach is just Approach 2 but preparing the labeled example data set by hand, which may be necessary because the existing software products may not handle the images being laid out at angles other than 0, 90, 180, or 270 degrees.
Approach 4
Create an architecture that is based on feature extraction, and use font rendering libraries to build the back half of an auto-encoder, allowing portions of image that do not auto-encode to be preserved as an x-y coordinate pair, which will allow the images to jump over the pictures if the convergence is set up correctly.
Final Note
One can offload some processing to a learning process, so that the actual document process runs faster, but sometimes the preparation of the example data set and the learning consumes more resources.  That's why those who assess which approach will cost less and can recommend the best approach with some reliability are high paid.


What is negative Resistance

Question: I have heard some people talk a bit about negative resistance, but I have never really understood it. What is negative resistance?
Comment: http://en.wikipedia.org/wiki/Negative_resistance http://en.wikipedia.org/wiki/Negative_impedance_converter
Answer: Negative Resistances is a behavior in which the current and voltage are inversely proportional to each other.  A normal circuit with a resistor following ohm's law has a current drop, when the voltage decreases.
In case of a negative resistance, the current increases with a voltage drop.
Practically, there is nothing as a negative resistor. Its just behavior on the V-I graph, where there is a negative slope, and operating in that region would give you a behavior of negative resistance.
In this graph below, you can see the region where the element shows a negative resistance behavior.

I think tunnel diodes and some other kinds of diodes exhibit this behavior.
Comment: Also sometimes the actively amplifying circuits may be modeled as the negative resistance black box.
Comment: For anyone who hasn't encountered tunnel diodes, I found [this book](https://archive.org/details/GeTunnelDiodeManual) extremely useful in understanding them.
Answer: To understand negative resistance, start with what a resistance actually is.  For any normal (positive) resistance, it is a measure of how much voltage builds up accross the resistor as a function of a known current.  This is exactly what Ohm's law describes:
  R = V / I
Or put into common units:
  Ω = V / A
In other words, a Ohm is one Volt per Amp.  If you pass 1 Amp thru a resistor and that causes there to be 3 Volts accross the resistor, then you have a 3 Ω resistor.
A negative resistance is no different, just that the sign of the resistance is negative.  If you put 1 Amp thru a -3 Ω resistor, you get -3 V.  The reason this may sound unintuitive is because these thing don't exist sitting around in nature.  I remember Professor Gisser in college explaining negative resistance.  He finished by saying "I have a jar of them in my office.  You can come by later and see some if you want.", then looked around to see who laughed.  Surprisingly, there were a few who sat there with blank stares wondering what was so funny.
To understand why these things don't exist naturally, consider the power tranfer.  Power into a load is the voltage accross it times the current thru it.  Note that with a negative resistance, the voltage and current have opposite signs.  That means when you apply a voltage to a negative resistance, the power into it is negative, which is another way of saying it is producing power, not dissipating it.  If you put -100 Ω accross a 2.2 V battery, then the 22 mA that will flow will charge the battery, not discharge it.  A negative resistance sources power.
Clever circuitry can emulate negative resistors, limited to a specific voltage and current range.  That circuitry is always powered, though, and what is connected to it will recieve some of that power.
There are passive devices that are said to exhibit negative resitance, but what is really going on is that the slope of the Volts as a function of Amps curve is negative in some region.  The actual magnitude still remains positive, which is another way of saying that the Volts as a function of Amps curve remains in the first and third quadrants (where the device absorbs power instead of sourcing it).  Certain types of diodes and the base of a unijunction transistor exhibit negative slope over some part of their V/A response.  These are sometimes called negative resistance devices, even though that refers only to their slope over a limited range.
Comment: A passive device may also operate momentarily in the secondary and fourth quadrants (outputting power) if, during the time that operates in the first and third quadrants it stores some of the power that it absorbs.  Such behavior is more common with inductors and capacitance than with things whose power/voltage transfer characteristic behaves like a negative resistance, but electrical power need not be conserved in the short term--only the long term.
Comment: "...what is really going on is that he *slope* of the Volts as a function of Amps curve is negative in some region."  But that's exactly what resistance is: the *slope* of V over I.  Right?
Comment: @Max: No.  See Ohm's law. There are no derivatives in there.

What is negative Resistance


mmap clarification: what happens after process restarts

Question: My understanding of mmap is very limited, let me know which of the following are correct. For the following scenario in a piece of program:
1. Process starts, call mmap()    // this is not actually loading anything from disk,
                                  // just allocates memory?

2. access data in the file        // this actually triggers the load from disk so
                                  // it takes longer?

3. at this point, the process is killed and restarted

4. Process starts, call mmap()    // this is not loading but the memory pointer
                                  // allocated is likely to be different?

5. access data in the file        // it takes roughly the same amount of time
                                  // as the first time

Is my understanding correct? I am especially confused about the part after the process is killed and restarted. Thanks!
Comment: 4 is correct, the system will likely map to a different address.
Comment: @SoronelHaetir thanks! What about 2? When I access the data do I only load what I need or load everything?
Answer: mmap "creates a new mapping in the virtual address space of the calling process". Unless you use MAP_POPULATE nothing is read from the file backing the mapping. (man page)
Accessing the file-backed mapping needs to bring in the data obviously. Whether physical I/O happens at this point depends on whether the OS has the page you're trying to access in its cache.
So I'd say your statements 1, 2, and 4 are true, while 5 might be not.
Comment: https://stackoverflow.com/questions/45972/mmap-vs-reading-blocks has discussion with much more detail


What's the secret to the purple room with four blocks and tetromino pictures on each side?

Question: It's a purple room with four blocks and a tetromino picture on each side (four): two upside-down Ts and two Ls. You can get to this area by going through the door atop the bell and entering the purple door on the opposite side. The stage is 3x3 with four blocks.
Answer: You need to push the blocks into the pink spots to form the tetromino shown on each side.
The easiest method is stacking two blocks and pushing that stack into position from all perspectives. Then fill in the last two blocks. It'll turn into an anticube.
Comment: Any idea if this puzzle is glitchy on the PC version ?  It seems like the blocks won't align: the 3 first blocks always take 3 different lines, avoiding to be aligned...
Comment: @Anto: Not that I've heard. You want it to look my third picture and it'll animate to align like the pictured tetromino.
Answer: Arrange the blocks into the tetris block shape so that it matches in both directions.
One is an L and the other an upside down T, so you can represent both shapes with just 4 blocks from different directions.


Exim4 Configuration of Maildir Delivery

Question: Documentation online is rather sparse on how to go about configuring Exim4 to use the Maildir delivery method instead of the default mbox format. This is on a FreeBSD system with Exim4 compiled from ports. Can anyone point to some documentation or tips for this?
Answer: in your local_delivery section remove "file = xxx" and add the following:

  directory = $home/Maildir
  maildir_format
  maildir_use_size_file
Answer: On FreeBSD, take a look at /usr/local/share/doc/exim/spec.txt for a copy of The Exim Specification which is pretty exhaustive.  This is the same doc that is available online in HTML, PDF and various other formats, but Exim makes the .txt output a first class citizen, not just a web-page dump, so it's highly usable.
You should search that for references to maildir, which would also lead you to read "26.5 Maildir delivery"; from there, you might learn about Maildir++ and some of the enhancements to Maildir which are commonly supported to improve performance by encoding information into the filename, auto-create sub-directories, and more.

Exim4 Configuration of Maildir Delivery


List all peerID in rtmfp group

Question: How can I get list of all peerID`s who now connected into rtmfp group?
Or variant get a group ID, but such as stored on the server.
I tried use sam groupspec.toString(); but this command return result not like in server. Server Cumulus.
Answer: I assuming you're talking about ActionScript here? The RTMFP protocol in Flash is essentially a rendezvous service - meaning it helps you connect to other clients and that's it. It's not connected to a server as such so it's not aware of who's connected at any given time (and it has no need to know). The messages get passed around by the clients between themselves as opposed to the server.
Making a 'user list' is possible, as described here; http://cookbooks.adobe.com/post_User_List_with_RTMFP_Groups-17535.html
Hope this helps!

List all peerID in rtmfp group


Is it acceptable to contact a potential customer who has accessed your site, using their IP?

Question: We run ad campaigns to attract potential customers to our website. Sometimes customers click, but don't make contact. Is it acceptable to reach out to these customers, based on the public info available from their IP?
Answer: Creepy. And kind of presumptuous.
There's nothing technically or legally(?) wrong about this, but the reaction is probably going to be uncomfortable at best, to even hostile.
If you really want to do this, I'd suggest acting as if it were a cold call. You get the benefit of using the information gained from your logs, without coming right out and saying you basically stalked them. I'll leave it as an exercise for you to justify the cold call itself, but presumably these are people within a given industry or something, such that there'd be a reasonable way for you to find out who they are by other means.
Comment: And no one likes a cold call... Thanks, I think we'll just avoid it.
Answer: No. First, I don't know how you are going to be able to find this customer based on their IP. Even a static IP (that doesn't change) may be used by multiple computers and even any single computer may be used by multiple users. You have no way of knowing who the potential customer is or how to contact them based on their IP.
But secondly, even if you had a way to contact them, no it would not be considered acceptable. If a potential customer clicks and goes away, there's nothing you can do. I recommend looking into ways to attract them further before they leave, such as offering chat services, collecting an email address, tracking pages with analytics to see what kinds of pages have lower bounce rates and try to determine why, or other similar possibilities.


My dog attacks my friends and other dogs

Question: My west highland white terrier is aggresive against my friends for example he bit my cousin's leg, tore his jeans and created a wound. Also when he meets another dog even larger than him he will try to attack. To stop him attacking my friends we keep him in the balcony while they are here, was this the right way to act? Also what can i do about him attacking other dogs? Oh and before i forget we have a larger male dog has been terrorizing him since he was a puppy. Could this be the problem
Comment: Not sure if you already read this but it may help.  https://www.cesarsway.com/dog-behavior/aggression/understanding-aggression
Comment: Can you clarify which dog was terrorised as a puppy? Also, what age are your dogs? Also describe what your dog is allowed to do and why? For example, is he allowed on the sofa? What are your terms of allowance on some of these behaviours? What training do you give your dog? I need more info to help understand the behaviour. Some excellent suggestions from the answer below though
Answer: If the dog is already that aggressive, chances are you need a professional dog-trainer.
Without knowing more it is even impossible to say what the reason for the aggression is. For example, it could be based on a hunting-instincts (most Terrier-breeds where bred for solitary hunting!), defending his territory, or even fear and/or panic! Attacking other dogs may be a result of bad socialisation. I don't know the dogs history, but he may even been encouraged to attack by a previous owner.
So, there are many possibilities. Seek out a professional dog-trainer, so you can diagnose the cause for the aggression and then work on it. Diagnosing the cause for aggression is possibly one of the hardest tasks disregard a dog because of all the different possible triggers, but you need to know the root cause before you can help him.
Until then, I would advise you do some basic obedience-training in a place where the dog is comfortable and calm. Use reward-based training here! No matter what the cause of the aggression is, any punishment- or dominance-based training may make the issue harder to deal with. Also, do take your dog for walks - long, tiring walks - but if possible, put a muzzle on him, and avoid other dogs. You can reintroduce to dogs once you know how to work on his aggression.
And above all: have love and patience! For many aggressive dogs, that is what is needed most.
Addendum for the second dog (lot's of speculation, take this with a grain of salt.. or more!):
With the older dogs behaviour, I would suspect fear-based aggression and/or bad socialisation. The older dog should have set limits, yes, but not terrorize. If you cannot reach out for a trainer, I would in this case really start by building a LOT of trust with the younger dog: sit with him (but giving him space), pet him gently if he shows no aggression and/or fear, let him come to YOU for a treat and retreat as he wants. Train "calm and nice" behaviour with the older dog, too, with many rewards and treats.
Try to keep the young one separate from the other dog for now as much as you can. If BOTH are calm, you should be able to let them together, give them both treats. If one of them starts being aggressive, separate them again. Above all: learn to read your dogs language! Barking and growling can mean MANY things, from "play with me" to "back off NOW!".
And again, please avoid any punishment-related training, with both of them. It is really hard to say which of your dogs caused the issue here, but I suspect their behaviours may have fed of each other.
Timing in dog-training is tricky, and once accidental rewarding the wrong behaviour is usually more easily fixed than accidentally punishing a desired one, especially in insecure dogs!
Comment: Thank you for the information. But i just want to add that we hve another male dog who has been terrorizing him since he was a puppy. does this help?
Comment: Not necessarily aggressive. Some dogs may be nervous and may take it out in biting to warn the person/animal that he/she is getting too close. I'm not sure how the bite happened, so I'm just guessing


Not sure how to successfully drill these pieces

Question: I'm trying to drill two pieces of wood similar to the angled pieces marked in blue. However, I'm not sure how to clamp these and can't drill them straight without the wood slipping. What's the best way to join them?
Comment: You may have better success asking this at woodworking.stackexchange.com
Answer: As the diagram mentions "pocket screws" you typically drill those type of holes using a pocket hole jig.   Here is one of the more popular ones, available from various outlets:  Kreg Pocket Hole jig https://www.homedepot.com/p/Kreg-Jig-Pocket-Hole-System-R3/202269070
You can clamp the jig to the material and it holds the drill bits at the proper angles to easily drill the holes where you want them.


OS X Yosemite multiple desktops with different files

Question: Is there a way to have a second desktop which you can put individual folders and files on it, so that the first desktop is clear without any files?
Comment: Maybe... I don't think you can change the "shortcuts" on your Desktop, but you can certainly have different files, folders and apps open on different desktops. I don't recall specifics about Yosemite, but there's a reasonable [overview of `Mission Control` here.](https://www.howtogeek.com/180677/mission-control-101-how-to-use-multiple-desktops-on-a-mac/)
Answer: Yes you can. Mac refers to the extra desktops as spaces. You can create up to 8 extra spaces I think and you can control them from Mission Control. The control key plus a digit will make that particular space active.
if you go to Mission Control (probably in your doc) a window opens showing all the spaces across the top. There is also a plus sign. Clicking the plus sign creates a new space. I find spaces very convenient. I have a space set up for one app and another space for a different app.


Archiving Workflow History

Question: Alright.  I am very very new to using Sharepoint in any capacity.  I have set up an Engineering Change process in our company Sharepoint so that people can create a change request.  I can then send that out for approvals and keep track of it through the process.  The workflow history shows me what I need as far as who approved, when they approved, etc.  I need a way to try and archive this or export it to some sort of document since Sharepoint deletes the workflow history after so long.  I need to keep it logged for auditing or until this process is moved over to Windchill sometime further in the future.  I have seen recommendations as far as coding this and such but honestly that is pretty foreign to me.  Any help would be greatly appreciated from you pros.  Thanks in advance.
Answer: The history list is not what you should use for this. The entries linking to the workflow will be removed (by a timer job) and you wont be able to access the data anymore. (the data is still there, but you will loose the ID's needed to access them)
If you need to persist some information from the workflow you should consider writing it to an alternate location in the workflow itself.

Archiving Workflow History


Can genetically modified genes jump to bacteria in the eater's intestine?

Question: The Guardian ran an article a while back talking about GM gene's jumping to bacteria in an eater's intestine. Has other research confirmed this phenomenon?
Comment: I just want to point out that the Guardian article you refer was published in 2000. 12 years later, these putative results have not been published yet.
Comment: Isn't the phrase "genetically modified genes" kind of tautology?
Comment: It is intestine, not stomach. Also, I love how the article says that because it can happen in certain conditions for bacteria that live in bees guts "The research - which has yet to be published and has not been reviewed by fellow scientists - is highly significant because it suggests that *all types of bacteria* could become contaminated by genes used in genetically modified technology, including those that live inside the human digestive system.". Talk about hurried conclusions.
Comment: @MartaCz-C: I guess it was intended to be GMO's genes
Answer: No.
There is nothing special about a piece of GM DNA when compared to any other random piece of DNA. If this phenomenon happened at any detectable level, we'd have found eukaryotic DNA in bacterial genomes/plasmids long before the introduction of genetically modified crops. And that would be front page news in the field of horizontal gene transfer! Which has many talented people in it!
Comment: A basic molecular biology textbook plus one in microbiology would be sufficient to provide the details of the mechanisms described by Amy +1.
Comment: @Casebash You're asking me to prove a negative. I think the onus would be on you to provide evidence otherwise. For what it's worth, the wiki entry on horizontal gene transfer gives a pretty good overview of the mechanisms we know about: http://en.wikipedia.org/wiki/Horizontal_gene_transfer
Comment: Do you have any references to back that up?
Comment: Also, this textbook chapter: http://pathmicro.med.sc.edu/mayer/genetic%20ex.htm
Answer: Of far greater concern is the transfer of genetic material between bacteria in which antibiotic resistance is conferred. The firmicutes in your poop is not at all the same genetically speaking as the firmicutes in my poop. Polymorphisms and genetic transfer have changed members of the gut microbiome and that leads to differential extraction of energy from the ingested food and differential behavior with respect to antibiotics.
Answer: Apparently transfer between prokaryote and eukaryote (in both directions) has been detected:
http://www.biomedcentral.com/1471-2148/11/276/abstract
http://www.sciencedirect.com/science/article/pii/S0888754311001959
http://genome.cshlp.org/content/19/8/1441.abstract
Some numbers I'd like to know are the rate of pro<->eu HGT detection /versus the rate of looking for it/ (i.e. 3 confirmations in 300 attempts would be more impressive than 3 confirmations in 30,000 attempts).
Comment: Hi and welcome to biology SE. Please use the buttons above the editor window to insert links and it is better to include the title, authors and journal of your cited articles. That said, I have downvoted your answer because i) you link to 3 articles showing HTC between virii and eukaryotes (even if one of them seems to think that the Hz-1 virus is a prokaryote!) and ii) the existence of HTC between eu- and prokaryotes does not answer whether it would be possible for such a transfer to occur in the very hostile environment of a mammalian gut. In short, you're not answering the question :).


How to give your characters enough dialogue?

Question: In my story, there are quite a lot of characters. It can be difficult for me to give them dialogue. For example, let's say that there are a five friends at a party. I would run into a habit of having only two of the characters speak. Is there a way I can distribute dialogue when there is a lot of characters?
Answer: Dialogue, just like everything else in a well-written story, has a purpose: either to advance the overall plot or to develop the characters. Who speaks and says what in what scene depends on what needs to be said and who the focus is on. Even if you want to develop all 5 characters, it doesn't necessarily have to happen all at once for everyone in every scene, even when all of them are present. Perhaps Tim and Sally are the focus of the current plot point/character development, so even if Harry, Shawn, and Linda are also at the same house party, they say comparatively little that is actually told the reader, because they are off chatting with one another about plot-unimportant things while Tim and Sally sit in the corner together and discuss their recently deceased friend Roger.
That said, when you have five characters in a room together, you don't want any of them to "disappear" either. It occurs to me you may really be asking about how to avoid this phenomenon: the vanishing of characters (and it can happen to your setting as well!) when the writing doesn't keep the reader present enough in the space the scene occurs in. Usually this is because the dialogue/focus is so caught up in whatever the main thought the writer is trying to get across that it forgets to include descriptions, sensory details, etc. about what is around the characters at that time.
I remember when I wrote a story in college, two characters were having a serious conversation in the backseat of a car, and my professor asked me, "Where did the car go?" Essentially, I was so focused on the characters' reactions and dialogue that it was all you could see from what I had written. They might as well have been sitting at a cafe, or in a movie theater, or anywhere else, because there was very little to remind the reader of where they actually were for the whole passage.
This happens with other characters in a setting too, if you aren't careful. Tim and Sally are talking, and pretty soon you realize, "Hey, where did Linda, Shawn, and Harry get to? They were in the room as well, but we've heard nor seen nothing from them for three paragraphs now!"
The solution to this problem isn't necessarily to just give the others more dialogue, but rather to ensure the entire setting, them included, isn't left behind. Sure, maybe one of the others says something from time to time. They might break into the conversation to make themselves know, like here, where Linda just arrived:

"Sally, I think that..." Tim paused as Linda appeared next to Sally's
chair.
"I haven't had a chance to ask how you're doing," she said.
Sally offered her a half smile. "I'm okay. Thanks for asking."
"I'm glad you're hanging in there, girl. Nice to see you as well, Tim." He nodded.
"Hey, Linda! Come help me with this pizza!" Shawn called from the kitchen, and Linda gave Sally one more reassuring smile before she
turned away.

More often, though, I think you'll find action and sensory input from by the other characters sufficient and less disruptive for any given scene:

Tim paused and glanced to the side as a clatter echoed across the
room. Shawn had dropped the punch bowl and was now swearing as he
looked down at his wet pants and shoes. Clumsy as always. Tim and
Sally shared a smile.

Linda's laughter carried across the room, at odds with the grim
expression on Tim's face, and Sally sighed. "I don't know, Tim. I
thought I could get answers, but all I've found is more questions."

Tim raised his voice to be heard over Shawn and Harry's roughhousing
behind them. "I don't know what to think anymore, Sally. Nothing seems
to add up like it should."
"I know." She leaned forward slightly so he
could hear her and spoke low, "I'm starting to think his death
wasn't an accident at all."
Someone bumped into her chair and she
startled, glancing back to see Shawn's sheepish grin. "Sorry," he
said, then bounded back across the room toward Harry, whooping.

Hmm, I think I have the making of a very cheesy murder mystery / possible romance novel here XD XD
One final point: At various point in your novel, assuming all five characters are meant to be important, each of the characters should have scenes where they have more dialogue and "moments" that help develop them. If you notice that there is one character who is always just kind of "there", standing around while everyone else talks and does things and comes up with the plans, then this character is currently just window dressing, and you need to take a good look at them. You need to ask if they have a real role to play in the story, and if so, why aren't they filling it? Perhaps another character is already filling the role you meant them to fill. Perhaps you don't actually need this character at all and should cut them entirely.
I once had a character whom I just couldn't get to come into their own, and I eventually realized that it was because their role in the story overlapped too much with the roles of two of my other characters, who each had a more interesting base personality and background, and had each therefore become the character who "dominated" their position in the story. I fixed this by removing the neglected character from the primary plot and placing them in a separate situation on their own, which allowed them show off their strengths and flaws out from under the others' shadows, while their absence simultaneously created a conflict for the other characters.
Side note: love interests, in particular (especially female ones), often suffer from the "cardboard cutout person" phenomenon, where they have no active role other than to exist as eye-candy for the main character to drool over. They stand around and look hot while the other characters do everything. If you want to have a love interest, you need to find a plot-relevant active role for them to play and develop the character to have their own personality, motives, and flaws. It will instantly improve the character and your story, I promise.
Answer: You Can Lead a Horse To Water:
But that doesn't make him Mr. Ed. Characters take on a life of their own, and there's no external rule to make them talk more. It sounds like you're conflicted about if characters should be talking more or not. On one hand, you admit you DON'T have them talking, and it doesn't always make sense for them to, but on the other hand, you want a rule to give fair speech to all.

Don't be afraid to have major and minor characters. If some talk more, they are bigger characters. Simple.
If you want it to be equitable, then write the story so each character has parts where they are major characters. Have a chapter centered around each, and make sure the events focus on them so they get developed. Or establish their relationships by how much time they talk.
Don't be afraid to use internal dialogue as a substitute. A character can be an informal narrator, listening to others talk while reflecting on the conversation. This also gives you the chance to introduce some limited omniscience to the story. Dick and Jane fight about Spot, but Joe knows Spot didn't pee on the carpet, and stays silent because it was his dog Rover who did.
Are all of your characters present all the time? If the dialog seems out of balance, people go off on side-quests for the story while the rest talk and reflect.
Actions are as important as words, so you can have characters shine by what they do, not what they say. Some of the best characters almost never talk, but provide an example.

Ultimately, if you want characters to have more say, you have them talk about what's important to them. If that's not important to the story, they don't need to be the center of attention. Stress less and let dialog evolve naturally. I find I don't need to try with dialog. The characters get to have a voice, and start saying what they want to. The story may move in an unexpected direction, but that's creativity. If you need to have things go a certain way, that's your executive privilege.
Answer: They need to have something to say.  You can't force it.
Readers don't want to read a lot of small talk.
If it does not help move the story forward or fill in holes about a character, then just describe what they are doing and don't make them talk like in your example when they are at a party.
Answer: Do not give them dialogue for the sake of giving them dialogue.
If it would be logical for other characters to speak more, then give them dialogue.  Otherwise, you may want to just throw in an observation that the other three were talking about something while these two talked, or the other three were listening intently, or whatever.
Answer: I run into the exact same problem all the time. In my fantasy series, there are six main characters, not counting the antagonists. If I did count the (main) antagonists, there would be eight main characters. A lot. Sometimes when all my main characters are together, their conversations sound either too choppy or too planned, like they're not even the ones talking. One way I fixed this is giving each of my main characters extremely distinct voices.
Example: one character has an accent.
Another character uses a lot of slang.
Another character is very formal.
Another character is always sarcastic and jokes around.
One character talks like me.
And my last character also talks like me because he happens to be the MC's brother.
So if you have different voices for each of your characters, you will not have to use dialogue tags unless necessary, and your dialogue will seem less choppy.
Another way I fixed this is (if you haven't already) getting to know my characters as actual people, not just figments of your imagination. Put your characters with the other characters and see what happens. Put them in difficult situations and see how they react. Get to know where they live, and how the people that live there talk. Do your research. A book without the proper research sucks.
I recently read a book that took place in London. The main characters were from London, their parents were from London, and they talked like they were from America. They're names sounded like they were from India. It was extremely frustrating, so I just stopped reading the book.
Research is key. Weather your research your characters, dialogue, setting, names, accents, cause and effect, whatever.
(P.S. this site is great for research on how to write. I use it all the time.)
Comment: "names sounded like they were from India." That doesn't mean they're not from London - London's a pretty multicultural place :) Of course, that doesn't change the fact that they probably shouldn't have sounded American!


Expected value and variance of log(a)

Question: I have a random variable $X(a) = \log(a)$ where a is normal distributed $\mathcal N(\mu,\sigma^2)$. What can I say about $E(X)$ and $Var(X)$? An approximation would be helpful too.
Comment: I think the question was about the "inverse" of the log-normal, i.e. where a normal rv A leads to log-normal X = exp(A), the questioner was asking about the distribution of X = log(A), which is undefined (due to sometimes requiring the log of a negative number). There may be some results for a truncated normal, but they're likely to be messy.
Comment: rocksportrocker, as @Martin O'Leary points out, it is not mathematically possible to have such a variable $X$, because $\log(a)$ is undefined for negative values. At a minimum you need to truncate $a$ at some non-negative value. Could you tell us why you believe $a$ might be Normal?
Answer: If we consider "approximation" in a fairly general sense we can get somewhere.
We have to assume not that we have an actual normal distribution but something that's approximately normal except the density cannot be nonzero in a neighborhood of 0.
So let's say that $a$ is "approximately normal" (and concentrated near the mean*) in a sense that we can handwave away the concerns about $a$ coming near 0 (and its subsequent impact on the moments of $\log(a)$, because $a$ doesn't 'get down near 0'), but with the same low order moments as the specified normal distribution, then we could use Taylor series to approximate the moments of the transformed random variable.
For some transformation $g(X)$, this involves expanding $g(\mu_X + X-\mu_X)$ as a Taylor series (think $g(x+h)$ where $\mu_X$ is taking the role of '$x$' and $X-\mu_X$ takes the role of '$h$') and then taking expectations and then either computing the variance or the expectation of the square of the expansion (from which can be obtained the variance).
The resulting approximate expectation and variance are:
$\text{E}\left[g(X)\right]\approx g(\mu_X) +\frac{g''(\mu_X)}{2}\sigma_X^2$ and
$\text{Var}\left[g(X)\right]\approx \left(g'(\mu_X)\right)^2\sigma^2_X$
and so (if I didn't make any errors), when $g() = \log()$:
$$\text{E}\left[\log(a)\right]\approx log(\mu_a) -\frac{\sigma_a^2}{2\mu_a^2}$$
$$\text{Var}\left[\log(a)\right]\approx \sigma^2_a/\mu_a^2$$
* For this to be a good approximation you generally want the standard deviation of $a$ to be quite small compared to the mean (low coefficient of variation).
Comment: Because the Taylor series for log has a relatively small radius of convergence, caution is advised in applying these approximations.
Comment: The approximation for the mean works pretty well for $\mu/\sigma \gt 1.5$ and that for the variance works pretty well for $\mu/\sigma \gt 2.5$ or so.
Comment: @whuber for an expansion around the mean, I think this would correspond to the advice that the "standard deviation of $a$ should be quite small compared to the mean" that my answer ends with -- if I am missing some further issue that that advice doesn't cover I should fix my answer.
Comment: In any case it is certainly worth being clear that we're indirectly relying on the convergence of $\ln(1+x)$ (since $\ln(\mu + y-\mu) = \ln[\mu\{1 + (y - \mu)/\mu\}] = \ln(\mu) + \ln[1 + (y - \mu)/\mu]$). Thanks also for the suggested explicit values; if anything perhaps I am slightly overcautious when I use it. Two valuable comments.

Expected value and variance of log(a)


Is it proper to cite a web page using embedded metadata for an APA paper?

Question: I saved the home page for the Academic Libraries of Indiana to Zotero, and it pulled back an author from the metadata embedded in the page.  After pulling up the source of the page, I found a meta field defined as "DC.Creator" (which, according to the comment above the metadata block is a Dublin Core element).  Given that the page itself doesn't display this person's name, is it appropriate to cite the page as authored by that person, or should the institution be named as author?  I suspect if I cited the page as written by the organization it wouldn't be considered wrong, but at the same time, knowing that metadata is there makes me feel odd not attributing the authorship to the defined (but somewhat hidden) author.
Answer: Some large websites, assign responsibles for each page, so in the case of a question or need for update that person would handle it. This does not mean authorship in its academic sense. So if the page does not contain a scientific claim and you refer to that just as a web-page then it should be attributed to the university (or department?), I guess.
Answer: I'd go with using the name from the embedded metadata. It's a little unusual but they've clearly made it available in some fashion, and intended it to be used - they wouldn't have marked it up as DC metadata if it was meant to be unknown!


After joining data from csv file to shapefile, why are all values zero in categorized renderer?

Question: I have joined data from a csv file to my shapefile. The attribute table shows a successful join. I have converted the variable of interest to INTEGER. But when I go through Style to categorize the variable, all I get is zero. Help please!
Answer: It's not your fault. It's a bug in QGIS 1.8. You can choose between categorizing manually or exporting the joined layer to e.g. Shapefile, and use this new file in your project.


What does it mean speed of lens in analogue photography?

Question: When reading some reviews on lenses in cons or pros are noted speed of lens. What does it means when we are talking about analogue cameras without autofocus?
Answer: The speed of the lens (independently if its about analogue or digital photography) is the aperture. When you have wide aperture (small number) we talk about fast lens because on the same scene you can use faster shutter speed. For example f2, f1.4 are apertures of fast lens. For other side if you have not so open apertures like f5.6, f8 you have slow lens because on the same scene you must use slow shutter speed.
We talk about maximum aperture of the lens.
And speed of the lens do not refer to how quickly it can autofocus
Comment: good answer, but just to state it explicitly... "speed" of a lens does *not* refer to how quickly it can autofocus.
Answer: The lens acts like a funnel in that it gathers light. The larger the working diameter of the lens, the more light it will gather. In other words, if you are imaging under feeble light conditions, you likely will benefit if the lens you are using has a large working diameter. Conversely, if you are imaging under bright light conditions, you would likely choose to work with a lens with a lesser working diameter.
In the jargon of photography a lens that passes a massive amount of light is termed a "fast" lens. Such a "fast" lens permits the use of a very quick opening and closing shutter.   A quick opening and closing shutter is also termed a "fast" shutter.
We must add a qualification: Just because a lens has a large working diameter doesn't always translate to being a "fast" lens. This is because the amount of light a lens passes to film or digital imaging chip, during the exposure, is also dependent on how much the lens magnifies. In other words a powerful telephoto lens magnifies greatly but this action pays a price as considerable light will be lost. Contrariwise, a wide-angle lens images with low magnification and this action results in a bright image being passes to film or sensor.
In other worlds the power of a lens to magnify is based on its focal length. Long focal length lenses are classified as telephoto and short focal length lenses are called wide-angle.
Because the speed (image brightness) of a lens intertwines the working diameter (aperture) and focal length, we must do some math to make sense of the speed of a lens. We divide the focal length by the working diameter to find what we call the "f-number).  Suppose the focal length is 100mm (about 2 inches) and the working diameter (aperture) is also 100mm. We divide 100 ÷ 100 = 1 stated as f/1. This is a very fast lens in that it passes tons of light. If we stop down (reduce) the aperture to 12.5mm the math is 100 ÷ 12 = 8 stated as f/8 (a lens with moderate speed. Stop down to 4.5mm, the lens is now operating at f/22, a slow lens that only allows a petite  amount of light to pass to film of sensor.
How about, you study the f-number system and gain some insight into how cameras expose under different levels of light brilliance.


Can I travel to Germany on a bus through France with a "Deutschland" visa not a Schengen stated visa?

Question: I have been issued a German family reunion visa type D. it clearly states that the visa is for Germany and not Schengen states as I used to get in the past. Can I travel by bus from London through France to Germany with this visa?
Comment: Note that this visa entitles you to travel through (and even visit for a short time) France, Belgium and other countries in the Schengen Area, but you'll need a separate visa for the UK.
Answer: Yes.  While I can't find anything useful on a German site, family reunion (type D) visas are issued by all Schengen states, and the French foreign ministry site says:

Long-stay visas
The long-stay visa is not a Schengen visa ; it is a
  national visa that entitles you, whatever the reason for your stay, to
  live in France for more than three months.
The visa also entitles you
  to transit through another country in the Schengen Area on your way to
  France and to move freely throughout the Schengen Area for its entire
  period of validity.
The main reasons for issuing this type of visa are
  study, work and family reunion.


Which Port And Protocol Is Being Blocked

Question: I wrote a .NET program to make an HTTP request over the Internet, and it's being blocked by my PC's firewall.  The operating system being used is Windows 7.  I figured I could create an outbound rule to allow connections on port 80 using TCP to be made.  I also made the same rule for Inbound connections.  Unfortunately, the program still throws an error.  When I allow all outbound connections to be made, my program does not throw any errors.  Is there some firewall rule which is not program specific that I can add which will allow the type of connection being made by my program?  I was thinking of a firewall rule for a specific port and protocol, but I don't know how to configure such a rule...
Comment: possible duplicate of [Windows Firewall: How to allow traffic on a specific port (eg. 8080)?](http://superuser.com/questions/144482/windows-firewall-how-to-allow-traffic-on-port-8080)
Answer: When you edit the firewall rule, make sure you go to the "advanced options" tab and select all scopes "private + public + domain". This one can be sometimes skipped.
From your post I see you only need an "outgoing" firewall rule. Review if you have any deny/blocking rules that can affect you.
Comment: Thanks for the response, these are great things to check that I didn't consider.  Turns out I was just specifying the wrong port number...
Answer: It turns out I was just using the wrong port.  I was specifying port 80, since my program is requesting information via HTTP.  However, the port number being used seems to be somewhere between 10,000 and 60,000 (haven't narrowed it down yet).  I should probably start using some tool to monitor network traffic on my PC...


Disable the delete option from Sharepoint list 2010

Question: I have a custom list in SharePoint 2010, for which, the requirement is to disable the delete option.  Users should be able to add to the list but not delete.  Is there anything oob for that?
Answer: Create a custom permission level based on Contribute that does NOT have the Delete Items option selected.  Apply this permission level to the list for the desired users.
See this article for full details, http://mssharepointtips.com/tip.asp?id=1019, the screenshots are from 2007 but the premise is exactly the same in 2010.
Comment: Note: this also prevents users with this custom permission level from being able to rename items. Also, in an environment that uses Retention Policies, I found that whenever a user with this custom permission level edits an item, that item's Expiration Date column becomes empty (my assumption is that normally, on the expiration date the automatic deletion of the item is attributed to the last editor of the item).


Is "so that" and "so" 100% synonymous in informal speech?

Question: I was told "so" is used to tell what the result was; whereas "so that" is used to tell what the purpose was. The question is that the case in informal speech? I feel a lot of people use "so" and "so that" interchangeably. In what situation, are they interchangeable in informal speech and when are they not?
Comment: Bear in mind that today, when people are interviewed on TV and the radio, they all seem to start their answers with: So, etc. You didn't mention that usage, which is very common now.
Answer: "so" and "so that" are interchangeabe when they express both purpose and result. However, it should be noted that "so" will only sound informal when it expresses purpose.

I work very hard so that I can be promoted. (purpose)
I work very hard so I can be promoted. (purpose, informal)
I worked very hard, so that I was promoted. (result, with "so that" being usually preceded by a comma).
I worked very hard so I was promoted. (result)

It should also be noted that "so" is more typically used to express result while "so that" will be normally found to express purpose, unless "so" is chosen in informal contexts.
You can find additional information here: https://dictionary.cambridge.org/grammar/british-grammar/so-that-or-in-order-that


Solving a discrete optimization problem

Question: Assume that $x_1,\dots,x_n$ are $n$ integer variables which takes values in a subset of given numbers, say $x_i\in\{5,6,\dots,5000\}$. Let $f_i(x_i)$ and $g_i(x_i)$ both be non-decreasing non-negative functions of $x_i$. Values of both functions are given for all values of $x_i$. Now consider the optimization problem
\begin{align}\max_{x_1,\dots,x_n}&\sum_jf_j(x_j) \\\text{s.t.}&\sum_jg_j(x_j)\leq B&\end{align}where $B$ is a given positive constant. The straightforward solution is to do a brute-force search. However, this will be exponentially complex. Is this problem studied in literature? What are the known approaches to this? If you are familiar with solution approaches or relevant references, please point them out.
Comment: The most suitable technique will probably depend on the nature of the functions $f_i,g_j$.  The more you can tell us about them, the more likely that we can suggest relevant techniques.  Also, are you looking for the optimal solution, or an approximation to it?  This is related to the knapsack problem, and is at least as hard as the knapsack problem; you might look at techniques for that problem to get some ideas.
Comment: non-negative non-decreasing is the only information I have. Can you some idea of what you were hoping for?
Comment: If you have no information about the $f_i,g_i$, you can't solve the problem.  How were you planning to solve the problem without knowing what $f_i,g_i$ are?  I'd recommend that your first step should be to go investigate what those functions are, where they come from, and how they will be specified in the inputs (as a truth table?  some other way?).  When dealing with a hard problem, it's important to have as much information as possible.
Comment: @D.W. I have the complete values of $f_i$ and $g_i$ at all possible values of their arguments. So if $b\in\{5,6,\dots,5000\}$, then I know all values of $f_i(b)$ and $g_i(b)$ for all $i$. These are given as data to me.
Comment: OK.  Makes sense, thanks for the clarification.  How large are the values of $f_i$, $g_i$, and $B$?  In particular, about how large is $B$, in the applications you care about?
Answer: Complexity
Your problem is NP-hard.  Therefore, you should not expect any efficient algorithm that will always find the optimal solution.
In particular, your problem is a generalization of the knapsack problem.  Suppose we insist that $f_i(5)=f_i(6)=\cdots=f_i(4999)=0$ for all $i$ (but $f_i(5000)$ can be any positive integer), and the same for the $g_i$.  Then the problem becomes exactly the knapsack problem.  In particular, the knapsack problem is a special case of your problem, which means your problem is at least as hard as the knapsack problem, as any algorithm for your problem could also be used to solve the knapsack problem.  Moreover, the knapsack problem is NP-hard, so your problem is too.
Therefore, you're going to have to make some compromises.  You could look for heuristics that produce the optimal solution and sometimes run fast, but in the worst case might take exponential time.  Or, you could look for heuristics that produce an approximate solution (not optimal, but hopefully close to it).  I'll outline several approaches.
Exact solutions
Suppose you want the exact optimum solution.  Then I know of two reasonable approaches, depending on how large $B$ is.
If $B$ is small, you can adapt the standard dynamic programming algorithm for the knapsack problem to this situation.  The running time will be roughly proportional to $B$, so if $B$ is not too large, this is reasonable, but if $B$ is a 100-bit integer, this is completely infeasible.
Alternatively, you can use integer linear programming.  Introduce zero-or-one variables $v_{i,k}$, with the intended meaning that $v_{i,k}=1$ means that you've set $x_i$ to $k$.  Add constraints to ensure that $x_i$ is set to  a single value ($v_{i,5} + \dots + v_{i,5000}=1$) and that $g_1(x_1)+\dots+g_n(x_n)\le B$ (namely, $\sum_{i,k} v_{i,k} g_i(k) \le B$), and then maximize the objective function $\sum_{i,k} v_{i,k} f_i(k)$.  Feed this to an off-the-shelf ILP solver, and it might find a solution for you, if you are lucky and the size of the problem is not too large.
Approximate solutions
If you're willing to accept an approximate solution that isn't necessarily optimal but should be close to optimal, there are several possible approaches.
One approach is to create the ILP problem above, run the ILP solver for a limited amount of time, then stop the solver and ask it to give you the best solution it has found so far.  Many ILP solvers have the ability to do that.
Another approach is to round to a limited precision.  Pick a constant $c>1$, and replace each $g_i(x)$ with $\lfloor g_i(x)/c \rfloor$ and replace $B$ with $\lfloor B/c \rfloor$.  In other words, divide all the $g$'s and $B$ by $c$, and then round to an integer.  Now solve the resulting problem.  This is an instance of your problem, but with smaller numbers and a smaller $B$, so you can now try to find an exact solution to this smaller problem -- for instance, using dynamic programming.  The optimal solution to this smaller problem will correspond to a close-to-optimal solution to the original problem.  You can tune the value of $c$: the larger $c$ is, the more efficient this will be, but the worse the quality of the solution.
There may be other methods.  You could study the literature on the knapsack problem to see what techniques have been considered there and see  how to adapt them to your situation.  But the above is probably a pretty good starting point.
Answer: Without more information about f and g, this problem is NP-hard to solve. The topic is quite broad, check the family of Branch and Bound algorithms, depending of additional information you can do better than NP-hard, in particular, it makes use of monotonicity to guide its search.
Worth to mention too are Genetic algorithms and Simulated Annealing, which, in general, gives you a good enough solution.
Answer: This problem is well studied in the literature, and is the integer version of Linear Programming, known as Integer Linear Programming.
You can use a solver for Linear Programming problems. There are free options, like GLPK, or COIN. There are some APIs that use these solvers available for Python, Java, etc... Most of them support integer variables/sets like your problem.
Comment: I fail to see why this is a version of ILP, if the functions $f_i,g_j$ aren't linear.
Comment: I appologize. When I read non-decresing I tought immediately in a linear function.
Comment: But what are these functions like?
It might be possible to convert it to linear form.
If not, you can follow this path:
Linear Programming -- (if not linear) --> Quadratic/Convex Optimization --(if not quadratic/convex) --> Non-linear optimization

Solving a discrete optimization problem


How do you meter for the effects of a TTL flash

Question: I'm experimenting with a shoe mounted flash at the moment. It's a TTL flash and yet the metering doesn't seem to account for the fact the flash will fire, making judging the correct exposure difficult. Any tips?
Comment: Which model of camera/flash are you using? What shouting move are you in?
Answer: If you have a scene where everything is equi-distant from the camera, TTL should attempt to properly expose.  So set you shutter speed below the sync speed of your camera, and the aperture to whatever DOF you require, and let TTL take care of the burst of flash.  Don't worry about the meter.
If you have  subject nearer to the camera, then most systems will account for the fact you're focusing on a nearby subject and properly expose the subject, leaving the background dark.  If you want to background to be lighter, drop the shutter speed (say from 1/200th to 1/60) because the shutter speed won't affect the flash exposure.  This is called dragging the shutter.
So you are right, the camera's metering doesn't take into account the flash - so assume it will properly expose whatever you're focused on, and use the metering to adjust the "ambient" exposure of your background.
Answer: When using a TTL flash, camera's exposure metering will still aim for a proper exposure of ambient light so the background (unaffected by flash) would be nicely lit too; since ambient light is still the same, there shouldn't be much difference from photographing without flash; flash TTL metering is used to tune the power of additional light provided by flash. Each TTL system has its quirks here, though:

Canon reduces flash power in bright ambient (to avoid clipping highlights);
Nikon's newer version of iTTL (starting from D3 and D300) underexposes ambient (to avoid clipping highlights);
Pentax caps shutter time (to prevent blur)

Judging exposure in (especially flash) digital photography should be performed by evaluating the histogram (preferrably of separate color channels) of a test shot, not by camera's anticipated exposure values. When you already know what the values should be (e.g. by using spot metering or a light meter), you'll be using manual exposure or exposure lock anyway.


Updating iOS, Storage Mystery Math

Question: I'd like to update my iPhone Operating System.  I plug the iPhone into my desktop computer, sync up to itunes, then press the Update button, right below where it says

A newer version of the iPhone software is available... To update your
  iPhone with the latest software, click Update.

I then get a popup that says

Updating to iOS 10.3.2 requires at least 770 MB of free space on your iPhone.
  Please change your media sync options to make more storage available.

Huh?  I'm looking at the data storage summary at the bottom of itunes.  It says quite clearly that I have 2.48 GB free in the little color bar describing the iPhone.  I need 770 MB, and I have 2.48 GB available, then why, for goodness sake, am I getting that mystery message?
When I learned math, I thought that 770 MB was a heck of a lot smaller than 2.48 GB.
Note: There is some other odd stuff going on with this phone's memory display.  I've deleted all the photos from the photo gallery on the phone, yet the data summary bar shows 1.49 GB, 1760 photos.  It should show near zero memory / zero images.
Note:  Its possible that Dropbox is messing things up.  I would have thought that the Dropbox memory usage would be accurately reported out on the data usage summary in iTunes. My Dropbox storage capacity is 10GB, of which I typically use 8GB.  (In fact is there a DropboxIgnore for the iPhone?  I really only need access to photo backup and my password vault from the iPhone...)  On the phone data summary color bar, there is an Other category, sized at 4.84 GB, which I assume to be Dropbox.
I've clicked Synch, Done and rebooted the entire computer numerous times trying to get stuff to update.  There are minor variations to the storage usage display, but the photo segment doesn't seem to update, nor will the OS update, and utilize that empty space.
Anybody know what's going on here?
ref: windows 10, itunes v22.214.171.124, iphone 6 with 16GB memory, sync via USB cable.
Comment: I suppose it is possible that there are some temp files on the phone that are messing things up. You could try deleting the dropbox app which will also delete all of its data. or you could try the 'ol "back up phone, wipe phone completely, restore from backup." that often clears up space issues on IOS devices.
Answer: Try restarting the iPhone, worked for me, maybe some temporary files get deleted on reboot.

Updating iOS, Storage Mystery Math


Can I defer loading Modernizr?

Question: I'm using an HTML5 template that makes thorough use of the semantic tags and includes Modernizr up top to do the necessary IE coaxing. Google PageSpeed is complaining about the blocking JavaScript and recommending a deferred load, but as I understand it Modernizr has to load first to prevent IE from choking. Is PageSpeed wrong about this particular item, or can I push the Modernizr load down to the bottom of the page?
Comment: Why don't you try to put the loading of the script at the end of the page to make happy Page Speed and see if it even though fixes IE oddities?
Answer: From Modernizr installation page:

Drop the script tags in the HEAD of your HTML. For best performance, you should have them follow after your stylesheet references. The reason we recommend placing Modernizr in the head is two-fold: the HTML5 Shiv (that enables HTML5 elements in IE) must execute before the BODY, and if you're using any of the CSS classes that Modernizr adds, you'll want to prevent a FOUC.

Modernizr is pretty fast and lean, especially if you have used their customizer to trim out the features you don't need to use
Comment: Links please? Is it still relevant in 2019?
Answer: try this:
https://developers.google.com/speed/docs/insights/BlockingJS
or insert async tribute in this javascript

Can I defer loading Modernizr?


How small could an Earth-like planet be while still realistically being able to sustain human life?

Question: I'm thinking a planet orbiting a nearby star colonized by human settlers sometime in the not near, but not too distant future.  How small could a planet be while still standing in as a relatively close substitute to Earth?  Let's suppose the atmosphere, the climate, and the gravity would be very similar to Earth's.  Is it realistically possible for a planet half the size of Earth to have these qualities, or even smaller?
Comment: [Related question in progress](http://worldbuilding.stackexchange.com/questions/9857/is-this-planet-habitable), though it doesn't yet cover this. I'll add in some information tomorrow, if I can. On a side note, are you interested in mass, too, or just size?
Comment: Thanks.  And yeah, just size.  As long as the planet's mass is believable, it's not an issue at all.
Comment: So, the planet is like the planets from [The Little Prince](http://en.wikipedia.org/wiki/The_Little_Prince)?
Comment: @akaddoura one important detail is amount of time. Mars was perfectly habitable (as least in terms of volume of atmosphere and presence of water) for hundreds of millions of years. So if you are just talking about a planet being colonized, and not producing sentient life, then you could conceivably have a MUCH smaller planet that will nonetheless sooner rather than later become uninhabitable due to loss of atmosphere and water.
Answer: Size and Gravity
Here's a handy equation if you want to find the radius of a planet with the same surface gravity as Earth (or near it), but with a different density. If you want to change the size but keep the same gravity, you need to mess with the density.
$$ r = {{g}\over{{{4\pi}\over{3}} * G * \rho}} $$
Where $ r $ is the radius in meters, g is Earth gravity (9.8 m/s), $G$ is the gravitational constant (6.67384E-11), and $\rho$ is the density of your planet in kilograms per cubic meter. I derived this equation from the surface gravity equation.
You can check this by entering earth's density in kg per cubic meter: 5510 kg/m^3.
$$ r = {{9.8}\over{{{4\pi}\over{3}} * 6.67384 * 10^{-11} * 5510 }} = 6362240 m = 6,362km $$
Check.
So, you can start looking up densities for various materials or mixtures and finding out how large your planet would be with a surface gravity the same as Earth.
For instance I'll check the radius for a planet made of platinum. The density of platinum is 21.09 grams per cubic centimeter. Convert that to kilograms per cubic meter: 21,090 kg/m^3.
Now, plug it into the equation and you'll get a radius of 1,662 km for a planet of solid platinum. That's a little smaller than our moon.
It's possible to get a planet this small with Earth gravity but, intuitively, this is not at all likely.
Atmosphere and Climate
As I'm sure someone would point out if I didn't mention it, these are a lot more things than gravity needed to get an Earth like planet.
The planet can't rotate too quickly. It also needs a magnetic field to protect from solar wind. So your planet can't be made of solid platinum. But you can mix in some different materials and include them in the density measurement by ratios of their mass in your planet.
Assuming you start with an atmosphere and the various requirements to hang on to it. You're well on your way to a habitable planet.
Comment: Your rotation link says nothing about rotation, but about gravity being able to hold onto lightweight gases.
Comment: @user3082 You stopped reading after the first paragraph. Try again.
Comment: It also depends upon how long you need it inhabitable.  Mars should have been capable of supporting some types of terrestrial life during its youth but can't now.  Is millions of year enough, a billion, two?
Comment: What would be the escape velocity of such a small dense world? The planet would need a thin silicate mantle to support life, the planet would be pretty unfavorable to life if the ground was just solid platinum
Answer: The planet will need sufficient gravity to retain oxygen and water. Technically less than Earth normal would be sufficient, but the size of the planet also has an effect. Annoyngly smaller planets are worse at retaining atmosphere, so we can start by assuming 1G will be needed. The actual physics is naturally more complex, but the sad fact is that it is too complex to model. My understanding is that due to only having one habitable planet to study much of what you read about this topic is unproven.
The ratio the planet diameter can be decrease while retaining the same gravity is the inverse of the ratio density can be increased.
Unfortunately, the Earth is already pretty dense. No natural process creating significantly denser planets is known. I think 10% increase of density would be plausible, but that gives nowhere near the level of decrease in size you want.
So you'll need to forget having the same gravity and find a loop hole ...
The obvious one is that since the colonists have only been on the planet for a short time, the atmosphere only needs to be stable for a short time. The planet would be losing volatiles rapidly, but a high level of volcanism would be replenishing them just as fast. Some of the volatiles could have been gained relatively recently from comet and asteroid impacts. Such heavy bombardment would also have heated and fractured the planets crust enough, to trigger release of other volatiles from there.
Mars used to have such an atmosphere and Mars has roughly half the Earth diameter and 30% surface area. So it should be possible for the halfling planet to be habitable for a few million years. Additionally, heavier elements do not naturally concentrate near the surface. This means that valuable minerals are brought by asteroid impacts. The halfling planet would probably be rich in valuable minerals due to the bombardment being relatively recent and no process having yet allowed them to sink deeper. (The planet would probably be too small for plate tectonics.)
Unfortunately, this atmosphere would not have free oxygen. So your colonists will either need some simple terraforming (introduce photosynthetic life and wait) or somebody or something else will have already introduced such life to the planet. This would mean either another life bearing planet in the same system or a visit from aliens a long time ago.
Alternately, you could simply have an Earth sized planet that has less habitable land area available in the form of a single, small continent. This would emulate all the effects of "smaller, but same gravity" planet, but without any speculative science. Really depends on why you want a smaller planet.
An ocean world with a single continent with habitable coastal areas and a central desert would have restricted space for the colony to grow, but not to the point people would be pushed to building floating arcologies or vast scale desert irrigation projects. Alternately, a planet without plate tectonics might not have real continents at all. All land would be from large igneous provinces. Why would this be a good thing? A quote from the linked article might tell the answer:

The study of LIPs has economic implications. Some workers associate them with trapped hydrocarbons. They are associated with economic concentrations of copper–nickel and iron. They are also associated with formation of major mineral provinces including Platinum-Group Element (PGE) Deposits, and in the Silicic LIPs, silver and gold deposits. Titanium and vanadium deposits are also found in association with LIPs.
Comment: @Falco Yes, this is actually kind of interesting idea that is skipped in SciFi. In realistic interstellar civilization with terraforming, most planets might not really be habitable in the long term. Just for a few dozens of millennia. Such planets might be interesting settings for those lost technology stories set millennia after initial terraforming. Precursors might have left the galaxy full of such planets.
Comment: A big part of the question is, how long do you need the planet to retain human life? Really small planets may hold their atmosphere for some hundred thousand years, which si usually too short for life to evolve. But if you just bring plants/animals and everything with you at just the right time, it might work!
Comment: "Alternately, you could simply have an Earth sized planet that has less habitable land area available in the form of a single, small continent." <= this is a good point.  I wanted to build a world with only one really major city on it, but a well-established one.  The problem is that if we were to colonize a world I imagine we'd start to spread out pretty quickly.  Thus some constraints on space are needed.  I like the idea of a mostly ocean world with maybe an Australia-sized landmass on it, maybe a few other island groups, and ocean otherwise.
Comment: @akaddoura Added more on that to the answer.
Answer: This question was looked at in a nice, very simple and readable paper by Williams, Kasting & Wade in 1997 (see here).  That paper focuses on moons of gas giant planets but the idea is the same, and they address the question of what exactly is needed in terms of planet mass for life.
The trick is, we don't know exactly what is on the checklist for life.  Williams et al considered 2 key things: 1) the planet must have enough gravity to hold onto an atmosphere, and 2) the planet must have enough long-lived radionuclides in its interior to provide a heat source capable of maintaining plate tectonics.
They came up with a lower limit for habitability of about Mars mass (0.1 Earth masses).  The key limiting factor is the internal heat source, and there is some uncertainty there. I re-did their calculation a few years later with slightly more conservative assumptions and ended up with about 1/3 of an Earth mass as a lower limit.
Here is a summary of the different factors: https://planetplanet.net/2014/05/20/building-the-ultimate-solar-system-part-2-choosing-the-right-planets/
Answer: One trick is getting the right atmospheric density.  Too thin, and it's tough to breath.  Too thick, and you don't have enough light at the bottom of the atmosphere to energize an ecology.
Planets lose atmosphere.  There is an energy distribution among gas molecules at any given temperature.  At the top of the atmosphere a few of them are faster than escape velocity from that point.
Average molecular speed is temperature dependent.  A hotter sun, or being closer to the sun means faster escape.
Escape velocity is dependent on both mass and distance from the centre of the planet. Heavier planet = slower escape.  Larger planet = slower escape.
This last one may be counter intuitive:  If you have a larger planet that is less dense, but that still has a 1g surface gravity, the escape velocity is considerably higher.
A strong magnetic field helps keep an atmosphere.  Many of the molecules in the upper atmosphere are ionized.  An ion can't travel in a straight line in a magnetic field, but instead will spiral around the magnetic field lines.  Since the field is embedded in the earth at either end the ion eventually hits the atmosphere again.  (Ok, it's messier than that.  There's a convergence of field lines at the poles.  This acts as a mirror for slow ions. So they bounce back and forth between north and south poles.)
So why does Venus with essentially the same mass and diameter as Earth have so much atmosphere. It's hotter. It doesn't have much of a magnetic field.  It should lose atmosphere. Good question.  My suspicion is that it's the lack of oceans. No oceans = no processes that turn CO2 into carbonate rocks.
Mars with a strong magnetic field might hold an atmosphere for a long time.


Direct path and reflections of ultrasound transmission

Question: I am using the following system:
Ultrasonic chirp signals with central frequency 100kHz are being transmitted using ultrasonic sensor. After the transmission through the medium(air/solid/liquid/combination) they are being received with hydrophone. The system is being controled by DSP and signal generation and acquisition is obtained via DAC and ADC. Our aim is to detect the time of arrival between transmission and reception.
My mentor suggested that I could use something with FFT to observe reflections, but I am struggling to find information on the internet about it. Does anyone have a suggestion how that could be done using FFT, or any other method?
Comment: This needs context. Time of arrival is a time-domain concept, but for certain *types* of signals it might be sensible to figure out that time through frequency-domain properties or just processing tricks. However, you're telling us absolutely nothing about your system, so what you're asking us is "How do I solve this very broadly stated problem using one of the most ubiquitously used algorithms?", and that's really not precisely enough stated for us to be able to understand what your mentor meant.
Comment: Also, ask your mentor about clarification what she or he said, maybe?
Comment: I have updated the post with explanation of the system. Unfortunatelly, I cannot obtain more information from my menthor right now, that is why I wanted to try and search about it on my own.
Answer: That sounds like a usual FMCW sonar.
It's technically identical to FMCW radar. So, multiply your receive with your transmit signal, you get a signal at the beat frequency, which is proportional to the range.
Standard FMCW approaches; there's a wealth of info out there.


How to sing major minor and seventh chord in a song?

Question: A song might have different types of chords like major, minor, seventh, and so on. We know different types of chords play with our emotions differently. For example, seventh chord creates tension in mind. I wanna know how to sing them in a song or more elaborately, how our singing voice adjusts different types of chords like major, minor or seventh and so on...within the same song?
Answer: As a vocalist, you will probably never sing more than one note at a time (although as jjmusicnotes pointed out some vocal styles sing multiple notes) and most likely it will be a note in the key the song is in so if you can sing all the notes of that scale you should be good. Even if you sing an arpeggio of a major, minor, or seventh they are usually just notes in the key. You could technically sing the same note over and over again and have the chord playing behind you change. One example of this in A minor is you can sing an E over an A minor chord, a C major chord, and a E7 chord. The note you sing may not change, but the chords around it might.
There may be tricky intervals that you may need to sing and that comes with practice, but it shouldn't have much to do with the chords themselves.
Comment: Great answer! Exactly, what I wanted. Yeah, we cant sing several notes simultaneously. But don't we give different emotions like happy,sad or tensed..(using our vocal that can sing a single note at a time) to different types of chords like major ,minor or seventh found in the same single song?
Comment: Again it's not about the chords themselves it is about the emotions and expressions the composer want. Traditionally minor chords sound "sad", but are used all the time in "happy songs". It is more about the expression like how loud or soft you sing, how long you hold out notes, how smooth the notes are. The chords themselves can help shape these emotions, but it comes out way more in the expression of a piece.
Comment: TY again. If possible, can you explain with examples if necessary this sentence that u said now " It is more about the expression like how loud or soft you sing, how long you hold out notes, how smooth the notes are."
Comment: http://en.wikipedia.org/wiki/Musical_expression gives a better explanation than I can give. Listen to song that you like. How loud or soft does the voice sound? Is it smooth? Does it jump around a lot? Is there a lot of energy to it?
Comment: TY very much. Now, I have the correct picture. Just match it now whether I am right or wrong...The ultimate goal of a song is to create feelings to the audience. Say, a composer has felt something. He has expressed it into a lyric and also, with the help of musical instruments, fixed a rhythm through a chord progression that can fit the verses of lyric and also,created some other musical intro, outro,bridges...etc felt necessary for fully expression to complete a song. Am I right?
Comment: Yes a lot goes into a song to make is sound happy or sad not just the chords.
Comment: @Dom - actually, you're incorrect with respect to note production.  There are several dozen types of singing styles from all over the world where vocalists can sing several pitches simultaneously.
Answer: The quality of a singer's voice doesn't change from singing a 6th, or 7th. The underlying mix of notes will change (harmony), but the timbre will remain stable. A different word/vowel sound may have a changed inflection, and where a particular word is,  in a bar or line will sound different - as in emphasis, but that's all.
In the Western world, Europe, etc. most vocals are sung using one note at a time, -I don't know where you're from - so singing more than one note, to make a chord, is quite unusual.So, only using one note at a time as the criterion, we can't sing chords anyway, thus making the idea of adjusting to different chords very difficult.
I wonder if you mean to ask about singing a particular note out of an underlying chord, or even a note that doesn't belong to that chord.E.g. singing the 6th over a maj6 chord will sound quite different from singing the root. It sort of highlights the fact that it's not just another major , but has an addition.I.e. it shows more about the quality of the accompaniment.
Answer: It seems that you are talking about singing improvisation. For that matter, you should get into studying harmony, so you will know wich note of a chord you are singing, and moreso, get into harmony chord functions. Then you'll realize that for each of those chords you pretend to sing in, there is an harmonic field: predetermined possible notes by the function of that chord at that place in the overall harmony. Among those notes, you will find that some are more emotional expressive - because they will conotate the harmonic function of that chord more explicitly - and others are less tensioned.
For example, take a simple harmony: | C7+   | Dm79   | G79-   | C7+   |...
At the first bar, if there is no accompaniment and the melody sings only C and G notes, we will never find it is a Major harmony. So, the 3rd is totally relevant. And so, if the B is not sung, we will not hear the 7th. You sing Jonic.
Second bar: most relevant notes: D and F (so it's minor). Expressive notes: C (7th) and E (9th). You sing Doric.
Third bar: relevant: G. Expressive: Ab (that's really expressive, because it is strange to the harmony). In this place of a dominant function, the B is also very expressive, it is the sensible note. All the traditional harmony grew from it. Sing it. It claims for the C. And F is very expressive because claims for the E. In this scenario, F and B form a tritone. You sing Altered Mixolydian b9 (and b13 -- Eb instead of E nat if you will).
Also remember that jumps express drama. And it feels different when the jump is up or downward. High pitches often thrill expectators.
Hope it helps to point out ways.