How to do this simple set operation?

Question:
Suppose A and B are events with P(A) 0.4 , P(B)  0.6 and P(A and B)
  0.25 . Calculate the probability P(A complement union B).
A 0.25
B 0.65
C 0.75
D 0.85

What I tried?-
P(A union B)=P(A)+p(B)-P(A and B)
i.e=0.4+0.6-0.25=0.75.  I am stuck after this. i know this is simple but I am unable to find the right approach.

Below is the diagram that I created after solving up to here.
Comment: Start by drawing a little diagram with all the cases (an array with A and not A as lines, B and not B as columns), you'll see how it works.
Answer: Your graph is fine. Now you can mark the area of $\overline A$. I did this with red lines. It is just the whole rectangle without $A$.

After that you mark the area of $B$
I did this with blue lines.

Now the union of this two areas are the whole rectangle without the unmarked area. Because of the values you already have inserted it can be easily seen (calculated) what $P(\overline A \cup B)$ is.
Comment: thanks for such a fine explanation. sorryy I am unable to figure out how to do calculation after this.
Comment: The unmarked area is $0.15$. And the area of the rectangle is $1$. Therefore the marked area is $1-0.15$.
Comment: Thanks it seems. P(A complement) is equal to P(A comp Union B) in this case.
Comment: Not really. $P(\overline A)=1-P(A)=1-0.4=0.6$ and $P(\overline A \cup B)=1-0.15=0.85$ It is comprehensible ? In your exercise the area of $A \cap B$ (blue marked only) is included, which is $0.25$.
Comment: thanks well understood now. Thanks a lot.
Comment: Nice to hear. You´re welcome.

How to do this simple set operation?


Constructing a function $u\in (W_0^{1,p}(B)\cap C(B))\setminus C(\overline{B})$.

Question: Let $B\subset \mathbb{R}^2$ be the unit "open" ball with centre in origin. Define a function $u:\overline{B}\to \mathbb{R}$ in the folllowing way: let $(x,y)=(r\cos\theta,r\sin\theta)$ with $r\in [0,1]$ and $\theta\in [0,2\pi]$.
For $r\in [0,1]$ and $\theta\in [\pi,2\pi]$, $u(r,\theta)=0$.
Now consider the segment $\ell=\{te_2+(1-t)e_1, \ t\in [0,1]\}$. For each $\theta\in [0,\pi/2]$, let $r_\theta\in [0,1]$ be the number for which $r_\theta\theta\in \ell$.
For $\theta\in [0,\pi/2]$, define $u(r,\theta)=2r\theta/\pi $, if $r\in [0,r_\theta]$.
For $\theta\in [0,\pi/2]$, define $u(r,\theta)=2r_\theta\theta/\pi-2r_\theta\theta/((1-r_\theta)\pi)(r-r_\theta)$, if $r\in [r_\theta,1]$.
We define $u(r,\theta)$ for $\theta\in [\pi/2,\pi]$ and $r\in [0,1]$ in an analogous way, by considering the segment $\ell'=\{te_2-(1-t)e_1,\ \forall\ t\in [0,1]\}$.
My question is: does $u\in W_0^{1,p}(\Omega)$ for some $p\in [1,\infty)$. If not, does anyone know of a function $u$ satisfying $$u\in (W_0^{1,p}(B)\cap C(B))\setminus C(\overline{B})$$
Remark: Note that my function $u$ satisfies $u\in C(B)\setminus C(\overline{B})$.
Remark 1: The graph of $u$ is piecewise linear.
Answer: Near $e_2$, you have the function approaching $1$ along the segment $\ell$; yet it's zero on the boundary of the disk. This will make $|\nabla u|$ blow up like $|x-e_2|^{-1}$ in between, guaranteeing $u\notin W^{1,p}$ for $p\ge 2$. I think $u\in W^{1,p}$ for $1\le p<2$. A more transparent description of (some version of) your function could be:
Let $\Omega$ be an open  disk, and let $Q$ be a square inscribed in $\Omega$. Define
$$
u(x) = \frac{\operatorname{dist}(x,\Omega^c)}{\operatorname{dist}(x,\Omega^c)+\operatorname{dist}(x,Q)},\quad x\in \Omega \tag{1}
$$
Note that $u\equiv 1$ on $Q$, and there are discontinuities at the points where the square touched the boundary of the disk. Since the distance function is $1$-Lipschitz, one can see from (1) that $u$ is locally Lipschitz in $\Omega$ and
$$|\nabla u|\lesssim (\operatorname{dist}(x,\Omega^c)+\operatorname{dist}(x,Q))^{-1}$$
The measure of the set where $\operatorname{dist}(x,\Omega^c)+\operatorname{dist}(x,Q)<\epsilon$ is $O(\epsilon^{-2})$, which means $|\nabla u|\in L^{2,\infty}$, hence $|\nabla u|\in L^p$ for $1\le p<2$.
The function is in $W^{1,p}_0$ because its zero extension to $\mathbb R^2$ has the ACL property and the derivatives are integrable, as stated above. I omit the details because the goal is easier to achieve with a different construction which I describe below.
Let
$$
u(x) = \sum_{n=1}^\infty \left(1-M_n|x-x_n| \right)^+
 $$
where $x_n\to e_1$ and $M_n\to \infty$. Every partial sum is a Lipschitz function with compact support on $\Omega$. The  $n$th term of the series has $W^{1,p}$ norm $O(M_n^{1-2/p})$; hence, the series can be made convergent in $W^{1,p}$ for every $p<2$. And since $u(x_n) =  1$ for all $n$, the sum is not continuous at $e_1$.
Comment: That's the first time I see someone proving that $f\in L^p$, by showing first that it is in some weak Lebesgue space. For this particular case, is there some justification behind this idea?
Comment: @Tomás If a function is geometrically described, it may be easier to determine the geometry of level sets than to actually integrate it. And that naturally leads to weak $L^p$ estimates. BTW I added a remark about $W^{1,p}_0$: this is the case, because the zero extension is ACL.
Answer: Such a function could also be constructed the lines of Boundedness of functions in $W_0^{1,p}(\Omega)$ if one chooses the functions $f_i$ to be continuous which is clearly possible. For any $x \in B$, there is a neighborhood which intersects the support of finitely many of the $f_i$, hence the limit $f$ is continuous at $x$. And since $f$ is not bounded on $B$, it can not be extended continuously to $\bar B$.


Can't pass data correctly to modal presentation using ForEach and CoreData in SwiftUI

Question: Im trying to pass data of some object from list of objects to modal sheet, fetching data from CoreData.
The problem is that no matter what object I click on in the list, only the data form last added object appears in the details view.
The same goes for deleting the object - no matter what object I'm trying to delete, the last one is deleted all the time.
Problem disappears using NavigationLink, but it is not suitable for me.
Here is my code:
import SwiftUI

struct CarScrollView: View {

    @Environment(\.managedObjectContext) var moc
    @FetchRequest(entity: Cars.entity(), sortDescriptors: []) var cars: FetchedResults<Cars>

    @State var showDetails = false

    var body: some View {
        VStack {
            ScrollView (.vertical, showsIndicators: false) {
                ForEach (cars, id: \.self) { car in

                    Text("\(car.text!)")
                        .onTapGesture {
                            self.showDetails.toggle()
                    }
                    .sheet(isPresented: self.$showDetails) { CarDetail(id: car.id, text: car.text)
                    }
                }
            }
        }
    }
}

Answer: There should be only one sheet in view stack, so just move it out of ForEach, like below
struct CarScrollView: View {

    @Environment(\.managedObjectContext) var moc
    @FetchRequest(entity: Cars.entity(), sortDescriptors: []) var cars: FetchedResults<Cars>

    @State private var selectedCar: Car? = nil

    var body: some View {
        VStack {
            ScrollView (.vertical, showsIndicators: false) {
                ForEach (cars, id: \.self) { car in

                    Text("\(car.text!)")
                        .onTapGesture {
                            self.selectedCar = car
                    }
                }
            }
        }
        .sheet(item: self.$selectedCar) { car in
             CarDetail(id: car.id, text: car.text)
        }

    }
}

Comment: @anton, just add empty `extension Car: Identifiable {}`, because Car already has id.
Comment: Thanks for the input, Asperi! However it gives me an error "Instance method 'sheet(item:onDismiss:content:)' requires that 'Cars' conform to 'Identifiable'". Any thoughts how to fix this?
Comment: What if I want to pass a binding to CarDetail?

Can’t pass data correctly to modal presentation using ForEach and CoreData in SwiftUI


Convert SQL to active record in CodeIgniter

