public static void computePaths(Vertex source) {     source.minDistance = 0.;     PriorityQueue&lt;Vertex&gt; vertexQueue = new PriorityQueue&lt;Vertex&gt;();     vertexQueue.add(source);      while (!vertexQueue.isEmpty())     {         Vertex u = vertexQueue.poll();          ///////////////////////////////         // This is where the error is happening         ///////////////////////////////         for (Edge e : u.adjacencies)         {             Vertex v = e.target;              double weight = e.weight;             double distanceThroughU = u.minDistance + weight;              if (distanceThroughU &lt; v.minDistance)             {                 vertexQueue.remove(v);                 v.minDistance = distanceThroughU;                  v.previous = u;                  vertexQueue.add(v);             }         }     } }   I'm getting the Runtime Error  Exception in thread "main" java.lang.NullPointerException at Dijkstra.computePaths(Solution.java:69) at Solution.main(Solution.java:141)   The program works fine with hard-coded vertices and paths, however the problem is going to be tested through file input, so I'm assuming it has to do with when I am taking in those values, but I can't find anything that would cause that error.  below is from where I take in the values  for (int i = 0; i &lt; plans; i++)     {         vs[i] = new Vertex(scan.next());         destinations[i] = new Vertex(scan.next());         weights[i] = scan.nextInt();         scan.nextLine();     }      for (int i = 0; i &lt; plans; i++)     {         vs[i].adjacencies = new Edge[]         { new Edge(destinations[i], weights[i]) };      }      Vertex[] vertices = new Vertex[plans];      for (int i = 0; i &lt; plans; i++)     {         vertices[i] = vs[i];     }      // starting vertice     String start = scan.next();     // ending vertice     String end = scan.next();      Dijkstra.computePaths(vs[0]);
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
Book: World covered in trees that are miles high What is the difference between correlation, causation and prediction? Suppose we have a set of events $\Omega$, containing events $A$ and $B$. My econometrics professor tried to distinguish the following three terms today.    Causation --- $A$ causes $B$ if the occurrence of $A$ always leads to another specific outcome $B$. For example, clapping my hands causes a sound to be emitted.  Prediction --- $A$ predicts $B$ if on average, $B$ is the expected outcome from $A$ occurring. In other words, whereas causality is deterministic, prediction is probabilistic. For example, studying for a test would predict doing well on the exam. But there's no guarantee.   Correlation --- $A$ and $B$ are correlated if when one occurs the other does too. But there may be some hidden variable causing both.    Are these distinctions meaningful? Or did he make these terms up?   My Questions   What is the difference between causation and correlation?  Are "causes" always deterministic? Stance on repost question instead of editing to invalidate answers? Can I award user with special bounty after accepting his anwer? I have a , and I haven't start a bounty for this question. After I got my answer I'd like to give a user a special bounty, because I consider his answer very helpful and it saved me a lot of time. I've already accepted the answer. Is there a way how can I give him some bounty?  Thank you I have a very large dataset and about 5% random values are missing. These variables are correlated with each other. The following example R dataset is just a toy example with dummy correlated data.  set.seed(123)  # matrix of X variable  xmat &lt;- matrix(sample(-1:1, 2000000, replace = TRUE), ncol = 10000) colnames(xmat) &lt;- paste ("M", 1:10000, sep ="") rownames(xmat) &lt;- paste("sample", 1:200, sep = "") #M variables are correlated   N &lt;- 2000000*0.05 # 5% random missing values  inds &lt;- round ( runif(N, 1, length(xmat)) ) xmat[inds] &lt;- NA  &gt; xmat[1:10,1:10]          M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 sample1  -1 -1  1 NA  0 -1  1 -1  0  -1 sample2   1  1 -1  1  0  0  1 -1 -1   1 sample3   0  0  1 -1 -1 -1  0 -1 -1  -1 sample4   1  0  0 -1 -1  1  1  0  1   1 sample5  NA  0  0 -1 -1  1  0 NA  1  NA sample6  -1  1  0  1  1  0  1  1 -1  -1 sample7  NA  0  1 -1  0  1 -1  0  1  NA sample8   1 -1 -1  1  0 -1 -1  1 -1   0 sample9   0 -1  0 -1  1 -1  1 NA  0   1 sample10  0 -1  1  0  1  0  0  1 NA   0   Is there a (best) way to impute missing values in this situation? Is the Random Forest algorithm helpful? Any working solution in R would be much appreciated.  Edits:  (1) Missing values are randomly distributed among the variables and samples.As number of variables is very large (here in the example - 10000), while the number of samples is small here in the above dummy example it is about 200. So when we look at any sample over all the variables (10000), there is high chances that there will be missing value at some variable - due to large number of variables. So just deleting the sample is not option.   (2) The variable can be treated both as quantitative or qualitative (binary) in the process of imputing. The only judgement is how well we can predict it (accuracy). So predictions like 0.98 instead of 1 might be acceptable rather 0 vs 1 or -1 vs 1. I might need to tradeoff between computing time and accuracy.   (3)  The issue I have thinking how overfitting can affect the results as the number of variables are large compared to number of samples.   (4) As the total quantity of missing values is about 5% and is random (not concentrated in any variables or samples as precaution was taken to remove the variables or samples that have very high missing values)   (5) Making data complete for analysis is first objective and accuracy is secondary. So not too sensitive to accuracy. What is the default /etc/inittab file on a fresh install of Debian Jessie? I'm looking for the full contents of the default /etc/inittab file on a fresh install of Debian 8.7 before any system-specific modifications are made.    I searched for this on the Debian website and other forums, but could not find it. How do I add a DNS server via resolv.conf? Is /etc/resolv.conf useless in  (Precise Pangolin)?  I see that the DNS server information is stored in  now. The nmcli command line tool can list that for you.  If I want to add one more  server, will adding it to /etc/resolv.conf by using the resolvconf package help? Hibernate JPA Sequence (non-Id) Is it possible to use a DB sequence for some column that is not the identifier/is not part of a composite identifier?   I'm using hibernate as jpa provider, and I have a table that has some columns that are generated values (using a sequence), although they are not part of the identifier.  What I want is to use a sequence to create a new value for an entity, where the column for the sequence is NOT (part of) the primary key:  @Entity @Table(name = "MyTable") public class MyEntity {      //...     @Id //... etc     public Long getId() {         return id;     }     //note NO @Id here! but this doesn't work...     @GeneratedValue(strategy = GenerationType.AUTO, generator = "myGen")     @SequenceGenerator(name = "myGen", sequenceName = "MY_SEQUENCE")     @Column(name = "SEQ_VAL", unique = false, nullable = false, insertable = true, updatable = true)     public Long getMySequencedValue(){       return myVal;     }  }   Then when I do this:  em.persist(new MyEntity());   the id will be generated, but the mySequenceVal property will be also generated by my JPA provider.  Just to make things clear: I want Hibernate to generate the value for the mySequencedValue property. I know Hibernate can handle database-generated values, but I don't want to use a trigger or any other thing other than Hibernate itself to generate the value for my property. If Hibernate can generate values for primary keys, why can't it generate for a simple property? Is there a direct proof that $\pi$ is not constructible, that is, that squaring the circle cannot be done by rule and compass?  Of course, $\pi$ is not constructible because it is transcendental and so is not a root of any polynomial with rational coefficients. But is there a simple direct proof that $\pi$ is not a root of polynomial of degree $2^n$ with rational coefficients?  The kind of proof I seek is one by induction on the height of a tower of quadratic extensions, one that ultimately relies on a proof that $\pi$ is not rational. Does any one know of a proof along these lines or any other direct proof?  I just want a direct proof that $\pi$ is not constructible without appealing to transcendence. Why is mathematical induction a valid proof technique? Context: I'm studying for my discrete mathematics exam and I keep running into this question that I've failed to solve. The question is as follows.    Problem: The main form for normal induction over natural numbers $n$ takes the following form:   $P(1)$ is true, and for every $n, P(n-1)\to P(n).\qquad\qquad\qquad\text{[Sometimes written as $P(n)\to P(n+1)$]}$   If both 1 and 2 are true, then $P(n)$ is true for every $n$.  The question is to prove the correctness of the form above.    My work: My idea was to make a boolean statement and if it's a tautology in a true false table. That means the statement is always correct.  I've tried many times but I've failed.  Here is the original question in Hebrew:  n טענה כלשהי לגבי מםפר טבעי  $P(n)$ תהי   אם מתקימיים שני התנאים הבאים:  1- הטענה $P(0)$ נכונה  2- לכל n>0, $P(n)$ נכונות הטענה $P(n-1)$ גוררת את נכונות הטענה   אז $P(n)$ נכונה לכל מספר טבעי n  הוכיחו את נכונות משפט זה What does my internet provider know about my online activities? What does my internet service provider know about my online activites in these cases?   plain server (www, ftp, whatever) connection and provider's DNS secured (e.g. TLS) server connection and provider's DNS plain server (www, ftp, whatever) connection and an non-provider non-logging DNS secured (e.g. TLS) server (www, ftp, whatever) connection and non-provider non-logging DNS   In case 4) does my provider know anything more about my online behaviour than "IP w.x.y.z was assigned to Foo Bar between connect-time and disconnect-time" (i.e. only the duration my router was connected)?  What traffic does need to go through the provider's infrastructure to make my connection work at all? Is there any table or any other way(metadata/rest api) we can query the list views of a particular object that a user/group  has access.  Example:  SELECT Name FROM table_x WHERE UserOrGroupId = '1234..' AND  SobjectType = 'Account'   I can see an object named UserListView in workbench, but query on that returns no data. Is it deprecated? Log form of variables and descriptive measures Because of larger values of variables, I did a log- transformation in my dataset. Now I want to give a descriptive table regarding my variables like mean, max, min, median, skewness, kurtosis. Can I give standard measures like arithmetic mean or should I give geometric mean? In terms of skewness or kurtosis, do I need a transformation? Suppose I am running a regression $Y \sim X$. Why by selecting top $k$ principle components of $X$, does the model retain its predictive power on $Y$?   I understand that from dimensionality-reduction/feature-selection point of view, if $v_1, v_2, ... v_k$ are the eigenvectors of covariance matrix of $X$ with top $k$ eigenvalues, then $Xv_1, Xv_2 ... Xv_k$ are top $k$ principal components with maximum variances. We can thereby reduce the number of features to $k$ and retain most of the predictive power, as I understand it.   But why do top $k$ components retain the predictive power on $Y$?   If we talk about a general OLS $Y \sim Z$, there is no reason to suggest that if feature $Z_i$ has maximum variance, then $Z_i$ has the most predictive power on $Y$.   Update after seeing comments: I guess I have seen tons of examples of using PCA for dimensionality reduction. I have been assuming that means the dimensions we are left with have the most predictive power. Otherwise what's the point of dimensionality reduction? By Cauchy's theorem, if a prime number $p$ divides the order of a group $G$, then there is an element $g$ in $G$ whose order is $p$. In addition, if $|G|$ admits a prime decomposition with a factor $p^k$, then Sylow's theorem tells us that a subgroup of order $p^k$ must exist.   My question is the following. If $|G|$ admits a prime decomposition with a factor $p^k$, does this imply that an element of order $p^k$ must exist in $G$?   Update: As explained in Mindlack's answer (among others), the implication does not hold and simple counterexamples exist. In the comments, Mindlack discusses special cases where such an element exists. How to calculate $$\int_{0}^{\pi/2}{\{\tan(x)\}dx}$$ where $\{x\}$ means the fractional part of $x$. I mentioned the zero points of $\{\tan(x)\}$. $\{\tan(x)\}$ equals to 0 iff $x=\arctan(k)$, $k$ is an integer. I tried to separate it into$$\sum_{k=0}^{\infty}{\int_{\arctan(k)}^{\arctan(k+1)}{(\tan(x)}-k)dx}$$ Then I found it hard to continue. I don't think I am on the right way. Suppose $\{f_n\} \subset L^+$ , $f_n \rightarrow f$ pointwise, and $\int f = \lim \int f_n &lt; \infty$. Then $\int_{E} f = \lim \int_{E} f_n$ for all $E \in \mathcal{M}$. However, this needn't be true if $\int f = \lim \int f_n = \infty$.   This is the exercise 13 on page 52, Real Analysis, by Gerald B. Folland. $L^+$ is the space of all measurable functions from $(X,\mathcal{M}, \mu)$ to $[0, \infty]$.  I can find a counterexample satisfying $\int f = \lim \int f_n = \infty$. Let $X = \Bbb N$, $\mathcal{M} = \mathcal{P}(\Bbb N)$ and $\mu$ be the counting measure. $f_n = \chi_{\{2i+1:i \leq n\} \cup \{2j:n \leq j \leq 2n \}}$. Then $\int f = \lim \int f_n = \infty$. But when $E = \{2k: k \in \Bbb N\}$,  Then $\int_{E} f =  0$ and $\lim \int_{E} f_n = \infty$.  But how to show the part "$f_n \rightarrow f$ pointwise, and $\int f = \lim \int f_n &lt; \infty$. Then $\int_{E} f = \lim \int_{E} f_n$ for all $E \in \mathcal{M}$"? How to check if click event is already bound - JQuery How to use numpad / on a keyboard without a numpad? I've just got into Blender, and I like it a lot. But as I just switched from a stationary computer to a MacBook, I've got some new problems regarding the numpad. I can use 1-9 perfectly, But I have no idea how to emulate buttons like / (used to enter local view). I've searched the web for an answer, but I can't find any. Is Dexterity overpowered compared to Strength?