What is a raw type and why shouldn't we use it?

Question: Questions:

What are raw types in Java, and why do I often hear that they shouldn't be used in new code?
What is the alternative if we can't use raw types, and how is it better?
Comment: Note that the reason why raw types exist is for backwards compatibility with Java 1.4 and older, which did not have generics at all.
Comment: the java tutorials still use the JComboBox that causes this warning. Which version of the combobox will not cause this warning ? http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html
Answer: What is a raw type?
The Java Language Specification defines a raw type as follows:
JLS 4.8 Raw Types

A raw type is defined to be one of:

The reference type that is formed by taking the name of a generic type declaration without an accompanying type argument list.

An array type whose element type is a raw type.

A non-static member type of a raw type R that is not inherited from a superclass or superinterface of R.

Here's an example to illustrate:
public class MyType<E> {
    class Inner { }
    static class Nested { }

    public static void main(String[] args) {
        MyType mt;          // warning: MyType is a raw type
        MyType.Inner inn;   // warning: MyType.Inner is a raw type

        MyType.Nested nest; // no warning: not parameterized type
        MyType<Object> mt1; // no warning: type parameter given
        MyType<?> mt2;      // no warning: type parameter given (wildcard OK!)
    }
}

Here, MyType<E> is a parameterized type (JLS 4.5). It is common to colloquially refer to this type as simply MyType for short, but technically the name is MyType<E>.
mt has a raw type (and generates a compilation warning) by the first bullet point in the above definition; inn also has a raw type by the third bullet point.
MyType.Nested is not a parameterized type, even though it's a member type of a parameterized type MyType<E>, because it's static.
mt1, and mt2 are both declared with actual type parameters, so they're not raw types.

What's so special about raw types?
Essentially, raw types behaves just like they were before generics were introduced. That is, the following is entirely legal at compile-time.
List names = new ArrayList(); // warning: raw type!
names.add("John");
names.add("Mary");
names.add(Boolean.FALSE); // not a compilation error!

The above code runs just fine, but suppose you also have the following:
for (Object o : names) {
    String name = (String) o;
    System.out.println(name);
} // throws ClassCastException!
  //    java.lang.Boolean cannot be cast to java.lang.String

Now we run into trouble at run-time, because names contains something that isn't an instanceof String.
Presumably, if you want names to contain only String, you could perhaps still use a raw type and manually check every add yourself, and then manually cast to String every item from names. Even better, though is NOT to use a raw type and let the compiler do all the work for you, harnessing the power of Java generics.
List<String> names = new ArrayList<String>();
names.add("John");
names.add("Mary");
names.add(Boolean.FALSE); // compilation error!

Of course, if you DO want names to allow a Boolean, then you can declare it as List<Object> names, and the above code would compile.
See also

Java Tutorials/Generics

How's a raw type different from using <Object> as type parameters?
The following is a quote from Effective Java 2nd Edition, Item 23: Don't use raw types in new code:

Just what is the difference between the raw type List and the parameterized type List<Object>? Loosely speaking, the former has opted out generic type checking, while the latter explicitly told the compiler that it is capable of holding objects of any type. While you can pass a List<String> to a parameter of type List, you can't pass it to a parameter of type List<Object>. There are subtyping rules for generics, and List<String> is a subtype of the raw type List, but not of the parameterized type List<Object>. As a consequence, you lose type safety if you use raw type like List, but not if you use a parameterized type like List<Object>.

To illustrate the point, consider the following method which takes a List<Object> and appends a new Object().
void appendNewObject(List<Object> list) {
   list.add(new Object());
}

Generics in Java are invariant. A List<String> is not a List<Object>, so the following would generate a compiler warning:
List<String> names = new ArrayList<String>();
appendNewObject(names); // compilation error!

If you had declared appendNewObject to take a raw type List as parameter, then this would compile, and you'd therefore lose the type safety that you get from generics.
See also

What is the difference between <E extends Number> and <Number>?
java generics (not) covariance

How's a raw type different from using <?> as a type parameter?
List<Object>, List<String>, etc are all List<?>, so it may be tempting to just say that they're just List instead. However, there is a major difference: since a List<E> defines only add(E), you can't add just any arbitrary object to a List<?>. On the other hand, since the raw type List does not have type safety, you can add just about anything to a List.
Consider the following variation of the previous snippet:
static void appendNewObject(List<?> list) {
    list.add(new Object()); // compilation error!
}
//...

List<String> names = new ArrayList<String>();
appendNewObject(names); // this part is fine!

The compiler did a wonderful job of protecting you from potentially violating the type invariance of the List<?>! If you had declared the parameter as the raw type List list, then the code would compile, and you'd violate the type invariant of List<String> names.

A raw type is the erasure of that type
Back to JLS 4.8:

It is possible to use as a type the erasure of a parameterized type or the erasure of an array type whose element type is a parameterized type. Such a type is called a raw type.
[...]
The superclasses (respectively, superinterfaces) of a raw type are the erasures of the superclasses (superinterfaces) of any of the parameterizations of the generic type.
The type of a constructor, instance method, or non-static field of a raw type C that is not inherited from its superclasses or superinterfaces is the raw type that corresponds to the erasure of its type in the generic declaration corresponding to C.

In simpler terms, when a raw type is used, the constructors, instance methods and non-static fields are also erased.
Take the following example:
class MyType<E> {
    List<String> getNames() {
        return Arrays.asList("John", "Mary");
    }

    public static void main(String[] args) {
        MyType rawType = new MyType();
        // unchecked warning!
        // required: List<String> found: List
        List<String> names = rawType.getNames();
        // compilation error!
        // incompatible types: Object cannot be converted to String
        for (String str : rawType.getNames())
            System.out.print(str);
    }
}

When we use the raw MyType, getNames becomes erased as well, so that it returns a raw List!
JLS 4.6 continues to explain the following:

Type erasure also maps the signature of a constructor or method to a signature that has no parameterized types or type variables. The erasure of a constructor or method signature s is a signature consisting of the same name as s and the erasures of all the formal parameter types given in s.
The return type of a method and the type parameters of a generic method or constructor also undergo erasure if the method or constructor's signature is erased.
The erasure of the signature of a generic method has no type parameters.

The following bug report contains some thoughts from Maurizio Cimadamore, a compiler dev, and Alex Buckley, one of the authors of the JLS, on why this sort of behavior ought to occur: https://bugs.openjdk.java.net/browse/JDK-6400189. (In short, it makes the specification simpler.)

If it's unsafe, why is it allowed to use a raw type?
Here's another quote from JLS 4.8:

The use of raw types is allowed only as a concession to compatibility of legacy code. The use of raw types in code written after the introduction of genericity into the Java programming language is strongly discouraged. It is possible that future versions of the Java programming language will disallow the use of raw types.

Effective Java 2nd Edition also has this to add:

Given that you shouldn't use raw types, why did the language designers allow them? To provide compatibility.
The Java platform was about to enter its second decade when generics were introduced, and there was an enormous amount of Java code in existence that did not use generics. It was deemed critical that all this code remains legal and interoperable with new code that does use generics. It had to be legal to pass instances of parameterized types to methods that were designed for use with ordinary types, and vice versa. This requirement, known as migration compatibility, drove the decision to support raw types.

In summary, raw types should NEVER be used in new code. You should always use parameterized types.

Are there no exceptions?
Unfortunately, because Java generics are non-reified, there are two exceptions where raw types must be used in new code:

Class literals, e.g. List.class, not List<String>.class
instanceof operand, e.g. o instanceof Set, not o instanceof Set<String>

See also