Question: <code>SELECT *, SUM(`Relaxation_rating` + `Food_rating`) AS Ratings
GROUP BY CODE
ORDER BY Ratings DESC
FROM destinations
</code>
How do I convert this sql code to CctiveRecord in CodeIgniter?
I tried the following methods, but it did show any results.
<code>$this->db->select("'(SELECT *, SUM(Relaxation_rating + Food_rating) FROM database GROUP BY CODE') AS Ratings", FALSE);
$this->db->get("database");
</code>
Comment: Your rewritten query is TOTALLY broken. You've got mismatched `'(` and `')` pairs, you're aliasing in the wrong place, blah blah blah.
Comment: The [CodeIgniter user guide](http://ellislab.com/codeigniter/user-guide/database/active_record.html) is pretty good. Try to use it.
Comment: http://ellislab.com/codeigniter/user-guide/database/active_record.html look at select, select_sum
Comment: The user of `$this->db-select` and `$this->db->get` doesn't make any sense either. Please read the user guide carefully.
Answer: Try:
<code>$data = $this->db->select('*, SUM(`Relaxation_rating` + `Food_rating`) AS Ratings', false)->group_by('CODE')->order_by('Ratings', 'desc')->get('destinations')->result_array();
</code>
Or,
<code>$this->db->select('*, SUM(`Relaxation_rating` + `Food_rating`) AS Ratings', false)->group_by('CODE')->order_by('Ratings', 'desc')->get('destinations')->result();
</code>
Answer: Try like
<code>$this->db->select('*, SUM(`Relaxation_rating` + `Food_rating`) AS Ratings');
$this->db->from('destinations');
$this->db->group_by('CODE');
$this->db->order_by('Ratings','desc');
$result = $this->db->get();
</code>


PHP file download with no changes to the file

Question: I am trying to make a file download by using PHP but the file downloaded is a clean mp3 file without tags/metadata and not the one that is on my server.
Here's a detailed explanation:
I have a mp3 file with saved ID3 tags and all information on my server.
I run this code to start the download:
header('Content-Type: application/mp3');
header('Content-Disposition: attachment; filename="file.mp3"');
header('Pragma: no-cache');
readfile("file.mp3");

This starts a file download, but the file that is downloaded loses all its meta data, including any info and album art. Is there a way around this?
For example opening the file url and right clicking -> Save As, downloads it and preserves all the information stored in the file.
How can I prevent the deletion of all the metadata? Thanks for your help
Answer: Just add these two lines:
ob_end_clean();

flush();

readfile("file.mp3");

Comment: How would that differ from what the OP has in their question?


Modifications in the Schwarz-Christoffel formula

Question: I am reading Ahlfors's Complex Analysis book, chapter $6.2.2$; The Schwarz-Christoffel Formula, and I have some questions in the exercises.
Firstly, the Schwarz-Christoffel formula is given as follows:

Theorem. The functions $z=F(w)$ which map the unit disk $|w|<1$ conformally onto polygons with (interior) angles $\alpha_k \pi$ ($k=1,...,n; 0<\alpha_k<2$) are of the form $F(w)=C \int _0 ^w (w-w_1)^{-\beta_1}...(w-w_n)^{-\beta_n} dw +C'$, where $\beta_k=1-\alpha_k$, the $w_k$ are points on the unit circle, and $C,C'$ are constants.
$(1)$ Show that the $\beta_k$ may be allowed to be $-1$. What is the geometric interpretation?
$(2)$ If the vertex of the polygon is allowed to be at $\infty$, what modification does the formula undergo? If in this context $\beta_k=1$, what is the polygon like?

In $(1)$, if the $\beta_k=-1$, then what do I have to justify? Also, if $\beta_k=1$ then $\alpha_k=2$ so the polygon would have a slit; is this the desired geometric interpretation?
Next, in $(2)$, I don't have any idea of modification. If $\beta_k=1$ in this case, then I see that the polygon would be a half-plane. Am I right?
I am having a hard time with these. Any help will be appreciated. Thanks!
Answer: You're correct about the first question. The formula still works for $\alpha_k = 2 \pi$ and gives two fully or partially overlapping segments as part of the boundary.
If $\alpha_k \leq 0$, then $w_k$ is mapped to $\infty$ since $(w - w_k)^{\alpha_k/\pi - 1}$ is a non-integrable singularity. If the angle between two lines at $\infty$ is defined as minus the angle at their finite intersection point, the formula also works for polygons with a vertex (or several vertices) at $\infty$.
Since we have to distinguish between inner and outer angles, the angle at $\infty$ for parallel rays (a $\Pi$-shaped boundary) is either $0$ or $-2 \pi$. The angle at $\infty$ for antiparallel rays (a $Z$-shaped boundary) is $-\pi$.
All this is exactly the same for the mapping from the upper half-plane to a polygon, but in that case we can eliminate one of the factors by choosing $w_k = \infty$.


"Nice" metric on $\Bbb RP^3\#\Bbb RP^3$

Question: Is there a standard riemannian metric on $\Bbb RP^3\#\Bbb RP^3$, in view of geometrization conjecture? It is known that $\Bbb RP^3\#\Bbb RP^3$ has $S^2\times S^1$ as a double cover, so its universal cover is $S^2\times \Bbb R$. In this view, what would be a nice metric on this space?
Answer: The involution $\iota: S^2 \times S^1 \to S^2 \times S^1$ given by $\iota(v,z) = (-v, \overline z)$, the first component the antipodal map and the second component complex conjugation, is an oriented isometry, and so the standard metric on $S^2 \times S^1$ descends to the quotient.
Now prove the quotient is diffeomorphism to the connected sum of two projective 3-spaces. (Hint: consider the fundamental domain given by $S^2 \times I$, where $I$ is the north hemisphere of the unit circle.)

"Nice" metric on $\Bbb RP^3\#\Bbb RP^3$


Comparison power series

Question: I have a doubt concerning concerning power series comparison.
There are two power series $f$ and $g$ with the coefficients $(a_i)_{i \in \mathbb{N}}$ and $(b_i)_{i \in \mathbb{N}}$. That is saying :
$$f(t) = \sum_{i=0}^\infty a_i t^i$$
and same thing for $g$ with the $b_i$. We know that both $f$ and $g$ are greater than $0$ on $\mathbb{R}_+$.
Can we say that if $ \forall i, |a_i| > |b_i|$,so we have $\forall t > 0, f(t) > g(t)$ ?
Could anyone answer this question by a reference or a proof ?
If it is not true, what conditions let this sentence be checked ?
Thank you in advance !
Answer: No that's not enough. Consider the power series $\sum_{i = 0}^\infty (-1)^i\frac{2^i}{i!} t^i$ and $\sum_{i = 0}^\infty \frac{1}{i!} t^i$ of $e^{-2t}$ and $e^t$. Obviously $|(-1)^i\frac{2^i}{i!}| = \frac{2^i}{i!} > \frac{1}{i!} = |\frac{1}{i!}|$ but $e^{-2t} < e^t$ for all $t > 0$.
Comment: Thank you very much ! So how can we strengthen the hypothesis on the coefficient so that the inquality is verified ?
Comment: @Gaetano Just omit the absolute values around the coefficients: $a_i > b_i$.
Comment: Thank you ayeayemaung, however, I want to compare to series expansion with information on the absolute value of the coefficients...
Comment: @Gaetano that's probably not possible based on absolute values alone; you need some information about the sign of the coefficients too
Comment: Ok, I can say that we have $|a_k|>|b_k|$ for all $k$ and $sign(a_k) = sign(b_k)$ for all $k$ too. Can We conclude from that ?  @ayeayemaung
Comment: @Gaetano even that is not enough; in my above example I could have used $e^{-t} = \sum_{i = 0}^\infty (-1)^i \frac{1}{i!}t^i$ for $g(t)$ to make the signs of the two series match

Comparison power series


Oracle APEX 4.2 Charts Custom XML IF ELSE IF Not Working

Question: I  defined cdata format of oracle apex bar chart tooltip value based on IF ELSE IF but no text shown in tooltip , tooltip apears without text

XML Code I am specifying is :
<code>   <tooltip_settings enabled="true">
    <IF>
        <Condition %SeriesName="Last_YR_CUR_MON_TD?">
            <format><![CDATA[{%Name}{enabled:False} - {%Value}{numDecimals:0,decimalSeparator:.,thousandsSeparator:\,} (&P4_LAST_YR_CUR_MON_ALIAS.)]]></format>
        </Condition>
    </IF>
    <ELSE>

            <format><![CDATA[{%Name}{enabled:False} - {%Value}{numDecimals:0,decimalSeparator:.,thousandsSeparator:\,} (&P4_CUR_YR_CUR_MON_ALIAS.)]]></format>

    </ELSE>
 </tooltip_settings>
</code>
Is there syntax problem of IF ELSE IF?
What is the syntax of IF ELSE IF Condition in XML?
Answer: Try it like this.
<code><IF something>
    <some actions>
<THEN something>
    <some actions>
</THEN>
<ELSE something>
    <some actions>
</ELSE>
</IF>
</code>


Moving keys out of std::map<> &&

Question: I'd like to have let's say getKeys() function getting not-copiable keys out of a map:
class MyObj {
  // ... complex, abstract class...
};

struct Comparator { bool operator()(std::unique_ptr<MyObj> const &a, std::unique_ptr<MyObj> const &b); };

std::vector<std::unique_ptr<MyObj>> getKeys(std::map<std::unique_ptr<MyObj>, int, Comparator> &&map) {
  std::vector<std::unique_ptr<MyObj>> res;
  for (auto &it : map) {
    res.push_back(std::move(it.first));
  }
  return res;
}

But it is not working because the key in it (.first) is const. Any tips how to solve it? Note: In our environment I'm not allowed to use C++17 function std::map::extract().
Is it somehow ok to use const_cast because map will be destructed anyway?
res.push_back(std::move(const_cast<std::unique_ptr<MyObj> &>(it.first)));

I want to avoid cloning MyObj.
I know why keys of a std::map container cannot be modified but is it still disallowed for a map that is going to be destructed immediately after the key modification?
Comment: Can you switch from `std::unique_ptr` to `std::shared_ptr`?
Comment: Please see below the answer to myself how I workarounded the issue.
Answer: Yes, it's still disallowed. Non-const access to keys is probably safe if you're just going to destroy the map afterwards, but it's not guaranteed to be safe by the standard, and the std::map interface doesn't offer any sort of relaxation of the rules which applies to rvalue references.
What std::map does have since C++17, though, is extract(), which rips a key-value pair out of the map entirely and returns it as a "node handle". This node handle provides non-const access to the key. So if you were to move the pointer out of that node handle, the eventual destruction would happen to an empty pointer.
Example:
#include <utility>
#include <memory>
#include <vector>
#include <map>

template <typename K, typename V>
std::vector<K> extractKeys(std::map<K, V> && map)
{
    std::vector<K> res;
    while(!map.empty())
    {
        auto handle = map.extract(map.begin());
        res.emplace_back(std::move(handle.key()));
    }
    return std::move(res);
}

int main()
{
    std::map<std::unique_ptr<int>, int> map;
    map.emplace(std::make_pair(std::make_unique<int>(3), 4));

    auto vec = extractKeys(std::move(map));

    return *vec[0];
}

Comment: Have you noticed that OP is not allowed to use C++17? It seems to me that he/she is aware of `std::map::extract`, just can't use it. The second part of your answer seems completely superfluous to me, including the whole code. (Also note that your `extractKeys` function will accept only `map`s with default both comparator and allocator template arguments, which is not OP's case.)
Comment: Removing key after key likely results in quite a number of tree-rebalancing. Still this seems to be the only fully legal way go get the keys out again...
Comment: @Aconcagua Agreed. I think in this circumstance I'd probably use a combination of `const_cast` and hoping for the best. :-D
Comment: Nope, I missed that bit of the OP's message (but remember that SO answers are meant to be widely applicable, not just applicable to the original questioner). The code is intended to illustrate the technique, not to be used unmodified.
Comment: They're supposed to be applicable to the question though
Answer:
Note: In our environment I'm not allowed to use C++17 function std::map::extract().

Shame - it was introduced to solve this problem.

Is it somehow ok to use const_cast because map will be destructed anyway?

No.

I want to avoid cloning MyObj.

Sorry; you'll need to clone the keys at least.

I know why keys of a std::map container cannot be modified but is it still disallowed for a map that is going to be destructed immediately after the key modification?

Yes.
The map's internal machinery has no way of knowing that its destiny awaits.
Comment: As for the `const_cast`: [Any attempt to modify a const object during its lifetime results in undefined behavior.](http://eel.is/c++draft/dcl.type.cv#4.sentence-1).
Answer: Answers persuaded me that I should avoid const_cast-ing. After some analysis I realized that usage of my map is quite isolated in the code so I could do a small refactor to avoid the const-issue.
Here is the result:
class MyObj {
  // ... complex, abstract class...
};

struct Comparator { bool operator()(MyObj const *a, MyObj const *b); };

// key is a pointer only, value holds the key object and the effective "value"
struct KeyAndVal { std::unique_ptr<MyObj> key; int val; };
using MyMap = std::map<MyObj *, KeyAndVal, Comparator>;

// Example how emplace should be done
auto myEmplace(MyMap &map, std::unique_ptr<MyObj> key, int val) {
  auto *keyRef = key.get();  // to avoid .get() and move in one expr below
  return map.emplace(keyRef, KeyAndVal{ std::move(key), val });
}

std::vector<std::unique_ptr<MyObj>> getKeys(MyMap map) {
  std::vector<std::unique_ptr<MyObj>> res;
  for (auto &it : map) {
    res.push_back(std::move(it.second.key));
  }
  // here 'map' is destroyed but key references are still valid
  // (moved into return value).
  return res;
}

Moving keys out of std::map<> &&


Longitudinal study - generalised linear mixed model - dealing with very wide confidence intervals due to sparsity in the outcome

Question: I am conducting a treatment evaluation using administrative data. It is a population-based study of all people diagnosed with a specific disorder in two calendar years (N = 2300). I have run a GLMM using the glmmTMB package in R using the following code:
glmmTMB(y ~ T*P*IG + offset(log(exposure)) + (1 | id),
weights = wts,
data = df,
family = poisson)

where T is a numeric variable denoting the time in months (0-41), P is a binary variable defining the pre- / post-intervention periods, IG is a binary variable denoting the intervention (comparison) group, and exposure is the number of days at risk per month.
The confidence intervals for the RR returned for P*IG are very wide (e.g., 0.02 - 1300), presumably because the outcome (an adverse event) is rare. Less than 2% of all patients experienced an adverse event at any time point, and the vast majority of the observations have zero events.
While I have come across a number of sources citing potential reasons for such wide confidence intervals, there seems to be relatively little guidance on how to deal with them. If I am incorrect in this statement, forgive my ignorance. If there is some truth to it, what are some potential remedies or alternative approaches to modelling such data?
Comment: I suspect the answer is collect more data unwelcome though that must be. If it is administrative data it may be impossible anyway. I assume you are including T as continuous rather than a factor.
Comment: @mdewey Unfortunately, I don't think more data will resolve the problem. I think the outcome is just quite rare in this population. T is continuous (0-41 months). I have edited my post to reflect this.
Comment: @C_H more data with more events of interest would mitigate the problem. Having 1 million observations with a total of 2000 occurrences is absolutely better than 2000 with 40 occurrences of interest. (Disregarding feasibility...)
Comment: @mdewey My apologies. Beyond "small" samples, I thought the issue with sparsity was simply that the ratio of occurrences : non-occurrences is too low. Assuming the manual collection of more data is not feasible, is some kind of simulation process based on the parameters of this dataset a viable option? Or is this just wrong?
Answer: Just to bring together information from comments here.
The issue is partly the sparsity of the data and partly the sample size (in terms of events, there are zillions of non-events). In such situations there is not much one can do if the option of collecting more data is closed off. One possible way of extracting at least something is to use a less complex model either by removing the three way interaction or even all the interactions apart from the one of scientific/clinical interest (I*PG). Whether that would be acceptable is moving beyond the limits of statistics to encompass scientific/clinical concerns.


the solution of ode can be encoded as first order logic

Question: Consider the following sytem of ODEs
$\dot{x}= Ax$, and given $x(0)$,
where $A$ is a $n\times n$ matrix with rational entries.
Can I encode the solution, say $x(t)$ for a given $t$, as a first order logic formula over
$(R, +, \cdot, e^x, 0, 1)$?
Here, let us assume that $x(t)$ has real entries.
The difficulty I can see is that some eigenvalue of A is an algebraic number, so the solution invloes some sin and cosin. I do not know how to overcome this.
Thanks.
Comment: Here(http://en.wikipedia.org/wiki/Differential_algebra) but nothing elsea is a link to the Wikipedia page for differential algebra. I recalled the existence but nothing else of this field. Perhaps it will help.
Answer: Partial answer. This seems to be equivalent to asking whether you chosen language can express the notion "$n$ is an integer".
First, if you can express solutions to linear ODEs, then an "integer" is a number $t$ such that $\sin(\pi t)=0$, and $(\sin,\cos)$ are solutions to a well-known ODE system of the kind you're considering.
On the other hand, if we can express integerness and also have $\cdot$ and $+$, then every computable function can be expressed (using Gödel's $\beta$ function to encode primitive recursion and building up from there). And then we can just program a numerical simulation of the ODE and write down a first-order-formula for "the limit of the output of the simulation as the step size tends to 0".
So can integers be recognized by $(\mathbb R, {+}, {\cdot}, \exp, 0, 1)$? Beats me. It's not obviously possible, but on the other hand the real exponential function is closely enough related to the complex one that I won't rule it out either.
Comment: As an example of something that almost but not quite works: $a\in\mathbb R$ is a nonnegative integer iff every higher derivative of $x\mapsto e^{a\cdot \log x}$ is bounded on $(0,1)$. Unfortunately, "every higher derivative" is hard to express without already having integers in the first place.


How to exclude taxes from total prices but still show the tax during checkout

Question: So I create a tax type Custom and set the rate 18%. The checkbox Display taxes of this type inclusive in product prices. comes in checked by default. If I leave it like that, cart shows product price as tax added and still displays tax line. If I uncheck it, cart shows product price as is but it hides the tax line. What I want is the combination of the two; I don't want to include the tax in the total price but I still want to display the tax in the cart. How can I achieve this?
Answer: This patch works beautifully for me, with both Display taxes of this type inclusive in product prices. under tax types and Prices are entered with taxes included. under store unchecked.


Move rows to another sheet based on a cell criteria not working

Question: I am trying to write a vba code to move the entire row to another existing sheet in the next available sheet for one and multiple criteria's. The file that I am working on is exported from an application and hence has unprintable data. I first trim and clean the range and then run the code. I have 3 problems as of now:

The below code that I used to move entire to another sheet based on the value of in column BY which should be blank, then all the lines which has AG has blank was moving from ACCF main sheet to Accounts Missing Info sheet. I had lot of pre and post action macros within the same workbook. I had to change the order of the macros and pos that the below code stopped working. I tried to debug, and there is no error as well.
2.I also have another code to move entire row from ACCF main sheet to next available column row in Accounts Missing Info sheet with 2 criteria's. Column F to be "JNTN" and column M to be blank. This was also working fine until I reordered the macros. I have tried many other codes but nothing works.

Third problem is, I am using the same code used in point 2 to include a date. I want all rows with criteria 1 = col F to be "TRST" and criteria 2 to be col Z( which is a date) to be opened before jan 5th 2012. I don't know how to incorporate the date.

I know the best method to use is Autofilter method to filter data and move to another sheet in the next available column. I googled and checked videos but none of them work.
Please help me. One code to use for all the above will be good. Where I can change one to two criteria as per the requirement.
Code 1
Sub missingphone()

a = worksheets("ACCF Main").cells(rows.count,1).End(xlup).row
For i = 2 to a
    If worksheets("ACCF Main").cells(i,77).Value= "" then

        Worksheets("ACCF Main").rows.copy
        Worksheets("Accounts missing info").Activate
        b = worksheets("Accounts missing info").cells(rows.count,1).end(xlup).row
        Worksheets("accounts missing info").cells(b+1,1).select
        ActiveSheet.paste
        Worksheets("accf main").Activate

   End if

Next

Thisworkbook.worksheets("accf main").cells(1,1).select

End sub

Code 2
Sub marriedjoint()

a = worksheets("ACCF Main").cells(rows.count,1).end(xlup).row
For i=2 to a
    If worksheets("ACCF Main").cells(i,5).Value= "JNTN" And cells(i,13).value="" then

    Worksheets("ACCF Main").rows.copy
    Worksheets("Accounts missing info").Activate
    b = worksheets("Accounts missing info").cells(rows.count,1).end(xlup).row
    Worksheets("accounts missing info").cells(b+1,1).select
   Activesheet.paste
   Worksheets("accf main").Activate

   End if

    Next

    Thisworkbook.worksheets("accf main").cells(1,1).select

    End sub

Comment: in your code1 and code2, I think you should write `Sheets("ACCF Main").Rows(i).copy` instead of `Worksheets("ACCF Main").rows.copy`
Comment: Still doesn't work. The column in range should be trimmed and cleaned which is taking a long time.
Answer: If i understand you correctly about your code-1 and code-2 :
Sub test()
Dim sh1 As Worksheet: Dim sh2 As Worksheet
Dim rg As Range: Dim cell As Range: Dim rgJNTN As Range

'set the needed sheet as variable sh1 and sh2
Set sh1 = Sheets("ACCF Main")
Set sh2 = Sheets("Accounts missing info")

'set the range of data in column A of sh1
Set rg = sh1.Range("A2", sh1.Range("A" & Rows.Count).End(xlUp))

    'looped to each blank cell in column BY (column 77)
    For Each cell In rg.Offset(0, 76).SpecialCells(xlCellTypeBlanks)
        'copy the entire row of the looped cell into sh2 blank row
        cell.EntireRow.Copy Destination:=sh2.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    Next

    'get the range cells which value is "JNTN" in column E sh1 as rgJNTN variable
    With rg.Offset(0, 4)
        .Replace "JNTN", True, xlWhole, , False, , False, False
        Set rgJNTN = .SpecialCells(xlConstants, xlLogical)
        .Replace True, "JNTN", xlWhole, , False, , False, False
    End With

    'loop to each cell (which value is "JNTN") in rgJNTN
    For Each cell In rgJNTN
        'if the looped cell.Offset(0,8) value = "" (column M or column 13, looped cell row)
        'and if the looped cell.offset(0,72) value <> "" (column BY or column 77, looped cell row)
        'then copy the entire row of the looped cell to sh2 blank row
        If cell.Offset(0, 8) = "" And cell.Offset(0, 72).Value <> "" Then cell.EntireRow.Copy Destination:=sh2.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    Next

End Sub

Not tested in my side.
Comment: Thank you very much for the code. The criteria in code 1 and 2 are different. I have 70 types of accounts and 70 different criterias. If I create 70 codes its going to take a long time to run. Instead I would like to include all criteria's  in the same code if possible but keep them independent.

I'm getting an error at "for each cell in rg.offset … ". I only see the yellow line. Not sure what it is for. Is there a way I can run this without having to trim and clean the range in question. Any way to include in autofilter method. Any suggestion will be helpful and greatly appreciated
Comment: Sorry, I thought the criteria to check is just the one I see in your code but it turned there are more than 60 criterias beside : `If worksheets("ACCF Main").cells(i,77).Value= ""` and `If worksheets("ACCF Main").cells(i,5).Value= "JNTN" And cells(i,13).value=""`. This is only two criteria.
Comment: You wrote : _Not sure what it is for_ . To know it, you can test it by first adding a line to select/activate the sheet and/or the range. For example `sh1.activate:sh2.activate` after `Set sh1 = Sheets("ACCF Main")
Set sh2 = Sheets("Accounts missing info")`. Or `sh1.activate:rg.select` after `Set rg = sh1.Range("A2", sh1.Range("A" & Rows.Count).End(xlUp))` , then step run the sub. And also try to see what happen on the sheet after you add a line something like `rg.offset(0,76).select` after activating sh1. And see what happen if you add `rg.Offset(0, 76).SpecialCells(xlCellTypeBlanks).select`


Why does adding a time index variable help with a trend in errors?

Question: I was reading through this example of a regression model fit to beer sales data link. After the log transformations on the data (which make sense how they correct for the compoundingly larger variance on one end of the range vs the other) they comment near the bottom that the one thing remaining is a "linear trend in the errors" and some auto-correlation. They mention that adding a time index addresses this but I'm not sure I understood how. If sales tend to increase as the year progresses then it would make sense to add a time index to capture that but in here at the bottom it's more of an increase through the summer followed by a decrease - which is nonlinear - how did adding the time index fix both the uptrend and the downtrend in one go? Any references for this 'time index technique' I can further read about?
For reference the "final model" was:
$$\log(S_{18}) = b_0 + b_1 \log(P_{18}) + b_2 \log(P_{12}) + b_3 \log(P_{30}) + b_4 W + \epsilon$$
Where $S_{18}$ is sales of 18-packs of beer, and the $P$'s represent log prices of $12$,$18$, and $30$ packs (the $12$ and $30$ are substitution goods for cross price elasticity effects). Then the "reduction of the linear trend in errors" comes about by adding $W$ which is simply what week of the year $1-52$ we are in.
Comment: Could you write out the model? I think that would help a lot. In particular, is this 'time index' a single 'time' variable, or is there a free parameter for each interval?
Comment: Added, it's the week of the year, I believe there was an observation recorded for each week of the year in the original data
Answer: Here's what I see going on:
First of all, the plot at the very bottom isn't of the data that's being analyzed. It says it's of a "much larger sample of stores." For whatever reason, the sample you have may not display all the same patterns. In fact, the link does make the claim that there is "no evidence of seasonality" in the data that is analyzed (although I'll come back to that, since I don't agree).
The reason it appears to be helpful to add the 'time index' can be seen in the third plot on the page. There, you can see the errors (more or less) only increase, over the course of the year. So they add a variable that also increases (time) to deal with it. Keep in mind this is different from sales going up, then down -- they're only talking about the amount by which they mis-predict.
In other words, to get rid of a trend of increasing error (not increasing in terms of absolute value, but increasing in a simple numeric way), the author simply adds a random increasing variable to 'explain' that portion of the error they couldn't get before. That's why it "works."
I put that in quotation marks of course because in the data itself, there doesn't seem to be a linear time trend at all, and the new variable appears to work more for numeric reasons than truly explanatory ones (isn't really a good fit). It looks much more like there is A time-based trend, but it's exactly the one in the bottom plot -- spikes around major drinking holidays, with the biggest one in the summer. Some differences, yes, and no subtle hump, like in the bottom -- but, first, it's different data, and second, that's a much better approximation to what I see than anything linear that their simple W gets at.
To properly include time, I would have 'holiday' indicators for each week with one of the known drinking peaks, and see how that works. Otherwise, I really don't like their model at all.
Comment: To add on your answer, adding a time trend does not increase the economic interpretation: it simply is that an monotonically increasing vector captures part of the variation. But how do we intepret that ? That is a question that is not addressed here.

In essence, it is simply detrending the data prior to analysis.


Rewriting a piece of C code without conditional statements or operators?

Question: I was in a technical interview where the interviewer gave me a piece of code like this
  int a=1;
  a++;
  ...something..
  ...something.
  if(a==25)
   a=0;

he said me to rewrite this code without using switch,if else or ternary operator for the if condition. How it can be done?
Comment: Was `a` indeterminate like you've posted or was it initialized to something?
Comment: I am pretty sure the correct answer here is this cannot be done. Since `a` has an indeterminate value there is no way to write an equivalent statement. Or more precisely, `int a=` is equally likely to produce the same results.
Answer: It's quite simple actually:
a *= (a != 25);

This will multiply a by 0 if a is equal to 25, else it will multiply a by 1.
If you're also not allowed to test for equality then here is a fully arithmetic way:
unsigned int v = a - 25;

/* test for bits set and put result in lsb of v */
v |= v >> 16;
v |= v >> 8;
v |= v >> 4;
v |= v >> 2;
v |= v >> 1;

/* set a to a if lsb of v is 1, else set to 0 */
a *= v & 1;

Comment: Well, on some [old] platforms the evaluation of `a != 25` might require branching, but this is not what the original question is about.
Comment: +1 and yes it does answer the question; I'm just curious, underneath wouldn't it still have a branch? I'd say the syntax in the question is more readable.
Comment: @legends2k No, a branch occurs when there is multiple code pathways, this only has one (first a test, then a multiply). This does not include compiler optimizations of course, that could potentially decide that a branch is faster.
Comment: @AndreyT I added a version that should be branchless on any machine. Never said it was fast though.
Answer: a != 25 || (a = 0);

This does not use "switch,if else or ternary operator"
Answer: The question, as posed, gives undefined behaviour since you are using an uninitialised variable. Therefore you are free to write any code you like (so long as it compiles).
See C standard 126.96.36.199p2:

If the lvalue designates an object of automatic storage duration that
  could have been declared with the register storage class (never had
  its address taken), and that object is uninitialized (not declared
  with an initializer and no assignment to it has been performed prior
  to use), the behavior is undefined.

That, in my opinion, is the smart answer: although you would be wise to be graceful when answering a question in this way.
Comment: @Zaibis: Sure, but how do you re-write something that could have any outcome? If I saw this kind of question on an interview, that would be the first thing that I would think of - they want you to waste time analyzing the solution to a problem that is unsolvable. There are a lot of these kinds of questions on the GRE quantitative section, and if you do not learn to analyze them properly you will never score competitively. In an interview, the employer is judging your analytic skills - if I were the interviewer, I would never hire someone who didn't point out that `a` is uninitialized.
Comment: and in addition the question was how to rewrite it, not even that it has to be compilable so -1
Comment: dude? where do you get it from that int isnt static storage class type?
Comment: Note that the question was changed in the meantime to initialize the variable *a*!
Answer: Remember that assignment is just an ordinary expression, and as such can be used as part of another expression. For example you could use the short-circuit logical and operator:
a == 25 && (a = 0);

You need to put parenthesis around the assignment because assignment has lower precedence than the && operator.
Answer: Another interesting answer could be
for ( ; a == 25 ; ) {
    a = 0; break;
}

This does not use 'if-else', 'switch' or 'ternary operator'
Comment: I had a similar thought, but with while instead of for
Answer: If the context implied is a counting loop where a always repeats the cycle 0..24, then perhaps a mathematically more appealing solution would be
a = (a+1) % 25;

But this of course wouldn't work in a sitation where a can be anything, and it should only be reset in case of a==25, while something a==26 should be left alone.
The interviewers might like it though, if you search for a "semantic" solution like that, and can explain when to use this.
Answer: I think interviewer wanted you to use this line instead of if:
a %= 25;

Comment: That's not equivalent. If a is 26, this will set it to 1.
Comment: It depends on context - I think in this context it is implicitly assumed in question that `a` keeps always increasing starting from 0. If I were an interviewer, I would be happy with such an answer.


Calculating Kurtosis for Groups Containing Fewer Than 4 Observations

Question: Based on some preliminary exploration, here are some interesting observations about kurtosis for when you're calculating kurtosis for groups that have fewer than 4 observations. First, here's the relevant R code.
One_Observation_Groups <- list(1, 3, -100, 0, 1000)
sapply(One_Observation_Groups, function (x) {
  y <- sum(((x - mean(x)) / sd(x)) ^ 4)
})
# [1] NA NA NA NA NA

Two_Observation_Groups <- list(c(1, 2), c(4, 4), c(10, 100), c(-1, 20), c(-1000, 0))
sapply(Two_Observation_Groups, function (x) {
  y <- sum(((x - mean(x)) / sd(x)) ^ 4)
})
# [1] 0.5 NaN 0.5 0.5 0.5

Three_Observation_Groups <- list(c(1, 2, 3), c(4, 4, 9), c(10, 100, 1000), c(-1, 1, 20), c(-1000, 0, 25))
sapply(Three_Observation_Groups, function (x) {
  y <- sum(((x - mean(x)) / sd(x)) ^ 4)
})
# [1] 2 2 2 2 2

Four_Observation_Groups <- list(c(1, 2, 3, 4), c(4, 4, 9, 4), c(10, 100, 1000, 10000), c(-1, 1, 20, -1000), c(-1000, 0, 25, 1000))
sapply(Four_Observation_Groups, function (x) {
  y <- sum(((x - mean(x)) / sd(x)) ^ 4)
})
# [1] 3.690000 5.250000 5.195882 5.247908 4.498946

It's obvious to me why kurtosis is undefined for one observation - the standard deviation is 0 for groups containing only one observation, and the kurtosis formula requires a division by the standard deviation. This reasoning holds for groups containing more than one observation of the standard deviation is 0 - kurtosis will be undefined or these groups as well.
It's not obvious to me why, as long as the standard deviation is nonzero, kurtosis is always 0.5 for groups consisting of 2 observations and 2 for groups consisting of 3 observations. (For groups containing 4 or more observations, kurtosis is no longer constant.)
Does this pattern appear for other (possibly higher-order) moments as well?
Answer: On general principles, fixing an integral order $k \gt 2,$ we would expect the central standard moment of order $k$ of three or more numbers to vary, because after centering the data and standardizing the moment we have used two of the three algebraic degrees of freedom, so that generally there ought to be an algebraic variety of possible values of dimension at least $3-2 = 1.$
This does not happen with kurtosis due to an algebraic identity.
Background
Standardizing a batch of numbers $(x_1, x_2, \ldots, x_n)$ re-expresses them as
$$z_i = \frac{x_i - m}{s}$$
where
$$m = \frac{1}{n}\sum_{i=1}^n x_i$$
and
$$s^2 = \frac{1}{n}\sum_{i=1}^n (x_i-\bar x)^2.$$
(Note that the sd function in R does not compute $s:$ it returns $s\sqrt{n/(n-1)}.$)
This guarantees that the sum of the $z_i$ is zero and the sum of their squares is $n.$
The standard central moment of order $k$ (for any number $k$) is the average of the $k^\text{th}$ powers of the standardized values,
$$\mu_k(x_1, x_2, \ldots, x_n) = \frac{1}{n}\sum_{i=1}^n z_i^k.$$
Analysis
Let's focus on $n=3$ numbers.  To simplify the notation, let $(x,y,z)$ be a group of three numbers that have been standardized so that $x+y+z=0$ and $x^2+y^2+z^2=3.$  Consequently $z = -(x+y),$ whence
$$3 = x^2+y^2+z^2 = x^2+y^2+(-x-y)^2 = 2(x^2 + xy + y^2).$$
Squaring both sides leads to
$$9 = [2(x^2 + xy + y^2)]^2 = 4(x^4 + y^4 + 2x^3y + 2xy^3 + 3x^2y^2),$$
whence

$$x^4 + y^4 + 2x^3y + 2xy^3 + 3x^2y^2 = \frac{9}{4}.$$

Use this to simplify the fourth central standardized moment:
$$\frac{1}{3}(x^4+y^4+z^4) = \frac{1}{3}(x^4 + y^4 + (-x-y)^4) = \frac{2}{3}(x^4 + y^4 + 2x^3y + 2xy^3 + 3x^2y^2) = \frac{2}{3}\frac{9}{4} = \frac{3}{2}.$$
The sum is three times this, but when you use sd instead of $s$ in the formula, you are dividing by a further factor of $\left(\sqrt{3/2}\right)^4.$  Therefore in your calculations you obtain constant values of
$$\frac{3}{2}\times 3 \div \frac{9}{4} = 2$$
for the sums of the standardized values.

There's nothing so special about the other moments.  With $n=3$ the other $\mu_k$ for $k = 3, 5, 6, 7, \ldots$ are non-constant functions of $y^3-3y.$  With larger $n$ there are just too many degrees of freedom.


Fazer mais de uma condição annotation asp.net mvc

Question: Eu tenho minha classe
e nela tenho uma propriedade
public TipoPessoa TipoPessoa {get;set;}

A mesma é um enumerador que tem valor "Fisica e Juridica"
E tenho uma propriedade que é CNPJ OU CPF
public string Cpf_Cnpj {get;set;}

Como eu faço para ele fazer a condição na hora de validar na anotation?
Answer: Usando um atributo misto de validação. Em outra resposta, ensinei como implementar um atributo que valida CNPJs. O desafio é fazer a mesma validação para o CPF.
Não estou com o código do CPF agora, mas vou editar a questão mais tarde colocando um exemplo de atributo para validação de CPF.


When should falsetto be used for a male voice?

Question: I'm really confused about the concept of a falsetto voice. As I understand it, past a point when I'm singing / talking, something in my vocal chords changes, I lose the "basey" sound of my voice, and with little to no effort, I can produce ridiculously high pitches. I can use this voice to match pitches the Soprano range, and when not singing, it's wonderfully amusing for all manner of squeaks and silly noises.
When should I be utilizing this voice? Usually I sing in the Baritone / Bass range with what I think is my chest voice. I'm not really sure what's happening with my throat that makes the change happen. Is there a way to shape my throat so that the falsetto sounds more like the chest voice, or to hide the transition between the two?
I should point out that I have no formal training, so all of this terminology is very new to me. I'm an intelligent sort though, so feel free to throw science at me. Some of it will stick. :D
Comment: I added "when" to the question since it's entirely up to you whether you "should", but in addition to your question about its sound others may have useful advice about its application.
Comment: I don't understand the question. If it sounds good, use it. If it sounds bad, don't use it. Examples of falsetto in recordings abound - example, Stayin' Alive by the Bee Gees.
Comment: Chest voice -> Head Voice -> Falsetto  and pro singers can actually blend them together (say 1/2 falsetto 1/2 head voice)
Answer: I'll answer the "When should I" of your question simply, and from the experience of someone with a music ed degree, but no formal voice training. I do know the basics of vocal training and education, and have had a little myself. I won't delve into the different physiological differences with the falsetto voice, since that's been awhile… :)
For most male singers, with enough training, they find they have a chest voice, a head voice, and a falsetto. I'm simplifying, but most discover these three ranges. The chest voice is the one you describe, it has a deeper resonance, and you feel many of the vibrations as they are happening. The head voice is a lighter sound and feel… it's tough to describe, but in my opinion it sounds a little closer to the resonance of the falsetto, and the singer's feel of their own vibrations decreases slightly HOWEVER they can feel a difference between that and falsetto.
Most singers will train all three parts of their voice extensively, and extend the ranges of all three, so that they can overlap and make seamless transitions. Falsetto, once strengthened, can be used to extend the range of the head voice when singing lighter repertoire. I've also noticed that strengthening the falsetto improves the chest and head voice. For example I've worked on falsetto enough that I can impersonate an operatic soprano. Not perfectly, by any means, but I can approximate the resonance and tonal qualities of, well, probably more like a mezzo-soprano. By doing this, I improved the resonance and consistency of the lower parts of my voice.
I'm not sure how much you know of the history of western (classical) music, but there used to be men called castrati, who were… modified… before they reached puberty, and so retained the high voices of boys, but the size and breathing capacity of full-grown men. After this process was finally abolished, some men became falsettists, or countertenors, often singing roles created for castrati. These men are just like you and I, except they choose to work and strengthen their falsetto rather than their chest and head voice. The point I'm trying to make is that these men are usually baritones, as something with the baritone voice usually results in a higher, richer falsetto.
So, depending on what your goals as a singer are… strengthen and work on your falsetto, if not to use it, at least to improve the lower ranges of your voice. I would NOT "shape" your throat in any abnormal way to modify the tone of your falsetto. Consult a voice teacher, at least for a lesson a month to keep you on track, and be up front with them about what you want to accomplish. The goal as a singer is to be stress-free; singing should be as effortless as talking.
However, for now, you can use the falsetto as an embellishment in songs you sing, use it to more easily reach higher pitches you can't sing in your chest voice, or just sing with the sopranos all the time. :)
If you listen to any musical theater music, there are good examples of use of falsetto. It's often used to dramatize a single outlier note, or even during a soft passage, to further soften the tone.
If you listen to folk music, it pops up now and then in there, sort of as an extension of the voice, but sparingly used to change the character.
However you'll most likely find that you will be unsure of what's falsetto and what's head voice when you listen to a softer song, especially in the musical theatre or classical realms. THIS is good falsetto.
Some people overlook it, and see it as a guy's circus sideshow… but all it really is is another portion of your voice that can be trained and improved just like any other.
Sorry for the overly long and rambling answer; you said you're an intelligent sort, so I threw you everything but the science, which percusse already gave you.
Comment: Adding to your [second to] last paragraph, Matt Bellamy from Muse uses it often (at least 5 songs)
Answer: Simple and straight answer: When you should use regular voice versus falsetto depends on the style of music you are singing. It's appropriate for certain kinds of music, and not for others. Considering that "theory follows practice", listen to some recordings of different kinds of vocal music. Some use falsetto, most don't.
There is a classical music tradition, especially in England, of adult males singing soprano or alto in falsetto. This is called "counter-tenor". Look for recordings by the King's Singers and Chanticleer. These are all-male a capella vocal groups who use men that sing alto and soprano.
In barbershop quartet music, sung by four men, often the first tenor is required to go into the falsetto range to sing the highest harmonies.
Brian Johnson of the hard rock band AC/DC is a natural bass singer, but with AC/DC he only sings falsetto. He never uses his natural range at all.
Lots of rock and pop music uses backing vocals sung by men in falsetto. It's used less often for lead vocals. Most of the vocals you hear in songs by the hard rock band Def Leppard are in falsetto.
The great R&B singer Smokey Robinson is a tenor adept at using head voice and falsetto interchangeably and going from one to the other smoothly so you don't notice the difference. The same might be said for the rock singer Sting, and Robin and Barry Gibb of the Bee Gees, all tenors, although each of these singers has a different style.
Now here's a point: If you take beginning traditional singing lessons, without exception, nobody will teach you to develop your falsetto range. Your lessons will consist of learning to sing in your normal head voice. That's just the way it's done. From the standpoint of teaching and learning, everybody seems to agree that it's best to learn and study singing in your regular range. Falsetto is extra-curricular.
Answer: Suppose an engineer is trying to express his understanding and please let me know if this is sheer nonsense. I tried to gather some info and the following is my take on the falsetto.
Let me use no terminology and try to give a visual answer such that there is no confusion about the terms and you can fill in the technical details (which I should also do later). It involves the natural frequency shift of the vibrating flaps (vocal folds) in your throat.
Roughly speaking, it is a matter of vibrational analysis. Hence here is the classical example from engineering class. Take a ruler and put it against the table as shown here. Now by contracting and releasing your muscles you change the vibration frequency of the ruler which symbolizes your flaps. The longer the ruler the lower the frequency. Well, kinda obvious anyway.
Now let's take this example a little further. (Actually since sound mechanism is unbelievably more complicated, I am committing some crime here) Imagine two rulers are end-by-end attached and the one that is on the free-end side is quite shorter than the clamped one. This means that overtones will be produced since their natural frequencies are different. You can still control the length of the clamped ruler and change the dominating low frequency.
Now what would happen when you start shortening the sticking out part of the ruler ? The frequency would get higher (still with overtones) but unfortunately there will be a point where the clamped ruler won't budge anymore since it would require tremendous strength to vibrate in visible frequencies. This does not bother the second one and it will be dominating the produced vibration at the tip. (Glottal cycle) Here is a more visual example of this. If you skip to 1:55 you will see the falsetto in action. Also later it shows what might happen if you push it too much :)
As far as I know, individuals have no control on their second ruler simply because it is not a muscular extension. (Please start to fill in the science from this point) What you are left with is the free part of your vocal folds and they tend to like a particular frequency.
Comment: Uh, that's really rather wrong.  Both voice types operate through the same vocal folds.  The principal muscle action for controlling chest voice pitch is curdling/stiffening muscles that are sort of the base of the vocal folds.  The principal falsetto action is stretching the vocal folds from their ends.  They are attached to cartiledge from some moving mechanisms moved my muscles.  As the cartiledge hardens with age, it is a bad idea to start powerful singing too early.  At any rate, the different mechanisms are interfering, so using both at once requires a lot of coordination and balance.
Comment: @David I think you misunderstood my example. I don't claim that there are two different types of vocal folds. While the mechanism is simplified a lot the vibrational effect is the same. It doesn't matter from which side it is actuated. It is the moving part that matters and can be superimposed to model the same behavior.
Answer: If you normally prefer to sing in the bass-baritone range, and primarily sing parts written in that range, you will ordinarily need to use falsetto only very rarely. Perhaps there will be a passage written in a very high register (well above the bass clef) where the composer intends for it to be sung softly (piano or softer). Or it may be used to achieve a "sweeter" tone quality, when the song calls for it.
However, the challenge with the falsetto voice is that it is very hard to make it as "vibrant" as the main chest voice, so you'll need to be careful when it gets used. If you're singing in a band or in a large ensemble, a falsetto tone isn't going to be as audible as if you're with just a guitar or piano.
Comment: "Reinforced falsetto" can be rather powerful.  While there is a reduced dynamic range, with practice comes good vocal closure, and the range reduction is more at the lower volumes, making it hard for male altos to work well in a standard choir setting.  It's easier to go soloist.  I had to swap my main self-accompanying instrument from finger-style guitar to accordion when switching my show voice from baritone to alto.Unpractised falsetto tends to have bad vocal closure and a breathy/wheezy and weak quality.  Reinforced falsetto is quite stronger and gets raspy in the low range.
Answer: When Lighting Strikes (Klaus Nomi).  Obviously, when it fits.  If you are not sure in choral or solo settings, it may make sense to make a good quality recording and crosscheck: since falsetto and chest voice have a different configuration of the voice box, they sound more different to the singer than to the audience.  In a group of tenors, a cultivated falsetto tends to stick out less than a forced chest voice: falsetto has quite fewer overtones and thus blends better than the rather marked overtone composition of a forced chest voice, even though "every single one sticks out but me" sounds like a contradiction.
Answer: Use falsetto when it suits the music you're singing.  Or, in extremis, when you need a note outside your normal range and the odd sound of a single falsetto note is preferable to not getting it at all!
A lot of singing technique is about recognising the different registers of your voice and melding them together.


Panel data model with two-way fixed effects and individual-specific slopes

Question: I have the following panel-data model:
$$ y_{it} = \alpha_i + \lambda_t + \beta_i X_{it} + \varepsilon_{it}. $$
It contains individual-specific intercept $\alpha_i$, time-specific intercept $\lambda_t$ and individual-specific slope $\beta_i$ (a vector). $X_{it}$ are exogenous variables.
If I got the panel data terminology right, it would be a fairly standard two-way fixed effects model, if not for the individual-specific slopes.
Questions:

Does this model have a name? If so, how is it called?
Where can I read more about this model and its estimation?
What is a good estimator for the above model if

$y_{i,\cdot}$ is integrated of order 1 (I(1)),
$X_{i,\cdot}$ are I(1),
$y_{i,\cdot}$ are cointegrated across individuals (i.e. across $i$), but
there is no cointegration between $y_{i,\cdot}$ and $X_{i,\cdot}$?

Is the model implemented in R? If not, is it implemented in some other software?

I have found something like this model in Stata's panel data manual, function xtxdpd (see bottom of page 15); but I did not like that source too much.
Edit:
The model does not look good if $y_{i,\cdot}$ is not cointegrated with $X_{i,\cdot}$, because then the regressors diverge from the regressand. So a model in first differences would make more sense.
Answer: Here is one way of estimating $\lambda_t$ and $\beta_i$.
Take the original equation (but consider only one $x_{it}$ in place of a vector $X_{it}$, that will help save some space and typesetting later on)
$$ y_{it} = \alpha_i + \lambda_t + \beta_i x_{it} + \varepsilon_{it} $$
and difference it with respect to time to obtain
$$ \Delta y_{it} = \Delta \lambda_t + \beta_i \Delta x_{it} + \Delta \varepsilon_{it}. $$
If $y_{i,\cdot}$ and $x_{i,\cdot}$ are integrated but not cointegrated, we get a relatively nice representation in terms of their stationary transformations.
Construct a set of dummies corresponding to $\Delta \lambda_t$ and stack the equations to get
$$
\begin{pmatrix}
\Delta y_{11} \\
\Delta y_{12} \\
\vdots \\
\Delta y_{1T} \\
\Delta y_{21} \\
\Delta y_{22} \\
\vdots \\
\Delta y_{2T} \\
\vdots \\
\Delta y_{m1} \\
\Delta y_{m2} \\
\vdots \\
\Delta y_{mT}
\end{pmatrix}
=
\begin{pmatrix}
1 & 0 & \dotsb & 0 & \Delta x_{11} & 0 & \dotsb & 0 \\
0 & 1 & \dotsb & 0 & \Delta x_{12} & 0 & \dotsb & 0 \\
\vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots \\
0 & 0 & \dotsb & 1 & \Delta x_{1T} & 0 & \dotsb & 0 \\
1 & 0 & \dotsb & 0 & 0 & \Delta x_{21} & \dotsb & 0 \\
0 & 1 & \dotsb & 0 & 0 & \Delta x_{22} & \dotsb & 0 \\
\vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots \\
0 & 0 & \dotsb & 1 & 0 & \Delta x_{2T} & \dotsb & 0 \\
\vdots \\
1 & 0 & \dotsb & 0 & 0 & 0 & \dotsb & \Delta x_{m1} \\
0 & 1 & \dotsb & 0 & 0 & 0 & \dotsb & \Delta x_{m2} \\
\vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots \\
0 & 0 & \dotsb & 1 & 0 & 0 & \dotsb & \Delta x_{mT} \\
\end{pmatrix}
\times
\begin{pmatrix}
\Delta\lambda_1 \\
\Delta\lambda_2 \\
\vdots \\
\Delta\lambda_T \\
\beta_1 \\
\beta_2 \\
\vdots \\
\beta_m \\
\end{pmatrix}
+
\begin{pmatrix}
\Delta\varepsilon_{11} \\
\Delta\varepsilon_{12} \\
\vdots \\
\Delta\varepsilon_{1T} \\
\Delta\varepsilon_{21} \\
\Delta\varepsilon_{22} \\
\vdots \\
\Delta\varepsilon_{2T} \\
\vdots \\
\Delta\varepsilon_{m1} \\
\Delta\varepsilon_{m2} \\
\vdots \\
\Delta\varepsilon_{mT}
\end{pmatrix}
$$
(for notational simplicity, I assumed the original observations at time $t=0$ are available).
This is a shape of ordinary linear regression, and the estimator of the coefficient vector is straightforward. I have not given much thought on how good such estimator is, though.


Solve exponenital integral equation

Question: $$\frac{1}{\sqrt{2\pi}\sigma_1 }\int_x^\infty\exp(-\frac {t_1^2-1}{2\sigma_1^2})dt_1 + \frac{1}{\sqrt{2\pi}\sigma_2 }\int_x^\infty\exp(-\frac {t_2^2-1}{2\sigma_2^2})dt_2 = a $$
$$\sigma_1 , \sigma_2 \gt 0$$
Is there a way to solve for $x$ !?
please help
Comment: Explicitely, no. Numerical methods such as Newton will do the job.
Answer: As said in comments and answers, there is no explicit solution to the equation which, after integration write $$f(x)=\frac{1}{2} e^{\frac{1}{2 \sigma_1^2}} \text{erfc}\left(\frac{x}{\sqrt{2} \sigma
   _1}\right)+\frac{1}{2} e^{\frac{1}{2 \sigma_2^2}}
   \text{erfc}\left(\frac{x}{\sqrt{2} \sigma_2}\right)-a=0$$ $$f'(x)=-\frac{e^{\frac{1-x^2}{2 \sigma_2^2}}}{\sqrt{2 \pi } \sigma
   _2}-\frac{e^{\frac{1-x^2}{2 \sigma_1^2}}}{\sqrt{2 \pi }
   \sigma_1}$$ In the case where $x$ would be small, you could use as a very first approximation $$\text{erfc}(y)=1-\frac{2 y}{\sqrt{\pi }}+O\left(y^2\right)$$ and solve one equation for one unknown.
Otherwise, Newton method would be the simplest way to solve the equation.
Comment: Well done! ... +1
Answer: Let $X_i\sim\mathcal N(1,\sigma_i^2)$ be independent for $i=1,2$, then the expression above is
$$\mathbb P(X_1>x) + \mathbb P(X_2>x) = a. $$
After standardizing we find that
$$\Phi\left(\frac{x-1}{\sigma_1}\right) + \Phi\left(\frac{x-1}{\sigma_2}\right)=a, $$
where $\Phi$ is the distribution function of the normal distribution with $\mu=0$, $\sigma^2=1$. In terms of the error function, this is
$$\operatorname{erf}\left(\frac{x-1}{\sqrt 2\sigma_1}\right)+\operatorname{erf}\left(\frac{x-1}{\sqrt 2\sigma_2}\right)=2(1-a). $$
This equation cannot be solved analytically, but can be approximated numerically in many ways.
Comment: Would you please guide me to a good numerical way,
easily applicable in Matlab for example
@Math1000

Solve exponenital integral equation


mapped-name is required for org.apache.cxf.binding.AbstractBaseBindingFactory/bus of deployment

Question: I am using JBoss AS 5.1 with Java 1.6.0_22 and get the following error when I try to deploy my dynamic web project through Eclipse. I am using Apache CXF v2.7.18 and have auto generated .java files through "Generate Java Bean Skeleton" from a wsdl file. What does mapped-name is required for org.apache.cxf.binding.AbstractBaseBindingFactory/bus of deployment mean? I looked on various websites but came to no solution.
java.lang.RuntimeException: mapped-name is required for org.apache.cxf.bus.managers.ConduitInitiatorManagerImpl/bus of deployment MySimulator.war
    at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXmlResourceEnvRefs(WebResourceHandler.java:287)
    at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXml(WebResourceHandler.java:325)
    at org.jboss.web.tomcat.service.TomcatInjectionContainer.processMetadata(TomcatInjectionContainer.java:550)
    at org.jboss.web.tomcat.service.WebCtxLoader.start(WebCtxLoader.java:158)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4272)
    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
    at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
    at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
    at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
    at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
    at $Proxy38.start(Unknown Source)
    at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
    at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
    at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
    at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
    at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
    at org.jboss.system.ServiceController.start(ServiceController.java:460)
    at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
    at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
    at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
    at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
    at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
    at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
    at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
    at org.jboss.profileservice.management.upload.remoting.AbstractDeployHandler.start(AbstractDeployHandler.java:263)
    at org.jboss.profileservice.management.upload.remoting.AbstractDeployHandler.invoke(AbstractDeployHandler.java:177)
    at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:891)
    at org.jboss.remoting.transport.local.LocalClientInvoker.invoke(LocalClientInvoker.java:106)
    at org.jboss.remoting.Client.invoke(Client.java:1724)
    at org.jboss.remoting.Client.invoke(Client.java:629)
    at org.jboss.profileservice.management.upload.remoting.StreamingDeploymentTarget.invoke(StreamingDeploymentTarget.java:305)
    at org.jboss.profileservice.management.upload.remoting.StreamingDeploymentTarget.start(StreamingDeploymentTarget.java:190)
    at org.jboss.profileservice.management.upload.DeploymentProgressImpl.start(DeploymentProgressImpl.java:231)
    at org.jboss.profileservice.management.upload.DeploymentProgressImpl.run(DeploymentProgressImpl.java:88)
    at org.rhq.plugins.jbossas5.util.DeploymentUtils.run(DeploymentUtils.java:120)
    at org.rhq.plugins.jbossas5.util.DeploymentUtils.deployArchive(DeploymentUtils.java:103)
    at org.rhq.plugins.jbossas5.ApplicationServerComponent.createContentBasedResource(ApplicationServerComponent.java:400)
    at org.rhq.plugins.jbossas5.ApplicationServerComponent.createResource(ApplicationServerComponent.java:211)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.rhq.core.pc.inventory.ResourceContainer$ComponentInvocationThread.call(ResourceContainer.java:482)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

