} \ simeq \ lambda d. \ varphi _ { i _ s } ( p _ s, d ). \, $ $ \ varphi _ { i _ s } $ may be seen as the execution of the interpreter $ i _ s $ on the hardware, i. e., as a black - box ready to interpret programs written in language $ s $. the function $ \ sigma $ may be seen as a function that specializes the interpreter $ i _ s $ for the program $ p _ s $, as in partial evaluation. thus the godel number $ \ sigma ( i _ s, p _ s ) $ may be seen has object code that is the compiled version of program $ p _ s $. so the function $ \ ; c _ s = \ lambda q _ s. \ sigma ( ( i _ s, q _ s ) $ may be seen as a function that take as argument the source code of a program $ q _ s $ written in language $ s $, and return the object code version for that program. so $ c _ s $ is what is usually called a compiler. some conclusions however, as i said : " theory can be a liar ", or actually seem to be one. the problem is that we know nothing of the function $ \ sigma $. there are actually many such functions, and my guess is that the proof of the theorem may use a very simple definition for it, which might be no better, from an engineering point of view, than the solution proposed by raphael : to simply bundle the source code $ q _ s $ with the interpreter $ i _ s $. this can always be done, so that we can say : compiling is always possible. formalizing a more restrictive notion of what is a compiler would require a more subtle theoretical approach. i do not know what may have been done in that direction. the very real work done on partial evaluation is more realistic from an engineering point of view. and there are of course other techniques for writing compilers, including extraction of programs from the proof of their specification, as developed in the context of type - theory, based on the curry - howard isomorphism ( but i am getting outside my domain of competence ). my purpose here has been to show that raphael's remark is not " crazy ", but a sane reminder that things are not obvious, and not even simple. saying that something is impossible is a strong statement that does require precise definitions and a proof, if only to have a


precise understanding of how and why it is impossible. but building a proper formalization to express such a proof may be quite difficult. this said, even if a specific feature is not compilable, in the sense understood by engineers, standard compiling techniques can always be applied to parts of the programs that do not use such a feature, as is remarked by gilles'answer. to follow on gilles'key remarks that, depending on the language, some thing may be done at compile - time, while other have to be done at run - time, thus requiring specific code, we can see that the concept of compilation is actually ill - defined, and is probably not definable in any satisfactory way. compilation is only an optimization process, as i tried to show in the partial evaluation section, when i compared it with static data preprocessing in some algorithms. as a complex optimization process, the concept of compilation actually belongs to a continuum. depending on the characteristic of the language, or of the program, some information may be available statically and allow for better optimization. others things have to be postponed to run - time. when things get really bad, everything has to be done at run - time at least for some parts of the program, and bundling source - code with the interpreter is all you can do. so this bundling is just the low end of this compiling continuum. much of the research on compilers is about finding ways to do statically what used to be done dynamically. compile - time garbage collection seems a good example. note that saying that the compilation process should produce machine code is no help. that is precisely what the bundling can do as the interpreter is machine code ( well, thing can get a bit more complex with cross - compilation ).


one application of the hilbert transform is to obtain a so - called analytic signal. for signal $ s ( t ) $, its hilbert transform $ \ hat { s } ( t ) $ is defined as a composition : $ $ s _ a ( t ) = s ( t ) + j \ hat { s } ( t ) $ $ the analytic signal that we obtain is complex valued, therefore we can express it in exponential notation : $ $ s _ a ( t ) = a ( t ) e ^ { j \ psi ( t ) } $ $ where : $ a ( t ) $ is the instantaneous amplitude ( envelope ) $ \ psi ( t ) $ is the instantaneous phase. so how are these helpful? the instantaneous amplitude can be useful in many cases ( it is widely used for finding the envelope of simple harmonic signals ). here is an example for an impulse response : secondly, based on the phase, we can calculate the instantaneous frequency : $ $ f ( t ) = \ dfrac { 1 } { 2 \ pi } \ dfrac { d \ psi } { dt } ( t ) $ $ which is again helpful in many applications, such as frequency detection of a sweeping tone, rotating engines, etc. other examples of usage include : sampling of narrowband signals in telecommunications ( mostly using hilbert filters ). medical imaging. array processing for direction of arrival. system response analysis.


it is true that, like any convention, the choice of 44. 1 khz is sort of a historical accident. there are a few other historical reasons. of course, the sampling rate must exceed 40 khz if you want high quality audio with a bandwidth of 20 khz. there was discussion of making it 48. 0 khz ( it was nicely congruent with 24 frame / second films and the ostensible 30 frames / second in north american tv ), but given the physical size of 120 mm, there was a limit to how much data the cd could hold, and given that an error detection and correction scheme was needed and that requires some redundancy in data, the amount of logical data the cd could store ( about 700 mb ) is about half of the amount of physical data. given all of that, at the rate of 48 khz, we were told that it could not hold all of beethoven's 9th, but that it could hold the entire 9th on one disc at a slightly slower rate. so 48 khz is out. still, why 44. 1 and not 44. 0 or 45. 0 khz or some nice round number? then at the time, there existed a product in the late 1970s called the sony f1 that was designed to record digital audio onto readily - available video tape ( betamax, not vhs ). that was at 44. 1 khz ( or more precisely 44. 056 khz ). so this would make it easy to transfer recordings, without resampling and interpolation, from the f1 to cd or in the other direction. my understanding of how it gets there is that the horizontal scan rate of ntsc tv was 15. 750 khz and 44. 1 khz is exactly 2. 8 times that. i'm not entirely sure, but i believe what that means is that you can have three stereo sample pairs per horizontal line, and for every 5 lines, where you would normally have 15 samples, there are 14 samples plus one additional sample for some parity check or redundancy in the f1. 14 samples for 5 lines is the same as 2. 8 samples per horizontal line and with 15, 750 lines per second, that comes out to be 44, 100 samples per second. now, since color tv was introduced, they had to bump down slightly the horizontal line rate to 15734 lines per second. that adjustment leads to the 44, 056 samples per second in the sony f1.


number of legs in terrestrial vertebrates not only do mammals have four legs but actually all terrestrial vertebrates ( which include mammals ) have four legs. there are slight exceptions though as some lineages have lost their legs. typically snakes have no legs anymore. apesteguia and zaher ( 2006 ) discuss the evolution of snakes legs reduction and report a fossil of snakes with a robust sacrum. cetaecea ( whales and friends ) have lost their hind legs but we can still spot them on the skeleton. see for example the orca ( killer whale, easily recognizable to its teeth ) on the picture below. pay attention to the small bones below its vertebral column at the level on the left side of the picture. i also want to draw attention to the importance of the definition of legs. i guess that we would call something a pair of legs if it is constructed using a similar developmental pathway than current existing legs. if we are using some broader definition, then a prehensile tail as found in some new world monkeys, for example, could be considered as a leg ( but only a single leg, not a pair of legs obviously ). a list of animals having a prehensile tail can be found here ( wikipedia ). did you say natural selection? i think ( might be wrong ) that you have too selectionist a view of evolution. what i mean is that you are wondering why mammals have four legs and you're looking for an explanation of the kind " because mammal have this kind of need of locomotion and for this purpose four is the most optimal number of legs ". consider the following sentence : " if there is a need, natural selection will find a way! ". this sentence is wrong! evolution is not that easy. this false view of evolution is sometimes referred to as panselectionist. the reality is that it is not easy to evolve such a developmental pathway as drastic as having an extra pair of legs that are well integrated into the body of the carrier of this new trait. such an individual would need a brain, a nerve code, a heart and some other features that are adapted to have extra legs. also, assuming such a thing came to existence it is rather complicated to imagine how it could be selected for. to go slightly further, you have to realize that there are many stochastic processes in evolution ( including mutation and random variation in reproductive success ) and an organism is a piece of complex machinery and is not necessarily easily transformable to some other form


that would be more efficient ( have higher reproductive success ). often going from one form to another may involve a " valley crossing " meaning that if several mutations are needed, intermediate forms may have low reproductive success and therefore a high amount of genetic drift ( stochasticity in reproductive success ) to cross such valley of low reproductive success. see shifting balance theory. finally, even if there is selection for another trait, it may take time for the mean trait in the population to shift especially if there is only little genetic variance. a complete discussion on why the sentence " if there is a need, natural selection will find a way! " is wrong would fill up a whole book. gould ( 1979 ) is a classic article on the subject and is very easy to read even for a layperson. why 4 legs? terrestrial vertebrates have four legs because they evolved from a fish ancestor that had four members that were not too far from actual legs ( members that could " easily " evolve into legs ). this is what we call a phylogenetic signal. the explanation is as simple and basic as that. you can have a look at the diversity of terrestrial vertebrates here ( click on the branches ). number of legs in invertebrates arthropoda ( spiders ( and other chelicerata ), insects ( and other hexapods ), crustaceans ( crabs, shrimps … ) and myriapoda ( millipedes ) and trilobite as well ) ) evolved from a common ancestor who had a highly segmented body. from this ancestor, many groups have fused some segments. in these taxa, each pair of legs is attached to a particular segment ( i don't think the segments are still visible in spiders today ). in insects, for example, all 6 legs are attached to the thorax but to 3 different segments of the thorax, the pro - meso and meta - thorax ( see below ). as a side note, it is interesting to know that the wings in insects did not evolve from the legs ( as it is the case in birds and bats ). there are two competing hypotheses for the origin of insect wings. wings either developed from gills or from sclerite ( chitine plate, the hard part of the insect ). when insect first wings, they actually evolved three pairs of wings ( one on each segment of the thorax ). at least one pair has then been lost in all modern species. in the diptera, a second pair of wings have been lost


and are replaced by halteres, particularly easy to spot in craneflies ( see below picture ). in millipedes, the link between segmentation and legs is even more obvious ( see picture below ). you can have a look at the diversity of arthropoda here ( click on the branches ). pictures update 1 asking how likely it is for a given population to evolve a given trait is extremely hard to answer. there are two main issues : 1 ) a definition of the question issue and 2 ) a knowledge issue. when asking for a probability one always needs to state the a priori knowledge. if everything is known a priori, then there is nothing stochastic ( outside quantum physics ). so to answer the question one has to decide what we take for granted and what we don't. the second issue is a knowledge issue. we are far from having enough knowledge in protein biophysics ( and many other fields ) to answer that question. there are so many parameters to take into account. i would expect that creating a third pair of legs would need major changes and therefore one mutation will never be enough in order to develop a third pair of legs. but, no i cannot cite you any reference for this, i am just guessing! following the wings example in insects. insects have had three pairs of wings. while some mutation ( s ) prevented the expression of the third ( the first actually ) pair many of the genetic information for this third pair remain in the genotype of insects as they still use it for the two other pairs. taking advantage of that, membracidae ( treehoppers ) developed some features using a similar biochemical pathway than the one used to develop wings. those structures are used as protection or batesian mimicry. update 2 let's imagine that an extremely unlikely series of mutations occur that create some rodent with 6 - legs. let's imagine this rodent with six legs has a larger heart in order to pump blood to these extra legs and it has a brain that is adapted to using six legs and some changes in its nerve cord so that it can control its 3rd pair of legs. will this rodent have higher reproductive success than other individuals in the population? well … let's imagine that with its six legs, it can run faster or whatever and has a very high fitness. how would the offspring of a six - leg mother ( or father ) and a four - leg father ( or mother ) look like? will it be able to reproduce? see the issue is


