How to export Accurev to another VCS?

Question: Does anyone know an easy way of exporting an Accurev 'depot' and its full history to, for example, git or mercurial?  Or even via a 3rd party system?  Unless I'm missing the obvious, I can't find anything via google.
If not, a bonus question, is it possible to build a git/mercurial repository based on patches with specific timestamps?  In other words, just make accurev dump its history as a set of patches and import them into a repository.
Comment: This has been asked a while ago and hasn't been updated. @pareley72's answer is most recent and should be considered by anyone viewing this question.
Comment: Thanks, but you spelled my name wrong!
Answer: @jtalbott is definitely correct regarding the difficulty in fully converting the history of an AccuRev depot into another SCM, including git. However, if you're willing to live with converting a single stream (be it your depot's "root" stream or any other stream you decide to  use as the conversion basis), have a look at https://github.com/rlaneve/accurev2git/. Note that is a very, very naive implementation, will take quite a bit of time for any sizable depot, and will thrash your hard drive excessively during the conversion. But, it does work, and I've used it to convert at least a couple of dozen AccuRev depots into git repositories.
Disclaimer: I wrote the tool a couple of years ago because I couldn't find an existing tool.
Comment: Thanks.  Something similar to what I've written in Python.
Answer: Check out ac2git, a much more fully-featured Python conversion tool than ryan-laneve's accurev2git although we credit him with the original concept.
Answer: Your best bet in moving to another tool is going to be extracts from streams (or snapshots) and importing into the other tool. You won't have transactional annotate, log, etc, but you'll be able to build up history that way, and keep AccuRev around in case you need to go check something that wasn't specifically migrated.
AccuRev's Timesafe architecture guarantees that the requisite history is available to you, but much like migrating into AccuRev is traditionally done with baseline imports, I'd suspect that your cost/benefit ratio in doing the reverse wouldn't ever lead to full history as an option.
Comment: Unless one was already written for you. See [ac2git](https://github.com/orao/ac2git). I have spent the time to export AccuRev to Git because I want to get rid of it that much. Additionally, I do export the **full history** and even attempt to make it useful by mapping it to the git branching model as best as I can. It is still not perfect but it will be close enough for most people.
Answer: Since the AccuRev paradigm is different from traditional branch-and-label tools, it would be a challenge to export a full history from an AccuRev depot into any other tool.  The data is certainly accessible from AccuRev's side, but you'd have to write a comprehensive, logical extraction routine to pull it into another system.  Anything that's been done by anyone else is probably very customized to their specific needs.  A baseline export, using point-in-time configurations from AccuRev streams would be more feasible and straightforward.
May I ask what the end goal is?  Would it be full migration away from AccuRev or are you just looking to be able to have users or teams make use of Git as a client instead of AccuRev?  I bring this up because AccuRev just recently introduced a full Git integration platform called Kando.  You can read about it yourself, but it might be what you're looking for.
Regards,
~James
Comment: Given your post history, it would seem that you are affiliated with Accurev. Please make sure to disclose any affiliation with the product in question.
Comment: @jtalbott I disagree. I would recommend from now on including your affiliation with certain products. You made a product recommendation, Kando, which you are clearly biased towards because of your affiliation.
Comment: Agreed with @vcsjones - you seem to be an Accurev employee.
Comment: @jtalbott  If kando allows me to clone an accurev depot as if it were a git repository, with full history, then this would be an accepted answer.

If kando merely provides the reverse, i.e. allowing acgui.exe and the CLI to run on top of a git repository, then this isn't a solution.

And in answer to your question the idea is to use other third party tools that do not work on top of accurev.
Comment: @jtalbott Thanks for confirming.  Then kando isn't a solution for us as we need full history (`git annotate`, `git log`, etc.).
Comment: @Barry No problem.  Your best bet in moving to another tool is going to be extracts from streams (or snapshots) and importing into the other tool.  You won't have transactional annotate, log, etc, but you'll be able to build up history that way, and keep AccuRev around in case you need to go check something that wasn't specifically migrated.
Comment: I am affiliated with AccuRev.  I don't feel the need to disclose that on every post since I do not link or advertise, I merely answer relevant questions.  Kando will Not export full history from AccuRev, the Git history would start at the point from which you clone the repo.  However, the end result is that the end users get to use Git and Git only as their client.  I'll let you take a look at Kando yourself to see if it's appropriate...
Comment: @jtalbott if you put your above comment as an answer, I'll accept that.  Thanks.
Comment: @jtalbott Your comment _"a full Git integration platform called Kando"_ is incorrect. It is **not** a **full** git integration if it doesn't have the full history. Until this is either rectified or your affiliation noted in your answer -1. In the interest of not being a hypocrite I'm the author of [ac2git](https://github.com/orao/ac2git).
Answer: AC2GIT conversion is one of the best conversion tool i have seen when it comes to accurev to git migration. very stable
https://github.com/orao/ac2git

How to export Accurev to another VCS?


Do piano composers often start out with C major?

Question: I'm wondering if composers write their pieces starting with C major since it's just the white keys, and then later transpose the finished song to the key of their choice?
Or will starting with the intended key from the start produce better results?
Edit: or "A minor" for minor songs
Comment: Can't work out why C is the *hardest* key for keyboard composers, I'm possibly happier in that than other keys. What makes you state that?
Comment: Since when has C major been "just the white keys", except for the simplest styles of music? In any case, C major is actually the *hardest* key for keyboard players, though many the people who write books on how to play by copying-and-pasting from other books don't seem to have learned that fact.
Comment: @alephzero - can't work out why C is the *hardest* key for keyboard players, I'm possibly happier in that than other keys. What makes you state that?
Comment: Funnily enough, a student asked me this today! Along with why certain composers worked in certain keys. Thought provoking.+1.
Comment: Speaking as a composer with a pretty lousy playing technique, I tend to start in E♭ as it just falls more easily under my hands. As I don't have to be able to play the resulting piece, I can later transpose it to wherever I like - usually a specific vocalist's key.
Comment: @Tim The statement was that C major is hard to _play._ See the remarks about piano playing in https://music.stackexchange.com/questions/32417/is-it-harder-to-play-in-a-key-with-more-flats-or-sharps, for example.
Comment: It would help to specify wether you're looking for an answer about alive, amateur composers, dead, legendary ones, or alive, professional ones. The answers here seem to assume the occasional one. Any slightly experienced musician will have no such complication as "just the white keys".
Comment: When I sit down to make up a song on the piano, I hit a single note note to begin, with no forethought, and whatever flows from there is the key it ends up being.  My very first song was in the key of F even though I started the song using 'the white keys'.  My second song was C (maj).  Whatever intervals and notes that I 'hear' in my head that come next is how the key and song progress.  I am not a professional or even amateur composer - I simply write songs because it's fun.  I'm also not a piano player - I just play what I feel and hear.  My primary instrument is the guitar.
Comment: As a weak piano player (and nothing like a composer in any possible sense) I have seldom seen pieces that only  "use the white keys", unless we are talking about the birthday song or pieces like that. Even fairly basic rock and roll tunes C-F-G will use C-maj-7, which already requires a B♭. I would be hard-pressed to recall any meaningful piano music that uses only the white keys.
Comment: As a side note, C major can be used for pieces that sound innocent and simple.
Comment: @DavidK: I find it curious that you (and alephzero) think C Major the *hardest* key to play in.  That certainly isn't my experience, running through pieces in various keys.  Maybe not the easiest to play in, but not the hardest.  Maybe it's the shape of our respective hands, but I've never observed any issue passing the thumb over or under any other in C Major (or, to be fair, any other key).  I will chalk it up to personal variation.
Comment: @BrianTung I didn't mean to imply that it is _hard_ to pass the thumb in C, just that you can get a slight advantage by using a black key. I suspect the most difficult _pieces_ are not in C, but it doesn't follow that transposing those pieces to C would make them easier.
Comment: @DavidK: Thanks, I think I understand you clearly now.  Let me put it this way.  If I'm playing a 12-bar blues (jazz changes), I would not prefer not to play it in either C or G.  Empirically, there are plenty of keys I'd prefer C or G to.
Comment: For any particular set of chord changes, I suppose whatever key(s) we're accustomed to are easiest to play (including mental and physical difficulty together). Any other key involves the extra effort of transposition and learning new fingering. Consider the version of the Maple Leaf Rag in G [here](https://sites.google.com/site/cbspianolessons/music-to-practice/jazz/maple-leaf-rag)--I think I'd find it practically unplayable, not because it has too many white keys but just because I have so much muscle memory for playing it in A-flat.
Answer: I think this is one of those questions where the answer is "it depends."
I would imagine that many composers who are uncomfortable with black keys for whatever reason do compose in C major or a minor and then transpose.  On the other hand, composers who are not uncomfortable with black keys or who are writing to fit a particular range are probably more likely to compose in whatever key they want to end up in.
I myself fall into this latter category.  I almost never transpose after the fact.  If I start a piece out with mostly white keys I'm likely to leave it there.  But keys like B major and c# minor actually fit under my hands better, so I often start out and stay in something like that.  I also typically go through many modulations in a piece, in which case it hardly matters where I start!
Answer: Apart from what's already been said, it is somewhat dependent on the instrument the composer is using as a reference point. For example, a lot of guitar-based music - pop and classical, is composed in guitar-friendly keys, like E/Em and A/Am. If it's a sax player, they may well be in other keys rather than C, and that goes for all other transposing instruments too.
If the guy's a keyboard player, and good enough to compose and play, it probably doesn't matter to him what key the piece is in - often inspiration comes when messing about, and it could well be that it happens in E♭, B♭, A♭, D...
If it's orchestral work, then he's thinking and writing in many keys - unless he's 'cheating' and using Sibelius or such like to get the parts in key!
Some well-known composers had preferred keys - I think Cole Porter liked E♭, but don't know why. Others will just write in a key that suits either the instruments in question or the vocalists' voice ranges, straight into that key, as it's easier for most who have reached that level. There will always be those who only play in C, or compose in C, though.
Comment: Just realised you only asked about piano players! But most of this is relevant, so it'll stay for now.
Answer: I think there is an assumption in the question that the composer is sitting at a keyboard.  Why would that be?
I imagine a composer thinking of a tune and then writing it down without reference to a keyboard at all.  In that scenario he is free to chose any key he wants and I assume that he choses one that he feels is appropriate to the piece he is composing
Comment: I rather agree, however you can't really refute the fact that many people do indeed write music "on an instrument", and more let their thoughts/ideas be guided by what the fingers do than the other way around.
Comment: I think that the assumption in the question *is* that in this particular case, he's sitting at a keyboard, rather than using any other instrument.
Answer: I think that professional composers do not have this big problems writing their pieces in a key with black notes. Some people also perceive a piece in d minor differently than a piece in a minor, for example. On the other hand, I can imagine that many non-professional composers use this technique, but for my part, I never change the key of a piece after finishing it.
Comment: Beethoven was of the same mind - 'if you can't reach the notes I wrote, don't sing it!'
Answer: As @L3b said, there are a few different types of composers, and some are more comfortable with black keys than others. Some compose in an easy keyboard key and transpose, and some are comfortable in any key and would rather choose based on sound. I think most people who consider themselves piano players and compose a lot compose in the same keys they tend to play in, because that's what they are most practiced at and comfortable with.
Modes are also something to consider. A lot of music, especially pop, isn't just in major and minor. Mixolydian (major with a flat 7) is more popular than major or minor in a lot of genres that are derived from blues, so G is also a popular key. And there's a lot more out there in Lydian (major with a sharp 4) than most people realize.
If the composer composes most of their music for jazz bands with wind instruments, chances are most of it will be in B flat, E flat, F, G minor, F mixolydian, etc.
If the composer plays in a guitar-based rock band, they will probably use a lot of E, A, D, and G, and modes (major/minor/mixo) will not matter as much.
Still others, as has been mentioned already, are good keyboard players and feel better in keys that seem weird to non-keyboard-players like me (like C# major or Eb).
And, as @Jules said in the comments to this answer, some people prefer to use just the black keys, which is a pentatonic (5 note) scale.
I've met a number of composers (particularly in folk and vocal jazz) that do use C major and A minor almost exclusively to compose on keyboard and then transpose, so there are definitely those who prefer the white keys.
People also have different views on transposing. Some think it's heresy, and that changing the key of a song fundamentally changes the way you perceive it because of things like resonant frequency. Some (most) don't.
Basically, the way people compose is all of them.
Comment: Upvoted for the last paragraph.  Everyone's different, and it all depends on what they're used to.  I write rock, and as you suggest if I work on guitar the traditional E/A/D/G/maybe a bit of B thrown in for variety is a staple for that.  But if I sit down at a keyboard, I often find myself starting in Db or Bb minor. Why? Because that's how my first teacher taught me to use a pentatonic scale (i.e. *just the black keys*), and as a lot of what I do is still based on pentatonic scales I just find it easier to work that way.
Comment: @Jules In hindsight I can't believe I didn't mention the pentatonic scale, but yeah, that is another widely used style of composing on a keyboard.
Comment: Your 2nd para.: true, Mixolydian is well used, but why would it mean G is a popular key?
Comment: @Tim it's because the G mixolydian scale contains all of the same notes as the C Major (aka C Ionian) scale, so it uses the white keys on a piano keyboard, making it an easy key for composing. That is a good way to understand modes; C ionian (aka C major) has all of the same notes as D dorian, E phrygian, F lydian, G mixolydian, A aeolian (aka A minor), and B lochrian. Ionian, dorian, etc are the names of the "modes" of the standard diatonic scale that we use in modern music, and that keyboards are based on.
Comment: That's the main way I've taught about modes for the last 50 yrs! 'I Don't Play Like My Aunt Lou'.
Answer: I think that there are two subtleties contained in your question which I will try seperate out, them being:
Can the composer comfortably play in the key the song will/may end up in?
and
Is the difference in key significant to the composer?
A composer will probably be reluctant to compose a song on a instrument in a key which is difficult to play in. This is especially true if the composition process involves lots of improvisation; fumbling around in a difficult key would regularly interrupt flow. How comfortable a composer is in a given key depends on their instrument and virtuosity.
Your assumption about composing in C/Am on the piano (or any other keyboard instrument) because its the easiest to play would make sense in this case. When I compose on the violin for example, the songs will often be in D or A because these keys are simple enough for me to improvise in at my skill level. If I wanted, I could take a song I've improvised on the violin and translate it to a different key, but I would have to relearn it on the violin because the fingering and bowing (for string changes) would be different.
The second point about the keys being significant to the composer is more nuanced. When I compose on the piano, which I am far more technically competent than on violin (and hence more comfortable with black keys) the key I compose in is really important because every key is subtly different, to me.
This may not be true for everyone because, I would suspect, its related to having absolute pitch verse relative pitch. To me, a song in a different key is in a small way a different song. I have even translated songs to different keys as a way of exploring its mood and temperament in the same way I might change the rhythm or pace.
Other reasons the key may be significant is if you are singing a vocal line over the top, the key you sing in can drastically change how easy or hard a song is to sing. Singers are often changing the keys of songs in order to accommodate their vocal range and ability.
Its probably also worth pointing out that the experience of playing on each of these instruments is very different to me. For me, playing a piece of music on the violin consists of fingering and bowing coming together to make a song and is hence very technical and rigid (key-wise). Whereas for piano I have moved from worrying about fingers on notes, to notes in a more general sense (I think notes and fingers work it out on the fly). This gives me the freedom to experiment more and so I can compose within a key of my choosing. Although keys with lots of black notes can become cumbersome compared to C/Am, I actually find the different feel adds to the creative process.
As an aside, my piano teaching growing up used to talk about each of the keys having a different personality and that A or D were hymnal keys (sounding like religious music suitable for worship), which I found kind of funny since many hymns are actually written in Eb and Bb (although our definition of frequency for each pitch has changed over time).
Answer: For me, I always start out in the key that I want to have the piece end up being in. That way, I don't have to go through the effort of trying to transpose it all later. I don't find it any more difficult to start on a key that's all white notes, and I don't really see the advantage that this would give.
Starting with the intended key may produce better results in that it helps you feel the piece of music that you are writing better. For example, when I start writing a piece of music, I often choose the key that I feel best suits the licks/motif I want in the music. So, if I start off in the beginning writing in the key I want, then it's easier to just keep things sounding in that key. Transposing the piece to a whole new key at the end would just throw me off.
Of course, this is just me -- other people may feel differently.
Answer: The choice of the key will definitively be influenced by how the fingering of the specific key works in relation to what the music is trying to achieve. The composer will have to consider how the efficiency of the hand movements is influenced by the choice of keys.
There is also the choice of the enharmonic keys, like B Major and Cb Major, where a choice would have to be made between five sharps and seven flats. Here the fingering is the same because the notes are the same but there is a real paradigm shift that needs to be made between thinking in terms of flats and in terms of sharps.
Seeing that pianist have to learn the fingering for all the keys as soon as possible most composers will assume that the skilled pianist will not be deterred by any key the composer may choose and would rather choose the most appropriate key for his composition.
It is at least in a trivial manner true that beginner music is done in C Major but C Major fingering is probably not the easiest, is just a convenient starting point to start teaching piano when the pupils scale knowledge is still lacking.


Do I need the project test to be accepted into the app store?

Question: I saw that there was a project test in the application right at the bottom of the page, Do i need to have that file to be able to be accepted in iTunes and what is that by the way?
How do I remove it if needed?
And lastly both the files are highlighted red, is that normal?
Answer: No, you do not need the Test project to submit your app to Apple. It is merely added for your convenience since most projects need some amount of unit testing. But it's purely optional. You can remove it either from Xcode or Finder.
And yes, it's OK for items under the "Products" section to be red. That just means that the product(s) haven't been built yet. You can ignore that. They will turn from red to black after you deploy to device or Archive the project later.
Comment: Cool, and the Test project had errors, I cleared it but if I send the project to apple with the Test project in the app, will it be a problem?
Comment: You should fix the errors (otherwise how will you run your app?). But to answer your question, Apple doesn't care whether or not you have Test project. As I said above it's 100% optional. I regularly ship apps that do not have the Test project.


Show that $y_2(t)=e^{-t^2/2}\int_0^te^{s^2/2}ds$ is a solution of $y"+ty'+y=0$

Question: Show that

$$y_2(t)=e^{-t^2/2}\int_0^te^{s^2/2}ds $$ is a solution of
$$ y''+ty'+y=0 $$

I seem to be making a mistake somewhere in my calculations, and I was hoping someone could tell me where exactly I am making the mistake:
$$y_2(t)=e^{-t^2/2}\int_0^te^{s^2/2}ds$$
$$y_2'(t)=e^{-t^2/2}(\int_0^te^{s^2/2}ds)'+(e^{-t^2/2})'\int_0^te^{s^2/2}ds$$
$$=e^{-t^2/2}(e^{t^2/2}-e^0)+(-te^{-t^2/2})\int_0^te^{s^2/2}ds$$
$$=e^{-t^2/2}(e^{t^2/2}-1)+(-te^{-t^2/2})\int_0^te^{s^2/2}ds$$
$$=1-e^{-t^2/2}+(-te^{-t^2/2})\int_0^te^{s^2/2}ds$$
$$y''_2(t)=0-(e^{-t^2/2})'+(-te^{-t^2/2})(\int_0^te^{s^2/2}ds)'+(\int_0^te^{s^2/2}ds)(-te^{-t^2/2})'$$
$$y''_2(t)=te^{-t^2/2}+(-te^{-t^2/2})(e^{t^2/2}-e^{0})+(t^2-1)(e^{-t^2/2})\int_0^te^{s^2/2}ds$$
$$y''_2(t)=te^{-t^2/2}+(-te^{-t^2/2})(e^{t^2/2}-1)+(t^2-1)(e^{-t^2/2})\int_0^te^{s^2/2}ds$$
$$y''_2(t)=te^{-t^2/2}+(-t+te^{-t^2/2})+(t^2-1)(e^{-t^2/2})\int_0^te^{s^2/2}ds$$
$$y''+ty'+y=0$$
$$[te^{-t^2/2}+(-t+te^{-t^2/2})+(t^2-1)(e^{-t^2/2})\int_0^te^{s^2/2}ds]+t[1-e^{-t^2/2}+(-te^{-t^2/2})\int_0^te^{s^2/2}ds]+[e^{-t^2/2}\int_0^te^{s^2/2}ds]$$
$$te^{-t^2/2}+(-t+te^{-t^2/2})+(t^2-1)(e^{-t^2/2})\int_0^te^{s^2/2}ds+t-te^{-t^2/2}+t(-te^{-t^2/2})\int_0^te^{s^2/2}ds+e^{-t^2/2}\int_0^te^{s^2/2}ds$$
$$=te^{-t^2/2}$$ But it is supposed to equal 0
If you could point out my calculation error or mistake in technique I'd appreciate it.
Comment: **Hint:** What is $d/dt \left( \int_0^te^{s^2/2}ds\right)$?
Answer: Notice this
$$ \left( \int_0^te^{s^2/2}ds\right)' = e^{t^2/2} $$
not
$$ \left( \int_0^te^{s^2/2}ds\right)'=e^{t^2/2} - 1 $$
Note:

$$ \frac{d}{dt}\int_{a}^{t} f(u)du  = f(t).$$
Comment: Oh right! I was making the mistake of $e^{t^2/2}-e^{0^2/2}$ when it should have been $e^{t^2-0^2/2}$ right?
Comment: @MathMajor: Do not worry it happens with all of us! Good job.
Comment: @MathMajor: I already gave you the correct answer! Not what is in your comment.
Answer: the $y$ defined by $$ye^{t^2/2} = \int_0^t e^{s^2/2} \, ds \tag 1$$
satisfies the differential equation  $$y'' + 2ty' + (1+t^2)y = 2t. \tag 2$$
differentiating $(1)$ you get $$y'e^{t^2/2} + tye^{t^2/2} =e^{t^2/2} .\tag 3 $$
differentiating $(3)$ you get $$y''e^{t^2/2} + 2ty'e^{t^2/2} + y\left(e^{t^2/2} + t^2e^{t^2/2}\right)  =te^{t^2/2} $$ clearing $e^{t^2/2}$ gives you $(2).$


Fourier transformation of $e^{-ax^2}$

Question: Find the Fourier transformation of $e^{-ax^2}$, for any constant $a>0$. In general, $$\int \frac{1}{\sqrt{(2\pi \sigma^2)}}e^{-\frac{(x-\mu)^2}{2\sigma^2}} e^{-iλx }dx = e^{-i\muλ-\frac{1}{2}\sigma^2t^2 }$$ holds.
Apparently, the result can be used to solve the heat equation. I have tried to do it as below $$ \frac {1}{2\pi} \int_{-\infty}^{\infty} e^{-ax^2}e^{iλx} dx $$  After some calculations, I got $\frac {1}{\sqrt{4\pi a}}e^{-\frac{λ^2}{4a}} $. But I looked up on the internet and there are some notes show that it should be $\frac {1}{\sqrt{2 a}}e^{-\frac{λ^2}{4a}} $.
Edit: I found that the notes I saw on the internet use $ \frac {1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} e^{-ax^2}e^{iλx} dx $ instead of $ \frac {1}{2\pi} $. Maybe that's the reason. But why the notes provided by my lecturer used $ \frac {1}{2\pi} $? Are there no standard form?
Comment: Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match [many users' quality standards](http://goo.gl/mLWc8), so it may attract downvotes, or be put on hold. To prevent that, please [edit] the question. [This](http://goo.gl/PlJyVQ) will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers.
Comment: Your answer is not correct. If you show us your work we can show where the mistake is.
Comment: @Kavi Rama Murthy I made a typo, my calculations should start from $ \frac{1}{2\pi}$instead of $\frac{1}{\sqrt{2\pi}}$
Answer: By linear transformations it's sufficient to check the case $\mu=0,\,\sigma=1$, so we want to prove $$\phi(t):=\int_{\Bbb R}\frac{1}{\sqrt{2\pi}}\exp\bigg(-\frac{x^2}{2}+itx\bigg)dx=\exp-\frac{t^2}{2}.$$By inspection $\phi(0)=1$, so it suffices to prove the following is $0$: $$\frac{d\phi}{dt}+t\phi(t)=\int_{\Bbb R}\frac{1}{\sqrt{2\pi}}(ix+t)\exp\bigg(-\frac{x^2}{2}+itx\bigg)dx=\Bigg[-\frac{i}{\sqrt{2\pi}}\exp\bigg(-\frac{x^2}{2}+itx\bigg)\Bigg]_{-\infty}^\infty.$$

Fourier transformation of $e^{-ax^2}$


Is there an amp power formula?

Question: I'm looking to buy a new amp for my keyboards, and I was wondering if there's a formula I can use to help me calculate some of the objective specs I should look for. Something along the lines of: I usually play on square-room venues, of A' x B' dimensions, for C number of people.  What wattage does my amp need to be loud enough for the room?
Of course, this doesn't account for the subjective "feel" of the amp, but I'm wondering if such a formula exists.
Answer: This question made me think of The 12-Volt.
It was the first thing that came to mind, and I personally hope someone could find some opensource-recourse/resource.  Is this the right direction,
-Thanks

Is there an amp power formula?


Please recommend a good D-Bus tutorial (Linux C GTK+)

Question: Yes, I have done a search yet found only partly working stuff. It seems to be a real maze. E.g.:

Why do they even use g_main_loop_run()? Is it really necessary when the GTK+ program has already entered the main loop by gtk_main()?
How should the path, the interface name and the signal name look like when invoking such functions like dbus_bus_request_name(), dbus_message_new_signal(), dbus_bus_add_match(), dbus_message_is_signal() ...?
How afterwards should the names be correctly set in the /etc/dbus-1/system.conf file to even allow the program to use the the D-Bus interface? Surprisingly all tutorials I found simply forget to mention  at all you need to edit it.
How the messages could be caught asynchronously? Should it be done somehow like in a separate thread?

Please recommend any good GTK+ D-Bus example which could help to learn how to use it.
Answer: gtk_main is calling  g_main_loop_run(), you should look into file gtk/gtkmain.c to find out.
Googling for dbug_bus_request_name gives several examples, notably dbus-example.c
And you should read a good gtk tutorial to have an idea of what signals and slots mean in the context of Gtk.
Googling for d-bus tutorial gives this dbus tutorial
At last, a good idea is to find and study the source code of the relevant free software. GtkApplication examples are calling dbus code.


dojo borderlayout show all the content , flicker then redraw correctly

Question: I copied an example from the dojo site using Borderlayout. However, when I load in the browser , the entire data is  shown for all the section  . Then after a few second the content is refersh and the data is displayed correctly.
here is code that i copied . Thanks for your help

    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.3/dijit/themes/tundra/tundra.css">

            Hi

            Hi, I'm center

Answer: This looks a bit upside down : you should put your javascripts in the head section and load the dojo libraries in first place. That's not your problem though.
What happens is that when the page loads, dojo loads all the modules that you "dojo.require", then parses all your tags containing the attribute "dojoType" and processes them for rendering, and this takes time.
So the flickering that you're seeing is the difference between the page before and after the widgets are parsed.
You should add a preloader div and hide it once the page is parsed (see this example).
This is what it would look like for your example :

        <title>Preloader example</title>

        <!– every Dijit component needs a theme –>
        <link rel="stylesheet"
                href="http://o.aolcdn.com/dojo/1.4/dijit/themes/soria/soria.css">

        <!– load Dojo, and all the required modules –>

Hi

I'm Center

Answer:

if(dojo.isIE){
    addEvent(window, 'load', function(event) {
        dojo.parser.parse();
    });
}else{
    dojo.addOnLoad(function(){
        dojo.addOnLoad(function(){
            dojo.parser.parse();
        });
    });
}
function addEvent( obj, type, fn ) {
  if ( obj.attachEvent ) {
    obj['e'+type+fn] = fn;
    obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
    obj.attachEvent( 'on'+type, obj[type+fn] );
  } else
    obj.addEventListener( type, fn, false );
}

disable parseOnLoad and manually add event to parse widgets for ie.


Find the maximum integer value $n$ such that $2^n\mid 3^{1024} -1$

Question: Since $2^{10} = 1024$ then we can $3^{1024}-1 = ( 3 - 1 )\Pi_{i=0}^{9} {3^{2^i}+1}$
And then we can start eliminating the $3-1=2$ and $(3^2-1)= 2\times 5$
But then? I guess I could calculate, but this is not different as starting calculating in first place.
What is a better method?
Comment: Repeated Difference of Squares
Answer: Hint
For $i \geq 1$ you have:
$$3^{2^i}+1 \equiv (-1)^{2^i}+1 \equiv 1+1 \equiv 2 \pmod{4}$$
Comment: Note the question is asking about $3^{1024} - 1$, not $3^{1024} + 1$.
Comment: @JohnOmielan yes, and as the OP posted $$3^{1024}-1 = ( 3 - 1 )\Pi_{i=0}^{9} (3^{2^i}+1)$$
Comment: Sorry for not noticing that. I appreciate you explaining it to me.
Answer: Hint $1$:
Note that $1024=2^{10}$
$$3^{2^{10}}-1=(2+1)^{2^{10}}-1=\sum_{k=0}^{2^{10}-1}\dbinom{2^{10}}{k}$$
Hint $2$:
$3^{1024}-1$ is the difference of squares. Consider the factors to get the answer.
Comment: I consider the factors but, I didnt know how to proceed when I have $(3-1)(3+1)(3^2 +1)...(3^{512}+1)$
Comment: Also you have a litte error in the powers
Comment: @MariaGuthier You can write $3^{1024}-1$ as $(3^{512}+1)(3^{512}-1)$ and $3^{512}-1$ as $(3^{256}+1)(3^{256}-1)$ and so on.... and you will get the final answer as $12$
Answer: In general, the order of $3$ mod $2^n$ is $2^{n-2}$ for $n\ge3$ (*). Therefore, the value you seek is $12$.
(*) This follows from $3^{2^{n-3}} \equiv 2^{n-1}+1 \bmod 2^n$, which can be proved by induction.


Feature selection for random Forest using rfcv in R package

Question: I am running randomForest regression. My observation number is 70 and independent variables is 122. For variable selection for the final model, I combined rfcv() function and Importance(randomForest) function. For example, if the model with six variables has lowest OOB error based on rfcv. Then the final model will have the six most importance variable based on Importance function.
I wonder that whether my approach is appropriate or not?
Answer: Using the cv values from randomforest is a valid approach to feature selection, if you've selected sensible settings for your oob sampling.
However, with only 70 observations you're not going to get great results. For one, it's really hard generate enough "folds" to get a meaningful validation number while still having enough data to build the forest.
Random forests work best when there are a lot more than 70 rows to sample from - I don't know how many trees you're using (and at what depth), but you'll quickly run out of unique 'draws' at each decision point and you'll see suboptimal performance.
The real challenge of your situation is how to do variable selection without many input rows. A traditional approach to this kind of situation would be a penalized linear regression, like ridge or lasso. These tend to perform best for variable selection in cases with very little input.
All this being said, given the very small amount of data you are working with, it's going to be really hard to get a good model even if you use the most sophisticated techniques.


The bar in the d3 graph is going out of range and i am not able to select it using a brush

Question: I have created a d3 graph to show the event count per day so the xaxis shows date and y axis shows count. I have also included brush event to filter data accordingly. but the last bar is shown outof range and i am not able to select it using brush. Now how can i make it look proper. I am adding an image of it and code too ... Everything is coming fine except the selection. please help me out. thanku :)
var data = document.getElementById('eventCountList').innerHTML;
        flights = JSON.parse(data);
        // Various formatters.
        var formatNumber = d3.format(",d"), formatChange = d3.format("+,d"), formatDate = d3.time
                .format("%B %d, %Y"), formatTime = d3.time
                .format("%I:%M:%S %p");

        // A nest operator, for grouping the flight list.
        var nestByDate = d3.nest().key(function(d) {
            return d3.time.day(d.date);
        });

        // A little coercion, since the CSV is untyped.
        flights.forEach(function(d, i) {
            d.index = i;
            console.log(d.eventTimeGmt);
            d.date = parseDate(String(d.eventTimeGmt));
        });

        // Create the crossfilter for the relevant dimensions and groups.
        var flight = crossfilter(flights), all = flight.groupAll(), date = flight
                .dimension(function(d) {
                    return d.date;
                }), dates = date.group(d3.time.day), second = flight
                .dimension(function(d) {
                    return d.date.getSeconds();
                }), seconds = second.group(Math.floor), minute = flight
                .dimension(function(d) {
                    return d.date.getMinutes() + d.date.getSeconds() / 60;
                }), minutes = minute.group(Math.floor), hour = flight
                .dimension(function(d) {
                    return d.date.getHours() + d.date.getMinutes() / 60;
                }), hours = hour.group(Math.floor);
        var charts = [

                barChart().dimension(second).group(seconds).x(
                        d3.scale.linear().domain([ 0, 60 ]).rangeRound(
                                [ 0, 10 * 60 ])),

                barChart().dimension(minute).group(minutes).x(
                        d3.scale.linear().domain([ 0, 60 ]).rangeRound(
                                [ 0, 10 * 60 ])),

                barChart().dimension(hour).group(hours).x(
                        d3.scale.linear().domain([ 0, 24 ]).rangeRound(
                                [ 0, 10 * 60 ])),

                barChart()
                        .dimension(date)
                        .group(dates)
                        .round(d3.time.hour.round)
                        .x(
                                d3.time
                                        .scale()
                                        .domain(
                                                [
                                                        new Date(
                                                                flights[flights.length - 1].eventTimeGmt
                                                                        .substring(
                                                                                0,
                                                                                4),
                                                                flights[flights.length - 1].eventTimeGmt
                                                                        .substring(
                                                                                5,
                                                                                7) - 1,
                                                                flights[flights.length - 1].eventTimeGmt
                                                                        .substring(
                                                                                8,
                                                                                10)),
                                                        new Date(
                                                                flights[0].eventTimeGmt
                                                                        .substring(
                                                                                0,
                                                                                4),
                                                                flights[0].eventTimeGmt
                                                                        .substring(
                                                                                5,
                                                                                7) - 1,
                                                                flights[0].eventTimeGmt
                                                                        .substring(
                                                                                8,
                                                                                10)) ])
                                        .rangeRound([ 0, 10 * 60 ])) /*.filter(
                                                                                [ new Date(2001, 1, 1), new Date(2001, 2, 1) ]) */

        ];

        // Given our array of charts, which we assume are in the same order as the
        // .chart elements in the DOM, bind the charts to the DOM and render them.
        // We also listen to the chart's brush events to update the display.
        var chart = d3.selectAll(".chart").data(charts).each(
                function(chart) {
                    chart.on("brush", renderAll).on("brushend", renderAll);
                });

        // Render the initial lists.
        var list = d3.selectAll(".list").data([ flightList ]);

        // Render the total.
        d3.selectAll("#total").text(formatNumber(flight.size()));

        renderAll();

        // Renders the specified chart or list.
        function render(method) {
            d3.select(this).call(method);
        }

        // Whenever the brush moves, re-rendering everything.
        function renderAll() {
            chart.each(render);
            list.each(render);
            d3.select("#active").text(formatNumber(all.value()));
        }

        // Like d3.time.format, but faster
        //2015-12-28 11:18:32
        function parseDate(d) {
            return new Date(d.substring(0, 4), d.substring(5, 7) - 1, d
                    .substring(8, 10), d.substring(11, 13), d.substring(14,
                    16), d.substring(17, 19));
        }

        window.filter = function(filters) {
            filters.forEach(function(d, i) {
                charts[i].filter(d);
            });
            renderAll();
        };

        window.reset = function(i) {
            charts[i].filter(null);
            window.poll.start();
            renderAll();
        };

        function flightList(div) {
            var flightsByDate = nestByDate.entries(date.top(40));

            div.each(function() {
                var date = d3.select(this).selectAll(".date").data(
                        flightsByDate, function(d) {
                            return d.key;
                        });

                date.enter().append("div").attr("class", "date").append(
                        "div").attr("class", "day").text(function(d) {
                    return formatDate(d.values[0].date);
                });

                date.exit().remove();

                var flight = date.order().selectAll(".flight").data(
                        function(d) {
                            return d.values;
                        }, function(d) {
                            return d.index;
                        });

                var flightEnter = flight.enter().append("div").attr(
                        "class", "flight");

                flightEnter.append("div").attr("class", "time").text(
                        function(d) {
                            return formatTime(d.date);
                        });

                flightEnter.append("div").attr("class", "sourceAddress")
                        .text(function(d) {
                            return d.sourceAddress;
                        });

                flightEnter.append("div").attr("class", "destAddress")
                        .text(function(d) {
                            return d.destAddress;
                        });

                flight.exit().remove();

                flight.order();
            });
        }

        function barChart() {
            if (!barChart.id)
                barChart.id = 0;

            var margin = {
                top : 10,
                right : 10,
                bottom : 20,
                left : 40
            }, x, y = d3.scale.linear().range([ 100, 0 ]), id = barChart.id++, axis = d3.svg
                    .axis().orient("bottom"), yAxisLeft = d3.svg.axis()
                    .scale(y).orient("left"), brush = d3.svg.brush(), brushDirty, dimension, group, round;

            function chart(div) {
                var width = x.range()[1], height = y.range()[0];

                y.domain([ 0, group.top(1)[0].value ]);

                div.each(function() {
                    var div = d3.select(this), g = div.select("g");

                    // Create the skeletal chart.
                    if (g.empty()) {
                        div.select(".title").append("a").attr("href",
                                "javascript:reset(" + id + ")").attr(
                                "class", "reset").text("reset").style(
                                "display", "none");

                        g = div.append("svg").attr("width",
                                width + margin.left + margin.right).attr(
                                "height",
                                height + margin.top + margin.bottom)
                                .append("g").attr(
                                        "transform",
                                        "translate(" + margin.left + ","
                                                + margin.top + ")");

                        g.append("clipPath").attr("id", "clip-" + id)
                                .append("rect").attr("width", width).attr(
                                        "height", height);

                        g.selectAll(".bar").data(
                                [ "background", "foreground" ]).enter()
                                .append("path").attr("class", function(d) {
                                    return d + " bar";
                                }).datum(group.all());

                        g.selectAll(".foreground.bar").attr("clip-path",
                                "url(#clip-" + id + ")");

                        g.append("g").attr("class", "axis").attr(
                                "transform", "translate(0," + height + ")")
                                .call(axis);

                        g.append("g").attr("class", "y axis").attr(
                                "transform", "translate(" + 0 + ")", 0)
                                .call(yAxisLeft);

                        g.append("text").attr(
                                "transform",
                                "rotate(-90 " + margin.left / 1.8 + " "
                                        + height / 2 + ")").style(
                                "text-anchor", "start")
                                .style("fill", "red")
                                .text("no. of events ");

                        /*
                        g.append("text")
                        .attr("transform", "translate(" + (width / 2) + " ," + (height + margin.bottom) + ")")
                        .style("text-anchor", "middle")
                        .text("Date");  */

                        /*  g.append("text")
                            .attr("transform", "rotate(-90)")
                            .attr("y", 0 – margin.left)
                            .attr("x",0 - (height / 2))
                            .attr("dy", "1em")
                            .style("text-anchor", "middle")
                            .text("no. of events"); */

                        // Initialize the brush component with pretty resize handles.
                        var gBrush = g.append("g").attr("class", "brush")
                                .call(brush);
                        gBrush.selectAll("rect").attr("height", height);
                        gBrush.selectAll(".resize").append("path").attr(
                                "d", resizePath);
                    }

                    // Only redraw the brush if set externally.
                    if (brushDirty) {
                        brushDirty = false;
                        g.selectAll(".brush").call(brush);
                        div.select(".title a").style("display",
                                brush.empty() ? "none" : null);
                        if (brush.empty()) {
                            g.selectAll("#clip-" + id + " rect").attr("x",
                                    0).attr("width", width);
                        } else {
                            var extent = brush.extent();
                            g.selectAll("#clip-" + id + " rect").attr("x",
                                    x(extent[0])).attr("width",
                                    x(extent[1]) - x(extent[0]));
                        }
                    }

                    g.selectAll(".bar").attr("d", barPath);
                });

                function barPath(groups) {
                    var path = [], i = -1, n = groups.length, d;
                    while (++i < n) {
                        d = groups[i];
                        path.push("M", x(d.key), ",", height, "V",
                                y(d.value), "h9V", height);
                    }
                    return path.join("");
                }

                function resizePath(d) {
                    var e = +(d == "e"), x = e ? 1 : -1, y = height / 3;
                    return "M" + (.5 * x) + "," + y + "A6,6 0 0 " + e + " "
                            + (6.5 * x) + "," + (y + 6) + "V" + (2 * y - 6)
                            + "A6,6 0 0 " + e + " " + (.5 * x) + ","
                            + (2 * y) + "Z" + "M" + (2.5 * x) + ","
                            + (y + 8) + "V" + (2 * y - 8) + "M" + (4.5 * x)
                            + "," + (y + 8) + "V" + (2 * y - 8);
                }
            }

            brush.on("brushstart.chart", function() {
                window.poll.stop();
                var div = d3.select(this.parentNode.parentNode.parentNode);
                div.select(".title a").style("display", null);
            });

            brush.on("brush.chart",
                    function() {
                        var g = d3.select(this.parentNode), extent = brush
                                .extent();
                        if (round)
                            g.select(".brush").call(
                                    brush
                                            .extent(extent = extent
                                                    .map(round)))
                                    .selectAll(".resize").style("display",
                                            null);
                        g.select("#clip-" + id + " rect").attr("x",
                                x(extent[0])).attr("width",
                                x(extent[1]) - x(extent[0]));
                        dimension.filterRange(extent);
                    });

            brush.on("brushend.chart", function() {
                if (brush.empty()) {
                    var div = d3
                            .select(this.parentNode.parentNode.parentNode);
                    div.select(".title a").style("display", "none");
                    div.select("#clip-" + id + " rect").attr("x", null)
                            .attr("width", "120%");
                    dimension.filterAll();
                }
            });

            chart.margin = function(_) {
                if (!arguments.length)
                    return margin;
                margin = _;
                return chart;
            };

            chart.x = function(_) {
                if (!arguments.length)
                    return x;
                x = _;
                axis.scale(x);
                brush.x(x);
                return chart;
            };

            chart.y = function(_) {
                if (!arguments.length)
                    return y;
                y = _;
                yAxisLeft.scale(y);
                return chart;
            };

            chart.dimension = function(_) {
                if (!arguments.length)
                    return dimension;
                dimension = _;
                return chart;
            };

            chart.filter = function(_) {
                if (_) {
                    brush.extent(_);
                    dimension.filterRange(_);
                } else {
                    brush.clear();
                    dimension.filterAll();
                }
                brushDirty = true;
                return chart;
            };

            chart.group = function(_) {
                if (!arguments.length)
                    return group;
                group = _;
                return chart;
            };

            chart.round = function(_) {
                if (!arguments.length)
                    return round;
                round = _;
                return chart;
            };

            return d3.rebind(chart, brush, "on");
        }
    };

Comment: seems like the last record date is incorrect...or may be its outside teh domain you have set...
Comment: I am not able to find the problem.. i have set the domain according to the data's array length so all the data is set from [0]-[last element]. But the last record is outside of range.... should i increase the width etc??
Comment: I got the answer for i added d3.time.day.offset in domain so that it adds one day more...
Answer: I have added a day as an offset. that solved my problem.below is my code that solved my problem.....
d3.time.day.offset(new Date(flights[0].eventTimeGmt.substring(0,4)
                            ,flights[0].eventTimeGmt.substring(5,7)-1,
                             flights[0].eventTimeGmt.substring(8,10)), 1)


How to calculate sensitivity of feature vector for binary variable flipping

Question: I need to calculate the "sensitivity" of a vector of binary data in order to flip a binary result (1,0) given an array of coefficients derived from a LinearSVC model.
For example, let's say I have an instance vector [1,0,0,1,0] which outputs y=1, and the coefficients I got from the LinearSVC model are [-0.11,0.05,0.064,-0.0012,0.047].
What I want to know is which variable/s are the most "sensitive" in order to flip the result to y=0, and if there is a way of calculating an overall metric of how "sensitive" the instance is to an output change.
Thanks in advance :)
Comment: Please do not vandalize your question. When you posted on SE, you gave up
ownership of the content under
[CC BY-SA 4.0](https://stats.stackexchange.com/help/licensing). If there are
no answers, you may delete your own question (see
[here](https://stats.stackexchange.com/help/what-to-do-instead-of-deleting-question)
): just click the faint gray 'delete' at lower left (your account needs to be
registered for this). Otherwise, the thread will remain according to SE's rules.
Answer: The absolute value of the coefficient is an indication of how much influence a particular factor has on the prediction.
The SVC can not only give a prediction (yes or no) but also a decision function, a number that is very positive for a definite yes, and very negative for a definite no. Values near to zero are close to the decision boundary, so easier to flip.


Measurable sets defined in Folland's Real Analysis

Question: On the page 25 of Prof. Folland's Real analysis:

If $X$ is a set and $M\subset P(X)$ is a $\sigma$-algebra, $(X,M)$ is called a measurable space and the sets in $M$ are called measurable sets. ($P(X)$ is the family of all subsets of a set $X$)

My question is we know $P(X)$, power set, is also a $\sigma$-algebra:
https://proofwiki.org/wiki/Power_Set_is_Sigma-Algebra

What about the set of subsets of $X$:  $\{E:E\in P(X), E\notin M\}$?  Are they also measurable sets in the above definition?   Also, why don't we care about these subsets, are there any specific example to say more on this?
Moreover, can we choose  $M = P(X)$ in the above definition?
Comment: 1. By definition, no. 2. $P(X)$ is a sigma-algebra.
Comment: Why are you wondering about this obscure subset (All the sets that aren't in a given sigma algebra)?  The question isn't why don't we care about them, but why should we?
Comment: Only the sets in $M$ are measurable.
Answer:
$P(X)$ \ $M$ can fail to be a $\sigma$-algebra. For example, when $X=\mathbb R$ and when $M$ is the family of Lebesgue-measurable subsets of $\mathbb R$, there exists a countable $F\subset P(X)$ \ $M$ with $\cup F=X\in M....$ So $P(X)$ \  $M $ can fail to be closed under countable unions.

2.$P(X)$ is indeed a $\sigma$-algebra. For example, for the counting measure $\mu$ on $X$,with $M=P(X)$, where  $\mu(Y)=\infty$ if $Y$ is an infinite subset of $X,$ and $\mu(Y)$ is the number of members of $Y$ if $Y$ is a finite subset of $X.$

A great deal has been said about $P(X)$ \ $M$ in various contexts. It is not without interest. But $\sigma$-algebras are interesting too.
Comment: @sleevechen. There is a standard textbook example of such F. If you post this as a Q you will surely get an answer.  An answer might be too long for a comment,  depending on writing style.
Comment: How to say the existing of $\cup F = X\in M$? Thanks!


Do in-swinging corner kicks generate more goals than out-swinging corner kicks?

Question: When lofting a corner kick into the air, many teams prefer to put two types of spin on the ball:

The ball curves towards the goal from the general direction of the midfield (an "in-swinging" corner kick) or;

The ball curves away from the goal to the general direction of the midfield (an "out-swinging" corner kick

Because an in-swinging ball is initially moving away from the goal, it seems like the goalie would have a harder time calculating the trajectory of the ball from the ball's original flight path.
Do the data show that in-swinging corner kicks generate more assists/goals than out-swinging corner kicks in the EPL, La Liga, or Bundesliga?
Are in-swinging corner kicks utilized more frequently than out-swinging corner kicks?
Comment: I'm pretty sure there aren't sufficient statistics about that. If you accept answers relying on personal experience, that I can help with.
Comment: @dly I'd love to hear about your experience! Thanks for offering to share :)
Answer: There is a certain risk for both ways and both have their pros and cons. Just counting which one produces more goals is not possible as it would ignore the fact of many shots being saved, blocked or going wide. Most corner kicks get headed out of the box by the defending team, regardless of the type of spin. Also having a player like Lewandowski or Ronaldo converting anything they touch it would not matter how you pass them the ball.
But why do you spin it in or out? This primarily depends on who is playing and the game plan.
Spin towards the goal:

easier to handle for the goalie
good opportunity to come closer to the goal
good for a cross to the far side of the box to have another player pass it back to the middle, so someone else can score from there

Spin away from the goal:

goalie has a harder time to catch it, because of a longer way getting to the ball through the crowded box
if the ball gets too close to the goal line it will eventually pass it in mid air, so it's not a good way to get close to the goal
you can target the whole box, so it's a good way for direct goal scoring opportunities

And which one is now better?
None, it's the mix of both. Alternating styles and player positioning is more important. Obviously it will be harder to defend, when the defenders don't know where the ball goes.
And what about the stats?
Many teams have two or three players doing all the corner kicks. When they're all right-footed they don't care about the spin, because that's already decided by the side they're kicking from. This would render any stats useless just by the nature of the game. Also it heavily depends on the players in the box being able to convert the corner kicks.


How to divide a set of $n$ points of the plane into two subsets so that $ MA_1+ MA_2+ ...+MA_k= MB_1+ MB_2+ ...+MB_{n-k} $ for some point $M$?

Question: Definition. If a some set of $n$ points of the plane can be divided into two subsets $\{ A_1, \; A_2, \; ..., \; A_k\}$ and $\{ B_1, \; B_2, \; ..., \; B_{n-k}\}$  so that there is a point $M$ of the plane such that $ MA_1+ MA_2+ ...+MA_k= MB_1+ MB_2+ ...+MB_{n-k} $, then we shall say that there exists a good partition of the set of these $n$  points of the plane.
a) Prove that for every set of  $n \ge 2$ points of the plane there is at least one good partition.
b) Prove that if $n$ is even then for every set of  $n \ge 2$ points of the plane there is at least one good partition such that both subsets of points contain $\frac{n}{2}$ points each.
My work. I solved the problem for cases when $n=2$ and $n=4$. If $n = 2$ then everything is easy: the point $M$ is an arbitrary point of the perpendicular bisector of a line segment $A_1B_1$.
If $n = 4$ then we randomly denote four points by letters $A_1,\; A_2, \;B_1, \; B_2$. Let $a$ be a real number such that $a>A_1B_1+A_1B_2+A_1A_2$. We construct an ellipse $w_1$ with foci at points $A_1$ and $A_2$ and with semi-major axis $a$. Then all two points $ B_1, \; B_2$ are inside this ellipse. We construct an ellipse $w_2$ with foci at points $B_1$ and $B_2$ and with semi-major axis $a$. These ellipses $w_1$ and $w_2$ will intersect at two points. Let $M$ be a intersection point of ellipses $w_1$ and $w_2$. Then $ MA_1+ MA_2=2a= MB_1+ MB_2$.
I have no idea how to solve the problem in general.
Answer: Let your points be $p_1, \ldots, p_n$.
If $n$ is even, take a vector $v$ such that the dot products $p_i \cdot v$ are all distinct, sort your points according to these dot products, and take the least $n/2$ values for one subset ($A$) and the greatest $n/2$ for the other ($B$).  Note that if $t$ is sufficiently large and positive, all points in
$A$ are farther from $tv$ than are all points in $B$; the reverse is true for $-tv$.
Use the Intermediate Value Theorem to show that you can take $M = t v$ for
some real $t$.
EDIT: To clarify, the function to use the Intermediate Value Theorem on is the sum of distances from $tv$ to the points in $A$ minus the sum of distances from $tv$ to the points in $B$.  It is easy to prove that this is continuous, using the fact that the sum or difference of continuous functions is continuous.
If $n$ is odd, let $A$ consist of $p_1$ and the $(n-1)/2$ closest points to $p_1$ (breaking ties arbitrarily), $B$ the farthest $(n-1)/2$.
For $M = p_1$ the sum of distances to points in $A$ is $\le$ the sum of distances to points in $B$.  For $M$ very far away the sum of distances to points in $A$ is greater.  Again use the Intermediate Value Theorem.
Comment: Very nice proof of **a)** and **b)**! Thank you very much!


Bring the linear part of a ODE system into a diagonal form

Question:

Consider the system
    $$
\dot{x}=y,\quad\dot{y}=z,\quad\dot{z}=-x-y-z+x^2+az^3.
$$
    Check that the zero equilibrium has a pair of pure imaginary eigenvalues. Make a linear coordinate transformation which makes the linear part of the system block diagonal.

First, the linearization matrix at $(0,0,0)$ is
$$
M=\begin{pmatrix}0 & 1 & 0\\0 & 0 & 1\\-1 & -1 & -1\end{pmatrix}
$$
and the eigenvalues are $\lambda_1=-1,\lambda_2=-i,\lambda_3=i$.
Edit due to Did's help
The transformation matrix is
$$
S=\begin{pmatrix}1 & -1 & 0\\-1 & 0 & -1\\1 & 1 & 0\end{pmatrix}.
$$
With this, we get
$$
S^{-1}MS=\begin{pmatrix}-1 & 0 & 0\\0 & 0 & 1\\0 & -1 & 0\end{pmatrix}=:J
$$
So the aim is to transform the system
$$
\begin{pmatrix}\dot{x}\\\dot{y}\\\dot{z}\end{pmatrix}=M\cdot\begin{pmatrix}x\\y\\z\end{pmatrix}+\begin{pmatrix}0\\0\\x^2+az^3\end{pmatrix}~~~(1)
$$
into the system
$$
\begin{pmatrix}\dot{u}\\\dot{v}\\\dot{w}\end{pmatrix}=J\cdot\begin{pmatrix}u\\v\\w\end{pmatrix}+\begin{pmatrix}f(u,v,w)\\g(u,v,w)\\h(u,v,w)\end{pmatrix}~~~(2).
$$
How do I get from system (1) to system (2)?
Do I have to compute
$$
S^{-1}MS \begin{pmatrix}x\\y\\z\end{pmatrix}+S^{-1}\begin{pmatrix}0\\0\\x^2+az^3\end{pmatrix}S?
$$
This would give me the system
$$
\begin{pmatrix}\dot{u}\\\dot{v}\\\dot{w}\end{pmatrix}=J\begin{pmatrix}u\\v\\w\end{pmatrix}+\begin{pmatrix}\frac{1}{2}(u^2+aw^3)\\\frac{1}{2}(u^2+aw^3)\\-\frac{1}{2}(u^2+aw^3)\end{pmatrix}.
$$
Comment: The block corresponding to the eigenvalues $i$ and $-i$ should not read $$\begin{pmatrix}i & 0 \\0 & -i\end{pmatrix}
$$ but $$\begin{pmatrix}0 & 1 \\-1 & 0\end{pmatrix}.
$$ So *the aim is to bring the system into* the form
$$
\dot{u}=v+f(u,v,w),\quad\dot{v}=-u+g(u,v,w),\quad\dot{w}=-w+h(u,v,w).
$$
Answer: Your determination of $S$ is now correct.
In order to transform system (1) into system (2), multiply with $S^{-1}$ from the left and use that $SS^{-1}$ gives you the identity matrix:
$$
S^{-1}\begin{pmatrix}\dot{x}\\\dot{y}\\\dot{z}\end{pmatrix}=S^{-1}MS\cdot S^{-1}\begin{pmatrix}x\\y\\z\end{pmatrix}+S^{-1}\begin{pmatrix}0\\0\\x^2+az^3\end{pmatrix}
$$
Now, set
$$
\begin{pmatrix}u\\v\\w\end{pmatrix}:=S^{-1}\begin{pmatrix}x\\y\\z\end{pmatrix}
$$
and what you get is
$$
\begin{pmatrix}\dot{u}\\\dot{v}\\\dot{w}\end{pmatrix}=J\begin{pmatrix}u\\v\\w\end{pmatrix}+S^{-1}\begin{pmatrix}0\\0\\x^2+az^3\end{pmatrix}.
$$
Finally to get rid of the $x$- and $z$ terms in the last summand, use that
$$
\begin{pmatrix}x\\y\\z\end{pmatrix}=S\begin{pmatrix}u\\v\\w\end{pmatrix}.
$$
The result is
$$
\begin{pmatrix}\dot{u}\\\dot{v}\\\dot{w}\end{pmatrix}=J\begin{pmatrix}u\\v\\w\end{pmatrix}+\begin{pmatrix}\frac{1}{2}\cdot ((u-v)^2+a(u+v)^3)\\\frac{1}{2}\cdot ((u-v)^2+a(u+v)^3)\\-\frac{1}{2}\cdot ((u-v)^2+a(u+v)^3)\end{pmatrix}
$$
so you've got your transformed ODE-System.


How to override facets checkbox theme and style checkboxes checked state?

Question: I'm having trouble to style Drupal 9 facets checkbox in checked state. I have tried to override the theme by theme_preprocess_checkboxes with no effect.
here is my code :
 function mytheme_preprocess_checkboxes($variables) {

  $element = $variables['element'];
  $element['#attributes']['type'] = 'checkbox';
  element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));

  // Unchecked checkbox has #value of integer 0.
  if (!empty($element['#checked'])) {
      $element['#attributes']['checked'] = 'checked';
  }
  _form_set_class($element, array('form-checkbox'));

  return '<input' . drupal_attributes($element['#attributes']) . ' />';
}