Why is Collection<String>.class Illegal?
Comment: What do you mean that, "Java generics are non-reified"?
Comment: "Non-reified" is another way of saying that they are erased. The compiler knows what the generic parameters are, but that information is not passed on to the generated bytecode. The JLS requires that class literals have no type parameters.
Comment: For the second exception, the syntax `o instanceof Set` is also permitted to avoid the raw type (though it's only superficial in this case).
Comment: @OldCurmudgeon That's interesting. I mean officially it's *neither*, because a class literal defined as just `TypeName.class`, where `TypeName` is a plain identifier ([jls](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.8.2)). Speaking hypothetically, I guess it could really be either. Maybe as a clue, `List.class` is the variant that the JLS specifically calls a compiler error, so if they ever add it to the language I'd expect that that is the one they use.
Comment: @Jwan622 because the program is *much less likely* to leave the developers local PC still in that state.
Comment: Raw types are very usefull and reduce boilerplate code in case of JNDI lookups for a bean which extends an interface. This resolves the need to write `n` remote beans for each implementing class with identical code.
Comment: There might be a thrd exception. A case where you really need to extnd/implement 2 parents with different typed methods that  share same erased signature whose names clash. Then the only simple way is using raw type for the parameter of the inherited method to avoid collisions and do the type checking hardcoded according to what each parent expects. It's really ugly, but works as a self-explanatory workarond,,..
Comment: can you give me an example of " migration compatibility" ??
Comment: When using the generics... why is having an error thrown at compilation time "better" than having an exception thrown at runtime?
Comment: @Radiodef - Wouldn't it be `List.class`? Like `Collections.emptyMap();` - i.e. the generic **after** the dot.
Answer:
What are raw types in Java, and why do I often hear that they shouldn't be used in new code?

Raw-types are ancient history of the Java language. In the beginning there were Collections and they held Objects nothing more and nothing less. Every operation on Collections required casts from Object to the desired type.
List aList = new ArrayList();
String s = "Hello World!";
aList.add(s);
String c = (String)aList.get(0);

While this worked most of the time, errors did happen
List aNumberList = new ArrayList();
String one = "1";//Number one
aNumberList.add(one);
Integer iOne = (Integer)aNumberList.get(0);//Insert ClassCastException here

The old typeless collections could not enforce type-safety so the programmer had to remember what he stored within a collection.
Generics where invented to get around this limitation, the developer would declare the stored type once and the compiler would do it instead.
List<String> aNumberList = new ArrayList<String>();
aNumberList.add("one");
Integer iOne = aNumberList.get(0);//Compile time error
String sOne = aNumberList.get(0);//works fine

For Comparison:
// Old style collections now known as raw types
List aList = new ArrayList(); //Could contain anything
// New style collections with Generics
List<String> aList = new ArrayList<String>(); //Contains only Strings

More complex the Compareable interface:
//raw, not type save can compare with Other classes
class MyCompareAble implements CompareAble
{
   int id;
   public int compareTo(Object other)
   {return this.id - ((MyCompareAble)other).id;}
}
//Generic
class MyCompareAble implements CompareAble<MyCompareAble>
{
   int id;
   public int compareTo(MyCompareAble other)
   {return this.id - other.id;}
}

Note that it is impossible to implement the CompareAble interface with compareTo(MyCompareAble) with raw types.
Why you should not use them:

Any Object stored in a Collection has to be cast before it can be used
Using generics enables compile time checks
Using raw types is the same as storing each value as Object

What the compiler does:
Generics are backward compatible, they use the same java classes as the raw types do. The magic happens mostly at compile time.
List<String> someStrings = new ArrayList<String>();
someStrings.add("one");
String one = someStrings.get(0);

Will be compiled as:
List someStrings = new ArrayList();
someStrings.add("one");
String one = (String)someStrings.get(0);

This is the same code you would write if you used the raw types directly. Thought I'm not sure what happens with the CompareAble interface, I guess that it creates two compareTo functions, one taking a MyCompareAble and the other taking an Object and passing it to the first after casting it.
What are the alternatives to raw types: Use generics
Answer: A raw type is the name of a generic class or interface without any type arguments. For example, given the generic Box class:
public class Box<T> {
    public void set(T t) { /* ... */ }
    // ...
}

To create a parameterized type of Box<T>, you supply an actual type argument for the formal type parameter T:
Box<Integer> intBox = new Box<>();

If the actual type argument is omitted, you create a raw type of Box<T>:
Box rawBox = new Box();

Therefore, Box is the raw type of the generic type Box<T>. However, a non-generic class or interface type is not a raw type.
Raw types show up in legacy code because lots of API classes (such as the Collections classes) were not generic prior to JDK 5.0. When using raw types, you essentially get pre-generics behavior — a Box gives you Objects. For backward compatibility, assigning a parameterized type to its raw type is allowed:
Box<String> stringBox = new Box<>();
Box rawBox = stringBox;               // OK

But if you assign a raw type to a parameterized type, you get a warning:
Box rawBox = new Box();           // rawBox is a raw type of Box<T>
Box<Integer> intBox = rawBox;     // warning: unchecked conversion

You also get a warning if you use a raw type to invoke generic methods defined in the corresponding generic type:
Box<String> stringBox = new Box<>();
Box rawBox = stringBox;
rawBox.set(8);  // warning: unchecked invocation to set(T)

The warning shows that raw types bypass generic type checks, deferring the catch of unsafe code to runtime. Therefore, you should avoid using raw types.
The Type Erasure section has more information on how the Java compiler uses raw types.
Unchecked Error Messages
As mentioned previously, when mixing legacy code with generic code, you may encounter warning messages similar to the following:

Note: Example.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

This can happen when using an older API that operates on raw types, as shown in the following example:
public class WarningDemo {
    public static void main(String[] args){
        Box<Integer> bi;
        bi = createBox();
    }

    static Box createBox(){
        return new Box();
    }
}

The term "unchecked" means that the compiler does not have enough type information to perform all type checks necessary to ensure type safety. The "unchecked" warning is disabled, by default, though the compiler gives a hint. To see all "unchecked" warnings, recompile with -Xlint:unchecked.
Recompiling the previous example with -Xlint:unchecked reveals the following additional information:
WarningDemo.java:4: warning: [unchecked] unchecked conversion
found   : Box
required: Box<java.lang.Integer>
        bi = createBox();
                      ^
1 warning

To completely disable unchecked warnings, use the -Xlint:-unchecked flag. The @SuppressWarnings("unchecked") annotation suppresses unchecked warnings. If you are unfamiliar with the @SuppressWarnings syntax, see Annotations.
Original source: Java Tutorials
Answer: A "raw" type in Java is a class which is non-generic and deals with "raw" Objects, rather than type-safe generic type parameters.
For example, before Java generics was available, you would use a collection class like this:
LinkedList list = new LinkedList();
list.add(new MyObject());
MyObject myObject = (MyObject)list.get(0);

When you add your object to the list, it doesn't care what type of object it is, and when you get it from the list, you have to explicitly cast it to the type you are expecting.
Using generics, you remove the "unknown" factor, because you must explicitly specify which type of objects can go in the list:
LinkedList<MyObject> list = new LinkedList<MyObject>();
list.add(new MyObject());
MyObject myObject = list.get(0);

Notice that with generics you don't have to cast the object coming from the get call, the collection is pre-defined to only work with MyObject.  This very fact is the main driving factor for generics.  It changes a source of runtime errors into something that can be checked at compile time.
Comment: More specifically, a raw type is what you get when you simply omit the type parameters for a generic type.  Raw types were really only ever a backwards-compatibility feature, and are potentially subject to removal.  You can get similar behavior using ? wildcard parameters.
Comment: @zerocrates: similar but different! Using `?` still offers type safety. I covered it in my answer.
Answer:  private static List<String> list = new ArrayList<String>();

You should specify the type-parameter.
The warning advises that types that are defined to support generics should be parameterized, rather than using their raw form.
List is defined to support generics: public class List<E>. This allows many type-safe operations, that are checked compile-time.
Comment: Now replaced by *diamond inference* in Java 7 -- `private static List list = new ArrayList<>();`
Answer: What is a raw type and why do I often hear that they shouldn't be used in new code?
A "raw type" is the use of a generic class without specifying a type argument(s) for its parameterized type(s), e.g. using List instead of List<String>. When generics were introduced into Java, several classes were updated to use generics.  Using these class as a "raw type" (without specifying a type argument) allowed legacy code to still compile.
"Raw types" are used for backwards compatibility. Their use in new code is not recommended because using the generic class with a type argument allows for stronger typing, which in turn may improve code understandability and lead to catching potential problems earlier.
What is the alternative if we can't use raw types, and how is it better?
The preferred alternative is to use generic classes as intended - with a suitable type argument (e.g. List<String>). This allows the programmer to specify types more specifically, conveys more meaning to future maintainers about the intended use of a variable or data structure, and it allows compiler to enforce better type-safety.  These advantages together may improve code quality and help prevent the introduction of some coding errors.
For example, for a method where the programmer wants to ensure a List variable called 'names' contains only Strings:
List<String> names = new ArrayList<String>();
names.add("John");          // OK
names.add(new Integer(1));  // compile error

Comment: Ah, so tempted to copy `polygenelubricants`'s "raw type" references from http://stackoverflow.com/questions/2770111/how-can-we-improve-performance-of-this-piece-of-code/2770253#2770253 into my own answer, but I suppose I'll leave them for use in his/her own answer.
Comment: yes, I've been essentially copying-and-pasting that segment everywhere people use raw types on stackoverflow, and finally decided to just have one question to refer to from now on. I hope it's a good contribution for the community.
Comment: @polygenelubricants I noticed - we hit some of the same questions :-)
Comment: @ha9u63ar: Indeed. In general concise and simple answers are at least as good as the long and accepted ones.
Answer: Here I am Considering multiple cases  through which you can clearify  the concept
1. ArrayList<String> arr = new ArrayList<String>();
2. ArrayList<String> arr = new ArrayList();
3. ArrayList arr = new ArrayList<String>();

Case 1
ArrayList<String> arr it is a ArrayList reference variable with type String which reference to a ArralyList Object of Type String. It means it can hold only String type Object.
It is a Strict to String not  a Raw Type so, It will never raise an warning .
    arr.add("hello");// alone statement will compile successfully and no warning.

    arr.add(23);  //prone to compile time error.
     //error: no suitable method found for add(int)

Case 2
In this case ArrayList<String> arr is a strict type but your Object new ArrayList(); is a raw type.
    arr.add("hello"); //alone this compile but raise the warning.
    arr.add(23);  //again prone to compile time error.
    //error: no suitable method found for add(int)

here arr is a Strict type. So, It will raise compile time error when adding a integer.

Warning :- A Raw Type Object is referenced to a Strict type Referenced Variable of ArrayList.

Case 3
In this case ArrayList arr is a raw type but your Object new ArrayList<String>(); is a Strict type.
    arr.add("hello");
    arr.add(23);  //compiles fine but raise the warning.

It will add any type of Object into it because arr is a Raw Type.

Warning :- A Strict Type Object is referenced to a raw type referenced Variable.
Comment: In Case 2, are there some other disadvantages except the warning? I mean, if I ignore the warning, I think Case 1 and Case 2 are the same...
Answer: The compiler wants you to write this:
private static List<String> list = new ArrayList<String>();