that it is hard for such trait to come to existence because 1 ) it needs many steps ( mutations ) and 2 ) it is hard to imagine how it could be selected for. for those reasons, there exist no vertebrates with 6 fully functional legs. well, let's assume it does and in consequence, after 200 generations or so, the whole population is only made of 6 - legged individuals. maybe the species got extinct then and no fossil record has ever been found. this is possible. it is not because something has existed that we necessarily find something in the fossil record.


there are several things which affect the time to first fix ( ttfx ). getting the almanac and ephemeris. these two things are technically a little different from each other, but for our purposes we'll treat them as the same. they are the locations of the satellites, and you need a to know where they are in order to work out your own position. each satellite transmits the whole lot roughly once every 12 minutes. so from a completely cold start with a one - channel receiver and a decent signal, ttfx will be at least 12 minutes. you can speed things up by : downloading from the internet instead - generally a good choice for phones. downloading the almanac and ephemreris this way is known as msb assisted gps. remembering the almanac from last time ( it's good for many weeks ) and only downloading the ephemeris. having more than one receiving channel in the device so you can listen to more than one satellite at once. the transmissions are staggered to make this work, and with some care you can use the ephemeris without an almanac which saves a lot of time. the vast majority of modules on the market these days have multiple channels, so it would be rare to find one which still needs 12 minutes. identifying satellites. you need to listen to at least three satellites, preferably more, to get a good fix, but each receiver ( known as correlators ) can only be tuned to one at a time. if you know roughly where you are, what time it is, and have an almanac already, then you can guess which satellites you can see. phones tend to know roughly where they are from recognising wifi or bluetooth signals, knowing which cell tower they are using, and other sources. they regularly get very accurate time updates too, so they can usually go straight for the correct satellite. both phones and larger modules can also remember when and where they were last used, and use that to start from. number of correlators. due to the very low signal - to - noise of gps signals, you need a special bit of hardware to receive them. some receivers only have one, and need to rotate'round the satellites. others have more, and can listen to more at once. so even if you already have the almanac / ephemeris and know roughly where you are, then more correlators will still help you fix quicker. you might think more


is always better, but more does increase cost and power consumption. some phones and modules have more than others. signal and antennas. the correlators will do their job faster if you have a good signal - to - noise going into them. very poor signals might not work at all. a good antenna design, amplifier, sky view, and good pcb layout can make all the difference. some modules may work ok out of the box, and much better with an antenna plugged in. number of usable satellites. there are actually two large constellations of satellites up there, gps ( run by the usa ) and glonass ( run by russia ). there are also more under construction : galileo ( eu ) and beidou - 2 ( china ) and some with local coverage like india's navic or beidou - 1. a receiver which can work with satellites from more than one constellation has more satellites to chose from, and will get a quicker and more accurate fix. quality of correlators. new hardware designs are better than old ones, and will be able to pick out fragments of the gps message in a noisy signal better. another trick phones can do is to capture fragments of signal and pass them over the internet to a server with a very good software correlator, and complete almanac / ephemeris to examine. this is known as msa assisted gps. some phones ( and even a few modules ) might also use some slightly sneaky tricks to avoid or hide a long ttfx. since they are on all the time, they might briefly switch on the gps without telling the user in order to keep the location and ephemeris roughly up to date. others might display a recent position while still waiting for a real fix - which looks like a good ttfx most of the time, but looks bad if it turns out the position is very wrong. point 1 above is the thing that makes the most difference, and is usually the key thing that is different between basic modules, more advanced modules, and phones. the others usually make a smaller difference, but it can actually become a very complicated thing. if you want to read more, then " gps time to first fix " is the term to search for.


via gencode and bedops convert2bed : $ wget - qo - ftp : / / ftp. ebi. ac. uk / pub / databases / gencode / gencode _ human / release _ 28 / gencode. v28. annotation. gff3. gz \ | gunzip - - stdout - \ | awk'$ 3 = = " gene "'- \ | convert2bed - i gff - \ > genes. bed you can modify the awk statement to get exons, by replacing gene with exon. to get hgnc symbol names in the id field, you can add the - - attribute - key = " gene _ name " option to v2. 4. 40 or later of convert2bed. this slight modification extracts the gene _ name attribute from the annotation record and puts it in the fourth ( id ) column : $ wget - qo - ftp : / / ftp. ebi. ac. uk / pub / databases / gencode / gencode _ human / release _ 28 / gencode. v28. annotation. gff3. gz \ | gunzip - - stdout - \ | awk'$ 3 = = " gene "'- \ | convert2bed - i gff - - attribute - key = " gene _ name " - \ > genes. bed bedops : this is based off an answer i wrote on biostars, which includes a perl script for generating a bed file of introns from gene and exon annotations :


this question is usually posed as the length of the diagonal of a unit square. you start going from one corner to the opposite one following the perimeter and observe the length is $ 2 $, then take shorter and shorter stair - steps and the length is $ 2 $ but your path approaches the diagonal. so $ \ sqrt { 2 } = 2 $. in both cases, you are approaching the area but not the path length. you can make this more rigorous by breaking into increments and following the proof of the riemann sum. the difference in area between the two curves goes nicely to zero, but the difference in arc length stays constant. edit : making the square more explicit. imagine dividing the diagonal into $ n $ segments and a stairstep approximation. each triangle is $ ( \ frac { 1 } { n }, \ frac { 1 } { n }, \ frac { \ sqrt { 2 } } { n } ) $. so the area between the stairsteps and the diagonal is $ n \ frac { 1 } { 2n ^ 2 } $ which converges to $ 0 $. the path length is $ n \ frac { 2 } { n } $, which converges even more nicely to $ 2 $.


( i assume for the purposes of this answer that the data has been preprocessed to have zero mean. ) simply put, the pca viewpoint requires that one compute the eigenvalues and eigenvectors of the covariance matrix, which is the product $ \ frac { 1 } { n - 1 } \ mathbf x \ mathbf x ^ \ top $, where $ \ mathbf x $ is the data matrix. since the covariance matrix is symmetric, the matrix is diagonalizable, and the eigenvectors can be normalized such that they are orthonormal : $ \ frac { 1 } { n - 1 } \ mathbf x \ mathbf x ^ \ top = \ frac { 1 } { n - 1 } \ mathbf w \ mathbf d \ mathbf w ^ \ top $ on the other hand, applying svd to the data matrix $ \ mathbf x $ as follows : $ \ mathbf x = \ mathbf u \ mathbf \ sigma \ mathbf v ^ \ top $ and attempting to construct the covariance matrix from this decomposition gives $ $ \ frac { 1 } { n - 1 } \ mathbf x \ mathbf x ^ \ top = \ frac { 1 } { n - 1 } ( \ mathbf u \ mathbf \ sigma \ mathbf v ^ \ top ) ( \ mathbf u \ mathbf \ sigma \ mathbf v ^ \ top ) ^ \ top = \ frac { 1 } { n - 1 } ( \ mathbf u \ mathbf \ sigma \ mathbf v ^ \ top ) ( \ mathbf v \ mathbf \ sigma \ mathbf u ^ \ top ) $ $ and since $ \ mathbf v $ is an orthogonal matrix ( $ \ mathbf v ^ \ top \ mathbf v = \ mathbf i $ ), $ \ frac { 1 } { n - 1 } \ mathbf x \ mathbf x ^ \ top = \ frac { 1 } { n - 1 } \ mathbf u \ mathbf \ sigma ^ 2 \ mathbf u ^ \ top $ and the correspondence is easily seen ( the square roots of the eigenvalues of $ \ mathbf x \ mathbf x ^ \ top $ are the singular values of $ \ mathbf x $, etc. ) in fact, using the svd to perform pca makes much better sense numerically than


forming the covariance matrix to begin with, since the formation of $ \ mathbf x \ mathbf x ^ \ top $ can cause loss of precision. this is detailed in books on numerical linear algebra, but i'll leave you with an example of a matrix that can be stable svd'd, but forming $ \ mathbf x \ mathbf x ^ \ top $ can be disastrous, the lauchli matrix : $ \ begin { pmatrix } 1 & 1 & 1 \ \ \ epsilon & 0 & 0 \ \ 0 & \ epsilon & 0 \ \ 0 & 0 & \ epsilon \ end { pmatrix } ^ \ top, $ where $ \ epsilon $ is a tiny number.


practically, what limits cpu speed is both the heat generated and the gate delays, but usually, the heat becomes a far greater issue before the latter kicks in. recent processors are manufactured using cmos technology. every time there is a clock cycle, power is dissipated. therefore, higher processor speeds means more heat dissipation. here are some figures : core i7 - 860 ( 45 nm ) 2. 8 ghz 95 w core i7 - 965 ( 45 nm ) 3. 2 ghz 130 w core i7 - 3970x ( 32 nm ) 3. 5 ghz 150 w you can really see how the cpu transition power increases ( exponentially! ). also, there are some quantum effects which kick in as the size of transistors shrink. at nanometer levels, transistor gates actually become " leaky ". i won't get into how this technology works here, but i'm sure you can use google to look up these topics. okay, now, for the transmission delays. each " wire " inside the cpu acts as a small capacitor. also, the base of the transistor or the gate of the mosfet act as small capacitors. in order to change the voltage on a connection, you must either charge the wire or remove the charge. as transistors shrink, it becomes more difficult to do that. this is why sram needs amplification transistors, because the actually memory array transistors are so small and weak. in typical ic designs, where density is very important, the bit - cells have very small transistors. additionally, they are typically built into large arrays, which have very large bit - line capacitances. this results in a very slow ( relatively ) discharge of the bit - line by the bit - cell. from : how to implement sram sense amplifier? basically, the point is that it is harder for small transistors to drive the interconnects. also, there are gate delays. modern cpus have more than ten pipeline stages, perhaps up to twenty. performance issues in pipelining there are also inductive effects. at microwave frequencies, they become quite significant. you can look up crosstalk and that kind of stuff. now, even if you do manage to get a 3265810 thz processor working, another practical limit is how fast the rest of the system can support it. you either must have ram, storage, glue logic, and other interconnects that