I guess i'm not getting facets checkboxes with it. Any suggestions how do i style facets and override their templates.
I'm using bootstrap 3 subtheme on drupal 9
Comment: Unfortunately preprocess_checkboxes hook is depricated and will be no longer available from Drupal 10 version... so looking for the solutions. probably i need to rewrite twig temeplate but still can't find it even in facets module templates folder... :(
Comment: getting more closer to it : public static function Checkbox::preRenderCheckbox for non facets checkboxes in checked stade adds to element css class. butr still canot track the facets chekbox renedering
Answer: The checkboxes are created in JS, not PHP, so you won't be able to manipulate them from the backend (see Drupal.facets.makeCheckbox in facets/js/checkbox-widget.js for the code).
It does mean you can just use some simple JS yourself, though; for example assuming you need to append an empty span you'd, probably just need to add something like this to a custom behavior:
$('.facets-checkbox').after($(''))

(that's just a minimal example, you should use once or a similar mechanism to make sure it isn't executed multiple times for the same element).
Comment: Thanks Clive will try this bit


Kubectl get events with two different field selectors doesn't work

Question: kubectl get events with two field selectors on source doesnt give the results as expected. I tried some other options as well
When I try to use the kubectl command to get events for two different field selectors it only returns events for one of them
kubectl get events --field-selector source=deployment-controller --field-selector source=kubelet
LAST SEEN   TYPE     REASON    OBJECT                               MESSAGE
10m         Normal   Killing   pod/loadgenerator-5c9656f8d6-2j9nt   Stopping container main
10m         Normal   Killing   pod/loadgenerator-5c9656f8d6-5glbv   Stopping container main
10m         Normal   Killing   pod/loadgenerator-5c9656f8d6-5xqvx   Stopping container main
10m         Normal   Killing   pod/loadgenerator-5c9656f8d6-bdggt   Stopping container main
10m         Normal   Killing   pod/loadgenerator-5c9656f8d6-kwkw5   Stopping container main
10m         Normal   Killing   pod/loadgenerator-5c9656f8d6-m4nbh   Stopping container main