because otherwise, you could add any type you like into list, making the instantiation as new ArrayList<String>() pointless. Java generics are a compile-time feature only, so an object created with new ArrayList<String>() will happily accept Integer or JFrame elements if assigned to a reference of the "raw type" List - the object itself knows nothing about what types it's supposed to contain, only the compiler does.
Answer: Here's another case where raw types will bite you:
public class StrangeClass<T> {
  @SuppressWarnings("unchecked")
  public <X> X getSomethingElse() {
    return (X)"Testing something else!";
  }

  public static void main(String[] args) {
    final StrangeClass<String> withGeneric    = new StrangeClass<>();
    final StrangeClass         withoutGeneric = new StrangeClass();
    final String               value1,
                               value2;

    // Compiles
    value1 = withGeneric.getSomethingElse();

    // Produces compile error:
    // incompatible types: java.lang.Object cannot be converted to java.lang.String
    value2 = withoutGeneric.getSomethingElse();
  }
}

This is counter-intuitive because you'd expect the raw type to only affect methods bound to the class type parameter, but it actually also affects generic methods with their own type parameters.
As was mentioned in the accepted answer, you lose all support for generics within the code of the raw type. Every type parameter is converted to its erasure (which in the above example is just Object).
Answer: A raw-type is the a lack of a type parameter when using a generic type.
Raw-type should not be used because it could cause runtime errors, like inserting a double into what was supposed to be a Set of ints.
Set set = new HashSet();
set.add(3.45); //ok

When retrieving the stuff from the Set, you don't know what is coming out. Let's assume that you expect it to be all ints, you are casting it to Integer; exception at runtime when the double 3.45 comes along.
With a type parameter added to your Set, you will get a compile error at once. This preemptive error lets you fix the problem before something blows up during runtime (thus saving on time and effort).
Set<Integer> set = new HashSet<Integer>();
set.add(3.45); //NOT ok.

Answer: Avoid raw types.
Raw types refer to using a generic type without specifying a type parameter.
For example:
A list is a raw type, while List<String> is a parameterized type.
When generics were introduced in JDK 1.5, raw types were retained only to maintain backwards compatibility with older versions of Java.
Although using raw types is still possible, they should be avoided:

They usually require casts.
They aren't type safe, and some important kinds of errors will only appear at runtime.
They are less expressive, and don't self-document in the same way as parameterized types..

Example:
import java.util.*;
public final class AvoidRawTypes {
    void withRawType() {
        //Raw List doesn't self-document,
        //doesn't state explicitly what it can contain
        List stars = Arrays.asList("Arcturus", "Vega", "Altair");
        Iterator iter = stars.iterator();
        while (iter.hasNext()) {
            String star = (String) iter.next(); //cast needed
            log(star);
        }
    }

    void withParameterizedType() {
        List < String > stars = Arrays.asList("Spica", "Regulus", "Antares");
        for (String star: stars) {
            log(star);
        }
    }

    private void log(Object message) {
        System.out.println(Objects.toString(message));
    }
}

For reference: https://docs.oracle.com/javase/tutorial/java/generics/rawTypes.html
Answer: What is saying is that your list is a List of unespecified objects. That is that Java does not know what kind of objects are inside the list. Then when you want to iterate the list you have to cast every element, to be able to access the properties of that element (in this case, String).
In general is a better idea to parametrize the collections, so you don't have conversion problems, you will only be able to add elements of the parametrized type and your editor will offer you the appropiate methods to select.
private static List<String> list = new ArrayList<String>();

Answer: tutorial page.
A raw type is the name of a generic class or interface without any type arguments. For example, given the generic Box class:
public class Box<T> {
    public void set(T t) { /* ... */ }
    // ...
}

To create a parameterized type of Box, you supply an actual type argument for the formal type parameter T:
Box<Integer> intBox = new Box<>();

If the actual type argument is omitted, you create a raw type of Box:
Box rawBox = new Box();

Answer: I found this page after doing some sample exercises and having the exact same puzzlement.
============== I went from this code as provide by the sample ===============
public static void main(String[] args) throws IOException {

    Map wordMap = new HashMap();
    if (args.length > 0) {
        for (int i = 0; i < args.length; i++) {
            countWord(wordMap, args[i]);
        }
    } else {
        getWordFrequency(System.in, wordMap);
    }
    for (Iterator i = wordMap.entrySet().iterator(); i.hasNext();) {
        Map.Entry entry = (Map.Entry) i.next();
        System.out.println(entry.getKey() + " :\t" + entry.getValue());
    }

====================== To This code ========================
public static void main(String[] args) throws IOException {
    // replace with TreeMap to get them sorted by name
    Map<String, Integer> wordMap = new HashMap<String, Integer>();
    if (args.length > 0) {
        for (int i = 0; i < args.length; i++) {
            countWord(wordMap, args[i]);
        }
    } else {
        getWordFrequency(System.in, wordMap);
    }
    for (Iterator<Entry<String, Integer>> i = wordMap.entrySet().iterator(); i.hasNext();) {
        Entry<String, Integer> entry =   i.next();
        System.out.println(entry.getKey() + " :\t" + entry.getValue());
    }

}

===============================================================================
It may be safer but took 4  hours to demuddle the philosophy...
Answer: Raw types are fine when they express what you want to express.
For example, a deserialisation function might return a List, but it doesn't know the list's element type. So List is the appropriate return type here.
Comment: You can use ? as type parameter
Comment: Yes, but that is more to type and I am against typing more. :)


Spectral Whitening, Seismic Interferometry

Question: What is the role of spectral whitening in the processing step done before cross-correlations in seismic interferometry?
Answer: I'm not an expert on this topic. But my understanding of seismic interferometry is that we try to obtain the 'Green's function' between various receivers. This Green's function is the equivalent of sending a spike pulse (i.e., delta function $\delta$) at one receiver, and recording the result at the other receiver. Once we have plenty of these Green's functions, ideally surrounding an area of interest, we can compute arbitrary Green's function recordings by evaluating a set of convolutions (rather than carrying out computations). It will be as if there is a recorder anywhere we want to record the signal.
In the time-domain, this $\delta$-spiked source is a source that's on for an infinitesimally small amount of time before switching off again. As you can maybe imagine, this source will have an infinitesimally small wavelength. We will thus be able to see every modulation of the signal as a single identifiable event in time: a scatter of amplitude $A_1$ happens after $t_1$ seconds, a reflection with amplitude $A_2$ happens after $t_2$ seconds, etc. Thus, we gain an incredibly high-resolution understanding of the medium in-between!
The frequency spectrum of such a $\delta$-spike has uniform amplitude. All frequencies are thus represented. It is called a 'broadband signal'.
In reality, we do not obtain $\delta$-spikes very often because the predominant frequencies in the data are provided by noise with a specific frequency, usually a very low one. This low-frequency, or long-wavelength, property makes the obtained Green's functions of very low frequency. Different events will smear and overlap in time. This makes it more difficult to interpret the medium from the obtained Green's functions.
Spectral whitening is a process that boosts frequencies with a low amplitude, to try and make any signal more $\delta$-pulse-like. See for example here https://twitter.com/DownUnderGeo/status/984324387720527872 for an example from active seismic exploration, how boosting the amplitude of higher frequencies (while retaining the low ones), doesn't just look nicer, but provides a considerable increase in identifiable events! The same principle applies to seismic interferometry. By filtering the data, we obtain a more $\delta$-like behavior, thus obtain a more broadband signal from a less-than-ideal signal.


Why didn't the Time Lords come through and all escape from Trenzalore?

