Complements of Linear Bounded Automata?

Question: Would switching the accept and reject states of an LBA A create a new LBA we'll say A' in which the language of A' is the complement of the language of A? I believe the answer is yes just by working out an example...but I'm not sure on a solid proof...nor am I sure if the fact that I am working with an LBA vs a regular turing machine makes a difference in this case.
Comment: As is often the case, the answer likely depends on the exact definition. What is the acceptance criterion resp. how is the output defined?
Comment: @Raphael I'm not sure I understand the comment. Isn't the meaning of LBA acceptance well defined?
Comment: @KevinG Well-defined, yes, but in multiple variants, all equivalent. For instance, you may allow $c|x|$ cells to be used, or only $|x$. You may consider the whole tape the output, or just everything to the right of the head. You may require the automaton to loop on non-acceptance, or just to stop in a specific final state. Same power, but different technical details.
Answer: It depends whether the automaton is deterministic or not. If it is deterministic, then the answer should be yes, just as in the case of DFAs, and you can mimic the proof for DFAs. If it is non-deterministic, then the answer should be no, just as in the case of NFAs; in fact NFAs are a special case of non-deterministic LBAs, and the NFA counterexample can be adapted to the LBA setting.
(The set of languages accepted by non-deterministic LBAs is closed under complementation, but the proof is not quite as straightforward; it is known as the Immerman--Szelepcsényi theorem.)
Comment: Probably it is not that easy. Even a deterministic LBA might reject its input by starting an infinite computation. So, we should start by showing we can assume our DLBA to be always halting.
Comment: Let me explain my point. Assume I start with a DLBA and want to construct a DLBA for its complement language. Swapping accepting and non-accepting states results in a situation where strings with computations that do not halt are not accepted in either of the two DLBA. That is not complement. Indeed the number of configurations is bounded, but you cannot assume without further explanations that the construction exploits this fact. Tou need a solid construction to ensure always halting. Hence you cannot compare this to the case of DFAs. I repeat: "it is not that easy".
Comment: I believe that Yuval's answer is sufficient (I am talking about a deterministic LBA) since we can safely assume that an "infinite computation" would halt since LBA's have a finite number of configurations.
Answer: I agree with Hendrick Jan; I don't think the currently accepted answer is correct. Even though $A_{LBA}$ is decidable, that doesn't mean the LBA itself doesn't loop.
As a counterexample, consider an LBA $A$ over $\Sigma = \{0, 1\}$, where $A$ accepts $0$ but loops on $1$. Then $L(A) = \{ 0 \}$. The LBA with swapped states, $A'$, would reject $0$ and still loop on $1$, so $L(A') = \{ \}$. This should be a sufficient counterexample as $\overline{L(A)} = \{1\}$, which is not equal to $L(A')$.
Comment: I checked with my professor, you and Hendrick Jan are correct.

Complements of Linear Bounded Automata?


Source for the bride's circling the groom

Question: I understand that there are ways of deriving a scriptural basis for the tradition of circling one's groom three times or seven times, etc - but what is the earliest (written) source for this being a custom?
Comment: Is this not an exact duplicate of the question you link to merely because you're seeking a source for circling three *or* seven times whereas the other question seeks a source for circling seven times only?
Comment: The question I linked to asked for the source only; I wanted the earliest written reference to it. Had the answer that I'd been given already been put there as well, I wouldn't have asked it. Now that @sam has answered it in both places, should I take my question down?
Comment: Since Sam has added the same answer in both places and, here, doesn't actually show that it's the *earliest* source (what this this question asks) but you accepted it anyway, I'm inclined to mark as a duplicate.  Other thoughts?
Comment: @MonicaCellio, sounds good, except for the three vs. seven thing, which I don't know what to do with.
Comment: @msh210, close this and if Shimon wants to ask separately about sources for three he can?
Comment: @MonicaCellio, good idea; done.
Answer: Kitzur Shulchan Aruch 147:5 says 7 times.
http://www.yonanewman.org/kizzur/kizzur147.html
Comment: I doubt that's the earliest source, but that will help me find it. Thanks!
Comment: Nope - it actually **might** be the oldest textual reference!


Fantasy novel where girl enters the world of fairy tales

Question: I am looking for a fantasy novel which I read 3 years ago. I want to read it again, but the problem is I don't remember much about the novel. It was about a girl who gets letters from her grandfather (maybe?) and somehow enters into the world of stories or maybe turns into a fictional character, as if she was reading about herself in some story book. She is able to see the fictional characters (eg. Snow white, dwarfs, Cinderella) and normal people can't see her anymore.
Comment: Can you remember any more details that might help identify the novel. Such as: What language was it written in? Where is it set? Is it set in the past, present or future?
Comment: @Valorum that title is actually wrong, if I have the story right.
Comment: @Mithrandir - Yes, but it matches the question. We don't retrospectively change Story-ID titles to match correct answers
Answer: Sophie's World,  by Jostein Gaarder.
In this book Sophie is reading something that she's receiving in the mail. It contains messages to someone with Care of Sophie. At the end,  it turns out that she is a character in a book and then she escapes with her teacher from the book.  She meets the fantasy characters and the regular people can't see her anymore.
From Wikipedia:

    Sophie Amundsen (Sofie Amundsen in the
Norwegian version) is a 14-year-old girl who lives in Norway in the
year 1990.      The book begins with Sophie
receiving two messages in her mailbox and a postcard addressed to
Hilde Møller Knag. Afterwards, she receives a packet of papers, part
of a course in philosophy.      Sophie,
without the knowledge of her mother, becomes the student of an old
philosopher, Alberto Knox. Alberto teaches her about the history of
philosophy. She gets a substantive and understandable review from the
Pre-Socratics to Jean-Paul Sartre. Along with the philosophy lessons,
Sophie and Alberto try to outwit the mysterious Albert Knag, who
appears to have God-like powers, which Alberto finds quite
troubling.      Sophie and Alberto's entire
world is revealed to be a literary construction by Albert Knag as a
present for his daughter, Hilde, on her 15th birthday.
     As Albert Knag continues to meddle with
Sophie's life, Alberto helps her fight back by teaching her everything
he knows about philosophy. Alberto manages to find a plan so that he
and Sophie can finally escape Albert's imagination. The "trick" is
performed on Midsummer's Eve, after Alberto informs Sophie's mother
about everything.

When Sophie receives the letter for Hilde:

Sophie felt her pulse quicken a little as she saw who the postcard was addressed to: "Hilde Møller Knag, c/o Sophie Amundsen, 3 Clover Close..."
Dear Hilde, Happy 15th birthday! As I'm sure you'll understand, I want to give you a present that will help you grow. Forgive me for sending the card c/o Sophie. It was the easiest way. Love from Dad.

When Hilde reads this part:

Hilde read on and on. With surprise, she reads about Sophie Amundsen receiving a postcard from Lebanon. "Hilde Møller Knag, c/o Sophie Amundsen, 3 Clover Close..." (above text)

Meeting fantasy characters:

"I'm out of one of Grimm's Fairy Tales. That was nearly two hundred years ago. And where are you from?"
"We're out of a book on philosophy. I am the philosophy teacher and this is my student, Sophie."
Comment: By the description in a question, I doubt that Sophie's world is a correct answer. Of course, the informations match. But I read it and the last thing I would remember is that Sophie is meeting fantasy (or even fairy tail) characters. The whole book is actually about philosophy and that is very clear from it. It seems very strange to me that OP would remember the fairy tails characters and not the philosophy.


Multisite plugin hiding on specific blogs

Question: Is it possible to hide plugins on a per blog basis in WordPress multisite? I would like not to have plugins available on certain blogs.
Answer: Super Admin is your friend!  If a plugin is not active in the Super Admin (also lamely named Network Admin) Then it won't show up as an option for individual blogs.
It basically works like this:
Installed as Super Admin (main site) and "Network Active" will be active on all blogs on the network.
Installed on Super Admin, Active but NOT "Network Active" only active on Main/Parent site
If you want it only installed on a few sites then just manually install the plugins like you would normally do. Each instance of WordPress on a multisite is treated as its own site so installing a plugin on one site (with the exception of the main site) will not install it on the rest.
EDIT:
Based on your comments I would make sure that the user has the correct role to upload/activate plugins. You must create a user in each site individually or add an existing user to the site.
You could also try a plugin like http://wordpress.org/extend/plugins/multisite-plugin-manager/ and see how it goes.
Comment: Hmm that's not what I'm seeing. Installing a plugin and not activating it in Network admin, makes it available for activation in all individual blogs.
Comment: From the individual blogs I cannot search for or upload any plugins. And I see all plugins installed via Network admin, whether activated there or not.
Comment: See Edit and let me know if that helps.


How to power up raspberry pi with batteries?

Question: Anyone here who has powered raspberry pi with batteries like lipo or alkaline batteries? I need to know how to do it.
Comment: Welcome to Stack Exchange. I have edited your title in order to meet SE standard. About your problem, could provide us more informations. Specifically: How long your RPi is supposed to work without interruption?
Comment: thanks sir.
I need it to work for around 15 to 20 min probably without any interruption.
Comment: actually I am working on an autonomous GPS based car which will be controlled through pi...
so I want to know that how to power raspberry pi with batteries.
Comment: Take a look at:
https://www.kickstarter.com/projects/hamishcunningham/mopi-mobile-and-24-7-power-for-the-raspberry-pi
This might give you what you need
Comment: Sounds like a duplicate of http://raspberrypi.stackexchange.com/questions/1360/how-do-i-build-a-ups-like-battery-backup-system
Answer: You will need a voltage regulator to properly supply your pi (PSU @ elinux.org, there is related questions on RPi SE). Additional protections should be considered if you feed through GPIO.
Basically to answer you question, you can use the Peukert's Law as a first approximation:
C = t*I^k

Where k is an adimensional constant ranging in [1.1;1.3] depending of the battery, I is the current drawn (you need to sum all components of your circuit, including your GPS. RPi draws 1A when idle), C the battery capacity (the fundamental specification of the battery with a dimension in A.s) and t the discharge time.
Eg.: t = 1/2h, I = 2000mA and k=1.2 leads to C = 0.5*2000^1.2 = 4573 mAh, then you better to select a 4800mAh battery.
Battery voltage must be chosen accordingly with the voltage regulator you selected. Do not forget that you need a good 5V supply in order to service your RPi.
Caution: LiH battery needs to be handle with care, it may explode and cause injuries. You need a dedicated circuitry to charge and discharge it. If you are not used to, select regular NiCd or alkaline Battery.
Answer: If you take either of those you need a regulator/BEC.
That said, I have sucessfully powered my Pi with (4) 1.2V NiMh(Nickel Metal-Hydride) batteries, just some cheap 2500mAh rechargeable energizer ones, no regulator needed and safe for your Pi :)
Comment: Just curious about it: How long does it shoulder your Pi? How old are those batteries (how many cycles)? Have you experienced some weird behaviour when processing complex jobs (I mean high CPU load)?
Comment: It powers mine for about 3-4 hours. They are about 30 cycles in. I have mine on a custom quadcopter, powering the Pi, my signal receiver and a MUX and 8 pin DIP MCU on a breadboard also. The Pi is sending 4 pulse widths out constantly, so the workload is high and it still works perfect..
Answer: Something that works well for me is using a portable power pack as opposed to a battery.  These are convenient due to the fact that they can plug up via the usb port, and they are easy to charge.  I have a solar powered one thats around 2000 mAh that can run my pi for an hour or 2 (havent timed it just ball parking it).  Or recently i got a portable charger that has a 6000 mAh battery that can power it for at least 4 hours (once again just ball parking it).  I have tried the battery method before but it seems a bit overly complicated and runs a risk of ruining my Pi.  So thats why i opted for this. Anyway i hope this helps you out.  I highly recommend this route above any other.  Cheers!!!
http://www.amazon.com/s/ref=sr_nr_n_12?rh=n%3A7073960011%2Ck%3Aportable+power&keywords=portable+power&ie=UTF8&qid=1394068518&rnid=2941120011
Answer: As already pointed, battery voltages will decrease with utilization (consumption), so you will need some sort of circuit to regulate such voltage to 5V for the Pi.
Lipo cells (single ones) for example will have voltages around 3,7V so you will need a boost (step up) circuit; putting them in series (say three of them) will give you around 11,1V, so you will need a buck converter (step down).
There is also the case when you may need a buck-boost circuit, since the voltage of the batteries can go below or above (say) 5V.
I recommend a UPS I found on Aliexpress, which will recharge lipo's and provide a clean stable voltage output for the pi: https://pt.aliexpress.com/item/32783727347.html .
Also keep in mind that you will need to calculate the quantity of batteries based on how long you want to power your system for. In my specific case I am supplying a Pi 4 + 7" HDMI display (for a total of 7W) for 7 hours on 6s (cells) Lipo.


