Transposing from 3 sharps to 4 flats

Question: I am trying to change a song that is in 3 sharps to 4 flats (as I am better in flats).  The original piece in 3 sharps has several extra flats, sharps, and naturals and, of course, I believe I need to change those particular notes.

So, if the original (3 sharps) has a note with a flat beside it, what do I do with the note when I play it in 4 flats?
And, if the original has a note with a sharp beside it, what do I do with the note when I play it in 4 flats.
Lastly, if the original music (3 sharps) has a natural sign beside a note, what do I do with the note when I play it in 4 flats?

I'm probably not explaining well, but I hope you can understand my questions.
Comment: A lot of music is printed with accidentals that are spelled incorrectly.   For example, an editor might think that Bb would be "easier" to read than Bb, despite the fact that A# is more likely to occur in 3 sharps than Bb.  This significantly complicates your task at transposing.  Posting an example of a few bars with flats will help us determine if you are working from a "correct" original.  If you are not, you will struggle when following the answers posted below.
Answer: Transposing from 3 sharps to 4 flats is equivalent to lowering each note by a half step. This means that:

double sharps --> sharps
sharps --> naturals
naturals --> flats
flats --> double flats
Comment: It can happen that this takes you so far around the circle of fifths that you have to translate back from flats to sharps. If you transcribe a piece in A major that has a section in D minor, you should almost certainly notate the transposed section in C♯ minor, not in D♭ minor.
Comment: @KilianFoth - The case of the isolated D minor chord in A major getting transposed to A flat major is debatable, though - I suspect quite a lot of publishers and Classical-/Romantic-era composers would actually use a **D flat minor** chord in that context (see the use of **B double flat major** chords in Schubert's Impromptu in F Minor, D. 935, No. 4 as the Neapolitan of A flat major).
Comment: @KilianFoth Your solution to your hypothetical issue creates a problem. D minor is the iv of A so it makes more sense to use a few extra flats because if you use C# minor in Ab you will have an +iii.
Answer: Key signature of 3 sharps puts it in key A (and/or F♯m) Reading the piece as if it has four flats puts it in key A♭ (and/or Fm). The same can happen with E (and/or C♯m) and E♭ (and/or Cm).Except the other way round. In fact, were there no accidentals in the piece, it'd be simple to read each (interchangeably) as if the key signature was whichever you wanted - no need to re-write!
What's happened is each note has dropped by a semitone. So, the 'standard' (key signature notes and naturals will all go down by that semitone, any sharpened notes as accidentals will be naturals, and any flats (unusual in a sharp piece, but not impossible) will be double flatted.

Transposing from 3 sharps to 4 flats


How do I improve my physical stamina for oboe playing?

Question: I find I can only really practice for 20 minutes max before my lips and jaws start to go numb and this makes me a bit worried for my stamina for my exam...any suggestions on how to build that up so I can practice for a bit longer?
I always begin my practice with long notes and then play scales and then my pieces. I've also tried playing the piece through doing everything but blowing to ensure better knowledge of keys etc. Any suggestions appreciated.
Answer: There are a couple things that spring to mind:
- Check that you're playing correctly.
If you're straining yourself unnecessarily, then you will become tired much more quickly and will therefore play for less time.  The comment that makes me bring this up is your description of how your lips / jaw get numb.  To me that indicates that you're clenching with your jaw, which isn't good.  As for the lips, I've found that with playing any instrument for a length of time, your lips just get tired and cannot hold the embouchure; perhaps sore feeling but not "numb".
I would check with either an oboist or an oboe / woodwind instructor and have them watch how you are playing.  Describe what you feel and see their response.
- Play more often.
This one is just one of those age-old axioms.  If you want the chops, you gotta play.  Simple as that.  Granted, if you can only play 20 minutes at a time, it is useless to try and force you to play longer - you'll only develop bad technique that way.  Instead, I would recommend doing what many players do: having at least two daily practice sessions.
The first "practice" session is really just a warmup where you focus on fundamentals: long tones, articulations, scales, range, etc.  You do that in the morning at a convenient time.  The second session is later in the day, in the afternoon sometime.  Now that you're already warmed up, after a couple scales you're ready to do hardcore technique / excerpt work.
The last "warm down" session is optional - some people / performers swear by it and will nay-say anyone who says differently.  I've known both types.  A trombonist friend of mine warms down for about 15min. after every gig / rehearsal regardless of how long he's been playing.  I myself have never needed a "warm down", so it's one of those things.
I don't know when your exam is, but remember that when it comes to instrument pedagogy, you can't cram.  You either have the technique or you don't, and with oboe certainly, there is no faking.
Just do your best preparation work possible, practice and play daily, and when it comes time, don't warm up too much before you play - it'll kill your chops and you'll sound bad.
Comment: I would add: make sure you're breathing correctly and learning breath control.  Almost invariably beginners try to control the sound with their mouth; later on they learn breath control and the jaw&lips are suddenly free of effort.
Comment: Swim a mile every day. This will improve your lung capacity and loosen up your whole body. You don't have to swim the same stroke, just get in a lap pool, use different strokes and mix it up, change every 5 to 10 laps: breaststroke with frog kick, Aussie Crawl, backstroke, then add a kick board. Also try the kick board between your legs and pull with your arms. Allow 45 minutes to 1 hour.
Comment: Good thought Carl - though I personally prefer to use the term "breath management."  You're right - it is very important (*especially* in the case of the oboe!)  I didn't mention it expressly because it is usually something touched upon when meeting with an oboist or instructor.
Comment: Thanks for that. yes, I get that I can't cram for this - especially as my intention is to be a musician and play this gorgeous instrument well. My exam is in November. I've learnt my pieces but I'm not playing them well enough yet.  Love the idea of playing two practice sessions and think I'll try that. Will check with my teacher about the breathing/embouchure but I have been focusing on using my diaphragm to control rather than my mouth. As for swimming - unfortunately I can't swim :-) but I walk pretty regularly. Thanks again for the advice. Very helpful.. :-)
Comment: Using your diaphragm is physically impossible.  It's a mis-statement by many musicians.  Your diaphragm moves involuntarily like your heart, stomach, and liver.  Look into "The Breathing Gym" by Pat Sheridan and Sam Pilafian. It contains many breathing exercises that will dramatically improve your efficiency and breath management.


How can I assign a block to a panel or mini-panel?

Question: I was reading the project description for Panels, and I noticed it was a way—using mini-panels—for me to rearrange the contents of my site.
So I just created a mini-panel with a two column layout. I want to add one block to the left and one block to the right. How can I do this?
Answer: Mini panels are blocks and you can add Mini Panels to Panels. You can't add blocks themselves to Panels, but usually most of the content that you can display in a block, you can actually display in Panels, content such as Activities, Menus, Mini panels themselves, Miscellaneous, Pages elements, Views, Widgets, Nodes, Custom content and more.
See Drupal - Blocks vs Context vs Panels.
Answer: You can add custom blocks to mini-panels. So create a custom block on the block admin page - admin/structure/block - and then add to your mini-panel or panel.
Comment: Can you not add normal blocks? Such as exposed filters?


Can't use both fig.pos and out.width/height in knitr?

Question: I am using the bookdown package to build my pdf. Here is my _output.yml:
## Here to create the pdf
bookdown::pdf_book:
  extra_dependencies: ["float"]
  toc: true
  template: _assets/template.tex
  mainmatter: true
  includes:
    in_header: _assets/preamble.tex
  latex_engine: lualatex
  keep_tex: yes
  citation_package: natbib

When I use only fig.pos = "!H" or out.height="75%", the knitting works.
However, I'd like to use both fig.pos = "!H" and  out.height="75%" (for instance {r fig, fig.cap="Caption", out.height="75%", fig.pos = "!H"}) but when I do so, I have:
! LaTeX Error: Unknown float option `H'.

I checked and the package float is correctly installed.
Answer: There is nothing that prevents fig.pos and out.height from being used a the same time. If I evaluate the code below:
---
title: "R Notebook"
output: latex_fragment
---

```{r fig, fig.cap="Caption", out.height="75%", fig.pos = "!H"}
library(ggplot2)
ggplot()+ theme_minimal()
```

I get the following latex output:
\begin{figure}[!H]
\includegraphics[height=0.75\textheight]{TestX_files/figure-latex/fig-1} \caption{Caption}\label{fig:fig}
\end{figure}

Which is what you'd expect with the options given (note the 0.75\textheight and the [!H])
The error comes from the package float not being available. To properly produce a pdf with fig.pos options, add the following:
---
output:
  pdf_document :
    extra_dependencies: ["float"]
---

as explained here
Comment: Thank you for your answer but no, it didn't work. I tried both to write `extra_dependencies: ["float"]` or to write `\usepackage{float}` directly in my .tex template but I still have the same message


PEAP validation against a different, secondary domain?

Question: Probably a little bit confusing, so let me explain the situation.
Our company wants to implement a corporate wireless LAN with PEAP authentication. Unfortunately, someone made a big mistake in our Active Directory design 10 years ago.
The domain name we are using, company.ch, is not owned by our company, but by someone else. This makes it impossible to issue a public SSL certificate for the RADIUS server, and our Active Directory domain is too big to rename.
We already thought about using  our private PKI and rolling out the CA-generated certificate via GPO but that would only cover our corporate-managed clients, and not any of the devices in our environment from our BYOD policy (Smartphones, Tablets, Laptops..)
Is there a way to add a secondary domain name like company2.ch, issue a public certificate against it and join RADIUS to that secondary domain as well, so we can configure that secondary domain via DHCP for all the client pools?
Or is there another way with, for example, a new RADIUS server on its own domain (company2.ch) which is connected with some kind of trust to the company.ch domain?
I'm not a client-server guy, but hopefully you get my drift.
Answer: First of all, let me say that you (well, your bosses, maybe) really need to get off of using a domain you don't own.  You say it's too big to do that now, but you're being short-sighted.  If it's "too big" to change now, what happens in the future, when it's even bigger?  You're just letting the problem grow and grow, until (if the company actually does succeed and continue to grow) you'll end up with a problem which really will be "too big" to handle, and you'll spend fantastic amounts of money and time and create a lot of user-impact to correct what you probably could correct now for much less effort.  At the very least, you should see if you can buy the domain your AD is using from its current owner, which would be the quickest way to correct this.
Anyway, having said, and assuming your bosses aren't willing to actually be reasonable, smart, or think further into the future than their next bonus check, there actually is a pretty east way around this, which you mentioned in your question.
What you would want to do is:

Create a second child domain in your Active Directory forest.

Pick a domain you own this time, or buy whatever domain you pick, for the love of God.

Create a trust between the new domain and the old one (within AD).
Create appropriate user groups, resources and permissions in new domain.

Setup a RADIUS/NPS server here that's got permissions to authenticate against the old domain, or perhaps just your RADIUS-capable devices, and allow them to authenticate against the old domain (or however you want to do it).

Manage permissions in old domain so that users of new domain have required access.

For example, make sure that any SSL cert you purchase for this domain will be accepted by the old domain, if that's the route you go.

(OPTIONAL, but HIGHLY RECOMMENDED) Use the new child domain to migrate away from the old one you don't actually own

Once the trusts are established and working, you can use them to migrate users off of the old domain you don't own, onto something you do, and make the problem go away eventually.

I am actually in the middle of a Windows Active Directory domain migration, and this is how we're handling it too.
We've created a second child domain, established trusts, and slowly started migrating users, services, machines (everything) over to the new domain, so the old, broken domain will eventually be empty and unused, at which point we'll dispose of it.
Comment: +1 for **migrating off the domain you don't own** - either through a renaming or through the child, trust, and transfer method described above. You'll save yourself a world of pain and suffering by doing this right...


Adjust customer complaints volumes for growth in subscriber base

Question: I have two sets of monthly data that spans over almost 2 years. The subscriber volume, and the customer complaint volume. I'm trying to determine the best way to adjust the changes in complaints volume for the growth in subscribers, so I can compare YoY growth in complaints, without the impact that more subscribers would have on the absolute volumes.
Previously I had just calculated complaints/subscriber. But I'm wondering if there's a more accurate way that would account for subscriber growth.
I've tried applying the same technique as you would to calculate Real GDP using the subscriber volume as the base, but I'm not sure the method applies the same way. I've spent a while looking online for different ways to approach but many don't really apply or are too complicated for me.
I'm just using excel, and my statistical knowledge is limited to a few classes (understand regression etc, but nothing too complicated).
Comment: What is it you ultimately want to say based on your data (ie, after you have appropriately adjusted for this)?
Answer:
Previously I had just calculated complaints/subscriber.

This seems like the right way to do it. If you actually get more or less complaints per subscriber as your number of subscribers increases, you probably don't want to normalize this away.
Answer: Another approach: Use some generalized linear model with log link function (maybe gamma, if complaints are counts maybe Poisson or negative binomial), the most important detail is the log link. For details see Goodness of fit and which model to choose linear regression or Poisson.
Then use the $\log\left(  \text{number of subscribers} \right)$ as an offset.
If this is too complicated just go with the answer of @Kodiologist.


Interpreting results from moderator analysis in a meta-analysis

Question: In a random-effects meta-analysis I found a negative association between a certain personality trait and gratitude (higher score on personality scale is associated with lower gratitude). Pearson's correlation coefficient is my effect size.
This association is significantly moderated by age. The estimate in the moderator analysis is negative.
Does this mean that the negative association between personality and gratitude gets more negative (i.e., stronger) with increasing age? Or is it getting less negative (i.e., weaker)?
The analysis was done using the robumeta package in R.
Comment: I edited my original post. Pearson's correlation coefficient was used as effect size.
Comment: If you could paste your output summary for moderator analysis., this may help us to answer your problem correctly.
Comment: Given the description, you seem to be  working on point- biserial correlation  - effect size for your meta- analysis.
Comment: I would interpret that as the higher the age, the lower the gratitute, independently from personality score
Comment: What effects size are you using? Mean differences? Correlations? Perhaps if you gave more detail by editing your question the answer might become clearer.
Answer: If you are analysing correlation coefficients and the summary estimate is negative then a moderator with a negative coefficient corresponds to the statement that studies with a high value of the moderator (in this case age) have more negative correlations. You are using the robumeta package so you are doing a meta-analysis of summary statistics. This is, therefore, an ecological finding since you appear to be using mean age (or some other summary of age like the median) in the study as the moderator so it does not mean that older people have more negative correlations but that studies with on average older people tend to have more negative correlations.


Why can't my user account remove an AD Computer in Powershell?

Question: I have created a Computer account in OU=AutoCreatedVMs,OU=Computer. I have allowed the AD Group Join-Move-Delete VMs to Create/delete Computer objects in OU AutoCreatedVMs:

I have an account called svc_jenkins and made it a member of AD Group Join-Move-Delete VMs.
I can't delete VMs from that OU when logged on as svc_jenkins:
PS C:\> gci env:username

Name                           Value
----                           -----
USERNAME                       svc_jenkins

PS C:\> Get-ADComputer test

DistinguishedName : CN=test,OU=AutoCreatedVMs,OU=Computer,DC=duck,DC=loc
DNSHostName       :
Enabled           : True
Name              : test
ObjectClass       : computer
ObjectGUID        : 7dd3b09a-d079-467a-b69f-90a2e30c363d
SamAccountName    : TEST$
SID               : S-1-5-21-1075642099-280362434-2919291742-3630
UserPrincipalName :

PS C:\> Get-ADComputer test|Remove-ADComputer -Confirm:$False
Remove-ADComputer : Access is denied
At line:1 char:21
+ Get-ADComputer test|Remove-ADComputer -Confirm:$False
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (CN=test,OU=Auto...,DC=duck,DC=loc:ADComputer) [Remove-ADComputer], Un
   authorizedAccessException
    + FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.UnauthorizedAccessException,Microsoft.ActiveDirectory.Manag
   ement.Commands.RemoveADComputer

Any ideas what I've done wrong? Domain controller is Windows Server 2012 R2.
UPDATE I tried it again 20 minutes later and it worked. Nothing else changed.
Comment: I'm betting the first time you forgot to open powershell as an administrator.
Answer: If Powershell was already running as the service account when you added it to the group, that group membership wouldn't have applied to that session.  Did you perhaps open a new Powershell session later when it worked?
Comment: I'm 99% sure this might be it!
Answer: You have more than one domain controller?
My guess is that the MMC was connected to one DC and you (or the powershell) tried to remove the computer object on the other, just before the security setting was replicated.
When you tried 20 minutes later, it was replicated granting you the permission.
Comment: No I have only one domain controller.


Are FCM and GCM backward and forward compatible?

Question: Google is deprecating Google Cloud messaging in favor of Firebase Cloud Messaging:

Firebase Cloud Messaging (FCM) is the new version of GCM. It inherits
  the reliable and scalable GCM infrastructure, plus new features! See
  the FAQ to learn more. If you are integrating messaging in a new app,
  start with FCM. GCM users are strongly recommended to upgrade to FCM,
  in order to benefit from new FCM features today and in the future.

From some tests I made on my servers, the FCM URL (https://fcm.googleapis.com/fcm/send) works with GCM projects, and vice-versa - the GCM URL (https://android.googleapis.com/gcm/send) works with FCM projects.
Migrating all existing GCM push sending code to FCM would save a lot of trouble and refactoring (I will not have to check, for each push, whether the app version is FCM or GCM).
Is this backward and forward compatibility officially supported or documented?
Answer: If you refer to @IanBarber's answer here:

The tokens are different. Firebase Cloud Messaging (GCM) use gets registration tokens from the Instance ID API which means you'll get different tokens between that and GCM2.
You'll need to send that new token back to your server to send messages. On the server side the APIs should be fully compatible (just new endpoints for FCM).

However, if you're looking for any official documentation, I don't think there is one that explicitly states it. Since as much as possible, Google encourages the use of the corresponding APIs, endpoints, etc. depending on what you really intend to use.
Comment: FCM supports all features available in GCM, so if you have clients that are currently working with GCM then switching the endpoints should have no effect on your application.
Comment: @ArthurThompson "no effect" ? then why should I switch. or did you mean no NEGATIVE effect?


If $P(u,v|x,y)=P(u|x)P(v|x)$, does it follow that $P(x,y|u,v) = P(x|u)P(y|v)$?

Question: Let $u,v,x,y$ be four random variables such that:
$$P(u,v|x,y)=P(u|x)P(v|x)$$
The question is: Does it follow that
$$P(x,y|u,v) = P(x|u)P(y|v)$$?
Comment: Why are you only conditioning u on x and v on y? The title question would suggest that your first line should be P(u,v|x,y) = P(u|x,y).P(v|x,y); similarly for the second equation. Why do you drop some terms from the conditioning?
Comment: @Glen_b I made the title more precise. This is not for a class, it's a question I came up with.
Answer: No. Indeed I see no reason why you'd even suspect it to be the case.
Here's a trivial counterexample.
Consider $U$ and $V$ each independent of all other variables, and further consider $X$ and $Y$ as being dependent (correlated, say), but independent of $U$ and $V$.
Then the first condition is true but the second is not.


Parsing a YAML with '!' tag via Pyyaml - sequence node parsing

Question: I am working on parsing a YAML file. I was able to read the data and access them with nested dictionaries. But I tried retrieving the sequence node data, or data with the seq tag and couldn't parse the same via scan or parse or load.
Example YAML
version: !schema 'v1'
version_major: 1
version_minor: 0
version_patch: 0
description:
  more_info: bar
  short_description: foo
depends: !EvaluatableList
- !dependency 'avb@/1.0.0': !And [!Equals [!Ref 'asdf::selected',
      true], !NotEquals [!Ref 'fddg', wwer]

In the above yaml, I couldn't access the string with '!' exclamation tag.  Those are required to validate the equal or not equal conditions. The output dict also doesn't read about the '!' tagged information.
On reading the PyYAML documentation, I couldn't retrieve any information related to the above.
Please let me know if there is any possibility of reading the above.
Comment: this is a similar problem and should help in your case: https://stackoverflow.com/questions/51883307/parse-nested-custom-yaml-tags
Comment: thanks tinita.. Found the answer from that post along with this https://www.programcreek.com/python/example/11269/yaml.add_constructor.
Answer: You are using the wrong documentation, and the wrong library.
If you want to know about !, you should consult the YAML 1.2
 documentation. That character
 indicates a node tag
PyYAML cannot handle YAML 1.2, it only parses YAML 1.1 (and loads only part of YAML 1.1).
What you want to use is ruamel.yaml (disclaimer: I am the author of
that package). You can install that in your python virtual environment
using: pip install ruamel.yaml .
After that you can access the value for the key 'version' as if you loaded dictionary from your YAML
document and other tagged entries appropriately as dictionary or list:
import sys
import ruamel.yaml

yaml_str = """\
version: !schema 'v1'
version_major: 1
version_minor: 0
version_patch: 0
description:
  more_info: bar
  short_description: foo
depends: !EvaluatableList
- !dependency 'avb@/1.0.0': !And [!Equals [!Ref 'asdf::selected',
     true], !NotEquals [!Ref 'fddg', wwer]]
"""

yaml = ruamel.yaml.YAML()
data = yaml.load(yaml_str)
print(data['version'])
dep = data['depends'][0]
for k in dep:
    print(k)
    for v in dep[k]:
        print(' ', v[0], v[1])

which gives:
v1
avb@/1.0.0
  asdf::selected True
  fddg wwer

yaml.load() can also be given a file handle (opened for
reading) or a pathlib.Path (i.e. the instance Path instance,
load will do the openeing).
Please note that I changed the last line in the YAML file. The
character after fddg is not a single quote and another closing
bracket was needed to balance the flow-style sequences in that mapping


IBM BladeCenter S: Disk Configuration

Question: Have just the one storage bay right now (SAS 15K 600GB x 6) and have configured one storage pool in RAID 10 with 4 disks (and two global spares).  For each blade, I've created a volume and mapped accordingly:

Blade #1 400 GB
Blade #2 200 GB
Blade #3 100 GB
Blade #4 100 GB

When I boot up Blade 1 and enter into the UEFI Setup (F1) followed by the Adapters and UEFI Drivers > LSI Logic Fusion MPT SAS Driver Utility, I see 4 disks: two are the on-board 73GB drives, the other two are 200GB each and assume I'm being presented with two logical disks from the volume I created and mapped to this blade.  I was a bit surprised by this: I figured I would've been presented with one logical drive per volume, not two.
I'm assuming I can just configure whatever RAID level I wish that supports two disks, but not really sure what the benefits/trade-offs here.  Should I go with RAID 10 on top of RAID 10?  RAID 0?  Software RAID 0/1/10? Does it even matter?
If this is "normal" to see two disks, then I'm going to likely just do some benchmarking and see if it makes a difference changing the RAID levels (my guess is no); if this is not normal, well, please let me know. :)
Answer: The fog has lifted...
I was not seeing a 50/50 split between both disks; I was seeing your typical multipathing problem that was resolved by setting up the proper multipathing configuration in the host OS.  Also had to unmap the volume, reinstall Ubuntu on the onboard RAID array first, then re-map, install/run multipath-tools (with the multipath.conf I grabbed from IBM's site).

IBM BladeCenter S: Disk Configuration


listen on port and decrypt https to stdout

Question: I write application that will send data to server over https. For development I would like to mock the server so that something listens there and simply shows me what it received, in decrypted form. Like nc -lv 8000 only with decryption. How to do this in linux?
Answer: You can use openssl as both a minimal SSL/TLS client as well as a simple server
openssl s_client -connect host:port

and similarly to run a listener  on port 8000 (with a key and certificate) :
openssl s_server -key key.pem -cert cert.pem -accept 8000

or or even a simple (web) server:
openssl s_server -key key.pem -cert cert.pem -accept 8000 -WWW

Comment: close but no cigar - I have POST requests with unpredictable paths so I always get 403 forbidden (surprisingly not 404). Returning error is ok, but I don't get to see what was sent on stdout, only `140032553370048:error:1408F09C:SSL routines:ssl3_get_record:http request:../ssl/record/ssl3_record.c:242: ACCEPT`
Answer: Develop your application in a web framework that makes the request object available. Then log these or do whatever you like with them.
To access the characters on the wire, do packet capture and decode TLS from extracted secrets. Wireshark is capable of TLS dissection.
An advantage to this approach is that it also works against production traffic, rather than using toy mock or echo servers.


What is a good source to learn about multidimensional scaling?

Question: I don't have much experience with statistics (my education included 8 credits of pure statistics, another 8 of related subjects). I mostly learned about distributions and significance tests for distribution parameters, and a bit about linear regression. I also had some factor and component analysis, but have completely forgotten them and don't have the textbook any more. Now we have to evaluate some empirical data and the other people on our team have even less knowledge in statistics.
After looking at different methods, I think that multidimensional scaling is the right technique to use - the examples I see it used for are similar to what we want to do. I found a book about it, but I find it very hard to learn from it. First, it is not at my level - the second paragraph of the "basics" chapter starts with the words "If σij is the affinity between object i and object j" and I am not sure what the affinity in my case is. Second, it is very old, from 1979, and I think there could have been improvements since then. Third, there is of course nothing about software support in this book. Fourth, it is in German, and googling about things I don't know is difficult, because there are better sources in English online, but I don't know the correct English translations of specific terms.
What I want is a better book. Here are my criteria for it.

  It should be a textbook aimed at students, not a reference tome for specialists.
  I would appreciate if it is written from an applied point of view, but it is more important for me to grasp the theory than to see a script which is supposed to spew out the result I am supposed to want.
  It won't hurt if it is a more general statistics textbook which includes a sizable section on MDS (I might need to refresh other knowledge), but please not an exhaustive brick which covers all the material for a B.Sc. in statistics and costs its weight in Euro notes.
  I would prefer it to be in English, but if the ultimative source is in another language, please tell me about it.
  I will use R for the evaluation, so if there is a book which uses R for the examples, it would be great. A book which is dependent on any tool - even if it is R - is a complete no-go (like a book which says "to obtain this result, use function X of package Y" instead of explaining the calculations which have to be made to obtain the result).

If you know of a book which meets at least the majority of these criteria, I'd love to hear about it.
Answer: A good textbook on multivariate data analysis, mixing introductory material and more advanced theory, is Modern Multivariate Statistical Techniques, by Alan J. Izenman (Springer, 2008). A review by John Maindonald was published in the JSS.
It features a complete chapter dedicated to MDS (chapter 13), with a lot of illustration using the open-source R statistical software. More on R packages can be found on CRAN Multivariate Task View, among others.
As an alternative, I would suggest the Handbook of Applied Multivariate Statistics and Mathematical Modeling, by Howard E. A. Tinsley and Steven D. Brown (Academic Press, 2000). Again, a complete chapter is devoted to MDS. Less mathematical background is required.
As for online reference, I can also recommend Forrest W. Young's course on Multidimensional Scaling.
Comment: The books look promising, but are these prices normal for statistics textbooks? (78 Euro for Izenman, 175 Euro for Tinsley et al). In my experience, textbook prices are in the 30 to 40 Euro range.
Comment: The first one is reasonable for a Springer textbook with 700+ pages. The second one is too expensive, even on Amazon, I agree. But if you can find it in a Library, it's worth taking a look at it.
Comment: I second @chl's recommendation of Tinsley and Brown's book.  It is expensive, though; see if you can get it from a library (as i first did).


Multiplicação de matrizes e armazenar em outra matriz?

Question: Seja uma função que receba três matrizes de valores inteiros A, B e C,
e dois inteiros n e m representando a quantidade de linhas e de colunas dessas matrizes. Essa função deve calcular a multiplicação das matrizes A e B e armazenar o resultado na matriz C.
Essa e a minha função:
void multiplicacao(int matA[] [MAX], int na, int ma, int matB[] [MAX],int nb, int mb, int matC [] [MAX], int nc, int mc)
{

int i , j;

if (na == nb && nb == nc && na == nc && ma == mb && mb == mc && ma == mc)
{
    for (i =0; i < na ;i ++)
    {
        for ( j = 0; j < ma ;j ++)
        {
           printf (" Digite matA [%d][%d]: ",i , j) ;
           scanf ("%d",&matA [i][j]) ;
        }
    }

    for (i =0; i < nb ;i ++)
    {
        for ( j = 0; j < mb ;j ++)
        {
           printf (" Digite matB [%d][%d]: ",i , j) ;
           scanf ("%d",&matB [i][j]) ;
        }
    }

    for(i=0; i<nb && i<na; i++)
    {
        for(j=0; j<nb && j<na; i++)
        {
            matC[i][j]= (matA[i][j]) * (matB[i][j]);
        }
        printf("%d \n",matC[i][j] );
    }
}

}

Só que não está compilando, está dando "Falha de segmentação (imagem do núcleo gravada)". O que está errado? A minha lógica também está certa para armazenar em  C?
Answer: Uma coisa é ler as matrizes do usuário, outra é multiplicá-las e outra é exibi-la. A função que multiplica as matrizes não deve fazer mais do que a multiplicação propriamente dita. O motivo para isso é que se você quiser multiplicar matrizes lidas de um arquivo ou produzidas como resultado de algum outro processo, isso não será possível se você estiver lendo elas do usuário. A mesma coisa se você quiser mostrar uma matriz sem ter efetuado multiplicação.
As funções de ler e mostrar uma matriz são essas:
void ler_matriz(int mat[][MAX], int n, int m) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            printf("Digite mat[%d][%d]: ", i, j);
            scanf("%d", &mat[i][j]);
        }
    }
}

void mostrar_matriz(int mat[][MAX], int n, int m) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            printf("%d ", mat[i][j]);
        }
        printf("\n");
    }
}

Vamos observar essa condição:
na == nb && nb == nc && na == nc

O na == nc é desnecessário. O mesmo pode ser dito do ma == mc.
Um outro problema no seu código é isso:
    for(j=0; j<nb && j<na; i++)

Você está utilizando j como variável do laço, mas está incrementando o i.
Você também pode usar um retorno inteiro para representar erro. Vamos colocar que 0 é ok e 1 é erro de tamanho das matrizes.
Assim sendo, se você queria era apenas multiplicar os elementos nas mesmas posições, então:
int multiplicar_elementos(
        int matA[][MAX], int na, int ma,
        int matB[][MAX], int nb, int mb,
        int matC[][MAX], int nc, int mc)
{

    if (na != nb || nb != nc || ma != mb || mb != mc) return 1;

    for (int i = 0; i < na; i++) {
        for (int j = 0; k < ma; j++) {
            matC[i][j] = matA[i][j] * matB[i][j];
        }
    }
    return 0;
}

Entretanto, se a sua ideia é implementar o algoritmo de multiplicação de matrizes, o problema aqui é maior. Nesse caso, as matrizes não têm os mesmos tamanhos. A quantidade de linhas da primeira matriz é igual a quantidade de colunas (e não de linhas) da segunda. Ou seja, a menos que você esteja multiplicando matrizes quadradas, elas não devem ter os mesmos tamanhos.
O produto de uma matriz de dimensões A x B por uma B x C dá em uma matriz A x C.
Como você está multiplicando uma matriz na x ma por uma nb x mb para dar uma nc x mc, então ma deve ser igual a nb, na deve ser igual a nc e mb deve ser igual a mc.
Com isso, podemos reduzir os seis números de tamanhos de matriz a apenas três.
O algoritmo de multiplicação de matrizes vai precisar de três laços. O motivo disso é que na matriz resultante, cada célula contém a soma dos produtos dos elementos de uma linha da primeira matriz pelos elementos de uma coluna da segunda. Dessa forma, para preencher cada célula da terceira matriz, você vai precisar de um laço interno percorrendo a linha da primeira e a coluna da segunda ao mesmo tempo. Por fora desse laço interno, você precisará de outros dois para visitar cada célula da terceira matriz.
O seu código arrumado para multiplicar matrizes fica assim:
int multiplicar_matrizes(
        int matA[][MAX], int na, int ma,
        int matB[][MAX], int nb, int mb,
        int matC[][MAX], int nc, int mc)
{

    if (ma != nb || na != nc || mb != mc) return 1;

    int a = na, b = ma, c = mb;

    for (int i = 0; i < a; i++) {
        for (int k = 0; k < c; k++) {
            matC[i][k] = 0;
            for (int j = 0; j < b; j++) {
                matC[i][k] += matA[i][j] * matB[j][k];
            }
        }
    }
    return 0;
}


Recorder sounds terrible with violin

Question: My daughter has some trouble reading music, so I try sometimes to help with the soprano recorder. The instrument is quite old, Johannes Adler written on it. Alone it sounds quite nice but with the violin (tuned) it sounds terrible! Completely out of tune. Do I do something wrong or is it the recorder? My daughter plays in pitch (I know she often plays along with the CD)
Comment: I'd be leery of concluding that yr daughter is on pitch just because she plays with a CD.  Tune both instruments with a meter.
Comment: @User8773 Even if you tune each fifth by ear, the first string still needs to be in tune. I can't imagine how terrible an orchestra would sound if everyone just said "Hey, my violin is is relative tune, should be good enough. right?"
Comment: If she plays a scale and you play an open a string drone does that still sound out-of-tune?
Comment: Could it be that you maybe have tuned the instruments in different Hz ?
Comment: Can you clarify which instrument the daughter is learning, and which you are attempting to accompany with?
Comment: The obvious solution is to use a tuner. How does your daughter have a violin to play but not a pocket tuner to tune it?
Comment: Disregard my question. I just noticed that you described your situation further here: http://music.stackexchange.com/questions/17611/learn-the-alto-recorder
Comment: @BinaryTox1n "How does your daughter have a violin to play but not a pocket tuner to tune it?"  Seriously.  That's like a violation of the Geneva Convention or something.
Comment: I am somewhat surprised at the answers suggesting a pocket tuner.  The main thing a violin need is to be tuned self-consistently, and using a pocket tuner will work worse for that than tuning pure(!) fifths by ear since you then look at the pitches independently instead of in relation to the next string which is what counts in playing.  And it's not like the beatings are hard to hear.
Answer: The recorder is probably very poor - Adlers were made in what was East Germany and in my opinion were not well-designed or well made. In fact, you may have a German-fingered recorder which are all uniformly terrible. The fingering for low f-natural is usually T1234-67, i.e, forked, but for those German fingered recorders it's T12345. In order to make this fingering work the tuning for the rest of the notes is severely compromised. But if even this is an English/Baroque/Modern fingered recorder, it is very likely out of tune with itself. If you've never had it worked on then getting it to play in tune may not be possible.
If you don't take our advice and get a tenor, at least go buy a new Yamaha plastic soprano. The clear colored ones work well, although you can see your spit in them.
Note also the soprano sounds in a very high range. Your lowest note is C5, only a third lower than the E string. It is very difficult even for professionals to match pitches up there perfectly and because the pitches are so high being even a little off can be very upsetting. That's one reason why piccolo players are often grouped in threes, it's easier for 3 of them to get in tune than just 2.
Comment: The clear colored ones are **freakishly awesome**.  I got a blue one for purely ornamental purposes (I always wanted a "small blue flute"), and was **very** pleasantly surprised at its tone quality.  I was seriously not expecting an instrument that cost under $5 to sound like that.
Comment: It is the baroque one, at least 30 years old but I guess 40.
Comment: BTW, the alto recorder (I've got from the same person), is too about 30 to 40 years old, was not played for ages and has supplied by Boosey & Hawkes, made in Germany written on it. (Boosey and Hawkes must have been the importer of recorders to Australia). What do you think of this one? It has a nice and mellow sound compared to the soprano.
Comment: Old recorders can be good, can be bad. Usually bad. It may sound OK all by itself, but is it really in tune with itself throughout its range? Are all the notes really there? Is the volume sufficient to be heard playing with other instruments (often the answer is no if you want to be in tune, old recorders were often voiced to play very softly by today's standards).
Comment: "you can see your spit in them" — I think that's more likely to be condensed water vapour. (Just like the mist on a mirror or spectacles after you breathe on them.)
Answer: Sounds like the violin is in tune, but the recorder is out of tune. It's most likely just the recorder. There may be a couple of possibilities here. Try to determine how far out of tune (and in which direction) the recorder is, either using a tuner or by ear.
Recorders can be tuned by pulling out the head joint from the body. If the recorder's pitch is too high, this will lower it. If the recorder's pitch is already too low, I'm not there's much you can do (unless the head joint is already pulled out, in which case you can push it back in).
Recorders (especially sopranos) are also susceptible to changing pitch along with breath pressure, so the harder you blow, the sharper the pitch gets, and the softer you blow, the lower it gets (this is why recorders don't have much dynamic range -- it makes them play out of tune). It's possible that you're blowing to hard or soft, and that by blowing harder or softer, you can bend the pitch into an acceptable range. But this is generally a pretty minor effect, and it sounds like your problem is much larger.
It's also possible that the recorder may be pitched in A=415 pitch, which is the tuning standard used by historical Baroque performance. Modern pitch (which her violin would be tuned to) is A=440. This results in a half-step difference. So if she plays an open E string (in a=440), you would have to play an F (in a=415) to get the same sound. This would be inconvenient. See also: How can I play my new tenor recorder (a'=440) along with someone playing a harpsichord (a'=415)?
Answer: Well, assuming that you tuned the violin properly to the flute (it may work better to tune to something other than A though), the basic advice here is: don't play empty strings.
A recorder has a very straight and pure tone and sort of a compromise tuning.  It takes very experienced recorder players to even slightly adjust pitch.
It takes "only" a good violin player to adjust pitch automatically, and once you add vibrato (and thus lose the straight and pure tone from the violin), the beatings get masked anyway.
But in a nutshell my experience is: when playing with recorder players below the semiprofessional level, don't bother playing an empty string on your violin ever.  You cannot tune the violin well enough to have that work out.
Comment: Unless I misread the question, I thought it was the daughter who is still learning the violin (and thus possibly not able to make the corrections you describe). I see now it could be interpreted either way, though.
Comment: Uh yes.  Well, what you can do is still tune the violin to the flute (hopefully she is able to tune her violin by ear).  And tell her to avoid empty strings when playing together.  And hope that she learns to correct soon enough.  If she has sightreading problems, chances are that she does not yet have the skill to do vibrato and/or subconscious adjustments.  You just have to tough it out until she does.
Comment: @David - To tune the violin to the recorder/flute is going to use open strings, so what's wrong with using them after it's in tune?
Comment: -1: I would be cautious of using instruments that are clearly out of tune with each other, planning only to adjust how they're played to get them in tune. A practical answer is going to involve tuning the instruments beforehand.
Comment: Thanks for all the answers! I learned a whole lot. The recorder was given by a neighbour and is probably very old and was not played for ages. I tune the violin by the computer there is something called get tuned or similar, very easy it plays every string. I guess I must buy another instrument be it an alto or a tenor the soprano is too high pitched anyway. She is working hard to learn reading music (at the moment she is reading fingering).  BTW the a's were in tune with each other.
Comment: @Tim: try it.  In general, you are not going to play inunison and the intervals don't work out.  Part of the reason may be that a soprano recorder is played an octave higher than written, sabotaging some of the intended harmonic intervals, but you'll still have some of that empty-string problem when playing with a tenor recorder notated at pitch.
Comment: @Kevin: thanks for the -1 but I did *not* recommend not first tuning the instruments to match.  See the first sentence I wrote.  I was reporting my personal experience, but as this is apparently not welcome, I will delete my answer today before accumulating too much negative reputation.
Comment: @User8773 I rolled back your edit because it replaced an answer with a non-answer.  You can delete the answer if you like (if you don't see a delete link, use a custom flag to request) or ask that it be disassociated from your account (use the "contact us" link at the bottom of the page), but you shouldn't make this kind of edit.  Thanks.
Answer: Note there are two different 20th-century designs of recorder, "German" and "baroque". You can tell the difference by looking at the relative size of the finger holes - see http://www.mollenhauer.com/en/useful-information/recorder-designs/baroque-and-german-fingering#.VcU2nZDbKJA.
You can't play in tune using the "wrong" fingering for the instrument. The German design was invented to be simpler for absolute beginners (you play the basic diatonic scale of the instrument simply by uncovering the holes one by one) but it is not so good for chromatic notes. And since they were designed as very cheap beginner's instruments, "German" recorders are often not good quality instruments in any case.
Fingering charts for the two basic types (and a lot more besides) are here: http://www.recorder-fingerings.com/en/index.php
Answer: Try a simplified test:  Write out some scales, major, minor, up and down, and play them in unison with your violinist.  Play them staccato, legato, pp and ff.  See if you sound reasonably in tune on this simple test.
Do the same thing with a recently-tuned piano.

Recorder sounds terrible with violin


How many caps do you need to cover the intersection of an $n-1$-sphere and a $k$-plane?

Question: Consider a unit sphere in $\mathbb{R}^n$ centered at the origin and a $k$-plane passing through the origin with $1 \leq k < n$. If I cover this intersection by spherical caps of radius $r$ (with $r \ll 1$), my question is how many spherical caps do you need?
As an example, when $n = 3$ and $k = 2$, then the intersection is a great circle and so you need roughly a constant multiple of $r^{-1}$ since the great circle has circumference a constant multiple of 1 and each spherical cap of radius $r$ takes up a constant multiple of $r$ of that circumference.
What is this in the general $n$ and $k$ case? Is it a constant multiple of $r^{-(n - k)}$? If so why?
Comment: Just for consistency with the title: the unit sphere in $\Bbb R^n$ is not an $n$-sphere, it's an $n-1$-sphere.
Answer: The intersection is the unit sphere in the $k$-plane, so the question is how many spherical caps of radius $r$ do you need to cover a unit $(k-1)$-sphere.
It's a difficult problem for which only lower and upper bounds are known. The thing is, in dimensions higher than $1$, you're going to have a lot of overlap between your caps, and this wasted volume is hard to evaluate precisely. For instance, the very recent Covering spheres with spheres by Ilya Dumer (2018) contains such results:
Call $\partial$ the density of a covering. That is, the ratio of the total volume of the caps divided by the volume of the sphere (volume means Lebesgue measure). Then any $n$-sphere of any radius $r$ has a covering by unit caps of density $$\partial \leq \left(\frac 12+\frac{3\ln\ln n}{\ln n}+\frac{3}{\ln n}\right)n\ln(n)$$
The author considers coverings of large spheres by unit caps, you will need to do the conversion to get coverings of unit spheres by small caps. You will then need to compare the volume of one small cap with the volume of the sphere to turn this density into an actual number of caps. And in the end, replace $n$ by $k-1$.


Can I use Android Audiorecord with AIDE IDE app?

Question: Is it possible to develop a Java application that uses Android Audiorecord, directly on my phone, via the AIDE-IDE app ?
Thank you for your attention.
Comment: Thank you Mike M. for your answer.
Comment: Yes, it is possible.
Answer: Plese try follwing code:
<code>//https://gist.github.com/nileshdarade/abd9a395821849b587583fafa00280a4
public static AudioRecord findAudioRecord(Context context) {
    AudioRecord recorder = null;
    try {
        AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        int _rate = Integer.parseInt(audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
        int bufferSize = Integer.parseInt(audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER));
        for (short audioFormat : new short[]{AudioFormat.ENCODING_PCM_8BIT, AudioFormat.ENCODING_PCM_16BIT}) {
            for (short channelConfig : new short[]{AudioFormat.CHANNEL_IN_MONO, AudioFormat.CHANNEL_IN_STEREO}) {

                Log.d(TAG, "Attempting rate " + _rate + "Hz, bits: " + audioFormat + ", channel: "
                        + channelConfig);
                int bufferSize = AudioRecord.getMinBufferSize(_rate, channelConfig, audioFormat);
                if (bufferSize != AudioRecord.ERROR_BAD_VALUE) {
                    // check if we can instantiate and have a success
                    recorder = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, _rate, channelConfig, audioFormat, bufferSize);

                    if (recorder.getState() == AudioRecord.STATE_INITIALIZED) {
                        return recorder;
                    }
                }

            }
        }
    } catch (Exception e) {
        Log.e(TAG, "Exception, keep trying.", e);
    }

    for (int rate : new int[]{8000, 11025, 16000, 22050, 44100}) {
        for (short audioFormat : new short[]{AudioFormat.ENCODING_PCM_8BIT, AudioFormat.ENCODING_PCM_16BIT}) {
            for (short channelConfig : new short[]{AudioFormat.CHANNEL_IN_MONO, AudioFormat.CHANNEL_IN_STEREO}) {
                try {
                    Log.d(TAG, "Attempting rate " + rate + "Hz, bits: " + audioFormat + ", channel: "
                            + channelConfig);
                    bufferSize = AudioRecord.getMinBufferSize(rate, channelConfig, audioFormat);

                    if (bufferSize != AudioRecord.ERROR_BAD_VALUE) {
                        // check if we can instantiate and have a success
                        recorder = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, rate, channelConfig, audioFormat, bufferSize);

                        if (recorder.getState() == AudioRecord.STATE_INITIALIZED) {
                            return recorder;
                        }
                    }
                } catch (Exception e) {
                    Log.e(TAG, rate + "Exception, keep trying.", e);
                }
            }
        }
    }
    return null;
}
</code>


Exercising fingerstyle bass technique

Question: I'm looking to improve my fingerstyle technique on the bass guitar. I'd like to develop good habits, especially regarding alternating my fingers, as I currently tend to overuse my index finger and rake the strings too much. Likewise, I'm trying to get out of the habit of anchoring my thumb on the E string. Are there any exercises or lessons that would help with this? I'm especially interesting in learning to alternate my fingers and mute with my thumb properly when skipping strings or playing complex rhythms.
Note: I asked a related question about the specifics of how to alternate between fingers.
Answer: You can't go wrong practicing scales, so I'd definitely start there. But for string skipping and thumb muting, here's an exercise I like, called "the spider". You can do this anywhere on the neck that's comfortable, but I'm illustrating it on frets 1-4 for clarity (can we write tab here for non-six-string stringed instruments?):
<code>$A 1 $D 3 $A 2 $D 4 $A 3 $D 1 $A 4 $D 2 | $A 1 $D 3 $A 2 $D 4 $A 3 $D 1 $A 4 $D 2
</code>
Then you expand the string spacing:
<code>$A 1 $G 3 $A 2 $G 4 $A 3 $G 1 $A 4 $G 2 | $A 1 $G 3 $A 2 $G 4 $A 3 $G 1 $A 4 $G 2
</code>
and finally:
<code>$E 1 $G 3 $E 2 $G 4 $E 3 $G 1 $E 4 $G 2 | $E 1 $G 3 $E 2 $G 4 $E 3 $G 1 $E 4 $G 2
</code>
This is a nice exercise for alternating your plucking fingers, since each finger is isolated on its own string. As always, practice with a metronome!
Comment: Thank you! With all of the octaves and fifths that looks like a very practical exercise!
Comment: Oh and I'm finding that it's helpful to reverse the pattern so that I'm not always using the same finger for the higher/lower string.
Answer: A simple but interesting exercise is playing octaves, or fifths (start with fifths, then move to octaves) but play the lower note once, and the higher note twice, but always alternating the two fingers you're plucking with. The result is that you play the lower note once with finger 1, the next time with finger 2, then again with finger 1, etc. Do it slowly at first. After a while, check what you're doing; most likely, you will be playing the lower note always with the same finger. It's not exactly wrong, but it's important that you're aware of it and that you can control it.
Answer: As far as anchoring goes, my old teacher taught me to rest my thumb on the top of the neck pickup.  Not sure if it's the best practice, but it's served me pretty well over the years.
What I do a lot of to help warm up is run various scales in triplets, both along and across the strings.  Not sure how to post tab on here, but something to the effect of the following:

G|------------------------------------------------|
D|------------------------------------0-----0-2---|
A|-------------0----0-2---0-2-3---2-3-----3-------|
E|-0-2-3---2-3----3-------------------------------|

You can modify this exercise to run along a single string, or take it across two octaves to go across all four-plus and get a better sense of how to get the left hand moving while you're at it.  I like the latter method in particular because it helps discipline your right hand to be aware of what's going on instead of mindlessly pinging on a single string.

Exercising fingerstyle bass technique


How To Force Commerce Cart View To Update (Ajax?)

Question: I admit to being a Commerce -novice-. It's getting better, but it's still quite confusing in some spots. I've posted several questions here over the past year trying to skin the same cat in different ways. We have a Drupal 7 cart. The pricing is pulled in from an external web site via http_request which updates the unit price of all items in the cart on hook_form_alter().
The problem is that the -initial- price that displays in the cart is always 0. The user always has hit  to refresh the page for that pricing to update the View. Commerce seems to want to pull the unit price in from the Product nodes so after a user hits  the cart displays but with a 0 unit price. When they hit  -then- our code fires and updates the price.
So... I need is either:
a) a way to force that view to 'refresh' when the page is rendered (ie. it initially loads with the zero prices, runs the http_request code and -then- renders again). Yeah, it's ugly but I'm just sick of this.
b) Figure out a way using the Rules (which I haven't been able to do) to get the line item price to pull in from the http_request with PHP. This -never- seems to work. It -always- wants to use a rule based on an existing field. If someone could give me a tutorial on how to use PHP with Commerce for the Unit Price I'd buy them a CASE of virtual beer!
c) Figure out a way to assign that http_request price as the line item price when the user hits the 'Add' button. Again, probably a noob thing, but I cannot figure out how to override the Unit Price for the Line Item to the value I want. It -always- wants to use the Unit Price from the Product node.
ANY help would be most appreciated!
Comment: _which updates the unit price of all items in the cart on hook_form_alter()_ Does that actually work? As in when you add the item to the cart and go through the checkout, does that price override stick?
Comment: Wow. I didn't see your reply--SORRY! The code -does- 'work'.. ie. my function does get executed. The problem is that I need (in template terms) to set the -priority- of the execution. The code executes -after- the view renders so the view displays the -wrong- prices. When the user hits  they see the correct pricing. SO: If I could force the code to execute -before- the view is rendered, I'd be in business!
Comment: Another possibility: If I could get the -same- code to fire -after- the Add Line Item button (different form.) Again, it's a priority issue... when I add my function to the Submit button on the Add form, it seems to execute -before- the actual line item add so again, when the user goes to the Cart, they see the wrong price. Maddening. Again: if I could force my code to run at the right priority (in this case -after- the Add Line Item) I'd be in business.

Ideas? TIA!!!!! ---JC
Answer: Implement a custom rules action and wire it to rules event Calculating the sell price of a product. The sell price of a line item can be forced to any value using the action Set the unit price to a specific amount. The missing piece is a custom rule action capable of retrieving the amount. As a starting point I propose the following (assuming the custom module is named acme):
/**
 * Implements hook_rules_action_info().
 */
function acme_rules_action_info() {
  return array(
    'acme_random_amount' => array(
      'label' => t('Generate random price (with params!)'),
      'group' => t('Examples'),
      'parameter' => array(
        'product_id' => array(
          'type' => 'text',
          'label' => t('Product SKU'),
          'description' => t('The SKU of a product.'),
        ),
        'account' => array(
          'type' => 'user',
          'label' => t('User'),
          'description' => t('A user account.'),
        ),
      ),
      'provides' => array(
        'amount' => array(
          'type' => 'decimal',
          'label' => t('Amount'),
          'description' => 'Return a random numeric amount, except for admin.',
        ),
      ),
    ),
  );
}

/**
 * Rules action: Generate and return random amount of money.
 */
function acme_random_amount($product_id, $account) {
  $amount = mt_rand(100, 1000);

  // Fix price for admin.
  if ($account && $account->uid == 1) {
    $amount = 420;
  }

  // Blue sells, let's boost the revenue.
  if (strpos($product_id, 'BLU') !== FALSE) {
    $amount *= 100;
  }

  return array(
    'amount' => $amount,
  );
}

The rule then looks something like this:
{ "rules_pick_random_price" : {
    "LABEL" : "Pick random price",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "acme", "commerce_line_item", "commerce_product_reference" ],
    "ON" : [ "commerce_product_calculate_sell_price" ],
    "IF" : [
      { "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } }
    ],
    "DO" : [
      { "acme_random_amount" : {
          "USING" : {
            "product_id" : [ "commerce-line-item:commerce-product:sku" ],
            "account" : [ "commerce-line-item:order:owner" ]
          },
          "PROVIDE" : { "amount" : { "amount" : "Amount" } }
        }
      },
      { "commerce_line_item_unit_price_amount" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : [ "amount" ],
          "component_name" : "base_price",
          "round_mode" : "0"
        }
      },
      { "drupal_message" : { "message" : "Set the price of [commerce-line-item:commerce-product:sku] to amount: [amount:value] for user [commerce-line-item:order:owner:name]" } }
    ]
  }
}

Note that in order to get at the product SKU, it is necessary to introduce a condition Entity has field checking for the presence of the commerce_product field on the commerce-line-item variable.
Please keep in mind that this rule will be executed on every page request for every item in the cart. Additionally it is executed whenever an add-to-cart form is displayed. If this is on a high traffic site, you probably need to think about an appropriate caching strategy.
Comment: @jchwebdev: View all episodes of [Coding for Rules 2](http://nodeone.se/da/node/28) screencast by NodeOne and read the [rules developer documentation](https://drupal.org/node/878718). The calculation of product line item prices happens in [commerce_cart_order_refresh](http://api.drupalcommerce.org/api/Drupal%20Commerce/sites%21all%21modules%21commerce%21modules%21cart%21commerce_cart.module/function/commerce_cart_order_refresh/DC). This is the function responsible for the prices being copied over from the product definition.
Comment: Thanks. I'm not at my computer this weekend. Will test first thing Monday morn. Hope yer around for any follow ups. I've had a DEVIL of a time getting -any- rules to work... CHEERS!
Comment: OK, I think I follow you. The only question I (think) I have is: in order to get the price I want from the external site I need to supply the Customer ID and Product ID for the order. How do I reference them from Rules? When I use hook_form_alter() I can get that by loading the global data ie. $order = commerce_cart_order_load($user->uid); Can I do this inside Rules?
Comment: @jchwebdev: Yes you can get at any property of your order. Example updated.
Comment: THANKS! I -think- I get it. (Well, enough to move ahead a bit.) What I really don't get is where this is all documented. I hate to sound so -thick- but where would you recommend I learn more---hopefully with some examples? The Commerce forum seems -really- opaque. Lots of very similar questions to mine with no answers.
Comment: Oh yeah, I just realised that a BETTER place to put the Rule would be -after- the Cart is updated... ie. after any add or delete... so that it's not being called for each line item. I assume the above concept would apply to the Event 'After saving a new commerce line item'?
Comment: @jchwebdev: There is a [users guide](http://www.drupalcommerce.org/user-guide), especially read through the [sell price calculation](http://www.drupalcommerce.org/user-guide/sell-price-calculation) chapter. Do not try to use other hooks than the rule event *Calculating the sell price of a product*.
Comment: Sorry to bug you one more time... but why -not- use the other hooks? Ideally, I'd like to be able to call the function I already have -once- before the Cart View is rendered. What I meant by docs was applying PHP to Rules.

Actually... what I'd -really- like to know is: How do I turn off that darned Cart Refresh so that it -doesn't- auto-calculate prices? That's the kind of docs I'm looking for. The references to 'Cart Boolean' all seem very vague to me. Ideas?


question about uniform integrability

Question: Am I correct with usage of this generalised Dominated Convergence lemma:  a sequence $(f_n)$ in $L^1$ on a bounded domain is strongly convergent if and only if $(f_n)$ is uniformly integrable and $(f_n)$ converges in measure, or pointwise almost everywhere?
By Dunford Pettis I know that $(f_n)$ is uniformly integrable if and only if $(f_n)$ is weakly convergent in $L^1$.
My question is, is it possible to deduce $L^p$ convergence of a bounded sequence $(f_n)\subset L^p$,  by showing that, for all $\phi\in L^\infty$:
$$1. \int |f_n |^p(x)  \phi (x) dx\to \int |f  |^p(x)  \phi (x) dx$$ and
$$2.  \,\, f_n\to f \text{ in measure} $$
which would imply the uniform integrability of $|f_n-f|^p$, and hence the desired convergence? I would attempt to use the Vitali lemma, so that on a bounded domain $\Omega$, $(|f_n|^p)$ uniformly bounded in $L^1(\Omega)$, existence (and finiteness) of the pointwise a.e limit and uniform integrability of $|f_n-f|^p$ allow passage to the limit
$$\lim_n \int_\Omega |f_n-f|^p dx =  \int_\Omega\lim_n |f_n-f|^p dx =0.$$
Furthermore, how limited would an approximation argument for 1., with $\phi\in C_c^\infty$? Is there a counterexample with a uniformly integrable sequence, pointwise converging, that does not converge in $L^p$? I ask this second question because of the equivalence of distributional convergence to weak convergence in $L^p$ if the sequence (and limit) are already bounded in $L^p$.
Note: I am using the following definition of UI:
$\forall\varepsilon>0, \exists g$ an integrable function such that
$$\sup_{n}\int_\Omega(|f_n|-g)^+\mathrm dx\lt\varepsilon.$$
Comment: I don't know qnd I really have no time to think at this now, but I'd like to leave a commentary anyway. Weak convergence in $L^1$ space and in $L^p$ space are very different things. The reason is that $L^1$ space embeds in the space of measures, so the "right" setting for weak convergence of $L^1$ functions really is seeing them as measures. There is nothing analogous for $L^p$. (For instance, note that you cannot "converge to the delta distribution" in $L^p$ space. The scaling is just wrong.) HTH even if it is rather vague; if you find it confusing I'll erase this comment
Comment: Thanks, I understand. I was trying to think of a way to prove a higher uniform integrability than $L^1$, but cannot find anything equivalent to the definition.
Comment: I am trying to make use of the equivalence that for a uniformly bounded sequence $(f_n)$ in $L^p, 1<p<\infty$, with $f\in L^p$, then $f_n\to f$ weakly in $L^p$ iff $f_n\to f$ weakly-* in the sense of measures (or even $f_n\to f$ in $\mathcal{D}'$).
Comment: Is your measure space finite? Otherwise, what definition of uniform integrability do you use? Because with the definition I know, the sequence $f_n = \chi_{[n,n+1]}$ on $\Bbb{R}$ with Lebesgue measure should be a counter example to your initial statement.
Comment: Yes it is finite. I will edit to include the definition.
Answer: I just noted that the statement you want to prove is actually trivial, because if
$$\int |f_n - f|^p \cdot \phi \, dx \rightarrow 0$$
for all $\phi \in L^\infty$, you can use this with $\phi \equiv 1$ which is then nothing but convergence in $L^p$.
EDIT: If you instead require $\phi \in C_c^\infty(\Omega)$, the statement becomes false in general. As a counterexample consider $p=2$, $\Omega = (0,1)$ and $f_n = \sqrt{n} \cdot \chi_{(0,1/n)}$. Of course, in this case, the sequence is not uniformly integrable.
Comment: Then maybe I am misunderstanding Dunford Pettis: what should it mean to be relatively compact in the weak $L^1$ topology? Wouldn't this trivially imply strong $L^1$ convergence as you have shown?
Comment: The point is that weak $L^1$ convergence means $\int (f_n - f) \cdot \phi dx \rightarrow 0$ for all $\phi \in L^\infty$. Note the missing absolute value around $f_n - f$. You could choose the $\phi$ so that the absolute value does not matter, but this requires $\phi = \phi_n$ in general, so that the statement with the absolute values is strictly stronger.
Comment: I think I see the problem now. Could one argue this holds for the positive and negative parts of $f_n-f$?
Comment: Perhaps weak convergence of the $p-th$ powers, plus convergence of their norms, would give the $L^p$ convergence for all reflexive $p's$.
Comment: Do you mean this? If $f_n \rightarrow f$ weakly in $L^p$ and $\Vert f_n \Vert_p \rightarrow \Vert f \Vert_p$ (and $1<p<\infty$), then already $f_n \rightarrow f$ strongly in $L^p$. If so, have a look at http://math.stackexchange.com/questions/163209/weak-convergence-in-lp-plus-convergence-of-norm-implies-strong-convergence .

question about uniform integrability


Stationarity of time series with product of white noise time series

Question: Is the time series $\{Yt\}$ given by $Y_{t} = Z_{t} - \frac{1}{2}Z_{t-1}Z_{t-2}$
With $Z_{t} \sim{N}(0\,1)$, weakly stationary?
I do not know how to check if the above stated formula is stationary? I am struggling how to interpret the product of the same white noise time series with different lag?
Answer: Assume $k> 0$ without loss of generality, and assuming white $Z_t$:
$$\begin{align}\operatorname{cov}(Y_t,Y_{t-k})&=\operatorname{cov}(Z_t-\frac{1}{2}Z_{t-1}Z_{t-2},Z_{t-k}-\frac{1}{2}Z_{t-k-1}Z_{t-k-2})\\&=-\frac{1}{2}\operatorname{cov}(Z_{t-1}Z_{t-2},Z_{t-k})+\frac{1}{4}\operatorname{cov}(Z_{t-1}Z_{t-2},Z_{t-1-k}Z_{t-2-k})\end{align}$$
Check this expression for $k=1,2$ and greater values. You'll see that the covariance is always $0$. Also, the mean process will be constant.
Comment: Yes, I shortened that a bit because covariance of $Z_t$ with any of the past values will be $0$
Comment: should second line be: cov(Zt,,Zt−k)−1/2cov(Zt,Zt−1Zt−2)−1/2cov(Zt−1Zt−2,Zt−k)+1/4cov(Zt−1Zt−2,Zt−1−kZt−2−k)


Docker (systemd) ignores change of default directory (docker.service)

Question: I want to deploy docker on a server, but I want all docker-related data to be in a separate partition from the base system. I have thus mounted said partition at '/srv' and made the following changes, according to the official documentation:
This is my '/usr/lib/systemd/system/docker.service' file:
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker.socket
Requires=docker.socket

[Service]
Type=notify
EnvironmentFile=-/srv/docker/docker.conf
ExecStart=/usr/bin/docker -d -H fd:// $OPTIONS
LimitNOFILE=1048576
LimitNPROC=1048576

[Install]
Also=docker.socket
WantedBy=multi-user.target

This is the '/srv/docker/docker.conf' file that is referenced inside the 'docker.service' file:
$OPTIONS="--graph /srv/docker --storage btrfs"

The docker daemon starts correctly and also PULLs images. The problem is that it still does not store anything inside the '/srv/docker' directory.
Also, when I run 'ps -aux | grep docker', what I get is this:
root       661  0.4  0.2 351080 17044 ?        Ssl  19:33   0:00 /usr/bin/docker -d -H fd://

The command line stops at 'fd://'. It seems to me that '$OPTIONS' is being overlooked for one reason or another.
Now, is there a problem with the way I reference the files? Is there something else going on here? The reason I am doing all these configuration changes is that I would really like to keep all docker related data under the '/srv/docker/' directory.
Any ideas?
UPDATE 1:
I changed my 'docker.conf' file, as suggested in the answers section. Now:
$OPTIONS="--graph /srv/docker --storage btrfs"

became:
OPTIONS="--graph /srv/docker --storage btrfs"

This had the (unexpected) consequence of the docker daemon not starting. This is the debug message from 'systemctl status docker':
[root@V12 ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2015-02-05 20:13:31 EET; 14s ago
     Docs: http://docs.docker.com
  Process: 776 ExecStart=/usr/bin/docker -d -H fd:// $OPTIONS (code=exited, status=2)
 Main PID: 776 (code=exited, status=2)
Comment: What happens if you alter ExecStart to include the line "--graph /srv/docker --storage btrfs" instead?
Comment: @MatthewIfe I tried it and the daemon refuses to start. The debug message says that the 'ExecStart' line is to blame. Also, please take a look at the update I made to the question.
Comment: Does that work if you manually invoke docker on the command line with all the options you want?
Answer: You have an error in your /srv/docker/docker.conf file.
$OPTIONS="--graph /srv/docker --storage btrfs"

The specification of a variable should not start with a $; the $ should only be used when using the variable later.
Change it to:
OPTIONS="--graph /srv/docker --storage btrfs"

Comment: Well, at least now your environment file works :)
Comment: I am so going to put this up for a bounty.
Comment: Please see my update.
Answer: First off I want to thank @MichaelHampton for his answer. It was spot on, and I would have never spotted the typo with the '$' ('OPTIONS=...' instead of '$OPTIONS=...').
Now, the problem was with the command line options. In the docker documentation the argument for changing the storage driver is given as:
--storage btrfs

Keep in mind that this is the docs for version 1.4, which is the version I have. Alas, the correct syntax, as evidenced by 'docker --help' is:
--storage-driver btrfs

So, after making the necessary change, the daemon starts correctly, the images are PULL-ed inside the '/srv/docker' directory, and everything is fine.
The moral is to always be a little mistrustful of official documentations, especially for projects under heavy development, like Docker. Again thanks to all for their contributions.
Answer: Initially I spent quite a bit of time fiddling with the previous upstart/sysv initscript from /etc/init.d/docker and its configuration file /etc/default/docker. It was really strange that it just didn't work no matter what I tried, then eventually I realized that systemd just ignores both of those, since I was using the legacy script directly.
The proposed solution doesn't seem to work 100% on my 15.04 with lxc-docker-1.7.0 installed from the official docker PPA, since the EnvironmentFile seems to be missing from my docker's systemd configuration file.
An option would be to edit it in-place and add it using this command:
sudo systemctl edit docker --full

But this risks to be overridden by the next update, so my solution was to instead create an override, by running
sudo systemctl edit docker

Then I decided to just redefine the ExecStart command in the new configuration  override, instead of also adding and referencing a new configuration file under /srv/docker/docker.conf.
[Service]
ExecStart=
ExecStart=/usr/bin/docker -d -H fd:// --storage btrfs

There's no error in the snippet above, for some strange reason that has to do with the way systemd reads its configuration overrides, a value needs to be first defined with an empty value, then reassigned to the new value.
Once I did this the daemon started happily and I was finally able to use it.


Trying to force WWW and HTTPS and only two out of my three rules will work

Question: Not working for me .. what am I doing wrong I get the dreaded too many redirects error. I am trying to force all my urls to WWW and https, though I would settle for just being able to force everything to https
    RewriteEngine on
    RewriteBase /

    RewriteCond %{http_host} ^all-service-musical.com [nc]
    RewriteRule ^(.*)$ https://www.all-service-musical.com/$1 [r=301,nc]

    RewriteCond %{http_host} ^asmusic.org [nc]
    RewriteRule ^(.*)$ https://www.all-service-musical.com/$1 [r=301]

    RewriteCond %{http_host} ^www.all-service-musical.com [nc]
    RewriteRule ^(.*)$ https://www.all-service-musical.com/$1 [r=301,nc]

The first two rules work fine together, but the 3rd rule to try to change the www url to https breaks the whole thing.... any ideas?
I also tried removing all the above code and tried to accomplish the http to https portion of the task by using:
RewriteEngine On
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

I also get a too many redirects error also when using the above approach.
I as well tried this alone by itself:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://all-service-musical.com/$1 [R,L]

Same results ... breaks the site with too many redirects error.
MrWhite ...Thank you for taking the time to answer, the code that is currently in the htaccess file is:
RewriteEngine on
RewriteBase /
RewriteCond %{http_host} ^www.all-service-musical.com [nc]
RewriteRule ^(.*)$ https://all-service-musical.com/$1 [r=301,nc]

RewriteCond %{http_host} ^asmusic.org [nc]
RewriteRule ^(.*)$ https://all-service-musical.com/$1 [r=301]

RewriteCond %{http_host} ^www.asmusic.org [nc]
RewriteRule ^(.*)$ https://all-service-musical.com/$1 [r=301]

As the certificate is for all-service-musical.com ( I am beginning to wonder if setting it up that way was bad advice from the hosting company) I thought I would try rewriting the code so that the non WWW version is the target, however I still have the same issue of when I type all-service-musical.com into the address bar it comes up as unsecured, when I had the code as originally posted the the WWW version when typed directly would come up as unsecured.
I would have to think that this bit of code you provided:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=302,L]

If everything else is removed should work all on its own to a certain extent, but it breaks the site with a too many redirects error even when it is the only thing in the htaccess file.
I do like and appreciate your advice on using a 302 redirect until I get the right code figured out for this. Any further advise on where my issue may be lurking is greatly appreciated.
Comment: "the certificate is for all-service-music.com" - do you mean `all-service-musical.com`?
Answer: If you are persistently getting redirect loops when trying all of these directives then clear your browser cache. All these shouldn't be triggering redirect loops. It is advisable to test with 302 (temporary) redirects for this reason, and only change to 301 (permanent) when you are sure they are working OK.

RewriteCond %{http_host} ^all-service-musical.com [nc]
RewriteRule ^(.*)$ https://www.all-service-musical.com/$1 [r=301,nc]

RewriteCond %{http_host} ^asmusic.org [nc]
RewriteRule ^(.*)$ https://www.all-service-musical.com/$1 [r=301]

RewriteCond %{http_host} ^www.all-service-musical.com [nc]
RewriteRule ^(.*)$ https://www.all-service-musical.com/$1 [r=301,nc]

Your first three RewriteRule directives are all missing the L flag, so processing will continue onto the next rule etc. Your 3rd rule that tries "to change the www url to https" will certainly result a redirect loop as you are simply redirecting to itself. To redirect from HTTP to HTTPS, you need to first check for HTTP (ie. HTTPS is off), as you are doing in your later attempts.

RewriteEngine On
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Your 4th rule redirects to HTTPS on the same host - this is potentially a good idea, providing your different domains (do you have just two?) all have a security cert installed.

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://all-service-musical.com/$1 [R,L]

This is redirecting to the domain apex, not the www subdomain (the opposite of the first three rules). This could potentially result in a redirect loop if the site code itself issued a redirect to the canonical host.
Assumptions:

You have a single canonical hostname www.all-service-musical.com and all other domains redirect to this.
The SSL cert is installed directly on your application server and not managed by a front-end proxy.
You are not implementing HSTS. (If you are you would need to redirect to HTTPS on the same host first and ensure you have a SSL cert installed on each domain.)

Try the following instead, near the top of your .htaccess file:
RewriteEngine On

# Redirect non-canoncial hostname
RewriteCond %{HTTP_HOST} !^www\.all-service-musical\.com$
RewriteRule (.*) https://www.all-service-musical.com/$1 [R=302,L]

# Redirect to HTTPS
# NB: This only applies if the canonical hostname is requested over HTTP
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=302,L]

As mentioned above, only change the 302 to 301 once you have confirmed it works OK - to avoid issues with the browser cache.


Fundamental Theorem of Algebra for fields other than $\Bbb{C}$, or how much does the Fundamental Theorem of Algebra depend on topology and analysis?

Question: When proving the Fundamental Theorem of Algebra, we need to appeal to analytic and/or topological properties of $\Bbb{C}$ and $\Bbb{C}[z]$. Is this going to be necessary in general, and if so, to what extent?
That is, suppose a field $K$ is given, and we desire to show that $K$ is algebraically closed. Is there any amount of purely algebraic data (save that $K = F^{alg}$ for some field $F$) that will allow us to say that $K$ is algebraically closed? Of course, the phrase "purely algebraic data" isn't well-defined, but I loosely mean information about $K$ in relation to fields $E_i$ of which $K$ is an extension, such as the degrees of the extensions $K/E_i$, if $K = E_i(\alpha)$ for some $\alpha\in K$, their Galois groups $\operatorname{Gal}\left(K/E_i\right)$, what $\operatorname{char}K$ is, and so on (where this information isn't precisely the information that $K$ is constructed as the algebraic closure of some field).
If this isn't possible, at what point does it become necessary to appeal to the topology and analysis of $K$ and $K[x]$, and how does this "point" depend on $K$? I realize that exactly how and where analysis and topology come into play for different $K$ will depend on the nature of the $K$ with which one is working, but I would be interested in knowing what properties of $K$ have the greatest effect on the necessity of analysis and topology in a proof that $K$ is algebraically closed. Of course, the more general these properties, the better.
A note: this question deals with this idea to some extent, although the discussion there is more focused on $\Bbb{C}$, and I would like to consider a more general setting: the conditions required to show a certain type of field is algebraically closed, and how those conditions differ for different types of fields.
Comment: There are, frankly, very few fields that are algebraically closed *other* than by definition.  Most algebraically closed fields are introduced as being algebraically closed. Exceptions are the complex numbers, for which you need analysis, and the union of the Laurent series fields ${\mathbf C}((X^{1/n}))$ over all $n \geq 1$, for which knowledge of ramification is used. Also the algebraic numbers are algebraically closed, but this is almost "by definition" if you grant the transitivity of algebraicity for field extensions, so it has a lot less meat to it than proofs for the other two fields.
Comment: Dylan, yes, ${\mathbf C}$ is the complex numbers. I despise blackboard bold in LaTeX.
Comment: @Dylan, KCd is posing (1) the complex numbers and (2) the union of Laurent fields, as two distinct examples of where algebraic closure arise naturally (not by definition, roughly) - he is not posing (2) as a requirement for seeing item (1). (This is seen by observing the comma structure in the sentence.)
Comment: I don't think there is a clean-cut answer to what properties have "the greatest effect" on proving the field is alg. closed if it isn't so by definition.
Comment: @KCd What do you mean when you say you need the Laurent series fields $\Bbb C((X^{1 / n}))$ to show $\Bbb C$ is algebraically closed? Or am I misunderstanding you?
Comment: Okay, that makes a lot more sense. So what is the bold $C$? Is it the complex numbers?
Comment: $\mathbb{R}$ is _defined_ by its order and Dedekind-completeness properties -- so it should be no surprise that if we are to prove something about $\mathbb{R}$ which doesn't follow from just the field and order axioms (other than the Dedekind one), and so of its derived (non-ordered but topologically related) field $\mathbb{C}$, we will have to invoke the Dedekind-completeness property at some point. And if you invoke Dedekind-completeness, you're doing analysis almost by definition.
Answer: this is borrowed from the comments in the link to the question you posted:
Let $F$ be a field of characteristic $0$, and $K / F$ be a finite Galois extension. Suppose every polynomial of odd degree in $F[x]$ has a root in $F$, and every polynomial of degree $2$ in $K[x]$ has a root in $K$. Then $K$ is algebraically closed.
Also, it turns out that algebraically closures are rarely finite extensions. In fact, if $F$ is a field and $C / F$ a finite extension that is algebraically closed, then $C=F(i)$ where $i^{2}=-1$, and $F$ has characteristic $0$. Also for every nonzero $a \in F$, either $a$ or $-a$ is a square, and finite sums of nonzero squares are nonzero squares. The source for this is Keith Conrad's notes:
http://www.math.uconn.edu/~kconrad/blurbs/galoistheory/artinschreier.pdf
Answer: There's one other way of getting an algebraically closed field: start with $\mathbb F_p=\mathbb Z/p\mathbb Z$, and adjoin an $m$-th root of unity for every natural number $m$ relatively prime to $p$. In other words, adjoin all possible roots of unity to $\mathbb F_p$. That's the construction, and now, of course, there's the exercise of showing that the result is indeed algebraically closed.
Answer: As is very common to note, the Fundamental Theorem of Algebra is not a theorem of algebra, but of the analysis of $\mathbb R$ and $\mathbb C$. It is the result that "by adjoining a solution to the equation $x^2+1=0$ and closing under field operations, once obtains precisely all solutions to all polynomials with coefficients in this new field".
To address your second paragraph, I don't think there is a lot of hope here. There is no information in the extension $K:K$, and I don't see how information about the extensions over proper subfields will capture $K$ being algebraically closed. I don't have a good argument though or a particular convincing counter example.
To address your third paragraph, there is immediately a big problem here. If $K$ is an arbitrary field, then there isn't necessarily any topology on $K$, so for general fields the question doesn't even jump-start.
So, you need to have some topology present on a field $F$, and then ask if the topological properties of $F$ are strong enough to guarantee that adjoining a single solution to $x^2+1$ will result in an algebraically closed field. This seems horribly too general, but again, I don't have any clear argument or convincing examples.
So, my answer doesn't actually answer anything, but rather tries to clarifies the situation, hoping others will contribute more insightful answers.
Comment: I disagree with your first sentence. There are purely analytic proofs of the FTA (every holomorphic map $\mathbb{P}^1\to\mathbb{P}^1$ is surj.) but the most illuminating proofs of the FTA are those that combine the alg. and analytic. For example, while the creation of $\mathbb{R}$ can be motivated almost entirely with an analytic flare (the completion of a metric space) the creation of $\mathbb{C}$ is, in the majority of instances, motivated by algebraic terms--wanting to solve equations. So, I don't think we can say the FTA is a theorem about either analysis or algebra, but one about both.
Comment: @AlexYoucis I see your point. I agree with the slightly schizophrenic nature of the theorem. While the sophisticated proofs all tell you something nice and illuminating about the theorem, I find the straightforward proof (basically, a maximum modulus analysis without any of the deep theorems (since when the function is a polynomial you don't need anything deep)) is most illuminating. I learned several proofs of the FDA, and several years later came across the simple proof. I now consider the sophisticated proofs as using a rocket to kill a fly.


Cloning an LVM disk with dd?

Question: I would like to clone a smaller LVM-formatted disk onto a larger one using dd, and boot that disk in the same machine. Do I need to make any special considerations for LVM?
Thanks! Although I considered the cool on-the-fly migration, where a second drive is added to an LVM volume and then LVM is told to remove the original drive from the volume, I decided my system would be much more likely to boot (and fully backed up, on the original disk) if I simply cloned the disk with dd, moved the new drive over to the first channel, removed the old drive, booted, added another partition in the new free space, added that partition to the original, smaller LVM volume, and used resize2fs to make the new space available to the filesystem. This worked great.
Answer: If a block for block copy, no.  You'd later extend the volumes using the unused space.
Comment: I won't even confuse LVM if I leave the original disk in the system?
Comment: No but you'd have to be considerate of your BIOS boot order if things don't perform as expected.
Comment: Additionally, trying to boot the secondary disk 'sdb' using the installation configured for the primary 'sda' would not boot after copy.  For the initial dd, it should be fine.  Otherwise, the boot disk would have to be on the same channel as before to operate as expected without changes.
Answer: Having the same volume group name will confuse LVM. Make sure you change the original's name with vgrename if you keep the original disks in the system.
Answer: Cloning a disk completely confuses lvm.  I made an exact copy (with dd) of a LVM partition onto another disk, and lvm started using the copy instead of the original!
Comment: Isn't that the point?

Cloning an LVM disk with dd?


How can I show this equality between inverses of functions?

Question: Let $f:X\to Y$ be a function between metric spaces $X$ and $Y$. Show that for any $B\subset Y$, $f^{-1}(B^\complement)=(f^{-1}(B))^\complement$.
I was able to show that they both map to $B^\complement$, but I know that that's not enough to prove equality. By definition, $(f^{-1}(B))^\complement = X \setminus f^{-1}(B)$. We know that $f^{-1}(B)=\{x\in X: f(x) \in B\}$ so all $\{x\in X : f(x) \notin B\} = f^{-1}(B^\complement)$. So, taking $f(f^{-1}(B^\complement))=B^\complement$. Taking $f[(f^{-1}(B))^\complement] = f(X\setminus f^{-1}(B)) = Y\setminus B = B^\complement$. So, $f^{-1}(B^\complement)\subseteq (f^{-1}(B))^\complement$ since $f^{-1}(B^\complement)\not\subset B$ and $(f^{-1}(B))^\complement\subseteq f^{-1}(B^\complement)$ since they both map to $B^\complement$. I am not sure if this is all correct, so any suggestion would be greatly appreciated. Thanks!
Answer: Your $f^{-1}(B^\complement)\not\subset B$ is true but probably not what you meant, since the lefthand side is a subset of $X$ and the righthand side a subset of $Y$.
In any case you're making it much too hard: $x\in f^{-1}[Y\setminus B]$ iff $f(x)\in Y\setminus B$ iff $f(x)\notin B$ iff $x\notin f^{-1}[B]$ iff $x\in X\setminus f^{-1}[B]$.


Std::Array with unique_ptr

Question: I have an class which I wish to instantiate by passing an array of values. The object here has two members but this has been reduced for illustration. In the future I will read values from disk and then create an object from those values, hence the array. The object will have multiple pointers later on hence the shared_ptr.
Firstly, I would like to know if this would prevent memory leaks as is. Secondly, I would like to know if there is are less bloated ways of instantiating objects and then determinsitically destroying them later on.
Class Header file:
//MyClass.hpp
#pragma once
#include "stdafx.h"
#include <array>

class SimpleClass{
    private:
        //Per object
        double var1;
        double var2;
    public static:
        //For calling when using templates such as std::array<>
        //Using __int8 as will not be > 256
        static const uint8_t varCount 2;
        SimpleBody(std::array<double, varCount> inputArray);
        ~SimpleBody();
}

Class Implementation
//MyClass.cpp
#pragma once
#include "stdafx.h"
#include <array>
#include "body.hpp"

SimpleBody::SimpleBody(std::array<double, SimpleBody::varCount> inputArray ) {
    //Assign var1
    MyClass::var1= inputArray[0];
    //Assign var2
    MyClass::var2= inputArray[1];
};

SimpleBody::~SimpleBody() {
    //Add in code here when children need deleting
};

Entry Point
// EntryPoint.cpp
//

#include "stdafx.h"
#include "MyClass.hpp"
#include <array>
#include <memory>

int main()
{
    //Create an array with a smart pointer for memory management
    std::unique_ptr< std::array<double, MyClass::varCount> > initArray =
        std::make_unique< std::array<double, MyClass::varCount> >();
    //Define values
    *initArray = { 1.0,2.0 };
    //Use array to create object
    std::shared_ptr<MyClass> object = std::make_shared<MyClass>(*initArray );

    //Free memory
    initArray.reset();
    object.reset();

    return 0;
}

Comment: I can't make any sense out of your question but I think you need to spend some time studying the basics of C++.
Comment: @Flash_Steel that's just being pedantic. The whole concept behind this RAII view is so that you can forget about them and concentrate on what is important.
Comment: Rather than release early I think it would be better to limit the *scope* of the smart pointers. Otherwise you can end up dereferencing null smart pointers or having to always check if they are not null. My suggestion would be, as far as possible, create them as not-null and don't null them before their scope ends.
Comment: you dont need to manually free the memory of unique and shared ptr. They will do it themself.
And you always derefernce your unique ptr array. You can just keep it on the stack that way instead of instantiating it on the heap.
Comment: A friend of mine who has worked as a developer for some time once told me that it's better to explicitly free memory when you know you don't need it and then when you forget then the smart_ptr funcionality can act as a safety net. Is that him just being pedantic or are there times when relying on smart_ptr's to free memory can cause memroy leak?
Comment: From what you have shown, there is no need for the smart pointers anyway.
Comment: @juanchopanza Objects of MyClass will contain many more members which are non-primitives.
Comment: @Flash_Steel That's not pedantry, it's being silly.
Comment: @Flash_Steel That doesn't matter.
Comment: It's worth resetting unique_ptr etc early if they are pointing to large amounts of data, *and* the variable is going to be long lived.  In this case, I wouldn't bother - it just adds complexity to your code
Answer: First of all its bad if you pass the array by value in the SimpleBody constructor. Better use a reference
 SimpleBody(const std::array<int, varCount> &inputArray);

At the moment, you construct your shared_ptr the unique_ptr looses the ownership of the array. You don't need to do reset manually. Also, at the moment, your program hits the } line, the memory will be freed.
Answer: In your example you could skip the unique pointer because you only want the values anyway
int main()
{
    std::array<double, MyClass::varCount> initArray = { 1.0,2.0 };
    std::shared_ptr<MyClass> object = std::make_shared<MyClass>(initArray );
    return 0;
}

This would do the same.
For "less bloated":
There is always auto:
int main()
{
    auto initArray = std::make_unique< std::array<double,  MyClass::varCount> >();
    *initArray = {1.0,2.0};
    auto object = std::make_shared<MyClass>(*initArray );
    return 0;
}

Comment: Less bloated could well be `MyClass({{1., 2.}});`. Difficult to say because most of OP's code seems to have no reason.
Comment: well I assumed the shared_ptr necessary and that you put an array in there. But year for OP code this would be the least code.

Std::Array with unique_ptr