What is the umbrella term for releasing the accused on bail or putting them into a remand prison?

Question: What do you call a court measure against an accused person before they are convicted or acquitted, such as releasing on bail or putting him into a remand prison? What is the umbrella term for these? In a translation of the Russian criminal procedural code, I saw the term "measure of restriction" (see p. 3 here). Is it really used in the English-speaking world?
Comment: measure of restriction is a no-go. restricted release. We don't say a remand prison.
Comment: @Lambie What do you say then?
Comment: A prison is a prison. How you get there (remanded) is an action by the authorities. He was remanded to prison.
Comment: So, released on bail versus remanded into custody.
Comment: @Lambie There's a substantial difference between 'СИЗО' (where a charged person may be put before facing his trial so that he doesn't escape, tamper with witnesses, etc.) and 'тюрьма' in Russian (a place where a person serves his sentence). This difference should be conveyed one way or another
Answer: The term is "remand" for any action where the accused is not free to move about as they please. That includes holding them in prison, releasing them on bail, or sometimes releasing them with a monitored tracking device.

the disposal of an accused person during further process of law. A person may be remanded on bail or in custody. Now includes non-secure remand, the principal example being ELECTRONIC TAGGING.

remand. (n.d.) Collins Dictionary of Law. (2006). Retrieved August 6 2020 from https://legal-dictionary.thefreedictionary.com/remand
An example of usage of the verb from Cambridge dictionary:

Of these, about 1,800 untried and more than 300 convicted unsentenced prisoners had been initially remanded into custody more than 120 days earlier.

An example of usage for the noun from Merriam-Webster:

On one side of the prison there was a block of prisoners on remand; on the other side were the convicts...
Comment: Lexico lists "a committal to custody" as the only meaning of the word 'remand' as a noun: https://www.lexico.com/en/definition/remand
Comment: @SergeyZolotarev And that means pretty much the same thing as the Cambridge definition. "Custody" doesn't necessarily mean "physical imprisonment" in legal terms. I will find an example of the noun's usage.'
Comment: This is right but he needs this phrasing: released on bail versus remanded into custody
Answer: The umbrella term, which covers all possible rulings (including many not mentioned in the question) is either a bail hearing decision or just a bail decision.
From "Bail Hearing Procedures" at FindLaw (the emphasis is my own):

The following is an overview of bail hearing procedures, including the considerations of a defendant's character, whether they should be remanded, and special requirements for defendants out on bail …
Where a defendant poses a threat to the safety of the community, they may be held without bail. In other situations, federal law typically requires that a defendant in a federal criminal case be released on personal recognizance or upon execution of an unsecured appearance bond. Released defendants must not commit any crimes during the period of release.
However, if a court determines that personal recognizance or an unsecured appearance bond won't reasonably assure the defendant's appearance, or determines that the safety of a person or the community is endangered, a defendant may be released upon conditions. Federal law delineates a number of conditions that may be imposed.
Defendants may be required to:

Limit travel (perhaps surrendering their passport);
Maintain or seek employment;
Undergo drug and alcohol testing;
Undergo medical, psychiatric, or psychological treatment;
Maintain or commence an educational program;
Comply with a curfew;
Refrain from excessive use of alcohol or any use of narcotic drugs;
Remain in the custody of a designated person;
Comply with periodic check-ins with authorities;
Refrain from possession of a firearm;
Refrain from contact with crime victim or others designated by the court;
Execute a bond agreement with the court or a solvent surety in an amount as is reasonably necessary to ensure the defendant's appearance; or
Agree to other reasonable conditions the court may impose to ensure a defendant's appearance.

Both the defendant and the government may appeal an adverse bail decision …
Comment: Legal terminology can be heavily jurisdiction-specific, and terms that are familiar in (e.g.) the United States may be different in England and Wales, and vice-versa. even within the UK there are differences: in Scotland the police can release  a suspect with conditions - this is called investigative liberation, and is analogous to being released on bail with conditions in England and Wales.
Comment: @MichaelHarvey However, it's still called a *bail hearing* in the UK, and the result is still some kind of *decision*, regardless of what the terminology of the specific decision is.
Comment: +1 because sometimes the plain English phrase is more useful than the legal term. Although, bail can be discussed at the arraignment hearing, so it might be worth talking more about the difference between a "bail hearing" and a "bail decision". Aren't bail hearings mostly just to appeal if you think your bail was set too high?
Comment: @ColleenV I don't believe so. A bail hearing is the first thing that happens in front of a judge. It determines if you get bail (or something else), and, if you do, how much it will be for. If you want to appeal that decision, I think you can schedule an appeal hearing. I think an arraignment hearing is specifically for indictments, which I think is something a bit different (those are related to federal crimes), but which could also be the same in certain situations.
Comment: @JasonBassford I thought arraignment was the first step and that bail is set at arraignment and if you don't like it, you schedule a bail hearing. This might just be an US thing though. You hear the charges, get informed of your rights, bail is set, you enter a plea, get a public defender assigned, set future court dates etc.
Comment: I need an umbrella term for a set of possible measures against a charged person before they are put to trial so that they don't escape justice. It doesn't seem like 'bail decision' is what I'm looking for


How should Muslim weddings be?

Question: How much amusement is allowed?  Is there any protocol for weddings? Please answer according to Sunnah.
Comment: Great question! It seems that whenever I go to a Muslim-American wedding, it's not very Islamic...
Comment: We know what is Sunnah only from the Hadeeths and the fiqh rulings are derived from that. So, I do not understand what you mean by the last statement.
Comment: I meant, I was looking examples from Sunnah. I don't want personal thoughts of historical famous researchers (alims) of sects.
Comment: When you ask "How much is allowed"- that is a fiqh question. You should probably rephrase your question in my opinion.
Comment: OK, I'm removing the word "fiqh" from my question. I don't want to do anything more. I don't think that my question is too vague to make people this much confused. Terms like "fiqh" are derived words, and Islam is nothing other than Quran and Sunnah. I only want to know how Nabi Muhammad (pbuh) did, I don't want to know how other people did or suggested to be done in the history.
Answer: The best model for marriage and wedding according to Sunnah is the marriage the Prophet made for his daughter Fatima Zahra S.A. All parts of this marriage and wedding were managed by the Prophet and because the groom (i.e. Imam Ali S.A. and cousin of the Prophet) was an orphan from childhood, and was raised and trained by the Prophet and, in fact the Prophet was his like father figure, so in this marriage the Prophet was the manager of the marriage for the both sides and, thus this marriage can be considered a perfect marriage in Sunnah because all of it was managed by the Prophet and can be considered a 100% Islamic marriage based on Sunnah.
How much amusement is allowed?
A free dinner was given to the people who attended and, some had happiness when the bride was going to her home.
Is there any protocol for weddings?
Yes, out of the obligatory rules in Fiqh there are some recommendations. For example, the Mahr (wedding gift) is better to be small and not excessive. The male and female guests should not be mixed. the bride should not show her 'adornments' to men (unless of course, they are her husband).
On top of these, there are more referred to in the following books.
References and more details:
Marriage Handbook
Marriage and Morals in Islam
Principles Of Marriage & Family Ethics

How should Muslim weddings be?


Angular ng-show directive doesn't work for button

Question: I have angular.js web application and btn-group in there like:

  <button class="btn btn-default hidden-xs">....</button>
  <button class="btn btn-default hidden-xs">....</button>
  <button class="btn btn-default hidden-xs">....</button>

I want to hide one of button and added:
<button ng-show="show_button">....</button>

And in controller

$scope.show_button = false;

But i see button. Why? ng-show works for whole btn-group but not for one button.
Comment: Can you add a jsFiddle to demonstrate your problem?
Answer: Here is the plunkr example for you. It works for me in btn-group.
Answer: I just ran into this problem using Angular v1.2.2.
It appears that Bootstrap's style rules for .hidden-xs:
.hidden-xs { display: block !important; }
@media (max-width: 767px) {
    .hidden-xs { display: none !important; }
}

override the style rules from Angular's (v1.2.2) injected inline stylesheet (prepended instead of appended to the head) for .ng-hide (presumably, .ng-show as well).
[ng\:cloak], [ng-cloak], [data-ng-cloak],
[x-ng-cloak], .ng-cloak, .x-ng-cloak,
.ng-hide {
    display: none !important;
}

For lack of better solution at the moment, add the angular stylesheet or specific rules that you need to your document, stylesheet or in some other fashion. (Then check for style rule changes if you change versions of Angular). If anyone has a more appropriate solution, feel free to contribute.
Answer: bootstraps' .hidden-xs class adds display:block for visible elemets which breaks angular's ng-show and ng-hide classes.
Instead, use a custom .my-hidden-xs class:
// my-style.css
@media (max-width: 767px) {
    .my-hidden-xs {
        display: none !important;
    }
}

// index.html
<button class="btn btn-default my-hidden-xs" ng-show="show_button"></button>

Answer: I ran into this issue too. Finally I found that I set the style "visibility: hidden" in my own CSS file to the div. So no matter how I change the expression in ng-show, div is always hidden. That means the visibility style in your own style is always applied, angularjs will never change this css property value. To use ng-show/ng-hide the first thing you need to make sure is that you do NOT add any show/hide style to DOM element, just hand over the control to angular.
Answer: Try replacing ng-show/ng-hide with ng-if.
Should do the trick :)


How do you generate a random double uniformly distributed between 0 and 1 from C++?

Question: How do you generate a random double uniformly distributed between 0 and 1 from C++?
Of course I can think of some answers, but I'd like to know what the standard practice is, to have:

Good standards compliance
Good randomness
Good speed

(speed is more important than randomness for my application).
Thanks a lot!
PS: In case that matters, my target platforms are Linux and Windows.
Comment: Note, as my answer indicates the modern C++ way to do this is using the `random` header.
Answer: An old school solution like:
double X=((double)rand()/(double)RAND_MAX);

Should meet all your criteria (portable, standard and fast).
obviously the random number generated has to be seeded the standard procedure is something like:
srand((unsigned)time(NULL));