About 'writing to files' and user permissions

Question: I'm working on a VB.NET (2010) project that will need to write text files to the end user's computer. I have read online that due to some user's security settings, that the safest place to write files to is the Application Data folder.
But what I would like to do (if possible) is allow the user to select where they want the files written to, via a SaveToFile dialog (I am using a SaveFileDialog in combination with My.Computer.FileSystem.WriteAllText).
So my question is... if I use a SaveFileDialog (as opposed to saving a file without using a dialog), does that mean that my files will always be written to wherever the user selects?
Or is it possible that the user could select a location (ie their "desktop"), and it would not write the file there, due to their security settings? (UAC, Firewall, etc).
If the latter is possible, is there anything I can suggest to the user that they can do that would  enable my program to write files to wherever they select, and it would work 100% of the time?
Like maybe... if they right-click on my program's exe file and go to Properties > Security, and make sure the 'Write' permission is allowed, will that do the trick? Or is there more to it than that?
And does it mke any difference whether or not they are logged into their computer as "admin"?
I've read a lot of conflicting things about all of this online, so I'm just trying to getting a better understanding of it all so that I know how to proceed.
Thanks!
Answer: The [Save As] dialog will only let the users select a folder they have read and write acceess to and that is done for you by the Operating system . So that is the best option in my openion


How to compile my own linux kernel?

Question: I want to learn about compiling a kernel from scratch. How can I download the latest stable Linux kernel from http://kernel.org/, compile it, and install it in a VMware virtual machine? This is just for educational purposes.
Comment: could you just clarify if you want to do exactly what you ask, or just run linux in a vm?  because linux is more than a kernel, and you don't need to compile a kernel, and, even if you want to do that, there are easier ways than compiling on windows (for example, install a linux distro and then update the kernel).  so it's probably best to clarify up front the details...
Comment: @andrewcooke I just want to learn. May be one day I want to have my own linux distirbute :)
Comment: I'm going to change this to just talk about compiling a kernel, and get rid of the "no use a distro" answers
Comment: Before starting to compile, I'd read a lot of the kernel sources, starting at the arch directory, followed by the kernel, lib, fs. If your hair still isn't grey after that, sneak thru the Makefiles.
Answer: Your question is too vague for anyone to give you a thoughtful answer, but here's the gist.
Compiling a kernel requires sources, so you'll need to get those.  Most Linux distros have a package for downloading the latest sources, or you can go manual and just download the latest tarball from kernel.org
Then, once you have the sources, un-tar them somewhere (usually /usr/src) cd into it and use menuconfig to compile it for your environment.  When that's finished, you'll run make && make modules_install and after a whole lot of output, you'll find a compiled kernel in arch/x86/boot/bzImage -- assuming you're using an x86 architecture and you setup the kernel to use bz2 compression in menuconfig.
For a more long-winded and useful howto, you should check out the Gentoo handbook.
Answer: You can compile the linux-0.11 edition first and install it on the "bochs" to learn about the linux kernel. The latest distribution of Linux is too complicated to handle with.
Comment: Could you explain how I can do this?
Answer: Are you currently using a Linux distribution? Most if not all allow you to boot from different Kernels
Download, the Kernel from kernel.org (As of Writing its 3.7.1)
The instructions within the readme file make it incredibly simple, just about all the configuration options are documented and a lot of times it will say 'If you don't know what 'x' is, then it can be N' or 'It's a good idea to say Y to this'
If you mess up, reboot into the previous system and use make menuconfig and change whatever value is missing and recompile (It won't recompile the whole Kernel again don't worry)
My first compile I personally disabled anything I didn't need the only hiccup for me was I didn't enable a virtual file system needed for the terminal.

How to compile my own linux kernel?


Jquery Malsup Form Plugin errors in IE for file upload

Question: I have been searching for the last 2 days trying to find a solution to this problem.
there are quite a few issues with the file upload of the Malsup form plugin for jquery - mostly surrounding the use of .click() functions. However I managed to work those out, but now I am trying to implement the progress bar.
It works fine in Chrome/FF but in IE I am getting the same error as before - basically the plugin gets stuck at the form.submit() part.
Can you please try loading the demo page in IE and see if you can figure out the problem?
http://jquery.malsup.com/form/progress.html
I noticed it was missing 2 semi-colons (2 different locations) after bar.width(percentVal)
but even with them in it doesn't work.
Also, if you run the demo page with IE developer tool running, it freezes at the form.submit() part. If you don't use that, the progress bar doesn't animate but the file does seem to upload since it returns the name of the file.....
Thanks
Answer: I have the same issue with IE. After some googling I found out that upload progress is only supported
with XHR uploads on Chrome, FF,
Safari and IE10.
http://caniuse.com/xhr2
https://github.com/malsup/form/issues/177


ImportError: cannot import name 'Accounts' from 'brownie.network.account'

Question: Setup

MacOS Catalina v10.15.6
IntelliJ Ultimate v2020.1.1
Python v3.7
eth-brownie v1.14.6
Ganache CLI v6.12.2

I created a VENV using my Python 3.7.
Following Patricks tutorial, I have installed eth-brownie and Ganache CLI, and now I am trying to create a simple NFT.
Executing (from the command line) the below works fine:
brownie run scripts/simple_collectible/deploy_simple.py --network rinkeby
brownie run scripts/simple_collectible/create_collectible.py --network rinkeby

However, I would like to create my own NFT from scratch. For this, I tried brownie init within a new project, but init always fails with the following error message:
ImportError: cannot import name 'Accounts' from 'brownie.network.account'

If I create a new Python file and add the following import, I get the same error:
from brownie import SimpleCollectible, accounts, network, config

I've tried everything I can think of - anyone know how to fix this?
Answer: i managed to solve this by uninstalling brownie and eth-brownie, and installing it again. Just run:

pip uninstall eth-brownie

pip uninstall brownie
Check if they have uninstalled correctly doing a pip list, and then install them again:

pip install brownie

pip install eth-brownie

Hope it helps.


Commodity Asian Swaps

Question: I'm trying to find info about asian swaps on oil/energy products and about their pricing methods.
However, all I could find are on asian options.
Would be glad if you can provide me with some documents about it.
Answer: In an Asian-style swap, instead of using the last price quote of the underlying (such as commodity price), they take an average, such as the average closing price over the last month. This is fairly common in commodity swaps.
As for pricing, a good start is this paper on pricing Asian-style interest rate swaps (where the floating leg uses the average of an index): https://doi.org/10.3905/jod.2002.319185 Chang and Chung, The Journal of Derivatives, 2002.
Afterwards look at Chance and Brooks, An Introduction to Derivatives and Risk Management, chapter 9, for a good discussion of pricing commodity Asian-style swap.
Answer: Just my 2cts' worth: With commodity swaps exchanging typically a daily spot price (i,e, immediate delivery price) vs a fixed rate payable in regular intervals, the only difference to a truly Asian product is that discount factors are not perfectly equal to  unity. So while rates are not high or tenors very long, regular commodity swaps would be pretty close to being Asian swaps.
Answer: Only just saw this. Commodity swaps are very simple products. For each averaging period, they will pay off the notional for the period multiplied with the difference between the strike and the average of some reference contract.
The thing that's a little hard is knowing what the conventions are for how the reference price is determined. For example, for WTI swaps, one takes the first nearby future contract. For Brent, it's the same, except one rolls to the next contract one day before expiry already. For natural gas, one actually doesn't take the average. For some other products, it could be weekly. On top of that, for spreads between two products, you might have to apply a conversion factor if they are quoted in different units (e.g. from Gasoil (in MT) to Brent (bbl) it's 7.45 if memory serves me right).
In terms of pricing, the above is all very simple if you have a price model for the underlying reference contract. When such a price depends on a spot price, you could need a model for that as well, but for most swaps you can actually just get the price from traded contracts.  For the more complex swaps, you might be able to imply prices by combining a few different spread prices together, but again that's fairly obvious.
Finally, if it's more the management of these contracts that you're concerned about, the asianing implies that you need to buy/sell some of the underling reference contract at each fixing, but again that's rather straight forward to figure out. If you have any more detailed questions on a specific topic, let me know.

Commodity Asian Swaps


Are questions about company structure and team member role/responsibilty on topic?