Any help would be appreciated as I can't make any sense of it.
Additional Info (Auto generated by Eclipse):
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
          http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
          version="2.5">
    <display-name>Myproject</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    <servlet>
        <description>Apache CXF Endpoint</description>
        <display-name>cxf</display-name>
        <servlet-name>cxf</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>cxf</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/cxf-beans.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>

cxf-beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
    <jaxws:endpoint xmlns:tns="theSchema.xsd" id="myserviceport"
        implementor="myservice.MyservicePortImpl"
        wsdlLocation="WEB-INF/wsdl/myservice.wsdl" endpointName="tns:myservicePort"
        serviceName="tns:myservice" address="/myservicePort">
        <jaxws:features>
            <bean class="org.apache.cxf.feature.LoggingFeature" />
        </jaxws:features>
    </jaxws:endpoint>
</beans>

Answer: Jboss comes prepackaged with cxf libraries. So, you will not need the apache cxf dependency at runtime and should be excluded from the deployment assembly if you go with Jboss CXF integration. You may have to tweak the jboss deployment descriptor to make it all work.
So one way or the other you'll have to decide which one you want to use and change accordingly.
Hopefully all the class loading issues will resolve themselves once you have right set up in place.
Update
After spending some more time,  I realized it's safe to use the jboss cxf integration for web services.
The problem you're running into is jboss trying to inject resources before cxf libraries have a chance.
In your case as you're using jboss 5 version which doesn't come with cxf libraries. So easy way to solve your problem will be to install cxf module in jboss server and then you can exclude the apache cxf binaries from your application deployment.
I gave it quick test locally and it worked fine.
Let me know if you're still looking for solution, I can add more steps on installing cxf module in jboss server.
Comment: Please use these links http://stackoverflow.com/questions/19370879/jboss-start-exception-due-to-apache-cxf and http://stackoverflow.com/questions/6888102/web-service-conflict-among-cxf2-2-4-spring2-5-6-and-jboss-7. These links will help you exclude the jax ws module from jboss so you can use your application cxf libraries.
Comment: Is the web.xml the deployment descriptor or jboss-web.xml? If the latter, I don't have that file. I guess I'll have to make one. Can you give me a guide of some sort on how I should make and tweak it? I'm new to all this so it would help me out tremendously as I do not know what to search for. Thanks for the reply!
Comment: Can you add web.xml and other cxf configuration files to the post ? Are you using spring ?
Comment: I added `web.xml` and `cxf-beans.xml` which were auto generated by Eclipse to the OP. I'll check out those links as well. Thank you!
Comment: I tried many different exclusions and each one just changes the "is required for ..." part. Always a different class saying "mapped-name is required". I'm not sure how to proceed.