kubectl get events --field-selector source=kubelet --field-selector source=deployment-controller
LAST SEEN   TYPE     REASON              OBJECT                     MESSAGE
12m         Normal   ScalingReplicaSet   deployment/loadgenerator   Scaled down replica set loadgenerator-5c9656f8d6 to 4

How can I get events from both in a single command?
Answer: You can use the chained field selector option, comma separated
kubectl get pods --field-selector=status.phase!=Running,spec.restartPolicy=Always

Example
kubectl get events --field-selector=source=kubelet,source=deployment-controller

Ref : https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/#chained-selectors
Comment: This doesn't seem to work

kubectl get events --field-selector=source=kubelet,source=deployment-controller
No resources found in default namespace.
aritra [ ~ ]$ kubectl get events --field-selector=source=deployment-controller
LAST SEEN   TYPE     REASON              OBJECT                     MESSAGE
21s         Normal   ScalingReplicaSet   deployment/loadgenerator   Scaled up replica set loadgenerator-5c9656f8d6 to 8
aritra [ ~ ]$ kubectl get events --field-selector=source=kubelet
Comment: yes you are right it uses the AND condition, you can use the `jsonpath` also


Check if the variable is empty

Question: What I want is to check if the columns $campo01 and $campo02 are empty or not, if not empty it displays on my page, the problem is that if a variable is empty it does not display the result of the variable that is not empty
class Test extends URLDynamic
{

