Why aren't transporters used for medical purposes?

Question: If a Star Trek Transporter can remember the physical state of a person it transports from point A to point B, then why couldn't it heal an injured person it has transported back to their uninjured state?
Comment: I recall an episode in which a transport had gone fatally wrong. The person was subsequently reconstructed from data in the transporter. I'm uncertain which person it was, but I think it was the captain.
Comment: They could be, provided enough stable memory was available.
What else could matter?
Answer: Theoretically it can.
This was a large topic of discussion in the TNG episode Unnatural Selection (S02E07). In the episode, while quarantined on a shuttlecraft Doctor Pulaski contracts a disease that speeds up her aging process. While the Enterprise staff is coming up with solutions for saving her

...Transporter Chief Miles O'Brien gets an idea: they can use the transporter trace, a previous pattern when she didn't have the disease, to control the way she is reconstituted.

The problem ends up being that she has never used the transporter before, so they find her DNA on a hair follicle from her cabin and use that to reconstruct her pattern through the transporter.
Watch this episode and they go through a lot about using the transporters in the way you've suggested. They don't end up using the pattern trace since it doesn't exist, but they talk about it as a good solution. And they do end up using her DNA pattern and the transporter to heal her of the aging disease.
This was also done in the TAS episode The Lorelei Signal (S01E04), it just wasn't talked about nearly as much.
This presumably isn't attempted more frequently because of the huge risks associated with the process. In both episodes, they talk about the danger of it failing, which would cause the people's molecules to scatter in space. On Unnatural Selection:

Chief O'Brien says it will work, but it would be risky, since they will lose her pattern if it doesn't work.

On The Lorelei Signal:

Spock states that the odds are against them, 99.7 to 1. If it fails, their patterns will break up and scatter in space.