Comment: Be wary of RAND_MAX though if you're looking for identical range and behaviour on different systems. Some have a RAND_MAX of 32k, others 2048k. Always best to check.
Comment: @Dave: just to be nitpicky: in this case, the output will always be a double in the range [0,1], so the only thing that the value of RAND_MAX can change is the amount of distinct values that the expression can return.
Comment: It's of course not a real uniform distribution, but even _defining_ that precisely for floating point numbers is a bit of a challenge.

(The very least you should expect is that p(x) > 0 if 0<x<1)
Comment: @suszterpatt: Yup, that's what I was referring to. Given he's asking for double precision, thought it might be relevant! I should have phrased it better.
Comment: This answer is definitely outdated and using srand/rand is not actually uniform. See links in Shafik Yaghmour's answer.
Comment: Stephan Lavavej humurously calls that kind of stuff _"floating-point double treachery"_  ([source](http://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful))
Comment: (double)rand()/(double)RAND_MAX will generate many zeros because double type is floating point. For every x < 0.0000000000000001 x/Double.MaxValue will result in 0.0
Answer: In C++11 and C++14 we have much better options with the random header. The presentation rand() Considered Harmful  by Stephan T. Lavavej  explains why we should eschew the use of rand() in C++ in favor of the random header and N3924: Discouraging rand() in C++14 further reinforces this point.
The example below is a modified version of the sample code on the cppreference site and uses the std::mersenne_twister_engine engine and the std::uniform_real_distribution which generates numbers in the [0,1) range (see it live):
#include <iostream>
#include <iomanip>
#include <map>
#include <random>

int main()
{
    std::random_device rd;

    std::mt19937 e2(rd());

    std::uniform_real_distribution<> dist(0, 1);

    std::map<int, int> hist;
    for (int n = 0; n < 10000; ++n) {
        ++hist[std::round(dist(e2))];
    }

    for (auto p : hist) {
        std::cout << std::fixed << std::setprecision(1) << std::setw(2)
                  << p.first << ' ' << std::string(p.second/200, '*') << '\n';
    }
}

output will be similar to the following:
0 ************************
1 *************************

Since the post mentioned that speed was important then we should consider the cppreference section that describes the different random number engines (emphasis mine):

The choice of which engine to use involves a number of tradeoffs*: the
  **linear congruential engine is moderately fast and has a very small
  storage requirement for state. The lagged Fibonacci generators are
  very fast even on processors without advanced arithmetic instruction
  sets, at the expense of greater state storage and sometimes less
  desirable spectral characteristics. The Mersenne twister is slower and
  has greater state storage requirements but with the right parameters
  has the longest non-repeating sequence with the most desirable
  spectral characteristics (for a given definition of desirable).

So if there is a desire for a faster generator perhaps ranlux24_base or ranlux48_base are better choices over mt19937.
rand()
If you forced to use rand() then the C FAQ for a guide on How can I generate floating-point random numbers?, gives us an example similar to this for generating an on the interval [0,1):
#include <stdlib.h>

double randZeroToOne()
{
    return rand() / (RAND_MAX + 1.);
}

and to generate a random number in the range from [M,N):
double randMToN(double M, double N)
{
    return M + (rand() / ( RAND_MAX / (N-M) ) ) ;
}

Answer: The C++11 standard  library contains a decent framework and a couple of serviceable generators, which is perfectly sufficient for homework assignments and off-the-cuff use.
However, for production-grade code you should know exactly what the specific properties of the various generators are before you use them, since all of them have their caveats. Also, none of them passes standard tests for PRNGs like TestU01, except for the ranlux generators if used with a generous luxury factor.
If you want solid, repeatable results then you have to bring your own generator.
If you want portability then you have to bring your own generator.
If you can live with restricted portability then you can use boost, or the C++11  framework in conjunction with your own generator(s).
More detail - including code for a simple yet fast generator of excellent quality and copious links - can be found in my answers to similar topics:

General purpose random number generation
Very fast uniform distribution random number generator

For professional uniform floating-point deviates there are two more issues to consider:

open vs. half-open vs. closed range, i.e. (0,1), [0, 1) or [0,1]
method of conversion from integral to floating-point (precision, speed)

Both are actually two sides of the same coin, as the method of conversion takes care of the inclusion/exclusion of 0 and 1. Here are three different methods for the half-open interval:

// exact values computed with bc

#define POW2_M32   2.3283064365386962890625e-010
#define POW2_M64   5.421010862427522170037264004349e-020

double random_double_a ()
{
   double lo = random_uint32() * POW2_M64;
   return lo + random_uint32() * POW2_M32;
}

double random_double_b ()
{
   return random_uint64() * POW2_M64;
}

double random_double_c ()
{
   return int64_t(random_uint64()) * POW2_M64 + 0.5;
}

(random_uint32() and random_uint64() are placeholders for your actual functions and would normally be passed as template parameters)
Method a demonstrates how to create a uniform deviate that is not biassed by excess precision for lower values; the code for 64-bit is not shown because it is simpler and just involves masking off 11 bits. The distribution is uniform for all functions but without this trick there would be more different values in the area closer to 0 than elsewhere (finer grid spacing due to the varying ulp).
Method c shows how to get a uniform deviate faster on certain popular platforms where the FPU knows only a signed 64-bit integral type. What you see most often is method b but there the compiler has to generate lots of extra code under the hood to preserve the unsigned semantics.
Mix and match these principles to create your own tailored solution.
All this is explained in Jürgen Doornik's excellent paper Conversion of High-Period Random Numbers to Floating Point.
Answer: The random_real class from the Boost random library is what you need.
Comment: The documentation for that library is pretty scarce.  Do you have a code sample?
Comment: Please have a look at this sample: http://www.boost.org/doc/libs/1_39_0/libs/random/random_demo.cpp
Answer: Here's how you'd do it if you were using C++ TR1.
Comment: This seems to me to be the only implementation that actually claims to give you a UNIFORM real distribution - my solution above gives MAX_RAND possible values evenly distributed in the range 0 to 1 which is not quite the same thing.
Comment: minus one, link-only answers are frowned upon
Comment: to improve this answer, explain the answer concisely right here and link to the blog for more details if applicable
Answer: If speed is your primary concern, then I'd simply go with
double r = (double)rand() / (double)RAND_MAX;

Answer: As I see it, there are three ways to go with this,
1) The easy way.
double rand_easy(void)
{       return (double) rand() / (RAND_MAX + 1.0);
}

2) The safe way (standard conforming).
double rand_safe(void)
{
        double limit = pow(2.0, DBL_MANT_DIG);
        double denom = RAND_MAX + 1.0;
        double denom_to_k = 1.0;
        double numer = 0.0;

        for ( ; denom_to_k < limit; denom_to_k *= denom )
           numer += rand() * denom_to_k;

        double result = numer / denom_to_k;
        if (result == 1.0)
           result -= DBL_EPSILON/2;
        assert(result != 1.0);
        return result;
}

3) The custom way.
By eliminating rand() we no longer have to worry about the idiosyncrasies of any particular version, which gives us more leeway in our own implementation.
Note: Period of the generator used here is ≅ 1.8e+19.
#define RANDMAX (-1ULL)
uint64_t custom_lcg(uint_fast64_t* next)
{       return *next = *next * 2862933555777941757ULL + 3037000493ULL;
}

uint_fast64_t internal_next;
void seed_fast(uint64_t seed)
{       internal_next = seed;
}

double rand_fast(void)
{
#define SHR_BIT (64 - (DBL_MANT_DIG-1))
        union {
            double f; uint64_t i;
        } u;
        u.f = 1.0;
        u.i = u.i | (custom_lcg(&internal_next) >> SHR_BIT);
        return u.f - 1.0;
}

Whatever the choice, functionality may be extended as follows,
double rand_dist(double min, double max)
{       return rand_fast() * (max - min) + min;
}

double rand_open(void)
{       return rand_dist(DBL_EPSILON, 1.0);
}

double rand_closed(void)
{       return rand_dist(0.0, 1.0 + DBL_EPSILON);
}

Final notes: The fast version - while written in C - may be adapted for use in C++ to be used as a replacement for std::generate_canonical, and will work for any generator emitting values with sufficient significant bits.
Most 64 bit generators take advantage of their full width, so this can likely be used without modification (shift adjustment). e.g. this works as-is with the std::mt19937_64 engine.
Answer: First include stdlib.h
#include<stdlib.h>

Then following can be a function to generate random double number between a range in C programming language.
double randomDouble() {
    double lowerRange = 1.0;
    double upperRange = 10.0;
    return ((double)rand() * (upperRange - lowerRange)) / (double)RAND_MAX + lowerRange;
}

Here RAND_MAX is defined in stdlib.h
Answer: You could try the Mersenne Twister algorithm.
http://en.wikipedia.org/wiki/Mersenne_twister
It has a good blend of speed and randomness, and a GPL implementation.
Comment: Doesn't it generate integers, not real numbers?
Answer: Well considering simplicity and speed as your primary criteria, you can add a small generic helper like this :-
  // C++ rand generates random numbers between 0 and RAND_MAX. This is quite a big range
  // Normally one would want the generated random number within a range to be really
  // useful. So the arguments have default values which can be overridden by the caller
  int nextRandomNum(int low = 0, int high = 100) const {
    int range = (high - low) + 1;
    // this modulo operation does not generate a truly uniformly distributed random number
    // in the span (since in most cases lower numbers are slightly more likely),
    // but it is generally a good approximation for short spans. Use it if essential
    //int res = ( std::rand() % high + low );
    int res = low + static_cast<int>( ( range * std::rand() / ( RAND_MAX + 1.0) ) );
    return res;
  }

