How to map a virtual drive (RAID 0, PERC) to Linux

Question: I have two different RAID arrays on a server. The first virtual drive is a RAID 10 with 4 disks and is already mapped to the OS. Now I have created another array with RAID 0 and one disk. Because the first virtual drive was created and mapped through the install routine when setting up the whole system, I don't know how to map the new virtual drive to the OS.
The virtual drives:
# megacli -LDInfo -Lall -Aall

Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name                :
RAID Level          : Primary-1, Secondary-0, RAID Level Qualifier-0
Size                : 5.457 TB
Sector Size         : 512
Mirror Data         : 5.457 TB
State               : Optimal
Strip Size          : 64 KB
Number Of Drives per span:2
Span Depth          : 2
Default Cache Policy: WriteBack, ReadAhead, Direct, Write Cache OK if  Bad BBU
Current Cache Policy: WriteBack, ReadAhead, Direct, Write Cache OK if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy   : Disk's Default
Encryption Type     : None
Default Power Savings Policy: Controller Defined
Current Power Savings Policy: None
Can spin up in 1 minute: Yes
LD has drives that support T10 power conditions: No
LD's IO profile supports MAX power savings with cached writes: No
Bad Blocks Exist: No
Is VD Cached: Yes
Cache Cade Type : Read Only

Virtual Drive: 1 (Target Id: 1)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 2.728 TB
Sector Size         : 512
Parity Size         : 0
State               : Optimal
Strip Size          : 64 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy   : Disk's Default
Encryption Type     : None
Default Power Savings Policy: Controller Defined
Current Power Savings Policy: None
Can spin up in 1 minute: Yes
LD has drives that support T10 power conditions: No
LD's IO profile supports MAX power savings with cached writes: No
Bad Blocks Exist: No
Is VD Cached: Yes
Cache Cade Type : Read Only

The existing filesystems:
# df -h
Filesystem                                              Size  Used Avail     Use% Mounted on
rootfs                                                  5.5T  4.7T  525G  91% /
udev                                                     10M   80K   10M   1% /dev
tmpfs                                                    38G  248K   38G   1% /run
/dev/disk/by-uuid/8fcd8997-12d3-4259-b7b9-4e5c27286b21  5.5T  4.7T  525G  91% /
tmpfs                                                   5.0M     0  5.0M   0% /run/lock
tmpfs                                                    77G     0   77G   0% /run/shm
/dev/sda2                                               504M   40M  440M   9% /boot

What are the right steps to get the new virtual drive mapped, create a filesystem and mounted to the OS, for example to /var/backups/new ? (We are on Debian 7.11) Thank you very much!
Comment: please add `fdisk -l` to the pasted outputs. Basically, you probably have an sdb disk showing up there (or sdc/e/f/etc) which you need to format and mount
Answer: You'll have to write a partition table to this drive, so that you may get a valid partition to work with. It can take up the whole available disk if need be. You'll also need to format that partition with a valid filesystem, and then mount that filesystem either temporarily with the mount command, or persistently using /etc/fstab or the automounter.
What you choose for your filesystem will depend on what you're using it for. I can't offer a recommendation based on the data I'm given here. However, this essentially boils down (in most cases) to a choice between BTRFS, XFS, and EXT4. Since you're on Debian Wheezy, I would avoid using BTRFS unless you're sure you need it.
First, you need to identify which disk you want to operate on. This is most easily accomplished in most situations by reading the output of the lsblk command.
Then you'll need to use fdisk or parted to partition your disk.
After this is done, you will need to use mkfs to format that partition with a filesystem
Finally, you'll need to specify a permanent mount point for this filesystem if you intend to persistently use it. This is done typically via the fstab file.
Comment: Thank you very much! Do you know a good howto where the steps from paritioning to mounting are explained?
Comment: mounting you can do manually by invoking the mount command directly. Mount utilized automatic filesystem detection, so you don't typically ever need to give it many options except in special cases. You could use it liek so: `# mount /dev/sda1 /mnt/location` First argument being the block device your filesystem is, second argument being the empty file you intend to mount it to. Also, you may invoke the fstab to mount things for you if you've made a persistent entry, by using `# mount -a` This is essentially what happens at boot. Using `mount -a` won't disrupt already mounted filesystems.
Comment: Right, `mount` isn't that big thing. Some adivce for `gdisk/parted` (need a GPT) and `mkfs` would be great instead.
Comment: I put a series of links in my answer. Is there something specifically deficient about them? Tried to include guides rather than just man pages.
Comment: Yes thanks! Found something very nice and complete here: http://www.cyberciti.biz/tips/fdisk-unable-to-create-partition-greater-2tb.html


Why are accidentals not just indicated next to the note in sheet music to make sight reading easier?

Question: For example, in the key of G, why is the sharp not put next to every F note? I think this would make it easier to sight read quickly, especially for keys that have many sharps or flats. Is there an advantage to having it the way it is (indicated by the key signature)?
Comment: Is there a terminology issue here as well?  To my way of thinking: in the key of G major the note F sharp is not an accidental, its a note of the scale.
Comment: No, it wouldn't. Playing a piece in F sharp with individual accidentals only would be a nightmare to read. And where to you want to draw the line? It's better to have *one* principle and stick to it than try to guess what your reader's threshold of tolerance for a messy score is.
Comment: When one is used to the notes that are generally sharpened or flattened in particular keys, one realises that the music is easier to read as it is when normally written out - not anywhere near as cluttered. You could always personalise your own sheet music by highlighting the # or b. Problem is usually caused by learning lots in C major initially, like most tutor books insist on.
Comment: Seeing all the accidentals at once helps you recognize the key and thus realize the intent of the composer with respect to the piece (a programmer would call it the "higher level" logic). If you saw the accidentals on a need-to-know basis only, you'd still be able to play but you'd have a harder time piecing all the information together and figuring out the composer's intention.
Comment: Try reading a piece of atonal music, maybe something twelve-tone by Schoenberg. These pieces tend to have every single sharp/flat next to every note because they lack a tonal center (thus their key signature is just C major). It can make your head hurt to process music that maps a note to a key on a piano (rather than a key of a scale). Sight reading is easier without all the sharps/flats _provided that_ you know each scale well.
Comment: @Tim "notes that are generally sharpened or flattened in particular keys" would be more accurate if it said "notes that are always sharpened or flattened in particular keys."
Comment: You will quickly get used to the fact that the sharps and flats are *always* added to the key signature in the same order.  The first one is F#, for the keys of G major and E minor.  Then every other key signature with sharps contains an F#.  The next key signature, with two sharps, has F# and C#.  Then F#, C#, and G#.  Then F#, C#, G#, and D#.  See the pattern?  The next one is always a fifth above the previous one.  It's the opposite for flats: The first one is Bb, then Eb, then Ab, then Db, and so on.
Comment: As I see it musical notation could be written one of two ways. "Relatively" would indicate the exact frequency of the first note and then describing the ratio of every note's frequency to the previous (because it's ratios that matter, not notes). "Absolutely" would just indicate every note exactly, as you suggest, and current responders ignore that accidentals don't have to be noted by the large and disruptive symbols currently used. The standard system is a weird compromise.
Answer: It is related to "chunking", once you are used to keys, it is easier to quickly understand the single chunk "This piece is in G major" instead of having to see and interpret each of the individual sharp signs.  This aids sight reading.
With the way keys are conventionally notated, the presence of accidentals is actually informative: it tells you when the music is doing something outside of the home key.  If every alteration were notated, you wouldn't get the same kind of clear visual indication that these passages are doing something outside the home key.
Comment: That is a very common default brain setting. The piano is setup to be like that by default. But when you start memorizing other scales and playing in other keys you will begin to appreciate not having to deal with unnecessary accidental markings because you already know the key.
Comment: Don't over-think this!  Your brain is not wired any differently to anyone else's.   Don't set up "I can't do this" blocks. You just need practice.
Also, black notes are not "harder" than white ones.  Some "pub pianists" habitually play in Gb major.  It's quite hard to hit a bad-sounding chord if you stick to the black notes!  Try.   (And don't assume every player who uses this trick CAN'T read music when they need to.)
Comment: Piano music that is more technically challenging is often written in keys that use most of the "black" notes, with key signatures of 5 or 6 sharps or flats. You might want to reconsider how easy it would be to read something like https://imslp.org/wiki/Special:ImagefromIndex/113234 with accidentals on every relevant note. For example look at the fourth page, where almost every note *does* have an accidental!
Comment: Thanks for your explanation. I have found this challenging specifically for piano because I automatically associate a note with a specific physical key. I think my brain defaults to C major.
Comment: @user34852 This comes from practice. You'll get used to it quickier than you think. "Difficult" signatures, like 4, 5 or 6 sharps/flats are very common (they are actually *easier* in many respects for pianists since they are more natural for the hands), and many pieces from the 19th century on use them.
Comment: In addition to all of the above, having to think about where the sharps and flats fall in any given key helps you see how scales are constructed.
Answer: It wouldn't be easier to read.
Firstly, most instruments are not tied into any particular key signature.
A simple sequence like someone singing/playing a scale in E major and someone else singing a third above feels very natural but actually is a complex walk resulting in an unregular sequence of major and minor thirds.
This makes sense and can be done in confidence when performing it in the context of an E major scale.
Take a look at
In general, the decreased readability leads to more confusion and less complex. The problem is that the second version is not even a neutrally notated version expressing an E major melody: it is expressing E major in relation and contextualized to C major! This would cause issues to instruments that are naturally in other keys, such as b flat clarinets.
As a result, most musicians keep the key signature, and only augment the markings with their own dynamics and/or fingerings. Funnily enough, when playing this on a piano which has a rather direct relation of white keys to C major notes, even then this notation will grow old on you very fast.
And the reason is that even piano players will become at home with different scales and will be playing an E major scale without thinking like they do with a C major scale, and will think of modifications in terms of the E major scale.
For similar reasons you cannot make do just with sharps even on instrument with equal temperament but also need flats and double sharps and flats: so that stuff can be written in terms of a home scale and diversions from it.
More chromatic notations (they would offer themselves for things like chromatic button accordions) have not caught on because the major musical building block of our Western music are diatonic scales.  If you are expressing the simple melodic phrase I spelled out in terms of their chromatic steps, it becomes rather irregular.  The first third is major, the second one is minor, the third is minor, that of the first half note is major again.
If you express it in terms of the C major scale, things become even worse.  The first third consists of the third and fifth of a C major chord, only that you raise the fifth by a semitone.
Answer: It's not just about which notes are flat or sharp
The key signature doesn't just tell you where the sharps and flats are.  It tells you where the pitch centricities are, and tells you the function of each and every note within the scale.  These are both important for interpretation, as the function can affect inflection, tuning, fingering/bowing/choice of string, etc.
Key signatures take less reading
A piece written with key signatures is going to have less ink on it than one where everything is treated as an accidental.  If there is less ink, there is less to read, meaning you can read it faster.  So key signatures actually make sight reading easier (assuming you know your scales).
OTOH, some composers do as you suggest
For some types of compositions (e.g. serial music, neoclassical, some forms of jazz), you may find that the composer has chosen to "keep it in the key of C" and write only accidentals, either because (a) the very concept of a key signature may not make sense in that particular work (e.g. it is atonal or does not use a diatonic scale), or (b) the key changes so rapidly that it is pretty ridiculous to try to write everything out the "right" way.
Answer: While a newcomer to the piano might feel like key signatures are essentially arbitrary, and may need to think about them while playing, people who are experienced at the piano get used to how different key signatures feel and don't have to think about what notes are sharp or flat--they just play them.
It may be helpful to think of sharps and flats not in terms of note names, but rather their positions on the keyboard.  The first sharp is the leftmost note in a group of three black keys, and the second is the leftmost note in the group of two.  Sharps alternate between the group of three and group of two, working toward the right.  Flats also start on the group of three and alternate with the group of two, but they proceed right to left.
If one thinks of things in those terms, then what a pianist will be conscious of is not which notes have sharps or flats in the key signature, but rather how many notes from one side of each group of two/three need to use the black key that's toward the other side.  In F major, for example (one flat), the note just to the right of the group of three moves left to a black key; none of the notes near the group of two move.  In A major (three sharps), the white keys to the left of the first two black keys in the group of three, and the first black key in the group of two, move right.
There might be some instruments where individually marking sharps and flats for each note would be helpful, but for most instruments it would usually increase a performer's mental workload.
Answer: Helping hands in the long run make it more difficult to become proficient. As you advance in playing your instrument you will find yourself recognizing and playing patterns, rather than individual notes. Reading, interpreting and playing a "crutched" score can adversely affect your ability to play it in the long run. This is also true when helpers in the past have annotated the score with "helpful" fingering for notes.
Comment: I feel that if there are no helping hands, for some people , the long run just won't exist, because they'll have given up well before that time. Too many pieces have 'reminder' accidentals written in, such as if an F# in the key sig gets naturalised, in the next bar, there's a # on the very next F. But, for beginners, those stabilisers stop a lot of pain.
Answer: Besides all the reasons above why key signature are better I'll add that using key signatures when you do see a accident it's like someone shooting up a warning flare that something is altered.  Not only good to know for sightreading, but if comping it's a note to adjust for, same for improving a note to take into consideration.
It's letting you know a note needs special handling from multiple points of view.
Answer: Before the printing press every letter was a cost to the writer if it was to be copied often.Writing the accidentals once only at the start was a an economy.
Answer: You might want to consider joining the dark side: take a pencil and put small marks, for example a tick sign ✓, near the notes altered by the key.
I find that since a key always has either flats or sharps (or neither (or actually, it might have flats with double flats or sharps with double sharps, but what you gonna do...)), you don't need to care to draw the actual signs ♭♯, and a small mark or a scribble near the note will do just as well, and it doesn't clutter the score as much, since it's miniscule, and in pencil.
Be wary that you might not want to come back, so make your choice...
Comment: Musical notation is already sufficient. Defacing score with redundant marks has nothing to recommend it whatsoever.
Comment: This is making the dots look even busier. A highlighter will do a better job.
Comment: Highlighter strikes the eye too much. All you need is really just a subtle hint.
Comment: Just recommending what I found useful for myself! Peace.
Comment: @EJP - one man's redundant is another man's helping hand. Most proper musos have a pencil or such like handy when dealing with dots.
Answer: In many ways, music that adheres only loosely to the key does have the accidentals in front of the notes. Jazz music, for instance, does not stay strictly in the key as what is the norm with classical music. You can have a host of chords that have seventh that are completely foreign to the key but are just used to add colour to pieces. Sometimes these ideas are used so heavy in Jazz that they do look like they have all the accidentals in front of the notes.