perform just as fast, or you need an immense cache.


combustion is a gas phase reaction. the heat of the flame vapourises the substrate and it's the vapour that reacts with the air. that's why heat is needed to get combustion started. anyhow, wood contains lots of relatively volatile compounds so it's not too hard to get combustion started. once combustion has started the heat of the flame keeps the reaction going. however sugar dehydrates and emits water when you heat it. water isn't flammable ( obviously ) so there's no way to get combustion started. dehydration leaves behind pure carbon and that is non - volatile so again there's no way to get this to burn. carbon will burn of course, but you need a high temperature to get it going.


i always hesitate to jump into a thread with as many excellent responses as this, but it strikes me that few of the answers provide any reason to prefer the logarithm to some other transformation that " squashes " the data, such as a root or reciprocal. before getting to that, let's recapitulate the wisdom in the existing answers in a more general way. some non - linear re - expression of the dependent variable is indicated when any of the following apply : the residuals have a skewed distribution. the purpose of a transformation is to obtain residuals that are approximately symmetrically distributed ( about zero, of course ). the spread of the residuals changes systematically with the values of the dependent variable ( " heteroscedasticity " ). the purpose of the transformation is to remove that systematic change in spread, achieving approximate " homoscedasticity. " to linearize a relationship. when scientific theory indicates. for example, chemistry often suggests expressing concentrations as logarithms ( giving activities or even the well - known ph ). when a more nebulous statistical theory suggests the residuals reflect " random errors " that do not accumulate additively. to simplify a model. for example, sometimes a logarithm can simplify the number and complexity of " interaction " terms. ( these indications can conflict with one another ; in such cases, judgment is needed. ) so, when is a logarithm specifically indicated instead of some other transformation? the residuals have a " strongly " positively skewed distribution. in his book on eda, john tukey provides quantitative ways to estimate the transformation ( within the family of box - cox, or power, transformations ) based on rank statistics of the residuals. it really comes down to the fact that if taking the log symmetrizes the residuals, it was probably the right form of re - expression ; otherwise, some other re - expression is needed. when the sd of the residuals is directly proportional to the fitted values ( and not to some power of the fitted values ). when the relationship is close to exponential. when residuals are believed to reflect multiplicatively accumulating errors. you really want a model in which marginal changes in the explanatory variables are interpreted in terms of multiplicative ( percentage ) changes in the dependent variable. finally, some non - reasons to use a re - expression : making outliers not look like outliers. an outlier is a dat


##um that does not fit some parsimonious, relatively simple description of the data. changing one's description in order to make outliers look better is usually an incorrect reversal of priorities : first obtain a scientifically valid, statistically good description of the data and then explore any outliers. don't let the occasional outlier determine how to describe the rest of the data! because the software automatically did it. ( enough said! ) because all the data are positive. ( positivity often implies positive skewness, but it does not have to. furthermore, other transformations can work better. for example, a root often works best with counted data. ) to make " bad " data ( perhaps of low quality ) appear well behaved. to be able to plot the data. ( if a transformation is needed to be able to plot the data, it's probably needed for one or more good reasons already mentioned. if the only reason for the transformation truly is for plotting, go ahead and do it - - but only to plot the data. leave the data untransformed for analysis. )


i'm a physicist, so apologies if the answer below is in a foreign language ; but this was too interesting of a problem to pass up. i'm going to focus on a particular question : if we have oxygen and nothing else in a box, how strong does the magnetic field need to be to concentrate the gas in a region? the tl ; dr is that thermal effects are going to make this idea basically impossible. the force on a magnetic dipole $ \ vec { m } $ is $ \ vec { f } = \ vec { \ nabla } ( \ vec { m } \ cdot \ vec { b } ) $, where $ \ vec { b } $ is the magnetic field. let us assume that the dipole moment of the oxygen molecule is proportional to the magnetic field at that point : $ \ vec { m } = \ alpha \ vec { b } $, where $ \ alpha $ is what we might call the " molecular magnetic susceptibility. " then we have $ \ vec { f } = \ vec { \ nabla } ( \ alpha \ vec { b } \ cdot \ vec { b } ) $. but potential energy is given by $ \ vec { f } = - \ vec { \ nabla } u $ ; which implies that an oxygen molecule moving in a magnetic field acts as though it has a potential energy $ u ( \ vec { r } ) = - \ alpha b ^ 2 $. now, if we're talking about a sample of gas at a temperature $ t $, then the density of the oxygen molecules in equilibrium will be proportional to the boltzmann factor : $ $ \ rho ( \ vec { r } ) \ propto \ mathrm e ^ { - u ( \ vec { r } ) / kt } = \ mathrm e ^ { - \ alpha b ^ 2 / kt } $ $ in the limit where $ kt \ gg \ alpha b ^ 2 $, this exponent will be close to zero, and the density will not vary significantly from point to point in the sample. to get a significant difference in the density of oxygen from point to point, we have to have $ \ alpha b ^ 2 \ gtrsim kt $ ; in other words, the magnetic potential energy must comparable to ( or greater than ) the thermal energy of the molecules, or otherwise random thermal motions will


cause the oxygen to diffuse out of the region of higher magnetic field. so how high does this have to be? the $ \ alpha $ we have defined above is approximately related to the molar magnetic susceptibility by $ \ chi _ \ text { mol } \ approx \ mu _ 0 n _ \ mathrm a \ alpha $ ; and so we have1 $ $ \ chi _ \ text { mol } b ^ 2 \ gtrsim \ mu _ 0 rt $ $ and so we must have $ $ b \ gtrsim \ sqrt { \ frac { \ mu _ 0 r t } { \ chi _ \ text { mol } } }. $ $ if you believe wikipedia, the molar susceptibility of oxygen gas is $ 4. 3 \ times 10 ^ { - 8 } \ \ text { m } ^ 3 / \ text { mol } $ ; and plugging in the numbers, we get a requirement for a magnetic field of $ $ b \ gtrsim \ pu { 258 t }. $ $ this is over five times stronger than the strongest continuous magnetic fields ever produced, and 25 – 100 times stronger than most mri machines. even at $ \ pu { 91 kelvin } $ ( just above the boiling point of oxygen ), you would need a magnetic field of almost $ \ pu { 150 t } $ ; still well out of range. 1 i'm making an assumption here that the gas is sufficiently diffuse that we can ignore the magnetic interactions between the molecules. a better approximation could be found by using a magnetic analog of the clausius - mossotti relation ; and if the gas gets sufficiently dense, then all bets are off.


yes, it has a lot to do with mass. since deuterium has a higher mass than protium, simple bohr theory tells us that the deuterium 1s electron will have a smaller orbital radius than the 1s electron orbiting the protium nucleus ( see " note " below for more detail on this point ). the smaller orbital radius for the deuterium electron translates into a shorter ( and stronger ) $ \ ce { c - d } $ bond length. a shorter bond has less volume to spread the electron density ( of the 1 electron contributed by $ \ ce { h } $ or $ \ ce { d } $ ) over resulting in a higher electron density throughout the bond, and, consequently, more electron density at the carbon end of the bond. therefore, the shorter $ \ ce { c - d } $ bond will have more electron density around the carbon end of the bond, than the longer $ \ ce { c - h } $ bond. the net effect is that the shorter bond with deuterium increases the electron density at carbon, e. g. deuterium is inductively more electron donating than protium towards carbon. similar arguments can be applied to tritium and it's even shorter $ \ ce { c - t } $ bond should be even more inductively electron donating towards carbon than deuterium. note : bohr radius detail most introductory physics texts show the radius of the $ n ^ \ text { th } $ bohr orbit to be given by $ $ r _ { n } = { n ^ 2 \ hbar ^ 2 \ over zk _ \ mathrm { c } e ^ 2 m _ \ mathrm { e } } $ $ where $ z $ is the atom's atomic number, $ k _ \ mathrm { c } $ is coulomb's constant, $ e $ is the electron charge, and $ m _ \ mathrm { e } $ is the mass of the electron. however, in this derivation it is assumed that the electron orbits the nucleus and the nucleus remains stationary. given the mass difference between the electron and nucleus, this is generally a reasonable assumption. however, in reality the nucleus does move too. it is relatively straightforward to remove this assumption and make the equation more accurate by replacing $ m _ \ mathrm { e } $ with the electron's reduced mass, $ \ mu _ \ mathrm { e } $ $ $ \ mu _ \ mathrm { e } =


\ frac { m _ \ mathrm { e } \ times m _ \ text { nucleus } } { m _ \ mathrm { e } + m _ \ text { nucleus } } $ $ now the equation for the bohr radius becomes $ $ r _ { n } = { n ^ 2 \ hbar ^ 2 \ over zk _ \ mathrm { c } e ^ 2 \ mu _ \ mathrm { e } } $ $ since the reduced mass of an electron orbiting a heavy nucleus is always larger than the reduced mass of an electron orbiting a lighter nucleus $ $ r _ \ text { heavy } \ lt r _ \ text { light } $ $ and consequently an electron will orbit closer to a deuterium nucleus than it will orbit a protium nucleus.


the two primary factors that describe a window function are : width of the main lobe ( i. e., at what frequency bin is the power half that of the maximum response ) attenuation of the side lobes ( i. e., how far away down are the side lobes from the mainlobe ). this tells you about the spectral leakage in the window. another not so frequently considered factor is the rate of attenuation of the sidelobes, i. e., how fast do the sidelobes die down. here's a quick comparison for four well known window functions : rectangular, blackman, blackman - harris and hamming. the curves below are 2048 - point ffts of 64 - point windows. you can see that the rectangular function has a very narrow main lobe, but the side lobes are quite high, at ~ 13 db. other filters have significantly fatter main lobes, but fare much better in the side lobe suppression. in the end, it's all a trade - off. you can't have both, you have to pick one. so that said, your choice of window function is highly dependent on your specific needs. for instance, if you're trying to separate / identify two signals that are fairly close in frequency, but similar in strength, then you should choose the rectangular, because it will give you the best resolution. on the other hand, if you're trying to do the same with two different strength signals with differing frequencies, you can easily see how energy from one can leak in through the high sidelobes. in this case, you wouldn't mind one of the fatter main lobes and would trade a slight loss in resolution to be able to estimate their powers more accurately. in seismic and geophysics, it is common to use slepian windows ( or discrete prolate spheroidal wavefunctions, which are the eigenfunctions of a sinc kernel ) to maximize the energy concentrated in the main lobe.


