Count the number of suggestions in a Google Docs

Question: Similar to this question, I would like to count the number of suggestions (not comments) a Google Docs has. The first answer of that question doesn't work for resolved comments, and neither works for suggestions. I would like to see how many total suggestions and/or comments a Google Doc received, all of which are now resolved.
Answer: Figured out an answer!
On a web browser, go to the Docs file. Press the comment icon to open the comments and suggestions panel; looks like this:

Open Developer Tools (usually F12). In console, type the following: <code>$('#docos-stream-view').childElementCount</code>. The number that pops out is the total number of suggestions + comments (replies not counted).
Explanation
The command above is basically selecting the comments panel (using jQuery) and counting the number of HTML DIVs it contains. This is the number of comments/suggestions!
Comment: if people are looking to filter out the resolved comments, click the 'all types' drop down and select open. the js will still work to output the number of open comments you have


vacuum compatible compact CCD camera

Question:
I need a CCD camera that can be used inside vacuum. Not the flange mounted types used in XUV-X-ray applications, but small compact preferably less than 20 mm dia housing. Does anyone have experience in using standard CCD cameras in vacuum, or can anyone suggest possible sources/references?
Is it possible to set electronic exposure (aka electronic shutter) time, remotely through software, in a USB based CCD camera?
Answer: I don't see too many issues using a standard USB camera in a vacuum. Your two largest issues are likely to be heat dissipation, and outgassing from the camera components.
Depending on how high a vacuum you need, you may need to package the camera in a hermetic container. There is almost inevitably going to be at least a small amount of soldering flux/VOCs left on the PCBs from production, and it will outgas when you pump the system down.
If you have sufficient pump capacity, or don't need extremely high vacuum, it shouldn't be too much trouble.
You could also try removing all the plastic from the camera, and baking the PCB assembly at a low temperature to speed up the out-gassing (~100°C?).
Second, at least some of the USB-cameras I have used do dissipate a fair amount of power, so depending on the camera, you may have localized heating issues due to the lack of convection cooling. It should be possible to deal with this using proper heat-strapping, though I think it would probably better to just pick a device with low dissipation.
Lastly, you can certainly buy some pretty interesting USB cameras, which do support all sorts of fun things like variable ISO, and variable shutter time. It mostly depends on your budget.

If you don't mind experimenting, I would say go to your local electronics store, and just buy a webcam, and see what happens (and post pictures!).
The hardest part, I think, is probably going to be hermetically sealing the cable feed-through. You can't just stick the cable in a cable gland, as you will get leakage through the cable, both between the strands, and between the individual wires and the sheath. You will need hermetically rated bulkhead connectors.
Comment: Regarding outgassing, any component which contains gas and is tightly sealed and whose walls cannot hold the pressure will simply burst. Capacitors come to mind, but I wonder whether integrated circuits contain gaseous voids? Probably. I'd be concerned about batteries.
Comment: @Kaz - You'd be surprised how well most common components handle even high vacuum. I've put whole computers (admittedly a ultra-low-power AMD Geode based system, but anyways) in vacuum before. The main concern there is hard-disks, the heads of which **require** air for normal operation. Everything else works fine, you just need to worry about heat dissipation.
Comment: I actually even tested some lithium pouch-cells in vacuum once. They looked like little balloons when you pull a vacuum on them, but they didn't rupture. I wouldn't trust them to maintain their capacity afterwards, though.
Answer: I was also looking for a vacuum compatible low cost camera. Then I bumped into a report by S. C. Delaquis of the Albert Einstein Center for Fundamental Physics,
Laboratory for High Energy Physics where they used an off the shelf webcam and made a custom housing for it. You can read it here.
However, their application was vacuum + cryogenic. This means that generating heat was more of a problem to them than actually getting rid of heat which is the case in "normal" vacuum. Maybe if you use a low power webcam (~1 W) you can get a way without cooling or connecting some copper braids to a thermal mass.
By just using a standard viewport window flange and a usb flange/9-pin flange combined with a piece of pipe you can made such housing without any metalwork to be performed.

Image courtesy of S.C. Delaquis [source]

vacuum compatible compact CCD camera


Lost Account/ Wallet