    public function Testando( $campo01, $campo02, $linguagem, $audio )
    {
         $CRUD = new CRUD;
         $this->SetParametro();

         $VerificaAudio = $this->SelectDados(
            "campo01, campo02",
            "table_01",
            "WHERE mCat = ? AND mSlug = ? AND mStatus = ?",
            array ( $this->SepURL[0], $this->SepURL[1], 1 )
         );

         foreach ( $VerificaAudio as $VerificouAudio ) {

             $campo01   = $VerificouAudio['campo01'];
             $campo02   = $VerificouAudio['campo02'];

             if ( empty ( $campo01 ) ) {
                 echo 'Empty Campo 01';
             } elseif ( empty ( $campo02 ) ) {
                 echo 'Empty Campo 02';
              } else {

                 // Returns the value of each column.
                 echo $linguagem;

                 $Temporadas = $this->SelectDados(
                    "*",
                    "table_02",
                    "WHERE mCat = ? AND mSlug = ? AND tAudio = ? AND tStatus = ?",
                     array ( $this->SepURL[0], $this->SepURL[1], $audio, 1 )
                  );

              } // end else
         } // end foreach
    }
}

$Test = new Test;
$Test->Testando( "Legendado", "Legendado" ); // campo01
$Test->Testando( "Dublado", "Dublado" ); // campo02