i'd like to find genes that were not expressed in a group of samples and were expressed in another group. this is, fundamentally, a differential expression analysis, with a twist. to solve this, you ’ d first use a differential expression library of your choice ( e. g. deseq2 ) and perform a one - tailed test of differential expression. briefly, you ’ d perform the normal setup and then use results ( dds, althypothesis ='greater') to perform a one - tailed test. this will give you only those genes that are significantly upregulated in one group. check chapter 3. 9 of the vignette for details. of course this won ’ t tell you that the genes are unexpressed in the other group. unfortunately i don ’ t know of a good value to threshold the results ; i would start by plotting a histogram of the ( variance stabilised ) expression values in your first group, and then visually choose an expression threshold that cleanly separates genes that are clearly expressed from zeros : vst _ counts = assay ( vst ( dds ) ) dens = density ( vst _ counts [, replicate ] ) plot ( dens, log ='y') ( this merges the replicates in the group, which should be fine. ) counts follow a multimodal distribution, with one mode for unexpressed and one or more for expressed genes. the expression threshold can be set somewhere between the clearly unexpressed and expressed peaks : here i used identify ( dens ) to identify the threshold interactively but you could also use an analytical method : threshold = identify ( dens ) quantile = sum ( dens $ x < dens $ x [ threshold ] ) / length ( dens $ x ) # using just one replicate here ; more robust would be to use a mean value. nonzero _ counts = counts ( dds, normalized = true ) [, replicates [ 1 ] ] nonzero _ counts = nonzero _ counts [ nonzero _ counts > 0 ] ( expression _ threshold = quantile ( nonzero _ counts, probs = quantile ) ) 26. 5625 % 4. 112033


it's simpler than you think. when we discretize frequencies, we get frequency bins. so, when you discretize your fourier transform : $ $ e ^ { - j \ omega } \ rightarrow e ^ { - j { 2 \ pi k } / { n } } $ $ our continuous frequencies become $ n $ discrete bins. this is exactly why the following is true : $ $ n ^ { th } \, \ text { bin } = n * \ dfrac { \ text { samplefreq } } { \ text { nfft } } $ $ where $ \ text { nfft } $ is the length of the dft. note that the fft represents frequencies $ 0 $ to $ \ text { samplefreq } $ hz. ( rab - actually, if $ \ text { nfft } = n $, then your bin index will span from $ 0 $ through $ n - 1 $. therefore, the frequencies generated will be ( 0 : n - 1 ) * samplefreq / nfft, and you won't get the $ n \ cdot \ text { samplefreq } / n = \ text { samplefreq } $ bin. that unrepresented bin will alias onto and be summed with the $ 0 $ bin. instead, you will get bins ( 0 : 9 ) * samplefreq / 10 in other words, if sampling 10 times per second, and sampling for 1 second, our frequency bins will be 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 hz. notice that the 10 hz bin is not there.


first, a note on spelling. both " ortholog " and " orthologue " are correct, one is the american and the other the british spelling. the same is true for homolog / homologue and paralog / paralogue. on to the biology. homology is the blanket term, both ortho - and paralogs are homologs. so, when in doubt use " homologs ". however : orthologs are homologous genes that are the result of a speciation event. paralogs are homologous genes that are the result of a duplication event. the following image, adapted ( slightly ) from [ 1 ], illustrates the differences : part ( a ) of the diagram above shows a hypothetical evolutionary history of a gene. the ancestral genome had two copies of this gene ( a and b ) which were paralogs. at some point, the ancestral species split into two daughter species, each of whose genome contains two copies of the ancestral duplicated gene ( a1, a2 and b1, b2 ). these genes are all homologous to one another but are they paralogs or orthologs? since the duplication event that created genes a and b occurred before the speciation event that created species 1 and 2, a genes will be paralogs of b genes and 1 genes will be orthologs of 2 genes : a1 and b1 are paralogs a1 and b2 are paralogs. a2 and b1 are paralogs. a2 and b2 are paralogs. a1 and a2 are orthologs. b1 and b2 are orthologs this however, is a very simple case. what happens when a duplication occurs after a speciation event? in part ( b ) of the above diagram, the ancestral gene was duplicated only in species 2's lineage. therefore, in ( b ) : a2 and b2 are orthologs of a1. a2 and b2 are paralogs of each other. a common misconception is that paralogous genes are those homologous genes that are in the same genome while orthologous genes are those that are in different genomes. as you can see in the example above, this is absolutely not true. while it can happen that way, ortho - vs paralogy depends exclusively on the evolutionary history of the genes involved. if you do not know whether a particular homology relationship is the result of a


gene duplication or a speciation event, then you cannot know if it is a case of paralogy or orthology. references r. a. jensen, orthologs and paralogs - we need to get it right, genome biology, 2 ( 8 ), 2001 suggested reading : i highly recommend the jensen article referenced above. i read it when i was first starting to work on comparative genomics and evolution and it is a wonderfully clear and succinct explanation of the terms. some of the articles referenced therein are also worth a read : koonin ev : an apology for orthologs - or brave new memes. genome biol, 2001, 2 : comment1005. 1 - 1005. 2. petsko ga : homologuephobia. genome biol 2001, 2 : comment1002. 1 - 1002. 2. fitch wm : distinguishing homologous from analogous proteins. syst zool 1970, 19 : 99 - 113. ( of historical interest, the terms were first used here ) fitch wm : homology a personal view on some of the problems. trends genet 2000, 16 : 227 - 31.


ftensor is a lightweight, header only, fully templated library that includes ergonomic summation notation. it has been tested extensively in 2, 3, and 4 dimensions, but should work fine for any number of dimensions.


a standard linear model ( e. g., a simple regression model ) can be thought of as having two'parts '. these are called the structural component and the random component. for example : $ $ y = \ beta _ 0 + \ beta _ 1x + \ varepsilon \ \ \ text { where } \ varepsilon \ sim \ mathcal { n } ( 0, \ sigma ^ 2 ) $ $ the first two terms ( that is, $ \ beta _ 0 + \ beta _ 1x $ ) constitute the structural component, and the $ \ varepsilon $ ( which indicates a normally distributed error term ) is the random component. when the response variable is not normally distributed ( for example, if your response variable is binary ) this approach may no longer be valid. the generalized linear model ( glim ) was developed to address such cases, and logit and probit models are special cases of glims that are appropriate for binary variables ( or multi - category response variables with some adaptations to the process ). a glim has three parts, a structural component, a link function, and a response distribution. for example : $ $ g ( \ mu ) = \ beta _ 0 + \ beta _ 1x $ $ here $ \ beta _ 0 + \ beta _ 1x $ is again the structural component, $ g ( ) $ is the link function, and $ \ mu $ is a mean of a conditional response distribution at a given point in the covariate space. the way we think about the structural component here doesn't really differ from how we think about it with standard linear models ; in fact, that's one of the great advantages of glims. because for many distributions the variance is a function of the mean, having fit a conditional mean ( and given that you stipulated a response distribution ), you have automatically accounted for the analog of the random component in a linear model ( n. b. : this can be more complicated in practice ). the link function is the key to glims : since the distribution of the response variable is non - normal, it's what lets us connect the structural component to the response - - it'links'them ( hence the name ). it's also the key to your question, since the logit and probit are links ( as @ vinux explained ), and understanding link functions will allow us to intelligently choose when to use which one. although there can be many link functions