Random number generation is a well studied, complex and advanced topic. You can find some simple but useful algorithms here apart from the ones mentioned in other answers:-
Eternally Confuzzled
Answer: //Returns a random number in the range (0.0f, 1.0f).
// 0111 1111 1111 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
// seee eeee eeee vvvv vvvv vvvv vvvv vvvv vvvv vvvv vvvv vvvv vvvv vvvv vvvv vvvv
// sign     = 's'
// exponent = 'e'
// value    = 'v'
double DoubleRand() {
  typedef unsigned long long uint64;
  uint64 ret = 0;
  for (int i = 0; i < 13; i++) {
     ret |= ((uint64) (rand() % 16) << i * 4);
  }
  if (ret == 0) {
    return rand() % 2 ? 1.0f : 0.0f;
  }
  uint64 retb = ret;
  unsigned int exp = 0x3ff;
  retb = ret | ((uint64) exp << 52);
  double *tmp = (double*) &retb;
  double retval = *tmp;
  while (retval > 1.0f || retval < 0.0f) {
    retval = *(tmp = (double*) &(retb = ret | ((uint64) (exp--) << 52)));
  }
  if (rand() % 2) {
    retval -= 0.5f;
  }
  return retval;
}

This should do the trick, I used this Wikipedia article to help create this. I believe it to be as good as drand48();
Comment: Wow, that is really, really terrible.
Answer: This is what I ended up using for my needs:
int range_upper_bound = 12345;
int random_number =((double)rand()/(double)range_upper_bound);

Answer: double randDouble()
{
  double out;
  out = (double)rand()/(RAND_MAX + 1); //each iteration produces a number in [0, 1)
  out = (rand() + out)/RAND_MAX;
  out = (rand() + out)/RAND_MAX;
  out = (rand() + out)/RAND_MAX;
  out = (rand() + out)/RAND_MAX;
  out = (rand() + out)/RAND_MAX;

  return out;
}

Not quite as fast as double X=((double)rand()/(double)RAND_MAX);, but with better distribution.  That algorithm gives only RAND_MAX evenly spaced choice of return values; this one gives RANDMAX^6, so its distribution is limited only by the precision of double.
If you want a long double just add a few iterations.  If you want a number in [0, 1] rather than [0, 1) just make line 4 read out = (double)rand()/(RAND_MAX);.
Comment: -1 this really seems to weaken as opposed to strengthen the randomness
Comment: Correct me if I'm wrong, but this method has a non-null probability to give a strictly superior to 1 number, right?
Comment: @Julio: Not only that, it does not even produce a uniform distribution even if the numbers are in 0-1 range. In fact the distribution should be quite anything but uniform. This is why you should NOT think of such algorithms yourself...


How fast are you moving on the earth at a given latitude?

Question: The radius of the earth is about $3959\,\mathrm{mi}$, so the earth is rotating at about $$\frac{1}{24\,\mathrm{hours}}\times 2\pi\times 3959 \,\mathrm{mi} \approx 1036\,\mathrm{mph}\,$$ and so someone standing on the equator is moving that fast too. But suppose you're standing on the earth at a latitude to $\theta^{\,\circ}$. How fast are you moving then?
Answer: If you're standing at a latitude of $\theta^{\,\circ}$, then you're rotating on a circle of radius $R\cos(\theta)$, where $R = 3959\,\mathrm{mi}$ is the radius of the earth. This circle still does one revolution in (about!) $24\,\mathrm{hrs}$, so we can calculate the speed from there.

$$
\left(\frac{1}{24 \,\mathrm{hours}}\right) \times 2\pi R\cos\theta \,\mathrm{miles}
\approx 1036\cos\theta \,\mathrm{mph}
$$
So you've just gotta scale the speed at the equator by $\cos\theta$.
Comment: You can also use the angular velocity of all points on the surface of the earth which is $\omega=\frac{2\pi}{24}$ radians per hour. And if you want the linear velocity of any point, you just use the equation $v=\omega.r$, and just like you said: the radius $r$ at any point is $R\cos\theta$ where $\theta$ is the latitude of that point.
Comment: May I ask what tool you used to make the diagram?
Comment: @saulspatz [Mypaint](http://mypaint.org). It's what I've been using as a blackboard for screenshared remote teaching.
Answer: Between two longitudes the arc distance
$$ L= r \Delta \theta$$
When its latitude $=\phi,$ radius $r$, earth's radius $R$
$$ r= R \cos \phi\rightarrow L = R \cos \phi \;\Delta \theta $$

In unit time the circumferential speed ( the others are constant)
$$ \dfrac{dL}{dt} = R \cos \phi\; \dfrac{\Delta \theta}{dt}= \omega R \cos \phi $$
where $\omega$ is the earth's angular velocity, $ \omega R$ is circumferential speed $v_{eqtr}$ at equator. So we can write it simply as
$$ v= v_{eqtr} \cos \phi= 1036 \;\cos \phi\; mph,$$
that vanishes at poles, from where you watch the moving world standing, like from a small merry-go-round.
Answer: Let's introduce a Cartesian coordinate system in which the center of the earth resides at origin $(0,0,0)$ and the north pole resides at $(0,0,R_E)$ where $R_E$ is the radius of the earth.
By slightly modifying the conventional definition of the azimuth angle, we determine the trajectory of an object residing at   $\theta$ latitude with initial position $\Big<R_E\cos(\theta),0,R_E\sin(\theta)\Big>$ to be modeled by the parametric curve $$\vec{r}_{\theta}(t)=\Big<R_E \cos(\theta)\cos\Big(\frac{2\pi t}{24}\Big),R_E\cos(\theta)\sin\Big(\frac{2\pi t}{24}\Big),R_E\sin(\theta)\Big>$$ Here $t$ is measured in hours. Then $$\|r_{\theta}'(t)\|=\frac{2\pi R_E}{24}\cos(\theta)$$


Clash of Clans using one Game Center account only

Question: I originally started Clash of Clans with one Game Center and my friend told me to log into his Game Center so somehow my Game Center is saved on multiple accounts so now my friend can use my account. Does anyone know how to remove my friend's Game Center while keeping my original one?
Answer: Game center is associated with an Apple ID. I do not believe that it can be shared across users. It is possible that you are still using your friends account ID.  You can change your settings like so :

iOS: Go to Settings and tap Game Center. You might have to sign in with your Apple ID.
    OSX: Go to the Me tab and click Account > View Account.

or refer to this page.


Is it possible to copy a Work Item Template from one project to another?

Question: The two projects in question were created from the same base template. Essentially I've stripped out a bunch of stuff that we don't need in several of the Work Item Templates, and deleted a few others. I'd like to copy these template changes to another project, instead of redoing all the work I just did.
Answer: If the other project is already created on the Server you can use the Team Foundation Server Power Tools. The Tool you want is the Process Editor.
After you install. Fire up Visual Studio and connect to Team Explorer. Then go to Tools | Process Editor | Work Item Types | Import WIT
Select the Work Item Type template and the project you want to install it to.
or if you prefer command line solutions use witimport:
witimport /f file /t TeamFoundationServer /p teamproject [/v] [/e encoding]
/f        Specifies the work item type XML definition file to be imported.
/t        Specifies the name of the Team Foundation Server. This can also be a fully specified URL such as http://server:8080.
/p        Specifies the Team Project on the Team Foundation Server to which the
           file is imported.
/v        Validates the XML without importing the work item type.
/e        Specifies the name of the .NET Framework 2.0 encoding used to import
           the work item type XML.  For example, /e utf-7 will use Unicode
           (UTF-7) encoding.  Encoding is auto-detected by default where
           possible.  If unavailable, encoding defaults to UTF-8.
Answer: This tool really helps with this too:
http://witsynchronizer.codeplex.com/
Comment: Nice! Although it's a bit old now. Is it because something else replaced it?
Answer: Yes templates are located on your local machine you should be able to copy it from there. My are in Documents\Work Item Templates.
Answer: Visual Studio doesn't give options to edit the process template or copy the process template


TM2 Related lists to show at the Top of the Account Page?

Question: How can I get the Territory and Assigned User related lists to show at the top, or towards the top, of the Account Page?  Users have to scroll down through the entire page to see who is working the account.  Possible??
Answer: We can't get any related lists to show at the top. If you however want to achieve this, you can create a inline visualforce page and expose towards the top. Let me know if you need help with the code.


Create a type containing only non-shared properties from two interfaces

Question: Given two interfaces:
type I1 = {
    a: string
    b: string
    c: number
}

type I2 = {
    a: string
    b: string
    d: string
}

I need to create a type which only has properties which are not shared by the two interfaces.
type Result = XOR<I1, I2>

// should become
type Result = {
    c: number
    d: string
}

I tried this:

type XOR<T1, T2> = {
    [K in keyof (T1 & T2)]: T1[K & keyof T1] | T2[K & keyof T2]
    // ^^ I need something like "not in" here
}

But I am not sure how to only map over keys which are not in both T1 and T2.
I prepared this playground
Comment: This isn't XOR and more like NAND tbh (unless we're talking about set theory?)
Answer: type XOR = {
    [K in Exclude<keyof A | keyof B, keyof A & keyof B>]: K extends keyof A ? A[K] : K extends keyof B ? B[K] : never;
};

Exclude keyof A ∩ keyof B from keyof A ∪ keyof B to get the keys that are only in either A or B. Then just get the right value from A or B for the key.
Playground

Oh, I haven't had my afternoon coffee yet...
type XOR = Omit;


Worst Voted Question Asked

Question: Is there any way I can check all Stack Exchange communities to find the worst (or best) voted question (as of now). I found one with -10 votes, and I forgot where that was. For curiousity, how many votes will it take to ban (or promote) a user?
Comment: The algorithm for banning is kept secret, to prevent people from gaming it.
Comment: You mean your own posts, or any posts?
Comment: Which are the worst voted questions and or posts? Is there some way of keeping track?
Answer: If you want to know the most downvoted or the worst scoring post, SEDE is the way to go.
For example, for Stack Overflow:

this answer seems to have the worst score (-62). This one the most downvotes (227);
this question seems to have the worst score (-154). And this one the most downvotes (218).

For MSE:

this question has a score of -270 having 440 downvotes;
this answer has a score of -215 having 249 downvotes.