Question: Back in I want to say 2011-2013 I was working and I was tipped by a man who was all excited to show me this new form of currency. I had created an account that he had sent me coins over. Since then I have lost/ switched phones and can't remember the exact app that I had at the time. Is there any way to look up my name and email?
Comment: I feel for you, whatever you were tipped would be worth like 10x now :(. I guess there's no way to retrieve that phone? If you know the guy who tipped you...ask him for his address and search it up in blockchain.info you might be able to find where your address is. Then you just need the password if it was an online app.
Answer: Try the mainstream wallets like Coinbase, blockchain.info, etc and see if they look familiar and try to log in.
The hard part about your situation is that it's kind of the point of the Bitcoin system. Its like cash. So in a essence a few coins fell out of your pocket at the movie theater. It's online cash.
Answer: Two options: if you had an online wallet, maybe you could retrieve your login via e-mail or something; in case you had a software wallet, you would need access to it to retrieve the private key -- still on that second case, if it was a HD wallet (Hierarchical Deterministic) and if you have the 12-word backup you can recover it on the same software (and maybe on a different one that uses the same protocol).
-
TM

Lost Account/ Wallet


Number of Unique Elements After Sampling w. Replacement

Question: Consider the set $N=\{1,\ldots, n\}$. Let $p_n(m,k)$ denote the probability that we have $m$ unique elements from $N$ after $x$ draws (with replacement). As per this post, we explicitly have $$p_n(m,x)=\frac{S_2(x,m) \; n!}{n^x \; (n-m)!},$$ where $S_2(x,m)$ is a Stirling number of the second kind. I have been asked to express $p_n(m,x)$ recursively in terms of $p_n(m,x-1)$ and $p_n(m-1,x-1)$. I have tried playing around with the equation above but I have not gotten any results. Maybe I need to simply condition on something? If that is the case, then I am not seeing it. Thanks in advance for the help.
Answer: Suppose after $x$ draws we have $m$ unique elements.
This implies that after the first $x-1$ draws, we either had $m-1$ unique elements or $m$ unique elements. Can you use these two cases (combined with the appropriate deduction of what the $x$th draw must be in each case) to get an expression for $p(m,x)$?
Comment: I see. After $x-1$ draws if we have $m-1$ unique elements then the chance of drawing a new element is $(n-m+1)/n$. On the other hand, if we already had $m$ unique elements then with $m/n$ probability we still have $m$ elements after a new draw. So $p_n(m,x)=(n-m+1)p_n(m-1,x-1)/n + mp_n(m,x-1)/n$.


France visa refusal

Question: Justification for the purpose and conditions of intended stay was not provided. I was been refused on this basis and I was given appeal in French language to CRRV BP 83699 44036 Nantes CEDEX1 France.  How would I go about this? Thanks.
Comment: What information did you provide regarding the purpose and conditions of your intended stay, and what justification did you provide?
Answer: It is normal that official decisions in Europe contain information where and how to appeal the decision. This information is not a suggestion that you should appeal, it is just there for legal reasons. A new application with better plans and circumstances is probably your best option. You must convince the French officials that you are a genuine tourist and that you will leave again after visiting France.

Make a detailed plan for your trip and calculate how much it costs. Don't forget the "little" things like a cup of coffee or an ice cream, those costs add up.
Compare that to your monthly income after your living expenses at home.

The whole picture must look reasonable to the visa official.

France visa refusal


Mathematica's morphological thinning algorithm

Question: Could anyone cite some papers that describe Mathematica's morphological thinning algorithm?
Comment: At this website there are some references to books: http://homepages.inf.ed.ac.uk/rbf/HIPR2/thin.htm.
Comment: In case you are satisfied with my answer you might consider setting it to "answered" using the check mark. If you think something is still missing in my answer, please let me know.
Answer: Prologue
Some five years ago I have asked exactly this question to the Wolfram support people. Below I have taken their respective answers (one sentence for each Method) but have added a lot of further reading. Finally, in an Add-On I demonstrate my own implementation of Rosenfeld's 1971 variant of a 2D thinning algorithm, in order to let you compare a few methods.
Guo/Hall:
Method -> Morphological implements the algorithm described in:
Lam L, Lee SW, and Suen CY, "Thinning Methodologies - A
Comprehensive Survey," IEEE Transactions on Pattern Analysis and Machine
Intelligence, Vol 14, No. 9, September 1992, page 879, bottom of first
column through top of second column
However, as this paper is a survey, it might be better to use the original reference:
Guo Z and Hall RW: "Parallel Thinning with Two-subiteration Algorithms." Communications of the ACM, Vol. 32, No. 3, March 1989, see section 3 starting on page 360 entitled "A TWO-SUBITERATION THINNING ALGORITHM" (referred to as Algorithm 1 throughout the paper)
Besides, there are further roots cited by Guo and Hall:
Zhang TY and Suen CY: "A Fast Parallel Algorithm for Thinning Digital Patterns." Communications of the ACM, Vol 27, No. 3, March 1984
Lü, HE and Wang PSP: "A Comment on 'A Fast Parallel Algorithm for Thinning Digital Patterns'" Communications of the ACM, Vol 29, No. 3, March 1986
Gonzalez/Woods:
Method -> MedialAxis is described in Gonzalez/Woods "Digital image processing", in a section named like "morphological medial axis by thinning".
In fact, in the first edition from 1992 for the medial axis computation the description is given in 8.1.5 "The Skeleton of a Region", in the second edition from 2001 you find it in under 11.1.5 "Skeletons" (sorry, the first two paragraphs are missing there), in the third edition as of 2010 it is given in 11.1.7 "Skeletons". Let's see where the authors will include it in the upcoming fourth edition :-)
As the copy referenced above was somehow cropped, here is the neighborhood as is defined by Gonzalez/Woods:
{{p9, p2, p3}, {p8, p1, p4}, {p7, p6, p5}}

Anyway, Rafael Gonzalez and Richard Woods cite Harry Blum who originally has proposed the concept of medial axis transform back in 1967 (naming it as "medial axis function - MAF"):
Harry Blum: "A Transformation for Extracting New Descriptors of Shape", in W. Wathen-Dunn (ed.), Proc. Models for the Perception of Speech and Visual Form, pp. 362-380, MIT Press, Cambridge, MA, November 1967.
Since Harry Blum is rather giving an abstract description of the general properties of the MAF and is not proposing a certain computational algorithm to obtain the MAF, and as Gonzalez and Woods do not cite anything else here, we need to assume that the given medial axis algorithm is their original work.
Add-On: Stefanelli/Rosenfeld
I was just thinking if I could please some of you by adding my own implementation of the good old Rosenfeld thinning. It was published decades ago:
Stefanelli R and Rosenfeld A: "Some Parallel Thinning Algorithms for Digital Pictures", Journal of the ACM, Vol. 18, No. 2, April 1971
Clear[Rosenfeld];
Rosenfeld[image_Image, nh_: 8, borders_: "NSEW"] :=
  Module[{imagedata, table, table4, table8, coords, deletions,
    deletionindices, northshift, southshift, eastshift, westshift,
    directionalsequence, check},
   imagedata = ArrayPad[ImageData[image, "Bit"], 1];
   northshift = {-1, 0};
   southshift = {1, 0};
   eastshift = {0, 1};
   westshift = {0, -1};
   directionalsequence = {northshift, southshift, westshift, eastshift};
   directionalsequence =
    directionalsequence[[Flatten[StringPosition["NSEW", #] & /@
         StringCases[borders, RegularExpression["[NSEW]"]], 1][[All, 1]]]];
   table4 =
    IntegerDigits[
     53069725914310846919685767315128399372436785243025614538690558020\
      5726755357445973110133053045854705883358494050138831185007206823686093\
      00909165535, 2, 512];
   table8 =
    IntegerDigits[
     15543186043038566186790018003123690632026825017137796030838268923\
      1709659598404465396940268644806626670319011047096356514674276473698052\
      70924042222591, 2, 512];
   Switch[nh, 4, table = table4, 8, table = table8, _,
    Print["The neighborhood " <> ToString[nh] <>
       " is not permitted, use either 4 or 8 (8 is preset)."];
   ];
   check = {{1}, {1}, {1}, {1}};
   While[Flatten[check] != {},
    Map[Function[ds,  coords = Position[imagedata - RotateLeft[imagedata, ds], 1];
       deletions =
        Map[table[[FromDigits[Flatten[imagedata[[{#[[1]] - 1, #[[1]], #[[1]] + 1},
                     {#[[2]] - 1, #[[2]], #[[2]] + 1}]]], 2] + 1]] &, coords];
       deletionindices = Flatten[Position[deletions, 1]];
       imagedata = ReplacePart[imagedata, coords[[deletionindices]] -> 0];
       check[[1]] = deletionindices;
       check = RotateRight[check, 1];
      ],
      directionalsequence];
   ];
   Image[ArrayPad[imagedata, -1, "Bit"]]
  ];

If you try to copy this code above, please make sure that no \[Times] symbols are being inserted in the huge numbers when pasting into your Mathematica front end.
To be honest, it is not parallelized, to do so, one would have to replace the inner of the two nested Map inside the While statement with ParallelMap, however, the overhead data traffic is too high for typical images. If someone has an advice for a better parallelization, let me know. Also, please note that a single channel binary image is being expected. As you see I am using two different look-up tables to find the simple points in either 4- or 8-neighborhoods.
Some Examples
Let's see how it works:
HighlightImage[#, Rosenfeld@#] &@
 Binarize@
  ColorNegate@
   ImageResize[
    ImagePad[
     Import["http://www.carstylisten.de/img/Leipzig_Skyline_einzeln.jpg"], -1],
    Scaled[0.5]]

Here the variant with a 4-neighborhood (ensuring the skeleton's pixels are always edge-connected):
HighlightImage[#, Rosenfeld[#, 4]] &@
 Binarize@
  ColorNegate@
   ImageResize[
    ImagePad[
     Import["http://www.carstylisten.de/img/Leipzig_Skyline_einzeln.jpg"], -1],
    Scaled[0.5]]

Please compare with Thinning, first using the Guo/Hall variant:
HighlightImage[#, Thinning[#, Method -> "Morphological"]] &@
 Binarize@
  ColorNegate@
   ImageResize[
    ImagePad[
     Import["http://www.carstylisten.de/img/Leipzig_Skyline_einzeln.jpg"], -1],
    Scaled[0.5]]

Finally, here is the Gonzalez/Woods variant
HighlightImage[#, Thinning[#, Method -> "MedialAxis"]] &@
 Binarize@
  ColorNegate@
   ImageResize[
    ImagePad[
     Import["http://www.carstylisten.de/img/Leipzig_Skyline_einzeln.jpg"], -1],
    Scaled[0.5]]

Now it is up to you to decide what do you like best...
Related Question
Has anybody some 3D thinning algorithm implemented in Mathematica?
Comment: Thank you very much for 1. linking to the papers; and 2. using the DOIs.


Pros and cons of using dlls

Question: I wonder about create every game engine module (render, input, sound, etc...) into dlls (renderer.dll, input.dll, etc...). What are pros and cons in your opinion of divide game into set of dlls ? I see only need to write game module in separate dll, to have posibility to create mods.
Comment: Pros and Cons compared to a static library or to no library at all?
Answer: Pros

You can build DLLs separately.
It could be faster to re-build one DLL

Cons

Calling code from DLL is slower
It would be slower to re-build hole project with all DLLs
Function names are visible. It is easier to reverse code that uses dynamic DLLs

I do not see sense to have render.dll and input.dll But some RareUsedJoystick.DLL could be made as loadable module to release memory for those who do not use that RareUsedJoystick
Comment: Have you any sources on this? From my understanding and experience of compiling and linking I would say nothing but the last point is true.
Comment: In huge projects linking is much faster when you use dlls. Also note that it is harder to debug complex types in a dll.
Comment: Static linking may inline functions. It is not possible to inline DLL function because DLL may change in future. It is also a reason why DLL linking is faster. I was saying it would be slower to compile all DLLs separately then compile all code in single EXE
Comment: The compiler/linker can optimize better when linking statically. But that doesn't mean that calling functions is generally slower.
Comment: function in dynamic link library is called slower. Because your code calls function by index in array. It is extra 1-3 operations but many functions are just getter/setters that it self are 1-3 ops. I case of static linking and inlining it could 1 CPU op. Without inlining static lib could use registers to pass function args. In case of DLL. it uses stack to pass args. It takes function address by index in array. There is a lot of extra ops that static linking removes.
Comment: http://stackoverflow.com/questions/1993390/static-linking-vs-dynamic-linking "To address the performance and efficiency issues: it depends."
Comment: @Mr.Beast: That only applies if many processes are using the same library, and I'm not sure it applies to any operating systems using ASLR (which today is all of them). I'd also a priori disbelieve a cache line would survive a context switch into another process anyway (but evidence would convince me otherwise). At best the performance difference is negligible. In the real world I feel comfortable saying you will _never_ see faster (unless you risk actually running out of physical memory).
Answer: Putting code into seperate Windows DLLs sounds promosing in theory, but in practice you should be aware of certain limitations.

You have to declare all your classes and global functions you want to use from outside as "exportable" using
<code>__declspec( dllexport ) class Foo {};
</code>
when building the library. Clients of your DLL must "see" the include like this:
<code>__declspec( dllimport ) class Foo {};
</code>
That is why you see a makro infront of class declarations in DLL headers.
Resources like FILE* pointers can not be shared under all circumstances (different CRTs) between DLLs. That means if you open the file in one DLL, you cannot write to it from the client app or another DLL, nor close it.
http://msdn.microsoft.com/en-us/library/ms235460%28VS.80%29.aspx
Memory management: You cannot allocate memory in the DLL and free it in another DLL or in client application under all circumstances (different CRTs).
Exporting template classes can be a real pain, especially if they use static member variables.

If you just want to reuse your code without recompiling, there is another option, static libraries (.lib). It is precompiled code (as in the DLL) but it is linked into your application and has no such limitations as the ones mentioned above, plus Link Time Code Generation still works with the library code.

Update: As Sean pointed out in the comments, point 2 and 3 can work when using the same CRT version, as the MSDN link in 2 also shows. However, my advice is to design the DLL without relying on it at all, since there are so many cases where it won't work, like using 2 DLLs with different CRT's or compiled with different Visual Studio versions.
Comment: The memory and FILE* claims (2 and 3) are not quite true.  Those problems occur when the DLL uses a different CRT version.  If built with the app itself, this is not a problem.
Comment: @Sean right, in theory. In practice there are many cases where it won't work (see the MSDN link), like DLLs from different VS versions, linking with 2 DLLs with different CRTs, so it's safer to design the DLL to not to rely on it. It's an important limitation to keep in mind and should be listed here. However, I put an update in my answer reflecting your comment, thanks Sean
Comment: I'd argue it's not "just theory." Sure, if you're designing DLLs as standalone components, it's a problem. The original question is about just breaking up a single app into DLLs, which implies that the DLLs are built together at the same time with the same compiler.  This is actually somewhat common in game engines for a variety of reasons (e.g., loading different optimized versions of code for different CPU instruction set variants), and in these cases, it is in practice totally safe to assume those problems won't happen. :)
Comment: It should be also noted that this only applies if you use MSVC. GCC (MinGW) exports everything per default.
Comment: @Mr.Beast Would that be export or import? I'm using MinGW myself. But got rather confused about the default settings for DLLs.
Answer: Most differences are negligible. DLL's are more flexible but make the building process more complex. I would only use DLL's if:

Multiple applications need to access the same functionality. For example if you have separate binaries for a editor and the game itself.
You want yourself or other people be able to replace certain components. For example in Civ IV modders could ship replacement for the game's DLL's to fundamentally change parts of the gameplay.
You want to load them at runtime to allow to extend the application by third party plugins.
Answer: Another advantage is that it can help you structure your code correctly. Any non-logical dependencies between modules will stand out more and it will be more difficult to use such hacks.

Pros and cons of using dlls


A lexicographic objective function

Question: I am trying to solve a multi-objective vehicle routing problem, I want to implement a lexicographic objective function, I have already defined a function for each objective. if someone has an idea of how can implement the lexicographic function. (PS. the code is written in python).
Comment: Are you using Gurobi/CPLEX?
Comment: yes I have the result of the CPLEX,  but I want to compare it with a heuristic I have implemented
Comment: To clarify: you are asking how to implement the objective function in your heuristic, rather than how to implement it using CPLEX, correct? Does you heuristic require a single number as objective value, or is it sufficient to provide a function that lets the heuristic compare two solutions and see which is preferable?
Comment: For the first one correct, for the second yes the heuristic requires a single value but it must have the same representation of the lexicographic function of CPLEX. I need to compare the value of the solution given by the CPLEX  and the one given by the heuristic.
Answer: Let $f(x)=(f_1(x),f_2(x),\dots,f_n(x))$ be a lexicographic objective function, where $f_1(x)$ is more important than $f_2(x)$ which in turn is more important than $f_3(x)$, etc. I'll assume you are solving a minimization problem.
In a mathematical programming solver, such an objective function could be easily implemented as follows. First find the solution $x$, subject to $x\in X$ which scores best on objective $f_1$ (here $X$ is the set of feasible solutions). Next, find the solution $x'$ that scores best on objective f_2, subject to $x'\in X$ and $f_1(x')\leq f_1(x)$. Continue this iterative procedure for every objective function, in descending order of the importance of each objective function.
To implement a heuristic with a lexicographic objective function, there exist different solutions.

Assign a weight $M_i$ to each objective function $i=1,2,\dots,n$, with $M_1\gg M_2 \gg \dots \gg M_n$.You can than solve $f(x)=M_1f_1(x)+M_2f_2(x)+\dots+M_nf_n(x)$. In other words, you simply combine all objective functions into a single weighted objective function.

An example in the context of a vehicle routing problem: $f_1=$ the total number of vehicles needed, $f_2=$ total driving distance of the vehicles. You could minimize $M_1f_1(x)+f_2(x)$, where $M_1$ is an upper bound on the total driving distance (e.g. the sum of the 2 longest edges out of each customer). Alternatively, if you don't want to mimic an exact lexicographic function, you could simply set $M_i=2^{n-i}$ or $M_i=10^{n-i}$.
Note that this kind of objective function has a major disadvantage: many common heuristics, including for instance Simulated Annealing, perform a lot better if the objective function is smooth, i.e. minor changes in the solution result in minor changes in the objective. With this multi-objective approach, a minor change in the solution might incur a big change in the objective function due to the different weights.

Another approach is to implement the Lexicographic property directly into your heuristic: first search for a solution $x$ which scores best on $f_1$. Next, search for the solution $x'$ which scores best on $f_2$, while only accepting moves to solutions that have the same score on $f_1$ as $x$.

It is likely that this approach will get you stuck in a local optima quickly.
References to other approaches can be found in this slide deck.

A lexicographic objective function


Derivation of the Simpson index

Question: I'm interested in the derivation of the Simpson diversity index. I found the normal interpretation of this index, but I'm not able to see what's the "mathematical background" of the formula. I read the original paper of Simpson, but I'm more interested in an easier explanation (my skills in probability theory are more on an undergraduate level). I would appreciate a little help here.
Answer: The "normal" interpretation of the index is that it is an index to measure biodiversity.
Mathematically, the formula is $ D=\sum(n/N)^2$ or  $D=\sum\frac {n(n-1)} {N(N-1)}$
$n$ is the number of a given species and $N$ is the total population. What is being calculated is probability that two randomly selected individuals from a sample belong to the same species.
The bigger the value of D, the more likely they are to be from the same species, hence the  lower the diversity. To fix this problem of counter-intuitiveness $1-D$ is calculated instead.
Comment: Or $1/D$, which is interpretable as the equivalent number of equally common species. Note that Simpson borrowed from Turing and that similar if not identical measures were suggested earlier and later by Gini, Hirschman, Herfindahl, Greenberg, etc. in statistics, economics, linguistics, etc. Even in ecology the discreteness of individual organisms that drives using $n (n -1)$ rather than $n^2$, etc., is not a universal, as abundance may be measured as a fraction or percent rather than a count.
Comment: @Nick Cox I didn't know that. For econ specifically, I think the Gini inequality index is what most(?) people think of when you mention the Gini coefficient. The Gini coefficient though is not really all that similar to the Simpson index, though.
Comment: We've both right. The name Gini has been attached to several quite different measures. It was his fault; he did invent several. Gini coefficients as particularly associated with (e.g.) income inequality are indeed different. But it's true that he suggested $1 - D$ in your notation long before Simpson.
Answer: There are several versions of the Simpson diversity index, as explained in this website.  I will focus here on this version, which I have stated slightly more precisely to clarify what the sum is over:
$$D = \sum_{i=1}^k\frac{n_i(n_i-1)}{N(N-1)}$$
Here $N$ is the total number of individuals within a habitat, and $n_i$ is the number of individuals of the $i$th of $k$ species. Note that, since $N$ is not indexed by $i$, it makes no difference whether the denominator is within the scope of the sum.  We can equally write:
$$D =\frac{\sum_{i=1}^kn_i(n_i-1)}{N(N-1)}$$
The derivation of these formulae is a straightforward application of probability. If two individuals are chosen at random from the habitat, the total number of possible outcomes $O_{tot}$ is:
$$O_{tot} = N(N-1)/2$$
The division by $2$ is to avoid duplication where the same two individuals are chosen in reverse order.  The outcomes of interest $O_{int}$ are those in which the chosen two individuals belong to the same species. For any one species $i$ the number of pairs $P_i$ of individuals belonging to that species is:
$$P_i = n_i(n_i-1)/2$$
To find $O_{int}$ we must sum over all species:
$$O_{int} = \sum_{i=1}^kP_i = \sum_{i=1}^kn_i(n_i-1)/2$$
Dividing $O_{int}$ by $O_{tot}$ and cancelling the divisions by $2$ yields the second of the above formulae for $D$.
Answer: One way to derive the Simpson index is via the concept of surprise and expected surprise.  For definitions and background, see the posts Statistical interpretation of Maximum Entropy Distribution and How to include the observed values, not just their probabilities, in information entropy?. I will use the theoretical definition of the Simpson index as $\sum_1^n p_i²$. In a biodiversity setting, say, $i$ indices $n$ species, where the probability of observing species $i$ is $p_i$.
Now let the observable, the random variable, be $I$, the species index of the observed species. Then the surprise function of the observed species is
$$ S(I) = p(I)=p_i $$
the probability of observing that species, and the expected surprise is
$$ \DeclareMathOperator{\E}{\mathbb{E}}
   \E S(I)=\sum_i p_i S(i) =\sum_i p_i^2
$$  that is, it is the Simpson index!

Derivation of the Simpson index


Forced colorings with IGraph/M

Question: Is it possible to force the colors of certain vertices in a graph so that the function which finds a minimum coloring will then extend the partial coloring with the fewest possible number of extra colors, without recoloring what has already been colored? If I understand the documentation of IGraph/M correctly, this is not quite possible, but maybe I am wrong.  Am I correct in saying that the "ForcedColoring" option doesn't quite allow this? Is there any other way to do this or otherwise hijack the IGMinimumVertexColoring function?  This would be a great option if it were to be implemented, this is a frequent situation in coloring graphs, especially when you know something about the structure of your graph which allows you to quickly color part of it, having only a small part of the graph left to color with a minimum number of extra colors.
Comment: I think the right place for `IGraphM` feature requests is [here](https://github.com/szhorvat/IGraphM/issues).
Comment: Thanks for the pointer.  I would like to leave the question, in case someone knows a way to do this, in any way ... or if you suggest to delete, then maybe I will, please do say
Comment: @JasonB. Right, thanks as I said.  Apparently, I don't have access to that site (nor will creating an account work :( ...
Comment: @EGME you can definitely add a feature request. Make a GitHub account, login, go here: https://github.com/szhorvat/IGraphM/issues/new and write your request. The project is public and open on GitHub so anyone can leave a comment
Comment: @b3m2a1 Thanks, maybe I will try later, perhaps there is something wrong with my connection at the moment ...
Answer: What you are asking for is not implemented in IGraph/M at the moment. You are correct that the "ForcedColoring" option doesn't quite do this at the moment. What it does is that it forces different colours on a set of vertices, but it is not currently possible to specify what those colours should be.
However, it is a reasonable request that is not too hard to implement. I will try to include this in the next release—but no promises (I'm very busy at the moment).
As others said, the correct place for feature requests is the issue tracker. Please do open an issue to make sure I won't forget about.
Comment: Thanks ... I will try opening an issue ... I had trouble signing up ... hopefully tomorrow
Comment: If you cannot, ping me here and I'll create the issue myself. However, it would be better if you could create an account so that we can continue the discussion in the issue tracker.
Comment: Ok, I will try ... I don't know what is the issue ... but will try .. by the way, what is "to ping" ? Sorry, not flowing with the times ...
Comment: Just comment on this post so that I get a notification. You can write my name with an "at" character like this: @EGME Then I get a notification, provided that I commented in the same thread before.
Comment: ok, thanks ... and will try the issue tracker tomorrow

Forced colorings with IGraph/M


Do people know how to use what Wordpress calls "Shortcodes"?

Question: For example, when posting to a blog via email, the user can enter [tags x,y,z] to add tags via email. How "technical" does that feel to the average user?
Reference: http://en.support.wordpress.com/post-by-email/
Comment: Is this question answerable if you're not Wordpress?
Comment: See here, on this very site: Comments use mini- **Markdown** formatting. Same principle. Wordpress is just one example.
Answer: You can't expect that users know before what is a shortcode. If you never used email you don't know what cc and bcc is, but you will figure out. Shortcodes are not like a button that stands there: "click me to see what is happening".
First of all, every plugin or theme developer choose the name of the shortcode. You have to read the description of that plugin to know what shortcode to use.
If the user already know how to install a plugin, read its description to see what is the name of the shortcode then he knows how to use them. If not, he will not know but it is very easy to just say: "to do this you have to post [thisshortcode], to do this other thing just post [theothershortcode]". Anyway you have to contact them to tell the name of the shortcode you used even if they know what a shortcode is.
Answer: Firstly - Average user - whatever is that? The definition of average user is of some debate and usually does depends on some kind of context.
It's unlikely an 'average' user will manage without a handy quick reference guide around.
Sure it feels technical - but 'how' technical? Ask your users.
Comment: Let's put it a different way. Is there a growing trend, e.g. with Twitter hash tags, or Markdown formatting being used on non-technical (non-StackOverflow) stack exchange sites, of asking people to use various "codes"? Thanks in advance.
Answer: From personal experience, we have a wordpress blog for a range of people* to contribute blog posts to.
* Mainly developers, technical people, and a handful of managers.
We have shortcodes to embed vimeo and a few other things, and the answer to your Q from my experience:
No. They need training on how to use shortcodes.  We have a wiki on how to create posts, which has a section on how to use the shortcodes.


Will I have to remove an apache 2 open-source project from the internet and stop using it if someone patents the concepts within the code?

Question: The Apache 2 open-source license allows patents, does this mean it could be possible that an apache 2 open-source project would have to be removed if a company demonstrates it has a patent based on or using the project?
Comment: Whether something is "prior" is determined by the laws of physics, not by the license.
Comment: I can see nothing in section 3 of Apache 2 that would require the software to be removed.
Comment: Why the negative points?
Comment: The code would be "prior art". Especially if it is open source and well published. And definitely if someone other than the author used it to create the patent.
Comment: Apache 2 grants a patent license, does this override the fact it would be prior art?
Answer: Any piece of software can be encumbered by patents. That is not something that is specific to the Apache license. The Apache license just acknowledges the fact and includes a patent license in addition to a copyright license.
If somebody holds a patent, then they can force you to remove your project that infringes on the patent from the internet, unless they either have given you a license to use the patented technology or you can prove in a court of law that the patent is invalid (for example because you can prove the relevant part of your software has been publicly published before the patent application was made).
The simple fact that a piece of code is licensed under the Apache license does not mean users of that code are protected from all patent claims. It is, for example, possible that a contributor makes a change that causes the code to infringe upon the patent of someone who is not involved in the project at all. That person has not suddenly given the project a patent license. Only if someone implements a patent they themselves hold can they grant a license for that patent.
Answer: The patent is inherently invalid, thus legally you do not have to.  Whether you want to fight that battle, though, is another matter.
(Your app predates the patent, thus showing the idea was already known.)


Automatically Set Alerts on List

Question: Is it possible to create a workflow or jquery function within the list's page that would allow a user to automatically be signed up for the built-in sharepoint alerts on any item they themselves create in the list?  This can be remedied with a workflow to create our own custom alert emails, but would like to try to implement the built-ins. Is this doable?
Answer: In SharePoint Designer, create a workflow that sends an email to the creator of the item on creation and on item change.  This is out of the box functionality.

but would like to try to implement the built-ins

Not sure what you mean by that.. unless you mean out of the box.
Comment: I was simply wondering if you were able to automatically set the out of the box alerts. But I will likely just do the aforementioned and just create a fast workflow myself.

Automatically Set Alerts on List


Replicating flash sliding effect with jQuery

Question: I was recently tasked with replicating http://www.rasikarestaurant.com/rasika.html in HTML5 and jQuery.
I'm currently struggling to do the effect where the menus slide up behind the images when an arrow is clicked (See the Menu section for the best example) and was wondering if this is actually possible in jQuery.
So far I have http://jsfiddle.net/wxRnf/1/ which is sort of getting there but I'm not sure it's the best approach.
Any advice you could offer would be great! Thanks.
Answer: The image makes a good reference point. So by using the currently clicked element and by finding the nearest sibling 'the-box' you can gather all the html elements. Then you can clone them, but hidden, to either before or after the-box depending if you found a prev or next sibling. Finally you execute an animation close at the same time as an animation up to get the one disappears/one appears affect. Definitely doable I would say.


JS 2 minute countdown then execute a function?

Question: I'm not that great at Javascript, for the record! I DO know how to use ajax. I just need a bit of help.
I'm having a hard time figuring out how to display a 5 minute countdown, and once the countdown hits zero, to run a function. I need to pass a variable to the function that needs to run. I tried SetInterval but this isn't exactly my strong suit. Does anyone have any suggestions? I can post the code I've got, but I would equate it to a gorilla fumbling in the dark at a typewriter!
Comment: your question title says 2 minutes count and you questions description says 5 minutes count.... not that it really matter at all :)
Answer: Perhaps try it this way. Use setTimeout() to control the "timer" side of the requirement, or differently put, to control the count down on the screen.
When launching the setTimeout(), also launch the function call using setInterval(). setInterval can be used to launch functions after a certain amount of time, and will attempt to run it at those intervals. Once you have run your function though, just use a call to clearInterval() to stop the timer.
Below is some code adapted from a site, it's untested, but should get the idea across.
Countdown Timer: - From here, just modified a bit.
<form name="counter"><input type="text" size="8"
name="d2"></form>


2004 Crown Victoria

Question: My Crown had her oil changed 8 days ago.  I drove it home and once the next day to church. trip was about 10 miles round trip.    I went out to go this morning, this is a week later, and all the oil in under the car, nothing in the car. light does not come on but is making horrible sound. I wonder if they did not put the plug all the way in right?
Answer: Don't start the car!  From what you said, it sounds like they might not have put the plug in all the way.  This is pretty easy to fix, but you might contact them, as it sounds like it's their fault, and they might be able to help you with it.
If there's oil under the car, that means there's at least less in the engine.  Slightly too little oil could be fine, but if you lose too much your engine won't be lubricated, and it'll wear out the inside really fast.  This is really bad for your engine.  If, like you said, the engine is making bad noises, you should not start it again until you've put the correct amount of oil in.
To do it at home, you would just get a wrench and screw in the oil plug tighter.  It could also be leaking from around the filter, so you can try to tighten that (it doesn't have to be too tight).  Afterwards, pour engine oil into your engine until the check stick reads normal levels.
Answer: If that is not it, try replacing the oil filter housing gasket. This is a common failure item that will cause oil to drip from the filter while the engine is running. The gasket is made of a plastic material with rubber o-rings molded in. They can crack or blow out with age. The stress on the housing from just changing the oil filter can cause this failure on an old gasket. The 15 year old plastic and rubber has lived a good life. The replacement part is about $15 - plus a quart of oil, a gallon of antifreeze, & few hours of your labor. A 10mm gearwrench for the last bolt on the power steering pump will save you an hour or two lol

2004 Crown Victoria


How many external monitors does the iMac 27" with 5k display support?

Question: Specs indicate just 1. Has anyone connected more than 1 monitor successfully? How many can you connect in total?
Answer: The Late 2015 iMac 5K with AMD 395X can support two external 4K (UHD) displays (at the full 3840x2160 res) with the builtin iMac display set to 5120x2880 FYI. This is the configuration that I am currently running (with 10.11.2), using two LG 27MU67 displays attached via DisplayPort-to-miniDP cables on each of the iMac's thunderbolt ports.
Comment: Are your 2 4k LG 27MU67 screens running at 30Hz or 60Hz? Are they running in HiDPI (retina) mode?
Comment: Both displays are running at 60Hz. In order to get the LG's to display at 60Hz via thunderbolt to HDMI, I had to enable Deep Color support through the display's manual menu controls however. Via standard thunderbolt to mDP or DP connection, there was no extra configuration necessary - it just worked. Regarding retina support: yes, non-native pixel retina resolutions can be enabled and are supported just as they are on the built-in 5K display; they look great, though I tend to run these external displays at 3840x2160 more often than not.
Answer: From Everymac…

In addition to the internal display, this model can support an external display up to 3840x2160 via Thunderbolt 2 (4K UltraHD). Third-parties have discovered that it also can support two simultaneous 27-Inch Thunderbolt displays at 2560x1140 each in lieu of a single UltraHD display.

I'm tempted to think that 2560x1140 is a typo & ought to be 2560x1440
Comment: Can more than 2 displays be supported by any chance?
Comment: Doesn't look like it.
Answer: At least 2, and likely no more.
The Retina 5K iMac can support an external 4K (UHD) (3840x2160 @60Hz) monitor AND a second external monitor up to at least 1920x1200 (60Hz) at the same time.
This is the setup I am currently using. No special tricks needed. Machine: Core i5 3.5 GHz, Radeon R9 M295X 4GB VRAM graphics card (BTO upgrade), 16 GB RAM, Yosemite 10.10.5.
I have the internal display set to scaled ("Looks like 2880 x 1620") and the 4K display set to 3840x2160 in Display Preferences.  These settings likely result in a reduction in performance vs. using the "Best for Retina" settings.
User interface animations (e.g., Mission Control) can be a little slower with these external displays running, but frankly it's not that snappy even without the external displays, if I have a lot of windows open. Hopefully El Capitan should fix this.  I don't do anything graphics-intensive, so can't comment on gaming/pro apps performance.
Things I've done to improve UI performance:

System Preferences > Accessibility > Check "Reduce transparency"
Deactivate the Mission Control Animation with the following
command in Terminal:
defaults write com.apple.dock expose-animation-duration -int 0; killall Dock

To set Mission Control animations back to defaults:
defaults delete com.apple.dock expose-animation-duration; killall Dock

Used an app such as QuickRes to turn off the OSX Retina/HiDPI mode on the 4K display. Since I'm running it at native resolution, Retina/HiDPI pixel-doubled drawing puts pointless effort on the GPU (i.e., it doesn't serve to make anything appear crisper on screen).

FWIW, this document from Apple says that the Retina iMac can support two Thunderbolt displays (2560x1440).  It also says that each Thunderbolt port can only support one display of any kind, and so that would limit the iMac to two displays total. It also suggests that the Retina iMac can support a 4K display (using MST) AND a Thunderbolt display at the same time (see footnote 5 in the table describing number of supported Thunderbolt Displays). That configuration is likely the maximum number of pixels the machine can put out across two displays (or possibly 4K & 2560x1600).
If you want to have more than 2 monitors, you can always use USB adapters utilizing DisplayLink's chipsets. I've used these to good effect on my Retina iMac.
Comment: I am now running one 4K (UHD) (3840x2160 @60Hz) monitor and one 2560x1440 @60Hz monitor on my iMac, with no problems.
Comment: I was just about to get a LG 49WL95C-W (5120x1140) for my iMac 27" 4K, is that even gonna work ? (was hopping to use a usb-c thunderbolt 3 or usb-c to display port)... I don't really want to use the actual iMac screen but I don't think we can disable the iMac monitor why using an external
Answer: I have 2 Dell 27 inch 4k monitors connected to my iMac 27 Retina with 4GB AMD, I can if it was readable run all three at max resolution and 60hz without issue.
Comment: I'm curious, though--which model iMac did you have at the time of your response? Mid-2015, I presume. . . .The OP for sure was asking about the late-2014 Retina iMac. I'm actually on the search for an answer to this question, myself, though specifically with regard to the late-2014 5K iMac. I'll hopefully have that answer later today.
Answer: Take a look at this Article (4 screen set-up),
http://www.zdnet.com/article/making-it-work-four-displays-on-a-monster-imac/
where he has three additional screen connected ....


Why do my scroll bar & cursor move on their own?

Question: I have a less than 3-year-old Dell Studio laptop running Windows 7, Internet Explorer 9. I use the touch pad, not a mouse. Lately the scroll bar moves on its own and the cursor does, too. The cursor bounces all over the place. This is driving me crazy! "I've read some of the answers to this question but I either don't understand what they're talking about or my computer doesn't have the "category" they say to click on.
Comment: Have you tried upating the driver for the touchpad? This can be found on the Dell support page http://support.dell.com/
Comment: It sounds like it could be a failing mouse connected to the USB port. Some laser mice wiggle around if they got confused about what they see (which happens at a certain distance from the surface), but they don't scroll around (unless the scroll wheel is not a mechanical wheel either).
Answer: I've found before that wireless interference from another wireless input device can be a cause of similar problems. Maybe you could look for other wireless input devices in range?
Answer: For weeks the problem was tabs multiplyed exponentially. Then the cursor raced to the end so I couldnt type any thing and the scroll bar plunged to the bottom. It was nuts.  I tried everything including replacing Win10. Nothing worked until I replace the driver on the keyboard. As soon as the new driver loaded, problems disappeared.


Saving linux boot messages in a file

Question: I have raspbian running on my raspberry PI. When I switch it on, boot messages crawl on the screen. I believe it would be beneficial to read them in order to get an idea about how the system starts. Hence I would like to know whether it is possible (and how) to redirect them to a file in order to read them thoroughly afterwards. Do I have to make a script that runs at startup?
Answer: Install the bootlogd package. Bootlogd is a daemon that will record all boot messages to /var/log/boot. Install the package with:
sudo apt-get install bootlogd

Then enable it by creating a new file called bootlogd in /etc/default/:
sudo vim /etc/default/bootlogd

And add the follwing to the file:
BOOTLOGD_ENABLE=yes

Save and exit. Now all boot messages will be put in /var/log/boot file, you can view them by using less like this:
less /var/log/boot

Answer:
I have raspbian […]

Then you can use the old Debian /etc/init.d/bootlogs that saves the last up to 0.5MiB of kernel messages to /var/log/dmesg at startup.  And of course, as mentioned in another answer, the old bootlogd from the same source, which only captures kernel messages that are at or above the kernel's console minimum log priority level.
And you can use one of the several Debian kernel log daemons or system log daemons (busybox-syslogd, dsyslog, klogd, inetutils-syslogd, sysklogd, socklog-run, syslog-ng, or rsyslog), which push kernel log messages to … wherever the package that you have has been configured to push kernel log messages.  But these don't all capture kernel messages.
Or you can use systemd, which takes everything that it can get its mitts on — application syslog() calls, dæmon output, kernel log buffer — mixes it all together and pushes it to its journal, which you can read with: journalctl -b -x.
Answer: Try to execute command
dmesg

And you will get them. If you want to save the message redirect the output to file
dmesg >out_file

Comment: `dmesg` only prints kernel ring buffer.
Comment: If it's based on Debian the messages will already be saved to `/var/log/kern.log`

Saving linux boot messages in a file


precrime options

Question: If a governmental institution, either police or a court, has information of an intention of a person who intends to commit a crime, is it their job description to prevent it from happening?
Comment: Please state the jurisdiction as this varies significantly across the world.
Comment: @jwh20  with no jurisdiction stated, answers are welcome for any and all jurisdictions. Indeed that is true even if a specific jurisdiction is mentioned in the question.
Comment: What are we talking about here? Preventing someone who actively plans a terrorism attack from doing that or to prevent a kid from stealing someone's lunch money?
Comment: What does "in their job description" mean? Are you referring to a literal job description of the sort police officers may be issued by their personnel department; to written orders; to the body of statute and case law governing behavior; or would you include oaths of office, mission statements, badge slogans, public pronouncements by senior officers, or other statements of purpose?
Answer: united-states
Per Warren v. District of Columbia, in the United States, there is no duty on the part of any police to protect any individual citizen.  In that case, the police were actually told of a crime in progress, showed up at the crime scene, and left again without stopping it.  They would certainly not have the duty to prevent a future crime.
Comment: "Is it their job description" is a different question from "is it their legal duty".
Comment: It's not clear whether "Is it their job description" is meant to be taken literally, so I think this is a reasonable answer.
Answer: canada
This depends on which institution has the information and in what role it is acting. I will just provide a few examples.

A court, when considering whether to declare a person to be a "dangerous offender" (Criminal Code, s. 753) should take into account evidence of the likelihood of recidivism. To declare somebody a dangerous offender, there must be a "high likelihood of harmful recidivism" (R. v. Boutilier, 2017 SCC 64 at para. 26).
A court, when considering whether to order someone to be detained in custody prior to trial, must consider whether the detention is "necessary for the protection or safety of the public... including any substantial likelihood that the accused will, if released from custody, commit a criminal offence..." (Criminal Code, s. 515(10)(b)).
In British Columbia, one of the duties of a municipal police department is to "prevent crime" (Police Act, s. 26(2)(c)).
Members of the Royal Canadian Mounted Police who are peace officers have the duty to prevent crime, subject to the orders of the Commissioner (Royal Canadian Mounted Police Act, s. 18).
"The police are statutorily obligated to prevent crime, and, at common law, they owe a duty to protect life and property." Doe v. Metropolitan Toronto (Municipality) Commissioners of Police, 1998 CanLII 14826 (Ont. Sup. Ct.) (only in extraordinary circumstances does this result in a specific duty of care to specific individuals or groups).
Other government agencies are not tasked with a duty to prevent crime. For example, the Civil Rules Committee of Ontario is not tasked with the prevention of crime. The University of Guelph Board of Governors is not tasked with the prevention of crime.
Answer: united-states
That depends on the job. This is an opening for an intake clerk in the US federal courts. The job description part says

Intake clerks assist the public and counsel with filing procedures,
case information and other court services. Related duties include
opening civil and miscellaneous cases, processing appeals, posting
court orders, managing prisoner and immigration cases, responding to
archive requests, overseeing attorney admission and discipline orders,
receipting payments, creating and maintaining procedural
documentation, mail sorting and reviewing documents to ensure
compliance with the Court's quality control standards

Crime prevention is not part of the job description.
There is a different and much longer job description for State Trooper which includes.

Conduct proactive patrol of assigned area and respond to calls for
service during day and/or night shifts, to ensure assigned area has
patrol coverage up to an including 24 hours/day, 7 days/week.

However, the state patrol does not normally investigate graffiti rings, which would be the job of municipal law enforcement. This is an even longer job description for a county sheriff patrol/detective position, which includes more investigative duties.
There may also be implicit "code of conduct" job requirements to the effect that you can't turn a blind eye to a plan to commit a crime. However, law enforcement agents are strongly limited in what they can do to prevent a crime. I might report to the police that I think Smith is planning to rob a bank, but that would not suffice to justify a search warrant. If I add more details e.g. attest that I heard concrete planning, the police might get a warrant on that basis, but they would need a warrant. However, if there is strong evidence (e.g. from screams) that Smith is about to murder Jones, under the exigent circumstances rule, police could enter and stop the crime.
There are basically two underlying questions here: duty, and power. Legally-enforceable duties are relatively few and generally the result of a specific law. The general rule is that a law enforcement agent has discretionary power to chose what enforcement actions to take, but there may be cases where "may" is replaced with "shall" in the law.

precrime options


What happen when Salesforce recycle bin is full?

Question: as mentioned in the title, assuming that the recycle bin of my org is full, what will happen in recycle bin and the new deleted record, when I delete something from Salesforce ?
Answer: Once the recycle bin is full Salesforce automatically start deleting the data. Old data is deleted first.
By default Deleted records remain in the recycle bin for 15 days, and can be restored during that time.
After 15 days, deleted items are purged from the recycle bin, and once purged, they can't be recovered.
Comment: if I understand, Salesforce will only delete some of the data (the oldest one), it will not purge all the recycle bin ?
Comment: @AnasLaghouaouta yes if its not older then 15 days and recycle bin is full then it will only delete required amount of data. If its older then 15 days then it will delete the complete data.
Answer: Nothing happens immediately when the Recycle Bin is full. However, on the next Recycle Bin clean up cycle, older records will be purged from the Recycle Bin to bring it below the maximum capacity allowed for your org. For example, if you have a limit of 15,000 records, and the Recycle Bin has 15,250 records, then the oldest 250 records would be purged.
In theory, you typically have a few hours to bring the Recycle Bin below the maximum capacity, but you should not rely on this behavior. Note that the 15 day limit is also only processed every few hours, so you typically have a bit longer than 15 days, though, again, you should not rely on this behavior.
Answer: If records exists in recycle bin which is used for sharing recalculation then Salesforce takes time to complete that process, because sharing recalculation includes records from recycle bin.
That's why, if you want to delete those records permanently without moving to recycle bin then recommended to use Bulk API hard delete.


Did Cantor know about Boole's work in logic, and did it influence his work on sets?

Question: We commonly say that sets obey a Boolean algebra. I think that's correct as a stand-alone statement. If true, did Cantor come up with a Boolean algebra on his own, or did he use the work of Boole?
Comment: Maybe Cantor had a knowledge of Boole's work, but IMO there is no use of "Boolean algebra" and "algebra of sets" in Cantor's views.
Comment: Anna Kornbluh's 2019 book *The Order of Forms: Realism, Formalism, and Social Space* is about the intersection of architecture, literature and the mathematics of set theory framing the representations of space in Victorian novelists including Dickens, Hardy, H. James.  In her view, "Originative Victorian mathematicians like George Boole, Augustus De Morgan, and William Stanley Jevons established formalist math as the prizing of logic, interrelation and the integrity of rigorous representations..." (p. 7).
Comment: Probably the term "Boolean algebra" appeared only later; perhaps Sheffer (1913) provided axioms for it.
Comment: In Kornbluh's retelling of Victorian history of mathematics, the emergence of set theory began with Augustus de Morgan in the late 1840s. De Morgan was heavily influenced by Boole and his logic (see https://en.wikipedia.org/wiki/Augustus_De_Morgan to confirm George Boole's influence on him).
Answer: Grattan-Guinness has an informative book on the history of logic and mathematical foundations, The Search for
Mathematical Roots, 1870-1940. There are dedicated chapters on Boole and Cantor, and Boole is mentioned in Cantor's chapter not once. The history of set theory by Ferreirós returns the same null result.
Boole's work was only publicized in Germany in the late 1870s, when Cantor was already well on his way with set theory. Schröder's exposition Operationskreis des Logikkalkuls came out in 1877. This said, Schröder was a prominent mathematician with interest in set theory and foundations, so Cantor might have been aware of it, but if so he left no indication to this effect. On the reception of Boole's work in the 19th century generally see Klement, New Logic and the Seeds of Analytic Philosophy.
Cantor had little use for set algebra and did not introduce it in his work. When one needs a fact about sets that a Boolean identity might provide it is more straightforward to deduce that fact by a direct element argument (compare deriving some Boolean identities from axioms, which can get quite intricate, to plain element arguments for them). So unless one is specifically focused on algebraic properties of set operations they would not be interested in Boolean algebra of sets. Cantor was not.
In addition to that, Boole framed his work as about "laws of thought" and translating that into Cantor's context would have required clarifying obscure relationships between properties (truth conditions), classes (intensions) and sets (extensions), which would have been a major distraction. It was not done until the early 20th century, see How did mathematicians notate the empty set before ∅?
"In fact, by the 1890s Cantor considered set theory as something completely different from logic", writes Ferreirós (Dedekind was far more receptive).
Cantor also had a special distaste for "laws of thought", heavily associated with Aristotle at the time, for those "laws" were traditionally used to rule out actual infinities, see Why did Cantor (and others) use c for the continuum?


Outlook 2010 contact group

Question: In Outlook 2010, I received an email with a list of email addresses in the body of the message.  Is there an easy way to turn the entire list into a new contact group?
Answer: There is a free Save Email Addresses from Messages to Contact Group utility that can do that. It integrates in Outlook as an add-in and you can run it right from Outlook ribbon on a message's window. In order to achieve the result, copy all email addresses to clipboard, create a new message, paste addresses to "To" field and run the utility. There is also a commercial version that can extract addresses right from message text.
I recommend this utility because I'm one of its developers, so feel free to ask any further questions.
Answer: I would suggest you copy those contacts from email body to an excel sheet and then save it as a .CSV file.
Import the .CSV file to contacts folder and map fields.

Outlook 2010 contact group


How do search engines calculate citations when both a preprint and a published journal/conference version of a paper exists?

Question: Let's say that I wrote my research paper and then I published it as a preprint on the ArXiv, and I got citations for this preprint. Afterwards, my same paper has been peer reviewed by a journal then published, so, how will search engines count the citations? Will they do a sum or union or consider them as two different papers?
Answer: This obviously depends on the indexing service used. Typically, the records for different versions of the same paper are merged, and the service will provide the sum of the references.
For example, on google scholar, you can click on "all versions" to see all versions of a paper included in their record. For example here are the 222 versions of the LIGO GW150914 discovery paper, included in Google's record.
(I am not sure how the extremely rare case that a single work references multiple versions of the same paper is handled. But this should indeed be very rare.)
Comment: okay, thank you very much, so the Google Scholar method is the most used method right ?
Comment: I don't know of explicit examples of services that do it differently. That doesn't mean they don't exist.
Comment: Note that Google Scholar sometimes does not merge different versions of the same paper automatically (e.g. when the title changed etc.)
Answer: Conventional "search engines", that is, services which index papers to count citations etc., such as Web of Science etc., will not count citations to preprints, nor citations in preprints. Similarly, they don't index all journals, but only certain ones (though, of course, the idea is that it covers the majority of journals, and in particular the relevant and established journals). Thus, all those citations are lost.  (Though, of course, they might decide at some point to index additional journals, or the arxiv, and they might decide to do so retroactively.)
Google Scholar, as mentioned above, indexes both the arxiv and the journal version, and usually merges them (which means that citations which appear in a journal and a preprint of the same paper are usually only counted once).  On the other hand, there is no official protocol as to what and how Google Scholar indexes things, and they might change this at any time, so in that sense this is less transparent (though it does not mean it gives worse citation data).


Confused about how to find de Bruijn sequence from Eulerian tour

Question: I am not following how wikipedia constructs a de Bruijn sequence from an Eulerian tour here. When our Eulerian tour visits vertices $000,000, 001, 011, 111, 111, 110, 101, 011,
110, 100, 001, 010, 101, 010, 100, 000$, wikipedia constructs the de Bruijn sequence using this as $0 0 0 0 1 1 1 1 0 1 1 0 0 1 0 1$. However, to me it seems that the last few vertices have been cut off. Why do we not continue the sequence with $000$? My underdstanding was that we find the de Bruijn sequence from the Eulerian tour by first using the first vertex in its entirety, and then augmenting this by the last digit of every subsequent vertex in the tour. The wikipedia example seems to have done this only up to the fourth to last vertex in the tour. Why did it suddenly stop there, and in what ways have I misunderstood how to construct the de Bruijn sequence from the Eulerian tour?
Comment: The cleaner way to state the method is "pick the first entry of each vertex"; then there is no cut-off any more (except of course that the last vertex doesn't count, since it is just the first vertex repeated). This is equivalent to what you said, but doesn't require special-casing the first and the last few vertices.
Answer: Remember that de Bruijn sequences are cyclic.  Notice that the 000 you want to add to the end is exactly the beginning of the sequence.  Whether you build the sequence as you describe or as Darij suggests in his comment, the goal is to find a length $2^4 = 16$ cyclic sequence containing all binary 4-tuples.
Answer: The sequence should be thought of as a cycle:
$0000111101100101$ is
\begin{array}{c|c|c}
0&0&0&0&1\\\hline
1&&&&1\\\hline
0&&&&1\\\hline
1&&&&1\\\hline
0&0&1&1&0
\end{array}


How does ordinary and extraordinary rays split inside calcite crystal in context of electromagnetic waves?

Question: If ordinary and extraordinary rays emerge out of calcite crystal at different points(double refraction) then why do we consider perpendicular electromagnetic wave components shifted by a phase in case of wave plates emerge at the same point?
Answer: This is because of how wave plate is made and used. The crystal is cut so that the optic axis is parallel to the long faces. Incident rays are normal to the plate and the optic axis so there is no refraction, only retardation. Wave plates are typically very thin (about 0.1mm) so even if the angle of incidence is not zero the deviation is very small compared with the diameter of the beam.
Comment: Then whats the thing that is different in crystal in case of double refraction? Even though the incident ray is normal it undergoes refraction, right?
Comment: Yes that is correct, but it depends on the orientation of the optic axis. I have updated my answer.
Comment: But how can we add those two perpendicular components of EM wave given that microscopic deviation?
Comment: The beam is usually from a laser, so it has good spatial coherence across the beam. Two parts of the beam will interfere if they are coherent.


Identifying structures in C++

Question: I have a large c++ program and I have found a pointer to an object of interest. I want to be able to identidy that object by atleast the constructor. What are some methods I can use to identify the constructor when the object's constructor is "nowhere in sight", i.e., it's far back in the program flow?
Answer: I have dabbled in this a little bit in the past, and one way to find the constructor is to try and find the Virtual Function Table for this object (VTable). Note that not all classes have virtual functions, and so not all classes have virtual tables.
Generally the pointer to the VTable is the first value in the objects memory e.g.
Object_base_address+0x00
More information on vtables is here https://stackoverflow.com/questions/3554909/what-is-vtable-in-c
and here
https://alschwalm.com/blog/static/2016/12/17/reversing-c-virtual-functions/
The other way is to explore what compilers do when they generate code for constructors by writing your own code and reverse engineering that.
This better understanding can then be applied to your larger program in your search for the specific function. It is important to note that code generation varies from compiler to compiler.
For this method you can use https://godbolt.org/ which lets you compile straight to assembly code and explore it.
If you need more information feel free to ask.
Comment: I am currently busy right now, but i will try to update with a bit more information later
Answer: I would like to expand a bit on the previous answer after I have learned some more about decompilation.
There are two principle types of objects in c++ (on MS Windows, that is). Those two are objects with vtables and objects without vtables.
In objects without vtables, identifying them is definitely more tricky, but on the plus side, these are usually either very big structures that are declared at compile time, or small structures that are constructed within the scope of the function. So you can either tell the object apart by it's constructor or it's address in the memory. Or at the very least, locally constructed objects without vtables aren't too many function calls behind.

Identifying structures in C++


How do I disable a form without erasing/deleting it?

Question: How do I disable a form without erasing/deleting it?
Answer: To disable a form without deleting it:

Go to Form Settings in your form builder.
Select the Limit Form Availability? option.
Set the Availability End date to any time in the past. Additionally, include a message to indicate that the form is no longer available.


Tapping opponents creatures

Question: If your opponent uses the ability where you can't untap until next turn can he use another card like that and have it stack for multiple turns?
Answer: It depends on the exact wording of the card in question (it's always helpful to give specific examples in these types of questions). If you mean a card like sleep, then no, it will not stack. Sleep makes the creatures not untap during the opponent's next untap step; even if you cast 2 of them on the same turn, they would both affect the same untap step.
But if you mean something like yosei, the morning star, then 2 instances of his triggered ability would stack. Each one would cause your opponent to skip his next untap step; so there are 2 replacement effects trying to replace the untap step. One if them would replace the next untap step with skipping that step; the other would would then still be around, waiting to skip the untap step that would happen after that.
Comment: Note: Triton tactics and other "freeze" effects are all 'sleep-style'

Tapping opponents creatures


Are there any tools that will display a complete tree

Question: My tree currently contains around 1500 people and I would like to be able to browse the WHOLE tree; I like the way the tree displays on Ancestry.co.uk but find it a little limiting (especially when checking some of the data) that I can only see a few generations and limited number of people, in one view.
Is there anything out there, which will give me a comprehensive view of the tree?
Comment: Are you interested in all solutions or just free ones?
Comment: The ability to show all your tree depends on several things. Do you want to see just your blood relatives and their spouses? Or their relatives as well. Either way the ability to show it will partly depend on the extent to which your lines cross when cousins intermarry. You may find it impossible to show your full tree in just two dimensions.... I remember being really interested in software that should show the full tree and then finding the full view got unintelligible very rapidly
Comment: You may think it's not overly complicated but I'll bet it'll look disappointing if you try to view the whole thing. I've just tried to view all the descendants of one 8th grandfather - note *not* ancestors of spouses - and his grandchildren are so far apart side to side that they cannot be seen on one screen and be legible at the same time. That's simply from needing to make space on the glass for their own descendants when trying to show all the tree. I really suggest that you go for free trials and be prepared for disappointment.
Comment: @ColeValleyGirl obviously, I would have a preference for free ones, but I don't mind paying for something, if it's going to work.
Comment: @AdrianB38 as it currently stands, there isn't anything overly complicated on my tree; no crossed lines (yet)
Comment: @AdrianB38 thanks for the feedback and the benefit of your experience; will have a look at some of the freebie programs to see what's about (and will be cautious of spending)
Answer: There is only one programme that I know of that will do this and that is Family Historian However as the comments say with 1500 people in your tree this is likely to be unwieldy to view and scroll around. Pedigree Collapse also causes extra links to be shown that may also confuse the viewer.
There is a 30 day free trial available so you will be able to try it and see if it does what you want.
Answer: The best way to do this is to view your tree as an ancestors list rather than a pedigree chart.  An ancestors list will show ALL your ancestors on one page.
Comment: Of course, it will only show ancestors and not the complete tree.


Why are simple shapes like spheres built using polygons?

Question: I was wondering what is the reason to implement shapes like spheres with triangles instead of a mathematical equation? This could allow perfectly round spheres and not kind of spherical with some levels of subdivision surface. Not to mention the significant boost in rendering time.
Comment: Lots of misconceptions in your question. Rendering would depend on the final amount of triangles, regardless of generation method. Blender does have NURBS based primitives and they are seldomly used because they present non of the advantages you claim, since at the end of the day those mathematical formulas are still used to generate triangles anyway
Comment: As far as I know PovRay bases its shapes upon equations
Answer: Creating an "equation" for rendering non-simple objects, such as a tank model, for instance, is much more difficult, especially when it comes to ray-tracing and shading. While for instance a sphere from an equation would be very simple, a sphere next to a complex object would be difficult, and its better to build complicated meshes out of polygons. The reason you can't have math-based meshes next to polygon-based meshes together is because they use different ways of rendering, as well as to keep everything consistent. This is my understanding of it, anyways, and people can correct me if I am mistaken.
Answer: It comes down to the complexity of math involved and to the design of compute hardware:

dealing with curved surfaces requires lots of complicated math - intersections of B-splines and Nurbs surfaces can lead to some cubic quartic or even more complicated math. Solution to those equations is not trivial. On the other hand representing planar triangles and lines requires only simple linear algebra.
the computer hardware under the surface is very dumb - can basically only add and multiply. Doing linear algebra is very efficient and fast, because it is hardware accelerated by special instructions that take advantage of how transistors and memory in the chip is designed. Doing more complicated math on computer is very slow and often the results are achieved by an iterative approximation method to some degree of precision.

So instead of using the proper math to deal with ideal surfaces and using iteration to get an approximated math solution, we approximate the surfaces instead and get the precise solution in single computation of linear algebra (usually as precise as 32bit floats allow).
Because there is a lot of simple cores that can do such task, we can compute millions of small triangles in real-time, triangles smaller than the pixels on screen.
Computer hardware is full of linear algebra units because it is universal, you can use it to do any task. A specialized unit that solves a cubic equation would not be utilized every time and would also occupy more space on the chip, but it would do the task much faster than a unit that computes linear equations. Today we start seeing some specialized hardware to accelerate non-linear tasks, like RT cores (does intersections of rays with BVH trees) or tensor cores (does inferencing of neural networks)


Why do digital cameras restrict the number of multiple exposures?

Question: Can somebody tell me why a Nikon D5200 would restrict the multiple exposure shots to 2 or 3 ? Is it some design issue or something else?
Comment: No, I meant multiple shots in a single frame. The Nikon D5200 can take either 2 or 3 only. I was curious to know why it had this restriction. Shooting while keeping the shutter down is called a 'burst mode', is it not ? I could be wrong with the terminology.
Comment: Are you referring to Auto Exposure Bracketing, or the drive mode that lets you just keep shooting when you hold down the shutter button?
Comment: Yes, burst mode, and it is usually limited by buffer memory or storage write speeds. If you are talking about bracketing, then I would assume that's at least mostly limited by firmware.
Answer: There is no real reason. Digital cameras could in theory cope with much more images. A number of models allow up to 9 but that is the most I've seen. The good ones allow you to confirm and retake each shot which makes this immensely workable.
In any case you can do multiple exposures simulated yourself in most image manipulation software such as Photoshop. The advantage there is that you control the blending and alignment.
As with most software features, including bracketing, manufacturers tend to provide what they think the target market will use and are careful not to diminish sales of higher end models.
Answer: A multiple exposure mode takes a given number of exposures and those are stored each in its own file on memory card. After the set is complete the in-camera program processes them into a single multiple exposure image. So, in reality, there is no "true" multiexposure happening inside your camera, but quite the same process as what you would be doing with your editing software in computer.
After the exposures are fused in camera the resulting image is written to a file on memory card. Limiting factor for the number of exposures must therefore be the amount of internal memory of the camera. This memory is quite expensive and carefully sized to meet the wanted performance of the camera. What is limiting the number of exposures in a multiexposure image with Nikon D5200?
I'd guess Nikon D5200 simply has an amount of internal memory that allows for two or three exposures only. Or some obscure marketing point?
Comment: its a design choice, most likely a usability choice, it makes it simpler for the poor average user, they need to protect, and it also leaves room for a feature improvement in a more expensive model when they need a new marketing point.
Comment: Actually, that would be wrong. You only need enough memory for an entire frame. It is easier with two, one where the camera reads from the sensor, one where it accumulates. All cameras know how many pictures will be taken but even if they did not, it could work with just enough space for two.
Comment: @Itai - There's something else wrong in my answer. Nikon saves all frames of the multiple exposure on memory card. Fusing into one frame does not happen on-the-fly is what I knew, but then.. If memory card is used for storage why would they restrict the number down to two or three?
Comment: Interesting. I do not have a Nikon with me this week but that makes me curious. What format are they on the card? Usually, cameras blend RAW-data then write to JPEG. When Autogain is enabled, this makes a significant difference in output quality.


Ways to access and download the metadata of OpenStreetMaps

Question: Does anyone know if there are any good methods or apps to access and download the metadata of OSM from desktop?
Comment: What exactly do you mean by "metadata of OSM"? The history of objects?  The source tag?
Comment: please expand on what information - metadata
Comment: I am sorry that I didn't make the term metadata clear. What I want is actually the time when the data uploaded by specific users was downloaded and edited. Thank you very much for your kind reminding.
Answer: http://planet.openstreetmap.org has a changeset file you can download, which includes information about each change made to the database. Look for changesets-latest.osm.bz2.
Answer: If by "metadata" you mean vector data, then there are several ways to do it. But it depends on your needs.
These two ways allow you to specify a map area you're interested in (but the size of the area is limited):

http://www.openstreetmap.org/export - choose "OpenStreetMap XML Data"
Using Maperitive (see the first two steps).

If you need the whole world, download the planet.osm. You will however need a lot of HW resources, so good luck with that.
There are also extracts for countries/parts of countries on Geofabrik and Cloudmade.
Comment: Thank you very much for your answers. But what I really mean about the term metadata is data about data which can be information about contributors who upload and edit the map. And here what I specially concern about is the time data which describes the uploading, editing and downloading time of the data. Still, as an OSM newie, I have been benefited a lot from your answers about vector data retrieving techniques.
Comment: @IgorBrejc Were you referring to GPS Coordinates from vector data? Or were you specifically referring to Vector Data instead of Raster Data as per this [Difference between Raster and Vector Data](http://gis.stackexchange.com/a/27089/80837)  I apologize in advance, if this seems confusing or what I am saying may not make sense. I am very new to this space, and am trying to understand it better. From what I understand, Raster is a more efficient way of getting GPS "metadata" the underlying coordinates of (GPS) in my case, that help depict an area on a map that can be linked to a map.
Answer: For inspiration, check out the blog posting "OpenStreetMap: a Year of Edits" by Derick Rethans (http://drck.me/osmyoe11-9nz). He discusses how he got hold of the changes in the OSM data set that happened in 2011 and how he made a beautiful video out of it. Intrigued to learn what use you are investiging!


Zoom to mouse cursor DirectX

Question: I have a DirectX scene. I want zoom in using mouse wheel to the mouse location. I am able to zoom the view to center of screen but I need to zoom to mouse location. Please suggest how it can be done. Thanks
Answer: You need to send a ray from the mouse cursor along the camera view direction  through the scene and see where it intersects (take the intersect position closest to the camera position) to know the 3D position. After that you can easily zoom in there by placing the camera closer.
This is often called unprojecting and can be done by fiddling a bit with your projection matrix and the screen coordinates of your mouse cursor.
Comment: Thanks for the reply Roy T. I am able to get the 3D position and able to unproject but I am able to zoom to the center of screen as my camera always looks at the center of viewing area. So, my question here is how do I place the camera around the mouse cursor point so that it looks like it is zooming to mouse position.
Comment: First set your camera look at to the 3D position of the mouse, then move closer to that point. Of course this will make the mouse cursor position the center of the screen. Alternatively you could figure out the distance between the screen-position of the mouse and the center of the screen. Then calculate what the same distance in screen space units would be zoomed in and use a parallel ray to move the camera along, this way the 3d position of the cursor will stay in the same relative screen space area but will come closer.

Zoom to mouse cursor DirectX


Review article in an area already published few years ago

Question: I want to write a review article in a particular narrow area of interest as part of my Doctoral research. But there is already a review article on that area published 2 years ago. So can I write a review paper on that area ?
Comment: A similar question was already answered [here](https://academia.stackexchange.com/q/11666/4018).
Comment: @MassimoOrtolano, in fact, this question is fundamentally different because it concerns doctoral research work; the question you link does not. In fact, the accepted answer there explicitly notes the special case: "If you have to do it as part of your thesis." I understand this question here to be asking about details about this special case only.
Comment: @Tripartio This question is about writing and, from the way it's written, publishing a review paper. Thus, whether it's part of doctoral research or not is irrelevant. It would be different if the review is meant to become a chapter of the dissertation, not published as paper.
Comment: @MassimoOrtolano, I've given an answer to the question, which is very different from appropriate answers to the question that you call a possible duplicate. For me, they are not the same question and they require different answers. But you might be right; it is possible that I misunderstood the question.
Answer: Let's look at your predicament from this perspective: A fundamental and absolute requirement for a doctoral thesis is that the work be original. One of the most important purposes of a doctoral thesis literature review is to prove that you are well aware of the work related to your topic and that you can clearly demonstrate that the work you are doing is truly original. So, if, as you say, you find a review article published on the same exact narrow area of research that your doctoral thesis aims to focus on, then you are basically saying that, in fact, your thesis topic is not original, and so fails the most basic requirement of a doctoral thesis.
From this initial consideration, I consider that there are two practical possibilities:

Possibility A: On closer examination, in fact, the older review does not cover exactly the same thing that you are trying to address in your doctoral thesis. (I guess this is probably the case. In my field of business research, it is extremely rare that two people have absolutely exactly the same idea, but it might be different for your area of research.) If that is the case, then you are free to do a thesis that is properly focused on your own narrow topic, and you should take great care to demonstrate and strongly prove that indeed your literature review is not quite the same thing as the superficially similar one from two years ago. You would mainly do this by including importatnt literature from areas that are related to your specific focus but outside the scope of the older review.
Possibility B: On close examination, sure enough, you are trying to treat a topic, however narrow, that has already been studied. In that case, you need to change your specific topic so that it is not an exact duplicate of what has already been done. You don't need to throw away what you've done so far; rather, carefully study the older review and all related work and then find a narrow focus that interests you (and for which you have feasible access to data--extremely important for choosing a doctoral thesis topic!) and then make that your unique, original focus. And because you've taken the time to develop a truly original topic, then study new literature that focuses on your new topic that was outside the scope of the older review and include that in your literature review.

In either case, be sure to include the literature from the older review that is still relevant for your own topic. Because the primary reason of a doctoral thesis literature review is to show your mastery of the topic, you must repeat your own reading and interpretation of the literature (in your own original words, of course), even if it seems to duplicate past work. If you were to publish your literature review chapter as a standalone article, you would probably have to greatly cut down that duplicate work, but from the standpoint of your own doctoral learning, it is not a duplicate, so you should fully include it to demonstrate your personal mastery of the literature.


how to set a database .loc function setting many values pandas?

Question: I have the following lines that work fine:
dbOut.loc[dbOut["id"] == id, "date"] = datevalue
dbOut.loc[dbOut["id"] == id,"number"] = numbervalue

The problem is, each line take too much time to run. I have like 10 lines of that type, so my iteration time is like 15 iterations/second. leaving just one takes it to 150 iterations/second.
The question is: Is there a way to make only one .loc and set each value to each row?
I tried something like:
dbOut.loc[dbOut["id"] == id, ["date","number"]] = datevalue, numbervalue

but it doesn't work.
I think that maybe there is a way of making the loc first and then apply each value to each column, but I don't know how.
Thanks in advance!
Answer: This should work.
dbOut.loc[dbOut["id"] == id, ["date", "number"]] = [datevalue, numbervalue]

Answer: you can use numpy
dbout['date'] = np.where(dbout['id'] == id, datevalue,None)

Similarly
dbout['number'] = np.where(dbout['id'] == id, numbervalue,None)

Note : considering id is predefined, replace the None value with some other if required.


Can I email a single page of a MS Word Document?

Question: I have a Microsoft Word document 50 pages long. I want to email a single page of the document. Is it possible to do so?
Comment: Copy the single page and mail it? What issue are you having?
Comment: I'm pretty sure this can't be done without creating an intermediary file with the pages you require to send. Some VBA scripts around to automate this, but you'd need to investigate yourself.
Answer: The quick answer to your question is, no it cannot be done directly from your email client because your email client (Outlook, Gmail, Mac Mail, others) do not have a direct interface into a Microsoft Word document.
With that said, if you are using a Windows version of Outlook, then there would be a possibility of writing a special VBA macro to do it, but then it could not be a generic macro that worked correctly in all cases. This is because in a Microsoft Word document, there is no such thing as a static and addressable page. In MS Word, pages are dynamically defined by margins, fonts, spacing, print drivers, etc.
If you need to provide the content of a certain page in a Word document to someone else so they can edit it, your best bet would be to paste the content into a separate document that you email. This of course does not give you the header/footer content. If you just want someone to view the content, then make a screenshot of the page and mail that.