that can be acceptable, often there is one that is special. without wanting to get too far into the weeds ( this can get very technical ) the predicted mean, $ \ mu $, will not necessarily be mathematically the same as the response distribution's canonical location parameter ; the link function that does equate them is the canonical link function. the advantage of this " is that a minimal sufficient statistic for $ \ beta $ exists " ( german rodriguez ). the canonical link for binary response data ( more specifically, the binomial distribution ) is the logit. however, there are lots of functions that can map the structural component onto the interval $ ( 0, 1 ) $, and thus be acceptable ; the probit is also popular, but there are yet other options that are sometimes used ( such as the complementary log log, $ \ ln ( - \ ln ( 1 - \ mu ) ) $, often called'cloglog'). thus, there are lots of possible link functions and the choice of link function can be very important. the choice should be made based on some combination of : knowledge of the response distribution, theoretical considerations, and empirical fit to the data. having covered a little of conceptual background needed to understand these ideas more clearly ( forgive me ), i will explain how these considerations can be used to guide your choice of link. ( let me note that i think @ david's comment accurately captures why different links are chosen in practice. ) to start with, if your response variable is the outcome of a bernoulli trial ( that is, $ 0 $ or $ 1 $ ), your response distribution will be binomial, and what you are actually modeling is the probability of an observation being a $ 1 $ ( that is, $ \ pi ( y = 1 ) $ ). as a result, any function that maps the real number line, $ ( - \ infty, + \ infty ) $, to the interval $ ( 0, 1 ) $ will work. from the point of view of your substantive theory, if you are thinking of your covariates as directly connected to the probability of success, then you would typically choose logistic regression because it is the canonical link. however, consider the following example : you are asked to model high _ blood _ pressure as a function of some covariates. blood pressure itself is normally distributed in the population ( i don't actually know that, but it seems reasonable prima facie


), nonetheless, clinicians dichotomized it during the study ( that is, they only recorded'high - bp'or'normal'). in this case, probit would be preferable a - priori for theoretical reasons. this is what @ elvis meant by " your binary outcome depends on a hidden gaussian variable ". another consideration is that both logit and probit are symmetrical, if you believe that the probability of success rises slowly from zero, but then tapers off more quickly as it approaches one, the cloglog is called for, etc. lastly, note that the empirical fit of the model to the data is unlikely to be of assistance in selecting a link, unless the shapes of the link functions in question differ substantially ( of which, the logit and probit do not ). for instance, consider the following simulation : set. seed ( 1 ) problower = vector ( length = 1000 ) for ( i in 1 : 1000 ) { x = rnorm ( 1000 ) y = rbinom ( n = 1000, size = 1, prob = pnorm ( x ) ) logitmodel = glm ( y ~ x, family = binomial ( link = " logit " ) ) probitmodel = glm ( y ~ x, family = binomial ( link = " probit " ) ) problower [ i ] = deviance ( probitmodel ) < deviance ( logitmodel ) } sum ( problower ) / 1000 [ 1 ] 0. 695 even when we know the data were generated by a probit model, and we have 1000 data points, the probit model only yields a better fit 70 % of the time, and even then, often by only a trivial amount. consider the last iteration : deviance ( probitmodel ) [ 1 ] 1025. 759 deviance ( logitmodel ) [ 1 ] 1026. 366 deviance ( logitmodel ) - deviance ( probitmodel ) [ 1 ] 0. 6076806 the reason for this is simply that the logit and probit link functions yield very similar outputs when given the same inputs. the logit and probit functions are practically identical, except that the logit is slightly further from the bounds when they'turn the corner ', as @ vinux stated. ( note that to get the logit and the probit to align optimal


##ly, the logit's $ \ beta _ 1 $ must be $ \ approx 1. 7 $ times the corresponding slope value for the probit. in addition, i could have shifted the cloglog over slightly so that they would lay on top of each other more, but i left it to the side to keep the figure more readable. ) notice that the cloglog is asymmetrical whereas the others are not ; it starts pulling away from 0 earlier, but more slowly, and approaches close to 1 and then turns sharply. a couple more things can be said about link functions. first, considering the identity function ( $ g ( \ eta ) = \ eta $ ) as a link function allows us to understand the standard linear model as a special case of the generalized linear model ( that is, the response distribution is normal, and the link is the identity function ). it's also important to recognize that whatever transformation the link instantiates is properly applied to the parameter governing the response distribution ( that is, $ \ mu $ ), not the actual response data. finally, because in practice we never have the underlying parameter to transform, in discussions of these models, often what is considered to be the actual link is left implicit and the model is represented by the inverse of the link function applied to the structural component instead. that is : $ $ \ mu = g ^ { - 1 } ( \ beta _ 0 + \ beta _ 1x ) $ $ for instance, logistic regression is usually represented : $ $ \ pi ( y ) = \ frac { \ exp ( \ beta _ 0 + \ beta _ 1x ) } { 1 + \ exp ( \ beta _ 0 + \ beta _ 1x ) } $ $ instead of : $ $ \ ln \ left ( \ frac { \ pi ( y ) } { 1 - \ pi ( y ) } \ right ) = \ beta _ 0 + \ beta _ 1x $ $ for a quick and clear, but solid, overview of the generalized linear model, see chapter 10 of fitzmaurice, laird, & ware ( 2004 ), ( on which i leaned for parts of this answer, although since this is my own adaptation of that - - and other - - material, any mistakes would be my own ). for how to fit these models in r, check out the documentation for the function? glm in the base package. ( one final note added later : ) i occasionally hear people say


that you shouldn't use the probit, because it can't be interpreted. this is not true, although the interpretation of the betas is less intuitive. with logistic regression, a one unit change in $ x _ 1 $ is associated with a $ \ beta _ 1 $ change in the log odds of'success'( alternatively, an $ \ exp ( \ beta _ 1 ) $ - fold change in the odds ), all else being equal. with a probit, this would be a change of $ \ beta _ 1 \ text { } z $'s. ( think of two observations in a dataset with $ z $ - scores of 1 and 2, for example. ) to convert these into predicted probabilities, you can pass them through the normal cdf, or look them up on a $ z $ - table. ( + 1 to both @ vinux and @ elvis. here i have tried to provide a broader framework within which to think about these things and then using that to address the choice between logit and probit. )


the central issue is the length of the critical path $ c $ relative to the total amount of computation $ t $. if $ c $ is proportional to $ t $, then parallelism offers at best a constant speed - up. if $ c $ is asymptotically smaller than $ t $, there is room for more parallelism as the problem size increases. for algorithms in which $ t $ is polynomial in the input size $ n $, the best case is $ c \ sim \ log t $ because very few useful quantities can be computed in less than logarithmic time. examples $ c = t $ for a tridiagonal solve using the standard algorithm. every operation is dependent on the previous operation completing, so there is no opportunity for parallelism. tridiagonal problems can be solved in logarithmic time on a parallel computer using a nested dissection direct solve, multilevel domain decomposition, or multigrid with basis functions constructed using harmonic extension ( these three algorithms are distinct in multiple dimensions, but can exactly coincide in 1d ). a dense lower - triangular solve with an $ m \ times m $ matrix has $ t = n = \ mathcal o ( m ^ 2 ) $, but the critical path is only $ c = m = \ sqrt t $, so some parallelism can be beneficial. multigrid and fmm both have $ t = n $, with a critical path of length $ c = \ log t $. explicit wave propagation for a time $ \ tau $ on a regular mesh of the domain $ ( 0, 1 ) ^ d $ requires $ k = \ tau / \ delta t \ sim \ tau n ^ { 1 / d } $ time steps ( for stability ), therefore the critical path is at least $ c = k $. the total amount of work is $ t = k n = \ tau n ^ { ( d + 1 ) / d } $. the maximum useful number of processors is $ p = t / c = n $, the remaining factor $ n ^ { 1 / d } $ cannot be recovered by increased parallelism. formal complexity the nc complexity class characterizes those problems that can be solved efficiently in parallel ( i. e., in polylogarithmic time ). it is unknown whether $ nc = p $, but it is widely hypothesized to be false. if this is indeed the case, then p - complete characterizes those problems that are " inherently


sequential " and cannot be sped up significantly by parallelism.


let $ v $ be a vector space ( over any field, but we can take it to be $ \ mathbb r $ if you like, and for concreteness i will take the field to be $ \ mathbb r $ from now on ; everything is just as interesting in that case ). certainly one of the interesting concepts in linear algebra is that of a hyperplane in $ v $. for example, if $ v = \ mathbb r ^ n $, then a hyperplane is just the solution set to an equation of the form $ $ a _ 1 x _ 1 + \ cdots + a _ n x _ n = b, $ $ for some $ a _ i $ not all zero and some $ b $. recall that solving such equations ( or simultaneous sets of such equations ) is one of the basic motivations for developing linear algebra. now remember that when a vector space is not given to you as $ \ mathbb r ^ n $, it doesn't normally have a canonical basis, so we don't have a canonical way to write its elements down via coordinates, and so we can't describe hyperplanes by explicit equations like above. ( or better, we can, but only after choosing coordinates, and this is not canonical. ) how can we canonically describe hyperplanes in $ v $? for this we need a conceptual interpretation of the above equation. and here linear functionals come to the rescue. more precisely, the map $ $ \ begin { align * } \ ell : \ mathbb { r } ^ n & \ rightarrow \ mathbb { r } \ \ ( x _ 1, \ ldots, x _ n ) & \ mapsto a _ 1 x _ 1 + \ cdots + a _ n x _ n \ end { align * } $ $ is a linear functional on $ \ mathbb r ^ n $, and so the above equation for the hyperplane can be written as $ $ \ ell ( v ) = b, $ $ where $ v = ( x _ 1, \ ldots, x _ n ). $ more generally, if $ v $ is any vector space, and $ \ ell : v \ to \ mathbb r $ is any non - zero linear functional ( i. e. non - zero element of the dual space ), then for any $ b \ in \ mathbb r, $ the set $ $ \ { v \, | \, \ ell ( v


) = b \ } $ $ is a hyperplane in $ v $, and all hyperplanes in $ v $ arise this way. so this gives a reasonable justification for introducing the elements of the dual space to $ v $ ; they generalize the notion of linear equation in several variables from the case of $ \ mathbb r ^ n $ to the case of an arbitrary vector space. now you might ask : why do we make them a vector space themselves? why do we want to add them to one another, or multiply them by scalars? there are lots of reasons for this ; here is one : remember how important it is, when you solve systems of linear equations, to add equations together, or to multiply them by scalars ( here i am referring to all the steps you typically make when performing gaussian elimination on a collection of simultaneous linear equations )? well, under the dictionary above between linear equations and linear functionals, these processes correspond precisely to adding together linear functionals, or multiplying them by scalars. if you ponder this for a bit, you can hopefully convince yourself that making the set of linear functionals a vector space is a pretty natural thing to do. summary : just as concrete vectors $ ( x _ 1, \ ldots, x _ n ) \ in \ mathbb r ^ n $ are naturally generalized to elements of vector spaces, concrete linear expressions $ a _ 1 x _ 1 + \ ldots + a _ n x _ n $ in $ x _ 1, \ ldots, x _ n $ are naturally generalized to linear functionals.


if you want to normalize your data, you can do so as you suggest and simply calculate the following : $ $ z _ i = \ frac { x _ i - \ min ( x ) } { \ max ( x ) - \ min ( x ) } $ $ where $ x = ( x _ 1,..., x _ n ) $ and $ z _ i $ is now your $ i ^ { th } $ normalized data. as a proof of concept ( although you did not ask for it ) here is some r code and accompanying graph to illustrate this point : # example data x = sample ( - 100 : 100, 50 ) # normalized data normalized = ( x - min ( x ) ) / ( max ( x ) - min ( x ) ) # histogram of example data and normalized data par ( mfrow = c ( 1, 2 ) ) hist ( x, breaks = 10, xlab = " data ", col = " lightblue ", main = " " ) hist ( normalized, breaks = 10, xlab = " normalized data ", col = " lightblue ", main = " " )


i think your question implicates another question ( which is also mentioned in some comments here ), namely : why are all energy eigenvalues of states with a different angular momentum quantum number $ \ ell $ but with the same principal quantum number $ n $ ( e. g., $ \ mathrm { 3s } $, $ \ mathrm { 3p } $, $ \ mathrm { 3d } $ ) degenerate in the hydrogen atom but non - degenerate in multi - electron atoms? although acidflask already gave a good answer ( mostly on the non - degeneracy part ) i will try to eleborate on it from my point of view and give some additional information. i will split my answer in three parts : the first will address the $ \ ell $ - degeneracy in the hydrogen atom, in the second i will try to explain why this degeneracy is lifted, and in the third i will try to reason why $ \ mathrm { 3s } $ states are lower in energy than $ \ mathrm { 3p } $ states ( which are in turn lower in energy than $ \ mathrm { 3d } $ states ). $ \ ell $ - degeneracy of the hydrogen atoms energy eigenvalues the non - relativistic electron in a hydrogen atom experiences a potential that is analogous to the kepler problem known from classical mechanics. this potential ( aka kepler potential ) has the form $ \ frac { \ kappa } { r } $, where $ r $ is the distance between the nucleus and the electron, and $ \ kappa $ is a proportionality constant. now, it is known from physics that symmetries of a system lead to conserved quantities ( noether theorem ). for example from the rotational symmetry of the kepler potential follows the conservation of the angular momentum, which is characterized by $ \ ell $. but while the length of the angular momentum vector is fixed by $ \ ell $ there are still different possibilities for the orientation of its $ z $ - component, characterized by the magnetic quantum number $ m $, which are all energetically equivalent as long as the system maintains its rotational symmetry. so, the rotational symmetry leads to the $ m $ - degeneracy of the energy eigenvalues for the hydrogen atom. analogously, the $ \ ell $ - degeneracy of the hydrogen atoms energy eigenvalues can also be traced