Because of the inherent risk, this seems to be a "nothing else will work and this is our only option" emergency solution. It's less risky to transport someone with a broken leg and have the medical team fix it. If they fail, at least the person wasn't transported out of existence and they're just left with a messed-up leg.
Comment: The transporter was also used in TNG [*Rascals*](http://en.wikipedia.org/wiki/Rascals_%28Star_Trek:_The_Next_Generation%29) in a similar manner.
Comment: @SocioMatt We should all be so lucky to forget
Comment: @Xantec Good call. I forgot about that episode.
Comment: Good addition from TAS (which I've never seen).  I was considering mentioning Unnatural Selection when I saw this earlier, but couldn't remember if there was talk of failure (which was pretty much required for the answer to make sense).
Comment: @Izkata Unfortunately, in other episodes (like TNG S06E07 "Rascals") where they try something like this, they don't talk about the consequences of failure.
Comment: @SocioMatt There may not have been much any risk - IIRC, they were reversing a transporter accident in _Rascals_, something they had complete logs for.  In _Unnatural Selection_, they were doing something new to reverse something not done by the transporter.
Comment: @Izkata Interesting point. I'll have to go back and re-watch episodes involving transporter accidents to see if there is mention of consequences for failure.
Comment: I wonder how the transporter knows to reconstruct all her memories and life history just from the DNA...
Answer: I can't remember which episode, but there's one that mentioned some one's pattern cannot be hold up in transporter more then certain time. It's said prohibited by Federation law. If somehow it does happen, whatever the reason, that pattern must be destroyed (so does the person itself).
Anyway just knowing there's an episode that tried to use transporter to cure someone disease with transporter. Guess it's "legal" if the intention is to save some one's live.
Comment: From the Memory Alpha page on Transporters: "The transporter trace itself would be stored for the duration of the person's tour of duty; when that person was reassigned, his or her trace would be deleted. (TNG: "Unnatural Selection")" I can't remember them talking about it being against Starfleet regulations anywhere else.
Comment: And welcome to SciFi SE!
Comment: I think you have the pattern buffer confused with the transporter trace.  The pattern buffer can't hold a person mid-transport for very long (usually just a couple of minutes at most), or it would lose integrity and they couldn't materialize.  It was a limitation of the technology, not a law.  The transporter trace is as @SocioMatt described.
Comment: Did they explain why this limitation exists? I thought once the pattern saved, it should be no problem to save it forever, and technically is capable to re-produce it as many as we like. Basically it's the same technology used by replicator and holodeck, that's I thought the law kicks in to prevent living organism being duplicated un-ethically.
Comment: Wasn't there an episode where Scotty was held in a transporter for a long period of time in TNG, where the other two were scattered due to extended length of time? (because we evidently can't kill off James Doohan! The engines would fail!)
Comment: The TNG Technical Manual covers it. Replicator patterns are stored at a lower molecular resolution than the quantum resolution required for transporter patterns, which can only be buffered. In a DS9 episode, they dump nearly every piece of software and data in the station's computers to store the crew's transport patterns before they're lost. (The manual covers the holodeck using a mix of replicated materials, guided forcefields, and light projections. There's no transporter pattern involved, beyond the replicator-related technology. Holodeck characters are light and forcefields, not people.)
Answer: I remember an episode of Voyager in which they were holding usable biological patterns in a transporter buffer, and they could only hold it there for about a half hour or so, before the patterns would degrade. A transporter is essentially a giant replicator, and it's a well known fact that replicators can't reproduce complex organic matter. The way that I've always thought of it was that during transport, your body was streamed from location to your destination, much like a radio stream of the internet. We humans are so big that you couldn't possibly store people in the main computer's storage devices, so the buffers are put into place for a consistent read/write time. It would suck if you had to buffer while you were materialization.
I don't think the transporter system would have the time to make the bulk edits needed to say, remove the cancer from your body. Think of zip files, when you edit one file, you have to uncompress the entire thing, then recompress the new file. Voyager's crew managed to do the transporter magic trick thing maybe three times, before there was biological repercussions. You'd probably do more harm then good.
Comment: A replicator is essential a cut back transporter that can work from stored data, but a transport is so much more than a replicator. To put it another way, all squares are rectangles, but all rectangles are not squares.
Answer: There are hints that the memory capacity needed for transporter patterns is massive even for future technology.
The assumption that all electronic memories are digital and essentially stable over an arbitrary amount of time, in the worst case by making a perfect copy (also, the assumption you can always perfectly copy them!), is newer than most canon-defining ST material.
In the 1960s, going digital when not needed would likely have been a somewhat absurd notion for an engineer even when imaging technology hundreds of years into the future.
--- What follows is real life electronics geekery, for comparison ---
Even in the 1960s to 1990s, finding unquantized ANALOG signals (that are subject to degradation in storage in some way or another) to be the most economic storage encoding was common. There were audio and video tapes, one-line glass-stick delay line memories in PAL televisions and VCRs, analog image stores like Radechon tubes or DVBST displays in professional applications (jam-proof RADAR, 1970s computer graphics terminals, fast data acquisition), long-persistence phosphors in radar CRT screens, bucket-brigade analog delays (in 1980s musician's delay units), analog CCDs (in high speed data acquistion), semiconductor based but ANALOG audio storage microchips (eg the ISD1016 series). All of these provided a MORE economic solution than quantizing and digitizing, then storing digitally on a medium that could have held more analog data, then converting back to analog, the data that needed storing. Note: quantizing = translating a real-life measure into something that can be expressed as a writable number. Not all digital signals are quantized (eg a PWM signal might not be), not all analog signals are truly unquantized (modern flash memory for SSDs and USB sticks often use a kind of quantized analog format internally).
Even many (not all!) real life digital storage systems rely on cancelling decay effects by regularly replacing the data with a perfect copy for the data to last. DRAMs used in modern computers do. Mass storage systems like HDD or SSD only do so accidentally and occasionally. Anything that can store a lot AND very fast is likely to need it. Unquantized data can neither be kept truly perfect for ANY length of time, nor can any copy of it ever be perfect (the ever-present noise will see to that).
Also, digitizing a very large amount of data will always give you a timing disadvantage - think of a real life camera sensor. While it can capture a, say, 12 megapixel (ca. 40 megabyte, assuming 3 channels a 8 bits) image at a 1/10000th second shutter speed (actually, most camera shutters don't work quite that way, but that is irrelevant here) - it is usually not capable of digitizing and transferring into memory all of that image in 1/10000th second (which would need a bandwidth of 400 gigabytes/second. Which would even today be an extra tall order, above what would be economical in the average camera). Using an analog signal would seemingly land you in similar trouble here - but in both cases the solution would be "use more parallel channels" (eg all rows or columns in parallel on a wire each), and working with analog end-to-end here could still prove the more cost effective solution if speed but not permanent storage was desired (say, 2048 100MHz video channels vs 2048 equally fast 8 bit flash or SAR  ADCs. Both are nightmare fuel.).
In something (eg a living being) that moves internally on all levels, accepting timing skews by not imaging everything at the same time won't go well.
Even today, a system that would need short-term data storage capacity beyond what is possible/economic in a digital way would be likely implemented in an analog manner at the very frontend.
Comment: I know you're only using it as an example, but you've got the way a digital camera sensor works wrong. Digital camera sensors work in grayscale, and many will use 12-14 bits per photosite to represent luminosity (basically, number of photons captured by that photosite during the exposure). In front of each photosite is a color filter. The image data is only later turned into a color image by interpolating nearby photosites and adding knowledge of the color filter layout, along with applying a white balance. With JPEG output, all this happens in the camera; with RAW, in post-processing.
Comment: _"In something (eg a living being) that moves internally on all levels, accepting timing skews by not imaging everything at the same time won't go well."_ I agree, which is why it bothers me when we see people moving around inside the transporter beam, or even showing evidence of cognition and sight (!) like Barclay. The thing was portrayed a little inconsistently.
Comment: _"In something (eg a living being) that moves internally on all levels, accepting timing skews by not imaging everything at the same time won't go well."_ I agree, which is why it bothers me when we see people moving around while under transport, or even showing evidence of cognition and sight (!) like Barclay. The thing was portrayed a little inconsistently.
Comment: Not hinted - flat out stated in the TNG Technical Manual - molecular vs. quantum resolution.
Answer: The episode 'Unnatural Selection' is one of those stupid canon breaking episodes that should never have been resolved as it did.
The showrunners should have made the writers come up with a better solution to the illness Dr Polaski and the other scientists had. Using the transporter to cure the illness and make them young again was just plain lazy writing. It is a canon breaker because it makes curing someone sick a relatively simple task. As long as there is a pre sickness transporter trace then anyone ill, or even injured, can be simply run through the transporter and they come out perfectly healthy again.
Worse, it could also be used to restore someone to a younger age, making death obsolete. As long as you've got a trace from when you were younger, who wouldn't treat themselves to a yearly birthday present of going through a transporter and coming out a year younger again.
Even worse, it can be used to clone someone. All you would need is some energy and a transporter trace and out pops a clone of that person.
And even worse than that, it could be used to bring a dead person back to life. The
dead could simply be put into the transporter and as long as there is a pre-death transporter trace they can simply be reanimated.
According to most official Star Trek resources the transporters are supposed to work like this; the person or object is scanned, then the molecules are converted into sub-atomic energy particles, these particles are briefly stored in the pattern buffer, then directed to a transporter emitter array, from there the matter stream is transmitted through a subspace domain to the destination, finally the energy particles are converted back into matter and the person or object rematerialises.
This means a sick person rematerialises sick, an injured person still needs medical attention, no one stays young forever, no clones, and the dead stay dead!
This is also why a person can't be stored in the transporter forever. The matter stream can only be held in the transporter buffer for a few minutes maximum. After that, the sub-atomic particles start to decay and the pattern degrades. If the pattern degrades too much the person cannot be rematerialisation fully and/or alive.
When the pattern has degraded too far there are only three things that can happen. One, it can be redirected back to an emitter and rematerialised as a cloud of individual atoms in space. Two, it can be left to decay into nothing inside the buffer. Or three, what is left can be rematerialised with a large amount of missing molecules. That means whatever is being transported will be 'incomplete'. An object would come with bits missing and a person would come out as a messy organic lump.
So the answer to your question is no, it cannot be used to heal an injured person. Unless
of course, the story is being written by a lazy writer.
Comment: _"As long as there is a pre sickness transporter trace then anyone ill, or even  injured, can be simply run through the transporter and they come out perfectly healthy again."_ Not really; the disease in that episode specifically worked by altering DNA. If we assume for the sake of argument that _that_ makes any sense, then the scenario in the episode isn't so crazy, and it also isn't really related to the question which seems to be more like "why can't they store a copy of the person from yesterday, then rematerialise them with the leg they lost this morning"...
Comment: ... the answer, of course, being (a) storage space, and (b) ethics. See also: Thomas Riker. But being able to manipulate DNA in the transporter stream (using a reference point from a hair sample) is not the same as magically fixing any ailment.


Experience Editor error: The item "/sitecore/content/Applications/WebEdit/WebEdit Texts" was not found. It may have been deleted by another user

Question: When I am trying to open pages which have Image in the experience editor the Image fails to render and I am getting the following error in Experience Editor,
The item "/sitecore/content/Applications/WebEdit/WebEdit Texts" was not found. It may have been deleted by another user.

   at Sitecore.DefaultClient.GetItemNotNull(String itemPath, Language language, Version version, Database database)
   at Sitecore.DefaultClient.GetItemNotNull(String itemPath, Database database)
   at Sitecore.Xml.Xsl.ImageRenderer.GetDefaultImage()
   at Sitecore.Xml.Xsl.ImageRenderer.Render()
   at Sitecore.Pipelines.RenderField.GetImageFieldValue.Process(RenderFieldArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Glass.Mapper.Sc.GlassHtml.MakeEditable[T](Expression`1 field, Expression`1 standardOutput, T model, Object parameters, Context context, Database database, TextWriter writer)

In code we are using the below line to Render the image
 @Html.Glass().RenderImage(x =>x.Image, new { W = 120, Width = 120 })

I have tried with following code as well
 @Html.Glass().Editable(x => x.Image)

I verified the logs and found the below error:

MediaRequestProtection: The Media.RequestProtection.SharedSecret
setting currently uses the default value. It is strongly recommended
that you change this setting to a random string.
ERROR Failed to render field
Exception: Sitecore.Exceptions.ItemNullException.

Followed the article
https://doc.sitecore.com/xp/en/developers/92/platform-administration-and-architecture/protect-media-requests.html and created a patch file as suggested, but still face the same error.
Any ideas on what might be causing this?
Comment: Have you tried rebuilding the link database?
Answer: I suggest to clear the browser cache and open the Experience Editor on the fresh start of your application.
Alternatively, try to open the same site in a different browser that you have not used before.


Insect Identification: What's this insect

Question: Recently i found an insect very rapidly multiplying itself in the compost heap at home. I took some blurry images of the insect since they were very brisk and not sufficiently static. I am concerned on their numbers getting multiplied in the compost. Kindly help in identifying this critter and any damage that they can cause to the plants if the compost is applied. Apologies for such pictures!!
Answer: The photos are a bit blurry but to me looks like some kind of earwig
Earwigs typically feed on live sprouts or decaying vegetation and, in rare cases, some species are predators.They prefer dark and wet areas and like to live and lay their eggs there.
I am leaving this link here about what do they eat.
Answer: This is a (very speedy) earwig! Earwigs love damp, close quarters, so I'm sure the compost heap was the perfect home in their eyes. They also do eat both living (plants and small arthropods) and dead organic matter.
If you let the compost dry out a bit and aerate it well before application, I think the risk of earwig damage to your garden plants would be minimal.


Division-free Krylov methods?

Question: I have been using various Krylov subspace methods for a long time, especially conjugate gradient. I'm wondering if there is some way to modify the algorithms to postpone / avoid the divisions that occur so that one could build the whole algorithm using only multiplications and additions. Any reference or description of how to do it would be welcome.
Comment: What is the motivation behind the question? On some system platforms, floating-point division is basically implemented via floating-point multiplies and adds (often, using fused multiply-add operations, or FMA), and one could make that replacement on other platforms with a native division capability (possibly at some loss of performance).
Comment: See [Wikipedia](https://en.wikipedia.org/wiki/Division_algorithm#Fast_division_methods) as a starter. I worked on the AMD Athlon processor, whose FPU uses Goldschmidt's algorithm for division. I later worked on NVIDIA's parallel programming technology CUDA, which implements division in software using an iteration for the reciprocal with cubic convergence (Halley iteration). Earlier work in this direction was done for Intel's Itanium processor line (see publications by Peter Markstein). It's fairly easy to implement this almost correctly rounded, challenging to do with correct IEEE-754 rounding
Comment: @njuffa : Yes the idea would be to try and reduce the latency and pipeline clogging in modern CPUs when doing a hardware DIV (which as far as I know) is using the euclidean algorithm. What you describe sounds very interesting. Feel free to refer me to any place where describes these division algorithms.
Comment: That's funny, I was just gonna ask a question about something very similar to Goldschmidt, it would be very fast now that we have the FFS instructions since a few years back. So it is actually used? I was under the impression that euclidean algorithm was still being used mostly.
Comment: When you talk about Euclidean algorithm  and `FFS` it seems to suggest you are asking about *integer* division, whereas I originally assumed you are interested in *floating-point* division (context of conjugate gradient methods). Could you clarify the question please? I was just in the process of pulling together a few reference for floating-point division based on multiply/add.
Comment: Yes I am mostly interested in floating point division but anything would be of interest.
Answer: As noted by Wikipedia the primary algorithms for fast floating-point division algorithms based on existing floating-point multiply and add capabilities are Newton-Raphson iteration and the related Goldschmidt algorithm. The latter usually provides more parallelism, but is not self-correcting like NR-iterations , making error analysis more difficult. It is relatively easy to build implementations that deliver approximate results, but designing implementations that provide proper rounding as defined by the floating-point standard IEEE-754 is a task for experts.
Various hardware platforms have no native floating-point division capability and use sequences of multiplies and adds, or – more commonly these days – sequences of fused multiply-add operations (FMA). The AMD Athlon processor used Goldschmidt's algorithm, the Intel Itanium processor used NR iterations, and NVIDIA GPUs using CUDA use Halley iteration on the reciprocal (related to NR-iterations but with cubic convergence). This latter work is not documented in a paper, but one can easily examine the relevant code through disassembly of a CUDA binary containing floating-point division with cuobjdump --dump-sass.
Stuart F. Oberman, "Floating Point Division and Square Root Algorithms and Implementation in the AMD-K7TM Microprocessor". In Proceedings 14th IEEE Symposium on Computer Arithmetic, IEEE 1999, pp. 106-115 (online)
Peter Markstein, "Software division and square root using Goldschmidt's algorithms." Proceedings of the 6th Conference on Real Numbers and Computers (RNC'6), Vol. 123, Nov. 2004, pp. 146-157 (online)
Peter Markstein, IA-64 and Elementary Functions. Speed and Precision, Prentice Hall 2000 (see chapter 8)
Marius Cornea, John Harrison, and Ping Tak Peter Tang, Scientific Computing on Itanium®-based Systems. Intel Press 2002 (see chapter 8)
Marius Cornea, "Software implementations of division and square root operations for Intel® Itanium® processors." In Proceedings of the 2004 workshop on Computer architecture education, ACM 2004. Article No. 17 (online)

Integer division can be implemented in much the same way, see this question on Stackoverflow for a worked example of 64-bit integer division via Halley iteration.

Division-free Krylov methods?


Add new user and site per front end form

Question: Do you know any multisite plugin which allows users to create a user account and a site after a form submission. After the form submission, the form will automatically add a site in the network admin and create a new user. Is this possible? Some say that it needs hardcoding for it to work. But I have no idea how to. Hope you guys can help.
Answer: create a form, same as contact or custom content from frontend  and send the content of field with the WP core function wp_insert_user() to WP, add the users.
an example without form, only a function to insert users and see the fields for the data array.
function fb_wp_insert_user() {
    $user_data = array(
        'ID' => '',
        'user_pass' => wp_generate_password(),
        'user_login' => 'dummy',
        'user_nicename' => 'Dummy',
        'user_url' => '',
        'user_email' => 'firstname.lastname@example.com',
        'display_name' => 'Dummy',
        'nickname' => 'dummy',
        'first_name' => 'Dummy',
        'user_registered' => '2010-05-15 05:55:55',
        'role' => get_option('default_role') // Use default role or another role, e.g. 'editor'
    );
    $user_id = wp_insert_user( $user_data );
}

I think is an good idea, that you check the user, before you add the entry on email or name. But you can also update via function: wp_update_user()

see also this post for more information
Comment: thanks. this one worked for me. this would be a big help. ;p
Comment: Thank you for this code. Please can you tell us how to create a subsite for that specific user, from front end?
Comment: @whitelettersinblankpapers i know a premium plugin that could do what you seek. It's actually the [Multisite integration](https://profilepress.net/downloads/multisite/) ProfilePress extension.


What is the best/most popular pipe-weed in middle earth?

Question: Is it ever stated, or agreed upon by the hobbits, men, dwarves, or elves that there is a "best" or "most popular" pipe Weed? Or, more specifically, do any characters state their personal preference?
Comment: VTC: Recreation drug recommendations are offtopic for this StackExchange
Comment: @Escoce DVK is troll
Comment: @Himarm - Am I a Stone, Hill, Cave, Mountain or Snow Troll? Or Olog-hai?
Comment: @DVK it's fiction and there are no middle-earth pipe weeds in the real world.
Comment: @Escoce - you forgot the spoiler markup!
Comment: @Himarm - But I wanna be Olog-Hai! All new hot model, tricked-out!
Comment: @DVK cave of course, the cave of the mind, filled with wonder and riches.
Comment: I don't understand?
Comment: @Escoce - I was politely calling you Captain Obvious. The original comment was clearly meant in gest, as irony. I'm well aware that Middle Earth is fictional :)
Answer: Longbottom Leaf, and variants thereof (emphasis mine):

But all accounts agree that Tobold Hornblower of Longbottom in the Southfarthing first grew the true pipe-weed in his gardens in the days of Isengrim the Second, about the year 1070 of Shire-reckoning. The best home-grown still comes from that district, especially the varieties now known as Longbottom Leaf, Old Toby, and Southern Star.
Fellowship of the Ring Prologue 2: "Concerning Pipe-weed"

Merry sings its praises later, when he and Pippin discover a barrel at Isengard (emphasis mine):

[Merry] produced a small leather bag full of tobacco. 'We have heaps of it,' he said; 'and you can all pack as much as you wish, when we go. We did some salvage-work this morning, Pippin and I. There are lots of things floating about. It was Pippin who found two small barrels, washed up out of some cellar or store-house, I suppose. When we opened them, we found they were filled with this: as fine a pipe-weed as you could wish for, and quite unspoilt.'
Gimli took some and rubbed it in his palms and sniffed it. 'It feels good, and it smells good,' he said.
'It is good!' said Merry. 'My dear Gimli, it is Longbottom Leaf! There were the Hornblower brandmarks on the barrels, as plain as plain. How it came here, I can't imagine. For Saruman's private use. I fancy. I never knew that it went so far abroad. But it comes in handy now?'
Two Towers Book III Chapter 9: "Flotsam and Jetsam"

Although quality doesn't necessarily correlate to popularity, the only other variety a character is explicitly identified as smoking (Southlinch, in Bree), is also explicitly identified as substandard, and presumably comes from the very back of the store-room:

[I]f you [Butterbur] have any pipe-weed, we'll bless you.'
'Well, if you'd called for anything else, I'd have been happier,' said Butterbur. 'That's just a thing that we're short of, seeing how we've only got what we grow ourselves, and that's not enough. There's none to be had from the Shire these days. But I'll do what I can.'
When he came back he brought them enough to last them for a day or two, a wad of uncut leaf. 'Southlinch,' he said, 'and the best we have; but not the match of Southfarthing, as I've always said though I'm all for Bree in most matters, begging your pardon.'
Return of the King Book VI Chapter 7: "Homeward Bound"
Comment: I think the clincher is that Saruman - who didn't particularly care for Hobbit culture in general - could get any pipe-weed he wanted, yet he specifically had Longbottom Leaf in his pantry. Unless he kept it on-hand for when Gandalf visited.
Answer: Actually, one can argue that pipeweed (or sweet galenas, the wild-growing variant thereof as known in Gondor) thrives the better as one moves southwards.
Apart from the references to Bree and to Longbottom in the Southfarthing, we have Merry's account in his Herblore of the Shire, quoted in LOTR, Prologue, 2: Concerning Pipe-weed.

It grows abundantly in Gondor, and there is richer and larger than in the North, where it is never found wild, and flourishes only in warm sheltered places like Longbottom.

For Bree, Merry has this to say:

It is said that in his youth he [Tobold Hornblower] went often to Bree, though he certainly never went further from the Shire than that. It is thus quite possible that he learned of this plant in Bree, where now, at any rate, it grows well on the south slopes of the hill. The Bree-hobbits claim to have been the first actual smokers of the pipe-weed. They claim, of course, to have done everything before the people of the Shire, whom they refer to as "colonists"; but in this case their claim is, I think, likely to be true.

[ibid., emphasis mine]
Merry, whom we can trust to be enough of a hedonist to know good stuff when he sees it, recognizes the (wild) pipeweed of Gondor to be superior to the  (cultivated) pipe-weed of the Southfarthing, as a plant; and similarly, the Southfarthing brands seem to be superior to that of Bree, altough even that seems acceptable.
Taking into account also that the plant was presumably introduced to Middle-earth by the Men of Westernesse, it is not unreasonable to concude that the quality of this warm-loving plant improves with the milder climate.
It is quite another thing, of course, whether, where, and how the raw material is gathered, processed and marketed. That is an industry, without a doubt, best achieved by hobbits of the Southfarthing.
Comment: My memory must be going; when does Merry sample the Gondorian leaf?
Comment: @JasonBaker - Pipeweed will do that to you.
Comment: Merry could have tried a Gondorian variety of pipeweed during the time before the coronation of King Elessar. Merry was recovering in the Houses of Healing from March 15th after the Battle of the Pelennor, and the coronation took place on May 1st. However, Merry and Pippin had replenished their supplies from the flotsam of Isengard shortly before, so he may not have documented Gondorian varieties until a much later time.
Comment: @JasonBaker I don't know. But he refers, again in the Prologue, to "observations that I have made on my own many journeys south". Presumably there's no detailed track of these journeys, but if there were many, and since he's writing about herbs, and taking into account his interest in pipe-weed, I'd assume that he or his acquaintance there sampled it sometime. It would seem remiss not to do so.


Error running hadoop application in Eclipse on Windows

Question: I'm trying to set up an Eclipse environment for developing and debugging hadoop. I'm following Tom White's Definitive Hadoop 3rd ed. What I would like to do is get the MaxTemperature app working locally on my Windows within Eclipse before moving it to my Hortonworks sandbox VM. The comment on page 158 about using the local job runner seems to be what I want. I don't want to set up a full hadoop implementation on Windows. I'm hoping with the right config params I can convince it to run as a java application inside Eclipse.
Windows: 7
Eclipse: Luna
Hadoop: 2.4.0
JDK: 7
When I set the Run configuration for MaxTemperatureDriver (Source code on page 157) to
  inputfile outputdir foo (deliberate bogus 3rd parameter)

I get the usage message so I know I'm running my program with those params.
If I remove the bogus third param I get
Exception in thread "main" java.io.IOException: Cannot initialize Cluster. Please check your configuration for mapreduce.framework.name and the correspond server addresses.
    at org.apache.hadoop.mapreduce.Cluster.initialize(Cluster.java:120)
    at org.apache.hadoop.mapreduce.Cluster.<init>(Cluster.java:82)
    at org.apache.hadoop.mapreduce.Cluster.<init>(Cluster.java:75)
    at org.apache.hadoop.mapreduce.Job$9.run(Job.java:1255)
    at org.apache.hadoop.mapreduce.Job$9.run(Job.java:1251)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1548)
    at org.apache.hadoop.mapreduce.Job.connect(Job.java:1250)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:1279)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1303)
    at mark.MaxTemperatureDriver.run(MaxTemperatureDriver.java:52)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84)
    at mark.MaxTemperatureDriver.main(MaxTemperatureDriver.java:56)

I've tried inserting -conf  but it seems to be ignored. There is no error message if I specify a nonexistent path.
I've tried inserting -fs file:/// -jt local, but it makes no difference
I've tried inserting -D mapreduce.framework.name=local
I've tried specifying the input and output with the file: format
Note. I'm not asking about how to configure eclipse to connect to a remote Hadoop installation. I want the application to run within eclipse.
Is this possible? Any ideas?
Additional info:
I turned on debugging. I saw:
582 [main] DEBUG org.apache.hadoop.mapreduce.Cluster  - Trying ClientProtocolProvider : org.apache.hadoop.mapred.YarnClientProtocolProvider
583 [main] DEBUG org.apache.hadoop.mapreduce.Cluster  - Cannot pick org.apache.hadoop.mapred.YarnClientProtocolProvider as the ClientProtocolProvider - returned null protocol

I'm wondering not why YarnClientProtocolProvider failed, but why it didn't try LocalClientProtocolProvider.
New info:
It seems that this is an issue with Hadoop 2.4.0. I recreated my environment with Hadoop 1.2.1, followed the instructions in
http://gerrymcnicol.com/index.php/2014/01/02/hadoop-and-cassandra-part-4-writing-your-first-mapreduce-job/
added the Windows hack from
http://bigdatanerd.wordpress.com/2013/11/14/mapreduce-running-mapreduce-in-windows-file-system-debug-mapreduce-in-eclipse
and it all started working.
Comment: check whether all the 5 servers are running or not ?
Answer: Following blog will be useful.
Running mapreduce in Windows filesystem


Why "Extend volume" in Windows 7 is greyed out?

Question: I want to extend C: drive in my Windows 7 PC which is the primary partition. I converted its adjacent D: drive into primary partition which was initially a logical partition. But the problem is that I am unable to extend C: by merging both C: and D:, because in windows disk management when I right-click C:, the extend volume feature is greyed out. Why is it happening and what should I do? I am also giving an image of my partitions herewith.
Answer: You can't (directly) merge 2 partitions. The "Extend Volume" option is greyed out because it has no available space adjacent to the partition, making C bigger would overlap with D, which is a full fledged partition (it is just empty, but that does not matter, that space is reserved for it anyways).
The solution is to delete the volume D, and apply changes, so that region of the disk becomes unallocated space instead.
In any case, there are some changes that you cannot do to a partition when booting from it. The easiest solution for this problem is to just use a live SO that does not need to make use of the partition you want to modify, like the open source utility gparted: https://gparted.org/ (you can burn a bootable CD/USB to use this utility)
Comment: You can do this from windows. Only removing a partition in use would not be possible, but because D is not a system partition, this can be fully done from within windows.
Comment: Resizing Windows partitions by Linux is not a good idea. Windows Disk Manager should be able to handle everything.
Comment: @lgb  Thank you so much, I just deleted the volume first and then merged them both by simply extending volume in windows disk management.


Finding volume of a frustum of a pyramid

Question: I need to find the volume of a frustum of a pyramid with square base of side $b$, square top of side $a$, and height $h$(using integrals). I have no idea how to do questions like these, I only know to use the disc/washer/cylindrical shells methods and rotate a region around any line and find its volume. For these type of question, I find myself at a loss as to where to even start. Any hints on general about starting these kind of problems are also appreciated!
Comment: Divide the pyramid into _square_ "discs" rather than round ones -- then it's just like a volume of rotation.
Comment: The length decreases linearly from $b$ to $a$ in height $h$. So at height $x$ it is $b-\frac{x}{h}(b-a)$. Or else you can use similar triangles to get the same result, in slightly different form.
Comment: I tried that, but I have no idea how to find the length of that cross section in order to find its area. @HenningMakholm
Answer: A volume element is
$$dV = A(y) dy$$
where the sides in the square cross-sectional area $A(y)$ behaves linearly with height:
$$A(y) = \left[ b-\frac{y}{h} (b-a)\right ]^2 = b^2-2 b (b-a)\frac{y}{h} +\frac{(b-a)^2} {h^2} y^2$$
so the integral is
$$V = \int_0^h dy \, A(y) = b^2 h - b (b-a) h  +\frac13 (b-a)^2 h$$
or, simplifying,
$$V = \frac13\frac{b^3-a^3}{b-a} h $$
Answer: The principle behind using single integrals to calculate volumes is this: One possible method of looking at what the integral does in the usual sense is that it converts calculations of area into calculations of "weighted length". That is, you can assign "weights" to every point on the $x$-line and then "add them up" to get the area. The weights you want are precisely the height, that is, the normal length in the perpendicular direction.
It turns out that what's essential in that calculation of area is just that the weights measure the stuff in the perpendicular direction. So by analogy we can think of the integral as calculating the volume of an object in this way: draw a line through the object, and assign weights to each point on that line given by the measure in the perpendicular directions (in the cross-section). This time, there are many lines perpendicular, so the measure is no longer length, but is instead area.
So now instead of $A=\int h(x)\,dx$ where $A$ is area and $h$ is height, we have $V=\int A(x)\,dx$, where $V$ is volume and $A$ is cross-sectional area. (Addressing Makholm's comment, we can use this principle when $A(x)=\pi r(x)^2$ to recover the disk method formula which you are familiar with.)
To be a bit more concrete about this, we can do a silly example: calculating the volume of a cube (with side length $s$). Of course we already know it's $s^3$, but let's see if we can see how to do it with integrals. Put your $x$-axis on one of its sides, and integrating along it. At each point, the cross-section is a square with side-length $s$, so its cross-sectional area is $s^2$. For convenience, put one corner of the edge on the $x$-axis at $x=0$, and one at $x=s$. Then we can integrate
$$V = \int_{edge} A(x)\,dx = \int_0^s A(x)\,dx = \int_0^s s^2 dx.$$
$$V = s^2\int_0^s 1\,dx = s^2x\Big|_0^s = s^3-0=s^3. $$
And of course that is the volume of a cube, like we already knew. Hopefully this is somewhat convincing :)
You can see some major themes here. The most important thing is the right choice of line. If we had chosen the diagonal of the cube, we certainly could do the calculation, but it's considerably messier. So you should try to exploit some symmetry when choosing the line so that the area function will be nice to play around with. We also have the freedom of where to place the origin; normally putting it at the end of the figure will make calculations easier, although the center is another place that is often effective as well.
Comment: @Henning: At least when I was in Calculus (US public school), I was taught the "disk method formula" and the "shell method formula". There were explanations of what made thesem valid, but the teacher didn't test it at a conceptual level, and many in my class, myself included, didn't bother to learn it. So it's easy for us to sit here and say "just use square disks", but if you don't know why the round disks work, you're not likely to get anything meaningful out of that. It's definitely the heart of the matter and I don't intend to fault you; just a friendly reminder :)
Answer: Ron Gordon is correct, but I do not know why his final answer was stated as such. It could be simplified further.
$$
V=\int_{0}^{h}(b-\frac{x(b-a)}{h})^2dx
$$
He got here because the line from the tip of the pyramid at origin to the end of the pyramid at H is of the form mx+b where the slope $$M=\frac{(b-a)}{h}$$ and the area of a square is equal to $$f(x)^2$$
From here you can multiply it out to be
$$
V=\int_{0}^{h}b^2-\frac{2bx(b-a)}{h}+\frac{x^2(b-a)^2}{h^2}dx
$$
Then you can integrate it to be
$$
V=b^2h-bh(b-a)+\frac{h(b-a)^2}{3}
$$
From there it simplifies to
$$
V=\frac{h}{3}(b^2+ab+a^2)
$$
This was verified as a correct answer in webassign and Wolfram
Thanks and credit goes to Ron Gordon. Though his answer is hard to understand, I was able to discern where I went wrong.
Comment: As $\frac {b^3-a^3}{b-a}=b^2+ab+a^2$ your answer agrees with Ron Gordon's answer.
Comment: Ok, I see now how he got to that point, but I don't feel that his answer is one that someone would easily arrive at doing it themselves. My answer I tried to be more clear on breaking it up into steps. He was probably down-voted because someone else could not follow his answer. I just hope mine is more understandable.


If everyone wanted to sell swaps, why does that drive swap rates down?

Question: If everyone wanted to sell swaps (pay fixed, receive floating) why does that drive down swap rates?  Wouldn't that raise rates because in order to compete with each other they would have offer to pay higher fixed rates to get people to take the other side?
Comment: There is a lot of receiving going on…
Comment: You are correct.  Who is saying otherwise ?
Comment: @dm63 Yeah I just talked to Bloomberg about this, they said my initial assumption was wrong and that selling swaps actually means receiving fixed, and paying floating.  I guess I just had the wrong assumption in my head.
Comment: No prob. Btw no one ever says "selling swaps". It is too confusing for this reason.
Comment: Makes sense.  What do they call it when there is a lot of downward pressure on rates?
Answer: When you buy or sell a financial instrument on a double auctions (ie involving buyers and sellers, for instance in an orderbook), it is straightforward to understand that when you have more buyers than sellers, the price will, on average, go up (and the reverse).
When market makers are in between buyers and sellers, their inventory acts as a "buffer". As a consequence: if they are temporarily more buyers and sellers, but if the market makers have the "intuition" that other sellers will come soon, the inventory of market makers allows the prices to not vary that much. Of course, this mechanism has a time scale: is it minutes? hours? days? weeks? It depends of the way the Market Maker (MM) is averse to a large inventory, that is a function of its capital. For instance: HF MM have a small capital and hence provide a very short term buffer.
If an issuer or structurer is at the origin of the product (like swaps), in practice it acts as a market maker on the risk exposures that are contents in the products it buys:

If a bank sells 1 swap to one client and the exact opposite one to another client, its inventory (in term of risk exposure) is zero.
If it sells for instance a Total Return Swap (TRS) on Eurostoxx50 and sells one TRS on a short exposure to the CAC40 and sells another one on a short exposure to the DAX, its inventory will be close to zero. Hence the price will not move a lot.
For derivatives, the same reasoning applies, on the directions of the Greeks (sensitivities of the bought products in a set of risky exposures); it is explained in  Financial Markets in Practice, From Post-Crisis Intermediation to FinTechs, by L and Raboun.

The balance sheet of the issuer acts as to inventory of a market maker. Ultimately the issuer, to counter a too high exposure to a risk factor, will have to hedge it and hence will move the price in the expected direction.


Can a Dapp buy or sell (usdtz or tzbtc) from dexter?

Question: Looking for a way for a dapp to buy tzBTC automatically after receiving tez from a baker.
Answer: If you mean "dapp" as in "front-end dapp", it is technically possible but highly dangerous and cumbersome: the exchange between XTZ and tzBTC requires signing a transaction so you would have to store a private key into the interface and keep it open at all time (suffice to say, you shouldn't do it).
What is possible is to do it server-side with a script that listens to changes of balance for a certain address or runs at fixed intervals and when a credit of XTZ is detected, the script can use a private key that is securely stored to sign a transaction and buy tzBTC from Dexter.
Comment: There are different solutions you can use if you want to sign transactions from the back-end, for example, the `@taquito/signer` package has a function called `InMemorySigner` that you can set up with a private key and that will be used in all the subsequent operations :)
Comment: Thank you for the information. I was thinking if it is possible for a "back-end" dapp ie the dapp sends tez (via  entry point )to dexter and dexter simply sends back tzBTC.  Since signing is required i dont think my idea will work.


How did monks time their practice?

Question: How did monks traditionally time their practice before the age of timers?
Any sutta references would be greatly appreciated.
I'm looking for an organic way to time my sittings.
Comment: Instead of copy-and-pasting answers it's normal to close duplicate questions.
Comment: Related answer here: http://buddhism.stackexchange.com/questions/1698/how-to-determine-the-end-of-a-meditation-session-without-a-clock/1717#1717
Comment: Yeah Robin that's a good answer... maybe copy that over as an answer if you want the points?
@ChrisW This question is specific to avoiding the usage of clock, timer, all "inorganic" tools haha.
Comment: I understand but this is not duplicate is it? One asks how to avoid clock. Mine asks how to avoid all digital devices but still time correctly
Comment: I titled my question wrong (but can't change it anymore..). I wanted to ask how to practice without timers (which is why I was asking how monks used to practice)..
Answer: To refer to the traditional way that time is kept:

"The best way I've heard to a) keep track of time b) without a clock
  (or timer) was related to me by my 91-year-old teacher who said in the
  old days they used to use incense sticks; once the incense stick was
  finished, they would switch from walking to sitting. For shorter
  sessions, you could cut the sticks in half, etc. Of course, it still
  means you need to open your eyes every so often during sitting."
  --this answer

The act of not timing your sitting is a profound one. It's not like the Buddha timed his sittings when he attained Enlightenment!
After nourishing himself the Buddha himself literally said "I will not get up from this Bodhi tree until I attain Awakening! Let my bones break and my flesh rot before I shall arise."
And then he entered the 1st jhana, 2nd jhana all the way to 4th and then experienced the 4 formless absorptions one by one and then attained Awakening.
He did not time his sittings except taking a bit of a break when he was truly exhausted and he opened his eyes to look at the night sky to take a bit of a rest.
And like magic, right then, he Awakened.
[Similarly Zen practitioners and other "hardcore" practitioners do not time their sittings... and they tended to Awaken when they took a bit of a rest and their Buddha Nature spotaneously opened to them, their skandhas dropping away giving them a strong taste of Awakening.]
Thus, the ultimate "inorganic" method is your own physical exhaustion, your own body telling you it is time to take a break from your arduous efforts!
Nonetheless, You can use other similar methods that are "organic" and do not use digital devices: tea kettle boiling, the birds starting to chirp in the morning as you push your meditation on in the early morning, etc.
Also your question is an important question because we all need to do an electromagnetic detox! We are all heavily dependent on our devices and are sleeping, reading, and practicing in a pool of EMR. I definitely notice a huge difference when I wear my crystals than when I am not.
Many of us experienced times when we go to a garden or some greenspace, far away from wifi connections and our mind completely clears and it feels the bliss of concentration is close at hand. It is also much easier to think about one's own life and contemplate in such an environment, also due to having less electronic devices subconsciously yelling and calling us in hundreds of ways.
Comment: This answer would be great on the original question mentioned in the comments to OP.

How did monks time their practice?


Windows Media Player library doesn't show any songs in folders!

Question: I have Windows 7 Ultimate and have added my music folders to the library of Win Media Player, yet none of my songs appear in the library!
What shall I do?
Also, i have switched off many services, which are the services essential for the above to happen!
Answer: What do you mean "added my music folder to the library of Win Media Player"?  Windows Media Player automatically searches your Libraries for media and does not have any "folders" of its own.
Your Libraries can be seen on the left side of the screen when you click Documents or Computer from the Start menu.
Libraries allow you to customize what folders are automatically searched for content.  For instance I do not use the My Music folder that Windows 7 provides under C:\Users\Typoknig\My Music, all of my music is stored on an external hard drive.
To account for this I had to right click Music under Libraries and select Properties.  There I was able to remove/add folders to automatically search for content.  You may need to do the same if you are not using the standard My Music folder.
Comment: did that, but doesn't work, the files don't appear in the library ...
Comment: @manishKungwani you can press `F5` to force an update.
Comment: even forcing the update doesn't work!
Answer: Try this:
Whilst inside Media Player, select Tools > Advanced > Restore Media Library. Allow it to close Media Player. Open it up again and see if it starts adding your music.


Can you use a single partition for two different time machine backups?

Question: I have a hard drive which has one HFS partition of 1TB that is being used as a MacBook backup.
Can I backup another MacBook to the same partition without overwriting or convoluting data?
Answer: Yes, the Time Machine system handles this automatically.
There's one major drawback in that you cannot decide on a storage quota for each backup. This means that if you have 1 TB of backup storage, you cannot decide that 500 GB is reserved for computer A and 500 GB for computer B.
So if the backup of one computer is too large, that could make it impossible to take a full backup of the other computer.
You can limit the size of a Time Machine backup though by executing on each Mac:
sudo defaults write /Library/Preferences/com.apple.TimeMachine MaxSize -integer size

with size in MB. Example:
sudo defaults write /Library/Preferences/com.apple.TimeMachine MaxSize -integer 500000

Comment: added a TM size limiting command
Comment: Would the folder structure reflect that there are two separate computers?
Comment: Time Machine creates a seperate sparsebundle for each computer. They are called `computer name`.sparsebundle - for example "Kolobs MacBook Air.sparsebundle".
Answer: I would highly recommend creating a separate partition for each computer that is being backed up via Time Machine, and if required (optionally) create another separate partition for general storage.
As an example... for a 4TB drive:
Partition 1 - Time Machine Backups (Computer 1) - 500GB
Partition 2 - Time Machine Backups (Computer 2) - 500GB
Partition 3 - General Storage - 2TB (optional)
The potential issue I see with jksoegaard's recommendation is that if you ever perform a major MacOS version update, or system restore, on either or both computers - and then forget to immediately reapply the sudo command to set the MaxSize - the MacOS update may inadvertently set MaxSize back to using the full disk space (system default) and will stop applying the storage quotas... before you have a chance to realise.
Using partitions, however, you can more effectively apply a storage quota for each computer backup irrespective of MacOS updates in the future.
I found this link very helpful:
http://www.baligu.com/pondini/TM/4.html


control the pageblocktable visibility

Question: I have 3 dependent dropdowns in my VF page. Upon selection of these, a pageblocktable is displayed. I want the table to be displayed only after the selection of 3 dropdowns. I dont want the table to be visible on PageLoad. How do i control the visibility of this table?
Comment: yes rendered conditions.
Answer: Add a property to your controller that checks the values selected in the 3 dropdowns:
public Boolean renderTable {
    get {
        return !String.isEmpty(dropDown1)
                && !String.isEmpty(dropDown2)
                && !String.isEmpty(dropDown3);
    }
}

and render your table accordingly:
<apex:pageBlockTable rendered="{!renderTable}" ...

You will need to add an onchange apex:actionSupport to the dropdowns that re-renders the containing element of the apex:pageBlockTable when any of them change.

control the pageblocktable visibility


What will happen if China stops loaning money to the U.S.?

Question: US's external debt to china is a staggering 1.1 trillion US dollars and according to many economists, it's highly unlikely that U.S. will be able to pay back the entire external debt to China in the next 4-5 decades or so.
So what will happen if China stops lending money to U.S. as prospects of ever getting back the debt is highly unlikely because of the ever increasing deficit and spending?
And is there any other nation other than China which can lend money to U.S. (Seems highly unlikely) ?
Comment: 4 people voted to close this question as "too broad". I don't understand why, considering that all the 3 answers essentially say "nothing serious will happen" and nobody posted a comment yet which explains why the question is too broad.
Comment: By the way, [Wikipedia says](https://en.wikipedia.org/wiki/Foreign-exchange_reserves_of_China) the *whole* foreign exchange reserves by the PRC are just 3.12 trillion USD. And those are loans given to *all* foreign governments, not just the United States. Wherever I look I can't find anything which corroborates your 6.1 trillion figure. Are you sure you didn't misunderstand something?
Comment: Where do you have the 6.1 trillion dollar figure from? Your source doesn't have it, and [the source I found](https://www.thoughtco.com/how-much-debt-does-china-own-3321769) says the US only owes 1.2 trillion to the China government, which is just 10% of its total debt.
Comment: @Philipp - I was torn between too broad and off-topic. This requires an in depth financial analysis to address properly (too low level for Quant SE and too high level for personal finance.SE). my answer was basically bumper sticker level; mostly to address question's assumptions.
Comment: @Philipp+ in addition to the more focussed source used by Wikipedia (in Gramatik's answer), TIC does have this breakdown, with a lag and estimated, under https://www.treasury.gov/resource-center/data-chart-center/tic/Pages/fpis.aspx part A. It shows China holding $1.1T Treasury securities as of last June, and another $.2T of 'agency ABS' (almost certainly 'Fannie Mae' and 'Freddie Mac', which are almost-but-not-really government debt).
Comment: Does China mean the Chinese government or the whole country?
Comment: A bucket that only holds 20 drops isn't much of a bucket. Why not avoid hyperbole in either direction, and call five percent: "five percent"?
Comment: How much of this debt is to the Chinese government, and how much is to ordinary Chinese investors (non-government owned companies or individuals)?
Comment: 1.1 is not "staggering" compared to the 20 trillion of total debt. In fact, one could characterize it as a "drop in the bucket".
Comment: I'm not allowed to answer because the question is protected. But my take would be that the debt gives China an incentive to keep US on it's feet to be able to repay. If you are indebted to me, then I am interested in you staying on your feet to be able to pay me back. Even more so as if the value of the US dollar was to plummet then China would be less wealthy as those debts would drop in value (as the debts are in US dollars). So by debt US has given China an incentive to help US stay up so to speak.
Comment: https://www.treasury.gov/resource-center/data-chart-center/tic/Pages/external-debt.aspx
Comment: I'm sorry, but I can't find that number on the page you linked to. None of the tables i found there seem to contain data broken down by lending country. Can you please point me to the right document?
Comment: @Philipp - I had voted for closure. My own opinion that this question was so broad that it invited speculative answers, rather than factual ones. Empirically, we can see that many of the answers below don't cite their central claim to an outside source, which supports (but doesn't prove) the conclusion that this question is in fact, too broad.
Comment: @dave_thompson_085 Thank you for digging that up. I think we can now say with reasonable certainty that the 6.1 trillion figure in the question is wrong. I will edit it.
Comment: The debt is in the currency US dollars which the US decides about. If the debt was in something more out of US control than the US dollar that may have been a totally different thing altogether.
Comment: @TylerDurden Why do you compare the USA debt to China with the total USA debt, instead of comparing it with the USA debt to other single countries? I'm not saying it's staggering or it's not, I have no idea and my point is only about logic. I'm saying that it would have been more meaningful to say like "China holds x% of USA total debt; the country that holds the greatest amount of USA total debt after China holds y%". In that case it would have been easier for people to tell whether it's staggering or not. F.ex. if x=5 and y=0.1, that's staggering, while if x=5 and y=4 that's not staggering.
Answer: There are some assumptions being made by this question that don't reflect how the international economic order works.
Countries do not ever have to pay off all of their debt
A nation's finances are not like a person's. A person has a finite lifespan, and creditors take this into account when giving a loan. A country does not have a finite lifespan, and thus it has, in theory, forever to pay off its debt. Additionally, due to inflation, the value of a loan decreases over time. $1.2 Trillion will be worth less 50 years from now than it is today, which is another reason countries do not strive to pay off all their debt. If the money they are being credited drives growth such that the GDP growth minus the loan plus time is greater than GDP growth without the deficit-spending-aided growth, then the deficit was worth it.
Think of it like this, if you have a loan with an interest rate of 3%, but you have stock market investments that continually return at 7%, it is more profitable to maintain some level of investment rather than pay down all your debt in a sprint. Riskier, yes, but more profitable.
China is not the only creditor of the United States, large or otherwise
Japan is nearly as a large a creditor to the United States as China, each owning about 1/6th of the US debt that is held by foreign countries. Ireland, Brazil, and the UK are also large holders of US debt.
To answer your question directly
Yes. There are many other countries which can lend the US money, and as long as US debt is considered investment grade, countries will continue to buy it.
Comment: "A country does not have a finite lifespan" - well, it does, it's just that we all *agree to pretend* it doesn't...
Comment: Yeah Japan is a HUGE creditor.  Why don't people ever mention them?  Glad you did, +1
Comment: This is quite the arrogant notion: "A country does not have a finite lifespan". - Some humility and history lessons will learn you that no empire will ever last forever. -- Economics need to take the average lifespan of a country into account. Worse: depending on this is basically stealing from the future, akin to "the future will solve it". Shouldn't that be also taken into account in the answer?
Comment: The lifespan of the average country is probably about the same as the lifespan of the average person.
Comment: @paul23 It's just a bit tricky wording. Rather than "infinite lifespan", it's more like "unknown time to live". Averages don't help, since the differences between different countries and the government's sense of past obligations are just too varied (though reflected in e.g. the interest rates). As for your examples, those obligations weren't to the "country/nation" (there wasn't really such a thing), but mostly to the particular dynasty. And anyway, what's far more common than "dynasty/country dies out" is "dynasty/country renounces their obligations or banishes/kills the creditors".
Comment: @millimoose See [crowding out](https://en.wikipedia.org/wiki/Crowding_out_(economics)) effect - government bonds compete with all other bonds and loans so the increase in goverment borrowing may out-compete private sector and make cost of borrowing money highier under some circumstances/long term.
Comment: @MsJackson because unlike in the 80s hysterical economic nationalists in the US aren't worried about Japan eating Americas lunch.
Comment: @sgf nobody said it should be done on purpose to pay off a debt. (Some) inflation is something that most central banks try to achieve anyway. And yes, that's already priced in the debt terms.
Comment: @hobbs : Possibly - but the distribution is rather different.  There is no reason to believe that either US or China will cease to exist in the next 100 years or so.  (It is *possible* that, eg, California will become independent, but if it does so, it will probably take a proportion of the US debt with it.)
Comment: @paul23: When the soviet union ceased to exist, Russia took its financial obligations (and weapons)
Comment: @kjetilbhalvorsen, reminds me of the excellent science fiction novel *Battlefield Earth.* After winning the military battle to retake Earth, Mankind inherits the debt for the intergalactic mortgage used originally to pay for its invasion. :) *"'The simple fact of military take-over does not change the basic debt structure of a planet. That a government changes does not relieve the property of debt. Why, if that were true, then governments would just arrange to change hands every day and they would be rid of all their financial obligations.' He laughed. 'No, no...The new owners have to pay.'"*
Comment: It's important to point out that inflation means printing money out of thin air which reduces the value of the GDP growth over time. Inflation generally leads to more inflation in the long run because GDP never grows enough to subdue a constantly increasing debt in the long run.
Comment: Don't forget that said slowed GDP value growth is counterbalanced by the nominal growth caused by public spending. In business/investment terms: the USA of today is borrowing some money from the USA of tomorrow. As long as GDP is actually growing, the USA of tomorrow should have more money at its disposal as the USA of today. The USA of today certainly can put this money to good use and hopefully turn a "profit" in this. Furthermore, given inflation and disregarding interest, the USA of today will be able to buy more with the same amount of money than the USA of tomorrow would be.
Comment: I'm not qualified to make a proclamation such as "debt good" or "debt bad" or "debt okay-ish", same goes for inflation, suffice it to say though that simplistic analyses of these questions are likely to be fallacious. For instance, if the interest on national debt is lower than the inflation rate, borrowing is free money at your creditors' expense - in today's dollars, the numbers work out to you paying the debt off for less than you borrowed. (There might be other reasons why that's a bad idea.)
Comment: Also, debt-to-GDP seems to have been flat in the UK, Germany, and France (chosen as representative strong European economies) up until the credit crisis since 1995 - as far back as I can find data easily. Presumably these countries were borrowing money and had inflation during this period, which would imply their GDP growth was in fact matching pace with a constantly increasing debt.
Comment: A quick question - is it the governments that hold the debt or is the people who do it? The latter are probably less likely to stop loaning just because as the decision process is much more distributed (and I assumed this is the case).
Comment: Doesn't Greece's debt crisis undermine your argument?
Comment: I like how you attribute your statement that due to inflation the value of a loan decreases over time to an article in the economist that states that doing that on purpose is *a horrible horrible idea*. Its last sentence is literally "When inflation has been used to reduce debt in the past, it has usually happened because a government has resorted to this out of desperation and weakness, rather than because it has judged that it is in the best interest of the economy in the long-term." Some other quotes from the article:(...)
Comment: "On the primary deficit front, while higher inflation would boost tax revenues, it would also push up spending on state benefits and public sector wages. It is not clear that it would be beneficial; the UK recently blamed inflation for increasing its deficit." "On interest rates, investors would demand a higher interest rates to compensate for the inflation risk. While they might be surprised by inflation for a while, as they were in the 1970s, sending real rates negative (or even more negative than they are at present), they would eventually cotton on. Real rates in the 1980s were very high."
Comment: @sgf Well the whole idea of inflation is that it increases everything; it's not surprising that it increases deficits as well.
Comment: @kjetilbhalvorsen what about the roman empire. Or the greece city state of sparta? Or the egyptian dynasty or babylonian empire? Really keeping history to "lats 100 years" which american influenced people seem to do is arrogant.
Comment: @AndréParamés But then exactly the same terms apply to a private loan - And, since inflation is already computed in the terms, you don't gain anything by keeping your loans up. Yes, 1.2 Trillion will be worth less in 50 years, but you will be paying more than 1.2 Trillion in 50 years or noone will buy your bonds (except if your Germany).
Comment: To all those saying a country does have a finite lifespan, I would compare a country to a person who can never die of old age but can die of a disease. They *can* live forever, they just won't, and we have no way of knowing when they will die
Comment: Interest rates on the federal debt would go up if China stopped buying. The hard question is how much.
Answer: To add to Gramatiks' excellent answer, the question makes another incorrect assumption, that China is somehow doing US a favor by lending money.
On one hand, US clearly benefits by having more demand for its debt (and thus, duh, having the debt being cheaper - finance/economics 101). On the other hand, China is not doing this out of being nice, but of economic necessity. Warts and all, US Treasury debt is still among the very safest, least risky investments there are; and the only one at the scale that China as large investor can invest in (what are they going to do, sell US Treasuries and buy Iran Bank notes? Or Russian debt? It may make some political statement, but very little financial sense). The fact is, they need to invest the money somewhere, to outpace inflation.
I'm going to omit the more wonky finance arguments pertaining to trade and currency exchanges, but that's also a factor (basically, if you trade in USD, you benefit from investing in USD based of course on exchange rate projections).
Comment: @NoSenseEtAl - with all due respect you don't seem to understand finance. Unless China lives in a magical fairy world of 0% inflation, they **don't have a choice** of whether to invest money or not. The only choice is where.
Comment: @user4012 you do not understand economics. Governments do not need to save money. China is buying US bonds to weaken their currency, not to save.
Comment: _the question makes another incorrect assumption, that China is somehow doing US a favor by lending money_ Why? Where does the question seem to assume something like that, or that China is doing this out of being nice? I cannot see anything not even remotely like that in the question. Maybe it was edited out?
Comment: @user4012 Hmm.  I'm not sure that the argument about inflation is really correct.  The US has a large trade deficit with China.  Buying US debt with those extra dollars helps keep the Remnibi from appreciating against the dollar.  [Read here](https://www.investopedia.com/articles/investing/040115/reasons-why-china-buys-us-treasury-bonds.asp)
Comment: @JimmyJames - the latter is a reason to invest in US debt. The former is a reason to invest ANYWHERE they can (which, thanks to the latter, as well as USTs being good investment, is best in US)
Comment: @NoSenseEtAl - it has nothing to do with saving. It has to do with (1) beating inflation (2) trade deficite (another answer covered that angle very well)
Comment: downvoted, China can just cut taxes and does not *need* to invest the money somwehere.
Answer: The United States would do what any other nation would do: Borrow the money from someone else. Either from other governments, from private banks or from private people. Governments do this by issuing government bonds. These are openly traded financial instruments. The government motivates people to buy these from them by guaranteeing an interest rate. When China stops buying US bonds, then the United States might have to pay a slightly higher interest rate to find more lenders.
By the way, according to this source, the Chinese government only holds 10% of the total debt of the United States government. Also, the amount held by China is currently going down, not up. So China actually does stop lending money to the United States, and it did not really seem to hurt the popularity of US government bonds much.
Comment: @AashishLoknathPanigrahi almost all countries are in debt. Their lenders are not just other governments but mostly private banks and private people. Government bonds of economically stable countries like the United States are rather popular financial investment to safely "park" unused capital because they are relatively safe and provide a guaranteed interest rate.
Comment: @SantiBailors They **are** already doing that. As I wrote in the second paragraph, only 10% of the US debt is to China. The comment by DavePhD says that the number might be even smaller. Also, keep in mind that bonds are openly traded financial instruments. The US could not stop another country from buying them up even if they tried. Finally, China owning US bonds is an issue which is far less serious than some people seem to assume, but that's material for a completely different question.
Comment: @indigochild What kind of source are you looking for? Suppose I claim that, if a grocery store closes down, its customers will go shop somewhere else, rather than growing food in their gardens or whatever. Is there any source in the world that would back up that claim? I doubt it.
Comment: @SantiBailors What do they stand to lose? If China collects a huge amount of US debt, the result is China's prosperity being linked directly to that of the US.
Comment: @AndréParamés it goes even further than that. Since the debt is in US dollars, China has an incentive to keep US economy strong or else the value of the US dollar may go down which would make the debts less valuable. So USA has given China an incentive to help keep it strong.
Comment: _The United States would do what any other nation would do: Borrow the money from someone else_ Then why USA is not doing that already, instead of borrowing from the country that is perceived as its main rival / competitor or even - in some circles - trading adversary ?
Comment: Well you are not getting it , the annual deficit is in the range of 600-700 billion USD annually , Most of the countries don't even have the capacity to buy as much debt as that of China , because most of the nations don't have such a humongous trade surplus in USD as that of China. In case of US-China trade , China alone gets a trade surplus of over a 500 billion dollars. Give me an example of any nation which has such a humongous trade surplus.
Comment: @Philipp Debt held by China is 1168 billion http://ticdata.treasury.gov/Publish/mfh.txt , which is only 7.6% of the federal debt held by public and only 5.6% of the total federal debt.  https://treasurydirect.gov/NP/debt/current
Comment: @SantiBailors Comments are not the best medium to explain this. I would recommend that you post a new question where you ask about the political implications of one state owning bonds of a different state.
Comment: @DavidRicherby A statement from a knowledgable expert or sufficient personal experience is generally how answers are backed up. You could claim your own personal experience in observing what happens when a store close. You could also get a statement from the store's management or staff about what is likely to happen, or some kind of marketing research about what customers of that store report they are likely to do.  This is all important because in many cases customers won't be able to simply shop at another store (for example, because there are no substitutes available).
Comment: @SantiBailors as the old adage say, "If you owe the bank $100, that's your problem. If you owe the bank $100 million, that's the bank's problem." - and if the US government owes you $1T, it's definitively your problem. If push comes to shove, what exactly will China do if the US refuses to pay?
Comment: @mathreadler _So USA has given China an incentive to help keep it strong._ That's great, it means that viewing China as an adversary that might weaken USA economy makes no sense after all, nor does any possible action taken by USA to counter China. It's a nice outcome.
Comment: @AndréParamés What you are saying is that USA has the upper hand because it took money from China with the promise of giving it back but actually it's not forced to give it back because it could break the promise without consequences, and that China was a fool in trusting USA's promise. While sadly you might be right, making this sound cool is a bit over the line. On a different note, if I owe the bank $100 million, _both_ I _and_ the bank have a problem.
Comment: Can this answer be backed up? It sounds reasonable in many ways, but how do you know with a reasonable degree of certainty that this is what the United States would do?
Comment: They **are** already not borrowing from China and borrowing from someone else? (No). Why does it matter if it is 10% instead of 20? Shouldn't it be 0% if there were actually no reason to borrow from China instead of "someone else"? Why would a country borrow from its strongest adversary if said country has equivalent or better options? Can USA not stop Iran or North Korea from buying US bonds?
Comment: @SantiBailors at least that's what they might be hoping.
Answer: There is detailed analysis of this issue in U.S. Financial Exposure to China, U.S.-China Economic and Security Review Commission, 9 May 2017.
As best seen in Fig. 4 of the report, mainland China decreased its holdings of US treasuries from 1.25 trillion to 1.05 trillion in only a 5 month period (6/2016 to 11/2016).  This correlated with roughly an 80 basis point spike in 5 and 10 year rates (See Fig. 5).
The report cites the approximation:

a $100 billion decrease in foreign official purchases of U.S. Treasuries in a given month increases the five-year Treasury yield by 40–60 basis points (bps) in the short run and by 20 bps in the long run.

So with mainland China currently holding $1.17 trillion, if China stopped lending completely, and no other foreign country increased its lending, there could be a short term 6% (600 bps) increase and a long term 2.3% (230 bps) increase.  A 230 bps increase from current levels would still be lower than most of the 1965 to 2005 time period.
Comment: I think this is the best answer as to what we would expect occur. Demand for US debt would drop and therefore the rates would increase.
Comment: I agree. Quantifying the impact is what really matters once you have the facts. The only flaw is that this analysis is done in isolation, but an event that would lead to Chinese divestment of U.S. Treasuries would only happen in a geopolitical environment in which the events causing the divestment would have confounding effects including a probable stock market crash, increased militarization, etc. which might lead to a flight to safety that could mitigate this effect on interest rates, or exacerbate the effect.
Answer: You can look at it this way. The United States borrows money by selling bonds. Anyone can buy those bonds, and they're considered to be safe investments because the United States has not yet defaulted on paying back those bonds. As a result, the interest rate on those bonds is quite low.
China happens to wisely invest its money by buying lots and lots of US government bonds along with everyone else. China owns a large amount of those bonds, but many of those bonds are owned by other countries, individuals, and financial institutions. It's not like the US went directly to China and signed up for a loan, so it's a more general bond-issuer, bond-holder relationship and not a bank loan type of relationship.
The United States can't just choose to not pay back just China and it can't choose to loan money just from China. The debt goes to whoever buys the bonds, and the US government either pays up when bond holders redeem their bonds or it doesn't.
So if China decided decided not to loan any more money, it would just stop buying US government bonds. Presumably, other investors would fill in the gap by buying more bonds. If the bonds could not be sold, the US government would either have to issue bonds with a higher interest rate, attracting more investors, or reduce its spending.
If the US government became so dysfunctional that decided it can't pay back its debts, all bond holders would suffer, not just China. In that scenario, the interest rates on future US bonds would increase drastically, otherwise no buyers could be found. The value of current bonds would drop drastically, since there would be much less confidence that those bonds could ever be redeemed.
Remember, it's not a bank loan type of relationship the US government has with China, it's a bond investor type of relationship, and there are a lot more investors than just China.
Answer: As long as China runs a trade surplus with the US, it's building up dollar reserves. There's not much it can do with those dollar reserves other than lending them to the US, or spending them with someone else in a third country who will then lend them to the US. If the US's trade deficit shrinks then its need for government borrowing will also shrink.
Answer: Worst case, the US federal reserve prints another trillion dollars to pay back the debt, deliberately triggering hyperinflation which makes the debt worth next to nothing (Russia and Germany both did this in the early 20th Century). Unfortunately this also tends to screw the economically disadvantaged and the middle class which leads to social unrest, which in the case of Russia and Germany led to the fall of Tzarist Russia to the Bolsheviks and the rise of fall of the German Weimar Republic to Fascism.
On the other hand, I'm reminded of the old maxim that if you owe the bank a thousand dollars that's your problem, but if you owe the bank a million dollars then that's the banks problem. This level of international financial interdependency is one of the reasons we haven't had a war between the major powers in almost a century.
Comment: 3 trillion was printed from 2008-2014 https://fred.stlouisfed.org/series/BASE , but there was no price hyperinflation.
Comment: @brichins - If the price level goes up 20% in 10 years (2008 to 2018), that's less than 2% per year *on average* over the 10-year period. By the way, the US *did not* "leave the gold standard" in the 1970s, mostly because it hadn't been on the gold standard since the 1930s. To liken the Bretton Woods system of currency pegs to a type of "gold standard" is grossly misleading. Moreover, average annual CPI inflation in the 1960s exceeded 2%. For sure, the Bretton Woods system did not, by itself, guarantee price stability.
Comment: @DavePhD Not disagreeing, definitely not hyperinflation, but a couple thoughts. The Consumer Price Index has [gone up 20%](https://tradingeconomics.com/united-states/consumer-price-index-cpi) since 2008, which is significant (though not significantly more than the trend since leaving the gold standard in the 70s, sadly). Also noticed your source chart is "currency in circulation"; wondering how much of that was re-circulated cash from more favorable investing options, and if currency taken out of circulation is accounted for in the numbers.
Comment: @Mico I was not familiar with Bretton Woods system - thanks for the reading suggestion. :) Was mostly just saying that increasing the amount of currency in circulation wasn't without effect at all; seems like there is little attention given to inflation by the media or people I interact with. Beginner at large-scale financial matters here, need to do a lot more studying.
Answer: Trading Economics has a good historic graph of US debt.  The US does not owe $6 trillion to China.  Some of the US debt is owed to Americans - think of the new government money market funds, which own treasuries and are with some brokerages the "default" fund (replacing the old money market funds).  The discussions about the debt don't always mention that it's not ONLY foreigners who own US debt, but also some Americans.
Even with the debt and even if China, Japan and all other countries stopped buying treasuries, the US could buy its own debt similar to what the Fed did with the QEs - purchasing their own bonds.  The US has assets, which rarely get discussed,  such as student loans, the exchange stabilization fund, and 8100 tons of gold.  Wrap that up with the second largest amount of natural resources and even with the dollar losing some value, it still won't go to zero like pundits claim.
Answer:
So what will happen if China stops lending money to U.S. as prospects of ever getting back the debt is highly unlikely because of the ever increasing deficit and spending?

US National debt exists in the form of US Treasury bonds.  If Chinese government buys less of them, then their price will fall until other buyers step in and start buying.
If there are no buyers in the market, the Federal Reserve steps in and buys the rest of the bonds offered for sale.  Since the Federal Reserve has no limit on how many bonds it can buy, this process need not ever stop.
Although if it happens too fast, it would increase inflation (because it would increase the amount of money in circulation without increasing the amount of goods and services in the economy).  This would render all the bonds that Chinese banks are holding worth less (if not worthless).  But as long as the whole process is controlled and happens slowly, no one loses more than they can afford to lose (and everyone gains a stable economic system).
Answer: While 1.1T looks huge it is actually not that big when you consider the size of the US debt.
Only big problem that can happen is that it could trigger a panic in a similar fashion as bank runs happen.
So while the most probable case is that the interest rates US would need to pay are just gonna increase a bit it is possible that it could trigger a debt crisis.
Comment: Interesting point that it's about 5% of the overall debt.


Efficient and stable estimation of restricted weighted multivariate regression model

Question: First, I will show what I currently do in a (non-redistricted) weighted multivariate regression model. Then I will pose my question as I need the notation I introduce. Suppose we have weighted multivariate least squares problem of the form
$$
\vec{y}_i = F\vec{x}_i + \vec{\epsilon}_i, \qquad \epsilon_i\sim N(\vec{0}, \Omega)
$$
where $\vec{y}_i,\epsilon_i \in \mathbb{R}^p$, $\vec{x}_i \in \mathbb{R}^q$, $\vec{\epsilon}_i$ are iid, and each observation $i=1,\dots,n$ has a weight $w_i$. Then the MLE of $F$ is
$$
\hat{F} = \underset{F}{\text{argmin}} \lVert W^{1/2} (Y - XF^\top) \rVert^2
$$
where
$$
Y = (\vec{y}_1,\dots,\vec{y}_n)^\top, \quad X=(\vec{x}_1,\dots,\vec{x}_n)^\top
$$
and $W$ is a diagonal matrix with the weights $w_1\dots,w_n$ as the diagonal entries. Let $\tilde Y = W^{1/2}Y$, $\tilde X = W^{1/2} X$, and the QR decomposition of
$$
\tilde X = QR = Q\begin{pmatrix} R \\ 0 \end{pmatrix}
$$
Lastly, let
$$
Q^\top \tilde Y = \begin{pmatrix} C_1 \\ C_2 \end{pmatrix}
$$
where $C_1$ are the first $q$ rows of $Q^\top \tilde Y$. I have solved the above problem by computing $R$ and $C_1$ in parallel with a low memory footprint as in the bam function in the R package mgcv (see Wood, 2015) since the matrices I worked with are rather large. Then I use that
$$
\hat{F}^\top = (R^\top R)^{-1}R^\top C_1 = R^{-1}C_1
$$
and the MLE of $\Omega$ is
$$
\hat \Omega = (\sum w_i)^{-1}(\tilde Y^\top\tilde Y - C_1^\top C_1)
$$

Now suppose that I want restrict some  of the parameter in $F$ such that
$$
\text{vec}(F) = K \vec{\theta} \Leftrightarrow
     \text{vec}(F^\top) = \underbrace{H_{p,q}K}_{D}\vec{\theta}
$$
where $K \in \mathbb{R}^{pq \times k}$ is a known matrix with full column rank, $k < pq$, $H_{p,q}$ is the $(p,q)$ commutation matrix, and $\text{vec}(\cdot)$ is the vectorization function. Suppose that we have an estimate of $\Omega$ denoted by $\hat \Omega$ then it is clear that we can use the GLS estimator. That is, we denote
$$
\mathrm{y} = \underbrace{\text{vec}(Y)}_{pn\times 1}, \quad
\mathrm{X} = \underbrace{I_p \otimes X}_{pn\times pq}, \quad
\mathrm{O} = \underbrace{\Omega \otimes I_n}_{np \times np}
$$
where $\otimes$ is the Kronecker product and $I_l$ is the $l$ dimensional identity matrix. It follows that
$$
\mathrm{y} = \mathrm{X}D\vec{\theta} + \mathrm{e}, \qquad
    \mathrm{e}\sim N(\vec{0}, \mathrm{O})
$$
Let
$$
\tilde{\mathrm{y}} = \text{vec}(\tilde Y), \quad
\tilde{\mathrm{X}} = I_p \otimes \tilde X, \quad
\widehat{\mathrm{O}} = \hat\Omega \otimes I_n
$$
Then we can find that the MLE is
$$
\widehat{\vec{\theta}} =
    D^+ (\tilde{\mathrm{X}}^\top\widehat{\mathrm{O}}^{-1}\tilde{\mathrm{X}})^{-1} D^{\top+}
    D^\top \tilde{\mathrm{X}}^\top\widehat{\mathrm{O}}^{-1}\tilde{\mathrm{y}}
$$
We can use that
$$
\begin{align*}
\tilde{\mathrm{X}}^\top\widehat{\mathrm{O}}^{-1}\tilde{\mathrm{X}} &=
    (I_p \otimes \tilde X)^\top(\hat\Omega^{-1} \otimes I_n)(I_p \otimes \tilde X) \\
&= (I_p \otimes \tilde X^\top)(\hat\Omega^{-1}\otimes\tilde X) \\
&= \hat\Omega^{-1}\otimes (\tilde X^\top\tilde X) \\
\tilde{\mathrm{X}}^\top\widehat{\mathrm{O}}^{-1}\tilde{\mathrm{y}} &= (I_p \otimes \tilde X)^\top(\hat\Omega^{-1} \otimes I_n)\text{vec}(\tilde Y) \\
&= (I_p \otimes \tilde X^\top)\text{vec}(\tilde Y\hat\Omega^{-1}) \\
&= \text{vec}(\tilde X^\top\tilde Y\hat\Omega^{-1}) \\
\end{align*}
$$
Thus,
$$
\widehat{\vec{\theta}} = D^+ (\hat \Omega \otimes (\tilde X^\top \tilde X)^{-1})
    D^{\top+}D^\top\text{vec}(\tilde X^\top\tilde Y\hat\Omega^{-1})
$$
and maybe
$$
\widehat{\vec{\theta}} = D^+ (\hat \Omega \otimes (R^\top R)^{-1})
    D^{\top+}D^\top\text{vec}(R^\top C_1\hat\Omega^{-1})
$$
which if one of my questions: is this true? If it is true then I can re-use the code I have written in the non-restricted model unless. That is, do it in parallel with a low memory footprint (not having to store the entire matrices at any one point). Are there other smarter (faster, stable, parallelizable, and low memory footprints) ways to do this?
I have seen the GLS estimator posted in multiple places but never come across an actual way to implement the estimation in the context of multivariate regression models.
Answer: To answer

and maybe ... which if one of my questions: is this true?

Then it is true as this example in R shows
#####
# simulate data
n <- 1000
p <- 2
q <- 4
k <- 2

library(Matrix)
K <- Matrix(0., p * q, k)
K[1, 1] <- K[3, 1] <- K[5, 1] <- K[7, 1] <-   1
K[2, 2] <- K[6, 2] <- 1
theta <- c(2, -.5)
(F. <- Matrix(as.vector(K %*% theta), p, q))
#R 2 x 4 Matrix of class "dgeMatrix"
#R      [,1] [,2] [,3] [,4]
#R [1,]  2.0    2  2.0    2
#R [2,] -0.5    0 -0.5    0

Omega <- Matrix(c(2, -1, -1, 1), 2)

set.seed(63098548)
X <- Matrix(rnorm(q * n), ncol = q)
Y <- X %*% t(F.) + Matrix(rnorm(n * p), n) %*% chol(Omega)
ws <- sample.int(1:5, n, replace = TRUE)
W_sqrt <- Diagonal(n, sqrt(ws))

#####
# Fit model as in the dense case
qr_o <- qr(W_sqrt %*% X)
R <- qr.R(qr_o)
C_1 <- qr.qty(qr_o, as.matrix(W_sqrt %*% Y))[1:q, ]

t(solve(R, C_1))
#R        [,1]   [,2]   [,3]    [,4]
#R [1,]  1.912 1.9934  2.019  2.0322
#R [2,] -0.456 0.0471 -0.516 -0.0273

# and we get the same w/ the GLS estimator
solve(
  kronecker(solve(Omega), crossprod(R)),
  as.vector(crossprod(R, t(solve(Omega, t(C_1))))))
#R 8 x 1 Matrix of class "dgeMatrix"
#R         [,1]
#R [1,]  1.9125
#R [2,]  1.9934
#R [3,]  2.0189
#R [4,]  2.0322
#R [5,] -0.4561
#R [6,]  0.0471
#R [7,] -0.5155
#R [8,] -0.0273

#####
# fit model in restricted case. Somehow we know Omega
D <- matrixcalc::commutation.matrix(p, q) %*% K
t1 <- crossprod(D, as.vector(crossprod(R, t(solve(Omega, t(C_1))))))
t2 <- crossprod(D, kronecker(solve(Omega), crossprod(R)) %*% D)
solve(t2, t1)
#R 2 x 1 Matrix of class "dgeMatrix"
#R        [,1]
#R [1,]  2.003
#R [2,] -0.505


How common is the idiom "No great shakes"

Question: How common is the idiom "no great shakes" in spoken English, especially among native English speakers? Will I sound natural if I use it in general conversation?
Comment: It seems to be the motto of many hamburger joints.
Comment: It used to be very common 30 or 40 years ago in US English. If you used it today, you would be very well understood, and no one would think it was strange, but it doesn't seem to be used very often now.
Comment: If you're not sure, don't use it. We can't tell you because we don't know the context of either intended sentence or audience.
Comment: Thank you so much to all.
Comment: @IsabelArcher Not just US English, your comment would apply almost exactly to UK English as well. People my age still use it sometimes but younger people (most of the population) do not seem to do so.
Answer: Its use in 21st century TV would indicate that it's not beyond the ken of the average Joe.
From the TV corpus:

I'm such a ninny, I didn't realize it before. I'll never be able to
thank you. Oh, no great shakes.  (Roots, Episode #1.2, 2016)
He... he always said he was glad that I was born there because, "
being a Connecticut Yankee in King Arthur's court is no great shakes.
" (Once Upon a Time, An Untold Story, 2016)
But no writer should be judged on their first effort. I mean, the
first draft of my novel was no great shakes. - Sure it's better than
this. (Murdoch Mysteries, Shipwreck, 2015)
You know, this manager job is no great shakes but it'll keep me here
and, I don't know maybe I can go to night school or something. (ER,
Drive, 2004)

A google Ngram comparison shows it to be a bit less common presently than run of the mill, but it's been a pretty steady part of the language for 200 years or so.

Looks like you'll be safe using it as long as it fits the context.
Comment: In the UK the term is used slightly differently, we use it to mean that someone, usually oneself, does not have great competancy in something. We would say, for instance, "I'm no great shakes at ballroom dancing"


Virtual-machine running from DVD?

Question: Greetings all,
I have this application which uses Tomcat and PostgreSQL (only involve database reads, no writes).
I need to make this application runnable from a DVD.(target platform is Windows).
So I was thinking to do these:

1) In a VirtualMachine (i prefer
  virtualbox) install lightweight linux
  distro.
2) Install Tomcat and Postgre,
3) Write virtualmachine into DVD which
  loads above virtualmachine image
  automatically when executed.

But I am not quite sure whether I can do step 3.Or is it possible ?
Note : My users cannot install VM software in their machines.I just give the DVD and they can execute the VM installed inside the DVD.
Any tips?
Answer: Can you put a vm image into a DVD?
Yes
Can you run the vm whithin (inside) the DVD?
Probably not, because the vm itself will need write permission for RAM files and things like that.
Answer:
Is it possible ?

Sure. This approach is similar to what live CDs do, and a number of VM servers support this natively with no extra work on your part (e.g., VMWare GSX).
Of course, because the VM still needs space to write files (because the guest OS will need to write files even if your application doesn't), you're going to pay a hefty price in memory. Essentially the pieces of the VM that need to be written to must be offloaded to main memory, which reduces the memory available to the rest of the applications you have.
Comment: IIRC some virtual machine runners support a bootstrapper so that you don't need to install the VM software itself. I haven't done this myself, though.
Comment: thanks John , I was asking whether its possible to run the VM+VM Disks   from the DVD.
I give the DVD to client and they execute the VM within the DVD  (so that they dont need to install VM in their machines )

Virtual-machine running from DVD?