Android Emulator ultra slow on Linux

Question: Yet another "slow emulator!" thread, but not quite. Ussualy people are complaining about boot time - for me it doesn't matter and I have snapshot option enabled. The problem with my emulator is that GUI is very unresponsive - by that I mean I have to wait around 3-4 seconds for emulator to register my click on a button for example. Since I don't have a physical device I am forced to work with this emulator.
The device I am emulating is Galaxy Tab 2 10.1, which means WXGA800 and large resolution (800x1280). I've set the device RAM size to 1024.
I am running Linux - if it makes any difference (because of crappy Graphics driver).
So what can I do to make it a bit more responsive? I can live with up to 1sec delay but not more.
Answer: I don't know any good solution for your problem but you can try to use Android on Virtualbox. Here you have site with .iso files:
<code>http://www.android-x86.org/download
</code>
Comment: I would prefer Leandros solution. Still, thanks for participating.
Answer: You can try the new x86 Emulators from Google.

http://android-developers.blogspot.de/2012/04/faster-emulator-with-better-hardware.html
Comment: Open the Android SDK Manager > Browse to 2.3.3 or 4.0.3 > Download x86 Atom System Image.
Comment: This looks really promising. However, how to download? Couldn't find it anywhere officialy.
Answer: Another option is to emulate devices using a Virtual Machine. I did a detailed tutorial (step by step) based in other tutorials:
http://edwindh.blogspot.com/2014/07/emular-uma-tablet-ou-smartphone-com.html