When is proving the truth of a biconditional statement "the same" as proving that two propositions are logically equivalent?

Question: In the math book that I am studying, the reader is asked to show that several statements are "logically equivalent"...and then in parentheses, the author says "[i.e.] any one of them implies the other".
After scouring this website (and others) for the differences between biconditionals and logical equivalencies, I must say that this question has me quite confused. I understand that when the biconditional $P(x) \leftrightarrow Q(x)$ yields a tautology, we claim that the propositions $P(x)$ and $Q(x)$ are logically equivalent...$P(x) \iff Q(x)$.
This is where my confusion arises. At first it seems like I need to demonstrate that the truth tables are identical...but then the advice in the parentheses seems to suggest that I only need to prove that the biconditional is true when the propositions are true.
Or does proving that the biconditional is true when the propositions are true necessarily imply that the propositions are logically equivalent?
Here is the exact question in the book (Tao's Analysis I):

Exercise 3.1.5. Let $A,B$ be sets. Show that the three statements $A\subseteq B$, $A\cup B=B$, $A\cap B=A$ are logically equivalent (any one of them implies the other two).
Comment: It might be the case that I either misread your question or your notation. What exactly defines the difference between $\leftrightarrow$ and $\iff$ for you?
Comment: When working with them in a setting like the *exercise* you gave; where's the difference? From what I understand that's your question, isn't it? Could you give an example for both (i.e. a biconditional connective and logically equivalence) which differ in a meaningful way?
Comment: Ah, I see. Then *Ben Blum-Smith*'s answer should clear it up.
Comment: @mrtaurho I am not sure I understand your response. Also, I think our notation may be different. You are using your "thick" double arrow to denote a biconditional?
Comment: @mrtaurho the skinny arrow simply denotes a biconditional connective. The thick arrow denotes logical equivalency.
Comment: @mrtaurho my understanding of logical equivalence is that I need to make sure these statements have the exact same truth table for all possible models...whereas the portion in the parentheses seems to suggest I only need to demonstrate the one model (specifically when the statements are assigned values of true).
Comment: When in doubt, read the definitions... :-) Tao's **Index** page 342: if: see *implication*, page 312. At page 312, *implication* is defined as the [logical connective](https://en.wikipedia.org/wiki/Material_conditional#Definitions) formalizing the "if..., then.." natural language syntactical construct.
Comment: Unfortunately, Tao's book does not define *logical equivalence*; it seems to me that the first occurrence is in *Ex.3.1.5*, "three statements are logically equivalent [when] any one of them implies the other two)." Thus, the Ex asks to prove: "if $A ⊆ B$, then $A ∪ B = B$" and "if $A ∪ B = B$, then  $A ⊆ B$".
Answer: I do not have a background in formal logic, but from the point of view of mathematics outside formal logic (which is the point of view from which Tao's book is written, for example), "Prove $P(x)$ and $Q(x)$ are equivalent" means the same thing as "Prove $P(x)$ and $Q(x)$ imply each other." There is no difference between the equivalence and the biconditional.
However, in all cases, you have to show more than that the biconditional holds when the statements hold. That's vacuous. If $P(x)$ and $Q(x)$ both hold, then $P(x)\leftrightarrow Q(x)$ holds too, just by truth-table reasoning. What you have to prove is that $P(x)\leftrightarrow Q(x)$ in all situations. Another way to say this is that you need to prove that whenever $P(x)$ holds, $Q(x)$ also holds, and whenever $Q(x)$ holds, $P(x)$ also holds.
In practice, this is not usually done by considering truth tables, but instead just by reasoning directly with the statements. For example:
Suppose $A\subseteq B$. Then, unioning both sides with $B$ and observing that this operation preserves the relation of containment, we can conclude that $A\cup B\subseteq B\cup B$. But $B\cup B=B$, and we can conclude $A\cup B\subseteq B$. Meanwhile, Also $A\cup B\supseteq B$ since $A\cup B$ is a union of $B$ and something else. Since $A\cup B\subseteq B$ and $A\cup B\supseteq B$, we can conclude $A\cup B=B$. We have thus proven that $A\subseteq B\Rightarrow A\cup B = B$.
You do a similar thing to show that $A\cup B = B \Rightarrow A\subseteq B$, etc.
Addendum: Per the discussion below in comments, I think the heart of the matter is that while it might at first appear that proving the two implications "P implies Q" and "Q implies P" is strictly weaker than proving equivalence, it is actually no weaker!
"P implies Q" is the same thing as "It is impossible for $P(x)$ to hold without $Q(x)$ also holding." Meanwhile, "Q implies P" is the same thing as "It is impossible for $Q(x)$ to hold without $P(x)$ holding." Thus, if you prove both implications, you have established that it is impossible for $P$ and $Q$ to have different truth values in any model. In other words, they have the same truth value in every model. This reasoning is not contingent on assuming they have the same truth value: the claim that they always have the same truth value follows as a consequence of the pair of statements "P implies Q" and "Q implies P".
Comment: After reflecting on this for a few minutes, I think I figured out something about what is bothering you. (??) The thing is, if you prove that "if P holds, then Q holds", then you have also simultaneously [with no additional work] proven that "if Q is false, then P is false." To put it another way, if you can show that in all models in which P holds, Q also holds, then you have also shown that in any model in which Q fails to hold, then P fails to hold. Both these statements are (equivalent) variants of the statement that it is impossible for a model to satisfy P without satisfying Q.
Comment: As a consequence, if you can show that "P implies Q" and also "Q implies P", then you have simultaneously [with no added work] shown that "not P implies not Q" [this follows from "Q implies P"] and "not Q implies not P" [this follows from "P implies Q"]. Let me know if this clears it up; if so, I'll add a version of these ideas to the answer itself.
Comment: Yes! This is most definitely part of the confusion. Thank you for touching on this part; however, this only establishes that the biconditional is true in the "appropriate" conditions. (i.e. a biconditional is true when both P and Q have the same logical value...TT=T and FF=T). To fully satisfy a biconditional, though, don't we have to demonstrate that the biconditional evaluates to false when P and Q do NOT have the same truth value? (I think this is the crux of my issue, namely that we are only demonstrating when the biconditional evaluates to "True"...hopefully I didn't lose you).
Comment: My point above is that "P implies Q" is the same as the statement "P and not-Q is impossible". "Q implies P" is the same as "Q and not-P is impossible". Taken together, these two statements mean that P and Q always have the same truth value; in other words, they have the same truth value in every model. So if you prove both "P implies Q" and "Q implies P", then you actually have a proof that the biconditional holds in all models. Does that answer?
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/104207/discussion-between-ben-blum-smith-and-s-cramer).
Comment: Thank you for the response. The one question I have is in response to your phrasing, "...$P(x) \leftrightarrow Q(x)$ IN ALL SITUATIONS." All situations, to me, means all possible models. i.e. I also need to demonstrate that the biconditonal is behaving like a biconditional from all possible truth values of the propositions (so, for example, I need to show that when one proposition is false, the others are false...etc)
Comment: Close enough! Thank you for the help.
Comment: I think in your previous comment I've lost track of what you mean by "the biconditional". In my mind this is the statement "P implies Q AND Q implies P". This evaluates to false if P and Q do not have the same truth value because, for example, if P is true and Q is false, then "P implies Q" is false, therefore "P implies Q AND Q implies P" is false.
Comment: Yes, I was under the impression that if I wanted to claim that a statement was a biconditional, I would have to also show that it is false when P and Q do not have the same truth values. But after understanding a little more about entailment, I see that we really only care about demonstrating when statements are true. So, for example, when someone says "Prove the biconditional statement"...what they really mean is "Show that this biconditional statement can result in truth". At least I think that is correct.
Comment: No. I think that either you are not fully appreciating the strength of the statement "P implies Q", or else you are using a different meaning of "to prove" than the rest of us. (I am at this point quite engaged by the challenge of achieving full communication here, so I hope you'll stick with it! I won't be satisfied with "close enough" and I hope you won't be either!) A biconditional (i.e., the statement "P implies Q AND Q implies P") *is* false when P and Q have different truth values! And we *do* care about this!
Comment: My second-to-last comment *is a proof* that the biconditional is false when P and Q have different truth values!

It is a completely universal proof of this. I did not require any information about P and Q.

In other words, *any* biconditional is false when P and Q have different truth values.

You do not have to prove this for a *given* biconditional, not because it doesn't matter or people don't care, but because *it's already been proven!*
Comment: Ohhhhh, interesting. So we don't "prove" false statements. We only "prove" true statements. Is there a reason for this? Why is it that "truths" necessitate formal proofs but falsehoods do not necessitate formal proofs? (I feel like we may be running into issues regarding what is meant by "proof" haha)
Comment: What would it mean to prove a false statement? (If it's false, how would you prove it?)
Comment: The easiest thing I could think of would be the act of demonstrating a counter example.
Comment: (Yes I think the issue may be coming down to what is meant by "proof".)
Comment: Giving a counterexample is proving that a given statement (say P) is false. (Of course we need to do this!) But then P is not the statement you're proving with the counterexample. The statement you are proving with the counterexample is "not-P". So you are still proving something true.
Answer:
This is where my confusion arises. At first it seems like I need to demonstrate that the truth tables are identical...but then the advice in the parentheses seems to suggest that I only to prove that the biconditional is true when the propositions are true.

False on both accounts!
First: A truth-table wil do you no good for this problem. Truth-tables work nicely for problems in propositional logic, and if this would be a propositional logic problem, then indeed showing that their truth-tables are identical would indeed show logical equivalence ... but this is not a propositional logic problem; these statements are about sets.
Indeed, I would get it out of your head that the way to solve this problem is to show that the truth-functional biconditional between any pair of the statements is true. Again, this is not a propositional logic problem. Instead, you should just directly show that all three statements are logically equivalent.
Second: I have no idea where and how or why you get the idea that you have to show that the biconditional is true "when the propositions are true". Instead, you show that if one of the propositions is true, then the other two are true as well. To be precise: you have to show that if the first is  true, then the second and third are true, but you also have to show that if the second is true, then the first and the second are true, and that if the third is true, then the first and the second are true. If you do all that, then you will have shown that the biconditional between any two of them is a logical truth ... but more to the point: that they are all logically equivalent.
Now, this makes it sounds like you have to show six logical implications ... but in fact just three of them will suffice: if you can show that the first implies the second, that the second implies the third, and that the third implies the first, then it is easy to see that they all imply each other.
Comment: @S.Cramer Well, to be exact, the three statements given in the exercise are not logically equivalent, but rather what you might call *set-theoretically* equivalent. That is: you cannot derive the statements from each other purely on the basis of logical principles, be they from propositional or first-order logic, but you can derive them once you add the standard axioms for set-theory.
Comment: @S.Cramer "reciprocal logical entailment" is really the same thing as logical equivalence, and does still not refer to the fact that set-theoretic axioms are assumed. So, it should be "set-theoretic reciprocal logical entailment" or "set-theoretic logical equivalence"  ... but even that is a mouthful. I think "set-theoretic equivalence" captures what we want quite nicely; logic is always presumed in any field of mathematics, so no need to refer to that.
Comment: could you please differentiate logical equivalence in the context of sets versus logical equivalence in the context of propositional logic?
Comment: hmmmm. Would you agree that "reciprocal logical entailment" is an okay way of describing logical equivalence in the context of set theory (or any theory founded on axioms)?
Comment: @S.Cramer Yes, the phrase "logically equivalent" (analogous: "logically implies") in the given exercise may distractingly lead some of us to think about tautologies and logical validities. The weaker "equivalent in the context of some theory/ axiom system" (or simply "equivalent" without any modifier) is more technically accurate.
Answer:

In the math book that I am studying, the reader is asked to show that several statements are "logically equivalent"...and then in parentheses, the author says "[i.e.] any one of them implies the other".

This is where my confusion arises. At first it seems like I need to demonstrate that the truth tables are identical...but then the advice in the parentheses seems to suggest that I only need to prove that the biconditional is true when the propositions are true.

The claim being made by the text is that a set of propositional statements will be logical equivalents when any one of them will logically entail another.   That "any" indicates a universal claim: all.
That is that when $P\Rightarrow Q$, $P\Rightarrow R$, $Q\Rightarrow R$, $Q\Rightarrow P$, $R\Rightarrow P$, and $R\Rightarrow Q$ all hold, then and only then do $P\Leftrightarrow Q$, $Q\Leftrightarrow R$, and $R\Leftrightarrow P$ all hold.  (And so forth for more than three statements.)
However, it is sufficient to prove a cyclic chain such as: $P\Rightarrow Q$, $Q\Rightarrow R$, and $R\Rightarrow P$ and let Hypothetical Syllogism take care of the rest.
Comment: It seems like logical equivalence in the context of predicate logic is really the idea of "reciprocal logical entailment". Is that correct?
Comment: so "logical equivalency", in this context, takes on a different meaning from the one that I described? (For example, based on my definition, i.e. when two propositions have the same truth values across all models, the implication and the contrapositive connectives are logically equivalent).


Como saber a conexão atual que o sistema está usando no CakePHP 3.0?

Question: Olá, estou trabalhando com dois tipos de conexões em bancos de dados com configurações diferentes. Quero saber como eu posso pegar a atual conexão que a página está executando de forma dinâmica.
Atualmente eu uso isso:
<code> use Cake\Datasource\ConnectionManager;

 $conexao = ConnectionManager::get('default');
 $conexao->execute('set local "funcap.usuario" = "build";');
</code>
Mas isso me retorne informações sobre a conexão fixa <code>'default'</code>, eu queria algo mais dinâmico como:
<code> $conexão = ConnectioXxx::getCurrent();
</code>
Estou usando o CakePHP na versão 3.0
Answer: Essa resposta foi tirada do SOEN
.
Você pode fazer assim:
<code>$this->{$modelName}->connection()->config();
</code>


Proof Verification Regarding Image of $K$-homomorphisms of a Normal Extension

Question: Let $N$ be a normal extension of $K$, where $N,K\subseteq \mathbb{C}$, and suppose that $[N:K]=n$. Show that every $K$-homomorphism $\sigma:N\to \mathbb{C}$ satisfies $\sigma (N)=N$.
My Proof: Since $N$ is normal, we can assume that it is the splitting field of some irreducible polynomial $P\in K[X]$, and given that $[N:K]=n$, we know that $P$ is of degree $n$. Let $\alpha_1,...,\alpha_n\in \mathbb{C}$ be the roots of $P$. By definition of a splitting field we write $N=K(\alpha_1,..., \alpha_n)$.
For any element $b\in N$ we can write $b$ as a linear combination of the generators of $N$, i.e. $b=a_0+a_1\alpha_1+...+a_n\alpha_n$ where $a_i\in K$. We consider the image of $b$ under $\sigma$. By the $K$-linearity of $\sigma$ we obtain:
$\sigma (b)= \sigma (a_0+a_1\alpha_1+...+a_n\alpha_n)=a_0+a_1\sigma (\alpha_1)+...+a_n\sigma (\alpha_n)$
Since $\sigma$ is a $K$-homomorphism, it sends the roots of $P$ to their conjugates i.e. for any $\alpha_i$ for $1\leq i \leq n$, $\sigma (\alpha_i)$ is a conjugate of $\alpha_i$. Since $N$ is normal, we have that for any $1\leq i \leq n$, $\sigma (\alpha_i)\in N$. Therefore $\sigma (N) \subseteq N$. Since $\sigma$ is a ring homomorphism, it is injective, and an injective map $\sigma:N\to N$ must necessarily be a bijection, therefore $\sigma (N)=N$.
I am somewhat unsure of the points I made in the last paragraph as well as the assumption regarding linear combinations. Any corrections or verification of this proof would be greatly appreciated.
Thank you
Answer: I'm afraid there are some weak steps in your argument. Listing those I spotted

$N$ is a splitting field of some polynomial $P\in K[X]$ all right. However, you cannot conclude that $\deg P=[N:K]$. For example the splitting field of $x^3-2$ over $\Bbb{Q}$ is a degree six extension. You can select the polynomial $P$ to have degree $[N:K]$, if you select a primitive element $\alpha$ such that $N=K(\alpha)$, and then let $P$ be the minimal polynomial of $\alpha$ over $K$.
The zeros $\alpha_1,\alpha_2,\ldots,\alpha_n$ generate $N$ as an extension field of $K$. You seem to think that they generate $N$ as a vector space over $K$. This is not necessarily so. Not even if you include $K$ itself. Consider the polynomial $P(x)=x^4-2$. Its zeros come in pairs of negatives of each other, so they span a vector space of dimension two only. When we say that the zeros $\alpha_i$ generate $N$, we mean that we get all the elements of $N$ as products and quotients of $K$-linear combinations of the zeros. So elements like $\alpha_1^2\alpha_3/(2+\alpha_2^2)$ are not necessarily included yet. Because all the extension in sight are algebraic, we do get all the elements of $N$ as polynomials $f(x_1,x_2,\ldots,x_n)\in K[x_1,x_2,\ldots,x_n]$ evaluated at $x_i=\alpha_i, i=1,2,\ldots,n$.
A ring homomorphism is not necessarily injective. A homomorphism $f$ of fields OTOH is. This is because the kernel of a homomorphism of rings is an ideal, and the field has only the trivial ideals. As $f(1)=1$ we then necessarily have $\operatorname{ker}(f)=\{0\}$ proving injectivity of $f$.
Comment: So in selecting a primitive element $\alpha$, (given that it is a finite extension in $\mathbb{C}$), I can guarantee that its minimal polynomial will be of a degree $n$, and then since $\{\alpha^k | 0\leq k\leq n-1\}$ forms a basis of $K[\alpha]$ as a $K$-vector space, then my argument will work?
Comment: @SirJective: That is a better idea!
Comment: And to rephrase what you said for  2.(to verify my understanding), the irreducibility of $P$ does not guarantee the linear independence of the roots, so they do not necessarily span $N$ as a $K$-vector space. Also, if you could please clarify what you mean by your last sentence (for your second point) I would greatly appreciate it.
Comment: The last sentence in item 2 can be rephrased as follows: if $N=K(\alpha_1,\alpha_2,\ldots,\alpha_n)$ such that all the elements $\alpha_i$ are algebraic over $K$, then $N$ is spanned as a vector space over $K$ by the monomials $\alpha_1^{a_1}\alpha_2^{a_2}\cdots\alpha_n^{a_n}$, where $a_i$ are non-negative integers. Of course, we only need finitely many of such monomials. Most notably when you use a primitive element $\alpha$, you only need monomials $\alpha^k,0\le k<n$ (as you already pointed out).
Answer: Just to add: while $N$ being normal does imply that it is a splitting field of some $P\in K[x]$, $P$ need not be irreducible. More generally, a finite extension $N/K$ is normal iff $N$ is the splitting field of some $P\in K[x]$.

To complete your proof, let $N=K(\alpha_1,\cdots, \alpha_m)$ where the $\alpha_i$ are roots of $P$ in $N$ (and are all the roots in $\Bbb{C}$, since $P$ splits in $N$). Fix a $K$-homomorphism $\sigma:N\rightarrow \Bbb{C}$. $\sigma$ maps roots of $P$ to roots of $P$, and moreover is completely determined by the values $\sigma(\alpha_1),\cdots,\sigma(\alpha_m)$. But the roots of $P$ in $\Bbb{C}$ are precisely $\lbrace \alpha_1,\cdots,\alpha_n\rbrace$, so $\sigma(N)\subseteq N$.
$\sigma$ is injective since it's a $K$-homomorphism, and moreover is also a $K$-linear map. By the rank-nullity theorem, $N$ and $\sigma(N)$ are $K$-vector spaces of the same finite dimension, and so $\sigma(N)=N$.
Alternatively, avoiding the rank-nullity theorem, note that $\sigma$ permutes $\lbrace \alpha_1,\cdots,\alpha_n\rbrace$. Then, $\sigma(N)=K(\sigma(\alpha_1),\cdots, \sigma(\alpha_m))=K(\alpha_1,\cdots, \alpha_m)=N$.


Cannot build PROJ on windows - linker error with sqlite3

Question: What I really wanted is to build GDal, but that requires PROJ, which requires SQLite3. None of these are particularly user friendly when it comes to building. After 4 hours, I'm stuck. What I did so far:

download PROJ source
Download SQLite sqlite-amalgamation-3290000.zip source
Download sqlite-dll-win64-x64-3290000.zip .exe and .dll
In PROJ directory mkdir build and cd build
Run CMAKE with preset paths to SQLite:
cmake -DSQLITE3_INCLUDE_DIR=D:\sqlite3\src -DSQLITE3_LIBRARY=D:\sqlite3\bin\sqlite3.dll ..

Then run build: cmake --build .
Compilation suceeds but link fails

The error:
  Building Custom Rule D:/proj-6.1.1/test/unit/CMakeLists.txt
  main.cpp
  proj_errno_string_test.cpp
  Generating Code...
D:\sqlite3\bin\sqlite3.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x360 [
D:\proj-6.1.1\build\test\unit\proj_errno_string_test.vcxproj]

I don't know what the problem is. Maybe the .dll is not compatible? Maybe it should be .lib? None of that is documented in PROJ.
Comment: https://stackoverflow.com/questions/23718146/creating-an-sqlite3-lib-file-using-sqlite3-in-visual-studios I think the comment here: https://stackoverflow.com/questions/23718146/creating-an-sqlite3-lib-file-using-sqlite3-in-visual-studios#comment48229487_23718146 is helpful
Comment: There is also a port for proj4 in vcpkg. https://github.com/microsoft/vcpkg/tree/master/ports/proj4
Comment: `-DSQLITE3_LIBRARY=D:\sqlite3\bin\sqlite3.dll` shouldn't that be a `.lib` file (possibly an import library). You don't link `dlls`
Comment: @drescherjm That's one theory, but then in the compilation instructions they set it to `sqlite3.so`, which I thought is shared library on Linux. Anyway, I don't know where to get `sqlite3.lib`.
Comment: @drescherjm Thanks a lot, I will check it out as soon as I get home!
Answer: I hit this too -- the PROJ docs are showing Linux info in the Windows section!
From the directory with sqlite3.dll and sqlite3.def in the appropriate MSVC console run:
lib /def:sqlite3.def

to generate the import library and give that to cmake as the SQLITE3_LIBRARY define.
Comment: That got PROJ to build for me. Had to use `lib /MACHINE:x64 /def:sqlite3.def`.


Clarity textarea height to fit wizard page height

Question: Using Clarity and Angular 9, I have a button in the main content area which opens the wizard. Now in the wizard, I have a textarea which I want to fill the wizard content area. I'm able to get the width of textarea working by setting width: 100%.
But I am not able to get the same thing working for height.
Here is the stackblitz link which shows the problem.
https://stackblitz.com/edit/clarity-form-reset-xtyait
Answer: The textarea get the size from it's parent.
Some css togehter with Angular ::ng-deep wil do it:
::ng-deep .clr-control-container {
  height: 100%!important
}

::ng-deep .clr-textarea-wrapper {
  height: 100%!important
}

::ng-deep .clr-form-control {
  height: 100%!important
}

::ng-deep .clr-wizard-content {
  height: 100%!important
}

Here is your Stackblitz with resized textarea.
Comment: Is  `!important` really required? You should give it higher specificity instead. https://uxengineer.com/css-specificity-avoid-important-css/ I'm almost tempted to downvote because `!important` is such bad practice, a lot like `eval`


Optimal software package for bayesian analysis

Question: I was wondering which software statistical package do you guys recommend for performing Bayesian Inference.
For example, I know that you can run openBUGS or winBUGS as standalones or you can also call them from R. But R also has several of its own packages (MCMCPack, BACCO) which can do bayesian analysis.
Does anybody have any suggestions as to which bayesian statistics package in R is best or about other alternatives (Matlab or Mathematica?)
The main features I am looking to compare are performance, ease of use, stability and flexibility
Comment: fair points, although re:4 - this is not necessarily true if you include development time. Also, the R-based solutions (either interfacing with R or running as R packages) are typically using C/C++ for the sampling code.
Comment: (1) I do not think there is a package that could qualify as *optimal*. (2) Bayesian analysis does not only include sampling. (3) These R packages are useful for sampling: [Rtwalk](http://www.cimat.mx/~jac/twalk/#Rversion), [mcmc](http://www.stat.umn.edu/geyer/mcmc/). They only require programming the log-posterior but no package is infallible. (4) It is well known that, under appropriate programming: `R<(Matlab,Python)<C` in terms of efficiency (see e.g. [link](http://perso.telecom-paristech.fr/~garivier/code/index.php)).
Comment: similar question: http://stats.stackexchange.com/q/9202/5509
Comment: @user4733, the C++ based solutions are 5-10x faster than BUGS variants, and much more faster than R solutions, see my answer.
Answer: External BUGS variants are the standard. Working within R may be convenient, but I'd be surprised if those packages are as mature and perform as well. Using a library which bridges R and the external program is usually the most common compromise.
I use the jags/rjags combo (jags might be roughly considered a dialect of bugs). I haven't tried the other bugs variants, but the reports I've heard are that jags's performance and ability to deal with numerical issues is a bit better than the other bugs variants. I find jags easy to use, but of course, you need some knowledge of bayesian data analysis to know how to use it.
Comment: Yes but read a book first. Gelman's Bayesian Data Analysis is the canonical one, although Kruschke's doing bayesian data analysis has a lower barrier to entry (although perhaps not as low as the puppies on the covers suggest).
Comment: Hmm ok thanks for you advice! So you reckon that BUGS variants are the fastest way to do bayesian analysis?
Answer: Within the 3 BUGS variants (openBUGS/winBUGS, jags) jags seems to be the most promissing as for the future feature development, and openBUGS/winBUGS seem to be dead projects. However, jags is still lacking some niceties present in openBUGS/winBUGS (also look here). On the other hand, jags has removed some limitations present in WinBUGS, e.g.:
<code>x ~ dnorm(0, tau)
tau ~ dgamma(1.0E-3, 1.0E-3) # in WinBUGS, you cannot do this, 1.0E-3 is too small
                             # for dgamma (use e.g. dgamma(0.01, 0.01))
</code>
The good news is that with most models, you can run them in all the 3 tools with just minimal changes, so you can switch to different tool later without much problems (that's what I do).
However, for some reasons (e.g. lack of parallelism and interpreter nature), it is not true that these BUGS variants are fastest way to do bayesian analysis! In fact, quite the opposite. BUGS projects are good to test and develop complicated models on small datasets. Once you have the model developed, and need to run it repeatedly on large datasets, it is more efficient to use different tools.
For example the CppBugs / rcpp combo is said to be 5-10x faster than BUGS variants. The principle is that you basically compile your model into a C++ program, which runs much faster. Also have a look at Dirk Eddelbuettel's blog for Rcpp test - looks brutally fast. You can also play with parallelism.
You can also do parallel computation in WinBUGS using bugsparallel.
Comment: Andrew gelman have a promising project called Stan (http://mc-stan.org/) which basically is a bugs dialect that compiles down to c++ and that seems really fast compared to bugs.
Comment: @RasmusBååth You should make that its own answer.  `Stan` is likely to become *the* piece of software for Bayesian models.
Comment: Oh wow, ok thanks for all your advice, it was very useful :)
Comment: You are welcome. What is your research area? If it's ecology, I can recommend books on Bayesian analysis using WinBUGS in Population Ecology.
Comment: interesting, are there references on how cppbugs compares to jags? Since jags is written in C++, it's not immediately obvious how much overhead the interpretation layer would entail.
Comment: @AriBFriedman I was thinking of that but while Stan might become the piece of software of choice when doing Bayesian models I felt that at this point JAGS is more mature and more well documented. But feel free to make it into an answer :)
Comment: Here is another link about Rstan: http://blog.revolutionanalytics.com/2012/08/rstan-fast-multilevel-bayesian-modeling-in-r.html
Comment: @user4733, [at the CppBugs page](https://github.com/armstrtw/CppBugs) they state it is 5-10x times faster than WinBUGS, and [jags is comparable to WinBUGS](http://www.r-bloggers.com/how-fast-is-jags-2/), so you can also expect 5-10x times (could be even more, depending on the model etc.).
Comment: @Tomas, sorry for the delayed reply, got sidetracked for a few days. My area of research is medical/epidemiological. However, I would greatly appreciate your recommendations on books on Bayesian analysis using WinBUGS for ecology. Heck, If you have any good recommendations on books for Bayesian analysis or Bayesian networks, then that'd be great too!
Comment: @BYS2, ok, look at books of Marc Kery: [Introduction to WinBUGS for Ecologists](http://www.amazon.com/Introduction-WinBUGS-Ecologists-Bayesian-regression/dp/0123786053/ref=la_B0030DQH1U_1_1?ie=UTF8&qid=1345476996&sr=1-1) ([pdf here](http://www.lce.esalq.usp.br/arquivos/aulas/2010/LCE5813/Introduction%20to%20WinBUGS%20for%20Ecologists.pdf)), and [Bayesian Population Analysis using WinBUGS: A hierarchical perspective](http://www.amazon.com/Bayesian-Population-Analysis-using-WinBUGS/dp/0123870208/ref=sr_1_1?s=books&ie=UTF8&qid=1345477205&sr=1-1&keywords=marc+kery+hierarchical)
Comment: @Tomas, thank you very much for your suggestions! Cheers


Woocommerce Subscription Renewal Issues

Question:
I have a question regarding Woocommerce Subscriptions recurring payment.
I need to know what the plugin means when it says to charge every 2nd week.
Thank you so much in advance.
Answer: OK I just answered this question myself.  Yes it means every 2 weeks.  So Oct 23, Nov 6, Nov 20, etc...
Answer: Just to add some clarification for anyone else with a similar question, you can synchronize payments to specific days of the month or days of the week.
You can do this by first turning it on in Woocommerce > Settings > Subscriptions and ticking the box 'synchronize subscriptions'. Then you can adjust this per product.

Woocommerce Subscription Renewal Issues


Update location on map when I scroll map

Question: I got .plist file from client which have addresses and their latitude and longitude.
My requirement is, when I scroll mapview respective latitude and longitude would be updated and show proper location on map.
e.g. Suppose I have current location on map is New york and I drop a pin in new york. Now when I scroll my mapview to new jersey and if the latitude and longitude match with .plist file's latitude and longitude then the pin should be drop on new jersey location.
requesting you to provide soulution because this is a big block for me in my application.
Comment: you want to add pins dynamically when you scroll map? or you want to add all pins at a time?
Comment: As I scroll if latitude and longitude matches then pin should be dropped.
Answer: First, you have to parse your plist and store the latlong in a dictionary. Every time the map moves (map delegate methods e.g. mapDidMove will be called), loop in you dictionary and check whether the latlon is visible.
Answer:
find map view is scrolled refer determine if MKMapView was dragged/moved
if map view is scrolled then get map view(visible) area bounds in latitude and longitude refer Getting the bounds of an MKMapvIew
compare your pins locations if any falls in this region. if so add pin to map

Home this helps
Comment: even you can add all pins to map if you have few pins to show.
Comment: Thanks for reply but how can I check whether my pin locations fall in the visible region? How can I compare locations?
Comment: please check http://stackoverflow.com/questions/2752725/finding-whether-a-point-lies-inside-a-rectangle-or-not
Comment: nares, that's not a good answer, as the rectangle is in a 2D plane, you are on the surface of a sphere (the Earth). Doesn't work as an approximation either.
Comment: here rectangle is made with GPS co ordinates. means we are comparing same quantities. you can suggest if you have any better answer.


how to get text from handwriting image in python

Question: the image:

the image is handwritten line of text this is extracting the text some what but not the expect same in the image
and the code is
import cv2

img = cv2.imread("a.jpg")
img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
img = cv2.resize(img,(6000,100))

_, result1 = cv2.threshold(img,100,255,cv2.THRESH_BINARY)
_, result2 = cv2.threshold(img,100,255,cv2.THRESH_BINARY_INV)

adaptive_result1 = cv2.adaptiveThreshold(result1,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,199,5)
adaptive_result2 = cv2.adaptiveThreshold(result1,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,199,5)
adaptive_result3 = cv2.adaptiveThreshold(result2,100,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,199,5)
adaptive_result4 = cv2.adaptiveThreshold(result2,256,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,999,1)
# cv2.imshow("title",result)
# cv2.waitKey(0)
import pytesseract
from PIL import Image
from pytesseract import Output
configs = r'--psm 6 --oem 3'
pytesseract.pytesseract.tesseract_cmd =r'C:/Users/ASUS/OneDrive/Desktop/ubuntu file/tesseract.exe'

data = pytesseract.image_to_data(img, config=configs, output_type=Output.DICT)
print(*data['text'])
data = pytesseract.image_to_data(result2, config=configs, output_type=Output.DICT)
print(*data['text'])
data = pytesseract.image_to_data(adaptive_result3, config=configs, output_type=Output.DICT)
print(*data['text'])
data = pytesseract.image_to_data(adaptive_result4, config=configs, output_type=Output.DICT)
print(*data['text'])
# data = pytesseract.image_to_data(img, config=configs, output_type=Output.DICT)
# print(*data['text'])
# print(data.keys())

The Output
buttered off before. there, twinkling like new Yar sytemy, hung cuter of tempting Uwitationx they beaged hi to contre the extera
Answer: I have tried some image preprocessing techniques such as using dilation and manipulating the threshold. The image became crystal clear.

However, the confidence score sometimes is as low as 51, which means that you cannot really rely on the output. It is something that is related to the training of the engine.


jQuery find and replace anchor in child element

Question: I have some HTML that follows this pattern:

    Overview

I need to change the hash to an anchor, something like Overview
I can't seem to be able to select this using jQuery, mainly because I'm terrible with it. I was trying something like $("p.title > a").attr("href","http://www.someURL.com");  just trying to change the href.
Any help greatly appreciated! thanks
Comment: I don't see any wrong in your code
Comment: you need to put that function inside an event, such as http://api.jquery.com/ready/
Answer: Your code is perfectly alright. I smell something fishy though.
I think you are trying to access elements even before the are there or jquery isn't loaded. Otherwise that simple code should've worked.
Try this:

Check if jquery is loaded
Wrap your code in DOM ready:

Wrapping is like this:
$(document).ready(function(){
   //code goes here
});

Comment: You're right, stupid mistake that I didn't even realize. you can't select an element that isn't loaded. Thank you!
Comment: @MannfromReno, glad to have helped you ;)
Answer: As you can see, this works in jsFiddle: http://jsfiddle.net/GY5D7/ .
Perhaps there is something wrong with when you initialize the script. Try this:
$(document).ready(function() {
    $("p.title > a").attr("href","http://www.someURL.com");
});

Comment: Thanks very much, the elements were not loaded yet so obviously nothing could be selected or modified.
Answer: Try this code it should work
$('p.title').find('a').attr('href',"http://www.someURL.com");

Sorry I am wrong :(
Regards
Answer: Try this fiddle. JSFiddle
Your code seems to be alright though.
$(document).ready(function() {
    $("#btn1").click(function(){
        $("p.title > a").attr("href","#tab1");
        alert($("p.title > a").attr("href"));
    });
});

Answer: When that Javascript is firing, is your HTML rendered? It may not be.
Easiest fix: Wrap in $(document).ready()
There are two ways. Longhand:
$(document).ready(function () {
    $("p.title > a").attr("href","http://www.someURL.com");
});

Shorthand:
$(function() {
    $("p.title > a").attr("href","http://www.someURL.com");
});

Other ways
You don't have to wrap it in $(document).ready(). If you place that script at the end of the body, then it can work:

        Overview

You might not have jQuery loaded
Check your console by hitting F12. If you see an error that looks like this:
Chrome:

Firefox:

Internet Explorer:

Then you need to include jQuery in your document
Comment: Thanks, you're also right, I appreciate the answer/help.


Circular arrangements of $12$ people in which neither Ann nor Ben can sit next to Clair

Question: At a wedding ceremony there are 12 people, including Ann, Ben, Clair, are to be seated in a ROUND table with 12 chairs. In how many ways can they sit if neither Ann nor Ben can sit next to Clair?
First I calculated the possibilities which all 3 can sit together(So I can deduct it later) i.e. 9!3!
But how do I calculate the possibilities which only one person is sitting next to Clair?(Definitiely this should not include all 3 sitting together case)
Can you please guide me?
Comment: The number of seating arrangements with all three people together is not $9!3!$ since Clair must be in the middle.
Answer: Method 1:  We use the Inclusion-Exclusion Principle.
Unless otherwise specified, in circular permutations, it is only the relative order that matters.
First, we count the number of distinguishable seating arrangements.  We seat Clair.  Relative to Clair, the other eleven people can be seated at the table in $11!$ ways as we proceed clockwise around the table.
From these, we must exclude those seating arrangements in which Ann or Ben sit next to Clair.
Arrangements in which Ann sits next to Clair:  We treat Ann and Clair as a unit.  Since Ann can sit to the left or right of Clair, they can be seated in $2$ ways.  Once they are seated, the other ten people can be seated in $10!$ ways as we proceed clockwise around the circle.  Hence, there are $2 \cdot 10!$ such seating arrangements.
Arrangements in which Ben sits next to Clair:  By the argument given above for Ann and Clair, there are $2 \cdot 10!$ such arrangements.
Arrangements in which both Ann and Ben sit next to Clair:  Ann can sit to the left or right of Clair, with Ben occupying the other side, so the trio can be arranged in $2$ ways.  The other nine people can be arranged in $9!$ ways as we proceed clockwise around the circle.
By the Inclusion-Exclusion Principle, the number of permissible seating arrangements is
$$11! - 2 \cdot 2 \cdot 10! + 2 \cdot 9! = (11 \cdot 10 - 4 \cdot 10 + 2)9! = 72 \cdot 9!$$
Method 2:  We correct the solution proposed by pwerth.
We seat Clair.  The seat occupied by Clair and the two seats adjacent to Clair cannot be occupied by either Ann or Ben.  Hence, there are nine ways to seat Ann and eight ways to seat Ben.  The remaining nine people can be seated in $9!$ ways as we proceed clockwise around the circle from Clair.  Hence, there are
$$9 \cdot 8 \cdot 9!$$
permissible seating arrangements, which agrees with the answer obtained by using the Inclusion-Exclusion Principle.

But how do I calculate the possibilities which only one person is sitting next to Clair?

Method 3:  We subtract those arrangements in which exactly one of Ann or Ben sits next to Clair and those arrangements in which both Ann and Ben sit next to Clair from the total.
We showed above that there are $11!$ possible seating arrangements, of which $2 \cdot 9!$ have both Ann and Ben seated next to Clair.
Seating arrangements in which exactly one of Ann or Ben sits next to Clair:  Choose whether Ann or Ben sits next to Clair.  The chosen person either sits to the left or right of Clair, so Clair and that person can be arranged in two ways.  The seat on the other side of Clair cannot be occupied by the person who was not chosen, so that person must sit in one of the nine seats that is not adjacent to Clair.  The other nine people can be seated in $9!$ ways as we proceed clockwise around the circle relative to Clair.  Hence, there are $2 \cdot 2 \cdot 9 \cdot 9!$ such seating arrangements.
Therefore, the number of permissible seating arrangements is
$$11! - 2 \cdot 2 \cdot 9  \cdot 9! - 2 \cdot 9! = (11 \cdot 10 - 2 \cdot 2 \cdot 9 - 2)9! =  72 \cdot 9!$$
Answer: The problem question "in how many ways can they be seated?" is open to at least two interpretations.  In one, the chair positions are numbered, and rotations of any seating arrangement (12 are possible) are to be counted.
This leads to 12*9*8*9! seating arrangements.
Another interpretation, the one the problem author implied by mentioning "ROUND table", is that rotations don't count as unique arrangements.  There are 1/12 as many, or
9*8*9!
Comment: Your answer is incorrect.  How did you obtain $10 \cdot 9 \cdot 9!$?
Comment: I agree, N.F., with your analysis.  I made my corrections.


show this inequality to $\sum_{cyc} \frac {a^3b}{(3a+2b)^3} \ge \sum_{cyc} \frac {a^2bc}{(2a+2b+c)^3} $

Question: Let $a,b$ and $c$ be positive real numbers. Prove that
$$\sum_{cyc} \frac {a^3b}{(3a+2b)^3} \ge \sum_{cyc} \frac {a^2bc}{(2a+2b+c)^3} $$
This problem is from Iran 3rd round-2017-Algebra final exam-P3,Now I can't find this inequality have solve it,maybe  it seem can use  integral to solve it?
my attempts:
I took $p=3a+2b,$ $2a+2b+c$. $k=3$  and I wanted to use this integral:
$$\dfrac{1}{p^k}=\dfrac{1}{\Gamma(k)}\int_{0}^{+\infty}t^{k-1}e^{-pt}dt$$
but I don't see how it  helps.
Comment: I think it was a typo in the formulation. This inequality is true, but has a very ugly solution. The inequality with nice solution is the following. $\sum\limits_{cyc}\frac{a^3b}{(2a+3b)^3}\geq\sum\limits_{cyc}\frac{a^2bc}{(2a+2b+c)^3}.$
Comment: @MichaelRozenberg,I have add mu attempts,and take $p=3a+2b$,$2a+2b+c$.$k=3$,maybe can help?
Comment: This inequality is obviously true by BW, but this solution is not by hand.
Comment: Also, this inequality is obviously true after full expanding by AM-GM. But for the proof we need to use a computer again.
Comment: can you post your nice solution with $\sum_{cyc}\dfrac{a^3b}{(2a+3b)^3}\ge\sum_{cyc}\dfrac{a^2bc}{(2a+2b+c)^3}$?Thanks
Comment: Yes of course. But you need before to show us your attempts. If you'll make it and  this topic not would be closed, I'll post my solution in the evening. I found here something, which really is very nice.
Comment: By C-S we can get an  inequality with degree $11$, but it's still very ugly.
Answer: The proof of my inequality.

let $a$, $b$ and $c$ be positive numbers. Prove that:
  $$\tfrac{a^3b}{(2a+3b)^3}+\tfrac{b^3c}{(2b+2c)^3}+\tfrac{c^3a}{(2c+3a)^3}\geq\tfrac{a^2bc}{(2a+2b+c)^3}+\tfrac{b^2ca}{(2b+2c+a)^3}+\tfrac{c^2ab}{(2c+2a+b)^3}.$$

Indeed, by Holder and AM-GM we obtain:
$$\sum_{cyc}\tfrac{a^3b}{(2a+3b)^3}=\sum_{cyc}\tfrac{\left(4(2a+3b)+(2b+3c)+2(2c+3a)\right)^3\left(\tfrac{4a^3b}{(2a+3b)^3}+\tfrac{b^3c}{(2b+3c)^3}+\tfrac{2c^3a}{(2c+3a)^3}\right)}{2401(2a+2b+c)^3}\geq$$
$$\geq\sum_{cyc}\frac{\left(4\sqrt[4]{a^3b}+\sqrt[4]{b^3c}+2\sqrt[4]{c^3a}\right)^4}{2401(2a+2b+c)^3}\geq\sum_{cyc}\frac{\left(7\sqrt[28]{a^{12+2}b^{4+3}c^{1+6}}\right)^4}{2401(2a+2b+c)^3}=\sum_{cyc}\frac{a^2bc}{(2a+2b+c)^3}.$$
Answer: Using binomial inequality for
$$|c-a|<2a+2b+c,$$
one can get
$$\dfrac1{(3a+2b)^3}=\dfrac1{(2a+2b+c)^3}\left(1-\dfrac{c-a}{2a+2b+c}\right)^{-3}
\ge \dfrac1{(2a+2b+c)^3}\left(1+3\dfrac{c-a}{2a+2b+c}\right),$$
$$\dfrac{a^3b}{(3a+2b)^3}-\dfrac{a^2bc}{(2a+2b+c)^3} \ge \dfrac{a^2b}{(2a+2b+c)^3}\left(a-c-3a\dfrac{c-a}{2a+2b+c}\right),\tag1$$
The issue inequality can be presented in the form of
$$S\ge 0\tag2,$$
where
$$S = \sum\limits_\bigcirc \left(\dfrac{a^3b}{(3a+2b)^3}-\dfrac{a^2bc}{(2a+2b+c)^3}\right) \ge  \sum\limits_\bigcirc\dfrac{a^2b(a-c)}{(2a+2b+c)^3}
+3\sum\limits_\bigcirc\dfrac{a^3b(a-c)}{(2a+2b+c)^4}.$$
In according with the rearrangement inequality for the productions of
$$a\cdot a\cdot a\cdot \dfrac b{2a+2b+c}
+ b\cdot b\cdot b\cdot \dfrac c{2b+2c+a}
+ c\cdot c\cdot c\cdot \dfrac a{2c+2a+b}$$
and
$$a\cdot a\cdot c\cdot \dfrac b{2a+2b+c}
+ b\cdot b\cdot a\cdot \dfrac c{2b+2c+a}
+ c\cdot c\cdot b\cdot \dfrac a{2c+2a+b}$$
between $a$ and $c$ (where the ratio can be placed arbitrary), one can write
$$\sum\limits_\bigcirc\dfrac{a^3b}{(2a+2b+c)^3} \ge
\sum\limits_\bigcirc\dfrac{a^2bc}{(2a+2b+c)^3}$$
and similarly
$$\sum\limits_\bigcirc\dfrac{a^4b}{(2a+2b+c)^4} \ge
\sum\limits_\bigcirc\dfrac{a^3bc}{(2a+2b+c)^4},$$
so $(1)$ is valid.
$\textbf{Proved.}$
Comment: @Yuri Negometyanov Can you write sequences, for which you used Rearrangement. Your sequences $(a,a)$ and $(c,c)$  give $a^2+c^2\geq2ac$, which is true, but it's nothing here. Actually, components of sequences should be ordered, otherwise Rearrangement does not work.
Comment: To which numbers exactly is the rearrangement inequality applied?
Comment: @MartinR To subsequences $\{a,a\}$ and $\{c.c\}.$
Comment: Well, perhaps I am too dumb to see it. The rearrangement inequality states that $x_1 y_1 + x_2 y_2 + x_3 y_3$ is maximal if $(x_1, x_2, x_3)$ and $(y_1, y_2, y_3)$ are ordered in the same way (both ascending or both descending). What are  $(x_1, x_2, x_3)$ and $(y_1, y_2, y_3)$  in your case so that the final two inequalities are obtained?
Comment: @MartinR I think that the most clear way is to correspond the debominators with $b.$
Comment: Is it so difficult to give a clear answer? Something like  *"The rearrangement inequality is applied to $x_1 = \ldots, x_2 = \ldots $ etc, therefore ..."*  ?
Comment: @MartinR Thabk you for the productive discussion. Will be done.
Comment: @Yuri Negometyanov Explain please, how you used Rearrangement. I saw your correspondence with Martin R. I did not see the answer. Thank you! Also, if you'll see down-voting, it's not mine.
Comment: @MichaelRozenberg You are welcome! Using [this link](https://www.imomath.com/index.php?options=598&lmm=0), I see non-decreasing sequences $\{a,a\}$ and then $\{c,c\}$ in the sum of productions in the LHS and its permutations in the RHS. BTW, MartinR never stops dialogue if he has doubts.
Comment: @MichaelRozenberg Done.
Comment: Read please about Rearrangement.
Comment: @MichaelRozenberg Read my answer, please. If the permutaation changes non-decreasing order,then it decreases the sum.
Comment: Also, your  $(1)$ is wrong for $a>c$.
Comment: @MichaelRozenberg Is it a joke?  The task has cyclic symmetry.
Comment: It's not joke. It's wrong. If you want to write the cyclic sum, so you can do it. But you did not write it. Your $(1)$ is wrong and not follows from the previous. Why the cyclic versa will be true?  I think your solution is total wrong.
Comment: (1) is wrong because within the last parentheses, it should be $a-c + 3a\dfrac{c-a}{2a+2b+c}$.
Comment: However, (after correcting this error) $\sum_{\mathrm{cyc}} \dfrac{a^2b}{(2a+2b+c)^3}\left(a-c+ 3a\dfrac{c-a}{2a+2b+c}\right) \ge 0$ is wrong.


Expected occupied area of a surface covered with possibly overlapping random shapes.

Question: Given a surface with area $A$, what is the expected area of the region occupied by $k$ possibly overlapping random circles with equal radii $r$?
For example, I would like to estimate the area of the black region of this simulation.
If it helps, we can assume the edges of surface wraps around, so the surface is a torus. And instead of random circles, it can also be random squares.
I've tried to find an approximation by partitioning the space as a "pixel" grid and solve it as a K balls in N buckets problem. But I didn't find how to generalize it from balls to circles.
Comment: Hint: The expected area of the occupied area $C$ is the integral over $x$ in $A$ of $P(x\in C)$. What is $P(x\in C)$?
Answer: Making all the necessary assumptions to make this question nice, if a point has a probability $\frac{a}{A}$ of being covered by a small object of area $a$, then the probability of not being covered by it is $1-\frac{a}{A} = \frac{A-a}{A}$.
So the probability of not being covered by $k$ small independent objects is $\left(\frac{A-a}{A}\right)^k$ and the probability of being covered by at least one of them is $1- \frac{(A-a)^k}{A^k}$.
So the area covered is $A-\frac{(A-a)^k}{A^{k-1}}.$
Comment: @Alexandre Vassalotti: The last step was multiplying the probability by the area $A$
Comment: I have a similar problem. May I know what is "A", "a", "k" in the solution? Is "A" the 2D domain where the dots are or the projected area of the dots? So are "a" and "k"?
Comment: @Nelson: $A$ is the total area, $a$ is the area of each of the small objects, and $k$ is the number of small objects


What's the distance between black and white piano key balance rail pins?

Question: Piano keyframe consists of these parts:

The balance rail is marked (6) in the image, but there are two balance rail pin rows - in the picture only the pin row for white keys is marked(7).
You can clearly see two rows of balance pin rows (with red felt around them) - one for white keys and one for black keys:

What's the distance between those two rows? What's the offset?
I'm asking because I want to make a piano action.
Comment: That's immensely helpful, because what you really need is not the distance, but how to calculate the distance based on the other dimensions of your action. You might actually be better off finding a junk piano, pulling it apart, and copying its action.
Comment: I'd expect that it isn't standardised and that different manufacturers and different models will have different distances
Comment: The reason for wanting more detail is this isn't a piano building forum.
Comment: This seems like the type of question where some more detail on why you're asking would be helpful.
Comment: @Aaron How does it help you in answering the question? You either know the distance between those pins (on any specific piano(s)) or you don't. But in this particular case it' s because I want to make piano action from wood.
Comment: As the current answer suggests, you'll probably have to build some tests before you make the final project, unless the feel of the final action is not critical.
Answer: The balance rail and fulcrum point of the keys must produce an even feeling between black and white keys. White keys are longer and heavier than black keys so that is why their fulcrum point is further from the action and closer to the keyboard.
I'm not a piano designer or tech but the distance between the balance points must be different for different brands and models and is determined when the piano is designed based on the length, weight and balance point of the keys. From your diagram it looks as if the balance point is close to the center of the key. That means that a longer key will give you a larger distance between the balance points of the white and black keys.
The offset is probably roughly determined by the overall length and weight of the black and white keys. I can't say exactly what that would be but logically it should be about half of the difference of the key's overall lengths. Allowances would also have to be made for the difference in weight, especially since white keys have more mass on the playing end.
Comment: "probably different for different brands and models and is determined when the piano is designed based on the length, weight and balance point of the keys": indeed, the key dimensions are not the same in different pianos.
Comment: The pins are offset from the actual balance points, and their placement depends on additional factors like the bushings around them.
Comment: Looks like the amount and placement of the leads is also important for key balance. And I would guess each key might be individually balanced (using the leads) based on the hammer and desired feel for the particular note.
Comment: @phoog I re-worded that section a bit,  thanks for your comment!
Comment: Meanwhile, I found [What are the dimensions of piano keys, in inches?](https://music.stackexchange.com/q/53847/2257)
Comment: @phoog Interesting but unfortunately they don't talk about the overall length from the playing end to the action.
Comment: @Aaron I know they do not sit exactly on their balance points. Otherwise the keys would float in mid air.
Comment: @Aaron I was just using that as a visual reference point.
Comment: @JohnBelzaguy It assumes the pins are placed identically relative to the balance points, which I think neither of us can say for sure is accurate or not.
Comment: @Aaron I never said that, My point was that longer keys will likely give you a larger distance between the black and white balance points
Comment: @JohnBelzaguy Fair enough.


Using JS code on the WordPress site under Script

Question: I know WordPress should get a JS code a different and I would ask help what to do with this code:
<code>$('table tr:nth-child(n+1):nth-child(-n+8)').addClass('active');

$('#songs-load').on('click', function(e) {
 e.preventDefault();
 var $rows = $('.songs-table tr');
 var lastActiveIndex = $rows.filter('.active:last').index();
 $rows.filter(':lt(' + (lastActiveIndex + 10) + ')').addClass('active');
 });

$('#album-load').on('click', function(e) {
  e.preventDefault();
 var $rows = $('.album-table tr');
 var lastActiveIndex = $rows.filter('.active:last').index();
 $rows.filter(':lt(' + (lastActiveIndex + 10) + ')').addClass('active');
 });
</code>
https://codepen.io/pixelboutiqueuk-the-lessful/pen/JjogZXa
I tried to copy and paste the JS code inside script tag and it does not work. Can you tell me how I should use this code in WordPress?
Comment: Put it in one of your theme's JS files.
Comment: I tried as stated in the script tag and it does not work
Comment: "Doesn't work" in what way?
Comment: The result is not obtained as you see it in the codepen and all 20 lines that exist in the example are displayed, so the code is incorrect
Answer: You can load the script from an external file by enqueuing the external file using the wp_enqueue_script function.
// https://developer.wordpress.org/reference/functions/wp_enqueue_script/
However, if you do not want to load an extra file, use the wp_add_inline_script instead.
// https://developer.wordpress.org/reference/functions/wp_add_inline_script/
Example:
Add this code in the functions.php file.
<code>// a custom inline script
function a_custom_script_mod() {
    if ( wp_script_is( 'jquery', 'registered' ) ) {
        wp_add_inline_script( 'jquery', '
        (function($) {
            $(document).ready(function() {
                $("table tr:nth-child(n+1):nth-child(-n+8)").addClass("active");

                $("#songs-load").on("click", function(e) {
                    e.preventDefault();
                    var $rows = $(".songs-table tr");
                    var lastActiveIndex = $rows.filter(".active:last").index();
                    $rows.filter(":lt(\' + (lastActiveIndex + 10) + \')").addClass("active");
                });

                $("#album-load").on("click", function(e) {
                    e.preventDefault();
                    var $rows = $(".album-table tr");
                    var lastActiveIndex = $rows.filter(".active:last").index();
                    $rows.filter(":lt(\' + (lastActiveIndex + 10) + \')").addClass("active");
                });
            });
        })(jQuery);
    ');
    }
 }
 add_action( 'wp_enqueue_scripts', 'a_custom_script_mod', 9999);
</code>
Comment: I tried to enter the code you wrote in .. its not work
Comment: Did you purge the cache? Do you see any errors in the browser console? Please provide further details about the issue so that we can understand it better.
Comment: The error is that the code actually does not work because as in not the example in codepan I see straight 20 lines and the button does not work and go to the top of the page.
Comment: The code actually works on our end. It starts with 8 entries and display more when the load more button is clicked. Are you sure that Javascript is enabled in your browser?
Comment: Yes I'm sure. So how to get to it? Did you enter this code in a script? Where exactly did you place it and how?
Comment: You have to add the a_custom_script_mod function and the wp_enqueue_scripts hook in the child theme's functions.php file. But if you have not installed a child theme yet, just add it in the parent theme's function.php file.
Comment: Copy and paste the code in functions.php file as it appears in the codepen or as you wrote?
Comment: You have to use the custom inline script that was provided above, or the snippet that is using the wp_add_inline_script function. Add it in the functions.php file.


Insert sequencia Oracle

Question: Pessoal boa noite estou querendo inserir dados em uma tabela , que tem uma sequencia criada, mas ao tentar inserir o dado com o nextval ele apresenta o seguinte erro

Erro Erro de SQL: ORA-00911: caractere inválido

00000 - "invalid character"

*Cause: identifiers may not start with any ASCII character other than
letters and numbers. $#_ are also allowed after the first
character. Identifiers enclosed by doublequotes may contain
any character other than a doublequote. Alternative quotes
(q'#...#') cannot use spaces, tabs, or carriage returns as
delimiters. For all other contexts, consult the SQL Language
Reference Manual.
CREATE TABLE CursoSequencia (
    cod_curso NUMBER(3),
    nome_curso VARCHAR2(30) NOT NULL,
    carga_hor NUMBER(3),
    CONSTRAINT cursoSquencia_cod_pk PRIMARY KEY(cod_curso)
);

CREATE SEQUENCE cod_curso INCREMENT BY 1
START WITH 1001;

INSERT INTO CursoSequencia VALUES(cod_curso.nextval, 'AdministracaoOracle',3);

INSERT INTO CursoSequencia VALUES(cod_curso.nextval, 'AdministracaoSQLServer',3);

Comment: Só pra confirmar... é PostgreSQL ou Oracle?
Comment: A chave tem tamanho de três a sequence começa de 1001 !?
Comment: @CamiloSantos o erro já confirma que é oracle. Felipe, acredito que você colocou a tag postgresql por engano.
Comment: George, fiz a remoção da *tag* pois o erro é referente à Oracle SQL. PostgreSQL não apresenta erros **ORA**.
Answer: Olá Felipe!
Fazendo uma rápida tradução do erro apresentado, ORA-00911, sabemos que foram encontrados caracteres inválidos em sua query que está impedindo a sua execução. Porém, encontrei um outro pequeno problema na parte DDL de seu código.
Vou separar os problemas que encontrei no seu código em duas partes.

O no seu comando DML, em específico, na coluna nome_curso VARCHAR2(30), do qual você está utilizando as aspas simples  '  ao invés   ' , note que visivelmente, o problema é justamente esse, você está utilizando as aspas simples no padrão americano e isso resulta no conflito de caractere inválido. Altere as aspas utilizadas nos valores characteres 'AdministracaoOracle' para 'AdministracaoOracle'.
Note que a sua SEQUENCE foi definida para ter a contagem do seu valor inicial à partir do valor 1001, logo, sabemos que esse valor se aplicará à um total de 4 caracteres ou mais. Ao definir a quantidade total de caracteres de sua PK para 3 digitos: cod_curso NUMBER(3), você terá o erro (ORA-01438), dessa vez ocasionado pelo total de caracteres retornado do cod_curso.nextval, justamente porque a SEQUENCE retornará um total de 4 dígitos e o permitido da sua coluna cod_curso está sendo 3 dígitos.

Resolvendo esses dois itens acima, você terá seu SQL funcionando normalmente.
Fontes:docs.oracle, dba-orable.
Fiddle com as correções aqui.
Comment: Ótimas observações Andre!
Comment: Agradeço David, estamos aqui para nos ajudar!
Answer: Se você criou uma sequence que irá fazer o auto incremento, no momento de fazer o insert não precisa informar o id, o banco irá adicionar automaticamente.
Portanto, basta fazer o seu insert dessa forma:
INSERT INTO CursoSequencia (nome_curso, carga_hor) VALUES ('AdministracaoSQLServer',3);
Comment: Na verdade depende Isaias. Ele só não precisa informar a coluna se ele criou uma triger before insert. Se apenas uma sequence foi criada ele tem que colocar a coluna ainda.

Insert sequencia Oracle


Logistic regression link function from optimization perspective

Question: I learned the logistic regression from optimization context instead of statistics context.
Logistic regression is trying to minimize logistic loss. I know there are two forms, but they are identical. Essentially from probability perspective, we are doing max likelihood on Bernoulli probability models.
Why there are two different logistic loss formulation / notations?
Now how the other link function play different rows here? In addition to logit link we have probit link
Difference between logit and probit models
Are we essentially changing logistic loss to something else? Why I never heard of "probit loss"?
Comment: I tried to give an answer, as I come from a similar perspective! Note that you have a typo in the question title: missing "i" in l**i**nk
Comment: @GeoMatt22 thanks for your answer and suggestions. typo fixed!
Comment: What is the question here exactly?  Are you asking if there is a way to formulate bernoulli regression with a probit link as a loss of the form $\log(1+ \exp(−y \hat{y}))$, as per the question [you linked](http://stats.stackexchange.com/questions/229645/why-there-are-two-different-logistic-loss-formulation-notations)?
Comment: @AndrewM I was trying to ask what's the objective function for other link functions. and if there are any intuitive explanations for other objective functions.
Answer: As I understand it*, link functions are associated with Generalized linear modeling (GLM). The link function is used to relate the (conditional) expected value of the dependent variable $y$ to a linear predictor constructed from the independent variables $x$, i.e.
$$g[\langle y\mid x\rangle]=L[x,\theta]$$
where $g[\,]$ is the link function and $L[\,]$ is the linear predictor, parameterized by $\theta$, which is to be estimated by MLE, assuming i.i.d. data $y$. The link function is relatively unconstrained, but to be admissable it must have an appropriate domain and range, and it must be invertible.
For the case of Bernoulli distributed data $y\sim\mathrm{Bern}[p]$, the left hand side becomes $g[\,p[x]\,]$, where $p[x]=\langle y\mid x\rangle$ is the conditional mean.
Now in machine learning, the "loss function" is commonly derived from MLE, where it is defined as the negative log-likelihood of the data given the parameters. For MLE involving exponential-family (conditional) PDFs, the log is convenient, but note that any monotonic (i.e. invertible) function could be used for optimization.
As I understand it*, in GLM the log-loss corresponds to the "canonical link". In the Bernoulli case this would be the logit function, which gives logistic regression. For probit regression the probit function would be used instead.
One final note: from an optimization perspective, GLM operationally gives a framework to translate many estimation problems into nonlinear least squares problems that can be solved with standard techniques that leverage existing linear LSQR toolkits.
(*I am not very familiar with GLMs, so parts of this may very well be wrong. Any corrections would be appreciated if so!)


Como definir uma cláusula where dinamica no mysql?

Question: Tenho 2 tabelas "pessoas" e "empresas", na tabela de pessoas existe o campo "endereco_correspondencia", que pode receber "empresarial" ou "residencial".
Preciso de uma busca onde defino UFs, por exemplo ["SP", "RJ"] e me retorne as "pessoas" onde a UF é a mesma definida em "endereco_correspondencia".
Segue o código que tentei sem sucesso, mas pode ajudar a resumir a pergunta:
SELECT nome  FROM pessoas
LEFT JOIN empresas ON empreas.id = pessoas.empresa_id
CASE pessoas.endereco_correspondencia  = 'residencial'
THEN WHERE pessoas.uf IN('SP','RJ')
ELSE WHERE empresas.uf IN('SP','RJ');

Isso realmente é possivel de se fazer? se sim, sobre oque preciso estudar?

<!DOCTYPE html>

<title>Diagrama sem nome.drawio.html</title>
<meta charset="utf-8"/>

<div class="mxgraph" style="max-width:100%;border:1px solid transparent;" data-mxgraph="{"highlight":"#0000ff","nav":true,"resize":true,"xml":"<mxfile host=\"app.diagrams.net\" modified=\"2022-08-30T14:20:49.303Z\" agent=\"5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/220.127.116.11 Safari/537.36\" etag=\"ya4NmdY-ZdcqZ8pL7N_F\" version=\"20.2.7\" type=\"device\"><diagram id=\"YhfaojcMS7rL5nVXc_Fy\" name=\"Página-1\">7ZhRb5swEMc/DY+bMASWPC40W6ulUrU8bG+VCwasGB8ypgn99DuCHUJRpLRdlEmLhBTu77N95985usTxo2L7XdEyv4eECcdzk63j3zieR9xpgB+t0nRKQEgnZIonxqkXVvyF2ZlGrXnCqoGjBhCal0MxBilZrAcaVQo2Q7cUxHDXkmZsJKxiKsbqL57ovFOn3pdev2U8y+3OJJx1IwW1ziaTKqcJbA4kf+H4kQLQ3VuxjZhoD8+eSzfv25HRfWCKSX3KhHTdSPZjdkd+T+6qRfp869fNJ69b5ZmK2iT8wKoKaGVi1o09iGrDC0ElWvMUpF6ZERftOOciWdIG6jaQStN4ba15Doq/oD8VOERQwGGlDWcvHHis2plmTcUq9Hmw2ZFX0j3dDhyXtNI2GhCClhV/2sXXTiyoyricg9ZQGCcqeCbxPca1mLI5dVGRCdrmXJjSbHv0wMkeI9Y/g4Jp1aCLnWBr2JT+1Jibvo5IaLT8sIYmoalfU7vZfukeL74Ywm+g7Y9oS1zZiTznqzsCjonrHS8FaxaBADymGwldBXAhXklVSWMusyVL2zQmvfLTZNZKgAeait0tyHmSMNkCBE01fdpXUwlc6l3mwRwfDCxyPwdOgDFFaJPexqd1VzoCiWFSvuPCsBQ2rC2HAVTvVKjH78mYtCHrhaeR9d0zgZ2MwNbpFej7gQaXBkrCEVFWlPhdRx9x3n9AVkEtE5aYjc7FeXppzsEYM6atWAyPMSjkXQLaMub0Cv1vQSfk0tRtDzy+3de268Ntlzd7X9s1PVfXRcZN9rXtOu0ikyOo/5W+i4w76mvj9SGkZ+y80Ox/be/GDv6z8Bd/AA==</diagram></mxfile>","toolbar":"pages zoom layers lightbox","page":0}">

Comment: Não está claro o que você quer de dinâmico como diz no título da pergunta. E não pode usar vários WHEREs, para múltiplas condições use AND e/ou OR numa única cláusula WHERE.
Comment: Com o dinâmico, me referi que á condição e feita em tempo de execução, como em um looping, que imagino que deve se comportart parecido em uma instrução SQL, mas realmente 'dinâmico', não foi a melhor abordagem pra definição dessa pergunta.
Comment: where ( (pessoas.endereco_correspondencia = 'residencial' and
         pessoas.uf IN('SP','RJ')
         or
        (pessoas.endereco_correspondencia <> 'residencial' and
         empresas.uf IN('SP','RJ') )
Answer: você usa o case no where desta forma: tenta assim -->
SELECT nome FROM pessoas
LEFT JOIN empresas ON empreas.id = pessoas.empresa_id
1=1
AND CASE
          WHEN pessoas.endereco_correspondencia  = 'residencial' THEN pessoas.uf IN('SP','RJ')
          empresas.uf IN('SP','RJ')
      END;

você pode ler mais em: https://www.mysqltutorial.org/mysql-case-function/


How do I collect field values of a submitted webform?

Question: I'm trying to integrate a Mailchimp mailing list into Drupal. The Mailchimp list requires:

First Name
Last Name
E-Mail

The client already has a list in this format so ideally I need to collect this data in Drupal.
I want to have a newsletter block that collects the email address and forwards a user to another page that has the full newsletter sign up with first name last name and the email but pre filled out.
I know I'm going to need Rules and Webform. But how can I collect the value of the webform field and use it again as a token later?
Note:  I am using this within the Drupal setup, but the list requires three fields of data (first/lastname/email). I want to have a block that initially collects the email and forwards them to the full newsletter signup page. I have the webform and rules working to direct the user from the page with the block to the signup page, but I need to find out how to create a custom token from the field.
Comment: Did you know there's a [MailChimp module](http://drupal.org/project/mailchimp)?
Comment: Yes i am using it within the drupal setup, but the list requires three fields of data first/lastname/email

I want to have a block that initially collects the email and forwards them to the full newsletter signup page, i have the webform and rules working to direct the user from the page with the block to the signup page but i need to find out how to create a custom token from the field
Answer: Have a look at Webform Mailchimp , different approach but may be of use

Provides a webform component that lets users subscribe to a Mailchimp
  newsletter as they submit a webform.
Answer: You do have access to all labels and all values of any field of a webform, ie:

[data:MachineFieldName-title] contains the Label of a field with machine name MachineFieldName.
[data:MachineFieldName-value] contains the Value of a field with machine name MachineFieldName

So in your case, you might be able to get it to work using something like [data:email-id] (assuming that's what corresponds to the "email field" in your case).
For way more details on this, and a prototype rule about this, refer to the answer to "How to create a node from a Webform using rules?":

the 1st attempt relates to using "Entity has field" (which doesn't work for Webform)
the 2nd attempt explains what to do in case of Webform.

Even though the above is a good start, it may not be sufficient to achieve your goal (= "... how can I collect the value of the webform field and use it again as a token later ...", as in your question).
However, you can use a technique similar to what is described in my answer to "How to do a data comparison to submitted webform data when using the Rules module?". For short:

Add an extra Rules Action to Add a variable, with a value assigned to it equal to your [data:EmailField-value-raw] (and with an appropriate data type). I'm assuming your eMail field in your webform has a machine name like EmailField (adapt to fit your machine name).
In your subsequent Rules Actions you can refer to the value of this variable you just added (that's the clue!).

PS: I'm assuming this question is about D7.
Answer: I dedicate a blogpost on how to add a custom WebformSubmitHandler to process the data. Read about it here: https://stefvanlooveren.me/blog/how-create-mailchimp-subscription-drupal-8-webform-module


Logarithmic inequalities

Question: Full disclosure: This is a homework problem, but my question is regarding a concept that came about during solving the problem, not the actual solution to the problem.
Problem: Rewrite as geometric power series (might not be correct formulation of problem, I'm still learning :] )
$$\sum_{n=0}^{\infty} (\ln x)^n$$
Formulating this as a geometric series with $a_1=1$ and $r=\ln x$, it converges to $$S=\frac{1}{1-\ln x}$$ if $|\ln x| < 1$.
I rewrite the above inequality to get rid of the absolute value as $-1 < \ln x < 1$.
Now, when I exponentiate (to undo the log), I get $$e^{-1} < x < e^1$$
The question: If the interval contained negative numbers, would I truncate it just to contain positive numbers as the argument of a log cannot be negative?
Answer: Do you mean your final interval?  That can't happen, since a positive number raised to any power (positive or negative) is positive.  (After all, that's why the argument of a log can't be negative.)
Comment: now that you put it that way the base can't be negative so exponentiation will never beget a negative value. Makes sense thanks :)
Comment: @JaneDoe: With just a little work, I think you can show this formula is valid even for *complex* values $z=re^{i\theta}$ as long as $e^{-1}<r<e$ and $|\theta| < \sqrt{1 - (\ln r)^2}$.

Logarithmic inequalities


Cannot set nivo pie chart color scheme

Question: I integrated the nivo library. I managed to get this pie chart to work:

For this, I used this slightly modified code from the example:
<ResponsivePie
  data={data}
  margin={config.margins}
  padding={0.3}
  colors="nivo"
  borderColor="inherit:darker(1.6)"
  animate
  motionStiffness={90}
  motionDamping={15}
  legends={config.legends}
  sortByValue
  innerRadius={0}
  padAngle={0}
  cornerRadius={0}
  borderWidth={0}
  radialLabelsSkipAngle={10}
  radialLabelsTextXOffset={6}
  radialLabelsTextColor="#333333"
  radialLabelsLinkOffset={0}
  radialLabelsLinkDiagonalLength={16}
  radialLabelsLinkHorizontalLength={24}
  radialLabelsLinkStrokeWidth={1}
  radialLabelsLinkColor="#CCCCCC"
  slicesLabelsSkipAngle={10}
  slicesLabelsTextColor="#333333"
/>

Now, I wanted the colors to be a grayscale, so I changed the colors prop to "greys", as shown in their docs:
colors={{ scheme: 'greys' }}

This results in:

I also tried:
colors="greys"

Using "greens" also results in the same.
If you want to try it out:

What do I need to do?
Comment: Not familiar with nivo but the docs says that it's the right syntax. Can you create a codesandbox?
Comment: @MoshFeu check the updated post.
Answer: I see that this is an old question, but I recently encountered the same issue when integrating with nivo. However I did find a solution so I decided to share it anyway.
After playing around with it I found that the code provided in the interactive view is not valid in React, if you would like to use a theme you should use the following syntax:
colors={"nivo"} // or the name of the theme you picked

instead of:
colors={{ scheme: 'nivo' }}

PS: If you want to use some of the other themes you might need to supply them additionally since just a couple of them come with nivo by default.
Comment: It's so old that I can't check whether this works, but thanks anyway for sharing your solution!
Answer: The property name is not colors, it's color:
color={{ scheme: "nvio" }}

Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).

Cannot set nivo pie chart color scheme


extjs : how can I hide series name from legend?

Question: I want to hide a series name from legend, how can I do it ?
Ext.each(chart.series.items, function(series) {
            if (series.yField = 'done') {
                alert('found done');
                // hides the series
                series.hideAll();

                series.showInLegend = false; // STILL SHOWS
                return false;
            }
        });

Any help is appreciated.
Answer: In the Ext js 6.2 have the option "showInLegend" within the series. :)
Comment: It's unclear how this answers the question at hand. Can you expand on this to tell us what steps to take to resolve the problem described in the question?
Answer: There is a workaround you can do to specifically target certain legend entries, e.g. if you specify a template for the legend:
legend: {
    itemTpl: [
        '<tpl if="value != seriesToHide">', // <= template condition
            '{name}',
        '</tpl>'
    ]
}

You can use the template condition to show/hide certain entries depending on the passed value (if this doesnt work, replace value with name).
Alternatively, you can also assign the template a class, e.g. x-legend-series-{name} and in your CSS file, create classes following that pattern for those series you wish to hide, e.g.
.x-legend-series-seriesToHide{
  display:none;
}

e.g.
legend: {
    itemTpl: [
        '<tpl>',
           '',
              '{name}',
           ''
        '</tpl>'
    ]
}

Comment: so the `showInLegend` property is no use in Extjs?? How can I do this via the controller?
Comment: Its implementation is spotty, you should make sure that on the chart object itself, you specify the legend property as an object, within which you specify a position. showInLegend will then work, but not for all chart types. E.g. on the chart object, add: legend:{position:'top'}}
Comment: Yes I have the position in the legend object, but still showInLegend doesn't work. I think I'll go by your solution, but how can I assign the `name` parameter dynamically via the controller? can I put the names in an array and loop in the template? Because I have many names I need to hide...