You can run this query for the site you want, or with some extra work run it for all sites in the network at once.
Note that this queries will only return the posts that are not deleted. Deleted post can't be queries using SEDE.
SE does not release any information on the script determining when someone gets banned or not. That is kept confidential to prevent misuse of the algorithm.
Comment: Worth to mention the -270 scored question got 440 downvotes, maybe worth running the queries to get most voted posts with only up/down votes, not net score.
Comment: Indeed. Updated @Sha
Comment: The worse non-deleted downvoted answer on MSE was posted by Jeff Atwood himself. Hmm.
Answer: The worst question seems to be this one with a score of -270. The best question is the well-known branch prediction question.
I found them using this SEDE query - keep in mind that the data is refreshed once a week on Sunday morning.
<code>-- all databases
declare  db_c cursor for select [name]
                         from sys.databases
                         where database_id > 5 -- skip master, temp, model, msdb, Data.SE

declare @db_c_name sysname   -- holds name of db after fetch
declare @sql nvarchar(max) -- holds build up sql string

-- result table
create table #worstquestions (site nvarchar(250), id int, score int, title nvarchar(250));
create table #bestquestions (site nvarchar(250), id int, score int, title nvarchar(250));

open db_c
fetch next from db_c into @db_c_name
while(@@FETCH_STATUS = 0)
begin
    set @sql = N'use '+ QUOTENAME(@db_c_name) + ';
    insert into #worstquestions
    select top 1 ''' + QUOTENAME(@db_c_name) + ''', id, score, title
      from posts
      where posttypeid = 1
      order by score asc;
    insert into #bestquestions
    select top 1 ''' + QUOTENAME(@db_c_name) + ''', id, score, title
      from posts
      where posttypeid = 1
      order by score desc';

    exec (@sql)
   fetch next from db_c into @db_c_name
end;
close db_c;
deallocate db_c;

select * from #worstquestions order by score asc;
select * from #bestquestions order by score desc;
</code>

For curiousity, how many votes will it take to ban (or promote) a user?

For banning, this will not be disclosed to mere users, like you and me. There's too much potential for abuse. I don't understand what you mean by promotion.

Worst Voted Question Asked


Abstraction VS Information Hiding VS Encapsulation

Question: Can you tell me what is the difference between abstraction and information hiding in software development?
I am confused. Abstraction hides detail implementation and
information hiding abstracts whole details of something.
Update: I found a good answer for these three concepts. See the separate answer below for several citations taken from there.
Comment: _"Encapsulation is then the technique for packaging the information in such a way as to hide what should be hidden, and make visible what is intended to be visible."_; remembering that encapsulation is achieved through information hiding.
Comment: possible duplicate of [precise difference between encapsulation and abstraction](http://stackoverflow.com/questions/742341/difference-between-abstraction-and-encapsulation/13589763#13589763)
Answer: Go to the source! Grady Booch says (in Object Oriented Analysis and Design, page 49, second edition):

Abstraction and encapsulation are complementary concepts: abstraction
  focuses on the observable behavior of an object... encapsulation
  focuses upon the implementation that gives rise to this behavior...
  encapsulation is most often achieved through information hiding, which
  is the process of hiding all of the secrets of object that do not
  contribute to its essential characteristics.

In other words: abstraction = the object externally; encapsulation (achieved through information hiding) = the object internally,
Example:
In the .NET Framework, the System.Text.StringBuilder class provides an abstraction over a string buffer. This buffer abstraction lets you work with the buffer without regard for its implementation. Thus, you're able to append strings to the buffer without regard for how the StringBuilder internally keeps track of things such the pointer to the buffer and managing memory when the buffer gets full (which it does with encapsulation via information hiding).
rp
Comment: would you say that, in the same way abstraction and encapsulation are complementary, encapsulation and information hiding are also complementary? Sure, encapsulation is achieved through information hiding, but... isn't encapsulation the mechanism through which information hiding is realised?
Comment: Another real world example for Booch's definition is available [here](http://stackoverflow.com/a/635747/307454)
Comment: Could you please tell me if it would correct to say that Abstraction is best understood through the Client code's perspective while Encapsulation is best understood through from the Service Code ( i.e. the Encapsulated Class itself ) perspective?
Comment: Real World Example for above definition is explained here: http://stackoverflow.com/a/635755/3181500
Answer: The OP updated his question with several citations that he had found, namely in an article by Edward V. Berard titled, "Abstraction, Encapsulation, and Information Hiding". I am re-posting a slightly expanded and reformatted version of the OP's update, since it should be an answer in its own right.
(All citations are taken from the article mentioned above.)
Abstraction:

"One point of confusion regarding abstraction is its use as both process and an entity. Abstraction, as a process, denotes the extracting of the essential details about an item, or a group of items, while ignoring the inessential details. Abstraction, as an entity, denotes a model, a view, or some other focused representation for an actual item."

Information Hiding:

"Its interface or definition was chosen to reveal as little as possible about its inner workings." — [Parnas, 1972b]
"Abstraction can be […] used as a technique for identifying which information should be hidden."
"Confusion can occur when people fail to distinguish between the hiding of information, and a technique (e.g., abstraction) that is used to help identify which information is to be hidden."

Encapsulation:

"It […] refers to building a capsule, in the case a conceptual barrier, around some collection of things." — [Wirfs-Brock et al, 1990]
"As a process, encapsulation means the act of enclosing one or more items within a […] container. Encapsulation, as an entity, refers to a package or an enclosure that holds (contains, encloses) one or more items."
"If encapsulation was 'the same thing as information hiding,' then one might make the argument that 'everything that was encapsulated was also hidden.' This is obviously not true."

Conclusion:

"Abstraction, information hiding, and encapsulation are very different, but highly-related, concepts. One could argue that abstraction is a technique that help us identify which specific information should be visible, and which information should be hidden. Encapsulation is then the technique for packaging the information in such a way as to hide what should be hidden, and make visible what is intended to be visible."
Comment: great explanation practically. it would be great to provide concrete examples in java. it looks to me that setter/getter in java hide the implementation, hence achieving `Information Hiding` (or implementation hiding), whereas a generic `class` achieves encapsulation and abstraction is achieved through `private` access
Comment: This is by far the best explanation that I have come across to tell me the difference between the 3.
Answer: Abstraction is hiding the implementation details by providing a layer over the basic functionality.
Information Hiding is hiding the data which is being affected by that implementation. Use of private and public comes under this. For example, hiding the variables of the classes.
Encapsulation is just putting all similar data and functions into a group e.g Class in programming; Packet in networking.
Through the use of Classes, we implement all three concepts - Abstraction, Information Hiding and Encapsulation
Answer: Please don't complicate simple concepts.
Encapsulation : Wrapping up of data and methods into a single unit is Encapsulation (e.g. Class)
Abstraction : It is an act of representing only the essential things without including background details. (e.g. Interface)
FOR EXAMPLES AND MORE INFO GOTO :
http://thecodekey.com/C_VB_Codes/Encapsulation.aspx
http://thecodekey.com/C_VB_Codes/Abstraction.aspx
Approved definitions here
P.S.: I also remember the definition from a book named C++ by Sumita Arora which we read in 11th class ;)
Answer: The meaning of abstraction given by the Oxford English Dictionary (OED) closest to the meaning intended here is 'The act of separating in thought'. A better definition might be 'Representing the essential features of something without including background or inessential detail.'
Information hiding is the principle that users of a software component (such as a class) need to know only the essential details of how to initialize and access the component, and do not need to know the details of the implementation.
Edit: I seems to me that abstraction is the process of deciding which parts of the implementation that should be hidden.
So its not abstraction VERSUS information hiding. It's information hiding VIA abstraction.
Answer: Abstraction
Abstraction is an act of representing essentail details without including the background details. A abstract class have only method signatures and implementing class can have its own implementation, in this way the complex details will be hidden from the user. Abstraction focuses on the outside view. In otherwords, Abstraction is sepration of interfaces from the actual implementation.
Encapsulation
Encapsulation explains binding the data members and methods into a single unit. Information hiding is the main purpose of encapsulation. Encapsulation is acheived by using access specifiers like private, public, protected. Class member variables are made private so that they cann't be accessible directly to outside world. Encapsulation focuses on the inner view. In otherwords, Encapsulation is a technique used to protect the information in an object from the other object.
Answer: Abstraction : Abstraction is the concept/technique used to identify what should be the external view of an object. Making only the required interface available.
Information Hiding : It is complementary to Abstraction, as through information hiding Abstraction is achieved. Hiding everything else but the external view.
Encapsulation : Is binding of data and related functions into a unit. It facilitates Abstraction and information hiding. Allowing features like member access to be applied on the unit to achieve Abstraction and Information hiding
Answer: Abstraction is hiding details of implementation as you put it.
You abstract something to a high enough point that you'll only have to do something very simple to perform an action.
Information hiding is hiding implementation details. Programming is hard. You can have a lot of things to deal with and handle. There can be variables you want/need to keep very close track of. Hiding information ensures that no one accidentally breaks something by using a variable or method you exposed publicly.
These 2 concepts are very closely tied together in object-oriented programming.
Answer: Abstraction -  It is the process of identifying the essential characteristics of an object
                   without including the irrelevant and tedious details.
Encapsulation - It is the process of enclosing data and functions manipulating this data into a single unit.
Abstraction and Encapsulation are related but complementary concepts.

Abstraction is the process. Encapsulation is the mechanism by which Abstraction is implemented.
Abstraction focuses on the observable behavior of an object. Encapsulation focuses upon the implementation that give rise to this behavior.

Information Hiding - It is the process of hiding the implementation details of an object. It is a result of Encapsulation.
Answer: In very short
Encapsulation:– Information hiding
Abstraction  :– Implementation hiding
Abstraction lets you focus on what the object does while Encapsulation means how an object works
Answer: See Joel's post on the Law of Leaky Abstractions
JoelOnsoftware
Basically, abstracting gives you the freedom of thinking of higher level concepts.  A non-programming analogy is that most of us do not know where our food comes from, or how it is produced, but the fact that we (usually) don't have to worry about it frees us up to do other things, like programming.
As for information hiding, I agree with jamting.
Answer: Encapsulation: binding the data members and member functions together is called              encapsulation. encapsulation is done through class.
abstraction: hiding the  implementation details form usage or from view is called abstraction.
         ex:
            int x;
      we don't know how int will internally work. but we know int will work. that is abstraction.