Android Emulator ultra slow on Linux


Why do we need to log transform independent variable in logistic regression

Question: I am curious that since we don't have normality assumption of the independent variable in logistic regression, why do I see people using log transformation for independent variables in logistic regression?
Comment: This has come up before [here](http://stats.stackexchange.com/q/147612/7071). Also, we usually make assumptions about the error terms, not the dependent or independent variables.
Answer: The reason for such transformations have nothing to do with their distribution. Instead, the reason has to do with the functional form of the effect. Say we want to know the effect of the number of publications on the probability of getting tenure. It is reasonable to believe that getting an extra publication when one has only 1 publication has more impact compared with getting an extra publication when one has already published 50 articles. The log transformation is one way to capture such a (testable) assumption of diminishing returns.


When Next Magento Modarator Election?

Question: I want to participate in Election. So can anyone explain whole process. And when This event is organized?
This is every year event or specific time duration event ?
When Modarator Election organized?
Thanks
Comment: this is specific when requested by old mods + community members
Answer: When I was brand new here, I got absolutely thrashed on Meta.SE for suggesting to have annual elections: Changing the Pro Tem moderators every X months/years, When do Pro Tempore Moderators change?.
So it's unlikely to happen annually, as your question suggests.
Elected diamond moderators remain in power forever (I know that sounds so weird!) unless:

they get kicked out due to rule violations (which is extremely rare, and doesn't even happen most of the time when they break rules) or
if all other diamond moderators agree that they should be removed, or
if they resign.

If any of the above three things happens, then a decision will be made about whether or not a replacement is needed, and then usually the community members (like you and me) don't get the chance to decide the election date. Instead it's chosen by SE's community management team, sometimes in consultation with the current diamond moderator team, but not always. If there's extreme backlash from the community about an election date, then the election date might get changed, but it would still be the community management team making the decision.
There's another situation in which an election can happen, and that's if the current team of diamond moderators decides that they want another member. They would then ask the community management team for approval, and then an election would be arranged (but again, you're not likely to know about it).
It might seem like a huge surprise, but elections here are often announced on the same day that they start! This recently happened on Vegetarianism.SE and something similar happened on Chemistry.SE.
If you are like me and think this is all weird, perhaps you might like to support the proposal to get more advance notice about election dates.

When Next Magento Modarator Election?


Optimal string gauge for beginner electric guitar

Question: I'm currently learning guitar and started out with an electric guitar that came pre-strung with .010's. I'm wondering if learning with .009's is much easier to learn chords. Is there a benefit to starting with the .010's?
Also, if I swap the .010 for .009 is it likely that I'll also need to adjust the truss rod? I've read that it's unlikely, but how will I know if I need a rod adjustment after swapping?
Answer: Lost count of the students that I changed strings from .010 to .009 and even .008. But that's not the whole solution. There's the action, which may need tweaking, even (especially) on a new guitar.
If you're struggling with new barre chords, that's a couple of ideas. Another, specially if you only play by yourself, is to do the almost obligatory tuning down, a semitone, even a tone. This can bring about unwanted rattles, so is a double edged sword,.Your teacher (what do you mean, you haven't got one) will guide you.
There is no point in showing off your battle scars - they shouldn't be there in the first place! It's also possible that you are pressing down on the strings too hard anyway - often happens with beginners, and I see it in intermediates, too.
Adjustment? Wait a day or two, sight down the neck, spot how much bow there is in it, compared with the dead straight strings. But there won't be much difference between .010 and .009s. Obviously, do the check before changing anything. It may show that's where the problem is anyhow.
Answer: It is true that lighter strings will require less finger strength and less exertion to press the strings down onto the frets.  If you are struggling with barre chords to get enough pressure on the strings to make them play without muting some of the strings, it is possible that lighter strings will help until you build up strength and or improve your technique.
However, the disadvantage to lighter gauge strings is that they will flex more and might make strumming and picking more difficult due to greater deflection of the strings and could also contribute to unintended bending (fretted string pushed out of parallel with other strings making note sharp) when stretching for certain fingerings.
As Tim mentioned in his excellent answer - before doing anything, be sure your guitar is properly set up.  For easiest playing you want the action to be as low as possible without causing fret buzz.
Many folks mistakenly believe that the first thing you should do to lower the action is to adjust the truss rod.  That is not always the case.  The truss rod is there to counter the tension on the neck exerted by the strings.  Without a truss rod, the neck would bow in so much that the action (relief between strings and frets) in the center of the fretboard would be way too high.  Ideally you want an almost straight neck with a slight concave curve to provide a little relief in the center of the fretboard and to be sure none of the strings are so close to the frets that they contact them while vibrating causing buzz.
But before you adjust the truss rod, you might want to check the string height at the bridge/saddle.  Most electric guitars will allow you to adjust the height of each individual string at the saddle/bridge.  Some may provide for pairs of strings to be adjusted simultaneously instead of individually. The action of your guitar can be changed by adjusting the string height at the bridge.
After adjusting the saddle height for the strings at the bridge, you can then check the relief by holding down the 6th string at the first fret and the fret where the neck joins the body and make sure there is some clearance at the frets in the center of the two frets you are holding down.  If there is not enough clearance you would loosen the truss rod to allow the string tension to pull the neck into more of a concave bow.  If there is too much clearance you would tighten the truss rod to straighten the neck against the string tension.  Always make very small 1/4 turn adjustments at a time and give the neck awhile to react to the new position before continuing.
For a better understanding of how the truss rod works check this answer on Stack Exchange Adjusting Truss Rod after changing to lighter strings
If you make any adjustments you will also want to check and possibly reset the intonation.  Setting the intonation is a subject in and of itself.  You can find information on adjusting intonation and how string gauge affects intonation here How Does String Gauge affect Intonation? and here How to adjust intonation
If you are able to lower the action with the existing strings, going to lighter strings may not be necessary.  If you still want to try lighter strings, you will need to re-check the saddle height, relief and intonation again after changing to lighter strings.
Finally, often problems getting fretted notes to sound clean are as much about proper technique and hand/arm position as the action or string gauge.  If you are not taking lessons from a qualified teacher, at least have one check your technique to be sure your hand/arm positions are optimized for the various chords you are trying to play and in general.
Good luck - and enjoy your journey towards becoming a guitarist.
Answer: I suggest you play on the strings for at least a few weeks and then move down a gauge if your barre chords are difficult or painful to play clearly. I started on acoustic and didn't play barre chords for a while, so I'm glad you're off to a balanced start. I've been playing for 12 years on and off, studied music education, but I really don't know much about electric guitar, so I asked the best guitarist I know about the truss rod. He said, "Just loosen a quarter turn!" like it was no big deal.. this makes me worry about my poor little electric :P This is my first post so I just signed up and thankfully my friend sent me a correction just in time to catch this. He said, "I lied, tighten a quarter turn please!"
in summary,
Do what feels right
Bleeding fingers are a sign of progress
Tighten a quarter turn if you do go down a gauge
Comment: I hope 'Bleeding fingers are a sign of progress' is meant to be taken with a pinch of salt!
Comment: Lighter gauge strings exert less tension on the neck, thus loosen would make more sense. Even more sense is leave alone for a while, till it settles. Bleeding fingers is a sign from Someone saying things aren't right.
Comment: Bleeding fingers are a sign of poor technique and impending infection.
Comment: Tim is correct about the truss rod.  When you switch to lighter strings they exert less tension and allow the neck to relax and straighten.  Loosening the truss rod allows the lighter string tension to put the curve back into the neck to provide more relief (distance between strings and frets in the middle of fretboard).  It's confusing sometimes.  Tim is also correct about checking the relief before making ANY adjustments to the truss rod as they might not be needed.


The transition from the residue classes modulo to the elements of classes

Question: Let $K$ be an associative commutative ring with identity. Let $R$ be an ideal of the ring $K$. Consider the factor ring.
Let $[\cdot]_1$, $[\cdot]_2$ and $[\cdot]_3$ - some residue classes that $[\cdot]_1 \cdot [\cdot]_2 = [\cdot]_3$.
Is it truth that $\forall c \in [\cdot]_3$ $\exists a \in [\cdot]_1, b \in [\cdot]_2$ that $ab = c$? If it is, how to prove it?
I tried to take advantage that there is a bijection between factors and further consider expressions $ab_1 = d_1$ and $ab_2 = d_1$ for $b_1 \ne b_2$. But next it does not work because the ring may contains zero divisors. Also I tried to express $c$ explicitly using that if $a_1b_1 = c_1$, then $c_1 - c \in R$. But it did not work too.
Thanks for the help!
Answer: No, this is not necessarily true.  For instance, suppose $K=\mathbb{Z}$, $R=2\mathbb{Z}$, and $[\cdot]_1=[\cdot]_2=[\cdot]_3=2\mathbb{Z}$.  Then $[\cdot]_1\cdot[\cdot]_2=[\cdot]_3$, but if $a\in[\cdot]_1$ and $b\in[\cdot]_2$, then $ab$ must be divisible by $4$, not just by $2$.  In particular, $2\in[\cdot]_3$ but cannot be written as such a product $ab$.


Swift: reflection thanks to infoDictionary

Question: I try to instanciate a new class from a string class name, like we can easy do in Java. I have finally wrote this function:
func stringClassFromString(_ className: String) -> AnyClass! {
    let namespace = Bundle.main.infoDictionary!["CFBundleExecutable"] as! String;
    let cls: AnyClass = NSClassFromString("\(namespace).\(className)")!;
    return cls;
}

Thanks to some googling, but as soon as I tried this solution thanks to a unit test :
func test() {
    let myclass = stringClassFromString("NSDate") as! NSDate.Type
    let instance = myclass.init()
    print(instance)
}

I have an exception (Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)) as soon as my test use the line : let namespace... I tried to see the content of the infoDictionary, he's empty. So my question is simple, is it because of the unit tests context that my dictionary is empty ? Is there any method or library (like robolectric for android) to simulate an infoDicionary for testing purpose.
Comment: If you are in the early stages of learning Swift, don't bother with reflection. Learn the basics of the type system first and later on if you find a problem that you really cannot solve while fully utilising the static type checker, then have a look again at reflections.
Comment: Why would you want to instantiate a class from a String classname? One of the biggest advantages of Swift is its static type checker, which you completely skip when you try to do stuff like creating classes from dynamic identifiers. Moreover, try to use native Swift classes when available instead of the Foundation ones (such as `Date` instead of `NSDate`).
Comment: I'm learning Swift development and reflection I think can be an interesting to learn. Thanks for your advice I do avoid to use Foundation classes but here it was just an example.
Answer: I succeed to find my error, instead of using the main Bundle, I use the constructor of the Bundle class to build a Bundle which will correspond to the current context :
let namespace = Bundle(for: type(of: self)).infoDictionary!["CFBundleExecutable"] as! String;

And tadda, it's working !


How do we prove that $(x-1)!\leq{(\frac{x}{2})^{x-1}}$?

Question: I plotted the graph of $y=(x-1)!$ and $y=(\frac{x}{2})^{x-1}$ and found that the latter is always greater than the former for $x>2$. Also, equality holds at $x=2$. Would someone please help me to prove it mathematically?
Comment: That's wrong. For $x=6$ you have $5!=120<46,656=3^6$
Comment: For every positive integer $n$, the arithmetic mean of $1, 2, \ldots, n$ is $\frac{n+1}{2}$, and the geometric mean of the same numbers is $\sqrt[n]{n!}$, so $\left(\frac{n+1}{2}\right)^n \geqslant n!$
Comment: It is not true since $n! \sim \sqrt{2\pi n}(n/e)^n$ by Stirling's formula.
Comment: Actually, I think your inequality should be reversed because of Stirling's approximation formula.
Comment: Yes sorry the reversed inequality holds. Also it is $(x/2)^{x-1}$ instead of $(x/2)^x$.
Answer: Your conclusion is wrong. For $x=4$ we have $$(x-1)!=6\\({x\over 2})^x=16$$and $$(x-1)!\not\ge ({x\over 2})^x$$
Comment
The inequality is true in reverse side for large enough $n$ using Stirling's Approximation for factorial as follows $$(x-1)!<x!\approx \sqrt {2\pi x}({x\over e})^x<({x\over 2})^x$$since $$\sqrt{2\pi x}<({e\over 2})^x$$
Comment: Yes, I made a mistake. The reversed inequality holds. Thank you very much.
Comment: You're welcome. Wish you luck!
Answer: As already noted in a comment, if $x$ is intended only to have integral values $\geqslant 2$, then the inequality (corrected now, so that the inequality sign points in the right direction) follows from the AM-GM inequality, applied to the $x - 1$ numbers $1, 2, \ldots, x - 1$.
But the question is naturally read as applying to all real values of $x \geqslant 2$, so for the sake of other readers it is also worth proving the inequality in the more general case, with $(x - 1)!$ understood to mean $\Gamma(x)$.
To prove
\begin{equation}
\label{ineq:1}\tag{1}
\log\Gamma(x) \leqslant (x - 1)\log\left(\frac{x}{2}\right) \quad (x \geqslant 2),
\end{equation}
because this holds for $x = 2$, it is enough to prove the inequality obtained by differentiating both sides:
\begin{equation}
\label{ineq:2}\tag{2}
\psi(x) \leqslant \log\left(\frac{x}{2}\right) + 1 - \frac{1}{x} \quad (x \geqslant 2),
\end{equation}
where $\psi$ is the Digamma function.
As a special case of the formula
$$
\psi(n) = H_{n-1} - \gamma,
$$
we have
$$
\psi(2) = 1 - \gamma < \frac{1}{2},
$$
so \eqref{ineq:2} holds for $x = 2$.
Differentiating again, we find that it is enough to prove
\begin{equation}
\label{ineq:3}\tag{3}
\sum_{n=0}^\infty\frac{1}{(x + n)^2} \leqslant \frac{1}{x} + \frac{1}{x^2} \quad (x \geqslant 2).
\end{equation}
Indeed,
$$
\sum_{n=1}^\infty\frac{1}{(x + n)^2} < \sum_{n=1}^\infty\frac{1}{(x + n - 1)(x + n)} = \sum_{n=1}^\infty\left(\frac{1}{x + n - 1} - \frac{1}{x + n}\right) = \frac{1}{x}.
$$
This proves \eqref{ineq:3}, therefore \eqref{ineq:2}, and therefore \eqref{ineq:1}, with strict inequality for $x > 2$.
Comment: Thank you very much. The proof was great!