back to a symmetry, the $ so ( 4 ) $ symmetry. the system's $ so ( 4 ) $ symmetry is not a geometric symmetry like the one explored before but a so called dynamical symmetry which follows from the form of the schroedinger equation for the kepler potential. ( it corresponds to rotations in a four - dimensional cartesian space. note that these rotations do not operate in some physical space. ) this dynamical symmetry conserves the laplace - runge - lenz vector $ \ hat { \ vec { m } } $ and it can be shown that this conserved quantity leads to the $ \ ell $ - independent energy spectrum with $ e \ propto \ frac { 1 } { n ^ 2 } $. ( a detailed derivation, though in german, can be found here. ) why is the $ \ ell $ - degeneracy of the energy eigenvalues lifted in multi - electron atoms? as the $ m $ - degeneracy of the hydrogen atom's energy eigenvalues can be broken by destroying the system's spherical symmetry, e. g., by applying a magnetic field, the $ \ ell $ degeneracy is lifted as soon as the potential appearing in the hamilton operator deviates from the pure $ \ frac { \ kappa } { r } $ form. this is certainly the case for multielectron atoms since the outer electrons are screened from the nuclear coulomb attraction by the inner electrons and the strength of the screening depends on their distance from the nucleus. ( other factors, like spin and relativistic effects, also lead to a lifting of the $ \ ell $ - degeneracy even in the hydrogen atom. ) why do states with the same $ n $ but lower $ \ ell $ values have lower energy eigenvalues? two effects are important here : the centrifugal force puts an " energy penalty " onto states with higher angular momentum. $ { } ^ { 1 } $ so, a higher $ \ ell $ value implies a stronger centrifugal force, that pushes electrons away from the nucleus. the concept of centrifugal force can be seen in the radial schroedinger equation for the radial part $ r ( r ) $ of the wave function $ \ psi ( r, \ theta, \ varphi ) = r ( r ) y _ { \ ell, m } ( \ theta, \


varphi ) $ \ begin { equation } \ bigg ( \ frac { - \ hbar ^ { 2 } } { 2 m _ { \ mathrm { e } } } \ frac { \ mathrm { d } ^ { 2 } } { \ mathrm { d } r ^ { 2 } } + \ underbrace { \ frac { \ hbar ^ { 2 } } { 2 m _ { \ mathrm { e } } } \ frac { \ ell ( \ ell + 1 ) } { r ^ { 2 } } } - \ frac { z e ^ { 2 } } { 2 m _ { \ mathrm { e } } r } - e \ bigg ) r r ( r ) = 0 \ end { equation } \ begin { equation } { } ^ { = ~ v ^ { \ ell } _ { \ mathrm { cf } } ( r ) } \ qquad \ qquad \ end { equation } the radial part experiences an additional $ \ ell $ - dependent potential $ v ^ { \ ell } _ { \ mathrm { cf } } ( r ) $ that pushes the electrons away from the nucleus. core repulsion ( pauli repulsion ), on the other hand, puts an " energy penalty " on states with a lower angular momentum. that is because the core repulsion acts only between electrons with the same angular momentum $ { } ^ { 1 } $. so it acts stronger on the low - angular momentum states since there are more core shells with lower angular momentum. core repulsion is due to the condition that the wave functions must be orthogonal which in turn is a consequence of the pauli principle. because states with different $ \ ell $ values are already orthogonal by their angular motion, there is no pauli repulsion between those states. however, states with the same $ \ ell $ value feel an additional effect from core orthogonalization. the " accidental " $ \ ell $ - degeneracy of the hydrogen atom can be described as a balance between centrifugal force and core repulsion, that both act against the nuclear coulomb attraction. in the real atom the balance between centrifugal force and core repulsion is broken, the core electrons are contracted compared to the outer electrons because there are less inner electron - shells screening the nuclear attraction from the core shells than from the valence electrons. since the inner electron shells are more contracted


than the outer ones, the core repulsion is weakened whereas the effects due to the centrifugal force remain unchanged. the reduced core repulsion in turn stabilizes the states with lower angular momenta, i. e. lower $ \ ell $ values. so, $ \ mathrm { 3s } $ states are lower in energy than $ \ mathrm { 3p } $ states which are in turn lower in energy than $ \ mathrm { 3d } $ states. of course, one has to be careful when using results of the hydrogen atom to describe effects in multielectron atoms as acidflask mentioned. but since only a qualitative description is needed this might be justifiable. i hope this somewhat lengthy answer is helpful. if something is wrong with my arguments i'm happy to discuss those points.


i'm not sure about the existence of molecules with bridges through rings. however, there are several publications of synthesis of molecules mimicking wheels and axles ( [ 2 ] rotaxanes ; the “ [ 2 ] ” refers to the number of interlocked components ) as one shown below ( ref. 1 ) : ( the diagram is from reference 1 ) this specific molecule ( 8 ; an “ impossible ” [ 2 ] rotaxane ) represents a macro - cycle with a straight - chain molecule with bulky end groups going through its center. the inclusion of two bulky end groups prevents the straight - chain molecule leaving the macro - cycle ( mechanically interlocked ) as depicted in the diagram ( see ref. 2 for the total synthesis of the molecule ). note that ref. 1 also cited articles for the synthesis of [ 2 ] catenanes, which contain two interlocked rings ( instead of one axle and one macrocycle ). keep in mind that there are some advanced catenanes and rotaxanes that exist ( e. g., [ 3 ] catenanes and [ 3 ] rotaxanes ). ( the structures are from reference 1 ) references : edward a. neal, stephen m. goldup, " chemical consequences of mechanical bonding in catenanes and rotaxanes : isomerism, modification, catalysis and molecular machines for synthesis, " chem. commun. 2014, 50 ( 40 ), 5128 - 5142 ( jeffrey s. hannam, stephen m. lacy, david a. leigh, carlos g. saiz, alexandra m. z. slawin, sheila g. stitchell, " controlled submolecular translational motion in synthesis : a mechanically interlocking auxiliary, " angew. chem., intl. fd. 2004, 43 ( 25 ), 3260 - 3264 (


i think the ( first order ) right thing to do is look at the ratio of flops to bytes needed in the algorithm, which i call $ \ beta $. let $ f _ { \ mathrm { max } } $ be the maximum flop rate of the processor, and $ b _ { \ mathrm { max } } $ the maximum bandwidth. if $ \ frac { f _ { \ mathrm { max } } } { \ beta } > b _ { \ mathrm { max } } $, then the algorithm will be bandwidth limited. if $ b _ { \ mathrm { max } } \ beta > f _ { \ mathrm { max } } $, the algorithm is flop limited. i think counting memory accesses is mandatory, but we should also be thinking about : how much local memory is required how much possible concurrency we have then you can start to analyze algorithms for modern hardware.


$ $ x ^ 2 = \ underbrace { x + x + \ cdots + x } _ { ( x \ text { times } ) } $ $ $ $ \ frac { d } { dx } x ^ 2 = \ frac { d } { dx } [ \ underbrace { x + x + \ cdots + x } _ { ( x \ text { times } ) } ] $ $ $ $ 2x = 1 + 1 + \ cdots + 1 = x $ $ $ $ 2 = 1 $ $


short answer : no, you don't have to do integration for certain fems. but in your case, you have to do that. long answer : let's say $ u _ h $ is the finite element solution. if you choose piecewise linear polynomial as your basis, then taking $ \ delta $ on it will give you an order 1 distribution ( think taking derivative on a heaviside step function ), and the integration of $ - \ delta u _ h \ in h ^ { - 1 } $ multiplying with $ v $ will only make sense when you take it as a duality pair rather than an $ l ^ 2 $ - inner product. you will neither get a null matrix, the riesz representation theorem says that there is an element in $ \ varphi _ { - \ delta u _ h } \ in h ^ 1 _ 0 $ can characterize the duality pair by the inner product in $ h ^ 1 $ : $ $ \ langle - \ delta u _ h, v \ rangle _ { h ^ { - 1 }, h ^ 1 _ 0 } = \ underbrace { \ int _ { \ omega } \ nabla \ varphi _ { - \ delta u _ h } \ cdot \ nabla v } _ { \ text { inner product in } h ^ 1 }. $ $ integrating by parts element by element for $ u _ h $ will shed a light on this duality pair : for $ t $ an element in this triangulation $ $ \ int _ { \ omega } \ nabla u _ h \ cdot \ nabla v = - \ sum _ { t } \ left ( \ int _ { t } \ delta u _ h \, v + \ int _ { \ partial t } \ frac { \ partial u _ h } { \ partial n } v \, ds \ right ), $ $ this tells you that $ - \ delta u _ h $ should include inter - element flux jump in its duality pair representation, notice the integration on the boundary of each element is also a duality pair between $ h ^ { 1 / 2 } $ and $ h ^ { - 1 / 2 } $. even if you use quadratic basis, which has a non - vanishing $ \ delta $ on each element, you still can't write $ ( \ delta u, v ) $ as an inner product, because of this inter - element flux jump's presence.


integration by parts can be traced back to the sobolev theory for elliptic pde using smooth function, where the $ w ^ { k, p } $ - spaces are all closure of smooth functions under the $ w ^ { k, p } $ type of integral norm. then people say what is the minimum regularity here that we can perform inner product. also bearing in mind that an $ h ^ 1 $ - regular weak solution under certain condition is the $ h ^ 2 $ - strong solution ( elliptic regularity ). but piecewise continuous linear polynomial is not $ h ^ 2 $, from this point of view, it doesn't make any sense to take inner product using $ \ delta u _ h $ either. for certain fems, you don't have to do integration by parts. for example, least - square finite element. write the second order pde as a first order system : $ $ \ begin { cases } \ boldsymbol { \ sigma } = - \ nabla u, \ \ \ nabla \ cdot \ boldsymbol { \ sigma } = f. \ end { cases } $ $ then you wanna minimize the least - square functional : $ $ \ mathcal { j } ( v ) = \ | \ boldsymbol { \ sigma } + \ nabla u \ | _ { l ^ 2 { \ omega } } ^ 2 + \ | \ nabla \ cdot \ boldsymbol { \ sigma } - f \ | _ { l ^ 2 { \ omega } } ^ 2, $ $ bearing the same spirit with ritz - galerkin functional, the finite element formulation of minimizing above functional in a finite element space does not require integration by parts.


it depends a lot on the size of your matrix, in the large - scale case also on whether it is sparse, and on the accuracy you want to achieve. if your matrix is too large to allow a single factorization, and you need high accuracy, the lanczsos algorithm is probably the fastest way. in the nonsymmetric case, the arnoldi algorithm is needed, which is numerically unstable, so an implementation needs to address this ( is somewhat awkward to cure ). if this is not the case in your problem, give more specific information in your question. then add a comment to this answer, and i'll update it. edit : [ this was for the old version of the question, asling for the largest eigenvalue. ] as your matrix is small and apparently dense, i'd do arnoldi iteration on b = ( i - a ) ^ { - 1 }, using an initial permuted triangular factorization of i - a to have cheap multiplication by b. ( or compute an explicit inverse, but this costs 3 times as much as the factorization. ) you want to test whether b has a negative eigenvalue. working with b in place of a, negative eigenvalues are much better separated, so if there is one, you should converge rapidly. but i am curious about where your problem comes from. nonsymmetric matrices usually have complex eigenvalues, so'' largest'' isn't even well - defined. thus you must know more about your problem, which might help in suggesting how to solve it even faster and / or more reliably. edit2 : it is difficult to get with arnoldi a particular subset of interest. to get the absolutely largest eigenvalues reliably, you'd do subspace iteration using the original matrix, with a subspace size matching or exceeding the number of eigenvalues expected to be close to 1 or larger in magnitude. on small matrices, this will be slower than the qr algorithm but on large matrices it will be much faster.