Question: If the Doctor spoke his name then they would know that it would be safe to come through, but all this time they must have grown more TARDISes or could have shared them and as soon as they come through they all escape to different time periods and places, Gallifrey would be completely abandoned so there wouldn't be anyone to be killed and the Daleks would all leave as soon as they realise there's no point attacking the place. Since no other race has mastered time travel like they have, they can all agree to rendezvous at a time when the Daleks are extinct (like around the year 100 trillion) and plan to rebuild their civilisation (or make the final sanction at the end of the universe, there's nothing alive anyway). The citizens of Christmas could also be saved as the Doctor can fit them all into his TARDIS.
Comment: Time traveling isn't a defense against enemies that have time travel.
Comment: Unfortunately it was wibbily wobbly timey wimey so that plan wouldn't have worked.
Answer: The purpose of the Time Lords' message was two-fold:

To confirm for The Doctor that they were still alive (which he was probably unsure of after "Day of the Doctor"
To determine if it was safe for them to come back through.

They knew they were sealed away in the pocket dimension at the height of the Time War, when the entire universe was at risk of being destroyed. Presumably, they haven't been able to watch what was going on since then, until they found one of the cracks and could leak a message through.
By refusing to say his name at Trenzalore, The Doctor was telling them that it was not safe to come back. He knew their reemergence would just kick-start the Time War all over again, so he never gave them the signal. However, Clara speaking to them would have clued them in that The Doctor was there. They would have been smart enough to add those clues up and realize that The Doctor was warning them to stay away a while longer.
Also, it's completely untrue to claim that no other race has mastered Time Travel. The Daleks are at least as good at it as the Time Lords -- that's how they managed to wage a Time War in the first place. In addition, a number of other time-aware races exist, and within a few centuries even humans had figured out Time Travel (e.g. the Time Agents little wrist thingees). So, there really was nowhere and nowhen the Time Lords could go that the Daleks couldn't chase them.
Comment: Unfortunately this also makes the whole notion of "come back when it's safe" completely nonsensical. Even if you kill all the Daleks, they're still out there somewhere in time and space.
Comment: Yes, the daleks can time travel rather well but their problem is that they can't detect where and when the timelords will be heading, and as I recall they either can't know where they'll end up(emergency temporal shift) or has to have a very specific time.
Comment: The timelords according the tenth doctor can travel between parallel worlds easily,if there is no safe place in the universe they can go to a parallel one. I know that some daleks have void ships that can smash through the void, however since they haven't used one to directly attack the timelords over the centuries, it is clear that either It wasn't dalek technology or it's very difficult to make one, either way, they will have extreme difficulty chasing them through parallel worlds.
Answer: Because Gallifrey was weak, and ready to fall.
The Timelords were sealed away at the lowest point they had. There was no further last redoubt. Final defenses had failed.  The Daleks had won. Period.
While we dont know what relative time has passed inside Gallifrey's pocket, we do know that Timelord tech doesn't always react well to being away from the universe. They could well lack the ability to rebuild their power while sealed off. The biggest proof of this is Trenzalore itself - if they were strong enough to hold off their enemies, they wouldn't be asking if it was safe to come out.
Leaving Gallifrey behind isn't much of an option either. Many of their facilities to do things like create TARDISes would be planetbound. Their civilians would not be easily evacuated.  Daleks have time travel tech, so they would be pursued.
They needed to come back to a point where they would have a chance to rebuild. They didn't get it at Trenzalore. If the Master is loose, maybe they found somewhere else.
Comment: _"While we dont know what relative time has passed inside Gallifrey's pocket"_ This bothers me too; time is clearly passing (it's clear for various reasons) but they were supposed to be frozen in time like a painting.
Comment: @LightnessRacesinOrbit I suspect we're seeing the results of Moffat's writing and showrunning:  scenes are written for immediate emotional impact, not for long-term consistency across other stories.
Comment: _"Many of their facilities to do things like create TARDISes would be planetbound"_ Are you sure? The Doctor seemed to think you could just tear a piece of coral off an existing TARDIS and get the job done ("Journey's End" deleted shot)
Comment: @LightnessRacesinOrbit - nope. I never claim I'm sure with magitek. That said, with conflicting factions on the planet and varying levels of morality, I didn't assume civilians would be the only reason to stay. I do believe there are things like the Schism that cannot be moved from Gallifrey, at least without titanic effort.
Comment: @TiStrga - ... and you think that's a Moffat only thing? Where were you for Davies? Or, from everything I've heard, the rest of the original show?
Comment: @Radhil I was politely suspending my disbelief.


How should one choose a supervisor if they haven't yet narrowed down their research focus?

Question: From what I know, every Phd student needs to choose a supervisor in the first year. For someone who is entering a  Phd with a broad interest in a field, this might be difficult since they don't immediately know what they want to work on. How do they go about choosing a supervisor in that case?
Comment: dont forget that you *always* have the chance to change supervisor.
Comment: But that can't be easy right? Most people I know seem to have had the same supervisor throughout their PhD. Please correct me if I'm wrong.
Answer: My advice will be similar to aeisimail's, and though I have not actually done exactly what I am suggesting, the main points are still based on personal experience.
(Also note that I come from the European setting (PhD in France currently) so the levels of education when you actually start looking for an adviser might differ, but I'll try to do my best to be general.)
In my opinion, there's three almost equally important parts to choosing what to do for PhD:

the subject (narrow field of focus, project you're taking on)
Even if you are not sure what exactly you want to do, if you don't see yourself getting at least a little bit excited about the subject, you will not be able to do it and enjoy it for the whole PhD duration. It also helps if you see the adviser being fascinated by what he does.

the adviser -- on both personal and professional level
Of course, you should read something about his previous works. Read some of his publications, something about ongoing projects. Ask around for information from other students. But also, if you have a chance, try and talk to the potential adviser, in person. Maybe some people can get a feel for an adviser from e-mail or other indirect communication, but for me, if I can hold an easy conversation with someone for 5-10 minutes, I'll probably be okay working with them.

the environment -- both for working and for living
If you can, try and get a feel for the research group and the lab you would potentially belong to. Depending on the type of person you are, you will prefer different environments. But, a friendly atmosphere is beneficial to everybody. Also, take a look at where you'll have to live (if you're moving for you PhD): a very extrovert person might suffer after moving to a small, quiet town. A big bustling town might overwhelm a shy and introvert person. Make sure you can be comfortable outside your PhD/job, because as much as you can't do a PhD if you don't love what you do, you won't be able to do it well if you don't like what your life is outside of that.

It might seem right now that you can survive with a good topic and adviser, in a bad environment, or some other way around, but think about it: those three things will be with you through the whole PhD. You can't do a PhD properly if you don't love what you do, who you do it with and where you are. All three of them are very important.

And some more specific advice that I collected over the years, which is probably not applicable in all the situations but is worth taking under consideration:

young advisers at the start of their career are more likely to pay more attention to their students. If you want to work with your adviser, it will probably be harder with somebody who's already made a name for themselves: you're more likely to end up just working under them.
the longer the people are in academia, the more they do administration instead of research. Know how to take advantage of what you have. If you end up with an adviser over his head in administration, keep research questions rare and to the point, when you need them. But know that these kind of people will be able to resolve some administrative problems for you that others might not be able to.
no matter what type of adviser you get, in the end it is your own PhD topic. The adviser does not hold the absolute truth, and does not have all the answers. He's good for directing you and helping you focus, sometimes discussing problems, but towards the end of your PhD, you are the one that will become the foremost expert on the topic. Prepare for that, so you don't end up disappointed the first time you see your adviser guessing and struggling around your problem just like you.
find what fascinated you about your own (potential) topic. Don't get all starry-eyed about what the output should be when looking for at a subject. If the output is all neat and useful and pretty, think about weather it has, for example, too much maths for you to be enjoying working on it. It's not just about what you are capable of doing, it's about what you enjoy doing.

Sorry for the short novel, I hope you find something that helps you.
Comment: "young advisers at the start of their career are more likely to pay more attention to their students" how did you arrive at that conclusion? (I've also met the opposite rumour: young professors who still need to "fight" for their position [standing in the faculty etc] need students (i.e. their results) they can *use*, whereas older professors who are settled at the top of their carreer can afford to support the professional development the student: putting the two trains of thought together it probably boils down to: see what the potential supervisor's group leading style and character are.
Comment: @cbeleites That's not my conclusion: that's advice from my Masters adviser, based on his experience, I'm just repeating. He says old, established professors will more likely be knee-deep in administration, have less time, and after a lot of successful PhD students behind them, will not care _as much_ for just one students' success. On the other hand, if you are among the first few students of a professor, it is very much in his interest to not have his first (or one out of 4) PhD students fail miserably. Also, apparently, less administration and more time for research for starting professors.
Comment: @penelope - Thanks a ton for your answer, it answers a lot of my worries.
Comment: @warmzombie glad I could help
Answer: Most research groups have seminars or weekly meetings. If you're not sure about a particular supervisor, but have a set of interests, try attending research group meetings for faculty in those areas. Faculty are quite used to this and will usually welcome the attendance (but do check with them first)
Answer: As it happens, your case was similar to mine—I didn't have a clue about exactly what I wanted to do, other than being interested in simulations rather than experiment. And, unlike JeffE's advice, in my field (chemical engineering), we don't get the option of working with multiple advisors for extended periods of time, because of the way project funding works.
What makes things easier for us? All of the faculty give presentations to the first-year graduate students, and all of the first-year students were required to meet with a number of potential advisors before ranking our preferences. This makes it easier, because we had to be active in seeking out advisors. Talking with graduate students in the group was also very helpful, because it allowed me to learn more about the advisors' styles, as well as the people that are in the groups. (Some of the groups were very cordial, others were not nearly so civil in their interactions—made a big difference in making my decision.)
Answer: When searching for a supervisor, look at their research profile (usually on a university website), paying particular attention to their fields of expertise/interests - look at and read any papers that they have had published and the nature of the PhD projects that they have already/are currently supervising.
Discuss what options there are with members of the Faculty that whose general fields you are interested in.  Ask what projects are upcoming.
Hope this helps.
Comment: Yes, asking potential advisers is what it most often comes down to.
Answer: Pick someone at random.  (Use your research interests and experience, and the available faculty's research interests and experience, to bias your probability distribution.)  Work with them for a semester.  If you both like the work that you're doing together, and they're willing to take you on as a student, you're done.  Otherwise, repeat.
No, I'm not joking.
Comment: That advice doesn't work in some disciplines.
Answer: The ideal PhD supervisor has/provides:

A good track record of successful PhD students
Expert Knowledge and High Reputation
Sufficient Time for your PhD supervision
Opportunities for collaborations
A permanent and stable position
Sufficient, Secure, and Flexible Funding
Good office space
A position at a reputable university
Additional Mentorship Skills

More in my blog: https://www.scss.tcd.ie/joeran.beel/blog/2018/03/20/how-to-find-a-good-phd-supervisor-for-recommender-systems-and-machine-learning-research/


Would uploading preliminary research results on Arxiv certify new discovery as mine?

Question: I have some preliminary results in my research, but due to my current situation I won't have time to send these to a relevant journal. Yet I would like to claim these as my discoveries, in case someone else have similar results.  Would I be able to claim these as my discoveries if I upload them to Arxiv?
Comment: Note that while the Arxiv doesn't have a typical peer-review process, it still has certain standards regarding your publication resembling a paper. You probably won't be able to publish a bunch of data with a few notes.
Answer: In short: yes.
Of course, as Wrzlprmft suggested, you need to make it look decent enough so that arXiv won't reject it, but once it's there, it will have your name on it, be connected forever to your arXiv account etc. You can always claim that you were first. (I.e. if someone publishes exactly the same thing, or at least very similar, you can always write to the journal and say their research was not original, and point to your arXiv preprint. By the way, this might not mean stealing your ideas, but simply overlooking your work; still a bad thing, though.) And of course there is no problem in improving the manuscript and sending it to journal later.
On the other hand, however, others can use your idea in their own research, apply it to something else, or generalize it, and with proper citation, they will be able to publish their own results while conforming with academic ethics. So they might do some further research that you have in mind, and you can't prevent it.
Comment: I guess if others significantly generalize OP's result and publish it; this could prevent the OP from later finishing the (arxiv) paper and publishing it in a journal/at a conference (or at least, this could make it harder to get it accepted somewhere).


Is it haram to discuss our father's careless employees at home?

Question: My father owns a shop he tells us about his business and carelessness of his workers at home.  Is it haram for him to do so? And is it haram us discussing about it at home? I mean he is telling us about his workers is it wrong?
Answer: Here's the definition of backbiting the Prophet gave:

Abu Huraira reported Allah's Messenger (ﷺ) as saying: Do you know what is backbiting? They (the Companions) said: Allah and His Messenger know best. Thereupon he (the Holy Prophet) said: Backbiting implies your talking about your brother in a manner which he does not like. It was said to him: What is your opinion about this that if I actually find (that failing) in my brother which I made a mention of? He said: If (that failing) is actually found (in him) what you assert, you in fact backbited him, and if that is not in him it is a slander. -- Sahih Muslim 2589 (sunnah.com)

Asking the question implies the employees would not like this conversation.  If you can work out exactly who the discussion is about, it matches this definition, and can be regarded as backbiting (or sufficiently close to backbiting to stay away from it).
However, it wouldn't be backbiting if the employees are sufficiently anonymous:

If there is no danger of anyone figuring out who is being spoken about, and if there is a genuine benefit from relating the matter – like setting an example or conveying to people a valuable lesson, then it is permissible. -- Islam Today
Comment: The hadith says "Backbiting implies your talking about your brother in a manner which he does not like", not "talking about someone in a manner he does not like constitutes backbiting"; it sounds like a necessary condition, not a sufficient one.


Can methylation from DNA get copied to RNA during transcription?

Question: Methylation on gene-body and 3'UTRs if copied to mRNA can potentially regulate post-transcription modifications or expression regulation. But I'm not sure if they are maintained after transcription or if they get all de-novo methylation.
Answer: I don't believe anything should change in the majority of DNA->RNA transcription. DNA methylation typically occurs on the non-watson crick side of Cytosine so it shouldn't affect the base-pairing.
However, there are a few hypothetical situations that would result in alterations of the transcribed RNA. The sponatneous deamination of the 4' amine would convert the base into uracil. If there is an additional 5' methyl, the 5-methyluracil would be recognized as Thymine.
(edit) I've talked with several genomics folks about this topic and it turns out that M5Cytosine is very resistant to deamination due to the presence of the Methyl group. As a result, the instance that I have just described is actually very rare.

5mCytosine to Thymine deamination
The other situation would be to errors in DNA proofreading. Does the 5mCytosine affect the fidelity of RNA polymerase? I honestly don't know but it would be worth examining.
Comment: Is there any citation of altering cytosine on RNA to 5mC?
Comment: @Garima Kushwaha. Does this count? http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2836557/
Comment: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC307917/ This paper has the opposite view; that the rate of deamination is higher in the methyl version which accounts for its increased mutation rate.
Answer: There is an article in PNAS Conservation and divergence in eukaryotic DNA methylation who used:

next-generation sequencing to investigate the DNA methylation patterns
  in eight divergent species, including green algae, flowering plants,
  insects, and vertebrates. Their data allowed a comprehensive
  comparison of whole-genome methylation profiles across the plant and
  animal kingdoms, revealing both conserved and divergent features of
  DNA methylation in eukaryotes.

So there is some conservation.
Comment: That evolutionary conservation seems very interesting, but the question is whether it is maintained somehow into the transcribed RNA


Does an electric vehicle going downhill recover energy?

Question: I have to model the behavior of an electric car. For this, I use these equations and I can observe by "playing" with parameters that, when going downhill at constant speed, the car has a negative consumption (i.e. recovers energy). I was wondering if this is realistic?
Comment: regenerative breaking is the keyword you are looking for
Comment: Important to note that regenerative braking is an feature that must be intentionally incorporated into the EV design; it is not an automatic property of any vehicle capable of electric drive. For example, bicycles with electric assist motors do not typically have regenerative braking as a feature.
Comment: As a happy Model S90D owner,  I can tell you that  regen can pull enough energy to bring the car nearly to a halt even on a downhill.
Comment: @Air If you take an electrical engine as it is, it is indeed capable of doing both: play motor and play generator. But maybe the electronics around it make it incapable of being a generator, which is why that has to be added afterwards again.
Comment: I remember reading an account of a Tesla owner who lived on the top of a small range.  He deliberately limited charging to 80% or 90% so that he could take advantage of regenerative breaking on his way to work.  It both saved energy andbreak pads.
Answer: It depends on how steep the hill is.  On a slight hill, the energy added by gravity is still not enough to overcome rolling friction and air resistance, so the car still needs power to maintain speed.  On a steeper hill, the two may balance out, so no power is used, and no power is generated.  On a hill that's steep enough to require braking to control the speed, the car recovers energy.  It's called regenerative braking.  If the car is going too fast, applying the brakes turns the motor into a generator and charges the battery.
Comment: To add to this, most modern combustion engined vehicles will also use no fuel on grades steeper than where the energy balance goes even.  Vehicles will usually only add enough fuel to keep the engine turning at idle speed, if necessary, but when rolling downhill they can cut fuel flow completely.  In the case of a combustion engine the break-even grade is a bit steeper, however, since the vehicle must also overcome the un-fueled braking effect due to engine compression.
Comment: @SGR Yes, it's called Deceleration Fuel Cutoff (DFCO).  I think even passenger diesel vehicles do this.  The diesel doesn't lubricate the engine - it lubricates the fuel system.
Comment: @SGR confirmed. Fuel injected engines shut off completely unless throttle or Idle Air Control asks for power.  IAC is a minimum speed governor whose job is keep the engine from stalling against varying loads, i.e. Power steering or A/C.  Also, diesel fuel does not lubricate the fuel system.  It used to, but then they removed the sulfur.   Biodiesel does a great job, even 2.5% biodiesel will replace the lost lubricity.
Comment: @J... Is this completely true? I know diesel engines at least use the diesel for lubrication purposes.
Comment: Not counting the newer cars that actually shut the engine off during drives... Fuel injected Manual transmissions cars have been doing fuel cutoff during in-gear deceleration for a while (engine load with no throttle).
Comment: @J...: is it ever more efficient to shift into neutral when coasting down a long shallow hill on the highway?  (gasoline engine, auto transmission, 4WD.  Engine drag is too much to maintain speed when in gear at maybe ~2.5k RPM, but coasting with engine at lower idle RPM picks up speed.  IDK if idle fuel consumption would have been enough to maintain speed if left in gear.)  I suppose I should post this as a question here or on automotive.SE...
Comment: @PeterCordes -- you don't want to lose the engine braking effects actually as that can overload the service brake and leave you in a crumpled heap at the bottom of the hill...
Comment: @tim modern engines have precise fuel control and can cut off fuel entirely. you can burn equally as much fuel in a high gear as in a lower gear at the same vehicle speed.
Comment: @PeterCordes Probably not enough to worry about, I would guess, notwithstanding that (or maybe directly because) driving in neutral is a bit crazy.  I don't think a human being could reliably or consistently win this game even if there was a narrow window of efficiency to gain here... a computer, maybe.
Comment: @ThreePhaseEel: When I want to slow down, I just put it back in "drive".  If the hill was steep enough that I'd go too fast in neutral, I probably wouldn't shift out of drive in the first place.  Although I probably won't bother doing this at all, now that I know the engine isn't getting any fuel at all if I stay off the pedal.  I thought it was adding that much drag even with the same fuel flow as neutral idle.
Comment: Going down a certain hill - in gear, coasting, the tacho might read 3000. Out of gear, it reads tickover - 1000. Surely the engine is using more fuel going three times faster in gear?
Answer: Yes, it can certainly happen.  To recharge the battery when going down hill, the free roll speed needs to be greater than the speed you are trying to go.  That means going down the same hill may result in a different outcome depending on speed.
For example, let's say you put the car in neutral and coast down a particular hill.  For most of the hill, the car settles at 45 MPH.  If you were to drive down the hill at 35 MPH, then the system should be charging the battery a bit.  However, if you drive down at 55 MPH, then additional power is needed than just the gravity assist of the hill, power is taken from the battery to run the motor or motors.
I have a Honda Civic Hybrid, and charging the battery when going down a hill is not unusual at all.
Comment: @Harper Aero drag is polynomial, not exponential, and any increasing function of speed would give rise to a terminal velocity. Terminal velocity arises simply whenever the speed is high enough that the drag forces cancel out whatever force is driving the vehicle forwards.
Comment: Don't forget that at proportionately higher speeds, you are gaining kinetic energy faster. That being a linear factor, what saves you is that aero drag tends to be polynomial... giving you a terminal velocity... **but that is at the whimsy of the wind**. 20kt headwind turns to a 20kt tailwind, aero drag drops precipitously and you could find yourself with a problem.
Comment: Thanks, my point is, aero drag is not a reliable contributor to braking, nor are reliably straight enough for terminal velocity, so there better be a plan B that doesn't rely on a battery being mid-charge.
Answer: ABB train regenerative braking.
Some Swiss trains give back energy to the grid upon descending the mountain pass that they previously climbed. The article claims as much of 70% is recovered.
I rode the Jungfraujoch and the personnel mentioned for every 3 trips down the mountain enough electricity was recovered for a "free" trip up.
Answer: The basic equations governing an electric car are reversible, so a simple analysis would say that the battery is getting charged. In the real world, there are more complications. In the case of an electric bike, there is a ratchet that disengages the engine from the wheel when the wheel is going faster from the engine (just like how on a regular bike -- where "regular" doesn't include track bikes -- if you stop pedaling, the wheel keeps moving even though the chain isn't). In an electric car, the motor can be disengaged from wheels either mechanically or electrically. Electric motors generally can't handle as much power when being driven backwards as when going forward, so electric cars are built to limit how much power can be transferred from the wheels to the battery. Absent those modifications, any time the wheels are going faster than the motor, there's going to be electricity flowing "backwards". Whether that energy will be charging the battery or frying the motor is a different matter.
And if you include heat, all cars "recover" energy in some sense when going downhill, either through increased kinetic energy, or heating of brake pads.
Answer: Absolutely.  That "recovering energy" will kill you.
Take the freight trains of yore.  In the day, helper districts involved extra steam engines waiting at the bottom of a mountain to help trains up.  Today, it's more important to help trains down the hill with their regenerative (dynamic) brakes.  Some railroads require additional units be added for dynamic braking, even for a train that could climb the hill! Best practice is to plan to use mainly or only dynamic brake, which saves money too.
The steam trains would awkwardly drag brakes all the way down the mountain, filling the valley with gray smoke.
Automotive brakes (gas or electric) don't have enough gray smoke, so they need engine braking... except electric cars can't.
That's been a huge problem, especially for the early/homebrew DC conversions.  Like the freight trains, they could go up hills they couldn't go down.
Even a regenerating car has an issue, if the owner tops up the battery at Summit.
That is to say, when an electric car loses the ability to regen because its batteries are full, its only fallback is friction brakes - and as discussed, those can't sustain a downgrade either.  They're playing with locomotive-style "make heat" dynamic braking, but I don't know how far along it is.  They need it.

By "don't have enough gray smoke" I mean automotive brakes are not designed nor rated to descend a continuous mountain grade.
Comment: Your claims about electric cars are also incorrect. While electric cars *have* regenerative braking, they use them in tandem with traditional frictional brakes. (Not only for the reasons you mentioned, but also because regenerative braking wouldn't provide enough braking power for an emergency stop.)
Comment: @DavidRicherby your experience is not mine, but I've made some edits to try to accommodate your experience.
Comment: @duskwuff you may be missing a big part of the context, *of course* electrics have friction brakes (they're just unhelpful) -- but I see where I did breeze through the relevant points pretty fast. I've thickened it up.  I've also asked the [technical question about electrics here](https://mechanics.stackexchange.com/questions/47984/can-electric-cars-do-dynamic-heat-waste-braking), I'm fairly sure I know the answer but we'll see.
Comment: @Harper Fair enough -- thanks. I've deleted my comments, since they're no longer very relevant.


Probability on three coins

Question: Design a game where three coins are tossed and the player "wins" if he or she tosses either all three heads or all three tails. The question is if the "wager" is $1, then what is a fair winning payout for the player such that he or she would break about even playing this game over time?
Answer: HINT: Only two of the possible outcomes, TTT and HHH, are wins. The other $n$ are losses, where I leave it to you to determine just what $n$ is. The $n+2$ outcomes are equally likely. If the winning payout is $p$, therefore, on average the player pays $n+2$ dollars and wins $2p$ dollars per $n+2$ games and has net winnings of $2p-(n+2)$ dollars. In a fair game the net winnings are $0$.
Answer: The probability of $3$ heads in a row is $\left(\frac{1}{2}\right)^3$, as is the probability of $3$ tails in a row. So the probability of winning is $\frac{1}{4}$.
It is not precisely clear what "payout" means. We assume that you get your dollar back plus an amount $a$ that we will call the payout,
Then the random variable $X$, which is the amount you win, is $-1$ with probability $\frac{3}{4}$ and $a$ with probability $\frac{1}{4}$.
It follows that $E(X)=(-1)\left(\frac{3}{4}\right)+(a)\left(\frac{1}{4}\right)$. For a fair game, we need $E(X)=0$. Solve the equation $(-1)\left(\frac{3}{4}\right)+(a)\left(\frac{1}{4}\right) =0$ for $a$. We get $a=3$.

Probability on three coins


Using python to download a file after clicking the submit button

Question: I need to login to a website. Navigate to a report page. After entering the required information and clicking on the "Go" button(This is a multipart/form-data that I am submitting), there's a pop up window asking me to save the file. I want to do it automatically by python.
I search the internet for a couple of days, but can't find a way in python. By using urllib2, I can process up to submitting multipart form, but how can I get the name and location of the file and download it?
Please Note: There is no Href associated with the "Go" button. After submitting the form, a file-save dialog popup asking me where to save the file.
thanks in advance
Answer: There are python bindings to Selenium, that are helping in scripting simulated browser behavior allowing to do really complex stuff with it - take a look at it, should be enough for what you need.


Buying vs catching a horse in Red Dead Redemption

Question: So far I caught my current horse early on in the game and now I can buy them at the merchant. Are there any advantages of buying a horse?
Answer: The advantage on buying a horse is that you will be able to call that -kind- of horse back even when it dies. Thus, if you buy a nice horse such the Kentucky Saddler, American Standardbred or Hungarian Half-bred you won't need to break them again to use them.
By the way, once you buy a horse it won't automatically come to you .. you must open your inventory and use the item you bought representing the horse... then, the horse you were using will go away and the 'item' horse will come to you. This item representing the horse has unlimited uses.
Comment: Using a horse deed is a nice way to quick save too.
Comment: It's like calling the Batmobile!
Comment: ah, so i can own multiple horses. excellent.
Answer: When you purchase the deed to a horse, and "Use" the deed you will have that horse when you whistle for it (and the deed never goes away and you can use it as many times as you like). So purchasing the deeds to horses are the only way to switch to new horses without losing your old ones.
I would suggest you purchase the deeds to the Kentucky Saddler, Hungarian Half-Bred and American Standardbred (but make sure you get them at stores where you have the discounted rate - $750 each)
Answer: Some horses are better than others, for instance the bright white Hungarian Half-Bred and solid black American Standardbred. These horses are among the best in the game, but can't be purchased unless you've broken at lest one of the same type in the wild.
After that, a horse is a horse. For a given breed, the only difference is in the wild they're free, but if you purchase a deed it looks like you can re-use one over and over to respawn a horse of the same type if your current one dies.
Comment: so they are all availabe in the free as well? what about horse-jobs, do they unlock horses at the merchant?
Comment: I'm not sure, sorry. That's a good question.
Answer: its better to buy a horse because if you look up cheats you can get 500 dollars and keep on turning it on and you will have enough to buy the best horses hope this helped good luck
Answer: Buying a horse is expensive, not to mention wild horses are free.But the most beautiful horse in the game is the Kentucky Saddler. I would recommend you buying the horse because you also have cheats of 500 dollars in the game.
Answer: Personally, I would catch a horse because buying them is really expensive, also when you catch a horse it gives you a trusty steed bonus ( I don't really know what that means)
Comment: The trusty steed is not a bonus.  It's just the horse you currently own.  As the [Wiki states](http://reddead.wikia.com/wiki/Horse): The player's "trusty steed," established as Marston's own horse either by hitching it or by using a horse deed


Neural network for PDE: Should we train the PDE using more initial and boundary data at the beginning?

Question: I was trying to solve a partial differential equation (PDE) using a neural network. The solution to the PDE is not unique unless the boundary condition is determined.
In my case, the neural network takes $(x, y)\in [0, 10]\times[0, 10] = A$ and outputs a scalar. Suppose at the beginning of the training, I only sample from the middle of $A$, which will give us a neural network that satisfies the PDE except for the boundary condition. Then we sample from the boundary of $A$.
My question is, will it be costly to train using the algorithm above? My guess is yes since we have to drag that solution to somewhere else based on the boundary condition, causing large change to the output value. And intuitively, it's better to construct the solution on the boundary first to make the foundation of the solution correct.
I know that we can test it by experiments, but I'm more interested in a theoretical explanation, e.g., why / why not will it be costly to update parameters of the neural network after the boundary data get considered?
Answer: There is sadly very little theory that is useful for predicting the behavior of neural networks.  Also, their effectiveness tends to be dependent on the particular workload/task you are trying to solve it.  While I know it's not what you were hoping to hear, I suggest that you try it in empirical experiments.


What do I need to do if I can't replace a broken guitar string

Question: So I broke the high e string on my guitar and it could be a long time before I replace it. I am afraid if leaving it like that for a long time will deform the neck. So should I tune down the rest of the strings to even out the pull or its ok to leave it as it is?
Thanks.
Comment: I'm just reaffirming what Tetsujin and Tim's answers say: The guitar will not be damaged by leaving it with a missing string, even for a long time.  You are safe to leave it, or even start to learn the 5 string guitar...
Comment: What could cause the lack of string?  DO you not have access to a music store?  Amazon?
Answer: For starters, there's no clue as to what sort of guitar it is. For seconds, it won't make much difference either way. For thirds, make sure you have enough spare strings next time for all eventualities.
Answer: Theoretically, you should tune the rest of the guitar high not low until you replace it, but even if you managed to judge the exact tension difference & not make a mess of it all, then

it would be so minor as to make no practicable difference overall &
any practicable difference it did make would also be contributing to twisting the neck very, very slightly out of true.

Fix is to just buy a new set of strings, or even spend a whole quid/buck/shekel on the one missing string... as it's probably pretty much unplayable with only 5 on anyway.
Comment: *`it's probably pretty much unplayable with only 5 on anyway`*; I wouldn't say this is exactly true. There are plenty songs that can be played with only 5 strings (there are in-fact, songs played on a single string). Just depends on what you're wanting to play. Definitely makes sweeping more difficult as you'll have to move your high e notes to your B string.
Comment: @davisj1691 - I'm taking the apparent skill-level of the OP into consideration here.
Comment: `Smoke on the Water` and `Smells Like Teen Spirit` can be played on the first four strings, and both are great beginner songs. Even if the OP was an intermediate player, `Sweet Home Alabama` can be played on 5 strings if you work at it (makes the solos difficult either way).
Comment: @davisj1691 - I'm sure you can - but I think you're making a meal of it. Just buy a new string. It'll cost a whole $£€ 1
Comment: I just wanted to point that out, with respect to the OPs playing level. It's best not to tell beginners that they can't really play if they don't have all their strings. I agree completely, just buy new strings.


How do Zombies differentiate between a zombie and a human being?

Question: Zombies are always after human beings. How do Zombies differentiate between a zombie and a human being? Why don't zombies eat each other?
Comment: Taste. Most assuredly. Zombies tasted dead. People are fresher...
Comment: Well, we can tell them apart. I would imagine the difference is about as obvious to zombies as it is to us. You could say that they shouldn't be able to tell us apart because their brains are so damaged, but then they shouldn't be alive either.
Answer: It appears to be related to their sense of smell.
In "Guts" (season 1, episode 2), Rick and the group cover themselves in the guts of walkers in order to disguise their scent, and it seems to work. They only get attacked when rain washes away their disguise.
It's reasonable to assume walkers won't attack any moving creatures that smell like them.
Answer: Without trying to sound like a smartass, zombies differentiate between humans and other zombies more or less the same way you do.  It is a combination of factors, rather than a single difference.
Appearance
Zombies look... well...  like zombies.  People look like people.  This one is pretty self explanatory.
Scent
Although I have frequently pondered the question of how bad the people in The Walking Dead must smell, having had few opportunities to bathe properly since the world fell apart, it still seems clear that the people smell different from the zombies.  Sweaty, unbathed Rick probably stinks like rancid body odor, but the zombies smell like the rotting corpses that they are.
In fact, the zombies stink so bad that in season 5, we saw Glenn, Maggie, Abe, Rosita, Eugene, and Tara almost reeling from the stench of a herd of zombies far off in the distance.  And in season 1, episode 2, Andrea explicitly said that zombies can smell people.  That's why Rick and Glenn covered themselves with zombie guts before walking into the herd outside the department store.
Sound
Humans make fairly unique noises, none of which can be made by zombies.  We talk, we laugh, we cry, we scream, we cough, we bang around and build stuff, etc.  Zombies are attracted to all kinds of sounds, but they are particularly attracted to the kinds of sounds that humans make, or that are associated with humans (including things like car engines).
Motion
People move in different ways than zombies.  Whereas they stagger around in a lurching, uncoordinated manner, we usually move with purpose, heading in a specific direction, and in a relatively coordinated manner.  We have a good sense of balance, we move relatively quickly compared to zombies, and we show far more deliberation in our movements - we are trying to get somewhere, not just wandering around with no particular destination in mind.
We also make other kinds of movements:  we fiddle with things in our pockets, we stop to get a drink, we carry guns and supplies on our backs, we open and close doors and windows, and so on. All of these movements and motions are quite different from those of the zombies.
Behavior
Zombies don't act the way we do.  If there is no prey in the area, they just hang around waiting for some to show up.  Sometimes they stand still or even sit down;  sometimes they stagger around, more or less in circles.  When they do the latter (staggering around in circles), they do so in a uniquely zombie-like way:  they make no attempt to avoid walking into each other.  They don't even try to avoid walking into stationary objects.  They bump into things, and into each other, and don't even seem to notice it.
Humans, on the other hand, don't do any of these things.  We generally don't stand around doing nothing, or lurch unsteadily in circles, or walk directly into other objects.  We are hardwired to avoid walking into things.  We don't like bumping into stuff, so we usually don't do it.
Zombies don't respond to anything except potential prey, such as people or animals.  In fact, it seems that they actually don't even notice anything other than potential prey.  If they don't hear or see any signs of nearby food sources, they don't look around much.  They just stand there and wait, or stagger around and wait.  They take no interest in each other or anything else that isn't food.
Humans are nothing like this.  We are constantly looking at everything around us, and in the world of TWD, we have good reason to look around - we need to find food, shelter, water, supplies, etc.  We pay attention to our surroundings and everything in them.  When we encounter an obstacle, we stop and think about how to get around it, whereas a zombie would simply walk directly into the obstacle.
Following the Herd
Sometimes, zombies attack people they can't actually see, hear, or smell, simply because other zombies are already trying to get at the people.  If a herd of zombies is piling up outside a house or whatever, presumably because they know that there are people inside, it sometimes happens that other zombies, who just happen t be walking by, will join the herd, despite the fact that they themselves have not heard, seen, or smelled the people inside.  They just seem to know that if other zombies are interested in something, it is probably food of some sort.
For more information about the herd dynamic, see my answer to this question.
Special Cases
The most obvious example of a special case, in which a person avoids attracting the attention of zombies, is Michonne.  This woman is a genius.  She realized that if she was accompanied by zombies everywhere she went, other zombies would assume she, too, was a zombie.
But things are never quite that simple.  She had to figure out how to prevent her "pets" from giving her away by constantly reaching out to grab her, which would obviously attract the attention of the other zombies in the area.  Her solution was brilliant in its simplicity:  she hacked off their arms.  To prevent the pets from trying to bite her, she also removed their lower jaws.
It appears that Michonne's pets break one of the central rules of zombie-hood:  they learned that they would never be able to bite her, so they stopped trying to do so.  According to the rules of Brooks zombies, Romero zombies, and every other TWD zombie, zombies can't learn anything, ever.  But somehow, the pets figured out that they couldn't get Michonne, so they stopped trying.
Michonne walks slowly, her pets follow closely behind her, and all the other zombies in the area just assume she is a zombie herself.  She is exploiting several of the factors that zombies use to distinguish between other zombies and living people:  her motions are zombie-like, the scent of the pets covers up her human scent, and the pets' inability to reach out for her avoids the possibility of the other zombies being alerted to her presence.
Answer: Seems to be a few factors:
Smell

S01E2; walker gore worked until the rain set it (at which point they
started smelling humans)

Reaction (human/herd based)

Like any other predator, they will chase what flees from them. While
the pet walkers would have smelt somewhat, other walkers noting no
reaction from them would have been important, probably even more so
given their herd mentality. A different reaction sparks mimicing, or suspicion, depending on what it is.

Sound

Walkers have come to assicoate sound with the presence of prey and
will follow it for a considerable distance (Hershel's Farm and the helicopter).
Answer: If we are talking about dead zombies, perhaps they can sense life force.
You would assume they can tell if something is still alive, which is why they never attack other zombies.
It would also explain how human bases always get discovered and surrounded.
After death a body should lose all senses, therfore zombies would be unable to use them.
This way a zombie's hunger is more understandable.
They are dead so they crave life because of that they hunt the living.
Comment: It sounds like you're speculating here. When answering questions like this, please try and base your answers on evidence from the source material rather than pure theory.
Answer: It's because they feel the blood running through people's veins, somewhat like vampires.
Comment: In-universe example of this being the case?


Why didn't the UK visa officer ask for financial documents?

Question: Recently, my parents had an interview in Pune for a UK tourist visa. They had originals of all of their bank statements and their passport with them, but the official did not ask them to submit them. Even though they asked, the officer said they were not needed. We were told that the official will ask for the originals of the passport and the financial documents, so we had not attached any photocopies to the application form, as well. Will this be a problem, and what should be done now?
Comment: That is unusual. Financial documents are typically required.
Comment: [Standard Visitor visa](https://www.gov.uk/standard-visitor-visa/documents-you-must-provide)

`Documents you must provide

When you apply you'll need to provide:

a current passport or other valid travel identification

evidence that you can support yourself during your trip, such as bank statements or payslips from the last 6 months`. From the rules it appears financial documents are **mandatory**. You will have to take it up with them.
Comment: Is the issue, and confusion, that financial documents were not included with the application itself, thinking that taking the originals to the interview was all that was needed?
Comment: are they known, wealthy individuals?
Could be that he has just taken it as fact that they obviously have enough money.
Answer: If you read Gayot Fow's response to UK Standard Visitor visa refusal. Should I reapply? you notice that sometimes VFS officers are taking on authority they do not have and removing documents and declaring some unnecessary contrary to their training and instructions.

Last February there was an advisory stating that VFS personnel in
  south Asia, (viz Pakistan and India) were removing evidence.

Per Visitor: supporting documents guide

Section 1: documents you must provide – all visitors
Valid travel document (national passport or other document that allows
  the holder to travel internationally)
Section 2: other documents you may want to provide – all visitors
This section provides guidance on the types of documents that you
  may want to provide to help us consider your application against the Immigration Rules. Previous travel documents/passports, which show
  previous travel. Financial documents showing that you have sufficient
  funds available. These must clearly show that you have access to the
  funds, such as: bank statements

I know of quite a few people [during the period when UK visas were by interview] who went for interviews and were granted without the ECO asking for anything in the form of supporting documents. From the rules it appears financial documents are not absolutely mandatory, nevertheless they are very typical. For now I will suggest take it up with them if your parents visa application is refused.
Answer: my Parents got UK visa successfully. VFS office process is somewhat changed. Office is moved to paperless mode from paperwork. So they do not keep your financial documents, instead they get it scanned. Only Passport is kept at VFS for stamping purposes. Confusion is clear at least from my side. :-)


Should "Designated Drivers" be compensated by their friends?

Question: In Britain in recent years there have been schemes in place to provide free or discounted soft drinks to designated drivers during holiday times.  But what about the rest of the year? When a group of friends, all of whom are drinkers, were out together, has experience shown that it is insulting to designated driver's good intentions for members of a group of friends to buy the soft drinks?
Comment: @Vylix: We will have to decide for ourselves what we want on this site, but on other SE sites, "experience" represents historical or actual occurrences, as opposed to guesses about what one should do or what should happen. By asking for "experience," one is saying "Please answer the question only if you have done this or seen it done (or read about it somewhere) rather than just adding your two cents."
Comment: @TomAu i think adding experience makes this even more opinion based?
Comment: I voted to close this because it is completely opinion based. This question could be edited to ask the question "How is it perceived when you tip your DD" or, "would my DD take offense/appreciate being compensated"
Comment: Related: https://interpersonal.stackexchange.com/questions/256/offering-payment-for-a-favour. This one is for the DD if they want to decline the offer: https://interpersonal.stackexchange.com/questions/301/how-to-politely-refuse-money-from-someone-who-is-insistent
Comment: @HDE226868 I feel like this is a good question, and deserves an answer. However, one of the reasons for closing a question is that they are opinion based, and I feel this is opinion based.
Comment: I have made an edit @JoeS, does it read any less opinion based?
Comment: @rm Looks good to me!
Comment: I made the question more objective by asking for "experience" and urge that it NOT be closed.
Comment: This in part brings us back to where we were in the Discussion phase.  https://area51.meta.stackexchange.com/questions/26732/how-do-we-guarantee-the-factual-element-for-interpersonal-skills-site
Comment: Don't forget that besides material compensation, the compensation of one of your friends being DD the next time around also exists. If it was usually the same person being DD though, I'd feel inclined to show my gratitude in some way.
Comment: @rm: For a question like this, "experience" counts as "expert opinion" which is recognized as "fact" on SE sites. A U.S. Supreme Court judge put it best: "I know pornography when I see it." His reasoning? "Pornography is something that would be offensive to a man of average sensuality (un homme moyens sensual). I am such a man. Therefore...(punch line)."
Answer: Think of the situation as if you were the designated driver, if you are out with your friends would you demand to be compensated? Probably not.
On the other hand, if you were driving your friends around all night, would you decline being compensated? Probably not.
It is always a nice gesture to buy your friends a drink (Alcoholic or Otherwise), or give them gas money, but I would have a hard time having a steadfast rule as to whether or not tips/compensation should be demanded among a group of friends.
Comment: I agree with this, however I do joke about it when my friend (non-driver) always asks for lifts and doesn't offer anything in exchange when someone picks him up. Note: Don't do it when you are the DD, that sounds pretentious. I'll occasionally go "Yo, you own the DD a drink!" when he asks why, I say because he drove him home. The friend eventually learned that it's not cheap to drive 15minutes to pick him up and to drop him off. He now offers a drink to his DD. When we go out, the DD usually doesn't spend any money on drinks. But people who don't drive usually don't think about gas money.
Answer: Can only speak from personal experience; but I've usually found that the DD will get a soft drink bought for them in any "round" without having to buy a round later themselves.
Answer:
Should "Designated Drivers" be compensated by their friends?

They already are: they bring them home safely. They can share another event all of them together later. What could be more valuable?

As I drink only water and soft drinks, I'm a long-time Designated Driver, and the best reward I actually had from my friends was them folks Staying Alive. I don't need more, I don't want more :)
That should be the only goal of any DD: get your buddies safe back home. If they buy you a drink (or not) doesn't matter, really. You do that (drive) for friendship's sake.
They don't even pay for the gas (I can afford this, and don't care anyway), but once in a while, they invite you and pay the bill, or we all gather at their home for dinner or to watch a game. It's not even a compensation, as there's no need for such things amongst friends.
But they show how they appreciate you being around and taking care of them.
When you protect your friends, you don't need gas or drink, just wings, because you're an angel :)
See it that way, as they normally do, that'll be fine, that's what friends are for...
Answer: Eternal designated driver speaking here.
My reward is to get on the wheel
That's a pleasure to be the one who will get to drive the car. Even more interesting is to get to drive each of my friends car, some more interesting than others. Besides, I don't particularly like the taste of alcohol, but I would rather drive than getting to drink whatever else I wanted, unless if it was for free of course (but this never happened).
It is difficult to assert this situation without knowing the person. Some people think it is a sacrifice to drive and say they like to drink a lot. Many people also lie about that and just want the compensation for the "favor". One day my uncle was bragging about being the one who was chauffeuring everyone during a long trip on a nice rental car so I offered to drive all the time until he snapped at me, since he was actually eager to drive that car.


Why do players always use smite as the killing blow?

Question: This has been bugging me for a while. I've seen streams of high ELO junglers, and it seems like they always use smite as the killing blow on the jungle creeps. Why do they do that? I mean, damage is damage, and using it early could save you a few second on cooldown. Why don't they start fighting the jungle minion by smiting them?
Comment: I agree with most of comments above, but would also want to mention that there once was a mastery point, which granted you gold if smite dealt the killing blow. Which meant that if the jungler was confident, he didn't need it to secure buffs or dragon, he'd gain extra gold by dealing the killing blow with smite. However, as the game is now it is as the others said.
Comment: The mastery was just using smite period.  You didn't need to get the killing blow on it.
Answer: SaintVicious, jungler for the CLG.NA team, once said it on stream.  If you are certain that you are not going to be counterjungled, then sure, smite right away.  However, circumstances can quickly change while you are attacking the creep (assuming smite is used on objectives like buffs).
Situation #1: You are jungling but leave base a little late.  Like usual you head to Red and you feel confident so tell your team you don't need their help leashing it.  So you smite right away and begin autoattacking it.  In the animation of your last auto-attack, the enemy jungler smites it away from you over the wall, then turns and kills you with the help of the small lizards and the red buff they now have cuz your smite was down.
Situation #2: You have been jungling and cleared the jungle already.  As typical, you get ready to feed your AP Carry the blue buff.  While, waiting for the AP Carry to deal the finishing blow, the whole enemy team comes charging from river to the Blue led by their jungler.  Fortunately this time, you saved your smite, so before the enemy jungler can smite steal it, you secure blue for your team.  While not optimal, certainly better than the enemy team having both blue buffs.
Finally, it is good practice as it helps you use smite to secure important objectives like dragon and baron.  After all practice makes perfect, and if you say that you always use smite first except for dragon and baron, you won't be as practiced.  A few seconds lost on the smite cooldown is hardly noticeable most of the time, but gaining a little more practice on using your smite to secure kills never hurts anyone.
Answer: I imagine it is mostly done to prevent the enemy from showing up and finishing off the target.
If you wait until a smite will kill it, you have much less chance of the enemy AP mid coming over and sniping it with a skill shot or the enemy jungler showing up to steal it with their smite.
Comment: As an aside, stealing an enemy buff after they've done all the hard work has to be one of the most satisfying things in League of Legends.
Comment: Aside from stealing the buff, smite also nets 10g on kill if the mastery point is put in the smite mastery tree.
Comment: @Jay nope, it's on use now, not only the kill.
Comment: The 10 gold is ok, but hardly a great reason to spam smite in my opinion. It really sucks to not lose Dragon because you used smite on the big wolf for the gold.
Answer: I also smite for the kill. I do this because other people may be roaming to steal the buff. This would ruin the jungle route and would result in a slower jungle clear time causing less ganks causing possible lane loss and so forth. It would also be beneficial for against a stealthed jungler such as Shaco, Eve, and Twitch since they could be there and smite for the kill. Smiting early may also result in the loss of major objectives like baron and dragon. If one is smited early others can come and smite to steal that bonus gold or baron buff. Although smiting early would in fact reduce the cooldown its better to be safe than sorry.