Question: In a scenario of 4-6 back-end developers, 3-5 front-end, and 1-3 testers would it be on topic to ask what roles/tasks belong to the team chief/leader?
Comment: No, that's not on-topic.
Comment: Not here. You can try other places, like [The Workplace](https://workplace.stackexchange.com/help/on-topic), but I'd check with them first. You have the association bonus so you should be able to visit the chat room their help page refers to.
Comment: Most definitely belongs on https://pm.stackexchange.com/.
Answer: No. It's off-topic for two reasons:

It's too subjective. There's no correct answer to this, since a team is free to divide up responsibilities as it likes.
It's more of a management problem than a "specific" and "practical" "programming problem", at least as I interpret those terms (from https://stackoverflow.com/help/on-topic).

Depending upon precisely what you want to ask, your question might be on-topic on https://softwareengineering.stackexchange.com/ or https://workplace.stackexchange.com/ or https://pm.stackexchange.com/, though I'm not intimately familiar with any of those communities.


Morphism of tangent space induce from a morphism of varieties.

Question: I am trying to show that a morphism of varieties $f: X \to Y$ induces a linear map between the tangent spaces $\tilde{f}: T_aX \to T_{b} Y$, for $a \in X$ and $b = f(a) \in Y$. My idea was to use the intrinsic caracterization of the tangent
$$T_aX \cong (m_a/m_a^2)^*$$
where $m_a $ is the unique maximal ideal of the local ring $\mathcal O_{X, a}$ (which is the stalk at $a$ of the regular functions). I know that $f$ comes with a $k$-algebra morphism
$$f^*: \mathcal O_Y(U) \to \mathcal O_X(f^{-1}(U)): \varphi\mapsto f^*\varphi = \varphi\circ f$$
for $U \subset Y$ an open set. But from that I don't really see how should I construct $\tilde f$ explicitly. Could one of you give me an explanation ? I am not very comfortable with the notion of $\text{Spec}$ etc. so it would be nice to answer the question without using these tools.
Answer: Question: "Could one of you give me an explanation ? I am not very comfortable with the notion of Spec etc. so it would be nice to answer the question without using these tools."
Answer: If you are familiar with the "stalk" of a sheaf you can use the following method: The map $f$ induce for any point $x\in X$ a map of local rings ($y:=f(x)$)
$$f_x:=f^{\#}_x: \mathcal{O}_{Y,y} \rightarrow \mathcal{O}_{X,x}$$
mapping maximal ideal to the maximal ideal: $f_x(\mathfrak{m}_y) \subseteq \mathfrak{m}_x$. This gives a canonical map
$$\mathfrak{m}_y/\mathfrak{m}_y^2 \rightarrow \mathfrak{m}/\mathfrak{m}^2$$
inducing a map at tangent spaces
$$(df)_x: T_x(X) \rightarrow \kappa(x)\otimes_{\kappa(y)} T_y(Y).$$
Note: You must dualize to get the tangent space:
$$T_x(X):= Hom_{\kappa(x)}(\mathfrak{m}_x/\mathfrak{m}_x^2, \kappa(x)).$$
Note: Locally it $\phi: A \rightarrow B$ and if $\mathfrak{p}\subseteq B$ is a prime ideal with $\mathfrak{q}:=\phi^{-1}(\mathfrak{p})$, you get using localization an induced map
$$L1.\text{   }\phi_{\mathfrak{q}}: A_{\mathfrak{q}} \rightarrow B_{\mathfrak{p}}.$$
This is the map corresponding to the map $f_x$ with $x$ the point corresponding to the prime ideal $\mathfrak{q}$. The map in $L1$ maps the maximal ideal to the maximal ideal.
In Hartshorne, Chapter I.3 they define for any "algebraic variety" $X$ and any open set $U$ the ring of regular functions $\mathcal{O}_X(U)$. This defines a sheaf of rings on $X$ - the structure sheaf. In Theorem I.3.2 in the same book they prove the isomorphism
$$\mathcal{O}_{X,x} \cong A(X)_{\mathfrak{m}_x}.$$
With this definition any map $f: X \rightarrow Y$ of algebraic varieties induced a map of local rings
$$f^{\#}_x: \mathcal{O}_{Y,f(x)} \rightarrow \mathcal{O}_{X,x}$$
with $f^{\#}_x(\mathfrak{m}_y) \subseteq \mathfrak{m}_x$. Hence you get an induced map on cotangent and tangent spaces. The sheaf $\mathcal{O}_X$ has the property that there is an isomorphism
$$H^0(X, \mathcal{O}_X) \cong A(X)$$
where $A(X)$ is the coordinate ring of $X$. There is a 1-1 correspondence between points in $X$ and maximal ideals in $A(X)$.
This construction is "more elementary" than the $Spec$-construction. If you understand this construction it is not a difficult thing to understand the "more general" $Spec$-construction.
Remark: If you want to read about the $Spec$-construction there are many books available: Hartshorne "Algebraic geometry", Fulton "Algebraic curves" etc. The Fulton book is the "more elementary" and is a good introductory book.
Comment: Just, I don't really understand how $f_x^#$ acts on the element of $\mathcal O_{Y, y}$..
Comment: Also, the fact that we have changed the sense of the morphism at the end it's because we dualize ?
Comment: Thank you for your nice answer. Could you just tell me where can I find details about what you said on localization at a prime ideal ?


If concentration of K+ ions inside the cell is almost equal to concentration of Na+ ions outside of the cell why these ions cross the membrane?

Question: I'm a bit confused about electrochemical gradients of sodium and potassium ions. They have similar concentrations and are kind of similar ions but their distribution is different across the membrane. If that is true why they cross membrane. Why don't these gradients somehow cancel out? Why is there even need for sodium to enter the cytosol when potassium ions which are also positive are already inside?
Comment: While there is a good chance that you'll get a good answer here, I suspect that you might actually have better luck on Biology.SE.
Comment: Simple [osmosis](https://en.wikipedia.org/wiki/Osmosis).
Answer: In order to understand why this happens, you have to recall the permeability characteristics of the plasma membrane. It seems that the movement of ions to and fro the cystol is counterproductive however this is not so. Actually there is unequal distribution of ions in the extracellular fluid and cytosol

Extracellular fluid is rich in Na+ and chloride ions (Cl–). In
  cytosol, however, the main cation is K+, and the two dominant anions
  are phosphates attached to molecules, such as the three phosphates in
  ATP, and amino acids in proteins.

Differences in intracellular and extracellular concentrations of ions result primarily from:

the Na +/K + pump and
the permeability characteristics of the plasma membrane.

Ions pass through the plasma membrane through ion channels. The two major types of ion channels are leak channels and gated ion channels.
i. Leak Channels
Leak channels, or non-gated ion channels, are always open and are responsible for the permeability of the plasma membrane to ions when the plasma membrane is unstimulated, or at rest. The plasma membrane is more permeable to K +and Cl- and much less permeable to Na+ because there are many more K + and Cl- leak channels than Na+ leak channels in the plasma membrane.
Because the plasma membrane typically has more K+ leak channels than Na+ leak channels, the number of potassium ions that diffuse down their concentration gradient out of the cell into the ECF extracellular fluid ECF is greater than the number of sodium ions that diffuse down their concentration gradient from the ECF into the cell. See below

The plasma membrane is relatively permeable to K + and much less permeable to Na + and to negatively charged molecules found inside of the cell. Consequently, positively charged K + tend to diffuse out of the cell through K + leak channels, leaving the negatively charged molecules behind, thus polarizing the membrane. The membrane is at equilibrium when the tendency for K + to diffuse out of the cell is resisted by the negative charge of the molecules inside the cell.
ii. Gated Ion Channels
These channels open and close in response to small voltage changes across the plasma membrane. The movement of ions into or out of the cell changes the charge difference across the plasma. membrane, which causes voltage-gated ion channels to open or close. Voltage-gated channels specific for Na+ and K + are most numerous in electrically excitable tissues
The Na+/K+ Pump
The differences in K + and Na + concentrations across the plasma membrane are maintained primarily by the action of the Na + –K + pump. Through active transport, the Na+/K + pump moves K+ and Na+ through the plasma membrane against their concentration gradients. Potassium ions are transported into the cell, increasing the concentration of K + inside the cell, and Na + are transported out of the cell, increasing the concentration of Na + outside the cell. Approximately three Na+ are transported out of the cell and two K + are transported into the cell for each ATP molecule used. These pumps help maintain the resting membrane potential by pumping out Na+ as fast as it leaks in. At the same time, the Na+/K+ ATPases bring in K+.
In summary it is important to note, there is uneven distribution of ions in and outside the cytosol.
Because the plasma membrane has more K+ leak channels than Na+ leak channels, the number of K+ ions that leave the cell is greater than the number of Na+ ions that enter the cell. As more and more K+ ions leave the cell, the inside of the membrane becomes increasingly negative and the outside of the membrane becomes increasingly positive. The inability of most anions to leave the cell also contributes to the negativity of the resting membrane potential. These trapped anions cannot follow K+ out of the cell because they are attached to non-diffusible molecules such as ATP and large proteins.
Nevertheless, sodium ions do slowly diffuse inward, down their concentration gradient. If not controlled, such inward leakage of Na+ would eventually destroy the resting membrane potential. The small inward Na+ leak and outward K+ leak are offset by the Na+/K+ ATPases (sodium pump)
This diffusion accross the plasma membrane is necessary because:

There is uneven distribution of ions which needs to be corrected.
The characteristics of the plasma membrane has lot to do with how transport of substances occur ( It is important to note that not only ions use this path, other substances vital for cell growth have to use this path as well, therefore strict control is necessary)

Hope this helps
References

Anatomy and Physiology (Seely)
Principles of Anatomy and Physiology (G. Tortora, B. Derrickson)


How does a mortgage pay the seller?

Question: When someone gets a mortgage to buy a house does the mortgage company give the seller a lump sum of the purchase price? Or does the seller get monthly payments from the mortgage company?
Comment: You borrow the money from the bank, via the mortgage. You sign over checks for that money (plus any other money needed, typically at least 20% of  the total, minus any "earnest money" you have already put up during the negotiations) as part of the closing process. The seller leaves with the money; you leave with the deed and the mortgage obligations.
Comment: This is one of the ["too good to be a comment"](http://meta.money.stackexchange.com/questions/2298/should-answers-be-left-in-the-comments) we discussed at meta last month.
Answer: Without getting in to the detailed mechanics of a real estate transaction, the seller receives the proceeds of the property at once, not in payments as the mortgage is paid.  Unless, of course, the seller is also the lender; which is unusual.
Comment: It's amazing how impossible it is to just give a high level answer without delving in to every single detail and possible scenario, even when I explicitly say that's what I'm doing.  If you think this high level two sentence question culminating in "Or does the seller get monthly payments " needs a text book depth answer including the rights and payment of lien holders go ahead and write one.
Comment: Any lienholders on the property receive proceeds before the seller.  If Bob sells a house for $200,000 while he owes $120,000 on a mortgage, then the buyer will give a chunk of money to the title company and the buyer's lender will give a (typically) larger chunk.  The title company will then give $120,000 to the holder of Bob's mortgage and the balance to Bob.
Comment: "Seller financing" is more usual with small businesses plus property they stand on
Comment: @quid: True, considering every case is impossible. But the case where the seller also has a mortgage is not exceptional; if anything is is the most usual case.
Comment: @MSalters "Unless, of course, the seller is also the lender; which is unusual." IS... Unless the seller IS the lender.
Answer: What usually happens is the the buyer will arrange a mortgage, and provide the details to his lawyer.  The conveyancing lawyer will then set a date with the seller's conveyancing lawyer and carry out any check required by the mortgage provider and request funds from the provider.
On the date of completion the buyer's lawyer will usually transfer all the agreed sales price to the seller's conveyancing lawyer and the deeds will be transferred over.
Comment: aka "settlement"
Comment: The specific details of the process involving lawyers is not universal. I've bought and sold two houses in two different US states; neither I nor the counterparty used a lawyer in any of the four transactions.
Answer: The typical home purchase uses an escrow. This is an account, managed by an agent, that holds the money used to buy the house.
The buyer, the buyer's mortgage provider, and anyone or anything else contributing to the sale pay into the escrow account. The sale does not occur until the escrow account holds whatever remains of the sale amount (less the deposit or any other payments or credits).
When the sale completes, the escrow agent makes payments to whoever is supposed to get the proceeds of the sale. This could be any holders of existing mortgages or liens on the property. The remainder typically goes to the seller in some convenient form such as an ACH transfer.

How does a mortgage pay the seller?


How to find the source code of my contract which is not yet verified

Question: I had created a token using eth based blockchain via
remix.ethereum.org
But I need to verify the source code ,but I am not having the backup copy of source code
How can I see the source code of the token .
Please let me know
Answer: You cannot retrieve the original source code anymore, if no copy is available. The only way is to decompile the EVM bytecode to get a source code that is equivalent, but not equal to your original source code (it will look different but do the same).
When you compile your Solidity code to EVM bytecode, the constructor is still included. After the contract has been deployed, the constructor is discarded. Hence no constructor will be included in your decompiled code, if you only decompile the deployed bytecode of the contract. If you want to retrieve the constructor as well, you have inspect your deployment transaction, which additionally contains the constructor.
Comment: Thanks dear. Actually I was supposed to verify the contract source code on etherscan


AWS Ubuntu 14.04 upgrade Python to 2.7.10, how to deal with apt-get python-dev

Question: Ubuntu 14.04 from AWS ships with python 2.7.6.
Before doing anything else to the image, I do an upgrade to 2.7.10 by issuing
sudo apt-get -y install build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
mkdir -p ~/python/2.7.10
cd ~/python/2.7.10
wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
tar xzf Python-2.7.10.tgz
cd Python-2.7.10
sudo ./configure
sudo make install
cd ~/

I use make install instead of sudo make altinstall because I want it to be the only Python 2.7 on the system, the default one.
I know there is a warning in the docs
Warning: make install can overwrite or masquerade the python binary. make altinstall is therefore recommended instead of make install since it only installs exec_prefix/bin/pythonversion.
Should I stick to make altinstall? How do I make that my default python then?
How do I deal with other libraries, like pip install --upgrade --force-reinstall pyopenssl, which compiles some C code? In order for the C code to get compiled, I need to sudo apt-get install python-dev in order to get the headers. Is this assumption wrong? I'm a bit confused about this, as I guess that the python-dev in the repo is based on 2.7.6, if that makes any sense.
Additionally, since I'm running pip in a virtualenv, when issuing pip install --upgrade --force-reinstall pyopenssl in there I do get a OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pyOpenSSL-0.15.1.dist-info' error, which is most likely because I'm not running sudo (but as the default user), in order for the library to get installed into the virtualenv. What is causing this? It doesn't happen if I do not upgrade but leave Python at 2.7.6
A last question: as soon as I upgrade python manually by compiling, am I disallowed to use the python-* packages (apt-get python-*) in the repo?
Thanks in advance for your help.
Answer: Solved this issue by leaving all at its default and using Docker for all non-standard versions.


VTK python on mac does not catch the keyboard events

Question: I have the following question. I have compiled the latest VTK under Mac Os X 10.6, and I am using Python bindings. The python distribution I use is the Enthought Python Distribution (EPD). Everything works quite well, however there is a difference in behaviour of the same program on Mac and on Linux with respect to keyboard event. It seems, that I miss some very important point.
The part of the code is as follows
    vtkrenderer = vtk.vtkRenderer()
    vtkrenderWindow = vtk.vtkRenderWindow()
    vtkrenderWindow.SetSize(800, 600)
    vtkrenderWindow.AddRenderer(vtkrenderer)
    vtkrenderWindowInteractor = vtk.vtkRenderWindowInteractor()
    vtkrenderWindowInteractor.SetRenderWindow(vtkrenderWindow)
    vtkrenderWindow.Render()
    vtkrenderer.ResetCamera()
    vtkrenderWindowInteractor.GetRenderWindow().AddObserver('CharEvent', self.show_update)
    vtkrenderWindowInteractor.Start()

The function self.show_update has the following form:
def show_update(self, renderer, event):
    if renderer.GetKeyCode() == ' ':
        self.update(renderer, event)
        print 'ready'
        #Do computations here
        renderer.Render()

However, the spacebar is working only in the terminal, where I launch the program (using python test_particles.py but is completely ignored in the Cocoa window.
In Linux everything works as expected (keyboards are working fine).
Any help is appreciated.
Answer: Try launching the program with pythonw:
pythonw test_particles.py

This worked for me under OS X 10.10.2 using the Anaconda Scientific Python Distribution.


Github won't let me change the source of my personal website to gh-pages branch?

Question: I made a personal website using github pages a while ago but recently recreated it from scratch using ReactJS. I changed the name of my old website repository and made my new one username.github.io and moved the CNAME over. I then started following:
https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#github-pages
I'm stuck, however, on step 4 where I'm supposed to change the source to gh-pages branch. The option to change it is not clickable and right below it says "User pages must be built from the master branch".
My thoughts are that this is because my repository is named username.github.io thus being a user page. I'm guessing the tutorial may be specifically for a project pages? I also originally had a custom domain if that makes a difference. I think maybe the problem might be that my homepage is not set correctly? I was a bit confused on how the homepage should be set up since my app (repository) is named username.github.io. I tried username.github.io/username.github.io and username.github.io for homepage on my package.json but it just publishes my ReadMe.
Answer: That tutorial must have been done without taking into account user pages: see August 2016 ("Simpler GitHub Pages publishing").
Nowadays, the publication is done directly from the master branch (or the docs folder of the master branch) for a user page (not a project page)

As mentioned in facebookincubator/create-react-app issue 2976:

You can keep source in another branch, and copy contents of build folder to master branch after every build.
  I don't think there's anything special you need to do—just more manual steps.
  Maybe you could automate it somehow.
Answer: VonC's answer is correct. I wanted to, however, clarify and also add on to his answer. The build process for your project will build to a folder (dist/build/etc) that contains an index.html file. Github is looking for this file which in turn looks (most likely) for other files such as style sheets, media, and whatever else you use to build your website.
What VonC is saying is that you can literally just copy and paste necessary files over to the root (what appears upon opening the project folder). Push this and it should work.
However, this is not the ideal solution. You'd have to manually move it over every time you want to build. The way to automate this process is by using symlinks to connect the files in the root to your build folder. This isn't really ideal either but it works!
Comment: Interesting. +1. I didn't think of that folder content as being the result of a build process.


Why is Diablo 2 laggy when played online with a lot of effects going on (flames)?

Question: Is this a server or a game issue? This happens even on modern PCs. It's when baal-running for example and you got 8 people and a lot of spells going off (especially flames seem to be an issue) it can get laggy and people are afraid the game might be shut down because of dupe-protection. I do not know how this works or why this is. I would really like to know why. I think it's because the game uses old technology that makes it so that with modern hardware you don't necessarily get better performance.
Comment: its just old unoptimized code almost everything in the game is tied to framerate so when you have so many effects on the screen it takes a long time to process
Comment: Could you elaborate on this just a bit? I would like to know if it's because D2 is a 2d game, not 3d, or if the fault is in the programming.
Comment: by laggy do you mean drops in framerate?
Comment: @Rapitor most likely. I have never in my experience come across any noteworthy episodes of latency in my history of Diablo 2. (And I played on dial-up!)
Comment: Yes. I'm pretty sure it's because of the game itself. A guy describes the problem here: http://www.lurkerlounge.com/index2.php?option=com_content&do_pdf=1&id=816 but I don't quite understand why this is.
Comment: If you think fire is bad try playing with a plague javalin zon ;)
Comment: Yeah but do you know why this is? I don't.
Comment: It is possible that modern video cards are optimized for more recent programs (and programming idioms?) and thus will do worse for older games.  Was it always laggy on older machines in this situations?
Answer: For answering this question, I first have to explain what GLIDE itself is.
GLIDE is a graphic card-interface that has been evolved by the company 3DFX, to give application-programmers the chance, to access their graphic card-chipsets (so-called voodoo-chipsets) with high efficiency.
The game Diablo 2 (Lord of Destruction too) is known for the fact, that it runs far better with GLIDE than with Direct3D. The actual problem is, that meanwhile the company 3DFX has been taken over by NVIDIA and so there's no manufacturer any more who produces graphic cards that support GLIDE naturally.
At this point a GLIDE-wrapper gives support:
It makes the GLIDE-interface available, by receiving the GLIDE-commands and translating them to another interface. So it is possible to use GLIDE-enhanced programs even on graphic-cards, which normally do not support this interface.
Setup Guide:
Download GLIDE-wrapper (People have asked on the Battle.net forums, and Blizzard reps confirmed that this was perfectly okay to use)
Copy glide3x.dll & glide-init.exe to your Diablo II directory
Launch glide-init.exe
Set preferred language setting (German is set by default)
Click OpenGL-infos from the left, then Query OpenGL-infos from the right (This will run a small test that identifies your video card and attempts to determine its performance capabilities and what extensions it supports). Make note of the texture memory.
Move on to the settings tab. Some of this is personal preference, but I recommend making sure Vsync is enabled, as this will cap the fps at the refresh rate of your monitor. There's no need to render more frames than your monitor can display. It's not necessary to set an fps limit unless you're not using Vsync for some reason.
Next is renderer.  This is where things get a little more complex and will probably depend on what your GPU is capable of. According to the author's website you want to set that based on your video memory for optimal performance.
On graphic-cards that support 8-bit-textures (f.e. all Geforces and Radeon since 8500):
texture memory = real video-memory / 4 * 3
on any other graphic card:
texture memory = real video-memory / 8 * 3
As for the other settings, buffer texture size will also depend on your GPU but it doesn't hurt to leave that at the default setting.  If you don't like what the wrapper does to gamma settings, feel free to either uncheck shader gamma or check no gamma.
In order to have D2 actually use the Glide wrapper, you'll have to run the video test. If you don't remember what that is, it's also in your D2 folder as D2VidTst.exe, and it's what allows you to change video modes.  Open it, run the test, and select Glide when it finishes.  Once you've selected it in the video test, D2 will always launch with it.
Note: If you don't want to use it anymore, open the settings, click std/export, click the button to remove the registry entries, and delete the Glide files. Then run the video test again and select a different video mode.
Comment: You make it sound so complicated though, all I had to do was put the .dll in the installation folder, run the vidtest and select the 3DFX glidewrapper and voila.
All performance issues were gone.
(Note had to select compatibility mode windows xp service pack 2 or 3 + Reduced color mode 16 bit and Run as administrator on both the D2.exe and the vidtest for them to work though.)
Answer: It's a question of the software libraries involved. Direct3D is the graphics card interface library included with DirectX. As you may be aware, DirectX will soon have its 12th version which is supposed to have massive performance improvements.
These optimizations have happened incrementally, so a game like Diablo 2 which utilizes an older version of Direct3D will have poorer performance simply because the library both doesn't work well with modern graphics cards and isn't programmed as well as it is now. Graphics rendering isn't just about having powerful hardware; there have been quite a few bottlenecks that have been cleared up over the years by better drivers.
There is also the question of how well the game itself is programmed to work with libraries like Direct3D or OpenGL, as nonterrorist mentioned.


What is the Youtube OAuth 2.0 user token validity period?

Question: I read the documentation in the Youtube developers website it does not talk about any validity.
Does the OAuth 2.0 standards define any validity period or is the authorization token valid till the user revokes it manually ?
The OAuth spec defines that the token should expire shortly after its granted, so will it expire after I get the
access and refresh tokens ?
And can I use this access token for all future API requests or do I need to get a new token periodically ?
Answer: I'm assuming you are talking about the authorization code, you're mixing the terms a bit here.
From the OAuth 2.0 draft:

The authorization code MUST expire shortly after it is issued to mitigate the risk of leaks. A maximum authorization code lifetime of 10 minutes is RECOMMENDED. The client MUST NOT use the authorization code more than once. If an authorization code is used more than once, the authorization server MUST deny the request and SHOULD revoke (when possible) all tokens previously issued based on that authorization code.

After using it once for getting the access token, you can not use it again. You also don't need to retrieve an authorization code periodically. You do this only when you have no access token for a user, but want to request his data.
Your access token some time expires. You know when by either looking at the expires_in value that got send with it, or by doing a request to the API and getting an access token expired error back. Then you can use the refresh token to get a new access token without the user being involved.
Answer: Very useful step-by-step guide about how to get access and fresh tokens and save them for future use using YouTube OAuth API v3.
PHP server-side YouTube V3 OAuth API video upload guide.
The good thing is, you do not need to worry about the expiry of the tokens, as the script in this guide checks, saves, and updates the token in a txt file for future access.
{"access_token":"XXXXXXXXX","token_type":"Bearer", "expires_in":3600, "refresh_token":"XXXXXXX", "created":000000}

We use at http://presentationtube.com and it works fine with thousands of users.


Google Sheets checkbox validation "If this then that"

Question: My sheet has two checkboxes who we will call "A" and "B". I need it so A must be checked in order for B to be checked. I cant find out how to do this using data validation but it seems there must be a way.
Comment: If you don't use Excel, don't tag with Excel.
Answer: In Google Sheets the checkbox itself is a data validation which means as soon as you change the data validation it will remove the checkbox. There is no way around this if you want to retain the ability to check and uncheck it manually.
If you want to have the ability to check and uncheck and prohibit checking column B unless column A is checked you will have to use Google App Scripts in conjunction with the onEdit(e) function.
You have not given a sample or enough context to your question but one work around is to create a third checkbox in column C with a formula <code>=A1*B1=1</code> then only when both A1 and B1 are checked will the third checkbox 'check'. Of course as previously mentioned this solution will not allow you to check or uncheck the column C manually.


How to create predictive model in R when outcome variable has more than 10 classes?

Question: I have a dataset for vehicles and trying to predict what will fail. Here is my data set
vId, MileageSincePartLastReplaced,  AgeOfPart, TypeOfVehicle, Failure

x,100000,200days,Truck,Alt Belt

y,200000,600days,PCar,Transmission Belt

z,140000,230days,Van,Fan Belt

Failure is outcome variable with 20 different types of failure categories. What I am looking for is given mileage driven and age of the part which one is likely to fail?
I am unable to figure out which model/models I should be looking for? I was looking into multinomial regression & ordered logistic regression  but was not sure. Any help around how to go about this and which package I could use?
Note: I asked same question in Stack Overflow and was suggested to move to this forum.
Comment: your failure classes, are they mutually exclusive?
Answer: I don't entirely understand the description of your dataset, but if there are 20 classes of interest, one typical solution would be to bundle some of them together. (classes 1-10 become class 1, classes 11-20 become class 2, etc).
Find a split which is easiest, and then split those groups with another classifier, and recurse. You need to keep track of the original labels as you go for this but assign temporary labels for splits. You may find this works better, you may not.
If you are using only two predictor variables (mileage and age of part), you are going to find that predicting 20 classes is hard no matter what you do.
Answer: Try Random Forest method. Its very useful tool in case of multinomial outcome.
library(randomForest)
?randomForest #check help and give necessary parameters.
randomForest(x, y=NULL,ntree=500)  # Y is response here


Blender Arrow when rendering

Question: When I try to render some scene for some reason I can see arrows around object, how can make them not to show at render?
Comment: blender does not just randomly add arrows to your scene. There must be arrow objects in there somewhere. Find them and either delete, or hide for rendering.
Answer: Are your arrows objects? If so, uncheck their camera icon in the Outliner.
If you want to render to OpenGL make sure to mark "Only Render" under /Display in the 3D-view Properties window, too.

Blender Arrow when rendering


Impact on exploratory factor analysis of limiting number of data imputations

Question: I intend to use multiple imputation to deal with missing continuous data before conducting exploratory factor analysis (EFA) on survey data, and to obtain factor scores for each individual case. I would ideally like to be able to subject the factor scores to further analyses (regression and possibly latent profile analysis).
Background:

I am a researcher in psychology, and am new to both EFA and data
imputation.
Data: 221 participants answered 60 questions, all of
which asked them to indicate the extent of their agreement with a
statement on a scale of 0-100.
During EFA I encounter some very low communalities (below .2). My understanding is that I therefore need to run the analysis multiple times, removing the variable with the lowest communality each time before re-running. On dry runs with singly imputed data, this means I end up with about 25 variables in the final factor solution.
95% of the original 60 variables have missing data, which results from selection of a 'don't know' option.  The proportion of missing data ranges from 0-10.9% on each variable, with a mean of 3.4%. The missing data are MAR or MCAR, multivariate and non-monotone.
Most of the variables have data that are skewed, some highly, and some with a high mass near 0 or 100. I want to impute data and conduct EFA in a way that is appropriate for the distribution of the data and results in a minimum of distortion to standard errors.
I am planning to use the programme FACTOR. It uses hot-deck imputation, which seems to be appropriate for non-normal data, then performs multiple EFAs and averages their factor solutions after Procrustes rotation. Factor scores are simply averaged as well (Lorenzo-Seva & Van Ginkel, 2016; Ferrando & Lorenzo-Seva, 2017). For the EFA I will use Unweighted Least Squares/Principal Axis Factoring to deal with the non-normal distribution, and direct oblimin rotation to obtain an oblique solution.

However, FACTOR limits users to 5 imputations. 95% of my variables have missing data. Bodner (2008) recommends having as many imputations as the percentage of cases with missing data, and Graham (2007) recommends about 100 imputations when 90% or more variables have missing information.
How serious a problem is this limited number of data imputations:

for the factor solution
for subsequent parametric analysis using the resulting factor scores?

I have tried an alternative technique that I hoped would avoid this problem: R package mifa  calls package mice to impute data – with no limit on the number of imputations -  using predictive mean matching (PMM), and combines the resulting covariance or correlation matrices. An averaged covariance or correlation matrix can be passed to package psych for EFA. However, I can only get factor weights this way, not individual factor scores. I assume this is because package psych is using the correlation matrix rather than case-level data. The author of package mifa has been extremely helpful, but mifa cannot currently get to a single set of factor scores for individuals using Rubin's rules.
Answer: I have now found Van Buuren's Flexible Imputation of Missing Data (2018). Section 2.8 explains that in cases such as mine, where there is a large number of variables, it may not after all make sense to use the percentage of complete cases to guide the number of imputations. Instead, we can consider using the average missing data rate as a less conservative estimate. For me this is 3.4%, meaning that 5 imputations are, at least on this reasoning, adequate.


How to convert fields into rows through SQL in MS Access 2007 or MS SQL Server 2005

Question: I have a legacy MS Access 2007 table that contains 52 fields (1 field for each week of the year) representing historical sales data (plus one field for the year actually). I would like to convert this database into a more conventional Time/Value listing.
Does anyone knows how to do that without writing queries with 52+ explicit parameters?
(if a solution exists under MS SQL Server 2005, I can also export/import the table)
Answer: Using PIVOT and UNPIVOT.

UNPIVOT performs almost the reverse
  operation of PIVOT, by rotating
  columns into rows. Suppose the table
  produced in the previous example is
  stored in the database as pvt, and you
  want to rotate the column identifiers
  Emp1, Emp2, Emp3, Emp4, and Emp5 into
  row values that correspond to a
  particular vendor. This means that you
  must identify two additional columns.
  The column that will contain the
  column values that you are rotating
  (Emp1, Emp2,...) will be called
  Employee, and the column that will
  hold the values that currently reside
  under the columns being rotated will
  be called Orders. These columns
  correspond to the pivot_column and
  value_column, respectively, in the
  Transact-SQL definition. Here is the
  query.

--Create the table and insert values as portrayed in the previous example.
CREATE TABLE pvt (VendorID int, Emp1 int, Emp2 int,
Emp3 int, Emp4 int, Emp5 int)
GO
INSERT INTO pvt VALUES (1,4,3,5,4,4)
INSERT INTO pvt VALUES (2,4,1,5,5,5)
INSERT INTO pvt VALUES (3,4,3,5,4,4)
INSERT INTO pvt VALUES (4,4,2,5,5,4)
INSERT INTO pvt VALUES (5,5,1,5,5,5)
GO
--Unpivot the table.
SELECT VendorID, Employee, Orders
FROM
   (SELECT VendorID, Emp1, Emp2, Emp3, Emp4, Emp5
   FROM pvt) p
UNPIVOT
   (Orders FOR Employee IN
      (Emp1, Emp2, Emp3, Emp4, Emp5)
)AS unpvt
GO

Here is a partial result set.

VendorID   Employee   Orders
1      Emp1         4
1      Emp2         3
1      Emp3         5
1      Emp4         4
1      Emp5         4
2      Emp1         4
2      Emp2         1
2      Emp3         5
2      Emp4         5
2      Emp5         5
...

Comment: Thanks for this answer.  Learning how to use PIVOT saved me a ton of time today!!
Answer: As mentioned above, UNPIVOT operator, if available, will do this... If this is not available, then std SQL approach is:
Union multiple select statments (One for each week) that alias the specific week's column with the same column name alias
  Select 1 as week, Week1Val as value from Table
    UNION
  Select 2 as week, Week2Val as value from Table
    UNION
  Select 3 as week, Week3Val as value from Table
    UNION
 ...
    UNION
  Select 52 as week, Week52Val as value from Table

Answer: No need to export to SQL Server. In Access, try the /View/PivotTable View submenu. (It's in my Access 2003, at any rate.) I like it better than the one in Excel.


How to automatically add 2-way interaction terms in SAS proc hplogistic

Question: I am trying to run a model using SAS proc hplogistic.
The syntax I used is (this is just an example, the actual data set has 100 independent variable, so it's difficult to type all interaction terms and quadratic terms manually):
proc hplogistic data = inputdata;
model flag(event = '1') = age gender @2/association;
selection method = stepwise;
run;
where inputdata has 100K rows and 3 columns: flag, age and gender. flag only take value 0 or 1; age has 3 levels: young, middle, old; gender has 2 levels: male and female. I want to automatically add 2-way interaction terms and quadratic terms: age^2, gender^2 and age*gender. @2 is designed for that. However, when I run the code, I got warning message:
NOTE: '@n' notation is only valid with bar effects.
And no interaction terms or quadratic terms returned. Anyone knows why?
Answer: <code>proc hplogistic data = inputdata;
model flag(event = '1') = age | gender @2 /association;
selection method = stepwise;
run;
</code>
Refer to this link for more details.


Why много раз if много requires genitive plural in the case of countables?

Question: I'm not sure if I understand completely the usage of the genitive case here, or if this is simply a one-time thing based on this individual expression. If, for instance, Много + кошка = Много кошек and Много + сок = Много сокa, how come the expression 'many times' constructed with Много + раз ≠ много разов, but instead (seemingly) stays in the nominative case? (много раз)
Answer: In Russian, some second declension nouns have zero ending in the plural genitive.
These are almost all neuter nouns: лицо/лиц, село/сёл, as well as some masculine nouns: чулок/чулок, солдат/солдат, армянин/армян etc.
Раз is one such word. The plural genitive form of раз is раз.
In Old Russian, all the nouns with the historical stem in -o (this is the majority of masculine and neuter nouns in Russian) had the ending -ъ in the plural genitive, the precursor to the modern zero ending. They had the same ending also in the nominative singular: вълкъ/вълкъ, градъ/градъ etc.
A handful of nouns with the historical stem in -u (like сын, лёд, верх and some others) had the ending -ове in plural nominative and -овъ in the genitive plural. It used to be сынъ (sg. nom) / сынове (pl. nom.) / сыновъ (pl. gen.), домъ / домове / домовъ etc.
Then a kind of exchange took place.
Most (although not all) masculine nouns with the historical stem in -o accepted the -ов paradigm in the genitive plural: волк/волки/волков, город/города/городов, and some even in the nominative plural: кум/кумовья/кумовьёв, хозяин/хозяева/хозяев.
At the same time, most nouns with the historical stem in -u have lost the ending -ов in the nominative plural: дом/дома, верх/верхи etc.
Nouns that have retained the zero ending in the genitive plural are mostly military ranks and specialties (солдат, гусар, драгун, партизан); units of measure (ватт, ампер, вольт, грамм); nationalities and ethnicities (татарин/татар, армянин/армян, грузин/грузин); articles of clothing, especially those that come in pairs (сапог, чулок, валенок); and some other disparate nouns.
This continues to be an ongoing process to this date. As recently as 200 years ago, зуб, пуд, рог had the zero ending in the genitive plural, and the jury's still out on some fruit and vegetable names: помидор(ов), банан(ов), апельсин(ов) etc.
Answer: All your examples follow the same rule: много is used with the genitive.
But the correct form of genitive of разы is раз, not разов.
Have a look at the declension: https://ru.wiktionary.org/wiki/%D1%80%D0%B0%D0%B7.
Comment: Nominative singular — раз,
Nominative plural — разы,
Genetive plural — раз,

Some other examples:
Gen. pl of стол — столов,
Gen. pl of глаз — глаз,
Gen. pl of лаваш — лавашей,
Gen. pl of край — краёв.

There is no single rule of forming declensions, it does not depend only on the gender, there are a lot of nuances like the ending type of sound, the stress, etc. Though, most likely your textbook suggests you the simplest rule and therefore yes, in that case it's an irregular case, but be prepared that the 'regular' ones comprise not the biggest part of all words.
Comment: Thanks for the quick response. However, I still feel as though I'm missing something, do forgive me if I am overlooking a simple rule. But it seems to me that the nominative singular form is раз if разы is plural (Though I have yet to see разы used in the language). Then, what rule does this declension follow? Under the regular rules, masculine nouns ending in a consonant would take ending -ов,. Is this just an irregular case or am I missing something?
Answer: For some masculine nouns, the genitive plural is the same as the nominative singular. Notable examples include: раз, глаз, челове́к, солда́т, боти́нок, чуло́к, во́ло́с...
Thus you say пять раз, мно́го раз, па́ра глаз, сто челове́к, ро́та солда́т, копна́ воло́с...
This last one (во́ло́с) is a bit tricky:

Nom. sing. is во́лос (a single hair)
Gen. plur. is воло́с (as in копна́ воло́с 'a haystack of hair' - think Boris Johnson)

Here is a more comprehensive list of such words (ignore the words ending in vowels).
Answer: This is not Genitive, this is numerative case.
Compare

Гиря весит десять грамм.
На этой шкале нет граммов.

In the first sentence we have Numerative case, in the second one we have Genitive.
Comment: I've never heard of numerative case in Russian before. I understand there are six grammatical cases, being Nominative, Accusative, Genitive, Instrumental, Prepositional (and locative), and Dative. Could you elaborate on the usage of numerative or if it's a bit of a historical, now 'sub case' of a different case? Thanks
Comment: @Evan it can be considered a sub-case of Genitive different from Genitive morphologically. It is used with units of measure, some vegetables (помидор, баклажан) and some types of soldiers (кирасир, гренадёр, etc)
Comment: @Evan Out of context of measure they have -ов ending in Genitive.
Comment: @Evan Килограмм помидор versus я не ем помидоров. Отряд кирасир versus не видать кирасиров.


Wave equation in inhomogenous medium - Missing term?

Question: When it comes to the electromagnetic wave equation in linear inhomogenous media, I find many sources who will just use the usual formula:
$$
(\Delta - \frac{\epsilon \mu }{c^2} \frac{d^2}{dt^2})\vec{E} = 0
$$
and render $\epsilon$ and $\mu$ being position dependend:
$$
(\Delta - \frac{\epsilon (\vec{x}) \mu (\vec{x}) }{c^2} \frac{d^2}{dt^2})\vec{E}(\vec{x}) = 0
$$
Why are we allowed to do that? When I derive the wave equation from Maxwell's equations, I require $\nabla \cdot \vec{E} = 0$, but in inhomogenous Media the equation is $$\nabla\cdot (\epsilon(\vec{x}) \vec{E}(\vec{x}))=0
$$
which leads to
$$
\nabla \vec{E} = \nabla( \log{\epsilon} )
$$
This would be an additional term in the wave equation, and it's similar with $\mu$. Can somebody tell me why this additional terms are neglected, what approximation is made and when this is valid?
Comment: I have a difficulty to think of this at the edge of 2 media, where $n$ is not continuous, and $\nabla n$ would be some kind of $\delta$ function.
Comment: Yes, you are correct. There is a term $-\nabla (E \cdot \nabla \ln \epsilon)$ on the RHS.
Comment: I have also faced this annoying problem. I think people implicitly assume $\epsilon$ is slowly varying or something and say $\nabla \epsilon \sim 0$. Check out these notes: http://opt.zju.edu.cn/zjuopt2/upload/resources/chapter5%20Electromagnetic%20Optics.pdf.   -- They were very helpful for me, hopefully they will be for you too. Equation (5.2--14) in particular is what you are looking for.
Comment: indeed, ∇n would be infinite at an infinitesimal thin interface across two media. I guess one could remedy the situation applying some tapering to obtain a more gradual boundary.
Answer: You are correct that there is a term on the RHS of $-\nabla(\vec{E}\cdot \nabla \ln \epsilon)$.
In order to neglect this you compare it's magnitude with $\nabla^2 \vec{E} = -k^2 \vec{E}$.
So, just looking at magnitudes, we can say that the RHS of your wave equation is $\sim 0$ if
$$ |\nabla(\vec{E}\cdot \nabla \ln \epsilon)| \simeq kE \nabla \ln \epsilon \ll k^2 E$$
$$ \nabla \ln \epsilon \ll k $$
$$ \nabla \epsilon \ll k\epsilon =2\pi \frac{\epsilon}{\lambda}$$
So as long as a typical length scale for a change in $\epsilon$ is much longer than the wavelength of light, then this approximation is good.
You certainly could not use this approximation (re your comment) where there are abrupt changes in refractive index, where you would have to employ the usual continuity conditions for the electromagnetic fields.
Comment: @Quantumwhisp The derivation of the standard laws of geometric optics does not even involve the wave equation in a direct way. You posit a travelling wave either side of a discontinuity and apply the boundary conditions for electromagnetic fields. On either side of the boundary the wave equation is homogeneous (if these are LIH media) with solutions that are standard travelling waves. This does result in discontinuities in the wave properties (e.g. in the wavevector and field amplitudes).  Anyway, that goes beyond what you were asking in your question (which I have answered).
Comment: What still buffles me is that you use the same approximation in deriving the Eikonal Equation for geometric optics, and geometric optics work out just fine, even it it comes to abrupt changes in the refractive index (Snell's law for refraction at a surface would be a good example for this). Maybe I should post this whole thing in another question.
Comment: @QuantumWisp I can derive the laws of geometric optics by treating the boundary condition as  sharp, with an abrupt change in $\epsilon$ at the boundary and a uniform (but different)  $\epsilon$ either side. The problem you have posed would not necessarily enter into it.
Comment: I don't see why the problem I have posed doesn't enter it: I derive the laws of optics, neglecting the said terms, I use them in a situation were the terms mustn't be neglected, and still everything works out. That's a contradiction to me.


Updating a contact record in Journey Builder

Question: Is it possible to update a contact record in an interaction during a journey. Also, can we import data into a data extension in journey builder scenarios.
Comment: My experience is that a contact record can be updated when contact is active in interaction.
Comment: Gajendra, what exactly do you mean by "update a contact record"? Are you referring to (a) the actual Contact Record in Contact Builder (b) update an Attribute in an Attribute Group that is related to the Contact Record, or (c) update a value in the Event Source data? Regarding your import question, there is no Import Activity in Journey Builder, however if you can explain what you need to achieve, perhaps I can make a suggestion.
Comment: Thanks @mattcameron . In that case data can be imported in data extension as well. Pls correct me if I'm wrong.
Comment: Thanks Eliot. I meant updating an actual contact record during an interaction  in contact builder. Also can we import data in a data extension during the journey.
Comment: @EliotHarper: I think we can import data in data extension during a journey. Pls check the [section](http://help.salesforce.com/HTViewSolution?id=000220316) below "Contacts fell below the High Water Mark" title.
Answer: Once a Contact is injected into an Interaction, if you update that record in the Event Source Data Extension, the updated values will not be applied to the Contact while they are moving through the Interaction.
Data from the Event Source DE is passed to the Interaction at the time that the Contact enters it and continues to be passed as arguments to subsequent Activities as the Contact moves through branches in the Interaction.
If you are trying to personalise email or SMS content with updated values, then you can use the AMPscript Lookup() function to retrieve rows from the Event Source DE (rather than use personalisation strings).
Regarding your question of importing data into a Data Extension, the Event can be fired at anytime while the Interaction is running. If using the Fire Event Activity in Automation Studio or the Event Schedule, then any new Contacts that have been added to the Event Source DE since it was last run will be injected into the Interaction (providing they meet the Contact Filter Criteria defined in the Event).


Relationship between autocorrelation function and mean of random process

Question: For instance, if we assume a white noise process $w(t)$, it would have an autocorrelation function $R=\delta(t)$. Obviously, the white noise process would have zero mean, but how can the autocorrelation function be use to prove that?
Comment: Why could we argue that?
Comment: Adding a nonzero constant to $w$ would not change its autocorrelation function but would give it a nonzero mean (yet it remains stationary).  That provides a counterexample to what you would like to prove.
Answer: White noise is generally defined to be a zero-mean process whose autocorrelation function is $K\delta(t)$ where $K > 0$
and $\delta(t)$ denotes the
Dirac delta, and so there is nothing left to prove. Alternatively,
a white noise process is a weakly stationary process whose power
spectral density $S(f)$ has constant positive value $K$ for all $f$.
For any weakly stationary (also called wide-sense stationary)
random process whose autocorrelation function $R(t)$ is an ordinary
non-periodic real-valued even function with a peak at $t=0$ (e.g. $e^{-|t|}$) such that the limiting value of $R(t)$ as $t \to \infty$ exists, the limiting value is the square of the mean $\mu$ and the power spectral
density $S(f)$ includes a Dirac delta at $f=0$. Such a power spectral
density does not match the power spectral density of white noise at all.
So, why can't this notion of $\mu^2 = \lim_{t \to \infty} R(t)$
be applied to the autocorrelation function $K\delta(t)$ of white
noise to deduce that white noise must have zero mean? Well,
$\delta(t)$ is not a function at all; it only walks like a duck
and quacks like a duck inside various integrals, not everywhere
like all actual ducks do. In particular, $\delta(5)$, say, does
not mean the value of the Dirac delta at $t=5$, and so the notion
$\lim_{t \to \infty} \delta(t)$ has no meaning.


Why does the WTP plugin deploy one Maven dependency as a folder, instead of a jar?

Question: I have a very strange problem with Maven and the Eclipse WTP. I have a multi-module project, let's call it project. It consists of two modules project-base and project-web. I have the workspace resolution enabled (and it works fine with several other very similar Maven projects).
project-base is a dependency of project-web and it's normally deployed as a jar file. But for several days, it keeps being deployed as a class folder in my local Tomcat, as you can see here:

Therefore, my Tomcat does not recognize any of my class files in there, because it expects them to be jars, not folder.
The -tests suffix comes from the need to have the test from base in my web project. I don't think this is the problem.
project-web has three dependencies being resolved from the workspace. Two of them are deployed correctly, as jar, but the third one is not.
project-base's pom.xml is shown here:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>project</artifactId>
        <groupId>com.company.project</groupId>
        <version>4.0.0</version>
    </parent>
    <artifactId>project-base</artifactId>
    <name>projectBase</name>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>windows-1251</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar</goal>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.4</version>
            </plugin>
        </plugins>
    </build>
</project>

The dependency project-base as it is defined in project-web looks like this:
<dependency>
    <groupId>com.company.project</groupId>
    <artifactId>project-base</artifactId>
    <version>${project.version}</version>
</dependency>

<dependency>
    <groupId>com.company.project</groupId>
    <artifactId>project-base</artifactId>
    <version>${project.version}</version>
    <type>test-jar</type>
    <scope>test</scope>
</dependency>

I don't have an idea why one dependency is deployed in such a strange way and I don't know how to fix this. I cleaned the projects, the tomcat, redeployed the web project, purged my whole Maven repository, checked out the whole project fresh from VCS, nothing helped.
What could cause Eclipse WTP to deploy this dependency as a folder instead of a jar file?
Comment: Although it doesn't explain **why**, [this question](http://stackoverflow.com/questions/8944278/m2eclipse-and-or-wtp-not-packaging-a-dependency-correctly) provides a work around that helped us
Comment: @chrisbunney Thank you for the information! I tried the trick, but it didn't work out for me. I removed all Eclipse specific files and let maven regenerate them, but the situation was unchanged.
Answer: I solved the problem by deleting the dependency in the "Deployment assembly" project settings page and adding it back.
Comment: Thanks for the hint. This didn'd work out for me, because I couldn't even open this exact settings page. See my answer for details.
Comment: This worked for me.... what an annoying bug. My previous work around was manually copying/pasting the jar into the deployment lib folder :/
Answer: I was just having the same problem. Upgrading m2e to version 1.2 fixed it.
Answer: If that folder is an exploded JAR (so it is like a JAR file, but appearing as a folder, not archived), in my case it was a server connector issue.
Although I use JBoss instead of Tomcat, this might be helpful for others struggling with this problem.
Provided you have the latest JBoss Tools installed on your Eclipse, you can double-click the server in Server view to open the settings.
On Deployment tab, you can select Zip Module Yes/No for each project. When I selected YES for my utility jar files, JBoss then deployed the dependency as a normal JAR file instead of a folder.
Answer: I ultimately solved my problem: I had problems with the properties section Deployment Assembly for the project-base project. I could not save it, as Eclipse mentioned, the current page does contain errors.
I then looked into the settings file .settings/org.eclipse.wst.common.component. It was completely empty (I don't know why). I then added the following block:
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="project-base">
        <wb-resource deploy-path="/" source-path="/src/main/java"/>
        <wb-resource deploy-path="/" source-path="/src/main/resources"/>
    </wb-module>
</project-modules>

After this, the settings page is accessible again and the JAR is assembled correctly. Workspace resolution does work, too.


Hoeffding's inequality with $a$ and $b$ depending on $n$

Question: In Hoeffding's inequality
$$
P(S_n-E[S_n]\geq t)\leq \exp(\frac{t^2}{\sum_{i=1}^n(a_i-b_i)^2}),
$$
where $S_n=X_1+X_2+\dots+X_n$, with $X_i$ independent random variables satisfying $a_i<X_i<b_i$, is it allowed to let $a_i$ and $b_i$ depend on $n$?
Answer: Yes, it is allowed. Note that the inequality is a statement for fixed $n$, hence there is no problem with $a_i$ and $b_i$ depending on $n$.
Answer: This is like asking if the $a_i$'s in the set $\{a_1, a_2, ..., a_n\}$ are allowed to depend on $n$. They can. Consider $a_i = i/n$ like in Riemann sums. Then
$$\{a_1, a_2, ..., a_n\} = \{1/n, 2/n, ..., n/n\}$$
We can have $a_i = (i-1)/n$
Then
$$\{a_1, a_2, ..., a_n\} = \{0/n, 1/n, ..., (n-1)/n\}$$


Change projection for LAS file

Question: I have read a LAS file. If I import it in Global Mapper it says the projection, however when I read it with laspy (header.proj_id_1) there is no information associated.
I have edited the coordinates and updated the X,Y,Z values to new values (according to this) for the LAS file and now I would like to give a new projection after updating the coordinates.
What function do I use?
Comment: The link scales and offsets, it does not change the projection, it sounds like you're swimming in dangerous waters adjusting the coordinates if you're not 100% sure. If you want to project a las file LASTools is a viable and reasonably cheap option using LAS2LAS which will embed the new CRS in the header.
Comment: It seems there are multiple ways to store the CRS [according to the spec](https://www.asprs.org/a/society/committees/standards/LAS_1_4_r13.pdf), so we could use some more information-- what LAS version and point format are you using?  Posting a the output from [lasinfo](http://lastools.org/download/lasinfo_README.txt) for the input and output file might be helpful as well
Comment: Which laspy version are you using?
Comment: I'm not sure how to do it offhand but it is possible-- LAS 1.2 uses the GeoTIFF standard as shown on page 11 here:  https://www.asprs.org/wp-content/uploads/2010/12/asprs_las_format_v12.pdf  But `proj_id_1` relates to the "project id", not projection.  The VLRs will be the relevant parts of the lasinfo report, I don't see those in your image.  It might be a little bit of work to update the georeferencing info, though, since I don't think laspy provides any mechanisms to help with that.  Sorry I don't have an easy answer
Comment: @MichaelStimson I am 100% sure. I use files from the national cadastre agency, that give parameters for the correct coordinates conversion from ETRS89 to Stereo70. The input LAS had UTM zone 35 coordinates, I changed those into ETRS89, then into Stereo70. I have to use the files given by the cadastre agency to make sure the conversion is correct. Other tools, even well known software, do not use the same parameters. The parameters could also change, so I read the parameters every time. I have given the input las the new coordinates, however I need to change the name of the projection.
Comment: @mikewatt  version major.minor:        1.2
point data format:          3
I will add the image with other details in the question.
Comment: @Mapperz laspy 1.7
Comment: @mikewatt Do you know if it is possible for my data las version and point format? I have added an image in the question with lasinfo. Is any more info required?
Comment: @mikewatt Thank you.
Answer: I found a minute to dig into this.  We don't quite know what your specific file contains, but here's a quick and dirty way to update the GeoKeyDirectoryTag VLR (page 11) using values as described in the geotiff spec.
This does not currently account for the storage of individual projection parameters in a separate GeoDoubleParamsTag or GeoAsciiParamsTag record.  I don't have any example data on hand that contains those params, so if you need help extending this I might need you to post something for me.
This updates the file in place, so be warned.
import laspy

src_path = r"C:\example\test.las"

# see here for possible values:
# http://geotiff.maptools.org/spec/geotiff2.7.html
replace_keys = {
    3072: 26912,  # set ProjectedCSTypeGeoKey to NAD83 / UTM 12N
    3076: 9001,   # set ProjLinearUnitsGeoKey to meters
    4099: 9001    # set VerticalUnitsGeoKey to meters
}

def update_geo_keys(path, lookup):
    with laspy.file.File(path, mode='rw') as f:
        for i, vlr in enumerate(f.header.vlrs):
            # search for the GeoKeyDirectoryTag record
            if vlr.record_id != 34735:
                continue

            modified_body = []
            j = 0

            # loop over geo key entries, stored in groups of 4 values
            while j < len(vlr.parsed_body):
                key_id, tag_loc, count, value = vlr.parsed_body[j:j+4]

                if j > 0 and tag_loc != 0:
                    raise NotImplementedError('modification of projection '
                                              'parameters not implemented')

                # update the value for this key ID, if necessary
                try:
                    value = lookup[key_id]
                except KeyError:
                    pass

                # maintain a new list of values to be written
                modified_body.extend((key_id, tag_loc, count, value))
                j += 4

            # update the vlr with our new values, quit searching
            vlr.parsed_body = modified_body
            break
        else:
            raise ValueError('no GeoKeyDirectoryTag found in file')

        f.header.save_vlrs()

update_geo_keys(src_path, replace_keys)

Comment: Glad it's working!  The implication of commenting out that exception, however, is that there may be another tag/VLR that has the old projection information still intact which wouldn't match what you've set.  That may or may not matter to you.  Deleting all projection info would be easy as well, but probably not in-place as it would change the size of the file, requiring it to be rewritten.
Comment: Thank you, however I get an error: "NotImplementedError: modification of projection parameters not implemented". Is it somehow possible to delete the projection information, if replacing it is not possible?
Comment: I found that if I comment the NotImplementedError if statement, it works. Thank you
Comment: I turned your post into a function "def change_proj(src_path):" then the full text, without where you defined the src_path and I get an error, when running it as a function with the path to the las file as argument. error is "[Errno 22] Invalid argument: path/to/file"
Comment: File "path_to_py_file", line 68, in update_geo_keys
    f.header.save_vlrs()
  File "pythonfolderpath\lib\site-packages\laspy\header.py", line 1310, in save_vlrs
    self.writer.save_vlrs()
  File "pythonfolderpath\lib\site-packages\laspy\base.py", line 1045, in save_vlrs
    self.set_vlrs(self.vlrs)
  File "pythonfolderpath\lib\site-packages\laspy\base.py", line 1068, in set_vlrs
    self.data_provider.open("w+b")
  File "pythonfolderpath\lib\site-packages\laspy\base.py", line 144, in open
    self.fileref = open(self.filename, mode)
OSError: [Errno 22] Invalid argument: 'in_path'
Comment: From what I noticed it happens when there is a space or other unaccepted character in the file path. For example for C:/test/file.las it works, for C:/test/0.file.las or C:/test files/test.las it does not work.
Comment: Does the original code work when using that file path?  It was already a function :)
Comment: it works well. I have a new question regarding this: for the else statement instead of giving the error "no GeoKeyDirectoryTag found in file", can i write the new projection, instead of giving an error message? @mikewatt
Answer: It sounds like you know the projection, it's just not being read in or possibly stored in the las file correctly?  If you want to set the known CRS using laspy, you can like so:
from pyproj import CRS
import laspy

# add known crs
las = laspy.read("original_file.las")
crs_pyproj = CRS.from_string("epsg:4326")
las.header.add_crs(crs_pyproj)
las.write("las_with_crs_added.las")  # save file with crs added to header

# Once set, you can read it back with the built-in laspy method `.parse_crs()`.
laspy.read("las_with_crs_added.las")
epsg = las.header.parse_crs().to_epsg()
print(epsg)

Change projection for LAS file


Why laser is not used to melt/soften material in polyjet?

Question: Polyjet uses UV light to cure UV curable plastic material.
I was wondering as to why laser light can't be used to soften/melt just any plastic material instead of using UV light to cure only UV curable plastic materials?
Comment: the materials in question need a specific wavelength and only a specific power. That's all.
Answer: The question in the title references a specific printer technology, while the question in the body of the post is more generic and is the one being answered here.
There are 3D printers which use lasers to cure liquid resin in a manner similar to MSLA 3D printers. The vat of resin sits atop a transparent panel, under which a laser assembly resides. The computer directs the laser over the surface of the panel in a manner associated with each layer of the print. Once the layer is completed, the bed is lifted, peeling the print from the base of the vat and then lowered again.
There are some printers which apply the laser to the surface of the liquid but the results are the same. The resin is photosensitive and cures when the laser is applied.
Additionally, there are SLS 3D printers. Selective Laser Sintering uses a laser applied to the surface of a nylon powder (one example) which sinters the nylon causing it to bond to adjacent particles. When a layer is completed, the bed of powder is lowered and another layer of powder is applied. The laser again "draws" the layer in the powder and the process continues.
This method requires compensation for shrinking, as the nylon powder changes dimensions as it is melted. The bed is also pre-heated prior to printing in order to reduce the amount of energy required by the laser to sinter the design.


Laptop screen is blank unless in safe mode

Question: On my laptop I used the HDMI once to connect to my TV. It worked fine once I changed the display setting to TV, and showed my screen on the TV instead of showing it on my laptop screen. Then I pulled out the HDMI cable the laptop screen stayed blank. When I plugged the HDMI cable back in both TV and laptop stayed blank. I tried pressing the button on the keyboard that says HDMI/LCD but it did nothing. I tried it with the HDMI plugged in and not plugged in. I also tried windows+p. Every time I turn on my laptop now it shows on the screen that windows xp is loading then it's blank. If I start it in safe mode it works but I can't open the NVidia control panel in safe mode. I also tried plugging in a different monitor with different HDMI cable and both screens are always blank. What do I do?
Comment: Sounds like a driver problem. Have you tried installing the drivers for your video card while you're in safe mode, then rebooting?
Comment: ^ it does, I would want to clean it all first too. . another possible In safe in XP almost all devices will show,  show hidden, then uninstall all instances of monitor items, re-scan the hardware, or reboot.  It might be a resolution or a refresh rate that isn't handled. What does the TV itself Say ever after it no longer shows?
Answer: Using HDMI involves something called 'Digital Rights Management' (DRM) ... this is designed to prevent copying of data from a HDMI cable .. unplugging it may have 'tripped' some stupid DRM 'trap' ..
First make sure you have the display drivers to hand (ideally 'unpack' them to your hard drive in some easy to find folder)
Then, (in safe mode) un-install your Graphics driver ... reboot to 'normal' mode and you SHOULD get the 'default' MS Display Driver (which likley shows a low resolution 640x480 VGA screen) .. and from there re-install the real driver ..
Answer: I had a same problem when I used HDMI, I think it's because there's no active process running OR your graphics driver is screwed up. Here's a solution that might work.
Press Ctrl + Alt + Delete and select Task manager. Under Applications select New Task. Type in explorer and press Enter. You must see your background image, taskbar and icons.
Hope that helps otherwise re-install your graphics drivers.


What are the prerequisites for calculus?

Question: I've studied basic math a very long time ago and would like to start over. I remember studying derivatives, but never really understood what rates of change were. I would like to know calculus, differential equations, dynamical systems. What information should I begin studying? should I know in depth about ratios, proportions, rates of change? I'm not very confident on these, especially rates of change. Should I begin by refreshing over this material? can anyone please also recommend any introductory material regarding these that I could start from. Thank you.
Comment: While trig isn't required for calculus (I never took a class on it and ignored it until I got to complex analysis and could easily derive the results) many textbooks assume it as background and thus make examples rely on it. If you plan to self study, that might be a place to seriously brush up your skills
Comment: If you want to seriously  study dynamical systems and diff Eqs, I'd focus at least somewhat on learning how to prove things and read proofs. You may not need to do this if you have only applications in mind, but it can definitely help deepen understanding
Comment: I have self taught how to read and write proofs so I am comfortable with that. I've been  reading through some calculus books and get confused on  rates of change and what they are. I don't know why I get a mental block with this elementary topic and would like to change this asap. I have been reading up on modelling using differential equations and would like to know the meaning and understand  the concepts
Comment: Duplicates https://math.stackexchange.com/q/466926.
Answer: A strong foundation in algebra Is very important, as most if not all of calculus relies on the idea of a function, something that is covered very in-depth in algebra 1 and 2. For example, the pre-calculus course at my school covers: polynomials, sketching graphs, trigonometry, and exponential and logarithmic functions. Another topic that I would recommend covering but isn't necessary is limits, as they are the foundation to all of calculus, but most textbooks and courses spend the first few chapters discussing them.
One great textbook I found useful was this Calc 1 textbook. However, learning math from just a textbook can be difficult, especially Calculus, because it introduces so many new subjects, so you might find 3Blue1Brown's Essence of Calculus youtube videos helpful.