it is a result from the insecticide you are using. from this excerpt from the 10th edition of the mallis handbook on pest control : neurotoxic insecticides cause tremors and muscle spasms, flipping the cockroach on its back. a healthy cockroach can easily right itself, but without muscle coordination, the cockroach dies on its back. cockroaches exposed to slow - acting insecticides that target respiration ( energy production ) also can die “ face - down, ” as they run out of energy without experiencing muscle spasms. here's also a website from umass describing it in more detail : most of these insecticides are organophosphate nerve poisons. the nerve poison often inhibits cholinesterase, an enzyme that breaks down acetyl choline ( ach ), a neurotransmitter. with extra ach in the nervous system, the cockroach has muscular spasms which often result in the cockroach flipping on its back. without muscular coordination the cockroach cannot right itself and eventually dies in its upside down - position. and an entomology professor even answered this for maxim : most insecticides are poisons that target a bug ’ s nervous system. when you spray a roach, those neurotoxins cause tremors and muscle spasms, which flip it onto its back, and without muscle coordination, that ’ s the position it dies in


the odour threshold for hydrogen cyanide $ ( \ ce { hcn } ) $ is in fact quite a bit lower than the lethal toxicity threshold. data for $ \ ce { hcn } $ can be found in many places, but here and here are a couple of good references. that subset of the human population that can detect bitter almonds do so at a threshold of $ 0. 58 $ to $ \ pu { 5 ppm } $. the lethal exposure dose is upwards of $ \ pu { 135 ppm } $. that's a whole $ \ pu { 100 ppm } $ range in which to detect and report the fragrant properties.


was xkcd, so time for dilbert : source :


if you are not well - acquainted with special relativity, there is no way to truly explain this phenomenon. the best one could do is give you rules steeped in esoteric ideas like " electromagnetic field " and " lorentz invariance. " of course, this is not what you're after, and rightly so, since physics should never be about accepting rules handed down from on high without justification. the fact is, magnetism is nothing more than electrostatics combined with special relativity. unfortunately, you won't find many books explaining this - either the authors mistakenly believe maxwell's equations have no justification and must be accepted on faith, or they are too mired in their own esoteric notation to pause to consider what it is they are saying. the only book i know of that treats the topic correctly is purcell's electricity and magnetism, which was recently re - released in a third edition. ( the second edition works just fine if you can find a copy. ) a brief, heuristic outline of the idea is as follows. suppose there is a line of positive charges moving along the $ z $ - axis in the positive direction - a current. consider a positive charge $ q $ located at $ ( x, y, z ) = ( 1, 0, 0 ) $, moving in the negative $ z $ - direction. we can see that there will be some electrostatic force on $ q $ due to all those charges. but let's try something crazy - let's slip into $ q $'s frame of reference. after all, the laws of physics had better hold for all points of view. clearly the charges constituting the current will be moving faster in this frame. but that doesn't do much, since after all the coulomb force clearly doesn't care about the velocity of the charges, only on their separation. but special relativity tells us something else. it says the current charges will appear closer together. if they were spaced apart by intervals $ \ delta z $ in the original frame, then in this new frame they will have a spacing $ \ delta z \ sqrt { 1 - v ^ 2 / c ^ 2 } $, where $ v $ is $ q $'s speed in the original frame. this is the famous length contraction predicted by special relativity. if the current charges appear closer together, then clearly $ q $ will feel a larger electrostatic force from the $ z $ - axis as a whole. it will experience an additional


force in the positive $ x $ - direction, away from the axis, over and above what we would have predicted from just sitting in the lab frame. basically, coulomb's law is the only force law acting on a charge, but only the charge's rest frame is valid for using this law to determine what force the charge feels. rather than constantly transforming back and forth between frames, we invent the magnetic field as a mathematical device that accomplishes the same thing. if defined properly, it will entirely account for this anomalous force seemingly experienced by the charge when we are observing it not in its own rest frame. in the example i just went through, the right - hand rule tells you we should ascribe a magnetic field to the current circling around the $ z $ - axis such that it is pointing in the positive $ y $ - direction at the location of $ q $. the velocity of the charge is in the negative $ z $ - direction, and so $ q \ vec { v } \ times \ vec { b } $ points in the positive $ x $ - direction, just as we learned from changing reference frames.


you tend to use the covariance matrix when the variable scales are similar and the correlation matrix when variables are on different scales. using the correlation matrix is equivalent to standardizing each of the variables ( to mean 0 and standard deviation 1 ). in general, pca with and without standardizing will give different results. especially when the scales are different. as an example, take a look at this r heptathlon data set. some of the variables have an average value of about 1. 8 ( the high jump ), whereas other variables ( run 800m ) are around 120. library ( hsaur ) heptathlon [, - 8 ] # look at heptathlon data ( excluding'score'variable ) this outputs : hurdles highjump shot run200m longjump javelin run800m joyner - kersee ( usa ) 12. 69 1. 86 15. 80 22. 56 7. 27 45. 66 128. 51 john ( gdr ) 12. 85 1. 80 16. 23 23. 65 6. 71 42. 56 126. 12 behmer ( gdr ) 13. 20 1. 83 14. 20 23. 10 6. 68 44. 54 124. 20 sablovskaite ( urs ) 13. 61 1. 80 15. 23 23. 92 6. 25 42. 78 132. 24 choubenkova ( urs ) 13. 51 1. 74 14. 76 23. 93 6. 32 47. 46 127. 90... now let's do pca on covariance and on correlation : # scale = t bases the pca on the correlation matrix hep. pc. cor = prcomp ( heptathlon [, - 8 ], scale = true ) hep. pc. cov = prcomp ( heptathlon [, - 8 ], scale = false ) biplot ( hep. pc. cov ) biplot ( hep. pc. cor ) notice that pca on covariance is dominated by run800m and javelin : pc1 is almost equal to run800m ( and explains $ 82 \ % $ of the variance ) and pc2 is almost equal to javelin ( together they explain $ 97 \ % $ ). pca on correlation is much more informative and reveals some structure in the data and relationships between variables ( but note that the explained variances drop to $ 64 \ % $ and $ 71 \


% $ ). notice also that the outlying individuals ( in this data set ) are outliers regardless of whether the covariance or correlation matrix is used.


this is a really interesting question. it turns out that your body is reasonably conductive ( think salt water, more on that in the answer to this question ), and that it can couple to rf sources capacitively. referring to the wikipedia article on keyless entry systems ; they typically operate at an rf frequency of $ 315 \ text { mhz } $, the wavelength of which is about $ 1 \ text { m } $. effective antennas ( ignoring fractal antennas ) typically have a length of $ \ frac { \ lambda } { 2 } = \ frac { 1 } { 2 } \ text { m } \ approx1. 5 \ text { ft } $. so, the effect is probably caused by one or more of the cavities in your body ( maybe your head or chest cavity ) acting as a resonance chamber for the rf signal from your wireless remote. for another example of how a resonance chamber can amplify waves think about the hollow area below the strings of a guitar. without the hollow cavity the sound from the guitar would be almost imperceptible. edit : as elucidated in the comments, a cavity doesn't necessarily need to be an empty space ; just a bounded area which partially reflects electromagnetic waves at the boundaries. the area occupied by your brain satisfies these conditions. edit 2 : as pointed out in the comments, a string instrument is significantly louder with just a sounding board behind the strings, so my analogy, though true, is a bit misleading. edit 3 : as promised in the comments, i made some more careful measurements of the effect in question, using a number of different orientations of remote position and pointing. i've posted these as a separate answer to this question.


/ / gcc impredictivepropositionallogic1. c - o impredictivepropositionallogic1. exe - std = c99 - wall - o3 / * which answer in this list is the correct answer to this question? ( a ) all of the below. ( b ) none of the below. ( c ) all of the above. ( d ) one of the above. ( e ) none of the above. ( f ) none of the above. * / # include < stdio. h > # define iff ( x, y ) ( ( x ) = = ( y ) ) int main ( ) { printf ( " a b c d e f \ n " ) ; for ( int a = 0 ; a < = 1 ; a + + ) for ( int b = 0 ; b < = 1 ; b + + ) for ( int c = 0 ; c < = 1 ; c + + ) for ( int d = 0 ; d < = 1 ; d + + ) for ( int e = 0 ; e < = 1 ; e + + ) for ( int f = 0 ; f < = 1 ; f + + ) { int ra = iff ( a, b & & c & & d & & e & & f ) ; int rb = iff ( b,! c & &! d & &! e & &! f ) ; int rc = iff ( c, a & & b ) ; int rd = iff ( d, ( a & &! b & &! c ) | | (! a & & b & &! c ) | | (! a & &! b & & c ) ) ; int re = iff ( e,! a & &! b & &! c & &! d ) ; int rf = iff ( f,! a & &! b & &! c & &! d & &! e ) ; int r = ra & & rb & & rc & & rd & & re & & rf ; if ( r ) printf ( " % d % d % d % d % d % d \ n ", a, b, c, d, e, f ) ; } return 0 ; } this outputs : a b c d e f 0 0 0 0 1 0 the main point i'd like to get across is that you cannot assume at the outset that there is only 1


satisfying assignment. for example consider the question : which of the following is true? ( a ) both of these ( b ) both of these you might be tempted to say that both ( a ) and ( b ) are true. but it is also consistent that both ( a ) and ( b ) are false. the tendency to assume singularity from definitions isn't correct when the definitions are impredictive.