Comment: [`php` has `isset`](https://www.php.net/manual/en/function.isset.php) to check whether a variable is declared and having value other than null.
Comment: @mehid, your question is confusing. What is your expected result based on your example above? What is it doing incorrectly based on your example above?
Comment: But your code is always show Empty text ??
Comment: @blupointmedia
I simulated that the variables `$Test01` and `$Test02` are columns from the database, I want to check if any of these columns are empty, return an "Empty" message and show the contents of the next one.
Comment: @Mahesh Bhatnagar
There will be cases where the column will be empty and the other column will not be empty
Comment: OK, so you want to check each variable individually then. This will return true on the first variable and the elseif and else will never get called.
Comment: If one have empty and other is not empty then show result ?? You want ??
Comment: @blupointmedia How could you do this check?
Comment: if ( empty ( $this->Teste01) && empty (  $this->Teste02 ) ) {
            print $HTML = 'Empty';
         } else {
           echo "Result"; ,}
Comment: @mehid, are you expecting to get the response from both variables?
Comment: @Mahesh Bhatnagar
Let's say the column Test01 has the value Notices, shows the news, and the column Test02 is empty, shows the message "Empty" makes these checks on both columns and shows their contents.
Answer: class Test
{
    public $Teste01;
    public $Teste02;

    public function Testando($Param01, $Param02)
    {
        $this->Teste01 = '';
        $this->Teste02 = 'Has value';

        echo $this->checkIfEmpty($this->$Param01);
        echo $this->checkIfEmpty($this->$Param02);
    }

    private function checkIfEmpty($var)
    {
        if (empty($var)) {
            return 'Empty';
        } else {
            return $var;
        }
    }
}

Comment: If I follow this logic, I will have to pass two parameters `public function Testing ($Test01, $Test02)` what would the verification look like?
Comment: I updated the answer to use two params and a private method to check each one to remove redundancy.
Comment: There is a problem, it cannot be ternary checking, because the return will be HTML element and called in database
Comment: The ternary doesn't matter. If it is empty it will return the string Empty and if not it will return whatever is in the variable.
Comment: @mehid, if my answer worked for you can you kindly make it your accepted answer? If not, please let me know and I will work with making it meet your expectations.
Comment: It won't work because the `checkIfEmpty()` method can't have a ternary check, because the `else` return will be a call to the database and HTML elements, so I can't do that inside the `$this->checkIfEmpty()` method.
Comment: @mehid, I updated and removed the ternary and added in if/else statement. Does this work for you?
Comment: @ blupointmedia It doesn't work, because I can't make the database call within the set method, this check has to be within the Test class.
I will edit the question
Comment: Are you making a connection to the database or do you already have a connection and just need to read from a query of results? Can you give an example of your code in reference to your db call you are referring to, please?
Comment: I put the most explained example
Comment: @mehid, if $campo01 is empty and $campo02 is empty do you want to print Empty and if both have a value you want to perform the query, correct?
Comment: Not quite, without both having value displays the contents of each, now if $ field01 is not empty and $ field02 is empty displays the content of $ field01 and $ field02 displays the empty message and vice versa

Check if the variable is empty


Django how to change bounds value of IntegerRangeField

Question: I have model with IntegerRangeField in it, which returns data as, for example,  NumericRange(1992, 1997, '[)') after adding objects to the database. I need second option of range to be also included in it, so the bounds should be like '[]'.
I was looking for the solution in the psycopg2 documentation, but unfortunatelly didn't find an answer.
Please help! Thanks in advance.
My current models.py
from django.contrib.postgres.fields import IntegerRangeField
from django.contrib.postgres.validators import RangeMinValueValidator, RangeMaxValueValidator
from django.core.validators import MinValueValidator, MaxValueValidator

from django.db import models
from datetime import datetime

class Bancnote(models.Model):

    Dollar= 'Dollar'
    Euro= 'Euro'

    TYPE_CHOICES = (
        (Dollar, 'Dollar'),
        (Euro, 'Euro')
    )

    type = models.CharField(max_length=11, choices=TYPE_CHOICES, default=Dollar)
    par = models.PositiveIntegerField()
    year = IntegerRangeField()
    size = models.CharField(max_length=7)
    sign = models.TextField(max_length=250)
    desc = models.TextField(max_length=500)
    image = models.ImageField(upload_to='bons_images')

    def __str__(self):
        return str(self.par) + ' ' + self.type + ' ' + str(self.year.lower) + '-' + str(self.year.upper)

Answer: The official documentation says:

Regardless of the bounds specified when saving the data, PostgreSQL
  always returns a range in a canonical form that includes the lower
  bound and excludes the upper bound; that is [).

So I'm afraid you can't really change that. You can however store the data as usual:
from psycopg2.extras import NumericRange

Bancnote.objects.create(
    # specify other fields
    year=NumericRange(1992, 1997, bounds='[]')
)
# assuming the object we created is with id=1
bancnote = Bancnote.objects.get(id=1)
print(bancnote.year) # NumericRange(1992, 1998, '[)')

which I suppose you do. It's not much of a help, but that's all I can contribute.
Comment: Looks like this might be changing soon for some types of range fields https://docs.djangoproject.com/en/dev/ref/contrib/postgres/fields/#range-fields


Is there a way to delete zip archive comments in python?

Question: I have multiple zip archives all with a similar comment.
Is there a way to delete the comment from the archives with python and use it over multiple archives with similar comment?
What I have tried with single archive
<code>import zipfile
archive = zipfile.ZipFile('D:\XXX\Desktop\MyZip.zip', 'r')
del archive.comment
</code>
This is not working. Comment is not getting deleted in the archive, plus I want this to work on multiple archives in the same directory.
Answer: You are opening the zipfile in read mode with 'r' parameter. Use a mode that enables you to modify the file. Then set comment  to '' instead of deleting it.


Math.max seems to be returning the wrong answer

Question: I have a list of double values that I don't know the range of and I want to find the maximum value. However, the Math.max function is giving a curious result for this sample code:
double a = -100.0;
double maxA = Double.MIN_VALUE;
maxA = Math.max(maxA, a);
System.out.println(maxA);

And the output is:
4.9E-324

So for some reason, Double.MIN_VALUE is being considered the max when compared to -100.0.
Why?
Comment: You need Double.NEGATIVE_INFINITY .
Comment: Thank you for the answers! What I need is double maxA = -Double.MAX_VALUE;
Answer: MIN_VALUE is:

A constant holding the smallest positive nonzero value of type double, 2^(-1074).

Not the most negative possible value.
Comment: The problem with this definition is that it is inconsistent with the integer types, where MIN_VALUE is indeed the smallest possible value.
Comment: Ah yes, thanks! I didn't even notice it was the smallest positive nonzero value. I just assumed it would actually be the smallest negative value.
Answer: Its pretty obvious -100 is less than 4.9E-324
-100 , -99 ..... -1 , 0 , 4.9E-324 , 1 , 2 , 3......

Comment: Only if you know scientific notation.
Answer: MIN_VALUE A constant holding the smallest positive nonzero value of type double.
Note "positive" value.
You are comparing it with a negative value is 1 > -1.


How to upgrade to the latest AMI in AWS Elastic Beanstalk?

Question: I'm running an application on AWS Elastic Beanstalk, and it looks like I need to create a new environment if I want to use the latest AMI.
If I knew what the latest AMI id was, I could update it in the environment configuration.
Is there a place where I could find the ID of the latest Elastic Beanstalk AMIs, or even better, is it possible to have the instances automatically replaced by the new version whenever a new version is rolled out?
Comment: Fire up a new environment and see what the AMI ID is on the server it launches?
Comment: That's a bit of a pain, isn't it?
Comment: They really ought to post these in some release notes or a sticky in their forums rather than just rolling them out silently.
Comment: Last time I set up an EB environment it took about five minutes. Amazon Linux AMIs come out once every three months IIRC. 1.6 minutes a month doesn't strike me as too much pain.
Comment: Let me rephrase: it *feels* like there must be a better way. But you're right, it's not a big deal.
Answer: The recommended and supported way to upgrade your AWS Beanstalk environment is documented here and managed platform updates are discussed here, honestly I'd stick to that if you want things to be easy (and that's what Beanstalk is all about), you'll theoretically only get the non-breaking updates and AWS will manage the process so there's no downtime.
So I just want to reiterate that managed platform updates are probably what you or anyone else coming here from Google will want, but if you want to know the latest AWS provided AMI for your Beanstalk environment it can be done fairly trivially with AWS CLI (thanks to sane naming conventions from Amazon on their AMIs).
Starting with an instance from your environment, describe the instance to get the current AMI (skip if you already know the current AMI).
aws ec2 describe-instances --instance-ids i-0909613f35ec0ffee --query 'Reservations[*].Instances[*].ImageId' --output text

