Networking, MST between HPE and CISCO switches

Question: can anybody help with this issue?
I have 2 HP Procurve switches 2650 and one Cisco switch 2950 connected together like this:
HP MST root (prio 16384) <-> HP IST root (prio 24576) Trk1 <-> Po1 Cisco IST member (prio 32768).
There is a MSTP configured on all of them.
My problem is that the Cisco switch claims itself to be the IST master:
C2950C24_01#show span mst

###### MST00        vlans mapped:   1-4094
Bridge      address 000a.b7b8.4e40  priority  32768 (32768 sysid 0)
Root        address 0015.6033.dc00  priority  16384 (16384 sysid 0)
            port    Po1             path cost 120000
IST master  this switch
Operational hello time 2, forward delay 7, max age 12
Configured  hello time 2, forward delay 7, max age 12, max hops 20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/4            Desg FWD 200000    128.4    Edge P2p
Fa0/5            Desg FWD 200000    128.5    Edge P2p
Fa0/8            Desg FWD 200000    128.8    Edge P2p
Fa0/9            Desg FWD 200000    128.9    Edge P2p
Fa0/10           Desg FWD 200000    128.10   P2p
Fa0/11           Desg FWD 200000    128.11   Edge P2p
Fa0/13           Desg FWD 200000    128.13   Edge P2p
Fa0/14           Desg FWD 200000    128.14   Edge P2p
Fa0/15           Desg FWD 200000    128.15   Edge P2p
Fa0/17           Desg FWD 200000    128.17   Edge P2p
Fa0/18           Desg FWD 200000    128.18   Edge P2p
Fa0/20           Desg FWD 200000    128.20   Edge P2p
Fa0/21           Desg FWD 2000000   128.21   Edge Shr
Fa0/22           Desg FWD 200000    128.22   Edge P2p
Po1              Root FWD 100000    128.65   P2p Bound(RSTP)

C2950C24_01#

Even if it receives BPDUs from the middle HP switch that has got lower prio.
(Lets ignore now the MST root - left HP switch)
C2950C24_01#sh spanning-tree det

 MST00 is executing the mstp compatible Spanning Tree protocol
  Bridge Identifier has priority 32768, sysid 0, address 000a.b7b8.4e40
  Configured hello time 2, max age 12, forward delay 7
  Current root has priority 16384, address 0015.6033.dc00
  Root port is 65 (Port-channel1), cost of root path is 120000
  Topology change flag not set, detected flag not set
  Number of topology changes 14 last change occurred 09:52:38 ago
          from Port-channel1
  Times:  hold 1, topology change 19, notification 2
          hello 2, max age 12, forward delay 7
  Timers: hello 0, topology change 0, notification 0

.
.
 Port 65 (Port-channel1) of MST00 is root forwarding
   Port path cost 100000, Port priority 128, Port Identifier 128.65.
   Designated root has priority 16384, address 0015.6033.dc00
-->  Designated bridge has priority 24576, address 001f.281e.4100
   Designated port id is 64.51, designated path cost 20000
   Timers: message age 4, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   Link type is point-to-point by default, Boundary RSTP
   BPDU: sent 36733, received 18973

C2950C24_01#

Here is the output from the middle HP switch:
  H2650G48_12# sh span
  Multiple Spanning Tree (MST) Information
  STP Enabled   : Yes
  Force Version : MSTP-operation
  IST Mapped VLANs : 1-4094
  Switch MAC Address : 001871-218080
  Switch Priority    : 32768
  Max Age  : 12
  Max Hops : 20
  Forward Delay : 7
  Topology Change Count  : 659
  Time Since Last Change : 10 hours

  CST Root MAC Address : 001560-33dc00
  CST Root Priority    : 16384
  CST Root Path Cost   : 20000
  CST Root Port        : 49
  IST Regional Root MAC Address : 001f28-1e4100
  IST Regional Root Priority    : 24576
  IST Regional Root Path Cost   : 20000
  IST Remaining Hops            : 19
  Root Guard Ports :
  TCN Guard Ports  :
  BPDU Protected Ports :
  BPDU Filtered Ports  :
  PVST Protected Ports :
  PVST Filtered Ports  :
                 |           Prio             | Designated    Hello
  Port Type      | Cost      rity  State      | Bridge        Time  PtP Edge
  ---- --------- + --------- ----- ---------- + ------------- ----- --- ----
  .
  .
  Trk1           | 200000    64    Forwarding | 001871-218080 2     Yes No
H2650G48_12#

Here are the running-configs of the Cisco and the middle HP switch.
What could be wrong there ??
    C2950C24_01#sh run
Building configuration...

Current configuration : 5237 bytes
!
version 12.1
.
.

spanning-tree mode mst
no spanning-tree optimize bpdu transmission
spanning-tree extend system-id
!
spanning-tree mst configuration
 name LKN1
 revision 1
!

The middle HP switch:
H2650G48_12# sh run

Running configuration:

; J4899B Configuration Editor; Created on release #H.10.119
.
.
trunk 45-46 Trk1 LACP
.
.
spanning-tree
spanning-tree protocol-version MSTP
.
.
spanning-tree Trk1 priority 4
spanning-tree config-name "LKN1"
spanning-tree config-revision 1

H2650G48_12#

Thank you for your comments
Answer: Your priorities tie so lowest mac wins which is Cisco.
Cisco
  Bridge Identifier has priority 32768, sysid 0, address 000a.b7b8.4e40

HPE
  Switch MAC Address : 001871-218080
  Switch Priority    : 32768

I'd have to lab this one up to confirm, but I suspect you can resolve by issuing by lowering your trk1 priority to 2 or 3 on the HPE or force the priority on the instance.
spanning-tree instance 1 priority 1


UML class diagram association name for scope like relation

Question: how de we call and denote an association like one that child and parent scopes have?
+--------------------+                          +-------------------+
|    parent scope    | <――――――――――――――――――――――x |    child scope    |
+--------------------+                          +-------------------+

Parent to child association is clear, the parent is not allowed to access the child.
Child to parent association however is restricted, the child can't fully access the parent object, it only can lookup for a specific identifier, yet the identifier has to be missing in the child object.
Answer: Your diagram means that the association is navigable from Child scope to Parent scope,  but that it is not navigable from the Parent scope to Child scope.
Navigation is about a promise of efficiency at run-time:

Navigability means that instances participating in links at runtime (instances of an Association) can be accessed efficiently from instances at the other ends of the Association. The precise mechanism by which such efficient access is achieved is implementation specific. If an end is not navigable, access from the other ends may or may not be possible, and if it is, it might not be efficient.- UML 2.5.1 specifications.

So it is not a question of "being allowed", but about the ease and efficiency of such access.
There is however a mismatch between your diagram an the narrative. Assuming that navigability in your context is implemented with the use of an identifier with an efficient way to find back the instances of a class based on that identifier:

navigability from Child scope to Parent scope means that the child would know the identifier of its parent.
the non-navigability from Parent scope to Child scope would mean that the parent does not have the identifier of its children, and would have to find all the instances of the child class and ask the child who the parent is.  Extremely infefficient.