Answer: It's worth noting these terms have standardized, IEEE definitions, which can be searched at https://pascal.computer.org/.
abstraction

view of an object that focuses on the information relevant to a particular purpose and ignores the remainder of the information
process of formulating a view
process of suppressing irrelevant detail to establish a simplified model, or the result of that process

information hiding

software development technique in which each module's interfaces reveal as little as possible about the module's inner workings and other modules are prevented from using information about the module that is not in the module's interface specification
containment of a design or implementation decision in a single module so that the decision is hidden from other modules

encapsulation

software development technique that consists of isolating a system function or a set of data and operations on those data within a module and providing precise specifications for the module
concept that access to the names, meanings, and values of the responsibilities of a class is entirely separated from access to their realization
idea that a module has an outside that is distinct from its inside, that it has an external interface and an internal implementation
Answer: Abstraction allows you to treat a complex process as a simple process. For example, the standard "file" abstraction treats files as a contiguous array of bytes. The user/developer does not even have to think about issues of clusters and fragmentation. (Abstraction normally appears as classes or subroutines.)
Information hiding is about protecting your abstractions from malicious/incompetent users. By restricting control of some state (hard drive allocations, for example) to the original developer, huge amounts of error handling becomes redundant. If nobody else besides the file system driver can write to the hard drive, then the file system driver knows exactly what has been written to the hard drive and where. (The usual manifestation of this concept is private and protected keywords in OO languages.)
Answer: To abstract something we need to hide the detail or to hide the detail of something we need to abstract it.
But, both of them can be achieved by encapsulation.
So, information hiding is a goal, abstraction is a process, and encapsulation is a technique.
Comment: Can u provide a Java example for the same?
Answer: Abstraction simply means the technique in which only essential details of software is made visible to the user to help the user to use or operate with software, thus implementation details of that software are not shown(are made invisible).
Encapsulation is the technique that have package that hold one or more items and hence some of information (particularly program details) became visible and some not visible to the user, so encapsulation is achieved through information hiding.
In summary. Abstraction is for observable behavior (externally) and encapsulation is for invisibility (internally) but these two are really complementary.
Answer: Just adding on more details around InformationHiding, found This link is really good source with examples

InformationHiding is the idea that a design decision should be hidden from the rest of the system to prevent unintended coupling. InformationHiding is a design principle. InformationHiding should inform the way you encapsulate things, but of course it doesn't have to.
Encapsulation is a programming language feature.
Answer: Both Abstraction and Encapsulation are two of the four basic OOP concepts which allow you to model real-world things into objects so that you can implement them in your program and code. Many beginners get confused between Abstraction and Encapsulation because they both look very similar. If you ask someone what is Abstraction, he will tell that it's an OOP concept which focuses on relevant information by hiding unnecessary detail, and when you ask about Encapsulation, many will tell that it's another OOP concept which hides data from outside world. The definitions are not wrong as both Abstraction and Encapsulation does hide something, but the key difference is on intent.
Abstraction hides complexity by giving you a more abstract picture, a sort of 10,000 feet view, while Encapsulation hides internal working so that you can change it later. In other words, Abstraction hides details at the design level, while Encapsulation hides details at the implementation level.
Answer: After reading all the above answers one by one I cant stop myself from posting that

abstraction involves the facility to define objects that represent abstract "actors" that can perform work, report on and change their state, and "communicate" with other objects in the system.

Encapsulation is quite clear from above however ->

The term encapsulation refers to the hiding of state details, but extending the concept of data type from earlier programming languages to associate behavior most strongly with the data, and standardizing the way that different data types interact, is the beginning of abstraction.