ami-35290a56

Take the resulting AMI ID and describe it.
aws ec2 describe-images --image-ids ami-35290a56 --query 'Images[*][Architecture, Hypervisor, Name, RootDeviceType, VirtualizationType]' --output json

[
    [
        "x86_64",
        "xen",
        "aws-elasticbeanstalk-amzn-2016.03.0.x86_64-python34-hvm-201603290718",
        "ebs",
        "hvm"
    ]
]

We can use the output of the above as input to a new, sorted describe-images but this time we replace the timestamps with * wildcard symbols, like so:
aws ec2 describe-images --filters 'Name=architecture,Values=x86_64' 'Name=virtualization-type,Values=hvm' 'Name=owner-alias,Values=amazon' 'Name=name,Values=aws-elasticbeanstalk-amzn-*.x86_64-python34-hvm-*' --query 'sort_by(Images[*], &Name)[-1].ImageId' --output text

ami-1be5de78

Due to the power of lexical sorting and ISO 8601, we end up with the latest AMI, which in my example is ami-1be5de78.
aws ec2 describe-images --image-ids ami-1be5de78 --query 'Images[*].Name' --output text

aws-elasticbeanstalk-amzn-2016.09.0.x86_64-python34-hvm-201612200708

Again, I wouldn't recommend you try to change to this AMI by hand, Beanstalk has provisions to do all this for you!
Answer: It seems like even if you change the AMI, to a proper AMI ElasticBeanstalk uses.  It doesn't seem to work properly.  It misses all of the files.  It doesn't work right.
I think you have to start a new Elastic Beanstalk environment that has the updated AMI.  Make everything work then swap the environment urls.
Answer: You could use the managed updates features that comes with eb but will have to pay for enhanced health reporting to do this.  Or use the 'eb platform show' command;
In a worker app have a cron that runs
CURRENT=eb platform show your_env_name | sed -n '5p' | cut -d: -f2- | tr -d '[[:space:]]'
LATEST=eb platform show your_env_name | sed -n '6p' | cut -d: -f2- | tr -d '[[:space:]]'
 - Then compare them and if different you can use eb clone (defaults to new version) and then cname swap.