(Note that this is really impelmentation specific.  If you'd implement such a model in an RDBMS,  there would be no navigability issue,  since it is always easy and relatively efficient to query children based on their parent id.).
Comment: Thank you for taking the time to answer my question. Is there a term to indicate a 'partial' navigability? The child object can not fully navigate through the parent object
Comment: @Slev7n there is no specific term defined in the UML specifications.  "Unidirectional" vs "bidirectional" associations are commonly used and understood.  However it's slightly ambiguous (i.e. an association is always bidirectional in the sense that the inverse relationship is always defined independently of navigability): I'd rather recommend  "unidirectional" vs "bidirectional" navigability.
Answer: From a business point of view (and so in a 'business use case'), there is no concept of navigability, this property is used for links between objects in O.O programming.
In a business use case, the direction of the arrow actually indicates which direction information flows after the lead actor triggers the use case. Most of the time, as there is 'interaction', information goes both ways (e.g. a screen sends information, visually, and receives it, by encoding, with mouse event, etc. If the information only goes one way, then the relationship is one-way.
For example, a use case sends data to a secondary actor (which is another system) and that system "consumes" that data WITHOUT ANY feedback.


How to override action Email SalesOrder in SO30100 Screen

Question: I try to customize action email in Salesorder screen, I use this code but it does not work. Could you give me some suggest about my code and customize send notification in Acumatica. I am using Acumatica 4.2.
Thank you in advance.
    public CRActivityList<SOOrder>    Activity;

    public PXAction<SOOrder> notification;

    [PXUIField(DisplayName = "Notifications", Visible = false)]
    [PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntryF)]
    protected virtual IEnumerable Notification(PXAdapter adapter,
        [PXString] string notificationCD
        )
    {
        foreach (SOOrder order in adapter.Get<SOOrder>())
        {
            if (order.OrderType == "CM")
            {
                ///my function
                EmailNotification.Send_AtNPP(order, "SO301000", "SENDRETURNSO", "[[NoiDung]]", createEmailContent(order));
            }
            yield return order;
        }
        yield return adapter.Get();
    }

Answer: What is the error you receive?
Have you tried removing the final yield?  Last line can be
return adapter.Get();

Comment: I have remove that and it cannot get into when I debug
Answer: I don't see why you would need the yield return order,
just do as suggested and return the adapter.
foreach (SOOrder order in adapter.Get<SOOrder>())
{
   if (order.OrderType == "CM")
    {
    ///my function
      EmailNotification.Send_AtNPP(order, "SO301000", "SENDRETURNSO", "[[NoiDung]]", createEmailContent(order));
   }
   //yield return order;
}
return adapter.Get();


Unable to install SQL Server 2019 because of the missing ODBC driver

Question: I am unable to install Microsoft SQL Server 2019 Developer Edition because of a missing ODBC driver 2017 (screenshot attached)
I already installed various version of the ODBC driver, already ran powershell commands to set SchUseStrongCrypto registry value
Still no success
Any advice?
Answer: The solution was NOT to deal with SQL Server 2019. We went ahead and installed SQL Server 2022, which installed just fine without any issues


What do the ending numbers (e.g., Db 1; Db/F 1/3) written below the chords mean?

Question: What do the ending numbers written below the chord in this video really mean?
Video link:

Db 1,
Db/F 1/3,
Gb 4,
Ab 5,
Db 1,
Db/F 1/3,
Gb 4,
Ab 5,
Fm7 3m,
Bbm7 6m,
Gb 4,
Ab sus 5 sus,
Ab7 5,
Fm7 3m,
Bbm7 6m,
Gb 4,
Ab sus 5 sus,
Ab 5,
Db 1,
Ab 5,
Bbm7 6m,
Gb 4,
Db 1,
Ab 5,
Gb 4,
Ab 5,
...

Db means the D flat triad. But what does 1 mean? Is that the keynote pitch? (like the middle C is C4?) or is that tempo?

Db/F 1/3 means the inverted D flat triad with the starting F base. But what does 1/3 mean? Is that the keynote pitch?
Answer: This is Nashville chord notation system
https://en.wikipedia.org/wiki/Nashville_Number_System
The numbers refer to the scale steps on which the chords are built.
The song is in the key of Db major. 1 means chord built on the first step, Db major. 1/3 means Db chord with 3rd scale degree in bass, F. 3m is a minor chord built on the 3rd scale degree, F minor. 4 is a chord built on 4th scale degree, Gb major – and so on.
It is an alternative chord notation, so you can use either regular chord symbols (Db, Db/F, Fm, Gb...), or Nashville numbers, they carry the same information.
Comment: On this site, see [What is the the Nashville Numbers system?](https://music.stackexchange.com/q/1480/70803)
Answer: It is indeed the NNS - Nashville Number System. Each chord in a key is given a number, corresponding to the note number in that key. Here, in D♭ - D♭ =1, E♭ = 2, F = 3, G♭ = 4, A♭ = 5, and B♭ = 6.
That may seem to be extra stuff for little purpose - just write the perishing chords, please!
But, the idea is far reaching. In the recording studio, for example, the musos turn up, and the song is already written. Musos though, don't know the best key for it. So with just NNS, they can play it immediately in any key. For example, the first 3 chords - 1, 1/3, 4 in key C are C, C/E F; in key G, G, G/B, C, in key A, A, A/C♯, D. Much quicker than re-writing the chart !


The function $f (n) = (1 + 1 / n) ^ {n+1}$ is decreasing

Question: I cannot prove that the function $$f (n) = \left(1 + \frac1n\right) ^ {n + 1},$$ defined for every positive integer $n$, is strictly decreasing in $n$. I already tried to prove by induction and also tried to prove by calculating the difference between $f (n + 1)$ and $f (n)$.
I need help.
Answer: May be this help:
$f_n/f_{n+1}=\frac{(1+1/n)^{n+1}}{(1+1/(n+1))^{n+2}}=(\frac{1+1/n}{1+1/(n+1)})^{n+1}\times\frac{1}{1+1/(n+1)}=(1+1/(n^2+2n))^{n+1}\times\frac{1}{1+1/(n+1)}$
But
$$(1+1/(n^2+2n))^{n+1}>1+\frac{n+1}{n^2+2n}>1+\frac{n+1}{(n+1)^2}=1+1/(n+1)$$
Answer: Use Binomial Theorem,
$\left(1+\frac1n\right)^{n+1}>\left(1+\frac1{n+1}\right)^{n+2}=\left(1+\frac1{n+1}\right)^{n+1}\left(1+\frac1{n+1}\right)$
$\iff \left(1+\frac1n\right)^{n+1}\Big/\left(1+\frac1{n+1}\right)^{n+1}>\left(1+\frac1{n+1}\right)$
but LHS is,
$\left(1+\frac1{n(n+2)}\right)^{n+1}=1+\sum\limits_{k=1}^{n+1}\binom{n+1}{k}\left(\frac1{n(n+2)}\right)^k>1+\frac{n+1}{n(n+2)}>1+\frac{1}{n+1}$
Answer: For $n>1$, we apply the AM-GM inequality to the numbers
$(1-1/n)$ taken $n$ times and $1$. Then
$$\underbrace{\frac{n(1-\frac{1}{n})+1}{n+1}}_{\text{Arithmetic mean}}> \underbrace{\left(\left(1-\frac{1}{n}\right)^n\cdot 1\right)^{1/(n+1)}}_{\text{Geometric mean}}$$
that is
$$\frac{n^{n+1}}{(n+1)^{n+1}}> \frac{(n-1)^{n}}{n^{n}},$$
which is equivalent, to
$$f(n-1)=\left(1+\frac{1}{n-1}\right)^{n}> \left(1+\frac{1}{n}\right)^{n+1}=f(n)$$
and we may conclude that $n\to f(n)$ is strictly decreasing.
Answer: $$f(n)=\exp{\left((n+1)\ln{\left(1+\frac1n\right)}\right)}$$ with $f(n)>0$. Hence $$f'(n)=f(n)\left(\ln{\left(1+\frac1n\right)-\frac1n}\right)$$ Now, use the inequality $\ln(1+x)<x$ for $x>-1$ with $x=\frac1n$ to conclude that $f'(n)<0$.
Comment: Are you serious? Why would this problem be presented after calculus, the exponential function and the logarithm?
Comment: I agree with @GitGud It's hard to be sure, but that problem seems a lot more likely as a preparation for introducing $e$ than anything else, in any case something at the beginning of studying limits.  As such that answer is not useful. // Having looked at OP's profile, maybe not. But it still seems way overkill to do it like this.
Comment: @MathematicsStudent1122 re 1, if you care to check say the [Wikipedia page on e](https://en.wikipedia.org/wiki/E_(mathematical_constant)) you'll see this one mention there too. The point to have a decreasing upper bound for e, in addition to an increasing lower bound for e, furnished by the sequence you mentioned.  One can nicely squeeze e between these two sequences. re 2, overkill or not, it uses quite a bit of theory that may not be available to somebody having to solve this problem. But yeah likely it does not hurt to have this answer in addition to a different one.
Comment: @quid Ok, fair enough. Now, that I see it again, I seem to agree with you, the OP must be looking for a much different answer. I will leave my answer anyway, just in case.
Comment: @quid (1) The expression with $n$ in the exponent is used to prepare for $e$. Not $n+1$. Small but important difference. (2) It's not overkill. Computing the derivative to show whether or not a function is increasing or decreasing is a standard and simple method to solve these types of problems.
Comment: @MathematicsStudent1122 Your rationale for (2) can also be applied to the identity sequence. If that's not an overkill, I don't think your definition of overkill is useful. Plus, as quid pointed out, this might be circular depending on how $e$ is defined and proved.
Answer: Take the fraction
$$
\frac{f(n)}{f(n-1)}=\left(\frac{n+1}{n}\right)^{n+1}\bigg/\left(\frac{n}{n-1}\right)^n=\left(\frac{(n-1)(n+1)}{n^2}\right)^n\frac{n+1}{n}=\frac1{\left(1+\frac{1}{n^2-1}\right)^n}\frac{n+1}{n}.
$$
Using the induction, show that for $n\ge2$ and $x>-1$, $x\ne0$ (if $x=0$ then there would be a trivial equality) $(1+x)^n>1+nx$. For $n=2$ we have $(1+x)^2=1+2x+x^2>1+2x$. For $n+1$: $(1+x)^{n+1}=(1+x)^n(1+x)>(1+nx)(1+x)=1+(n+1)x+nx^2>1+(n+1)x$.
Using this inequality one can conclude that
$$
\left(1+\frac{1}{n^2-1}\right)^n>1+n\frac1{n^2-1}=\frac{n^2+n-1}{n^2-1},
$$
and
$$
\frac{f(n)}{f(n-1)}=\frac1{\left(1+\frac{1}{n^2-1}\right)^n}\frac{n+1}{n}<\frac{n^2-1}{n^2+n-1}\frac{n+1}{n}=\frac{n^3+n^2-n-1}{n^3+n^2-n}<1.
$$
Therefore, $f(n)$ is decreasing in $n$.
Answer: We could also apply the GM-HM inequality:
$$
\left(1+\frac{1}{n}\right)^{n+1}=1·\prod_{1}^{n+1}\frac{n+1}{n}>\left(\frac{n+2}{1+\sum_1^{n+1}\frac{n}{n+1}}\right)^{n+2}=\left(1+\frac{1}{n+1}\right)^{n+2}
$$
(Left side is strictly greater than right side since $1\ne1+\frac{1}{n}$, for every $n\in N^+$.)
Thus
$$
f(n)> f(n+1).
$$


How to create facet plot from hierarchically grouped data frame

Question: I have the following tibbles s12.tbl and ref.tbl.

s12.tbl <- structure(list(Sample_name = c("s1", "s2", "s1", "s2", "s1",
"s2", "s1", "s2", "s1", "s2", "s1", "s2", "s1", "s2", "s1", "s2",
"s1", "s2", "s1", "s2"), some_score = c("0.04741", "0.09293",
"0.06210", "0.09838", "0.09606", "0.09866", "0.08851", "0.10866",
"0.05063", "0.09726", "0.39775", "0.10731", "0.05509", "0.09866",
"0.10784", "0.09398", "0.04680", "0.10007", "0.04782", "0.10408"
), category = c("real", "real", "real", "real", "real", "real",
"real", "real", "real", "real", "real", "real", "real", "real",
"real", "real", "real", "real", "real", "real")), .Names = c("Sample_name",
"some_score", "category"), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -20L))
s12.tbl
#>    Sample_name some_score category
#> 1           s1    0.04741     real
#> 2           s2    0.09293     real
#> 3           s1    0.06210     real
#> 4           s2    0.09838     real
#> 5           s1    0.09606     real
#> 6           s2    0.09866     real
#> 7           s1    0.08851     real
#> 8           s2    0.10866     real
#> 9           s1    0.05063     real
#> 10          s2    0.09726     real
#> 11          s1    0.39775     real
#> 12          s2    0.10731     real
#> 13          s1    0.05509     real
#> 14          s2    0.09866     real
#> 15          s1    0.10784     real
#> 16          s2    0.09398     real
#> 17          s1    0.04680     real
#> 18          s2    0.10007     real
#> 19          s1    0.04782     real
#> 20          s2    0.10408     real

ref.tbl <- structure(list(Sample_name = c("K1", "K2", "K3", "K1", "K2",
"K3", "K1", "K2", "K3", "K1", "K2", "K3", "K1", "K2", "K3", "K1",
"K2", "K3", "K1", "K2", "K3", "K1", "K2", "K3", "K1", "K2", "K3",
"K1", "K2", "K3"), some_score = c(0.09651, 0.09787, 0.09526,
0.09543, 0.09479, 0.09435, 0.09122, 0.09123, 0.09024, 0.09458,
0.09478, 0.09299, 0.09382, 0.0945, 0.09285, 0.10158, 0.10127,
0.09889, 0.10339, 0.10476, 0.1037, 0.13594, 0.13257, 0.14651,
0.09458, 0.09473, 0.09325, 0.09296, 0.0935, 0.09196), category = c("fake",
"fake", "fake", "fake", "fake", "fake", "fake", "fake", "fake",
"fake", "fake", "fake", "fake", "fake", "fake", "fake", "fake",
"fake", "fake", "fake", "fake", "fake", "fake", "fake", "fake",
"fake", "fake", "fake", "fake", "fake")), .Names = c("Sample_name",
"some_score", "category"), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -30L))
ref.tbl
#>    Sample_name some_score category
#> 1           K1    0.09651     fake
#> 2           K2    0.09787     fake
#> 3           K3    0.09526     fake
#> 4           K1    0.09543     fake
#> 5           K2    0.09479     fake
#> 6           K3    0.09435     fake
#> 7           K1    0.09122     fake
#> 8           K2    0.09123     fake
#> 9           K3    0.09024     fake
#> 10          K1    0.09458     fake
#> 11          K2    0.09478     fake
#> 12          K3    0.09299     fake
#> 13          K1    0.09382     fake
#> 14          K2    0.09450     fake
#> 15          K3    0.09285     fake
#> 16          K1    0.10158     fake
#> 17          K2    0.10127     fake
#> 18          K3    0.09889     fake
#> 19          K1    0.10339     fake
#> 20          K2    0.10476     fake
#> 21          K3    0.10370     fake
#> 22          K1    0.13594     fake
#> 23          K2    0.13257     fake
#> 24          K3    0.14651     fake
#> 25          K1    0.09458     fake
#> 26          K2    0.09473     fake
#> 27          K3    0.09325     fake
#> 28          K1    0.09296     fake
#> 29          K2    0.09350     fake
#> 30          K3    0.09196     fake

I have no problem creating one ECDF plot for s1 in s12.tbl using this code:
library(dplyr)
library(ggplot)

# Here we only pick S1,
s1.tbl <- s12.tbl %>% filter(Sample_name=="s1")
s1.tbl <- s1.tbl %>%
       mutate(some_score=some_score %>% as.numeric)

ref.tbl <- ref.tbl %>%
       mutate(some_score=some_score %>% as.numeric) %>%
       setNames(c("Sample_name", "some_score","category"))

dat <- rbind(s1.tbl, ref.tbl)

ggplot(dat, aes(x = some_score)) +
    stat_ecdf(aes(group = Sample_name, colour = category, alpha=category)) +
    scale_alpha_discrete(range = c(0.5, 1)) +
    scale_color_manual(values = c("black","red")) +
    theme_minimal(base_size=15) +
    theme(legend.title=element_blank()) +
    theme(axis.text.x=element_text(angle=45, hjust=1,size=15)) +
    theme(axis.text.y=element_text( hjust=1,size=10)) +
    ylab("ECDF")  +
    xlab("Score")

Which produces this:
My question is how can I make the facet wrap version of that to include s1 and s2 from s12.tbl?
Answer: Perhaps this is easiest with two calls two stat_ecdf:
ggplot(mapping = aes(x = as.numeric(some_score), group = Sample_name,
                     colour = category, alpha = category)) +
  stat_ecdf(data = mutate(s12.tbl, facet = Sample_name)) +
  stat_ecdf(data = ref.tbl) +
  scale_alpha_discrete(range = c(0.5, 1)) +
  scale_color_manual(values = c("black","red")) +
  facet_wrap(~facet) +
  theme_minimal(base_size=15) +
  theme(legend.title=element_blank(),
        axis.text.x=element_text(angle=45, hjust=1,size=15),
        axis.text.y=element_text( hjust=1,size=10)) +
  ylab("ECDF")  +
  xlab("Score")


Solving inequality by induction associated with a recurrence

Question: Consider the sequence an defined by $a_1=1$, $a_2=3$ and
$$a_n=a_{n-1}+a_{n-2} \text{ for } n>2.$$
Prove that $$a_n<
\left(\frac{7}{4}\right)^n\text{ for every positive integer }n.$$
My attempt: By induction, we assume that $a_k<(\frac{7}{4})^k$
Now, we need to prove to $n=k+1$. I did: $a_k<(\frac{7}{4})^k$, and $\frac{7}{4}.a_k<(\frac{7}{4})^{k+1}$.
I assumed that $a_{k+1}\le a_k\cdot\frac{7}{4}$
I replaced the minor cases and it always worked, but I am not able to prove this inequality by induction
Comment: You haven't used $a_n=a_{n-1}+a_{n-2}$. You gotta.
Answer: Because the recurrence depends on $2$ previous steps, you need to assume $2$ steps in the inductive hypothesis.
Inductive hypothesis: $a_k \le (7/4)^k$ and $a_{k+1} \le (7/4)^{k+1}.$
Inductive step: you need to prove that $a_{k+2}\le(7/4)^{k+2}$. Can you do this step using the recurrence $a_{k+2}=a_{k+1}+a_{k}$?

 $$a_{k+2}=a_{k+1}+a_{k}\le(7/4)^{k+1}+(7/4)^k=(7/4)^k(1+7/4)=(7/4)^k(44/16)<(7/4)^k(49/16)=(7/4)^{k+2}$$

Note: you'll also need to prove $2$ base cases.

 $a_1 = 1 < 7/4, \quad a_2 = 3 = 48/16 < 49/16$

If you're interested, these are almost the Lucas numbers and the proof works essentially because $7/4 > \phi$ the golden ratio.


How do I target specific inputs on a form fields to change output to Title Case?

Question: On my form I am trying to have specific output fields and their strings output as Title Case. May be worth noting, this form outputs to results on the same page. Here's a Fiddle demo of my form.
As you can see from it I have 3 input categories Name, City and Words, for this example I am trying to implement the Title Case script to just the 'Name" and City" output strings without it effecting the "Words" category. As I don't want to convert an ongoing sentence to Title Case.
I found a lot of discussion here on how to convert to title case. However I am having difficulty implementing this in to my form as I am still new to JavaScript. All the examples show the script, but not how to implement it in a form.
I was playing around with Greg Dean's top answer to try and target the specific inputs like so...
toTitleCase = function(str)
{
var name  = document.getElementById('name');
var city  = document.getElementById('city');

return str.replace(/\w\S*/g, function(txt){return
txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}

However this does not seem to be working.
Here's the HTMl:
<form>
<input type="text" class="text" id="name" placeholder="Name">

<input type="text" class="text" id="city" placeholder="City">

<textarea type="textarea" id="words" placeholder="Words" cols="70" rows="6">
</textarea>

<input type="button" value="Combine" onclick="convert()">

<textarea type="textarea" name="output" id="output" cols="70" rows="10"
maxlength='' placeholder="Output"></textarea>

<button type="reset" onclick="ResetForm();" value="Reset
form">Reset form</button>
</form>

And the rest of the script:
function convert() {
var name = document.getElementById("name").value;
var city = document.getElementById("city").value;
var words = document.getElementById("words").value;
//input = wordwrap(input, 70, true);
var output = "";

if(!document.getElementById("name").disabled){
output += "Name: " + name + "\n";
}

if(!document.getElementById("city").disabled){
output += "City: " + city + "\n";
}

if(!document.getElementById("words").disabled){
output += "The words are... " + words + "\n";
}

document.getElementById("output").value = output;
}

CharacterCount = function(output,FieldToCount){
var myField = document.getElementById(output);
var myLabel = document.getElementById(FieldToCount);

var Chars =  myField.length;
if(!Chars){Chars =  "" ; };

var remainingChars =   Chars + myField.value.length
myLabel.innerHTML = remainingChars+""+Chars
}

setInterval(function(){CharacterCount('output','CharCountLabel1')},55);

How do I target the script to just the specified input fields? Please no jQuery, just JavaScript solutions.
Answer: While you have a fully-function toTitleCase() function, you're never actually calling it. All you need to do is run your name and city variables through your toTitleCase function when you go to output them to the page:
if (!document.getElementById("name").disabled) {
  output += "Name: " + toTitleCase(name) + "\n";
}
if (!document.getElementById("city").disabled) {
  output += "City: " + toTitleCase(city) + "\n";
}

To prevent the words from also being transformed, simply don't pass that variable to the function:
if (!document.getElementById("words").disabled) {
  output += "The words are... " + words + "\n";
}

A working demo of this can be seen here.
Hope this helps! :)
Comment: The defiantly helps, I wondered if there was somewhere I was failing to call it, but didn't realized I could call a function within another function like that. Thank you so much, i really appreciate that :)

Now I might have to try some of those more elaborate examples that also modify names like MacDonald and the like.


drush pm-update "File drupal6-eol is corrupt (wrong md5 checksum)."

Question: PHP version 5.3.3
Scientific Linux release 6.5 Carbon (like CentOS/Redhat)
Can't update a Drupal 6 site using Drush 6.x. Installed Drush 6.x using composer. "drush pm-update" produces the following, which makes me think something's wrong with the hash for the end of life announcement.
<code># drush pm-update --verbose --no-cache
Initialized Drupal 6.38 root directory at /var/www/html/<url-removed>                      [notice]
Initialized Drupal site default at sites/default                                              [notice]
Loading release_info engine.                                                                  [notice]
Loading version_control engine.                                                               [notice]
Loading package_handler engine.                                                               [notice]
Executing: wget --version
Loading update_info engine.                                                                   [notice]
/usr/bin/php  -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d                          [notice]
magic_quotes_sybase=Off /home/<user>/.composer/vendor/drush/drush/drush.php
--php=/usr/bin/php --php-options=' -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d
magic_quotes_sybase=Off'  --backend=2 --verbose --root=/var/www/html/<url-removed>
--uri=http://default  pm-updatestatus 2>&1
Update information last refreshed: Thu, 04/14/2016 - 12:32
 Name                                    Installed     Proposed       Message
                                     Version       version
 Backup and Migrate (backup_migrate)     6.x-2.8       6.x-2.8        Installed version not supported
 Drupal                                  6.38          Drupal 6 has   SECURITY UPDATE available
                                                   reached end
                                                   of life
 CCK Facets (cck_facets)                 6.x-1.x-dev   6.x-1.x-dev    Installed version not supported
 Field Indexer (field_indexer)           6.x-1.0       6.x-1.0        Installed version not supported
 Content (cck)                           6.x-2.9       6.x-2.9        Installed version not supported
 Content Access (content_access)         6.x-1.2       6.x-1.2        Installed version not supported
 Data export import                      6.x-1.1       6.x-1.1        Installed version not supported
 (data_export_import)
 Date (date)                             6.x-2.10      6.x-2.10       Installed version not supported
 External Links (extlink)                6.x-1.17      6.x-1.17       Installed version not supported
 Faceted Search (faceted_search)         6.x-1.0-beta  6.x-1.0-beta3  Installed version not supported
                                     3
 Google Analytics (google_analytics)     6.x-3.6       6.x-3.6        Installed version not supported
 Image (image)                           6.x-1.2       6.x-1.2        Installed version not supported
 ImageAPI (imageapi)                     6.x-1.10      6.x-1.10       Installed version not supported
 ImageCache (imagecache)                 6.x-2.0-rc1   6.x-2.0-rc1    Installed version not supported
 ImageField (imagefield)                 6.x-3.11      6.x-3.11       Installed version not supported
 IMCE (imce)                             6.x-2.7       6.x-2.7        Installed version not supported
 IMCE Wysiwyg API bridge (imce_wysiwyg)  6.x-1.1       6.x-1.1        Installed version not supported
 jQuery UI (jquery_ui)                   6.x-1.5       6.x-1.5        Installed version not supported
 Link (link)                             6.x-2.11      6.x-2.11       Installed version not supported
 Menu Block (menu_block)                 6.x-2.4       6.x-2.4        Installed version not supported
 Override node options                   6.x-1.14      6.x-1.14       Installed version not supported
 (override_node_options)
 Pathauto (pathauto)                     6.x-1.6       6.x-1.6        Installed version not supported
 Poormanscron (poormanscron)             6.x-2.2       6.x-2.2        Installed version not supported
 Site map (site_map)                     6.x-2.2       6.x-2.2        Installed version not supported
 Token (token)                           6.x-1.19      6.x-1.19       Installed version not supported
 Views Data Export (views_data_export)   6.x-2.0-beta  6.x-2.0-beta7  Installed version not supported
                                     7
 Views modify query                      6.x-1.x-dev   6.x-1.x-dev    Installed version not supported
 (views_modify_query)
 Webform (webform)                       6.x-3.21      6.x-3.21       Installed version not supported
 Weight (weight)                         6.x-1.3       6.x-1.3        Installed version not supported
 Wysiwyg (wysiwyg)                       6.x-2.4       6.x-2.4        Installed version not supported

Code updates will be made to drupal core.
WARNING:  Updating core will discard any modifications made to Drupal core files, most noteworthy among these are .htaccess and robots.txt.  If you have made any modifications to these files, please back them up before updating so that you can re-create your modifications in the updated version of the file.
Note: Updating core can potentially break your site. It is NOT recommended to update production sites without prior testing.

Do you really want to continue? (y/n): y
Executing: svn info '/var/www/html/<url-removed>/drupal-Drupal 6 has reached end of life'
Executing: bzr root '/var/www/html/<url-removed>/drupal-Drupal 6 has reached end of life'
Executing: wget --version
Executing: wget -q --timeout=30 -O /tmp/download_fileBIUKo0 https://www.drupal.org/about/drupal6-eol
Downloading drupal6-eol was successful.                                                       [notice]
File drupal6-eol is corrupt (wrong md5 checksum).                                          [error]
Updating project drupal failed. Attempting to roll back to previously installed version.   [error]
Rolling back update of Drupal core code ...                                                   [notice]
Executing: svn info 'drupal-Drupal 6 has reached end of life'
Executing: bzr root 'drupal-Drupal 6 has reached end of life'
Backups were restored successfully.                                                        [ok]
Command dispatch complete                                                                     [notice]
Command dispatch complete                                                                     [notice]
</code>
Comment: There is no such module as drupal6-eol, probably this break is deliberately since 6.x updates aren't supported anymore, see: [Drupal 6 end of life](http://drupal.stackexchange.com/q/42382/1908).
Comment: Yea, I know about it being EOL. I was hoping to upgrade it to Drupal 7, though the first stage was to make sure everything was up to date in Drupal 6 first.
Answer: [I presume you meant to say that you installed Drush 6.x by Composer, since it is not possible to install Drupal 6.38 via Composer.]
If you are working with Drupal 6, you should be using Drush 8. Drupal.org changed some things in the metadata when Drupal 6 went EOL; Drush 6 and Drush 7 probably can't handle this.
Comment: Is that the only option? I'm trying to keep PHP at 5.3.3 on this system until I can upgrade to Drupal 7.
Comment: I recognize that this is a serious impediment. Try Drush 7; this version is still supported. If it does not work,you could try posting an issue in the issue queue. Please also reproduce on Drush 8 on a different system to diagnose. If there is a fix in Drush 8 that just needs to be backported, that would make things easier and faster. Note that we do not have a Drupal 6 maintainer for Drush, though.
Comment: Will do, though I can't get to this again until next week. Stay tuned.
Comment: I'm back. I tried switching to Drush 7 after verifying that it works with php 5.3.3. I am now getting this error:  `Command pm-update needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.
`
I am working on copying the site to another host where I can freely update PHP and try Drupal 8. After some googling, it seems like getting drush 7 to work would be another SO question altogether.
Comment: Looks like Drush 7 wont run on PHP 5.3.3 because of a bug in PHP 5.3.3. Whenever I try to use **drush sql-cli** or **drush sqlq** using Drush 7, I get `exception 'ReflectionException' with message 'Class Drush\Sql\Sql6 does not have a constructor, so you cannot pass any constructor arguments' in /home/user/.composer/vendor/drush/drush/includes/drush.inc:117` A quick search turned up this issue: https://github.com/drush-ops/drush/issues/544
Comment: Committed https://github.com/drush-ops/drush/pull/2136 to the 7.x branch yesterday, but the work needed to get Drush 7 to work with Drupal 6 is not yet done. Questions about how to do this are best done in the Drush issue queue, not Stack Exchange.
Answer: Drush 6 is not supported by the drush developers anymore. Drush 7 is supported and is still compatible with PHP 5.3.x, though according to @greg_1_anderson you will be better off using Drush 8. ("Drupal.org changed some things in the metadata when Drupal 6 went EOL; Drush 6 and Drush 7 probably can't handle this.")
Unfortunately, there is a bug in PHP 5.3.3 that prevents Drupal 7 from running on it. You can verify that you are being affected by this bug by running drush sql-cli. If you get the following error, you are affected:
<code>exception 'ReflectionException' with message 'Class Drush\Sql\Sql6 does not have a constructor, so you cannot pass any constructor arguments' in                                                  [error]
/home/user/.composer/vendor/drush/drush/includes/drush.inc:117
Stack trace:
#0 /home/user/.composer/vendor/drush/drush/includes/drush.inc(117): ReflectionClass->newInstanceArgs(Array)
#1 /home/user/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(607): drush_get_class('Drush\Sql\Sql', Array, Array)
#2 /home/user/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(590): drush_sql_get_version()
#3 /home/user/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(428): drush_sql_get_class(NULL)
#4 [internal function]: drush_sql_query()
#5 /home/user/.composer/vendor/drush/drush/includes/command.inc(361): call_user_func_array('drush_sql_query', Array)
#6 /home/user/.composer/vendor/drush/drush/includes/command.inc(212): _drush_invoke_hooks(Array, Array)
#7 [internal function]: drush_command()
#8 /home/user/.composer/vendor/drush/drush/includes/command.inc(180): call_user_func_array('drush_command', Array)
#9 /home/user/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(64): drush_dispatch(Array)
#10 /home/user/.composer/vendor/drush/drush/drush.php(70): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#11 /home/user/.composer/vendor/drush/drush/drush.php(11): drush_main()
#12 {main}
</code>
Fortunately, the bug is easy to work around.
GitHub user diarmy suggests replacing a single line in your drush 7 install:

In PHP 5.3.3, the line
  $reflectionClass->newInstanceArgs($constructor_args) in
  drush_get_class throws an exception.
A clue as to why this might be the case may be found in
  http://php.net/manual/en/reflectionclass.newinstanceargs.php where the
  documentation says that a ReflectionException will be thrown if the
  class does not have a constructor and the args parameter contains one
  or more parameters.
The base class SqlVersion class does not have a constructor and yet an
  empty array is passed into its descendant (Sql6 or Sql7).
To work round this, the line
return $reflectionClass->newInstanceArgs($constructor_args);
should be replaced with:
return !empty($constructor_args) ?
  $reflectionClass->newInstanceArgs($constructor_args) :
  $reflectionClass->newInstanceArgs();
I had the same issue as above and this fix worked for me -7.0-dev is
  now working on PHP 5.3.3.

After applying this update, drush sql-cli and drush pm-update should work.


Android : No USB Driver to detect my Android Phone - Download App

Question: I have an Android Mobile phone but even after installing Universal USB driver my system is not able to detect the phone.
I have an Android application developed using Android SDK - how can I download the app to my mobile. I have an SD card - but which  file should I copy on it?
Comment: Usually you get the driver from the manufacturer of your phone.
Comment: Sorry I tried a lot but I was unable to get it identified by my system. So which files I should copy to my SD card of the Andriod APP developed by Android SDK
Answer: To detect phone -
See my SO post on No driver for application debug.
Generally, if the only purpose is to install the application on your mobile device then
you just need to copy the generated .apk file of your application to your mobile device
via any way (USB, email, etc.) and simply run it there.
The location of .apk file is your workspace application bin folder.
Answer: The steps to enable USB debugging depend on the version of Android running on the target device, as indicated in the following table:
Developer Options on Gingerbread (Android 2.3):
Settings> Applications> Development> USB Debugging
Developer Options on ICS (Android 4.0):
Settings> Developer Options> USB Debugging
Developer Options on JB (Android 4.1):
Settings> Developer Options> USB Debugging
If you have recently upgraded your device to Android 4.2 Jelly Bean or have bought a new device with 4.2 or higher pre-installed, do not be surprised if you find the  "Developer Options" missing.
Enable the USB Debugging option under Settings > Developer options.

On the device, go to Settings > About .
Tap the Build number seven times to make Settings > Developer options available.
Then enable the USB Debugging option.
Comment: It is A Yxtel G905 having version 4.1.1. I have enabled the USB debugging options already
Comment: In Windows 7 try the following.
Right Click Computer then Manage
Expand Android phone at the top of the list
Right click Android ADB Interface then Update Driver Software
Browse my computer for driver software
Let me pick from a list of device drivers on my computer
Choose USB Composite Device then next
Comment: Thanks but I have already made the same configuration


Use Token in contact form as default value

Question: I have a contact form build from the drupal core contact forms.
I am trying to prefill some fields from URL GET parameters like this. /?foo=bar But it seems that "default value" doesnt support tokens.
I want to use something like this: [current-page:url:args:value:foo] in the default field of my form field.
But this gets just rendered as plain text.
Any help is appreciated.
EDIT: Working solution with form_alter:
function MY_MODULE_form_alter(&$form, &$form_state) {
  $args = \Drupal::request()->query->all();
  $form['field_test']['widget'][0]['value']['#default_value'] = $args['foo'];
}

Maybe there is a solution with tokens relating to the topic?
Comment: Can you show more code ?
Answer: Usually this is done in hook_form_contact_site_form_alter, like this:
function YOUR_MODULE_form_contact_site_form_alter(&$form, &$form_state) {
      $args = \Drupal::request()->query->all();
      $form['subject']['#default_value'] = $args['foo'];
}

Comment: Thanks for your solution. I thought I could make some approach with tokens. But your solution worked for me with some modifications. I will update my question


Apache on windows and php-fpm

Question: php 7.1
Apache 2.4 + mod_proxy_fcgi
Windows 10
I'm trying to set up php-fpm + apache on windows, using mod_proxy_fcgi but keep getting errors. Can anyone help me with configuring apache.
I got php-fpm runnig, and verified that it actually works using nginx, so php should not be a problem.
PHP-fpm is running on port 9123.
Here is my vhost config:
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "${SRVROOT}/htdocs"
    <Directory "${SRVROOT}/htdocs">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        <FilesMatch "\.php$">
            SetHandler proxy:fcgi://127.0.0.1:9123
        </FilesMatch>
    </Directory>
</VirtualHost>

Here is the error:

Proxy Error
Your browser sent a request that this server could not understand. The
  proxy server could not handle the request GET /index.php/.
Reason: URI cannot be parsed:
  fcgi://127.0.0.1:9123C:/Apache24/htdocs/index.php*

Does anyone know how to fix it ?
Comment: I've the same problem. Could you please share your solution?
Comment: My solution was switching to linux or use nginx instead
Comment: Clearly that's the single "best" approach, but sometime is unfaseable due to business requirements.
Answer: I was dealing with the same issue and I found the root cause: most likely we were both following the this wiki.apache.org guide. There are a couple of typos in said guide. What causes the problem for us is that there is a missing slash after SetHandler. This is the config that worked for me:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

<FilesMatch "\.php$">
    <If "-f %{REQUEST_FILENAME}">
        SetHandler "proxy:fcgi://localhost:9123/"
    </If>
</FilesMatch>

Answer: Hi try something like :
<FilesMatch "^/CHANGE_ME/.*\.php(/.*)?$">
    SetHandler proxy:fcgi://127.0.0.1:9123
</FilesMatch>

Comment: This one doesn't work either. But no error is displayed at all. I just can see content of my index.php on the screen that's it. May-be Im doing something wrong. what exactly is supposed to be in place of "CHANGE_ME" ?
Comment: Hi. It should be your project folder
Answer: have you tried putting the:
<FilesMatch "\.php$">
    SetHandler proxy:fcgi://127.0.0.1:9123
</FilesMatch>

outside the directory? Ie. what happens if you put that part between the docroot directive and the directory directive?
Regards,
Eric

Apache on windows and php-fpm


Flexslider - on touch

Question: I am using Flexslider module in drupal 7 .  when i checked my website on mobile.  i am not use slider by touch
Is there is any setting for flexslider.
Thanks
Answer: You need to enable touch for that. Follow this path for flexslider setting <code>$base_url/admin/config/media/flexslider/list/default/edit</code>.
You will see screen such as
You need to check Touch in Navigation and Control Settings & save.
Don't forget to clear cache :)
Comment: i already enable, when i am checking on mobile. it is not touch behaviour
Comment: @Hitu - It works for me with these settings :)
Comment: i checked twice and  thrice . not working :(

Flexslider - on touch


Speed issues with a long script?

Question: I write a lot of bookmarklets and I put them inside a meta-bookmarklet (>20kb so far) thus:
var uGlY_vArIaBlE=(function(){
  var d=document;
  var f1=function(){};
  var f2=function(){};
  …
  … /* lot of code here */
  …
  var f50=function(){};
});
uGlY_vArIaBlE();

Is it okay for me to assume that f50 will 'know' that d=document as fast as f1 would? Also how does a browser actually read/interpret a script (injected or loaded from the cache)? I don't seem to be experiencing any significant delays. Any tips you could share please.
Comment: Please don't add that much white space you did.
Comment: thanks 2 whoever formatted it. My * phone * browser is not up 2 the job or I'm just thick.
Comment: All the answers are fine. I'll tick the first one since it was. Thank you all.
Comment: How did I guess! My *Phone* browser even in 'desktop mode' won't let me click on a tick-it's not 'active'-and I don't own a PC so that's that.
Answer: Your variable will be equally fast in all functions of the same level. Only inner functions lose some speed, e.g:
function f32(){
  function f33(){
    // to get d, we have to walk up 2 levels
    // so it is a bit slower to get it then
    // it is for f32
  };
};

A bit better concept would be:
(function( window, undefined ){ // <- no need to name it (can be anonymus)

var d = window.document;

function f1(){};
function f2(){};

// .............

function f50(){};

})( window ); // <- it will be executed immediately

And both document and window will be faster, since they are local variables.
Comment: galambalazs Why the param 'undefined'?
Comment: because minifiers will be able to shrink it, and defining your own undef prevents 3rd party code from breaking yours.
Answer: The only delay a long script should cause is in loading and parsing. It will take longer to load the script from disk (because the file size is bigger), and it will take longer to parse the script so it can be executed (because there is more code to parse).
Other than that, you should not get any slowness (unless your algorithms require optimization, but that's a whole other topic)

Speed issues with a long script?


how to add solution to TFVC on android Studio directly?

Question: I created a project on android studio and install and configured a TFS.
I don't want to add my project to TFS and then on my android studio open it as new from source control.
on my cause android studio and TFS both have been configured and everything is ok but I don't know is it possible to add my project to TFS in Android Studio or not? because when I right click on my solution and select TFVC as you can see on my photo "Add" option is disable.
Answer: According to your description, you want to add local code/project/solution in android studio to TFS as TFVC version control.
In the version control bar, there should be a local changes option, select the folder and files, right click and choose commit changes, finally check in the changes. Then your local project should be sync synchronized to TFS server side.

Precondition: you have the correct workspace mapping for local Andriod folder.  Besides to use TFVC as your version control, you have to use the TEE CLC to provide the TFVC support.
For a Video tutorial, you could refer this link Getting Started with TFVC inside of Android Studio with the Team Services Plugin Suggest you to refer from (10:00~ 12:00) which talk about related things.
You could also take a look at my reply in  How to Use TFS in Android Studio


Confidence Intervals for Likert Items

Question: Background
As part of a community survey looking into environmental habits, I have 22 Likert Scale questions each with six Likert items.  As for the sample size, we have over 65 responses to each question.
I am familiar with the analysis of Likert Scales and the various limitations.  However I am wanting to look at this differently (even if just for research curiosity).  I want to ascribe the confidence interval for each item across each 22 Likert scale questions.
From what I have reviewed, the classical Wald interval for a binomial response is unreliable when the proportion approaches zero and one.  So I have discarded that option and that seems to leave the following two.
Wilson score interval
$\hat p_w \approx \frac {n_i +\frac{1}{2}z^2}{n+z^2} \pm \frac {z}{n+z^2} \sqrt{\frac{n_i n_j}{n} +\frac {z^2}{4}}$
Simultaneous Confidence Intervals for Multinomial Proportions
$\hat p_g \approx \frac {n_i +\frac{\beta}{2}}{n+\beta} \pm  \sqrt{\frac{\frac{\beta^2}{4}+\beta n_i(1-\frac{n_i}{n})}{n+\beta^2}}$
$n_i$ = number of respondents choosing the $i^{th}$ item
$n_j$ = number of respondents not choosing the $i^{th}$ item
$n = \sum_{i=1}^k n_i$
$k$ = the count of $i^{th}$ Likert items per scale
$\beta$ = the upper $(\frac{\alpha}{k})$ 100th percentile of the $\chi^2$ distribution with 1 degree of freedom
Both $\hat p_w$ and $\hat p_g$ re-estimate the proportion hence the confidence intervals that are not symmetric to the original proportion.
Using some survey data for the above options, we have (using $z$ = 1.96 and $\alpha$ = 0.05).
$$\begin{array}{c|c|c|c|c|c|c}
\text{Likert Item} & \text{Count} & p & \hat p_w & \pm CI_w & \hat p_g & \pm CI_g \\ \hline
\text{1} & 5 & 0.071 & 0.094 & 0.063 & 0.110 & 0.087\\ \hline
\text{2} & 3 & 0.043 & 0.067 & 0.052 & 0.084 & 0.074\\ \hline
\text{3} & 15 & 0.214 & 0.229 & 0.095 & 0.240 & 0.126\\ \hline
\text{4} & 32 & 0.457 & 0.459 & 0.114 & 0.464 & 0.150\\ \hline
\text{5} & 8 & 0.114 & 0.134 & 0.075 & 0.149 & 0.102\\ \hline
\text{6} & 7 & 0.100 & 0.121 & 0.072 & 0.136 & 0.097\\ \hline
\end{array}$$
Assuming my calculations are correct, two observations:

$\hat p_w$ is less than $\hat p_g$.
$\hat p_w$ has a smaller confidence interval than $\hat p_g$.

Question
Which is the 'correct' confidence interval to use for a Likert Scale question?
Answer: The Wilson confidence interval is superior.  Among other places it is implemented in the R Hmisc package binconf function.
But this whole discussion has focused on binary variables which are coarsened versions of Likert ordinal scales.  Even though Likert scales are not really interval-valued it is often best to summarize them with a single mean.  Then the job can be converted to one of selecting the best performing bootstrap confidence interval approach to get confidence intervals for population means.  "Best performing" means the method that has the two tail non-coverage probabilities closest to 0.025 if computing a 0.95 confidence interval.
You can also get estimated means from ordinal regression as discussed here and here.
Answer: I do not know the Wilson approach so will not comment this one.
The multinomial approach would be the best approach if and only if the total sample size (here 70) was a universal constant. Indeed, this distribution assumes that the total count (here 70) is a constant. However, if --in taking a new sample-- the total sample might no longer be 70, then this is not the correct approach.
Let me document two alternative approaches.
1) The Clopper-Pearson method This approach, based on Clopper and Pearson (1934) is the exact distribution of a proportion (in isolation). Leemis and Trivedi, 1996, provided an easier computation, that is
\begin{equation}
CI_{low} = \left( 1+ \frac{n-x+1}{x F_{2x,\, 2(n-x+1)}((1-\gamma)/2) } \right)^{-1}
\end{equation}
and
\begin{equation}
CI_{high} = \left( 1+ \frac{n-x}{(x+1) F_{2(x+1),\, 2(n-x)}(1-(1-\gamma)/2)} \right)^{-1}
\end{equation}
in which $x$ is the count, $n$ is the total count, and $F$ is the quantile taken from a F distribution with numerator and denominator degrees of freedom respectively, for a $\gamma$ level confidence interval (e.g., $\gamma = .95$).
2) The transformation approach Proportions can be transformed using the Anscombe arcsine transform. When this is done, the resulting proportion has a sampling distribution which is normal and a standard error which is constant at $\sqrt{1 / (4(n+1/2)) } $ (well, sort of a constant as it depends on sample size).
The transformation is $\text{arcsine} \left( \sqrt{\frac{x+3/8}{n+3/4} } \right)$
Thus, the transformed scores have a confidence interval of 1.96 the standard error, i.e.,
\begin{equation}
CI_{low} = \text{arcsine} \left( \sqrt{\frac{x+3/8}{n+3/4} } \right) - 1.96 \sqrt{\frac{1}{4(n+1/2)}}
\end{equation}
then the scores can be un-transformed, e.g., $$\text{Untransformed }CI_{low} = \frac{(n+3/4) \sin(CI_{low})^2 - 3/8}{n}$$
Note that in either case, the confidence interval limits are not symmetrical.
In your example, we get the following 95% confidence intervals.

Likert item
Count(x)
Total(n)
$p$
CP-$CI_{low}$
CP-$CI_{high}$
Tr-$CI_{low}$
Tr-$CI_{high}$

1
5
70
0.071
0.024
0.159
0.021
0.145

2
3
70
0.043
0.009
0.120
0.005
0.105

3
15
70
0.215
0.125
0.329
0.126
0.318

4
32
70
0.457
0.337
0.581
0.342
0.575

5
8
70
0.114
0.051
0.213
0.049
0.200

6
7
70
0.100
0.041
0.195
0.039
0.182

CP: Clopper and Pearson; Tr: Anscombe transformation.
The advantage of the transform approach is that it can be used to test comparisons and perform ANOVAs when there are multiple proportions to compare.
Comment: I did not say there was something wrong with the Wilson interval, I said I did not know it.
Comment: There is nothing wrong with the Wilson interval so not clear about all this discussion.  And are the original questionnaire items really binary? I thought they were on a Likert scale.
Comment: Thanks Denis. Do you have a good reference for the Anscombe arcsine transform? I can find the references for Clopper & Pearson and Leemis & Trivedi.
Comment: I have a paper submitted to FrontiersIn.org wrapping all this approach into a unified framework. Bits of this work was published here and there, e.g., Anscombe (1948) doi: 10.1093/biomet/35.3-4.246; Laurencelle (2021) doi :10.20982/tqmp.17.3.p272 [in french].
Comment: thanks I will look out for your article

Confidence Intervals for Likert Items


How to migrate files into a field with unlimited values (D6 -> D7)

Question: I am currently migrating a D6 site into D7 and so far everything has gone smoothly. I use migrate and migrate_d2d.
But now I am stuck :-(. I have an image field with unlimited values (a slideshow) and into that field I need to import images from the corresponding slideshow in the legacy site. My problem is that after import only one image is imported (the last one in the slideshow). How do I make every picture end up in its own subfield?
In my prepareRow() I am trying to use the loop below. I fetch the field ID from $row->fields_productimages[#] (index > 2 are field ID's that belong to the slideshow). I then get the file path from the legacy database and use that path to import the image. But as I said, only the last image is attached to my field.
There are no error messages. Any help is appreciated.
<code>$i = 2;
if($row->field_productimages[$i] != ''){
    while($row->field_productimages[$i] != ''){
        $fid = $row->field_productimages[$i];
        $filepath = Database::getConnection($target='default', $key='legacy')->query('SELECT f.filepath FROM {files} f WHERE f.fid = :fid',array(':fid' => $fid))->fetchAssoc();
        $this->addFieldMapping('field_bildspel_instrument')->defaultValue($filepath);
        $this->addFieldMapping('source_dir')->defaultValue('http://www.mysite.se/');
        $this->addFieldMapping('destination_dir')->defaultValue('public://instrument/bildspel');
        $this->addFieldMapping('field_bildspel_instrument:file_replace')->defaultValue('FILE_EXISTS_REPLACE');
        $this->addFieldMapping('field_bildspel_instrument:file_class')->defaultValue('MigrateFileUri');
        $this->addFieldMapping('field_bildspel_instrument:title', 'field_sensorimage:title');
        $this->addFieldMapping('field_bildspel_instrument:preserve_files')->defaultValue(1);
        $this->addFieldMapping('field_bildspel_instrument:urlencode')->defaultValue(1);
        $i++;
    }
}
</code>
Answer: Finally figured it out. The image field with unlimited values needs a default value with file paths presented as an array. As the array in $filepath was 2 dimensional (an array in an array), I needed two foreach loops to get down to the simple array needed. This is now a working example, I publish it here in case somebody have the same question:
<code>$i = 2;
$filepath = array();
if($row->field_productimages[$i] != ''){
    while($row->field_productimages[$i] != ''){
        $fid = $row->field_productimages[$i];
        $filepath[] = Database::getConnection($target='default', $key='legacy')->query('SELECT f.filepath FROM {files} f WHERE f.fid = :fid',
        array(':fid' => $fid))->fetchAssoc();
        $i++;
    }
    foreach ($filepath as $value1){
        foreach ($value1 as $value){
          $files[] = $value;
        }
    }
    $this->addFieldMapping('field_bildspel_instrument')->defaultValue($files);
    $this->addFieldMapping('field_bildspel_instrument:source_dir')->defaultValue('http://www.myoldsite.se/');
    $this->addFieldMapping('destination_dir')->defaultValue('public://product/slideshow');
    $this->addFieldMapping('field_bildspel_instrument:file_replace')->defaultValue('FILE_EXISTS_REUSE');
    $this->addFieldMapping('field_bildspel_instrument:file_class')->defaultValue('MigrateFileUri');
    $this->addFieldMapping('field_bildspel_instrument:title', 'field_productimages:title');
    $this->addFieldMapping('field_bildspel_instrument:preserve_files')->defaultValue(1);
    $this->addFieldMapping('field_bildspel_instrument:urlencode')->defaultValue(1);
}
</code>


Filter bind source

Question: I have a bind source which is filled with following data
TOM JACK
JACK TOM
TOM DEISE
JACK JENNY
TOM DALTON
JERRY JOY
JOY JERRY

And I have a combobox which is also filled with the above data, For example If i choose JACK TOM then the boind source should filter the result so that I need to get the following result
result :
TOM JACK
JACK TOM

(Only wanted to show the name that contains both the WORD('TOM' and 'JACK') only)
following is my try
bndSourceGrid.Filter = String.Format("{0} LIKE '%{1}%'", "Name", cboName.Text)
bndSourceGrid.Sort = "Name ASC"

Answer: You need to build your query to look like this:
Name LIKE '%tom%' AND Name LIKE '%jack%' ....

So take your input, split it up, project it to a new string and join them all together with AND:
bndSourceGrid.Filter =
    string.Join(" AND ",
        cboName.Text
        .Split(' ')
        .Select(s => string.Format("Name LIKE '%{0}%'", s))
    );

As noted in the comments, you may need to return the results of the Select as an array:
bndSourceGrid.Filter =
    string.Join(" AND ",
        cboName.Text
        .Split(' ')
        .Select(s => string.Format("Name LIKE '%{0}%'", s))
        .ToArray()
    );

Comment: getting this error `Unable to cast object of type 'WhereSelectArrayIterator2[System.String,System.String]' to type 'System.String[]'.`
Comment: FYI, I converted the code to vb.net to work in my environment i.e `bndSourceGrid.Filter = String.Join(" AND ", cboName.Text.Split(" "C).[Select](Function(s) String.Format("Name LIKE '%{0}%'", s)))`
Comment: Why didn't you tag your question with `VB.Net` instead of `C#` then? I have no clue how VB.Net uses Linq. Not sure why you get the error, perhaps you can append `.ToArray()` after the `Select`?

Filter bind source


Metatag and page title modules conflict

Question: I am using Drupal 7 with the Metatag module along with the Page title module.
I have a requirement to build the title of a custom content type using some node fields and additional conditions that I can't reproduce using the tokens provided, so I have hooked to the page title API ( hook_page_title_alter(&$title)) to build my custom title only for one node type.
The function works and the page title is set. But the meta tags are wrong, they are not using the page title found in <TITLE> (under ) but the node's title which I don't want to use.
How do I feed metatags module with my custom title ? I am out of ideas, so anything is appreciated.
As commented by someone you don't need the page_title module if you use metatags, but page_title provides an API with hooks to alter the page title, and that's what I am using and what I need to use, so maybe the question could be reformulated to "How do I alter the page title generated by metatags?"
Comment: There is already 'Page title' configuration with 'Meta tag' Module. You do not need to install separate 'Page title' module.
Comment: So the hooks already exist in the metatag module ? I will take a look.
Comment: The API hooks for altering the title are not present in the metatags module, so I need both. Or a hook elsewhere to modify the metatags title ...
Comment: Are you using Drupal 7?
Comment: Yes, Drupal 7 (edited).
Comment: If you edit you content, you will get 'Page title' under 'Meta tag' fieldset. You can use 'token' to set page title or can set pattern in 'Meta tag' under search metadata in admin.
Comment: I already know and use that, but my requirements for the title are quite unique and I need to set it using PHP.
Comment: OK. I have not looked into api of metatag. I will look into this and if I found anything, I will let you know.
Answer: It is indeed a bad idea to have both modules altering the page title. A better approach I have found is to create a custom token, (which is really trivial with the provided example) and use it inside a metatag configuration for the desired node type. This way page_title could be uninstalled since it's no longer needed.

Metatag and page title modules conflict


Conditional expectation of function from $\mathbb{R}^n$ to $\mathbb{R}$

Question: Let $f$ be a 1-Lipschitz function from $\mathbb{R}^n$ to $\mathbb{R}$, and let $\{X_i\}$ be an independent sequence of random variables, each with variance $\leq 1$.
Suppose we are given a function $g(x_1, \dots, x_{k}) := E\left(f\left(x_1, \dots, x_{k},X_{k+1}, \dots, X_{n}\right)\right)$ from $\mathbb{R}^k \rightarrow \mathbb{R}$ with $k < n$. Finally, we define another function $v(x_1, \dots, x_{k-1}) := Var(g(x_1, \dots, x_{k-1},X_{k}))$.
I realize that this is a pretty convoluted construction, but I believe everything so far is well-defined.
Now, I have a few questions about what happens if I replace $x$s with random variables. In particular, what is $g(X_1, \dots, X_k)$? I am interpreting it as
$$g(X_1, \dots, X_k) = E(f(X_1, \dots, X_n)|X_1, \dots, X_k),$$
is this correct?
What about $Ev(X_1, \dots, X_{k-1})$? I am interpreting this as
$$Ev(X_1, \dots, X_{k-1}) = E\left(Var(g(X_1, \dots,X_{k})|X_1, \dots, X_{k-1})\right),$$
is this correct?
If the above interpretations are correct, how do I evaluate $E\left(Var(g(X_1, \dots,X_{k})|X_1, \dots, X_{k-1})\right)$? I would like to show that it is less than 1.
Intuitively, this should follow from the fact that $f$ is $1$-Lipschitz and that $Var(X_{k}) \leq 1$.
I want to formalize the idea that $X_1, \dots, X_{k-1}$ are "fixed" (since they are being conditioned on), and that $X_{k+1}, \dots, X_n$ are also "fixed" (since they don't vary with $g$), leaving only $X_k$ to "vary", but I am having an extremely difficult pinning this down rigorously.
Answer: Here is a well-known result about conditioning:

Let $X$ and $Y$ take values in $(S,\mathcal{S})$ and let $\mathcal{F}$ be a $\sigma$-field s.t. $X$ is $\mathcal{F}$-measurable and $Y$ is independent of $\mathcal{F}$. If $\varphi$ is a function  with $\mathsf{E}|\varphi(X,Y)|<\infty$, then
  $$
\mathsf{E}[\varphi(X,Y)\mid \mathcal{F}]=\psi(X)\quad\text{a.s.},
$$
  where $\psi(x):=\mathsf{E}\varphi(x,Y)$.

In your case, letting $W_k:=[X_1,\ldots, X_k]$,
$$
g(W_k)=\mathsf{E}[f(W_n)\mid W_k]
$$
and
$$
v(W_{k-1})=\mathsf{E}[(g(W_k))^2\mid W_{k-1}]-\left(\mathsf{E}[g(W_k)\mid W_{k-1}]\right)^2.
$$
Therefore,
\begin{align}
\mathsf{E}v(W_{k-1})&=\mathsf{E}\left(\mathsf{E}[f(W_n)\mid W_k]\right)^2-\mathsf{E}\left(\mathsf{E}[f(W_n)\mid W_{k-1}]\right)^2 \\
&=\mathsf{E}[\operatorname{Var}(\mathsf{E}[f(W_n)\mid W_k]\mid W_{k-1})].
\end{align}

The function $g$ is $1$-Lipschitz on $\mathbb{R}^k$ because
\begin{align}
|g(x)-g(y)|&\le\mathsf{E}|f(x_1,\ldots,x_k,W_{k+1},\ldots,W_n) \\
&\qquad-f(y_1,\ldots,y_k,W_{k+1},\ldots,W_n)|\le \|x-y\|.
\end{align}
Consequently,
\begin{align}
\mathsf{E}v(W_{k-1})&=\mathsf{E}\operatorname{Var}\left(g(W_k)-g(\mathsf{E}[W_k\mid W_{k-1}])\mid W_{k-1}\right) \\
&\le \mathsf{E}[g(W_k)-g(\mathsf{E}[W_k\mid W_{k-1}])]^2 \\
&\le \mathsf{E}\|W_k-\mathsf{E}[W_k\mid W_{k-1}]\|^2=\operatorname{Var}(X_k).
\end{align}
Comment: Thank you for this great answer, it was very helpful.

I have a couple of quick questions: Should the second last line be $\mathsf{E}\left(\mathsf{E}[f(W_n)\mid W_k]^2\right)-\mathsf{E}\left(\mathsf{E}[f(W_n)\mid W_{k-1}]\right)^2$? Also, I presume the last line should have $Var(E(f(W_n)|W_k))$ instead of $Var(E(W_n|W_k))$.

How do I go about thinking about the last expression? Any ideas on how I can show that it is less than 1?
Comment: Thanks a lot for your edit, and for putting so much time into this. I understand if you don't want to spend more time on this, so I am accepting your answer.

But, I do believe we can improve the result, right? This allows me to bound it by $n-k$, but I think we should be able to get $Ev(W_{k-1}) \leq Var X_k$, do you agree?

If so, any ideas on how I could approach this?
Comment: @jackson5 Updated.


Why log-transforming the data before performing principal component analysis?

Question: Im following a tutorial here: http://www.r-bloggers.com/computing-and-visualizing-pca-in-r/ to gain a better understanding of PCA.
The tutorial uses the Iris dataset and applies a log transform prior to PCA:

Notice that in the following code we apply a log transformation to the continuous variables as suggested by [1] and set center and scale equal to TRUE in the call to prcomp to standardize the variables prior to the application of PCA.

Could somebody explain to me in plain English why you first use the log function on the the first four columns of the Iris dataset. I understand it has something to do with making data
relative but am confused what's exactly the function of log, center and scale.
The reference [1] above is to Venables and Ripley, Modern applied statistics with S-PLUS, Section 11.1 that briefly says:

The data are physical measurements, so a sound initial strategy is to work on log scale. This has been done throughout.
Comment: Related: https://stats.stackexchange.com/questions/319794.
Answer: The iris data set is a fine example to learn PCA. That said, the first four columns describing length and width of sepals and petals are not an example of strongly skewed data. Therefore log-transforming the data does not change the results much, since the resulting rotation of the principal components is quite unchanged by log-transformation.
In other situations log-transformation is a good choice.
We perform PCA to get insight of the general structure of a data set. We center, scale and sometimes log-transform to filter off some trivial effects, which could dominate our PCA. The algorithm of a PCA will in turn find the rotation of each PC to minimize the squared residuals, namely the sum of squared perpendicular distances from any sample to the PCs. Large values tend to have high leverage.
Imagine injecting two new samples into the iris data. A flower with 430 cm petal length and one with petal length of 0.0043 cm. Both flowers are very abnormal being 100 times larger and 1000 times smaller respectively than average examples. The leverage of the first flower is huge, such that the first PCs mostly will describe the differences between the large flower and any other flower. Clustering of species is not possible due to that one outlier. If the data are log-transformed, the absolute value now describes the relative variation. Now the small flower is the most abnormal one. Nonetheless it is possible to both contain all samples in one image and provide a fair clustering of the species. Check out this example:
data(iris) #get data
#add two new observations from two new species to iris data
levels(iris[,5]) = c(levels(iris[,5]),"setosa_gigantica","virginica_brevis")
iris[151,] = list(6,3,  430  ,1.5,"setosa_gigantica") # a big flower
iris[152,] = list(6,3,.0043,1.5  ,"virginica_brevis") # a small flower

#Plotting scores of PC1 and PC" without log transformation
plot(prcomp(iris[,-5],cen=T,sca=T)$x[,1:2],col=iris$Spec)

#Plotting scores of PC1 and PC2 with log transformation
plot(prcomp(log(iris[,-5]),cen=T,sca=T)$x[,1:2],col=iris$Spec)

Comment: Nice demo and plots.
Answer: Well, the other answer gives an example, when the log-transform is used to reduce the influence of extreme values or outliers.
Another general argument occurs, when you try to analyze data which are multiplicatively composed instead of addititively - PCA and FA model by their math such additive compositions. Multiplicative compositions  occur in the most simple case in physical data like the surface and the volume of bodies (functionally) dependent on (for instance) the three parameters lenght, width, depth. One can reproduce the compositions of an historic example of the early PCA, I think it is called "Thurstone's Ball- (or 'Cubes'-) problem" or the like. Once I had played with the data of that example and had found that the log-transformed data gave a much nicer and clearer model for the composition of the measured volume and surface data with the three one-dimensional measures.
Besides of such simple examples, if we consider in social research data interactions , then we ususally think them as well as multiplicatively composed measurements of more elementary items. So if we look specifically at interactions, a log-transform might be a special helpful tool to get a mathematical model for the de-composition.
Comment: @Amatya - I didn't find the "thurstone-box-problem", but a (german) site discussion pca on cubes, containing width,lenght,height as basic items and surfaces and volume as multiplicatively combined additional items. Perhaps the included formulae for definitions are enough.  See http://www.sgipt.org/wisms/fa/Quader/q00.htm
Comment: Ah, and I forgot  - an old discussion of mine about this http://go.helms-net.de/stat/fa/SGIPT_Quader.htm
Comment: Could you please list some references that may explain the "multipicative" compositions better? Thanks a lot!
Comment: @GottfriedHelms I'm still not really understanding why if we are standardizing the variables, we need to also log-transform them as well. I understand the general principle of reducing the unwanted influence of extreme outliers, but if we are already standardizing (centering, scaling) them, it seems like log transforming it in addition is actually distorting the data.
Comment: @YuChen - any log-transformation converts *multiplicatively* composition to *additive* composition, and additive composition is the basic assumption (besides of linearity etc) of all types of components and factor analysis. So if your data have multiplicative composition in it, a log-transform should be an option worth to consider.


Why bss has some value in this case?

Question: I saw this in some website and was surprised with the result:
#include <stdio.h>

int main(void)
{
    return 0;
}

When the above code is checked for memory in each sections using size
$ gcc memory-layout.c -o memory-layout
$ size memory-layout
text       data        bss        dec        hex    filename
960        248          8       1216        4c0    memory-layout

Here,
    without any global or static variables, the size of bss is shown 8. I didn't get for what this 8 bytes are used?
Answer: You are looking at the segment sizes for the full executable program: the object module for your source code is linked to the standard library startup code and the necessary library support functions, such as exit.  The numbers you see for data and bss are probably due to global objects defined by these modules.  Note in particular that your main function hardly justifies 960 bytes of code.
Generate just an object file and run size on that:
$ gcc -c memory-layout.c
$ size memory-layout.o

Why bss has some value in this case?


Proving set equality?

Question: I was looking online for some examples to aid my understanding of set equality and I'm confused on this question.
$A = \{x\mid 0 ≤ x ≤ 50 \quad\text{and}\quad  x=4n^2 +11, \quad n\in N\}$.
$B = \{n^2 + 11\mid n\in N,n ≤ 6\}$
Is $A = B$?
I understand I need to show $A$ is a subset of $B$ and $B$ is a subset of $A$, But I get stuck here.
Comment: Where do you get stuck specifically? You are right that showing A and B to be subsets of each other works.
Comment: @Dasherman - I get stuck on how to go about showing the subsets as a proof?
Comment: For every element of A, show that it must also be in B and vice versa.
Comment: So, I would need to list out all the elements of A and B and see if they are in each other? - What about proving it with arbitrary sets?
Comment: No, just use "Let x be an element of A....[here you prove the stuff]... Thus x must be in B" and the other way around.
Comment: @Dasherman - Okay I understand you, but the proof bit is the bit in which i get stuck as Im not sure if I'm doing it right
Answer: $A \neq B$ because $12 \in B$, but $\not \in A$.
Comment: Could you please elaborate on how you did that?
Comment: Take $n=1$.Thus,  $12 \in B$. But there is no $n \in \mathbb{N}$ such that $12 \in A$.
Comment: Great thanks. If i would assume there are two arbitrary sets A and B - how would I show that they are equal? or is that not possible?
Comment: Yes! You should show that $A \subseteq B$ and $B \subseteq A$.
Comment: through arbitrary sets how would that be possible to show a subset b and b subset a ?
Comment: I think there is no a general method for that. It depends on the sets.
Comment: @RandomMath $A\subseteq B\iff \forall x\in A(x\in B)$.
Answer: Just by explicit computation we have $A=\{15,27,47\}$ and $B=\{ 12, 15, 20, 27, 36, 47\}$.
Hence $A \subset B$. Since $|A| < |B|$, we have $A \neq B$.
If you want to make it more complicated, note that
$4 n^2 +11 \le 50 $ iff $|n| \le { \sqrt{39} \over 2}$, hence
$A = \{ 4 n^2+11 | n \in \mathbb{N}, n \le 3 \} = \{ (2n)^2+11 | n \in \mathbb{N}, n \le 3 \}$.
Now note that $\{ 2n | n \in \mathbb{N}, n \le 3 \} \subset \{ n | n \in \mathbb{N}, n \le 6 \} $, hence we have
$A \subset B$. (And again, $|A| < |B|$, so we have $A \neq B$.)

Proving set equality?


How can I prove this statement?

Question: I wanted to prove this using induction, but since the RHS is a sum, I can't use the assumption. Therefore I'm stuck in the middle. Is there maybe a way proving that without induction?
If induction is the only way, can you give any hints please? Especially how to get rid of the sum on the RHS?
$\sum_{k=1}^{2n}(-1)^{k+1}\frac{1}{k}=\sum_{k=1}^n\frac{1}{n+k}$
Answer: HINT: You will want to do it by induction. For the induction step, notice that if you replace $n$ by $n+1$, you add
$$(-1)^{2n+2}\frac1{2n+1}+(-1)^{2n+3}\frac1{2n+2}=\frac1{2n+1}-\frac1{2n+2}$$
to the lefthand expression, and on the right you add
$$\sum_{k=1}^{n+1}\frac1{n+1+k}-\sum_{k=1}^n\frac1{n+k}=\sum_{k=2}^{n+2}\frac1{n+k}-\sum_{k=1}^n\frac1{n+k}\;.\tag{1}$$
The difference on the righthand side of $(1)$ allow a lot of telescoping. In fact, you should end up with just three terms.
Comment: @Arthur: Looks good!
Comment: I'm sorry but I don't understand how you got your term on the right hand side (1)? I put $n+1$ in for $n$ but I don't get what you got.
Comment: @Arthur: Do you mean the first summation, $\sum_{k=2}^{n+2}\frac1{n+k}$?
Comment: I mean the whole line (1). I get $\sum_{k=1}^n\frac{1}{n+1+k}+\frac{1}{2n+2}$. Where does your $-\sum_{k=1}^n\frac{1}{n+k}$ come from?
Comment: @Arthur: I'm not simply evaluating the righthand side of your equation with $n$ replaced by $n+1$: I'm calculating how much that change *adds* to the righthand side, just as my first calculation shows how much it adds to the lefthand side of your equation. Thus, my first summation in $(1)$ is the righthand side for $n+1$, and I'm subtracting the righthand side for $n$ to get the increase.
Comment: I'm still confused... I have this so far for the induction step: $(\sum_{k=1}^{2n}(-1)^{k+1}\frac{1}{k})+\frac{1}{2n+1}-\frac{1}{2n+2}=(\sum_{k=1}^n\frac{1}{n+k})+\frac{1}{2n+1}-\frac{1}{2n+2}$. Should I subtract the right hand side now?
Comment: @Arthur: For the induction step you want to show that the two sides of your equation change by the same amount when you increase $n$ to $n+1$: then if they started equal (your induction hypothesis), they must end up equal. In my answer I showed how to calculate how much each side changes; you just have to show that those amounts really are equal.
Comment: I think I got it now. Are the three remaining terms $\frac{1}{2n+2}+\frac{1}{2n+1}-\frac{1}{n+1}$?
Comment: @Arthur: Not quite, though I think that you may have the right general idea: the first sum does have two extra terms, but they're the $k=n+1$ and $k=n+2$ terms, so they're $\frac1{2n+1}+\frac1{2n+2}$; with that as a model, can you fix the third term?
Comment: Is it correct now?
Comment: @Arthur: You're welcome!

How can I prove this statement?


How to use entities in collection (+prototype) in Symfony 2.1

Question: I want to add a collection of entities in Symfony 2.1.0-dev bug I got:
Neither property "sitterDegrees" nor method "getSitterDegrees()" nor method "isSitterDegrees()" exists in class "xxx\Entity\Degrees"

It happen because I have an entity in DegreesFormType.php and at this line
$this->form->bindRequest($request); in my handler.
I want to add multiple "degrees" on "sitter" entity (but degrees are a choice not like http://symfony.com/doc/master/cookbook/form/form_collections.html)
Did I forget something?
Entities
A simple ManyToMany between Sitter and Degrees
Sitter
class Sitter
{
    //some properties
    /**
     * @var xxx\Entity\Degrees
     * @ORM\ManyToMany(targetEntity="xxx\Entity\Degrees", orphanRemoval=true, inversedBy="sitters",cascade={"persist"})
     * @ORM\JoinTable(name="sitter_degrees_relationships",
     *   joinColumns={
     *     @ORM\JoinColumn(name="sitter_id", referencedColumnName="id")
     *   },
     *   inverseJoinColumns={
     *     @ORM\JoinColumn(name="degrees_id", referencedColumnName="id")
     *   }
     * )
     */
    private $sitterDegrees;

    public function getSitterDegrees()
    {
        return $this->sitterDegrees;
    }

    public function setSitterDegrees(ArrayCollection $sitterDegrees)
    {
        foreach ($sitterDegrees as $sitterDegree) {
            $sitterDegree->addSitter($this);
        }

        $this->sitterDegrees = $sitterDegrees;
    }

    public function addSitterDegree(xxx\Entity\Degrees $sitterDegrees)
    {
        $this->sitterDegrees[] = $sitterDegrees;

        return $this;
    }

    public function removeSitterDegree(xxx\Entity\Degrees $sitterDegrees)
    {
        $this->sitterDegrees->removeElement($sitterDegrees);
    }
}

Degrees
class Degrees
{
    public function __toString(){return $this->name;}

    private $id;

    private $name;

    /**
     * @var xxx\Entity\Sitter
     * @ORM\ManyToMany(targetEntity="xxx\Entity\Sitter", mappedBy="sitterDegrees")
     */
    private $sitters;

    public function __construct()
    {
        $this->sitters = new \Doctrine\Common\Collections\ArrayCollection();
    }

    public function getId()
    {
        return $this->id;
    }

    public function setName($name)
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }

    public function getSitters()
    {
        return $this->sitters;
    }

    public function addSitter(xxx\Entity\Sitter $sitter)
    {
        if (!$this->sitters->contains($sitter)) {
            $this->sitters->add($sitter);
        }
    }

    public function removeSitter(xxx\Entity\Sitter $sitters)
    {
        $this->sitters->removeElement($sitters);
    }
}

FormType
VerifFormType.php is my main form, it embed DegreesFormType.
VerifFormType.php
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        //->add('some_properties')
        ->add('sitterDegrees', 'collection', array(
                            'type' => new DegreesFormType(),
                            'by_reference' => false,
                            'allow_add' => true,
                            'allow_delete' => true,
            )
        );
}

DegreesFormType.php
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('sitterDegrees', 'entity', array(
            'class' => 'xxx:Degrees'
        ));

}

Controller
public function indexAction()
{
    $user = $this->get('security.context')->getToken()->getUser();
    $sitter = $user->sitter;

    $formHandler = $this->get('xxx.form.handler');
    $form = $formHandler->getForm();
    $form->setData($sitter);

    if ($formHandler->process()) {
        //ok
    }

    //fail

}

Handler
public function process()
{
    $request = $this->container->get('request');
    if ('POST' == $request->getMethod()) {
        $this->form->bindRequest($request);//Fail at this line

        if ($this->form->isValid()) {
            return $this->onSuccess();
        }
    }
    return false;
}

public function onSuccess()
{
    $sitter = $this->form->getData();
    $this->form->bindRequest($this->container->get('request'));
    $sitter->setContainer($this->container);
    $this->container->get('xxx.manager')->persistSitter($sitter);

    return true;
}

index.html.twig
With some javascript like in the cookbook http://symfony.com/doc/master/cookbook/form/form_collections.html

  {% for sitterDegree in form.sitterDegrees %}

{{ form_row(sitterDegree) }}

  {% endfor %}

Answer: The error comes from DegreesFormType: The sitterDegrees field maps to a setterDegrees property in your Degrees class. However, this class doesn't have such property.
There is a similar problem in VerifFormType: The sitterDegrees field maps to a setterDegrees property in your Sitter class. However, this class doesn't have such property.
Comment: Thx, but VerifFormType isn't good? Yet there is a sitterDegrees property in Sitter class. But I don't see how to fix DegreesFormType, any clues/examples?
Comment: Ok fixed, I just needed name instead of sitterDegrees in DegreesFormType.


Exterior derivative of a two-form as a divergence times the volume form

Question: In a textbook, I have found the following relation.
$$
d \stackrel{2}{\omega_V}
=
\frac{1}{3!}
(\mathrm{div} V)
\epsilon_{ijk}
dx^i \wedge dx^j \wedge dx^k .
$$
It is cool, but I don't know how to show it in an elegant way, please show me the way.
Here are definitions:
It is a relation in a Euclidean space $\mathbb{R}^3$. There is a vector field in that space $V \in \Gamma (T\mathbb{R}^3)$. With the use of components of that vector, one can define a two-form
$$
\stackrel{2}{\omega_V} := \frac{1}{2} V^i \epsilon_{ijk} dx^j \wedge dx^k,
$$
where $\epsilon$ is completely antisymmetirc and $\epsilon_{123} =1$. Divergence of a vector is
$$
\mathrm{div}V = V^m_{\hphantom{mk},m}
$$
where comma indicates partial derivative.
My attempt:
By taking the derivative of $\stackrel{2}{\omega_V}$ I get
$$
d\stackrel{2}{\omega_V}
=
\frac{1}{2} V^i_{\hphantom{m},l} \epsilon_{ijk}
dx^l \wedge dx^j \wedge dx^k
$$
clearly, only terms where $i=l$ are non-zero. Consequently, by substituing $V^i_{\hphantom{m},l}$ with $V^i_{\hphantom{m},i}$ and dividing by  number of extra repetition which is $3$, I get what I want, but its v hand-wavy. Can someone can show me how to do in a decent way?
Comment: You did in a decent way, I think there is nothing to improve.
Answer: You can make a remark that
$$ dx^l \wedge dx^j \wedge dx^k = \epsilon^{ljk} {\rm vol} $$
where ${\rm vol} = \frac{1}{3!}\epsilon_{ijk}dx^i\wedge dx^j\wedge dx^k$ is the volume form. Then use the fact that
$$ \epsilon_{ijk}\epsilon^{ljk} = 2\delta^l_i$$
That may make the final transformations a bit smoother.


Traffic on port 80 although Http-Server is not running

Question: Good'day
Just out of curiosity I did a tcpdump port 80 on one of my remote virtual machines. I see a huge amount of requests to this http-port, 95% going to some AWS EC2 instance. Strange thing: The Web-Server was not on high load at all. The packets from tcpdump look like this:
20:57:16.860028 IP user123.example.net.http > ec2-55-155-123-123.ap-northeast-2.compute.amazonaws.com.12345: Flags [S.], seq 1234567, ack 12345567, win 12300, options [mss 1460], length 0

(user123.example.net.http is the address of my remote machine)
All of them looks basically the same, only thing that changes, is the actual EC2-adress (aka IP-adress) and the destination port. Sometimes it's an incoming packag (to port 80, too), but most of them are outgoing.
I run this tcpdump on port 80 today, from the office now. Now the traffic is between the remote virtual machine and another IP-adress, not the AWS-instance anymore:
08:34:46.369161 IP user123.example.net.http  > 184.108.40.206.37176: Flags [R.], seq 0, ack 2821777444, win 0, length 0
08:34:46.388933 IP 184.108.40.206.55539 > user123.example.net.http : Flags [S], seq 2934790784, win 29200, length 0

In this case, the IP-Adress does not change.
Only thing that changed: I remotely logged in from my working place now, using another IP-Adress (not the one you can see in tcpdump) and another SSH-client.
Investigation
What I tried so far, without success:

I checked the logfile of nginx, they don't show any traffic (I am not running huges sites, just some  little private projects)
I stopped nginx, the only apparent port80-daemon in this setup
I stopped all other non-system services: no changes

Current setup
I am running nginx on this server on port 80 and 443, but traffic is generally routed to HTTPS. Also I am running PHP 7.3 with FPM, but on sockets, not via TCP.
Besides that, I am running some e-mail services (dovecot, postfix, ...), Unbound, a *MySQL-*Server and an *ELK-*stack. This is what netstat -tulpn confirms:
(I x'ed my public IP-Adress and my SSHD-port, which is not the default one)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      858/unbound
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2806/master
tcp        0      0 x.x.x.x:25              0.0.0.0:*               LISTEN      2806/master
tcp        0      0 127.0.0.1:8953          0.0.0.0:*               LISTEN      858/unbound
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      7942/nginx -g daemo
tcp        0      0 0.0.0.0:4190            0.0.0.0:*               LISTEN      628/dovecot
tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      628/dovecot
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      491/mysqld
tcp        0      0 127.0.0.1:587           0.0.0.0:*               LISTEN      2806/master
tcp        0      0 x.x.x.x:587             0.0.0.0:*               LISTEN      2806/master
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      628/dovecot
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      7942/nginx -g daemo
tcp        0      0 0.0.0.0:???             0.0.0.0:*               LISTEN      27952/sshd
tcp6       0      0 ::1:53                  :::*                    LISTEN      858/unbound
tcp6       0      0 ::1:25                  :::*                    LISTEN      2806/master
tcp6       0      0 ::1:8953                :::*                    LISTEN      858/unbound
tcp6       0      0 :::443                  :::*                    LISTEN      7942/nginx -g daemo
tcp6       0      0 :::4190                 :::*                    LISTEN      628/dovecot
tcp6       0      0 :::993                  :::*                    LISTEN      628/dovecot
tcp6       0      0 ::1:587                 :::*                    LISTEN      2806/master
tcp6       0      0 :::143                  :::*                    LISTEN      628/dovecot
tcp6       0      0 :::80                   :::*                    LISTEN      7942/nginx -g daemo
tcp6       0      0 :::???                  :::*                    LISTEN      27952/sshd
udp        0      0 127.0.0.1:53            0.0.0.0:*                           858/unbound
udp6       0      0 ::1:53                  :::*                                858/unbound

After stopping all of the above mentioned servies, this is the output - Packets on port 80 still remains:
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:???             0.0.0.0:*               LISTEN      27952/sshd
tcp6       0      0 :::???                  :::*                    LISTEN      27952/sshd

That's the output of service status-all|grep + (marked some with an * - those didn't stop when stopping the parent process, still trying to figure that out)
 [ + ]  amavis-mc *
 [ + ]  amavisd-snmp-subagent *
 [ + ]  apache-htcacheclean *
 [ + ]  apparmor
 [ + ]  cron
 [ + ]  fail2ban
 [ + ]  gdomap
 [ + ]  ip6tables
 [ + ]  iptables
 [ + ]  lm-sensors
 [ ? ]  modules_dep.sh
 [ + ]  nscd
 [ ? ]  php-fpm-chroot-setup.sh (make PHP available after reboot)
 [ + ]  procps
 [ + ]  quota
 [ + ]  rc.local
 [ + ]  resolvconf
 [ + ]  rsyslog
 [ + ]  ssh
 [ + ]  sysstat
 [ + ]  udev
 [ + ]  unattended-upgrades
 [ + ]  urandom
 [ + ]  uwsgi

Question is..
Why is there traffic on port 80, even if nginx is not running?
Where does this traffic comes from (what process)?
Comment: Are you sure the packet source is `user123.example.net.http`? The port http points to a webserver.
Comment: Can you please edit your question to be a bit more precise. Is this your web server making outgoing requests to a variety of EC2 servers, or your home PC? What other software is running on the server? If you shut down the services one by one which one stops the requests being sent?
Comment: @EduardoTrápani Gotta admit, I don't understand your question. Or I am confused as you are. As far as I understand tcpdump, the left side is the packet source, in this case port 80  of my local machine.  So: Yes, I am sure.
Comment: @Tim Sure, added some more details.
Comment: @Tim Didn't try stopping services one by one, thought it has to do something with nginx, but will try this definetely tomorrow.
Comment: Your question is still vague and imprecise. When you edit it, don't just tack info on, you can rewrite the whole question to make sense. If you're confident it's Nginx then shut it down, show it's not happening, then edit your question to include the full Nginx configuration. Then we can help.
Comment: What your packet capture shows is not the behaviour you are describing.
Comment: @Tim sorry, your totally right, I rewrote it, hopefully it's better to read now.
Answer: If your webserver initiates the outgoing request on port 80, stopping your nginx webserver doesn't necessarily help because many services can initiate an outgoing connection on port 80.
You won't get any more detail with tcpdump because it's on the ethernet level. You need to find the source of the problem.
Most of the time, when you see such a high requests of outgoing traffic, it's originating from the outside, executing for example a PHP script on one of your sites. But since you disabled Nginx, this is not obvious. But double check if really nothing is listening on port 80 or 443 anymore when nginx is disabled, since such a PHP file can be called from 443 or any other port your webserver is listening on.
Check if something still listens on a specific port with this command:
netstat -tulpn

If really nothing is running on port 80 or 443 anymore and you still see the initiated outgoing port 80, I would block incoming requests, see if it's originating from your webserver itself for sure.
If that's the case, check all running services, because only a running service can then be the initiator. You can also use:
netstat -tulpn

or
service --status-all

Check for suspicious services and try to disable them, see if that helps.


Disable warnings and all prints in in sql engine

Question: I have a sql engine with main stored procedure that call many other stored procedures , how can i disable all warnings and prints while executing this engine from job
is there a way to do that without finding all prints and disable them , and what can i do with warnings like Warning: Null value is eliminated by an aggregate or other SET operation
Answer: One way to solve this problem is by turning the warnings off.
SET ANSI_WARNINGS OFF;
GO

Comment: @MarianNasry yes you have to Add in All Store Proc
Comment: @AlfaizAhmed, `ANSI_WARNINGS OFF` will not affect `PRINT` statements. I strongly recommend running with `ANSI_WARNINGS ON` to conform to ISO behavior and handle informational and warnings as desired in the app code. SQL Server features like filtered indexes and indexed views require the setting to be on.
Comment: i have to add this in all stored procedures , is there any way to add this only one time ?