reference wiki
Answer: I too was very confused about the two concepts of Abstraction and Encapsulation. But when I saw the abstraction article on myjavatrainer.com, It became clear to me that Abstraction and Encapsulation are Apples and Oranges, you can't really compare them because both are required.
Encapsulation is how the object is created, and abstraction is how the object is viewed in the outside world.
Answer: Encapsulation: binding data and the methods that act on it. this allows the hiding of data from all other methods in other classes.
example: MyList class that can add an item, remove an item, and remove all items
the methods add, remove, and removeAll act on the list(a private array) that can not be accessed directly from the outside.
Abstraction: is hiding the non relevant behavior and data.
How the items are actually stored, added, or deleted is hidden (abstracted).
My data may be held in simple array, ArrayList, LinkedList, and so on.
Also, how the methods are implemented is hidden from the outside.
Answer: Encapsulation- enforcing access to the internal data in a controlled manner or preventing members from being accessed directly.
Abstraction- Hiding the implementation details of certain methods is known as abstraction
Let's understand with the help of an example:-
class Rectangle
{
private int length;
private int breadth;// see the word private that means they cant be accesed from
outside world.
 //now to make them accessed indirectly define getters and setters methods
void setLength(int length)
{
// we are adding this condition to prevent users to make any irrelevent changes
  that is why we have made length private so that they should be set according to
   certain restrictions
if(length!=0)
{
 this.length=length
 }
void getLength()
{
 return length;
 }
 // same do for breadth
}

now for abstraction define a method that can only be accessed and user doesnt know
what is the body of the method and how it is working
Let's consider the above example, we can define a method area which calculates the area of the rectangle.
 public int area()
 {
  return length*breadth;
 }

Now, whenever a user uses the above method he will just get the area not the way how it is calculated. We can consider an example of println() method we just know that it is used for printing and we don't know how it prints the data.
   I have written a blog in detail you can see the below link for more info
abstraction vs encapsulation


Is it possible to play a external (e.g. from youtube) flash-video with html5 on my site?

Question: I would like to use my site as a "gateway" for watching flash-videos in HTMl5.. Is this possible? What are the requirements?
Comment: First requirement: make sure you are not violating the terms of service for those sites.
Answer: There's an app that already does this called skyfire.
For example, on the iPhone, pulls out requests to flash video files and converts them server-side into HTML5 and re-embeds them into the page.
I haven't tried it, as its reviews are a bit rubbish at the moment (supposedly only works on certain websites), but its a proof of concept that it can be done.


Conduits - multiple "attempts" into one Source

Question: I am trying to do the following:
sourceIRC
  :: (MonadBaseControl IO m, MonadLogger m)
  => NetworkSettings
  -> Producer (ConnectionT m) Message
sourceIRC networkSettings = do
  withConnectionForever networkSettings $ \socket -> do
    bracket (liftBase $ Network.socketToHandle socket IO.ReadWriteMode)
            (\handle -> liftBase $ IO.hClose handle)
            (\handle -> do
               mvar <- newMVar False
               bracket (fork $ do
                          threadDelay 5000000
                          _ <- swapMVar mvar True
                          return ())
                       (killThread)
                       (\_ -> runConnectionT handle (sourceHandle handle))
               takeMVar mvar)

As you can see, I am trying to create a Producer in terms of a primitive withConnectionForever.  That primitive is of type:
withConnectionForever
  :: (MonadBaseControl IO m, MonadLogger m)
  => NetworkSettings
  -> (Network.Socket -> m Bool)
  -> m ()

As you can imagine, I am getting an error message on compilation!  It is:
Haskell/IRC.hs:128:54:
    Couldn't match expected type `ConnectionT m0 a0'
                with actual type `ConduitM i0 ByteString.ByteString m1 ()'
    In the return type of a call of `sourceHandle'
    In the second argument of `runConnectionT', namely
      `(sourceHandle handle)'
    In the expression: runConnectionT handle (sourceHandle handle)

Now, I know that the type of the call to withConnectionForever is not obviously a conduit, but I had hoped that it could manage to be one, by virtue of the fact that a conduit is also a monad and withConnectionForever uses a free monad instead of a hardcoded one.  My understanding of what the message is trying to communicate is that that's not happening, and I'd like to know why and what I can do about it.
Here, for completeness, is the source of the primitive:
withConnectionForever
  :: (MonadBaseControl IO m, MonadLogger m)
  => NetworkSettings
  -> (Network.Socket -> m Bool)
  -> m ()
withConnectionForever networkSettings action = do
  let loop nFailures = do
        maybeSocket <- newConnection networkSettings
        case maybeSocket of
          Nothing -> return ()
          Just socket -> do
            terminatedNormally <- action socket
            if terminatedNormally
              then loop 0
              else do
                exponentTwiddle <- liftBase $ Random.randomRIO (0, 100)
                let exponent =
                      1.25 + fromIntegral (exponentTwiddle - 50) / 100.0
                    delay = floor $ 1000000.0 *
                      ((0.5 ** (fromIntegral nFailures * negate exponent))
                       - 1.0 :: Double)
                $(logInfo) (Text.concat
                  ["Abnormal disconnection from the network ",
                   networkSettingsName networkSettings,
                   "; pausing attempts for ",
                   Text.pack $ show $ fromIntegral delay / 1000000.0,
                   " seconds..."])
                liftBase $ threadDelay delay
                loop (nFailures + 1)
  loop 0

I'd really prefer not to rewrite the primitive, unless it can be done in minimally invasive fashion, but I suppose that's on the table.
Thanks in advance!
Comment: Just to clarify what `withConnectionForever` is doing, it makes one network connection at a time, over and over, and calls the provided monadic action with each socket in turn.  (Of course, it has logic to back off time-wise, so that it doesn't hammer a server!)
Answer: The relevant thing to do was
(\_ -> transPipe (runConnectionT handle) (sourceHandle handle))

instead of
(\_ -> runConnectionT handle (sourceHandle handle))

Thanks for your time! :D


Lens and plane mirror: inverted or not?

Question:
In a situation like this, I understood that the focal length is half of that of the original lens. However, I don't know whether its image is inverted or not. In this situation, will the image be inverted?
Comment: Check it yourself, you only have to take a point above O. Of course you cannot tell if an image is inverted if it is only one point, a point is self.-symmetric. You need two points to know if it is inverted or not
Answer: The image will be inverted. You can think this combination as concave mirror. The beam reflected from the mirror will be converging spherical wave same as concave mirror (ideally).

Lens and plane mirror: inverted or not?


Which is more effective, TLP or CPUfreq?

Question: Which is more effective? TLP or CPUfreq?
Do both have exactly the same function?
What would possibly happen if I installed both?
Would it cause conflict that could significantly reduce the laptop performance?
Cheers.
Answer: CPUfreq is a tool to control frequency scaling and may be used to limit power dissipation.
TLP is a complete power saving tool that covers frequency scaling settings too, so no need to use CPUfreq when TLP is installed.
Both tools do not conflict as long as you do not use frequency scaling settings in TLP.
Comment: Thank you. It's made my knowledge of ubuntu 14.04 better.
Comment: Actually, in the current versions cpufreqd will override TLP settings like the scaling governor or min/max frequencies, based on its own configuration; so it's not a good idea to run both, and TLP should be ideal choice as it is a lot more powerful/capable.
Answer: Depends on what you need done. If it is for increasing battery usage then I would use TLP.  If you want to reduce temperature then I would use CPUfreq on power saving setting and also dim your monitor brightness.  TLP has many different settings in it.  You will have to read up on all the settings for TLP.  I believe that you can use both together.
Comment: TLP can also control cpu frequencies to control overheating ... My guess is that you should choose for one of those in order to avoid conflicts ...
Comment: What is the difference between extending battery life and reducing heat production? Isn't it the same thing, since virtually all energy is lost to heat? Your answer seems to contradict itself.


what is the canon 18-55mm IS lens good for?

Question: is the canon 18-15mm lens good for self portraits and nature pictures {trees, leaves, DETAILED rain or snow} ?
Answer: An 18-55mm lens is a wide angle to wider side of standard zoom lens.  It's a little wide for most portrait work, though it could do full body portraits alright on an APS-c camera (which you most likely have given the lens model that was included).  It should be able to do any wide angle landscape work alright, but will be limited when it comes to zooming in on any scenery that is in the distance.
As for self-portraits, your best bet there is a lens that is good for normal portraits and then using a tripod and remote trigger or timer.
Also, for photos of rain or snow, you need to take care to protect the camera from the elements.  If both your camera and your lens aren't weather sealed, then exposure to moisture or excessive dust isn't good for the camera.


Conditional zonal statistics

Question: I have often used the Zonal Statistics plugin to calculate the mean pixel value of a raster. However, this time I have an additional Boolean (pixels are equal either to 1 or to 0) raster, which is overlapping with the other. I would like to calculate some kind of "conditional mean" of the former raster, i.e. the mean for those pixels which in the latter raster are equal to 0 and to 1. Can anyone suggest an approach? Is maybe R more appropriate that the the GRASS-GIS environment for doing so?
Answer: In GRASS-GIS you can do it quite easily.
Assuming your binary raster with 1/0 value is named 'my_binary_raster', and the other you want to compute the mean value is named 'base_raster'.
Don't forget to define your Computational region correctly !
<code># Compute basic statistics on the base_raster, for each zones of the binary
g.region raster=base_raster
r.univar map=base_raster zones=my_binary_raster
</code>
It will return mean and a lot of other statistics.
https://grass.osgeo.org/grass74/manuals/g.region.html
https://grass.osgeo.org/grass75/manuals/r.univar.html

Conditional zonal statistics


Does it make sense to say "It beggared belief of the most astonishing nature"?

Question: Basically, I've been trying to find out whether saying "What he said beggared belief of the most astonishing nature" makes sense. I believe it doesn't as the phrase "beggars belief" already indicates that the object which beggars belief is very astonishing and surprising. However, I thought I would ask this just to make sure.
Comment: 'of the most astonishing nature' is an adjectival not an adverbial, so this is either ungrammatical or semantically very suspect. 'Belief of the most astonishing nature' is unusual enough, but 'beggar belief' is a fixed idiom not accepting adjectives.
Answer: It makes sense but it would be entirely redundant.
Instead I would just say, "It begged for belief of the most astonishing nature."
Comment: But I'd interpret "*It begged for belief of the most astonishing nature*" as meaning, "It was so unbelievable that in order to believe in it, you'd have to have a truly astounding level of faith in it."   Whereas I would guess OP's statement is intended to mean, "It was so astounding that I almost couldn't believe it." - in more of a hyperbolic way.
Comment: *Beggared belief* (which is idiomatic) is not at all the same as *beg for belief* (which is not).


Band structure calculation

Question: I want to do band structure calculation of Magnesium silicide for GGA  in VASP. Can anyone please help how to do this by setting initial INCAR tags and KPOINTS file?
Thanks!
Answer: I assume your structure is relaxed.

The 1st step: self-consistent calculation to obtain converged charge density (uniform K mesh).

The 2nd step: non-self-consistent calculation to obtain the eigenvalue along a high symmetry path by reading previous converged charge density.

PS: you can generate the high symmetry path with VASPKIT.
Hope it helps.
Comment: @Shalini: You accepted the answer, so why don't you upvote it? Your quesiton might have been featured on the network-wide "hot network questions" since Jack answered it so quickly, but this only happens if the answer has enough upvotes. I'm surprised I'm the only one that upvoted this!
Answer: First, the lattice optimization is performed, and then the atomic position is optimized. After the stable position is obtained, the static calculation can be performed, and then the k-point path is set to obtain the energy band.

Band structure calculation


Desktop translation tool

Question: I am a journalist whose primary job is to translate articles from Russian to English language. Basically what I need is something that watches clipboard too & (via a click or something)auto translate them to some pre-set language (in my case Russian » English).
Comment: There's a google-translate for desktop that is java powered, but it requires a google-api key.  Just something worth thinking about.
Answer: This project looks interesting - try Dual Clip Translator: http://sourceforge.net/projects/dcliptranslator/
It's "powered by Google", so I bet it will do Russian to English.
The only downside to this program is that there are no DEB's or RPM's. Look for some documentation to find out how to use it. My suspicion is that Linux users must compile from source.
Comment: Well it looks interesting under windows not linux, no GUI here :(
Answer: Why won't you use translate.google.com for the translation? You can also install "Auto-Translate" extension for Google Chrome if you want to translate selected text in the browser: https://chrome.google.com/webstore/detail/auto-translate/obgoiaeapddkeekbocomnjlckbbfapmk
And why Fedora in Ubuntu forums? :)
Comment: Because there  is an official fedora tag here
Answer: Ther's an Ubuntu based distribution called tuxtrans especially designed for translators.  If you don't want to install a new distro and multi-boot, other options include running a VM, Booting the ISO live, and if you want to roll your own a look at the included software and a bit of research should get you there.
Answer: While working with multilanguage gitbooks for a while I came across this Google Translate extension for vscode.
When I select some text in the editor and hit the shortcut keys the selected text is translated into the target language. Any language! That easy!

Desktop translation tool


Questions about Kosterlitz–Thouless (KT) transition

Question: Why we extend $\theta$ from $(0,2\pi)$ to $(-\infty, \infty)$? I mean we cannot measure $\theta$ in experiment, can we?
Secondly,the feature of vortex solution (at least in KT transition) can be summarized as the following: have singularity and multi-valued.
I'm wondering is this the definition of vortex in mathematics? And why do we say that vortex is topological effect? I cannot see any topology from these two features.
Answer: It is not fully clear what is meant by $\theta$ - assuming that it is the angle between spins, extending it from $(0,2\pi)$ to $(-\infty, +\infty)$ is a matter of convenience: it does not change anything physically, as enters the Hamiltonian only via trigonometric functions; on the other hand, it may significantly simplify calculations - both analytical and numerical, since one does not have to take care of taking module of $\theta$ every time it exceeds $2\pi$ or falls below $0$.
Vortex may mean different things in different fields. Thus, the definition used in this or that branch of mathematics might be an unreliable guideline. Yet, singularities definitely have topological meaning. The simplest examples come from the complex analysis:

$1/z$ is a singularity and integrating around it results in a finite residue, unlike integration along a closed contour not enclosing this point.
$\log z = \log r + i\phi + 2\pi n $ is a multi-valued function: going around the point $z=0$ brings us to a sheet with different $n$.
Answer: We extend $\theta$ from $(0, 2 \pi)$ to $(-\infty, +\infty)$ exactly because it makes it possible to see the multi-valued nature of $\theta$.
Imagine a simple vortex with the associated complex field $\psi(r, \varphi) = |\psi(r, \varphi)| e^{i \theta(r, \varphi)} = r e^{i \varphi}$.
In that case, $\psi(r=1, \varphi=0) = 1$, but what about $\theta$? In principle, you could choose $\theta = 0$ (and if you would restrict $\theta$ from $0$ to $2\pi$ that would be the only choice). But if you allow $\theta$ to run between $-\infty$ to $+\infty$, and you want $\theta(r, \phi)$ to be locally smooth (continuous), $\theta$ has to be multivalued.
This is simply because if you want $\theta$ to be continuous, then you need to have $\theta(r, \varphi + d\varphi) = \theta(r, \varphi) + d\varphi$ (you cannot "jump" by $2 \pi$ at once). But in that case, it is easy to see that you must have "$\theta(r, 2\pi) = \theta(r, 0) + 2\pi = \theta(r, 0)$" so $\theta$ is multivalued. Of course, you would still be able to see this with $\theta \in (0, 2 \pi)$ by integrating the change in $\theta$ along a circle, but that would require extra-care (especially at the points where $\theta$ is discontinuous).

Now, why is this topological behavior? One way to understand "topological" is to say that the property is robust to small deformations (probably not a rigourous definition, but that's the idea). This is to say that for any infinitesimal change $d \psi$ in the wavefunction $\psi$, some property of the new wavefunction remains unchanged. Here such a property would be for instance the winding number, which is a fancy way of saying "by how many multiples of $2 \pi$ does $\theta$ change when going in a circle around some point" (here, for any circle centered around $r=0$, the winding number would be $+1$). I think (but I am not an expert), that this is equivalent to saying that the values of the winding number/topological number are isolated (for any winding number $\omega_1$, there exists $\epsilon > 0$ such that there is no winding number $\omega_2 \neq \omega_1$ in the interval $(\omega_1 - \epsilon, \omega_1 + \epsilon)$.
For the winding number, this is obviously the case, as by definition it takes values over the integers $\mathbb{Z}$. Intuitively, you can convince yourself that an infinitesimal change in a continuous field $\psi$ cannot possibly result in a discrete jump for a quantity that can be expressed as a function of the field.
As for why a vortex is always associated with a singularity (which is to say that if the winding number over a closed curve is non-zero, there must be a point inside the region delimited by the curve for which $\psi(r_{\mathrm{singularity}}, \varphi_{\mathrm{singularity}}) = 0$, this is also a consequence of the "robustness" of the phase winding. Just as the same way an infinitesimal change in $\psi$ cannot change the winding number, an infinitesimal deformation of the curve cannot change the winding number. This is true as long as $\psi \neq 0$, because then $\theta$ is ill-defined.
So imagine that there is no point inside your curve for which $\psi = 0$. You could continuously shrink the curve without changing the winding number because everything is continuous. This would  mean that, as the curve becomes smaller and smaller, $\theta$ would still take every values from $0$ to $2 \pi$ at least once along the curve. But if you keep shrinking the curve, it will eventually become a single point $(r, \varphi)$. But what is the value of $\theta$ here? If $\psi \neq 0$, then $\theta$ is well-definded an unique up to a multiple of $2 \pi$. At the same time, because the point is defined as the limit of the shrinking curve, and the winding number was non-zero all along the shrinking process, $\theta$ must also take every value between $0$ and $2 \pi$ at a single point, which is clearly impossible. The only way out of this situation is to relax the assumption that $\psi \neq 0$ inside the initial curve. Then there is a point for which $\theta$ is ill-defined and even an infinitesimal deformation of the curve can lead to a discrete change in winding number if the curve happens to cross the point for which $\psi = 0$.
Comment: Thank you very much for explanation!


How to show a block on pages with a path like '/member/*' but not 'member/*/likes'?

Question: I want to show a block on a member's profile page (member/*) but not on member/*/likes.
It doesn't seem I can do this without PHP in the block settings, does it?
Answer: Try restricting visibility to this URI:
member/*/

(trailing slash!)
Alternatively, you can download the Context module and position the block using a new context, and negate the member/*/likes path in your context configuration.
Comment: I had tried member/*/ but then it wouldn't show on a member/user123 page
Comment: Grab the Context module - it'll do what you're after easily enough!
Answer: There is a way to answer your question without PHP in the block settings  (as in your question): you can use the Rules block visibility module for this (assuming your question is about D7). Here is a quote from its project page:

The Rules block visibility module allows Rules components to be used to control block visibility. This provides Drupal administrators and developers extreme flexibility in controlling when blocks should be displayed on their websites, in addition to the default visibility options provided by Drupal.
The general idea is that if you can do it with Rules, you can use it to control block visibility, so the possibilities are limitless.
Need to show a block only for users registered more than a month ago?
Perhaps you have a block that must be shown only between 8am-5pm on weekdays?
What about displaying or hiding a block based on current weather conditions?
All of this can be done by using Rules block visibility.

With that, and as per the "if you can do it with Rules, you can use it to control block visibility" above, you've reduced your question to making Rules "check the path of the current page" (so that the block is only shown on your pages with a path that starts with "members/", but not on those pages that have a path ending with "/likes").
For an illustration of how to use this module, refer to my answer to "How to stop a Views block from displaying to admins, such as user/1?". It includes a Rules Component (in Rules export format), which you should replace by this variation of it to make it match your specific question):
{ "rules_block_visibility_show_on_selected_member_pages" : {
    "LABEL" : "Show block on selected member pages",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "module" : { "label" : "Module", "type" : "text" },
      "delta" : { "label" : "Delta", "type" : "text" },
      "result" : { "label" : "Result", "type" : "boolean", "parameter" : false }
    },
    "IF" : [
      { "AND" : [
          { "text_matches" : {
              "text" : [ "site:current-page:path" ],
              "match" : "members\/",
              "operation" : "starts"
            }
          },
          { "NOT text_matches" : {
              "text" : [ "site:current-page:path" ],
              "match" : "\/likes",
              "operation" : "ends"
            }
          }
        ]
      }
    ],
    "DO" : [ { "data_set" : { "data" : [ "result" ], "value" : "1" } } ],
    "PROVIDES VARIABLES" : [ "result" ]
  }
}

Also, if you'd replace the 2nd Rules Condition in the above Rules Component with something using an appropriate regular expression, you could even further refine it, to check for something like "members/uid/likes", whereas uid corresponds with some user's uid, and so that the block would be shown anyway on pages with a path like "members/with/lots/of/likes".


A term for ads masquerading as independent journalism

Question: There's a Russian word "джинса" (here's an article in Russian if one wonders) for articles that feel like ads (and most probably are de-facto hidden ads indeed) but not officially marked as such. My question is, apart from the term "hidden ad", is there a specific English term for this?
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/108141/discussion-on-question-by-shabunc-a-term-for-ads-masquerading-as-independent-jou).
Answer: A newspaper or magazine article, which is written in the form of an editorial article, but is actually promoting a product is often called an advertorial, but some marketing/advertising people prefer the term "Native Advertising" and attempt to create a distinction between this and advertorials, though to me the distinction is vague at best.
Often magazines will have ads that are created by third-parties which are deliberately designed to resemble the appearance of a legitimate news article, by using layout and fonts similar to the magazine's own. Often they are required to provide some sort of disclaimer that it's actually an ad, but the disclaimer is generally small and easily missed. Some magazines actually cooperate in creating such advertising, even doing the layout. Sometimes an actual article or editorial is written by a staff writer, but simply contains promotional content. This is very common with local area magazines or TV news programs.
Answer: If I read your question correctly, you are talking about print or online media that  features the written word, because you've used the term "article".
I worked in advertising for more than 25 years. "Infomercial" is used for broadcast media -- audio or video.
The term most often used for media featuring the written word is "advertorial".  For example, special sections in newspapers that are sponsored by corporations or regional tourism boards are advertorials.
Answer: Sponsored Content is often used for a news story partly or wholly paid for by the seller.  The following promotes the use of sponsored content. https://www.activecampaign.com/blog/sponsored-content. There seems to be no single general word, only phrases.
Sponsored Content: What You Need to Know (and 9 Examples!)
SEPTEMBER 30, 2019
ERNIE SANTERALLI
"Paid post"
"Presented by"
"Sponsored by"
"Partnered with"
"Promoted"
"Affiliated with"
"Powered by"
. . . These phrases are indicators of sponsored content. They mean that a brand has spent some money to get some content in front of you.
Comment: Those phrases are good to know in the context, but the question asked about *unmarked* materials and those phrases are supposed to mark the content (although potentially in a subtle way).
Comment: It should be noted that some of the terms listed are deliberately ambiguous between advertising masquerading as journalism (i.e. the cases in which the **content** is determined by the business that pays for it), and the cases in which genuine journalism is funded by some business, without the business dictating the content.
Answer: If the article is presented as being from the public or expressing a populist opinion, you might also hear the term astroturf or astroturfing applied. These terms are sometimes capitalized, as AstroTurf is a brand name of artifical grass (as a play on the term "grassroots" to mean a local or populist movement/agenda).
Wikipedia's article on astroturfing describes it as "masking the sponsors":

Astroturfing is the practice of masking the sponsors of a message or organization (e.g., political, advertising, religious or public relations) to make it appear as though it originates from and is supported by grassroots participants.

From Wiktionary's page on astroturf (adj):

Of a group created by a larger organisation (especially a corporation or political party), but presenting itself as a grassroots organisation.

For reference, from Wiktionary's page on grassroots (adj):

Of, or relating to people or society at the local level, particularly in politics, social movements, etc.; of the grass roots.

In this sense "astroturfing" is the generic term that can be applied to legal and illegal advertising content that is not clearly marked, where "advertorial" or "sponsored content" are labels generally applied by the publishers to disclose that sponsorship and avoid legal repercussions.
Answer: We have the term infomercial (coined as a combination of "information" and "commercial").

infomercial NOUN
  North American
  An advertising film which promotes a product in an informative and supposedly objective style.
LEXICO
Comment: *Infomercial* captures the idea that the OP has in mind, but is suitable only for the media for which *commercial* would otherwise be used, i.e. principally for television. As the quoted definition, somewhat quaintly, puts it, an infomercial is a 'film'. The OP, however, seems to be seeking a term for such hidden advertising in any medium, including, for example, print.
Answer: If you speak of editorial independence the expression often used to indicate both insufficient disclosure of interests or actual incentive payments is "Chequebook Journalism".
Answer: I like the term "Checkbook Journalism" or "Prostituted Journalism". Journalism should be about the truth. Most pieces are now just the opinion of whoever is paying the journalist. Pay can be in the from of advertising or a paycheck. Sad but true, unless we are independently wealthy, but we have to serve somebody. Being your own man as Kipling said is a hard business. So if you can buy a CNN or a journalist you can have your opinion presented as the "Truth". The rest of us will be limited in our own sources for the truth.
Don M
Answer: "subliminal advertising"

Subliminal advertising tries to influence people without them being aware of it, for example by showing messages for such a short time that people read them without realizing that they have done so.  CD

subliminal - not recognized or understood by the conscious mind, but still having an influence on it. CD

Examples:

This newspaper was full of subliminal messages about the new product
His speech was full of subliminal prejudice, which will surely influence some voters.

Dictionary.com defines subliminal message as a technique used in marKeting and other media to influence people without their being aware of what the messenger is doing.  This may involve the use of split second flashes of text, hidden images, or subtle cues that affect the audience at a level below conscious awareness.
Comment: The phrase *subliminal advertising*, used literally, stands for the advertising that is below the threshold of perception, so that one is not conscious of it **at all**, as is the case with the split-second images, mentioned in the last sentence of the answer. What the OP is asking about are, however, the materials that the audience does consciously perceive; it's just the materials do not identify themselves as advertisements. Using the phrase for what the OP has in mind would be, at best, metaphorical, and possibly misleading, given that the phrase is often used in its literal sense.
Comment: @Centaurus That dictionary definition you included specifically states "This may involve the use of split second flashes of text, hidden images, or subtle cues that affect the audience at a level below conscious awareness." Subliminal doesn't just mean deceptive.
Comment: @jsw29  You're entitled to your opinion, but I still think "subliminal advertising" fits the bill perfectly.
Comment: Your example of "This newspaper was full of subliminal messages about the new product" wouldn't be ads *masquerading* as journalism, it would be ads hidden in real journalism (or whatever other content).  The *masquerading as journalism* case would be where the subject of the article is fairly directly the product itself, and it's just pretending to be unbiased about how great it is.


measuring $n\ 2$-planes in $\mathbb{R}^{2n}$

Question: Given $n$ vectors $v_1, \ldots, v_n$ in $\mathbb{R}^n$ of course we all know at least one measure for their relative configuration: $|v_1 \wedge\ldots \wedge v_n|$. Now suppose one were given $n$ pairs $(e_1,f_1), \ldots, (e_n,f_n)$ in $\mathbb{R}^{2n}$---then what could be a meaningful measure for their relative configuration? Suppose moreover we require this measure to be $geometric$ ie. having fixed, say a full rank lattice $\Gamma$ in $\mathbb{R}^{2n}$ what could be a meaningful measure for the relative configuration of n 2-planes $\pi_1, \ldots, \pi_n$ in $\mathbb{R}^{2n}$?
Comment: The $n$-volume in $\Lambda^2\mathbb R^{2n}$ of the parallelopiped with sides $e_i\wedge f_i$?
Comment: Nothing is lost in supposing that $e_1, \ldots f_n$ span a volume 1 parallelopiped. Then their n-volume in $\wedge^2$ will correspond to $|e_1 \wedge \ldots \wedge f_n|$ (ie =1). For fun, in light of the identity dim$Gr_{2,2n}=(2n-2).2=(4n-4).1=$dim$Gr_{1, 4n-3}$ we might try to find a suitable embedding from the Grassmannian of 2-planes in $\mathbb{R}^{2n}$ into $\mathbb{R}P^{4n-3}$ and then take the volume form there. But i don't think this is to be taken seriously.
Answer: I believe the wedge-based measure you mentioned for the $\mathbb{R}^n$ case works here as well.  Assuming each of the $e_i$ and $f_i$ are in $\mathbb{R}^{2n}$, then $\pi_i := e_i \wedge f_i$ is a 2-vector (a weighted specification of a 2-plane in $\mathbb{R}^{2n}$).  This wedge quantity will be zero iff $e_i$ and $f_i$ are linearly dependent.
Wedging together all of the $\pi_i$ will give a $2n$-vector having analogous geometric meaning as the 2-vector.  It will zero iff $X := {e_1, \dots, e_n, f_1, \dots, f_n}$ is a linearly dependent set.  Then $|e_1 \wedge f_1 \wedge \dots \wedge e_n \wedge f_n|$ is the norm you are looking for.  The geometric quantity this measures should be the signed volume of the simplex spanned by the vectors in $X$ (there may be a normalizing factor, something like $n!$, depending on convention).
This is certainly a natural measure of such objects, but probably not the only one.
Comment: What I want from this question is a measure which recognizes that "configurations of $2n$ lines in $\mathbb{R}^{2n}$" is different than "configurations of n 2-planes". The volume $|e_1 \wedge \ldots \wedge f_n|$ is insensitive to configurations of 2-planes. The point is to find a form or measure which isn't.
Comment: In my own particular situation this measure is not interesting because all the $e_i, f_i$ generate a unimodular lattice----hence their wedge product is 1. This then does nothing to distinguish them.
Answer: This is more of a musing than an answer, but maybe it can be useful.
There is a nice way to think about the Grassmannians of 2-planes in $\mathbb{R}^n$; there is an isomorphism between $Gr(2, n)$ and the projectivized light cone in $\mathbb{C}^n$.  Here is how it works:  start with your 2-plane $P$ in $\mathbb{R}^n$ and pick any two perpendicular vectors $v$, $w$ of equal norm which span $P$.  From those two real vectors, form the complex vector $q = v + i w$.  Letting $\cdot$ denote the standard (not hermitian!) dot product, the conditions on $v$ and $w$ imply that $q \cdot q = 0$, so $q$ is a point on the light cone in $\mathbb{C}^n$.  A different choice of spanning vectors will cause $q$ to be multiplied by some complex factor $z$, so $q$ is well-defined up to complex scalars.
From this perspective you are looking for invariants of configurations of $n$ points on the projective light cone in $\mathbb{C}^{2n}$ (perhaps modulo the action of $O(2n)$ or some other group).  This can be cranked out more or less mechanically...
Comment: @Noonan: well I don't know how to crank anything out of this. For one, i don't see how this embedding recognizes 2-planes $P,P'$ which are not transverse. And even if I had some idea of how points on the projectivized light cone lay, I'm unaware of any potential invariants. So I'm not sure what to do with this. Thanks all the same though.
Answer: This is not a terribly informed answer -- I have just become aware of the subject material (mass and comass) and don't fully understand the geometric significance.  Hopefully it will be useful though.
Take a look at http://www.encyclopediaofmath.org/index.php/Mass_and_co-mass -- it gives a different norm than the one already mentioned, and in fact has an inequality involving the aforementioned norm.  Reference: Herbert Federer, Geometric Measure Theory, pg 38.
Comment: Well, here's a special situation: say we have a lattice L and an integral unimodular symplectic form \omega defined on L. Moreover say we have a symplectic basis e_1, .., e_n, f_1, .., f_n \in L. Then each pair e_i, f_i span a rational symplectic subspace P_i of the lattice. As measure on P_i we can take the eccentricity k_i of the convex hull of {e_i, f_i} (an ellipse). This describes an n-fold continuous measure {k_1, ..., k_n} on the symplectic bases (e_1, ..., f_n). But again, this a special special little situation.


Add NOT NULL constraint to large table without table scan

Question: Trying to add a NOT NULL constraint to a table with 1 billion rows. I cannot afford a table lock for more than a couple of seconds. Is there a way to prevent a full table scan during the alter table statement? I created an index on the column hoping it would be used but that doesn't seem to work. May be a check constraint? Other options? Thank you!
Comment: :) collecting real time data but only for a very small part of the universe.
Comment: As of PG 12, we now have the ability to concurrently add NOT NULL! https://dba.stackexchange.com/a/268128/12659
Comment: Just thoughts... That's weird it uses full table scan if you have an index. If it would be using the index, as index lookup for a non-existing value should be lighting fast... so the lock will not be a problem.
Comment: What on earth are you running that you cannot afford a table lock for more than a couple of seconds?The Universe software?
Comment: (btw, the question that this question is marked a duplicate of is actually about something else - if an admin sees this, could you undo that so that a real answer for PG 12+ can be added)
Answer:
Is there a way to prevent a full table scan during the alter table statement?

At this time there is no supported, safe way to do that with PostgreSQL.
Some kind of ALTER TABLE ... ADD CONSTRAINT ... CONCURRENTLY would be nice, but nobody's implemented it. Same with the alternative of adding a NOT VALID constraint that still affects new rows, and that you then VALIDATE later - it'd be good, and it's something everyone knows is needed but nobody's had the time or funding to add yet.
In theory you could directly modify the system catalogs to add the constraint if you know it is true and valid. In practice, well, it's generally not a great idea.
So no, there isn't really a way.
Comment: For the record: The `NOT VALID` feature has since been added for `CHECK` and `FK` constraints. Related: http://dba.stackexchange.com/questions/75613/disable-all-constraints-and-table-checks-while-restoring-a-dump/75635#75635 or http://dba.stackexchange.com/questions/158499/postgres-how-is-set-not-null-more-efficient-than-check-constraint
Comment: Thank you! In case somebody wants to implement: While adding constraints concurrently would be fantastic, just looking at indexes before scanning the entire table would already be very helpful.
Comment: You still have to `VALIDATE` the constraint later though, there's no way to force it to be considered valid. You can, however, twiddle the catalogs to lie about that much more easily than creating a constraint from whole cloth correctly.
Comment: As of PG 12, we now have the ability to concurrently add NOT NULL! https://dba.stackexchange.com/a/268128/12659
Comment: In the off chance that the column on which you want to add 'not null' is unique, you might be able to use the technique described here: [http://stackoverflow.com/a/20006502](http://stackoverflow.com/a/20006502).
Answer: One potential alternative is to create a check constraint using NOT VALID, then validating the check constraint later. This method requires holding an ACCESS EXCLUSIVE lock only for the duration to create the constraint, which should be on the order of milliseconds. The VALIDATE command will perform a time-consuming full table scan to validate the constraint, but it holds a less restrictive SHARE UPDATE EXCLUSIVE lock.
As for trade-offs, I've been unable to find any documentation that mentions internal mechanism differences between a standard NOT NULL constraint and a check constraint that validates a column is not null. I recall digging up a forum post that eluded to a potential performance difference, but have lost the link, so this is unconfirmed.
ALTER TABLE table ADD CONSTRAINT table_value_not_null_check CHECK (value IS NOT NULL) NOT VALID;

ALTER TABLE table VALIDATE CONSTRAINT table_value_not_null_check;

Sources:
https://www.postgresql.org/docs/9.4/static/sql-altertable.html
https://www.postgresql.org/docs/9.4/static/explicit-locking.html
Comment: The benchmark discussing the difference between a standard `NOT NULL` constraint and a check constraint is here: https://dba.stackexchange.com/questions/158499/postgres-how-is-set-not-null-more-efficient-than-check-constraint
Comment: You can also convert the CHECK constraint to a real NOT NULL afterwards without locking the table for a large amount of time since PG 12: https://dba.stackexchange.com/a/268128/137516