Answer: Navigating to the dashboard of your application locate 'Configuration' and click 'Change'
You should see a list where you can choose a Platform. The latest version is indicated in that list.
Selecting platform
AWS EB uses specific setups for different programming languages. You can find a list of the setups in the documentation http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.platforms.html
There are tables showing you which AMI version each platform uses.
I didn't find a way to run these updates automatically though. I actually prefer to review changes of the platform and test them before deploying them.
Answer: Select your service in Elastic Beanstalk, You will see overview in Dashboard, In the dashboard right hand side you can see configuration of your AMI, Select Change upgrade or degrade your AMI. At this point your are going to replace your instance. So make the backup or clone.
Answer: I was able to update my current application hosted on Beanstalk to the latest Amazon Linux AMI using the steps below.
1- Log into the AWS Console and navigate into the Beanstalk portal.
2- Navigate into the configuration page of your application and click-on 'Instances'.
3- Locate the AMI id it should be like so AMI-xxxxxx.
4- Take the AMI id and navigate back into the EC2 console and click-on AMI.
5- Change the view to Public Images and look for the AMI id retrieve earlier from the Beanstalk configuration.
6- Launch that AMI as a new instance.
7- Once its launched log into the instance and customize as per your applications requirements.
8- Once your satisfied everything in place as you would like it to be create an AMI image of this new instance.
9- Take the new instance AMI id that was created in step 8 and apply that to your Beanstalk application configuration.
10- It will not delete the old instance and create the new instance with your customize AMI and also deploy your latest application onto the new instances.
Comment: I think you misunderstood the question. I didn't ask how to create and use a custom AMI, I asked how to know what is the latest default Elastic Beanstalk AMI id that is applied when you create a new environment, and if possible, how to automatically have the new AMI applied when it's released by AWS.