Best approach for dealing with time measures? My goal is to write a framework for measuring method execution or transaction time and for processing the measurements, i.e. storing, analysis etc. Transaction may include calls to external systems, with synchronously or asynchronously waiting for the results.  There already have been some questions around that topic, like    ""  ""  ""   And all the answers boil down to three approaches for taking the time   System.currentTimeMillis() System.nanoTime() Instant.now() and Duration(since Java 8)   I know, all of these have some implications  System.currentTimeMillis()  The result of this method depends on the platform. On Linux you get 1ms resolution, of Windows you get 10ms (single core) ~15ms (multi core). So it's ok for measuring large running operations or multiple executions of short running ops.  System.nanoTime()  You get a high resolution time measure, with nano second precision (but not necessarily nano second accuracy) and you get an overflow after 292 years (I could live with that).  Instant.now() and Duration  Since Java 8 there is the new time API. An instant has a second and a nano second field, so it uses on top of the Object reference two long values (same for Duration). You also get nano second precision, depending on the underlying clock (see ""). The instantiaion is done by invoking Instant.now() which maps down to System.currentTimeMillis() for the normal System clock.  Given the facts, it becomes apparent, that best precision is only achievable with System.nanoTime(), but my question targets more towards a best-practice for dealing with the measures in general, which not only includes the measure taking but also the measure handling.   Instant and Duration provide best API support (calculating, comparing, etc) but have os-dependend precision in standard case, and more overhead for memory and creating a measure (Object construction, deeper callstack) System.nanoTime() and System.currentTimeMillis() have different levels of precision but only have basic "api" support (math operations on long), but are faster to get and smaller to keep in memory.   So what would be the best approach? Are there any implications I didn't think of? Are there any alternatives?
How do I write a correct micro-benchmark in Java? How do you write (and run) a correct micro-benchmark in Java?  I'm looking for some code samples and comments illustrating various things to think about.  Example: Should the benchmark measure time/iteration or iterations/time, and why?  Related:
Create file and its parent directory I know that touch command creates a file:  touch test1.txt   but how I can create a file and its full path?  for example my desktop contains nothing:  ~/Desktop/$ ls ~/Desktop/$   and I want to create 1.txt in ~/Desktop/a/b/c/d/e/f/g/h/1.txt. Can I do this with a simple command like:  $ touch ~/Desktop/a/b/c/d/e/f/g/h/1.txt   instead of create full path manually and then create the file? Decode HTML entities in Python string? Statistical inference when the sample "is" the population Imagine you have to do reporting on the numbers of candidates who yearly take a given test. It seems rather difficult to infer the observed % of success, for instance, on a wider population due to the specifity of the target population. So you may consider that these data represent the whole population.   Are results of tests indicating that the proportions of males and females are different really correct? Does a test comparing observed and theoretical proportions appear to be a correct one, since you consider a whole population (and not a sample)? If $(a_n)\subset[0,\infty)$ is non-increasing and $\sum a_n<\infty$, then $\lim{n a_n} = 0$ I'm studying for qualifying exams and ran into this problem.  Show that if $\{a_n\}$ is a nonincreasing sequence of positive real numbers such that $\sum_n a_n$ converges, then $\lim_{n \rightarrow \infty} n a_n = 0$.  Using the definition of the limit, this is equivalent to showing \begin{equation} \forall \varepsilon &gt; 0 \; \exists n_0 \text{ such that } |n a_n| &lt; \varepsilon \; \forall n &gt; n_0 \end{equation} or \begin{equation} \forall \varepsilon &gt; 0 \; \exists n_0 \text{ such that } a_n &lt; \frac{\varepsilon}{n} \; \forall n &gt; n_0 \end{equation} Basically, the terms must be bounded by the harmonic series. Thanks, I'm really stuck on this seemingly simple problem! How to create a matrix with 20 columns in latex The code below works,  but when I add 10 more columns, it does not. So, how can I add ten more columns to the matrix below?  \documentclass{article} \usepackage{amsmath} \begin{document}  \begin{equation} \begin{bmatrix}  1 &amp; 0 &amp; 0 &amp; 0  &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 1 &amp; 0  \end{bmatrix} \end{equation}  \end{document} Resolve build errors due to circular dependency amongst classes I often find myself in a situation where I am facing multiple compilation/linker errors in a C++ project due to some bad design decisions (made by someone else :) ) which lead to circular dependencies between C++ classes in different header files (can happen also in the same file). But fortunately(?) this doesn't happen often enough for me to remember the solution to this problem for the next time it happens again.  So for the purposes of easy recall in the future I am going to post a representative problem and a solution along with it. Better solutions are of-course welcome.     A.h  class B; class A {     int _val;     B *_b; public:      A(int val)         :_val(val)     {     }      void SetB(B *b)     {         _b = b;         _b-&gt;Print(); // COMPILER ERROR: C2027: use of undefined type 'B'     }      void Print()     {         cout&lt;&lt;"Type:A val="&lt;&lt;_val&lt;&lt;endl;     } };       B.h  #include "A.h" class B {     double _val;     A* _a; public:      B(double val)         :_val(val)     {     }      void SetA(A *a)     {         _a = a;         _a-&gt;Print();     }      void Print()     {         cout&lt;&lt;"Type:B val="&lt;&lt;_val&lt;&lt;endl;     } };       main.cpp  #include "B.h" #include &lt;iostream&gt;  int main(int argc, char* argv[]) {     A a(10);     B b(3.14);     a.Print();     a.SetB(&amp;b);     b.Print();     b.SetA(&amp;a);     return 0; } What should we do about Stack Overflow-specific questions on Meta SE? Example of a domain where all irreducibles are primes and that is not a GCD domain One has the following relations for a domain $R$:  $R$ GCD domain $\Rightarrow$ All irreducible elements are prime  $R$ PID $\Rightarrow$ $(R$ GCD domain $\land$ $R$ statisfies ACCP$)$  $R$ UFD $\Leftrightarrow$ $(R$ GCD domain $\land$ $R$ satisfies ACCP$)$  $R$ satisfies ACCP $\Rightarrow$ $(R$ UFD $\Leftrightarrow$ All irreducible elements are prime$)$  $R$ GCD domain $\Rightarrow$ $(R$ UFD $\Leftrightarrow$ $R$ atomic domain$)$  So what is the difference between a GCD domain and a domain where all irreducible elements are prime? What is the "weakest" predicate $P$ such that  $R$ GCD domain $\Leftrightarrow$ $($All irreducible elements are prime $\land$ $P(R))$ ? Neg Binomial and the Jeffreys' Prior I'm trying to obtain the Jeffreys' prior for a negative binomial distribution. I can't see where I go wrong, so if someone could help point that out that would be appreciated.  Okay, so the situation is this: I am to compare the prior distributions obtained using a binomial and a negative binomial, where (in both cases) there are $n$ trials and $m$ successes. I get the right answer for the binomial case, but not for the negative binomial.   Let's call the Jeffreys' prior $\pi_J(\theta)$. Then,  $$ \pi_J(\theta)\propto [I(\theta)]^{1/2}. $$  Under the regularity conditions (fulfilled as we are dealing with the exponential family),  $$ I(\theta)=-E\left(\frac{\partial^2 \log L(\theta|x)}{\partial \theta^2}\right) $$ where for the negative binomial $n$ is $x$ in the above expression (the total number of successes $m$ is fixed, $n$ is not). The distribution --I think-- is  $$ p(m|\theta)\propto\theta^m(1-\theta)^{n-m} $$ since $\theta$ is defined as the probability of success and $m$ is the number of successes. This is also the likelihood, since $m$ is a scalar and not a vector. Hence,  $$ L(\theta|n)\propto\theta^m(1-\theta)^{n-m}\\ \log L(\theta|n)=m\log\theta +(n-m)\log (1-\theta)\\ \frac{\partial\log L(\theta|n)}{\partial \theta}=\frac{m}{\theta}-\frac{n-m}{1-\theta}\\ \frac{\partial^2\log L(\theta|n)}{\partial \theta^2}=-\frac{m}{\theta^2}-\frac{n-m}{(1-\theta)^2} $$ so the Fisher information is  $$ I(\theta)=-E\left(\frac{\partial^2\log L(\theta|n)}{\partial \theta^2}\right)=\frac{m}{\theta^2}+\frac{E(n)-m}{(1-\theta)^2}=\frac{m}{\theta^2}+\frac{\frac{m\theta}{1-\theta}-m}{(1-\theta)^2}\\ =\frac{m(1-\theta)^2+\frac{m\theta^3}{(1-\theta)}-m\theta^2}{\theta^2(1-\theta)^2}=\frac{m(1-2\theta)+\frac{m\theta^3}{(1-\theta)}}{\theta^2(1-\theta)^2}\\ =\frac{m(1-2\theta)(1-\theta)+m\theta^3}{\theta^2(1-\theta)^3}=\frac{m(1-3\theta+2\theta^2+\theta^3)}{\theta^2(1-\theta)^3}\\ \propto\frac{1-3\theta+2\theta^2+\theta^3}{\theta^2(1-\theta)^3} $$  This, however, does not give me the correct answer. The correct answer is  $$ \pi_J(\theta)\propto \frac{1}{\theta(1-\theta)^{1/2}} $$ which means that the Information I get should be   $$ I(\theta)=\frac{1}{\theta^2(1-\theta)} $$ since the prior should be proportional to the square root of the information.   Can anyone find any mistakes? I wouldn't be surprised if I screwed something up with the set up of the distribution (successes vs failures with their respective probabilities, etc).   I used the expected value from  and I know the correct answer from . Plot a piecewise function with black and white disks marking discontinuities I'm wondering if there's any log which stores information about a particular program such as when the program has started and closed manually on Windows such as MS Word, or Chrome. Any ideas? My Father passed away - next test(s) on what remains of his DNA sample? I posted this general question over at the forum on FamilyTreeDNA. Though I received a reply, there is still no answer to my question, so I thought I'd try my luck at posting here.  Anyhow, in early 2009 I bought two kits for the Genographic Project and dutifully had my father do his cheek swabs: one kit for his Y-Chromosome, and one for his mtDNA. Once that was completed, I had his samples transferred to Family Tree DNA.  Then, late in 2009 I paid to have an mtFullSequence done on his mtDNA sample.  My father passed away in 2015. In early 2016, I phoned FTNDA to discuss. The first thing they did was arrange to merge his two original samples into one kit. Then, they suggested doing Family Finder. I did that and recently obtained the interesting results.  So, all told what I have done on my father is:   Y-12 (originally done for the Genographic Project) mtFullSequence Family Finder   My father's Y Haplogroup is R-M269 and I am being presented with the M343 SNP pack on FTNDA.  My question is, what now? My father is gone so the sample that remains with FTDNA is old and finite (their customer service says they still have "one container" of his DNA). His siblings have all passed away -- unfortunately, with no samples taken. What is the best way to make use of the sample of my father's DNA that is left?  Should I refine the Y-Chromosome to Y-111? That seems the most natural (though I'm a male and carry it too). Should any SNP tests best be done on his remaining sample as opposed to on me? Or, should I do nothing and just let his 2009 samples continue to sit at FTDNA?  By phone, FTDNA said that they should have enough left to do the Y-111 and a SNP pack which is great, but I'd love to know independent of their customer service if that is the wisest way to make use of the remaining DNA sample which they have?  Full disclosure: I did have my father do 23andMe in 2010 and I did have his blood drawn and sent to a DNA Bank. I hope to never touch his banked DNA (except maybe to do a full sequence someday), but at least it does exist. My question now is solely how to best make use of my father's remaining sample at Family Tree DNA? Well, I'm trying to find the Thevenin equivalent of this circuit:    As you can see, the only current source is a dependent source. However, the control variable is in a wire where, if nothing is connected between A and B, is \$i_\Delta = 0\$ A, and that makes the source 0 A. However, if I connect an impedance \$Z\$ to the circuit, I will have current, and a Thevenin equivalent. I don't know how to solve this problem. I've bee searching here for a while, and I found this:   . I can see how is solved that case. However, I still don't know how to apply that method to my circuit.  Any help about finding the Thevenin equivalent is appreciated n.n How to change specific values in a List In Episode 1: The Phantom Menace, Anakin's mother, Shmi, said that he does not have a father, although it seemed to me that she doubted that.  Is there a canonical answer as to who Anakin's father is?  If so, who? Can I disable GNOME legacy tray in 17.04? Review bans should escalate beyond 30 days How can I convert a string to boolean in JavaScript? Clothing store access in Pokémon X & Y Once the player obtains access to Lumiose City for the first time, they'll be able to visit Boutique Couture from the city's Vernal Avenue (South fork, connecting from South Boulevard). Upon entering the store without performing any other actions, the player will be turned away and informed they "aren't stylish enough" and that they should visit more places in Lumiose City before visiting again.  This description is dubious, and doesn't inform the player of what they need to accomplish to gain access. Specifically:  Even beating the game (completing the Pokémon League) fails to allow access, as does modifying the player's look, visiting most shops in all areas of Lumiose City, and performing all hair stylist, PR studio, and associated actions. Completing a set of triple battles in Restaurant Le Wow did set the event flag that allowed access in my copy of Y, but it is not clear if this is the only requirement for access.  So other players may benefit, and so I know how to repeat this process if I obtain a copy of X or the future release of Z, what exact requirements yield access to this store for the first time? Which view is the "Current view"? I have got a SharePoint 2010 website with a WebPart-page and a few WebParts on it.  One of the WebParts displays a list/a view of a list.  The views of that list have been updated due to business needs - but the view in the WebPart on the WebPart-page is not updated.    If I edit "Modify Shared Web Part" (the one with the list / list view),  the "Selected view" is set to "&lt;Current view&gt;".  My question is now: Which view of the list is the "&lt;Current view&gt;"? Is it any view of the list at all - or has the WebPart some kind of its own view to that list?