error estimates usually have the form $ $ \ | u - u _ h \ | \ leq c ( h ), $ $ where $ u $ is the exact solution you are interested in, $ u _ h $ is a computed approximate solution, $ h $ is an approximation parameter you can control, and $ c ( h ) $ is some function of $ h $ ( among other things ). in finite element methods, $ u $ is the solution of a partial differential equation and $ u _ h $ would be the finite element solution for a mesh with mesh size $ h $, but you have the same structure in inverse problems ( with the regularization parameter $ \ alpha $ in place of $ h $ ) or iterative methods for solving equations or optimization problems ( with the iteration index $ k $ - - or rather $ 1 / k $ - - in place of $ h $ ). the point of such an estimate is to help answer the question " if i want to get within, say, $ 10 ^ { - 3 } $ of the exact solution, how small do i have to choose $ h $? " the difference between a priori and a posterior estimates is in the form of the right - hand side $ c ( h ) $ : in a priori estimates, the right - hand side depends on $ h $ ( usually explicitly ) and $ u $, but not on $ u _ h $. for example, a typical a priori estimate for the finite element approximation of poisson's equation $ - \ delta u = f $ would have the form $ $ \ | u - u _ h \ | _ { l ^ 2 } \ leq c h ^ 2 | u | _ { h ^ 2 }, $ $ with a constant $ c $ depending on the geometry of the domain and the mesh. in principle, the right - hand side can be evaluated prior to computing $ u _ h $ ( hence the name ), so you'd be able to choose $ h $ before solving anything. in practice, neither $ c $ nor $ | u | _ { h ^ 2 } $ is known ( $ u $ is what you're looking for in the first place ), but you can sometimes get order - or - magnitude estimates for $ c $ by carefully going through the proofs and for $ | u | $ using the data $ f $ ( which is known ). the main use is as a qualitative estimate - - it tells you that if


you want to make the error smaller by a factor of four, you need to halve $ h $. in a posteriori estimates, the right - hand side depends on $ h $ and $ u _ h $, but not on $ u $. a simple residual - based a posterior estimate for poisson's equation would be $ $ \ | u - u _ h \ | _ { l ^ 2 } \ leq c h \ | f + \ delta u _ h \ | _ { h ^ { - 1 } }, $ $ which could in theory be evaluated after computing $ u _ h $. in practice, the $ h ^ { - 1 } $ norm is problematic to compute, so you'd further manipulate the right - hand side to get an element - wise bound $ $ \ | u - u _ h \ | _ { l ^ 2 } \ leq c \ left ( \ sum _ { k } h _ k ^ 2 \ | f + \ delta u _ h \ | _ { l ^ 2 ( k ) } + \ sum _ { f } h _ k ^ { 3 / 2 } \ | j ( \ nabla u _ h ) \ | _ { l ^ 2 ( f ) } \ right ), $ $ where the first sum is over the elements $ k $ of the triangulation, $ h _ k $ is the size of $ k $, the second sum is over all element boundaries $ f $, and $ j ( \ nabla u _ h ) $ denotes the jump of the normal derivative of $ u _ h $ across $ f $. this is now fully computable after obtaining $ u _ h $, except for the constant $ c $. so again the use is mainly qualitative - - it tells you which elements give a larger error contribution than others, so instead of reducing $ h $ uniformly, you just select some elements with large error contributions and make those smaller by subdividing them. this is the basis of adaptive finite element methods.


i used to implement everything myself, but lately have begun using libraries much more. i think there are several very important advantages of using a library, beyond just the issue of whether you have to write a routine yourself or not. if you use a library, you get code that has been tested by hundreds / thousands / more users code that will continue to be updated and improved in the future, without any work on your part optimized code that is more efficient and perhaps more scalable than what you would write in a first attempt depending on the library, by establishing an interface to it in your code you may get access to many algorithms that you currently don't use but may want to in the future in the last bullet point above, i'm thinking of large libraries like trilinos or petsc. i can reinforce this with a couple of concrete personal examples in development of pyclaw. although it would have been straightforward to parallelize clawpack with mpi calls, we chose to use petsc. this allowed us to limit the paralle code in the package to less than 300 lines of python, but even better, by putting our data in petsc's format we gained immediate access to petsc's implicit solvers, enabling current work on an implicit solver in pyclaw. as a second example, pyclaw initially included hand - code fifth - order weno reconstruction, but we eventually decided to rely on the pyweno package for this. this was a huge gain, since pyweno can automatically generate weno routines of any order in several languages. finally, if you use libraries, you can contribute back by developing improvements or finding bugs, which will benefit many other people, whereas debugging or improving your own code only benefits you.


pedagogical dimension due to its simplicity lomuto's partitioning method might be easier to implement. there is a nice anecdote in jon bentley's programming pearl on sorting : “ most discussions of quicksort use a partitioning scheme based on two approaching indices [... ] [ i. e. hoare's ]. although the basic idea of that scheme is straightforward, i have always found the details tricky - i once spent the better part of two days chasing down a bug hiding in a short partitioning loop. a reader of a preliminary draft complained that the standard two - index method is in fact simpler than lomuto's and sketched some code to make his point ; i stopped looking after i found two bugs. ” performance dimension for practical use, ease of implementation might be sacrificed for the sake of efficiency. on a theoretical basis, we can determine the number of element comparisons and swaps to compare performance. additionally, actual running time will be influenced by other factors, such as caching performance and branch mispredictions. as shown below, the algorithms behave very similar on random permutations except for the number of swaps. there lomuto needs thrice as many as hoare! number of comparisons both methods can be implemented using $ n - 1 $ comparisons to partition an array of length $ n $. this is essentially optimal, since we need to compare every element to the pivot for deciding where to put it. number of swaps the number of swaps is random for both algorithms, depending on the elements in the array. if we assume random permutations, i. e. all elements are distinct and every permutation of the elements is equally likely, we can analyze the expected number of swaps. as only relative order counts, we assume that the elements are the numbers $ 1, \ ldots, n $. that makes the discussion below easier since the rank of an element and its value coincide. lomuto's method the index variable $ j $ scans the whole array and whenever we find an element $ a [ j ] $ smaller than pivot $ x $, we do a swap. among the elements $ 1, \ ldots, n $, exactly $ x - 1 $ ones are smaller than $ x $, so we get $ x - 1 $ swaps if the pivot is $ x $. the overall expectation then results by averaging over all pivots. each value in $ \ { 1, \


ldots, n \ } $ is equally likely to become pivot ( namely with prob. $ \ frac1n $ ), so we have $ $ \ frac1n \ sum _ { x = 1 } ^ n ( x - 1 ) = \ frac n2 - \ frac12 \ ;. $ $ swaps on average to partition an array of length $ n $ with lomuto's method. hoare's method here, the analysis is slightly more tricky : even fixing pivot $ x $, the number of swaps remains random. more precisely : the indices $ i $ and $ j $ run towards each other until they cross, which always happens at $ x $ ( by correctness of hoare's partitioning algorithm! ). this effectively divides the array into two parts : a left part which is scanned by $ i $ and a right part scanned by $ j $. now, a swap is done exactly for every pair of “ misplaced ” elements, i. e. a large element ( larger than $ x $, thus belonging in the right partition ) which is currently located in the left part and a small element located in the right part. note that this pair forming always works out, i. e. there the number of small elements initially in the right part equals the number of large elements in the left part. one can show that the number of these pairs is hypergeometrically $ \ mathrm { hyp } ( n - 1, n - x, x - 1 ) $ distributed : for the $ n - x $ large elements we randomly draw their positions in the array and have $ x - 1 $ positions in the left part. accordingly, the expected number of pairs is $ ( n - x ) ( x - 1 ) / ( n - 1 ) $ given that the pivot is $ x $. finally, we average again over all pivot values to obtain the overall expected number of swaps for hoare's partitioning : $ $ \ frac1n \ sum _ { x = 1 } ^ n \ frac { ( n - x ) ( x - 1 ) } { n - 1 } = \ frac n6 - \ frac13 \ ;. $ $ ( a more detailed description can be found in my master's thesis, page 29. ) memory access pattern both algorithms use two pointers into the array that scan it sequentially. therefore both behave almost optimal w. r


. t. caching. equal elements and already sorted lists as already mentioned by wandering logic, the performance of the algorithms differs more drastically for lists that are not random permutations. on an array that is already sorted, hoare's method never swaps, as there are no misplaced pairs ( see above ), whereas lomuto's method still does its roughly $ n / 2 $ swaps! the presence of equal elements requires special care in quicksort. ( i stepped into this trap myself ; see my master's thesis, page 36, for a “ tale on premature optimization ” ) consider as extreme example an array which filled with $ 0 $ s. on such an array, hoare's method performs a swap for every pair of elements - which is the worst case for hoare's partitioning - but $ i $ and $ j $ always meet in the middle of the array. thus, we have optimal partitioning and the total running time remains in $ \ mathcal o ( n \ log n ) $. lomuto's method behaves much more stupidly on the all $ 0 $ array : the comparison a [ j ] < = x will always be true, so we do a swap for every single element! but even worse : after the loop, we always have $ i = n $, so we observe the worst case partitioning, making the overall performance degrade to $ \ theta ( n ^ 2 ) $! conclusion lomuto's method is simple and easier to implement, but should not be used for implementing a library sorting method. clarification in this answer, i explained why a good implementation of the “ crossing - pointer scheme ” from hoare's partitioning method is superior to the simpler scheme of lomuto's method, and i stand by everything i said on that topic. alas, this is strictly speaking not what the op was asking! the pseudocode for hoare - partition as given above does not have the desirable properties i lengthily praised, since it fails to exclude the pivot element from the partitioning range. as a consequence, the pivot is “ lost ” in the swapping and cannot be put into its final position after partitioning, and hence be excluded it from recursive calls. ( that means the recursive calls do no longer fulfill the same randomness assumptions and the whole analysis seems to break down! robert sedgewick's phd dissertation discusses this issue in detail. )


for pseudocode of the desirable implementation analyzed above, see my master's thesis, algorithm 1. ( that code is due to robert sedgewick ).


i can't tell you which to learn, but here's some contrasting points ( from a very vhdl - centric user, but i've tried to be as fair as possible! ), which may help you make a choice based on your own preferences in terms of development style : and keep in mind the famous quote which goes along the lines of " i prefer whichever of the two i'm not currently using " ( sorry, i can't recall who actually wrote this - possibly janick bergeron? ) vhdl strongly - typed more verbose very deterministic non - c - like syntax ( and mindset ) lots of compilation errors to start with, but then mostly works how you expect. this can lead to a very steep feeling learning curve ( along with the unfamiliar syntax ) verilog weakly - typed more concise only deterministic if you follow some rules carefully more c - like syntax ( and mindset ) errors are found later in simulation - the learning curve to " feeling like getting something done " is shallower, but goes on longer ( if that's the right metaphor? ) also in verilog's favour is that high - end verification is leaning more and more to systemverilog which is a huge extension to verilog. but the high - end tools can also combine vhdl synthesis code with systemverilog verification code. for another approach entirely : myhdl - you get all the power of python as a verification language with a set of synthesis extensions from which you can generate either vhdl or verilog. or cocotb - all the power of python as a verification language, with your synthesisable code still written in whichever hdl you decided to learn ( ie vhdl or verilog ). systemc is also a good option for an hdl. systemc supports both system level and register transfer level ( rtl ) design. you need only a c + + compiler to simulate it. high - level synthesis tools will then convert systemc code to verilog or vhdl for logic synthesis.