Generating random numbers based on partial correlation data

Question: I need to generate random numbers based on already existing partial correlation data (not correlation or covariance data). Specifically, a 168*12 matrix based on a 12*12 partial correlation matrix. The idea is to simulate a data matrix that can be used for testing a few components of a project.
Any help in this regard would be appreciated. I have looked around but have not found any threads that talk about doing this with partial correlation data.
If someone has ideas about implementation in MATLAB, that would be a bonus!
Thanks a lot in advance!
Additions:
Apologies for any ambiguity.
-What I mean by partial correlation matrix is a matrix containing the partial correlations, calculated for any two pairs by partialling out effect of all other pairs.
-The goal is: given a matrix of partial correlation values, is there a way I can generate a data set (168*12) that would have these partial correlation values?
-If there is a method to convert partial correlation to correlation values, that would be appreciated as well.
Thanks again!
Comment: This is a cross-post http://stackoverflow.com/questions/18871792/generating-random-data-based-on-partial-correlation Please decide whether it belongs here (as I'd say) or on SO and ask a moderator to migrate or perhaps close it.
Comment: @whuber What I meant by a partial correlation matrix is a matrix that has partial correlations in it (calculated for any two pairs of entries by partialling out all other pairs. In your words "a matrix of partial correlations". Yes, this is regarding time series as you have rightly pointed out. It is on the lines of back calculating a time series (168*12) if I have a pre-defined matrix having partial correlation data.
Comment: Could you please explain precisely what you mean by a "partial correlation matrix"? Is this a correlation matrix, a correlation matrix with missing entries, or a matrix of partial correlations?
Comment: @whuber the partial acf is the conditional acf. THe relationship between the pacf and the acf is the same as that between partial regression coefficients and regression coefficients.  It is a matrix of partial (auto) correlations.
Comment: @Irish Thank you.  Your interpretation might be correct or it might not: it assumes this is a question about time series, even though time series have not been mentioned or tagged. (The value of 168 = 7*24 certainly is suggestive.) I want to hear from the *original poster* concerning his question rather than guesses (no matter how intelligent or well-meaning) from others.
Comment: @Momo Apologies for cross posting. Will look into that.
Answer: Convert the partial correlation matrix to a correlation matrix. Identify the underlying model that would generate a similar looking correlation matrix. If you had the original time series data (and you should ) then simply post it and I will help you and the list characterize it as an ARIMA model which you can then use to simulate realizations.
Comment: Could you elaborate on how to convert partial correlation data into correlation data? What I am looking for is to _make_ a time series if I have pre-defined partial correlation data.
Answer: Let $P$ = a 12 x 12 matrix with 1s on the diagonals and the negatives of the partial correlations on the offdiagonals, and let $Q = P^{-1}$. Then the original correlation between variables $i$ and $j$ is $r_{ij} = q_{ij}/\sqrt{q_{ii}q_{jj}}$.


sql select from an ordered table

Question: I want to ask some records from an ordered table.
select * from table_name order by something desc limit 4;

This is the error message (is the 'limit 4' line):
ORA-00933: SQL command not properly ended
00933. 00000 -  "SQL command not properly ended"
*Cause:
*Action:
Error at Line: 7 Column: 1

Comment: @ShashankKadne - given the error code is `ORA-xxxxx` where the `xxxxx` is 5 digits, I'm 99.99% certain that its Oracle.
Comment: What is the Database type ? SQL Server, Oracle, My SQL ?
Comment: I really wonder when they do "minus" for comments to downvote two previous comments...
Comment: Try this  `select * from table_name limit 4 order by something desc ;`
Comment: select * from table_name order by something desc limit '4';
Comment: Duplicate?: [SQL (ORACLE): ORDER BY and LIMIT](http://stackoverflow.com/q/7480243/456814).
Answer: use ROWNUM to limit the number of rows returned by a query
http://docs.oracle.com/cd/B28359_01/server.111/b28286/pseudocolumns009.htm#SQLRF00255
select *
  (SELECT * FROM table_name ORDER BY someval desc)
 WHERE ROWNUM < 5;

sql select from an ordered table


Spider walk ascending fleshy finger pad muting

Question: So the title pretty much says it all.
When ascending the spider walk exercise  the fleshy part of my fingers touch the
next string. As I'm sure most of you know when ascending it's 1,2,3,4 fingers, move to the next string with the 1 finger but all the other fingers (2,3,4) must stay depressed on the string you started from. Then continue sequentially. I dont think I can arch my fingers any further, but maybe it is my thumb.
For reference sake im not a new guitarist. Just trying to get more pinky control and can play the main verses and chorus of "Cliffs of Dover" at the songs original tempo. Solos are still a work in progress. Especially the begining
So is it worth my time to do this exercise as it does seem to help for control, but I cant hear the notes ring out because I am muting them and I think I am doing this wrong.
Any tips would be greatly appreciated.
Thanks
Answer: One finger per fret isn't for everyone, neither does it work for all the time. It's basically an exercise, and exercises often are just that, rather than real life playing. If you need to adapt, or do a variation on this, so be it. Work out your own fingering. Even when explicit fingering for something is recommended, it won't always be applicable for everyone.
Answer: This is an answer that applies to the spider walk which I am familiar with but have not spent much time doing but it also applies to playing in general.
If you can't arch your fingers enough the position of the thumb is a possible culprit but more likely the problem is the position of your entire fretting arm. It is possible to move your thumb up and down the back of the neck and not change the curvature of the fingers at all. A better method is to think of moving your elbow  forward and slightly down with your fingers on the board. This automatically adds curvature to your fingers and as an added benefit brings your thumb down a little lower on the back of the neck. As you get comfortable with this you can use subtle movements forward and back while playing to go to and from the low strings. Give it a try.
From what I've seen the spider walk is more of a mechanical, not really musical exercise but it seems helpful for helping develop finger strength, dexterity and independence so if you like it and find it useful spend a little time on it as a part of your practice routine.


Reverse engineer linear model $Ax+c=y$. Given $x$ and $y$, find $A$ and $c$

Question: Consider the standard linear model linear, given by the matrix equation
\begin{align*}
\mathbf{A}\vec{b}_{i}+\vec{c} & =\vec{y}_{i}\,,
\end{align*}
where vector $\vec{b}_{i}$ denotes the input to the model, $\vec{y}_{i}$
the output of the model, while $\mathbf{A}$ and $\vec{c}$ are the
matrix and constant-offset vector of the linear model. Typically,
in least squares, $\mathbf{A}$, $\vec{c}$, and $\vec{y}_{i}$ are
known, and one wishes to find $\vec{\beta}_{i}$.
Here, instead, we wish to consider the model matrix and vector, $\mathbf{A}$
and $\vec{c}$, as a black box that we can empirically test. We run
$N$ experiments with a set of known inputs $\vec{b}_{i}\in\left\{ \vec{b}_{1},\ldots,\vec{b}_{N}\right\} $
and a corresponding set of known, observed outcomes $\vec{y}_{i}\in\left\{ \vec{y}_{1},\ldots,\vec{y}_{N}\right\} $.
Based on the known vector data, we wish to ``reverse-engineer''
the black-box consisting of the unknown $\mathbf{A}$ and $\vec{c}$.
This seems like a textbook problem that should be treated somewhere,
and probably has a name. I hope someone could help educate me on this
and point me to a reference or textbook.
In the absence of that, let me propose an approach to the solution,
but perhaps there is a much better way? For each data set $i$, we
have a matrix equation like this, which, here, we take to be 3 dimensional,
\begin{align}
\begin{pmatrix}A_{xx} & A_{xy} & A_{xz}\\
A_{yx} & A_{yy} & A_{yz}\\
A_{zx} & A_{zy} & A_{zz}
\end{pmatrix}\begin{pmatrix}b_{i,x}\\
b_{i,y}\\
b_{i,z}
\end{pmatrix}+\begin{pmatrix}c_{x}\\
c_{y}\\
c_{z}
\end{pmatrix} & =\begin{pmatrix}y_{i,x}\\
y_{i,y}\\
y_{i,z}
\end{pmatrix}\,.\label{eq:z1}
\end{align}
We could vectorize the matrix and constants, (and slightly change
the notation)
\begin{align*}
\boldsymbol{\beta} & \equiv\left(A_{xx},A_{xy},\ldots,A_{zz},c_{x},c_{y},c_{z}\right)^{\mathrm{T}},\\
\mathbf{X}_{i} & \equiv\begin{pmatrix}b_{i,x} & b_{i,y} & b_{i,z} &  &  &  &  &  &  & 1\\
 &  &  & b_{i,x} & b_{i,y} & b_{i,z} &  &  &  &  & 1\\
 &  &  &  &  &  & b_{i,x} & b_{i,y} & b_{i,z} &  &  & 1
\end{pmatrix}\\
\mathbf{y}_{i} & \equiv\begin{pmatrix}y_{i,x}\\
y_{i,y}\\
y_{i,z}
\end{pmatrix}\,.
\end{align*}
In view of this, the equation above takes the form
\begin{eqnarray*}
\mathbf{X}_{i}\boldsymbol{\beta} & = & \mathbf{y}_{i}\,\forall i\,.
\end{eqnarray*}
To take account of all the data, we can vertically concatenate all
the matrix equations, and define the partitioned matrix of known inputs
to the system
\begin{eqnarray*}
\mathbf{X} & \equiv & \begin{pmatrix}\mathbf{X}_{1}\\
\hline \vdots\\
\hline \mathbf{X}_{N}
\end{pmatrix},
\end{eqnarray*}
which is a $3N\times12$ matrix, since there are 3 rows per data set,
and the number of unknown are 12, and there are 12 datasets. The corresponding
known output data matrix is
\begin{align*}
\mathbf{y} & \equiv\begin{pmatrix}\mathbf{y}_{1}\\
\hline \vdots\\
\hline \mathbf{y}_{N}
\end{pmatrix}\,.
\end{align*}
Thus the complete matrix equation is in the standard least-squares
form
\begin{eqnarray*}
\mathbf{X}\boldsymbol{\beta} & = & \mathbf{y}\,.
\end{eqnarray*}
This allows us to employ the standard method of least squares to an
overdetermined system of equations
\begin{eqnarray*}
\hat{\boldsymbol{\beta}} & = & (\mathbf{X}^{{\rm T}}\mathbf{X})^{-1}\mathbf{X}^{{\rm T}}\mathbf{y},
\end{eqnarray*}
 where $\hat{\boldsymbol{\beta}}$ is the least square solution vector,
which contains all the information necessary to find out what $\mathbf{A}$
and $\vec{c}$ are in the first equation.
Would this be the advisable way to solve this kind of problem on a
computer program? (e.g., numpy in python). This question seems like
a textbook kind of problem, but after some digging around I couldn't
find anything. Perhaps you can educate me on what this type of problem
is called, and what a good go to reference to read up on it would
it. Thank you, this would be much appreciated.
Comment: where is $y$ in your model??
Comment: @SZN  Thanks. Just updated, hopefully more clear now.
Comment: I see nothing wrong with your approach.
Comment: Nice, so this is what you would do as well? Does this have a name or a place to dig more? I thought it would be a common problem in some field of math
Comment: I'd use this if it worked. You can generate some random matrices according to your rule and see how well it works. The only thing I know even remotely like this is the orthogonal Procrutes problem (Wabha's problem) which assumes $A$ is a rotation matrix and $c = 0$. In that case it turns out you can use quaternions, but I doubt there is a similar approach for general matrices $A$.
Comment: Also -- look at singular value decomposition. An alternative way of solving the Procrustes problem without quaternions that might generalize.
Answer: Augment the matrix $A$ with the vector $c$ as an extra column. Then augment each vector $b_i$ with an extra component equal to unity. The $y_i$ vectors are unchanged.
Now the equations read
$$Ab_i = y_i$$
where the quantities on the LHS are augmented as described above.
But the indexed vectors are really just columns of their constituent matrices, i.e.
$$\eqalign{
 b_i &= Be_i \cr
 y_i &= Ye_i \cr
}$$
And so we have arrived at a purely matrix equation, which can be solved by standard techniques.
$$\eqalign{
 AB &= Y \cr
 ABB^T &= YB^T \cr
 A &= YB^T(BB^T)^{-1} \cr
}$$
Comment: Great! This looks like a more straightforward solution, and has essentially the same form as the least squares solution, $ \boldsymbol{\hat\beta} =( X ^TX)^{-1}X^T \boldsymbol y$, except that it is the transpose.  How do i know that $BB^T$ has an inverse?
Comment: In general, you don't know if $BB^T$ or $X^TX$ (or any other matrix) will have an inverse. To be safe, you should utilize the Moore-Penrose inverse, i.e. $$\eqalign{A&=YB^+\cr \beta &= X^+y}$$ which exists for all matrices.
Comment: Practically speaking, the more columns you can add to $B$ the more likely the rows of $B$ will be linearly independent (so $B$ will be full rank.and $BB^T$ will be invertible).  The likelihood $B$ is not full rank diminishes geometrically with each extra column.  The likelihood $BB^T$ is poorly numerically conditioned diminishes similarly, I think.
Answer: It can be much simpler.  Use $n+1$ test vectors, one of all zeroes, and $n$ each with a single $1$ and the rest $0$.  Put all these vectors into a $n$ by $n+1$ matrix called $\mathrm{X}$ that looks like $[\mathrm{I}\ 0]$ or
$$\mathrm{X} = \left[\begin{matrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 \\
\end{matrix}\right]$$
Plug each of the vectors into the transformation, and look at the result like $\left[M\ c\right]$.  $c$ is the $c$ from the transformation equation, and $\mathrm{A} = M - c^t \mathrm{I}$
Comment: Nice, right, you say, that there are n+1 special input vectors that are informationally  maximally orthogonal and complete. If we can make these and plug them into the model with good fidelity, then its straightforward. Indeed, for the zero vector y (b = 0) = c,  so the output directly gives us c. Agreed, this is more straightforward. The issue, which i haven't specified above, is that in the application of interest, i am not able to plug in the 0 vector easily, and there might be some noise on the other inputs, so having more of them should help (i think) to overconstrain the fit problem.
Comment: Real world data? Eww, that has errors.  Looks like you're stuck with least squares then.
Comment: Life is complex: it has both real and imaginary components. Thanks though, still useful  :)
Answer: We have the following linear model
$$\rm y = A x + b$$
where $\mathrm x \in \mathbb R^n$ and $\mathrm y \in \mathbb R^m$, $\mathrm A \in \mathbb R^{m \times n}$ and $\mathrm b \in \mathbb R^m$. Vectorizing, we obtain an underdetermined system of $m$ linear equations in $m n + m = m (n+1)$ variables
$$\begin{bmatrix} \mathrm x^\top \otimes \mathrm I_m & \mathrm I_m\end{bmatrix} \begin{bmatrix} \mbox{vec} (\mathrm A)\\ \mathrm b\end{bmatrix} = \mathrm y$$
Since the matrix has full row rank for all $\rm x$, the least-norm solution of the linear system is
$$\begin{array}{rl} \begin{bmatrix} \mbox{vec} (\mathrm A_{\text{LN}})\\ \mathrm b_{\text{LN}}\end{bmatrix} &:= \begin{bmatrix} \mathrm x \otimes \mathrm I_m \\ \mathrm I_m\end{bmatrix} \left( \begin{bmatrix} \mathrm x^\top \otimes \mathrm I_m & \mathrm I_m\end{bmatrix} \begin{bmatrix} \mathrm x \otimes \mathrm I_m \\ \mathrm I_m\end{bmatrix} \right)^{-1} \mathrm y\\ &\,= \begin{bmatrix} \mathrm x \otimes \mathrm I_m \\ \mathrm I_m\end{bmatrix} \left( (\mathrm x^\top \otimes \mathrm I_m) (\mathrm x \otimes \mathrm I_m) + \mathrm I_m \right)^{-1} \mathrm y\\ &\,= \begin{bmatrix} \mathrm x \otimes \mathrm I_m \\ \mathrm I_m\end{bmatrix} \left( (\mathrm x^\top \mathrm x \otimes \mathrm I_m) + \mathrm I_m \right)^{-1} \mathrm y\\ &\,= \frac{1}{ \| \mathrm x \|_2^2 + 1} \begin{bmatrix} \mathrm x \otimes \mathrm I_m \\ \mathrm I_m\end{bmatrix} \mathrm y\\ &\,= \frac{1}{ \| \mathrm x \|_2^2 + 1} \begin{bmatrix} \mathrm x \otimes \mathrm y \\ \mathrm y\end{bmatrix}\end{array}$$
Un-vectorizing, we obtain
$$\boxed{\begin{array}{rl} \mathrm A_{\text{LN}} &:= \color{blue}{\frac{1}{ \| \mathrm x \|_2^2 + 1} \, \mathrm y \mathrm x^\top}\\\\ \mathrm b_{\text{LN}} &:= \color{blue}{\frac{1}{ \| \mathrm x \|_2^2 + 1} \, \mathrm y}\end{array}}$$
Verifying,
$$\mathrm A_{\text{LN}} \mathrm x + \mathrm b_{\text{LN}} = \frac{1}{ \| \mathrm x \|_2^2 + 1} \left( \mathrm y \mathrm x^\top \mathrm x + \mathrm y \right) = \left(\frac{ \| \mathrm x \|_2^2 + 1 }{ \| \mathrm x \|_2^2 + 1 } \right) \mathrm y = \mathrm y$$


$\inf (E)$ does not exist and $\sup (E) = (0 , 1)$

Question: Let $\leq$ be the usual order on the field $\Bbb R$ of real numbers. Define an order $\leq$ on $\Bbb R^2$ by $(a,b) \leq (c,d)$ if $(a < c)$, or $(a = c$ and $b \leq d)$. Consider the subset $E$ = {${(\frac{1}{n} , 1 - \frac{1}{n} ) \in \Bbb R^2 : n \in \Bbb N}$}. With respect to $\leq$ which of the following statements is true ?

$\inf (E) = (0 ,1)$ and $\sup (E) = (0 , 1)$

$\inf (E)$ does not exist and $\sup (E) = (0 , 1)$

$\inf (E) = (0 ,1)$ and $\sup (E)$ does not exist

Both $\inf (E)$ and $\sup (E)$ do not exist.

We know that  $\inf (E)$ = smallest member or smallest limit point of $E$ and $\sup (E)$ = largest point or largest limit point of $E$.
By using above information, we get
$\inf (E)$ does not exist and $\sup (E) = (0 , 1)$. I think, I'm not on right way. Please help me
Comment: @outofspace0106,Please tell me how to connect the concept discussed between " we see that .......Hence if we had an infimum". with further discussion.
Answer: You are correct about non-existence of infimum of $E$. I have tried to provide a proof as follows:
We see that $\forall n\in \mathbb{N}, a \in \mathbb{R}$
$$(0,a)<(\frac{1}{n}, 1-\frac{1}{n})$$
If $\exists (x,y)\in \mathbb{R^{2}}$ such that $$(0,a)<(x,y), \forall a\in \mathbb{R}$$ then $x>0$. Hence, using Archemedian Property, $\exists n_{0} \in \mathbb{N}$ such that $\frac{1}{n_{0}}<x$.
So we have $$(\frac{1}{n_{0}}, 1-\frac{1}{n_{0}})< (x,y).$$ Hence, if we had an infimum, it must be of the form $(0,a)$ which is not possible because $(0,a)<(0,a+1)$ and $(0,a+1)$ is again a lower bound of $E$.
So we don't have a "greatest" lower bound of $E$.
On the other hand the supremum of $E$ exists and $sup(E)=(1,0)$.
This is because $\forall n\in \mathbb{N}$, $$(\frac{1}{n}, 1-\frac{1}{n})\leq(1,0)$$ and $(1,0)\in E$.
So $(1,0)$ is the "least" upper bound of E.


How to find duplicate ids from list in c#

Question: I want to filter duplicate id from a list using **linq, here is the code:**
foreach (var item in _VMReturnStock.scmDistReturnDetails.ToList())
{

}

I have ids in scmDistReturnDetails, what should I do in this case?  And on the basis of duplicate id I have to set model state false.**
Comment: filter ids and if any id have count greater than 1 than set model state false
Comment: Duplicate of http://stackoverflow.com/questions/18547354/c-sharp-linq-find-duplicates-in-list
Answer: You can use MoreLinq by Jon Skeet (Nuget).
It offers the method "DistinctBy".
foreach (var item in _VMReturnStock.scmDistReturnDetails.DistinctBy(d=>d.Id).ToList())
        {

        }

DistinctBy checks the return value of the lambda for uniqueness, but it returns the original object.
Comment: i have to store that ids in a variable and if ids count > 1 than i have to set model state false. i dont need distinct ids
Comment: I thought the original question was to filter out records with duplicate id...? What do you mean by "setting the model state false"?
Comment: yes filter out duplicate ids and if there is any duplicate id available in list i have to set model state false so user cant save data
Answer: List<int> list = new List<int>() { 1, 2, 5, 3, 1, 2, 3, 4, 5, 6 };

var dups = list.GroupBy(i => i).Where(i=>i.Count()>1).Select(i=>i.Key);

foreach (var k in dups)
  Console.WriteLine(k.Key);

Answer: var list = _VMReturnStock.scmDistReturnDetails.Select(x=> x.ID).Distinct();

Comment: For my needs, this is the most useful answer here, give me a list (or count) of everything minus the duplicates.
Answer: Your question is not clear at all, and "to set model state false" is a mystery, but based on one of your comments, I think you want to do something like this.
        foreach (var item in scmDistReturnDetails.GroupBy(x=>x.id))
        {
           if (item.Count() > 0)
             {
               //add item.Key, the ID, into a variable where you can "set model state false"
             }
        }

Answer: Try this:
List<int> list = new List<int>() { 1, 2, 5, 3, 1, 2, 3, 4, 5, 6 };

            var info = list.GroupBy(i => i).ToDictionary(i => i.Key, i => i.Count());

            foreach (var k in info.Where(k => k.Value > 1))
                Console.WriteLine(k.Key);

Comment: While this would work, it's inefficient if you have large numbers of records that don't have duplicates.  You will pull all records from the datasource, even if they don't have any duplicates.  See my answer for a better approach.
Answer: If you want to achieve a solution with existing LINQ operators, one solution is to GroupBy the ID, and then selecting the first element of each group. If the data source is a LINQ provider, then chances are that the heavy lifting will be done server side.
foreach (var item in _VMReturnStock.scmDistReturnDetails.GroupBy(d=>d.Id).Select(grp=>grp.First()).ToList())
    {

    }

Comment: They are two different answers. http://meta.stackexchange.com/questions/60445/is-it-ok-to-post-multiple-answers-to-a-question
Comment: Please don't post multiple answers. Merge it with your other answer and remove this
Answer: I suppose your IDs is int and ModelState default value is true so you can do it like this
        int? uniqueID = _VMReturnStock.scmDistReturnDetails.FirstOrDefault();

        foreach (var item in _VMReturnStock.scmDistReturnDetails.ToList())
        {
            if (item != tmp)
            {
                _VMReturnStock.ModelState = false;
                uniqueID = null;
                break;
            }
        }

If your IDs is not distinct so model state will set to false and uniqueID (that ou gonna return r stored it some where) will not has a value.


What's a good web-based analytics package that'll work without requiring javascript?

Question: My understanding is that Google Analytics (the tool I'd normally use for website analytics) cannot be used on a MySpace page, because MySpace doesn't allow you to embed javascript.
But my client wants to track usage of her MySpace page.
Has anyone found away around this? I'm looking for a different web-based, third-party analytics toolset, I guess. One that doesn't depend on javascript, is at least close to as feature-rich as Google Analytics, and is preferably cheap (or free!).
(I picture a 1x1 image-based solution.)
Answer: StatCounter is a pretty good alternative to Google Analytics that provides an image-based tracking tool for this sort of situation. It does only keep track of the last 500 requests for the free plan, however.
You also have to understand that the only way to do this without Javascript (the image based approach) will not be able to collect nearly as much data as the Javascript-based tracking tools.
Answer: AwStats is a server-side that processes based on your server logs.
Answer: GetClicky uses an image and/or a script to track visitors.


Suitescript - How do I access "Related Records" subtab and get/store their associated values?

Question: I am trying to get the associated values from the related records subtab. For example, I am trying to get the associated bills values (amount billed) on a purchase order. There is no other way to do what I am trying to do besides getting those values OR I need to get the "amount billed" or "amount unbilled" column field on the items subtab per each item. I can find the internal id of "amount unbilled" as 'amountunbilled' but trying to retrieve the value of this column on a line gives me null. (Also, there is no "Amount Unbilled" column but there is a "Billed" column that is disabled as it is a calculation I am assuming - I cannot access this column to get this value).

UPDATE:
So I actually found that "Amount Unbilled" is accessible while I am on a different record. However I would still love to know how I could access items on the Related Records subtab.
Comment: are you trying to do this via savedsearch or through suitescript?  If suitescript, what try of script?  UserEvent, Map/Reduce,ect?
Comment: suitescript, client, on save
Answer: generally you do that with a transaction search using a filter for created from:
nlapiSearchRecord('transaction', null,
 [
   new nlobjSearchFilter('createdfrom', null, 'is', nlapiGetRecordId()),
   new nlobjSearchFilter('mainline', null, 'is', 'T'),
  ...

The list of fields available for search filters or search results is available at https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_1/script/record/transaction.html
Or if you are focused on bills attached to POs:
var bills = nlapiSearchRecord('vendorbill', null, [
        new nlobjSearchFilter('createdfrom', null, 'is', poId),
        new nlobjSearchFilter('mainline', null, 'is', 'T')
]);

Comment: However, there is no "created from" field on the bill that references the purchase order. The only reference of the PO I have is in the URL. I am able to retrieve the type and id of the record from which the bill has transformed in the URL on creation of the new bill and from there I can get the "amount unbilled" from the PO. However, I also need this script to trigger on edit to recalculate the amount unbilled, which I cannot do from the URL on an edit. The only other way I can think of is a custom "created from" field. And I don't know how to set a ref. link there pointing to PO....help!
Comment: You may not see it in the GUI but the field is there. I have added a vendor bill search sample from a production script.
Answer: You can retrieve the internal id of the bill associated to the purchase order using this:
var vendorBillId = nlapiGetLineItemValue("links", "id", 1);
Then load the vendor bill using the retrieved id and get the amount.


How to Monitor/listen aws Services?

Question: Suppose multiple aws services are running (like EC2,S3) and If someone changes the configuration of these services , I want to know immediately and want to pull the updated configuration. So how can i listen to these services to pull configuration immediately . I went through couple of options like aws SNS and all. But i don't want to implement this using any aws services for this.
I am using spring boot application. Any help is appreciated , Thanks in advance.
Comment: Have you looked at AWS Config?
Comment: @Marcin AWS Config internally send the notification to SNS and As i said I don't want to use the AWS services.
Answer: The two services you should be interested in are:
AWS CloudTrail:

AWS CloudTrail is an AWS service that helps you enable governance, compliance, and operational and risk auditing of your AWS account. Actions taken by a user, role, or an AWS service are recorded as events in CloudTrail. Events include actions taken in the AWS Management Console, AWS Command Line Interface, and AWS SDKs and APIs.

AWS Config:

AWS Config provides a detailed view of the configuration of AWS resources in your AWS account. This includes how the resources are related to one another and how they were configured in the past so that you can see how the configurations and relationships change over time.

You can also configure Amazon CloudWatch Events rules that trigger when a particular API call is made (eg when a user changes some configuration). This could trigger a notification, a Lambda function, etc.
See:

Creating a CloudWatch Events Rule That Triggers on an AWS API Call Using AWS CloudTrail - Amazon CloudWatch Events
How to monitor AWS account activity with Cloudtrail, Cloudwatch Events and Serverless

How to Monitor/listen aws Services?


How to rename all directories on a terminal

Question: I have a total of 31 directories. Every directory has a random name.
❯ ls -al
total 32
drwxr-xr-x  34 shinokada  staff   1088 Dec 28 17:16 .
drwxr-xr-x  32 shinokada  staff   1024 Dec 28 17:12 ..
-rw-r--r--@  1 shinokada  staff  14340 Dec 28 17:16 .DS_Store
drwxr-xr-x   5 shinokada  staff    160 Dec 28 17:10 05618066
drwxr-xr-x   5 shinokada  staff    160 Dec 28 17:08 0fef2d20
drwxr-xr-x   5 shinokada  staff    160 Dec 28 17:09 11ff096d
drwxr-xr-x   5 shinokada  staff    160 Dec 28 17:09 1651ff1f
drwxr-xr-x   5 shinokada  staff    160 Dec 28 17:09 2123b256
... and more

Now I'd like to rename them sample1 sample2 sample3 ...sample31.
How can I do it on a terminal(bash/zsh)?
Is there a quick way to do it rather than rename one by one?
Comment: You can't be running Bash and Zsh at the same time. The answers will probably look different for each.
Comment: MacOS does not seem to ship a `rename` tool; there are several incompatible ones, so it's unclear which one you refer to, but if you have the Perl-based one, it can probably do what you are asking in a slick one-liner.
Answer: This should do:
num=1; for dir in */ ; do mv "${dir}" "sample$num" ; ((num++)); done

I assume you don't want to rename the files, only directories inside your current working directory.
Comment: I just needed to change num=0 to num=1. Thanks.
Comment: Sorry, I missed that you are starting from `sample1`. Thanks for pointing it out (I edited it in the answer).


Do I have a bad motherboard or a bad CPU? (STOP 0x00000101 and 0x00000124)

Question: I just built a new system and I'm getting very frequent STOP errors.  The STOP errors I've hard are 0x00000101 and 0x00000124, which are both Machine Check Exceptions.
I know that I have a hardware error, but I'm not sure if it's the CPU or the motherboard that's the problem.  I don't have another CPU of the same socket handy to swap and test.
The reason I suspect the CPU is because in the event log I see a log of these:

<code>A corrected hardware error has occurred.

Reported by component: Processor Core
Error Source: Corrected Machine Check
Error Type: Cache Hierarchy Error
Processor ID: 1

The details view of this entry contains further information.
</code>

From what I've read, that could be a BIOS issue, but it certainly sounds like a CPU issue.
The motherboard is a GIGABYTE with AMD SB700 southbridge.  The CPU is an Athlon X2 7750.
My understanding is that the CPU is a re-branded X4 with two cores disabled, probably because they are faultly.
I want to RMA the faulty part, but I'm not sure which it is.  Anyone care to guess?
UPDATE: RESOLVED - After replacing the motherboard, the problem turns out to be "Cool 'n Quiet".  Disabling "Cool 'n Quiet" in the BIOS suddenly resolved the issue.  No more BSODs.
Answer: Two ways to look at it:
1) The CPU almost never goes bad. We've replaced 36 desktop motherboards this year. We've only replaced 1 bad CPU. The CPU failing is very, very rare.
2) In my career/experience, I have never had a bad CPU that allowed the computer to get as far as a blue screen. When bad CPU's happen, the machine does not boot.
I can't site anything specific on those two pieces of advice beyond general experience, as I have not seen that specific error message before, but my career says bad motherboard.
Comment: The CPU cannot be told apart from the motherboard by an application (ie, socket could be bad, other things like that). There is no way to tell definitively from a windows error message where the problem lies. Do what you can to eliminate problems you can fix (update BIOS, drives, reinstall OS), then replace the most likely problem component. I agree with Happy Hamster that this is /probably/ a motherboard problem - but there's no way to be sure aside from replacing one of them.
Comment: RE - Chris --

One of my favorite error stories is a hard drive error I got once. Error log was filled with errors about the inability to write to a sector. Obvious hard drive fault, right? Ran Spinrite to confirm, drive was bad. Replaced drive. Same problem. Ran Spinrite, drive confirmed bad again, so I assumed I got a DOA replacement. Replaced THAT drive, same problem, realized something was up. All three drives tested fine on another machine. Problem? Bad hard drive controller on the motherboard! So yeah, errors can be very misleading sometimes...
Comment: That's what I was thinking myself, but the "Processor Core" error from Windows is giving me pause.
Comment: CPUs can break, but most commonly because someone improperly applied thermal paste and they overheated. Most of the the time an inherently faulty CPU will be pulled long before it gets a chance to ship.
Answer: I cought similar issues with CPU overheating; check the fan or install one if it's passivly cooled. Try also hardware monitoring tools (such as PC Probe for Asus desktop motherboards) that can indicate CPU overheat
Comment: I don't think it's CPU overheating.  Temperature readings are below 40* C.
Answer: Wikipedia has a section on interpreting MCEs, which has a link to a tool from AMD called mcat, which apparently will help you figure out exactly what the numbers mean.
Answer: How hard would it be to return/replace the CPU, could you afford the 'downtime'? If you replace it you'll know very quickly if it's a CPU or MB issue.
Comment: I think I'm going to go that route.  Downtime isn't an issue since its a new computer.  I think I'm going to RMA the motherboard since it seems that's the most likely culperate.


Set css class to list options dynamically AngularJS

Question: Well there are two list options in my code - Monthly and quarterly
I have one class "active" which generally highlights the element.
I need class "active" should be applied to one of the options when they are clicked or selected. Here class=active is applied to only Monthly manually.
Looking for Angular solution for this.

Select Preferred View

Monthly

Quarterly

Answer: Use ng-class directive like in a code below.

Select Preferred View

Monthly

Quarterly

It adds specified class when expression given after classname evaluates to true and removes it when it evaluates to false.
ng-class="{'classname' : expression}"

You can set a default value in a controller:
$scope.type = 'month';

or via ng-init directive on div:

jsfiddle with example
jsfiddle with setting default in ng-init
Comment: Have you looked into jsfiddle? There active class is removed from Monthly. Setting default you can handle in a controller by setting $scope.type = 'month'; or by adding ng-init="type='month'" to the parent div
Comment: Thanks. Here active class highlights Monthly by default and when I click on Quarterly now it highlights Quarterly but doesn't remove from Monthly. I want to toggle selection and keep active to monthly by default


Practicing jumps in piano without looking: Is there any progressive method?

Question: This is kind of a common question here, but one point I haven't seen addressed in detail:
While sight-reading, it is recommended to practice jumps (over an octave) without looking, which is difficult, but evidently possible after a lot of practice and effort. So far I have only seen one method for practicing this, but it is not very pleasant and a bit frustrating, as it does not give a sense of step-wise progression:  The method I am referring to, is to just "try" to blindly find the right keys, where the "trying" is either guessing, or touching around the keyboard to find landmarks based on the black keys.

The guessing part is important for building the spatial awareness, but clearly there is no easy start, and the result is qualitative: "you either get it or not". So there is no real practice here, just absolute result.
The finding landmarks method is what I have most conflict with. Touching around the keyboard blindly is a way to find the position, but this is not something that will happen during real playing, so its not something you should get good at (is it?). It feels like a waste of time to practice this, and instead it seems way more important to practice looking quickly at the keyboard without missing the part of the score you are reading. But this is hardly ever addressed (and even frowned upon).
As an example for this in a real practice session, my hand jumps to the position of the new chord, but I am not sure if I am over the right keys. Shortly looking down will quickly tell me that I am just shifted by one tone, so its a quick adjustment. If I want to get this reassurance without looking, I have to remove the hand of the position altogether and start touching around for black keys, therefore the "jump" is lost, and suddendly I am training to find the position from a totally different one than the original set by the music.
Is there a reason for this? Do professional piano players really practice "touching around the keys" and do this in real time?
Comment: For the 2nd point, I'd like to think that feeling around helps to build and strengthen your internal map of the keys. I think of it like this, let's say I try the jump and I land wrong. Instead of just looking and correcting, if I take the time to find the right keys by feeling around, I'll have a richer and more detailed mental picture of the layout that I can use in the future to get it right. Maybe. I'm trying to do more research here I'll come back if I find anything.
Answer: Ah, this question is really perfect for me because I used to struggle with this until I figured the following method out.
As cliche as it sounds, the answer is to start slow. Start really really slow and keep your eyes open as you do it. Make sure you nail it exactly right every single time.
Then, close your eyes as much as you can. Close your eyes as much as possible, but open them to make sure you are perfectly accurate. Keep doing it at this speed until you can do it with your eyes completely closed the whole time.
Then, start speeding up the tempo. I suggest you get it right 5 times IN A ROW, before making the BPM 5 or 10 ticks faster. Eventually, you will get it up to speed and you will nail it perfectly.
I hope that helps. Let me know if you need any clarification or more help.
Comment: In short, learning to play blind, will make you a thousand times better if you have your eyes. In other words, if you can play the piece without opening your eyes, then when you do open your eyes, it will be very easy to play. This is also especially helpful in expressing yourself in the piece because if you can close your eyes and not think about the execution, then you can focus on the interpretation. I am not sure why this method is not recommended that often but it truly helps - it got me to Carnegie Hall and first in several competitions. This method should gain more attention.
Comment: So you don't do the second method of looking for tactile landmarks right? And you seek for visual confirmation instead. This seems more intuitive to me too. But are you aware that this is often not recommended? Any idea why?
Comment: @Haversine - it was a taxi that got me to Carnegie Hall, and in no time at all...
Answer: It's down to 'muscle memory' - whatever that is!
Feeling for where you are is no great help - you won't be doing any of that when you play properly. It's a great help visually, while you jump endlessly up and down octaves. And, yes, get used to jumping both ways.
You know the geography of the keyboard, so watch where the fingers need to land. Slowly is good. It's basically training your hand and more importantly, arm, to move just the right amount. And if you're talking octave jumps, the most used, the bonus is that every jump from one note to its octave copy is exactly the same distance!
Just like athletes practise a move hundreds of times, so it becomes automatic, so will you. And even without the piano there, you can measure out the octave distance, (6 1/2" on most) and bounce your hand on any available surface!
The bigger problem is working out which finger plays the lower note, which plays the upper note. That's for you to figure out.


Why my transition dont work in javascript?

Question: My problem is that i want to put some transition duration in the changes that make one button. This is my code:
ingenieriaInd.addEventListener('click',(e)=>{

  ingenieriaInd.style.transition = 'all 500ms ease-in-out';
  ingenieriaInd.style.width = '90vw';
  ingenieriaInd.style.height = '80vh';
  ingenieriaInd.style.position = 'absolute';
  ingenieriaInd.style.justifyContent = 'flex-start';
  ingenieriaInd.style.top = '5vh';
  ingenieriaInd.style.left = '-15vw';

})

All the changes are working, but the transition not.
I want to make that the changes that i want have smooth.
Comment: Please  edit the question and create a code snippet with enough CSS and HTML for readers to recreate the problem, thanks. Meta: [I've been asked to create a "Stack Snippet". How do I do that?](https://meta.stackoverflow.com/a/358993/5217142)
Answer: You need to set starting positions for your element:
only css
#ingenieriaInd {
    width:  0;
    height:  0;
    position:  absolute;
    justify-content: flex-start;
    top:  0;
    left:  0;
    transition: all 500ms ease-in-out;
    -webkit-transition: all 500ms ease-in-out;
}

#ingenieriaInd:active {
    width:  90vw;
    height:  80vh;
    position:  absolute;
    justify-content: flex-start;
    top:  5vh;
    left:  -15vw;
}

css and js
css
#ingenieriaInd {
    width:  0;
    height:  0;
    position:  absolute;
    justify-content: flex-start;
    top:  0;
    left:  0;
    transition: all 500ms ease-in-out;
    -webkit-transition: all 500ms ease-in-out;
}

js
ingenieriaInd = document.getElementById("ingenieriaInd")

ingenieriaInd.addEventListener('click',(e)=>{
    ingenieriaInd.style.width = '90vw';
    ingenieriaInd.style.height = '80vh';
    ingenieriaInd.style.position = 'absolute';
    ingenieriaInd.style.justifyContent = 'flex-start';
    ingenieriaInd.style.top = '5vh';
    ingenieriaInd.style.left = '-15vw';

})


Quando e como devo usar operador instanceof e typeof no JavaScript

Question: Quando e como devo usar operador instanceof e typeof no JavaScript?
Em um post do Stack EN vejo a usabilidade do instanceof. Porém, em outro post do Stack EN diz que não é necessário usar nenhum outro operador além do typeof. Então gostaria de ver exemplos situacionais sobre ambos operadores.
Answer: O instanceof e o typeof têm de facto maneiras de usar que se sobrepõem. Mas têm também diferenças que os tornam distintos e aplicáveis em casos diferentes.
Repara que o typeof dá object para os seguintes casos:
typeof (new Date())  // "object"
typeof [1, 2, 3]     // "object"
typeof {foo: 'bar'}  // "object"

e no caso dos exemplos em cima podes ter uma resposta mais específica com o instanceof:
(new Date()) instanceof Date // true
[1, 2, 3] instanceof Array   // true
({foo: 'bar'}) instanceof Object // true

Lembra-te no entanto que em JavaScript o seguinte também é válido:
(new Date()) instanceof Object // true
[1, 2, 3] instanceof Object    // true

Por isso é bom ser específico com a instancia com que se compara.
Outra utilização onde o instanceof é muito útil é para saber se um objeto ou classe é uma instancia/herda de outra. Repara no exemplo em baixo e nos resultados de console.log():

class Transporte {
  constructor(marca) {
    this.tipo = marca;
  }
}

class Carro extends Transporte {
  constructor(marca) {
    super(marca);
    this.tipo = 'Carro';
  }
}

class Mota extends Transporte {
  constructor(marca) {
    super(marca);
    this.tipo = 'Mota';
  }
}

const VW = new Carro('Volkswagen');
const Kawasaki = new Mota('Kawasaki');

console.log(VW instanceof Carro); // true
console.log(Kawasaki instanceof Mota); // true
console.log(Kawasaki instanceof Carro); // false
console.log(VW instanceof Transporte); // true
console.log(Kawasaki instanceof Transporte); // true
Comment: To vendo muito errado ou os dois últimos `console.log` são iguais?
Comment: @GuilhermeCostamilam tens razão, devia ser `Kawasaki`, corrigi.
Answer: O operador typeof sempre resulta numa string com o nome do tipo primitivo do objeto. Por exemplo, se você executar o seguinte comando:
var a = typeof 1;

A variável a vai ter como valor a string "number". Ou seja, se você quer executar um código caso a variável value seja do tipo primitivo number, você deve fazer:
if (typeof value === "number") {
   // ...
}

No caso acima, a expressão typeof value irá ser resolvida para uma string com o tipo de value, que em seguida será comparada com a string "number".
Já o instanceof resulta num booleano que indica se um objeto foi gerado (direta ou indiretamente) por uma função construtora: obj instanceof func.
function Carro(cor, nome) {
   this.cor = cor;
   this.nome = nome;
}

var foo = new Carro("preto", "ka");
var bar = "teste";

foo instanceof Carro; // retorna true
bar instanceof Carro; // retorna false

Portanto, se você quiser fazer um if com instanceof, deve ficar assim:
if (obj instanceof Carro) {
   //
}

já que a expressão obj instanceof Car vai ser resolvida para um boolean.
Note que no exemplo abaixo, o valor de retorno de typeof é "object", ou seja, o typeof nunca pode ser usado para testar se um objeto foi criado por uma determinada função construtora, mas somente para testar o tipo primitivo do objeto.
var foo = new Carro();
typeof foo; // retorna "object"

Espero ter ajudado!
Answer: O typeof e o instanceof são complementares, além de possuírem sintaxes diferentes.
O typeof verifica o tipo primitivo de um valor, e sempre retorna uma das seguintes strings:
"undefined"
"boolean"
"number"
"string"
"object"
"function"
"symbol"

Já o instanceof percorre a cadeia de protótipos de um determinado objeto, e verifica se nessa cadeia existe referência a um segundo objeto, retornando um booleano. Isso serve para verificar se um objeto herda de outro.
Como se vê, são funções totalmente diferentes, além do fato de o typeof se aplicar a qualquer valor, e o instanceof somente a objetos. Existe alguma confusão porque o typeof nunca distingue o tipo de objeto (exceto no caso das funções e símbolos), e para isso é necessário utilizar o instanceof e/ou outras técnicas. Há ainda o caso de typeof null === "object", que pode parecer confuso mas tem explicação.
Aproveito ainda para esclarecer um mal-entendido da sua pergunta, quando você diz:

Porem em outro post do Stack EN diz que não é necessário usar nenhum outro operador alem do typeof

Na verdade não é isso que esse post diz. Ele diz apenas que, para descobrir se um valor é uma função, é melhor usar o typeof do que a função isFunction da biblioteca underscore.


Provided $A$'s distinct eigenvalues, show that $Ax = u$ has no solution. [Strang P297 6.1.32]

Question: My question  differs from this question. Source for the following is on P3 hereof:

Suppose $A$ has eigenvalues $0,3,5$ with linearly independent eigenvectors $u,v,w$.
  (a) Give a basis for $\operatorname{null}(A)$ and a basis for $\operatorname{col}(A)$.
  (b) Show that $Ax=u$ has no solution.
  Hint: If it did, then $()$ would be in $\operatorname{col}(A)$ and this contradicts the assumption.
Solution
(a) $\operatorname{null}(A)=\operatorname{null}(A-0I)=E_0=\operatorname{span}(u)$. For any linear combination $c_1v+c_2w$,
  $c_1\color{green}{v}+c_2\color{#FF4F00}w = c_1\color{green}{\dfrac{Av}{3}} + c_2\color{#FF4F00}{\dfrac{Aw}{5}} =
A\left(\dfrac{c_1}3 v + \dfrac{c_2}5 w\right)\in\operatorname{col}(A),$
  therefore $\operatorname{col}(A)=\operatorname{span}(v,w)$.
  (b) $Ax=\color{green}v+\color{#FF4F00}w
=\color{green}{\frac 1 3 A v}+\color{#FF4F00}{\frac 1 5 Aw}
=A\left(\dfrac v 3 + \dfrac w 5\right)$.
  All solutions are of the form $\dfrac v 3 + \dfrac w 5 + cu$.
  (c) Assume that $Ax=u$ has a solution. Then $u\in\operatorname{col}(A)$,
  but $u$ is linearly independent of both $v$ and $w$ therefore cannot be in $\operatorname{col}(A)$.

By P308, Thm 4.20, from David Poole's Linear Algebra, distinct eigenvalues correspond to linearly independent eigenvectors. Suppose I revamp part (c)'s argument for $\mathbf{v}$ instead:

Assume $\mathbf{x}$ solves $\mathbf{Ax = v}$. Then $\mathbf{v} \in col(A)$.
  By Thm 4.20 (aforementioned), $\{\mathbf{u, v, w}\}$ is lin-ind therefore $\mathbf{v} \notin col(A)$.

$1.$  This is false because $\color{green}{\mathbf{Av = 3v}}$ is given. Thus, what am I misconstruing?
Why does the argument in part (c) hold for $\mathbf{u}$ but fail for $\mathbf{v}$ and $\mathbf{w}$ ?
$2.$ Moreover, what's the intuition for part (b)? P267, 268 of Poole presents the geometric interpretation of eigenvectors so I'd imagine something geometric here?
$\Large{\text{ Supplementary dated Jan 12 2014: }}$
$3.$ In (a), how would you divine/previse to consider $c_1\color{green}{v}+c_2\color{#FF4F00}w$ for determining $colspace(A)$?
$4.$ As regards (b), what's the objective in solving $Ax=\color{green}v+\color{#FF4F00}w$ for $x$? Why be concerned with this?
Comment: Both your question and the link you gave do not mention, surprisingly, what is $\;A\;$, but it seems to be a $\;3\times 3\;$ matrix. Is this correct? And why your solutions has (a)-(b)-(c) if the question only has (a)-(b)?
Comment: If I understood correctly what's going on here, and that could be a long shot, the reasoning seems to be simply that $\;u\notin Span\,\{v\,,\,w\}=Col(A)\;$ so no solution's possible, but for $\;w,v\;$ there're trivially solutions...
Answer: You have the right ideas, but you're expressing them in a very tortuous way.
If the vectors $u$, $v$ and $w$ are linearly independent, they must be relative to distinct eigenvalues (assuming $A$ is $3\times3$). I believe it's also intended that $Au=0$, $Av=3v$ and $Aw=5w$, but in this case linear independence would follow.
Moreover $\{u,v,w\}$ is a basis of $\mathbb{R}^3$ (or $\mathbb{C}^3$, if you use complex numbers).
Each eigenspace has dimension $1$, so $u$ generates the null space.
An equation $Ax=y$ has a solution if and only if $y$ belongs to the column space of $A$; but, since $v$ and $w$ obviously belong to the column space, they form a basis of it, because of the rank-nullity theorem. It follows that $u$ doesn't belong to the column space.
Note that saying $u$ is linearly independent from both $v$ and $w$ is meaningless.
Comment: +1. Thank you very much for your answer. Would you please expound on "$u$ is linearly independent from both $v$ and $w$ is meaningless"? What should the author have written? I'd have written $\{u, v, w\}$ is linearly independent. I'd also be grateful for your help towards my supplementary in my OP.
Comment: @LePressentiment The statement is too ambiguous to have a sensible meaning.
Comment: I don't perceive what you mean. Would you please enlarge on your comment in your answer? Please forgive me for forgetting +1.
Answer: Let's address your question 1 first. Recall that in part a you found that $\{\mathbf{v},\ \mathbf{w}\}$ forms a basis for the columnspace of $A$. The reason that the argument works for $\mathbf{u}$ and not for $\mathbf{v}$ is because $\mathbf{u}$ is not an element of this basis set while $\mathbf{v}$ is. Analagously, the argument will also fail for $\mathbf{w}$ (and indeed any linear combination of $\mathbf{v}$ and $\mathbf{w}$).
Since $\{\mathbf{u},\ \mathbf{v},\ \mathbf{w}\}$ was assumed to be linearly independent, it follows that $\mathbf{u}$ is not in the span of $\mathbf{v}$ and $\mathbf{w}$. Otherwise, there exists scalars $a$ and $b$ such that
$$a\mathbf{v} + b\mathbf{w} = \mathbf{u}$$
But then we have the non-trivial linear combination
$$a\mathbf{v} + b\mathbf{w} - \mathbf{u} = \mathbf{0}$$
contrary to the assumption of linear independence.
Since the span of $\mathbf{v}$ and $\mathbf{w}$ is precisely $\mathrm{col}(A)$, this means that $\mathbf{u}$ is not an element of the columnspace, i.e. there does not exist $\mathbf{x}$ such that $A\mathbf{x} = \mathbf{u}$. Note that this argument cannot work for $\mathbf{v}$ because $\mathbf{v}$ is in the span of $\{\mathbf{v},\ \mathbf{w}\}$, and trivially so.
For question 2, the geometric intuition is complicated by the fact that there do exist matrices in which vectors in the nullspace are also in the columspace (i.e. matrices for which part b has a solution). In fact, there exists matrices in which the columnspace is equal to the nullspace, for example
$$A = \begin{pmatrix}0 & 1 \\ 0 & 0\end{pmatrix}$$
However, for diagonalizable matrices (such as the one in consideration), we can present a relatively simple view. If you have not learned about diagonalization yet, then it may be difficult to follow the next bit. I recommend that you continue with your studies for now; diagonalization is typically not far away once you've begun studying eigenvectors and eigenvalues. You can come back to the next part after you've learned about diagonalization.
When your matrix is diagonalizable, you can effectively view the matrix as a sequence of scalings along the standard axes (via a change of basis). With this viewpoint, we can effectively look at $A$ as a linear transformation in 3-space where the $x$-axis is stretched by a factor of $3$ (representing the basis vector $\mathbf{v}$), where the $y$-axis is stretched by a factor of $5$ (representing $\mathbf{w}$), and where the $z$-axis is compressed (representing $\mathbf{u}$).
From this viewpoint, the statement that $\mathbf{u}$ is not in the columnspace is analagous to the statement that the image of the linear transform does not contain the $z$-axis, but this is intuitively obvious since the mapping compresses $z$. In fact, it's relatively clear from our description that the image of the map is entirely contained within the $z=0$ plane, i.e. the $xy$-plane. This is a representation of the fact that the columnspace of $A$ does not contain any vectors in which $\mathbf{u}$ is a component, i.e. $a\mathbf{v} + b\mathbf{w} + c\mathbf{u}$ is not an element of $\mathrm{col}(A)$ if $c\neq 0$.
Addendum for the supplementary questions by the OP
Question 3: Why consider $c_1\mathbf{v} + c_2\mathbf{w}$ for the columnspace?
The consideration of linear combinations of $\mathbf{v}$ and $\mathbf{w}$ comes from experience with eigenvalues. The key point is the hidden assumption that the matrix is $3\times 3$ which is not stated in the text of the question for some reason. Since $A$ is $3\times 3$ with $3$ distinct eigenvalues, this means that $A$ is diagonalizable, as I mentioned previously. What this means in particular is that the eigenvectors $\mathbf{u},\ \mathbf{v}$ and $\mathbf{w}$ forms a basis for $\mathbb{R}^3$ (assuming $A$ is a real matrix). If we consider some arbitary vector in $\mathbb{R}^3$, then it follows that we can write $\mathbf{x}$ as a linear combination of our basis of eigenvectors or eigenbasis:
$$\mathbf{x} = c_1\mathbf{v} + c_2\mathbf{w} + c_3\mathbf{u}$$
If we then consider the image of $\mathbf{x}$ under $A$, we get
$$A\mathbf{x} = c_1A\mathbf{v} + c_2A\mathbf{w} + c_3A\mathbf{u} = 3c_1\mathbf{v} + 5c_2\mathbf{w}$$
Since our choice of $\mathbf{x}$ is completely arbitrary, it follows that the entire image of $A$, that is the entire columnspace of $A$, is expressible as a linear combination of $\mathbf{v}$ and $\mathbf{w}$. Conversely, the solution for part (a) shows that every such linear combination is indeed in the columnspace.
As for question 4, I'm also not too sure what the solution is trying to do. It seems that part (b) in the question is answered by part (c) in the solution and that part (b) of the solution is completely extraneous. It seems to answer a different question altogether.
Addendum 2 in response to OP's questions
The fact that $\mathbf{u}\notin \mathrm{span}(\mathbf{v},\ \mathbf{w})$ comes simply from the fact that $\{\mathbf{u},\ \mathbf{v},\ \mathbf{w}\}$ is a linearly independent set. Certainly you can recast the argument so that contradiction is not used, and here is one example of a proof using the contrapositive instead of contradiction. This proof makes it clear that the result follows essentially from the definition of linear independence.
Theorem: Suppose that $\{\mathbf{v}_1,\ \cdots,\ \mathbf{v}_n\}$ is a linearly independent set of vectors. Then $\mathbf{v}_1 \notin \mathrm{span}(\mathbf{v}_2,\ \cdots,\ \mathbf{v}_n)$.
Proof: The contrapositive of the statement is: Suppose that $\mathbf{v}_1 \in \mathrm{span}(\mathbf{v}_2,\ \cdots,\ \mathbf{v}_n)$. Then $\{\mathbf{v}_1,\ \cdots,\ \mathbf{v}_n\}$ is linearly dependent.
But this is essentially trivial. The fact that $\mathbf{v}_1 \in \mathrm{span}(\mathbf{v}_2,\ \cdots,\ \mathbf{v}_n)$ means there exists some linear combination of $\{\mathbf{v}_2,\ \cdots,\ \mathbf{v}_n\}$ adding up to $\mathbf{v}_1$, i.e. there exists scalars $\{c_i\}$ such that
$$\mathbf{v}_1 = c_2\mathbf{v}_2 + \cdots + c_n\mathbf{v}_n$$
But then we also have
$$-\mathbf{v}_1 + c_2\mathbf{v}_2 + \cdots + c_n\mathbf{v}_n = \mathbf{0}$$
which is a non-trivial linear combination of $\{\mathbf{v}_1,\ \cdots,\ \mathbf{v}_n\}$ adding up to the zero vector. By definition, this means that $\{\mathbf{v}_1,\ \cdots,\ \mathbf{v}_n\}$ is linearly dependent. $\square$
Applying this result to the set $\{\mathbf{u},\ \mathbf{v},\ \mathbf{w}\}$ gives the desired result.
Note that the above argument works for any set of linearly independent vectors. However, we can also take advantage of the fact that $\{\mathbf{u},\ \mathbf{v},\ \mathbf{w}\}$ are eigenvectors under distinct eigenvalues to prove that they are linearly independent. This results in the well known theorem that eigenvectors corresponding to distinct eigenvalues are linearly independent. The proof of this fact is available in many, many locations and so I will not reproduce it here. I simply wanted to let you know of an alternative approach which you may prefer instead.
Comment: +1. Thank you very much for your sterling detailed and helpful answer. I'd be grateful for your superlative attention and help towards my supplementary questions in my OP. If possible, would you please answer in your answer and not as a comment?
Comment: @LePressentiment I've tried to answer your supplementary questions. Next time, please consider starting a new question and simply referencing the old. As for your question 4, I am also quite confused as to what the solution is trying to do. It seems extraneous to me.
Comment: Thank you profoundly again! Did you mean to write $\mathbf{v, w}$ where I inserted red brackets? Please feel free to revert the edit. Lastly, I apprehend your 2nd paragraph but is it possible to intuit $u \notin span\{v, w\}$ without contradiction? Would you please recast it as a direct natural argument?
Comment: @LePressentiment I did mean to write $\mathbf{v}$ and $\mathbf{w}$, thanks for catching that typo. I've also added a section addressing your new question.
Comment: Thank you profoundly for your continual care. Please maintain your supernal contributions and beneficence, which I'm grateful
for and cherish.


Build status icon for multibranch pipeline

Question: Can some one please provide details on How Build Status icons can be used in MultiBranch Pipeline to Put as a link on Github Pull request.
As multibranch pipeline has different PR builds, what is the right way to form the build status url in this case and link it to a PR?
Answer: Got it working.
As multi branch pipeline can have different branches for each PR, You need to explicitly specify the PR branch id in your Build status command in order to get it working.
See reference below:
<code>[![Build Status](https://jenkins.com/buildStatus/icon?job=folder/job/PR-id&build=1)](https://jenkins.com/job/folder/job/PR-2338/1/)</code>
You can make this URL part of PR in order to see the real time status of your build.


How is the confidence interval calculated for the ACF function?

Question: For example, in R if you call the acf() function it plots a correlogram by default, and draws a 95% confidence interval. Looking at the code, if you call plot(acf_object, ci.type="white"), you see:
qnorm((1 + ci)/2)/sqrt(x$n.used)

as upper limit for type white-noise. Can some one explain theory behind this method? Why do we get the qnorm of 1+0.95 and then divide by 2 and after that, divide by the number of observations?
Comment: FWIW, this isn't really about R.
Answer: In Chatfield's Analysis of Time Series (1980), he gives a number of methods of estimating the autocovariance function, including the jack-knife method. He also notes that it can be shown that the variance of the autocorrelation coefficient at lag k, $r_k$, is normally distributed at the limit, and that $\operatorname{Var}(r_k) \sim 1/N$ (where $N$ is the number of observations). These two observations are pretty much the core of the issue. He doesn't give a derivation for the first observation, but references Kendall & Stuart, The Advanced Theory of Statistics (1966).
Now, we want $\alpha/2$  in both tails, for the two tail test, so we want the $1−\alpha/2$
quantile. Then see that
$(1+1−\alpha)/2=1−\alpha/2 $
and multiply through by the standard deviation (i.e. square root of the variance as found above).
Comment: Good answer but this doesn't discuss the part of the question about why (0.95+1)/2 (or whatever other value ci takes); that's not really enough for a separate answer, I think, so I'll mention it here: That's simply because we want $\alpha/2$ in both tails, so we want the $1-\alpha/2$ quantile. and then see that $(1+1-\alpha)/2=1-\alpha/2$. (Robert: if you want to incorporate something along these lines into your answer please go ahead)
Comment: Hi Glen_b, I have tried to update my answer accordingly - I have also borrowed some of your words, which I hope is okay.


Relevancy of order statistics to the roll-and-keep dice mechanic?

Question: Throw $x$ dice, each of which has $z$ sides, keep the $y$ highest values rolled, and find their sum $s$. In roleplaying games, this is called a "roll and keep dice mechanic" and notated "$x$d$z$k$y$" or perhaps just "$x$k$y$" if the number of sides $z$ is understood. Let (capital) $S$ be the random variable for the sum of the $y$ highest dice, and let (lower case) $s$ be the observed sum of the $y$ highest dice.
A combinatorial formula for the probability mass funtion $f$ for this distribution was derived by a user called "techmologist" over at PhysicsForums: Puzzling "roll X dice, choose Y highest" problem.
The pmf is
$ f(s) = $
$$\sum_{r=1}^{z}\sum_{i=0}^{x-y}\sum_{j=x-y-i+1}^{x-i}{x \choose i,j,x-i-j}(r-1)^i N(s+i+j-x-ry; x-i-j, z-r-1) $$
where $N$ is the number of ways to distribute $B$ indistinguishable balls among $C$ cells so that each cell has between 0 and $D$ balls, namely,
$$ N(B;C,D) = \sum_{k=0}^{\lfloor B/(D+1) \rfloor} (-1)^k \binom{C}{k} \binom{B-k(D+1) + C-1}{C-1}  $$
My intuition is that there might be a simpler way to express this mechanic using order statistics. Let $Z_1,Z_2,\ldots,Z_x$ be the unordered random variables for the $x$ iid dice throws, which are each discrete uniform distributions on the integer values $\{1, 2, \ldots, z \}$. And let $1 \leq Z_{1:x} \leq Z_{2:x} \leq \ldots \leq Z_{x:x} \leq z$ be the order statistics, so that for example, $Z_{x:x}$ is the r.v. representing maximum roll of the $x$ dice.
In support of my intuition, it can be shown that
$ E(S) = E(Z_{(x-y+1):x} + Z_{(x-y+2):x} + \ldots + Z_{(x-1):x} + Z_{x:x}) $
For instance, for the 4d6k3 distribution, the mean is 15869/1296 (or 12.2446). And this can be verified (quite easily in Mathematica) by using either techmologist's cominatorial formula or by using the expected value of the sum of the three highest order statistics shown above or by enumerating all outcomes or by simulating a large number of dice throws.
However,
$ S \not= Z_{(x-y+1):x} + Z_{(x-y+2):x} + \ldots + Z_{(x-1):x} + Z_{x:x} $ (WRONG)
EDIT: Thanks to Douglas Zare for explaining that the LHS and RHS are in fact equal... This helped me realize that my real confusion was that the pmf of S cannot be calculated easily by taking the convolution of the pmfs of the second through fourth order statistics, because the order statistics are not independent RVs. And that leads to a follow-up question: In a case like this, how would you find the convolution of the pmfs of the order statistics on the RHS, given that order statistics are not independent RVs? I will think about a better way to phrase this question and post it separately. Thanks again!
The question is whether my intuition is correct: Is there some way to express the pmf $f$ of $S$ in terms of the pmfs of the order statistics? And if not, what's wrong with my intuition that there should be some easy way to calculate the pmf $f$ from the pmf of the  order statistics?
BTW, this isn't homework. I'm just a roleplayer, not a statistician, trying to satisfy my curiosity whether this dice mechanic can be analyzed and expressed more simply using order statistics.
Comment: Related: http://stats.stackexchange.com/q/30585/2970
Comment: If you are not familiar with them, this is also related to what are known as $L$-functions, i.e., linear combinations of order statistics. :)
Comment: $S = Z_{(x-y+1):x}+ ... + Z_{x:x}$. I'm not sure why you say they are not equal. Since they are not independent, you can't determine the distribution of $S$ from the distributions of the order statistics from this equation, but it is still true that the sum of the $3$ highest dice is the highest die plus the second highest die plus the third highest.
Comment: One quick way to see that the distribution you compute for the RHS is incorrect is that the probabilities are not of the form $\text{integer}/6^4$.
Answer: The relationship is simple: $S = Z_{(x-y+1):x} + ... + Z_{x:x}$. This should make logical sense: The sum of the top $k$ dice is the highest die plue the second highest die etc. down to the $k$th highest die. If you still believe $S \ne Z_{(x-y+1):x} + ... + Z_{x:x}$, try to exhibit a roll of the dice so that the sum of the top $k$ dice is not equal to the highest die plus the second highest etc. plus the $k$th highest.
Order statistics are only independent for trivial constant distributions. They are not independent here. Since the summands are not independent, you can't use TransformedDistribution in Mathematica. See the documentation which says "TransformedDistribution
represents a transformed distribution where , , ... are independent and follow the distributions , , ...." This is why the distribution you calculate for the right hand side is not correct.
Because of the dependence, you can't determine the distribution of the sum from the distributions of the summands. The same is true in much simpler cases. If $X_0$ and $X_1$ are both $1$ with probability $1/2$ and $0$ with probability $1/2$, then it is possible that $X_0 = 1-X_1$ so that $X_0 + X_1$ is the constant $1$. It is also possible that $X_0 = X_1$ so that $X_0+X_1$ is $0$ with probability $1/2$ and $2$ with probability $1/2$. It is also possible that $X_0$ and $X_1$ are independent so that $X_0+X_1$ takes the values $0,1,2$ with probabilities $1/4,1/2,1/4$, respectively.
Nevertheless, $S = Z_{(x-y+1):x} + ... + Z_{x:x}$. Expectation is linear regardless of whether the terms are independent, so $E(S) = E(Z_{(x-y+1):x}) + ... + E(Z_{x:x})$.
I've thought about expressing the distribution of $S$, and I keep getting the same expression that techmologist did (with the corrected upper bound I edited in). Order statistics for discrete distributions are messy, so I don't expect to find a big simplification by using them.


Sequence convergence with inequality

Question: Find the limits:

$$lim_{n \to \infty} \frac{n^4 -n^3}{e^n}$$

My Attempt:
using L'Hospital's rule I got that the limit equals to $0$.

(1) the sequence $a_n$ given by:
  $$a_n = \int_{1}^{t} e^{-nx} x^3 dx, \ n=1,2,\ldots $$

then $a_n$ is the function value $F(n)$, as:
$$F(t) = \int_{1}^{t} e^{-nx} x^3 dx$$

(2) use the mean value theorem on the function $F(t)$ in the interval $[1,n]$ to show that: $$\frac{a_n}{n-1} = e^{-nc} c^3, \ c\in (1, n)$$

My Attempt:
I think I'm able to show this. Is it correct that $f(b)-f(a) = f(b) = a_n$ because $f(a) = o$ (integral from 1 to 1)?

(3)  why is $$e^{-nc} c^3 (n-1) \le e^{-n} n^{3} (n-1), c\in (1,n) $$

My Attempt:
 Need help, I don't know how to approach this. What is the role of $c$ here?

(4) Use the inequality to show that the sequence $a_n$ converges, and find the limit: $lim_{n\to \infty} a_n$

My Attempt:
(4) Not sure what to do here, maybe I have to solve (3) first.
Answer: For (3), it's very simple:

$c>1$ implies $-nc<-n$, and as the exponential is an increasing function, $\mathrm e^{-nc}<\mathrm e^{-n}$.
the  $x^3$ function is also increasing, so $ c<n$ implies $c^3<n^3$

As these inequalities involve only positive numbers, we can multiply them to get
$$e^{-nc}c^3<e^{-n}n^3,$$
and there only remains to multiply both sides by the positive number $n-1$.
Comment: Thank you, I was thinking way to complicated as I usually do when I'm stuck. And since the right side of the inequality converges to 0 (task 1), then $lim_{n\to \infty} a_n = e^{-nc} c^3 (n-1)$ = left side of inequality must converge to 0 (task 4) as well since it is a positive smaller number?

Sequence convergence with inequality


intellij - setting to replace the caret at the beginning of each line with correct indent

Question: I am looking for the setting that forces the caret to placed at the beginning of each line. Currently if I click anywhere, the caret gets positioned there. It is not the behavior I like, I would like it to be replaced, in order to prevent me to do it incorrectly. I think it is an option commonly used, and was standard in the intellij I became in some other company but I am bad at describing it.
Sorry for my approximative vocabulary and thanks for any hint.
Comment: you can move it to the start of the line by pressing the home key https://www.jetbrains.com/help/idea/basic-editing.html and can enable or disable placing carets at the end of each line. https://www.jetbrains.com/help/idea/general.html#after_end
Comment: home key works, but how can I make it automatic ? I want to make sure that the caret is never misplaced.
Answer:
Go to File → Settings
On the left pane, expand Editor, then select General.
Find the Virtual Space section, and uncheck "Allow placement of caret after end of line".


ScriptManager.RegisterStartupScript e a Key

Question: Boa tarde,
Queria entender como funciona essa Key, tenho uma função no aspx que necessito no code-behind, mas quando a chamo com uma Key estática, colocando csname = "x"; Ela só é chamada uma vez, mas preciso que seja chamada quantas vezes for necessário, daí tentei colocar o nome como variável e ela nunca é chamada, mesmo sem o if (!Page.ClientScript.IsStartupScriptRegistered(Page.GetType(), csname))
Eis o código, este código coloca os itens em um mesmo row de uma gridview, depois ele verifica se colocará o ícone de Expand naquele row, para que o mesmo possa ser expandido quando clicarmos no ícone.
protected void gvProduct_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HyperLink hlProcesso = (HyperLink)e.Row.FindControl("hlProcesso");
            GridView gvRepetidos = (GridView)e.Row.FindControl("gvRepetidos");
            DataTable dtNew = dtFormsFilhos.Clone();
            bool isRepetido = false;

            foreach (DataRow row in dtFormsFilhos.Rows)
            {
                if (row["ProcessoFilho"].ToString().Contains(hlProcesso.Text))
                {
                    dtNew.Rows.Add(row.ItemArray);
                    isRepetido = true;
                }
            }

            if (isRepetido)
            {
                //se coloco o csname como "x" ou "inclui", funciona 1x
                //mas se coloco como está, não funciona. Não entendo como essa key funciona!
                string csname = hlProcesso.Text.ToString();
                string cstext = "IncluiExpand('" + hlProcesso.Text + "')";
                if (!Page.ClientScript.IsStartupScriptRegistered(Page.GetType(), csname))
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), csname, cstext, true);
            }

            gvRepetidos.DataSource = dtNew;
            gvRepetidos.DataBind();
        }
    }

Answer: Finalmente consegui!
Ao invés de ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), csname, cstext, true);, coloquei this.Controls.Add(new LiteralControl(""));
Nem precisa daquele if pra ver se o controle já existe, no meu caso.


solve $\sqrt{z^2+4t}=w$ for $z\in\mathbb C$

Question: Let $t\ge0$ and $z,w\in\mathbb R$. We obviusly find the two solutions $z=\pm\sqrt{w^2-4t}$ when we solve $\sqrt{z^2+4t}=w$ for $z$. But are there more solutions Wien $z,w\in\mathbb C$ instead? Howard do we approach this?
Answer: Square root is generally defined to be a number, which squared, gives the thing below the root. So your equation is essentially equivalent to
$$z^2+4t=w^2.$$
Because we want to solve it for $z$ and $t$ and $w$ are treated as known parameters, we can conveniently rewrite the equation into
$$z^2=w^2-4t,$$
and we just need to take this square root of the right hand side. Every complex number has $2$ square roots except the $0$ which has only one square root - itself. All you need to check is whether or not $w^2-4t$ is equal to $0$. That tells about the number of solutions. Finding the actual square root in the complex field is a method. And there are surely many methods to do it. The ones that are specifically designed for complex case and are meaningless in the real case are maybe the ones in which we represent complex numbers as expressions with real parameters, such as $z=a+ib$ or $z=re^{i\varphi}$ ($a,b,r$ and $\varphi$ are real numbers). Then the square root of $z$ is reduced to square roots of real numbers which you are familiar with: $z=\sqrt{r}e^{i\frac{\varphi}{2}}=\sqrt{r}(\cos(\frac{\varphi}{2})+i\sin(\frac{\varphi}{2}))=\sqrt[4]{a^2+b^2}e^{\frac{i}{2}\arctan(\frac{b}{a})}.$ You can simplify the expressions of course.


Stepbased division algorithm.

Question: Assume that I have already calculated the integer division $\frac{p}{q}$ so that I have both integer part and rest a.k.a. "modulus": $$\cases{\left\lfloor\frac{p}{q} \right\rfloor = n\\p \equiv m\,\,\,(\text{mod } q)}$$
Now, say I want to calculate the same for $q+d$, where $d\lt\lt q$. Is there some faster way than just to do the full euclidean algorithm from scratch..?
Answer: Consider the equation $$nq = p$$
If we for a second allow all quantities to take any real number, we can, assuming (which is given in the question) that $p$ is constant, rewrite $n$ as a function of $q$:
$$n(q) = \frac{p}{q}$$
Now if we calculate $$\frac{\partial n}{\partial q} = - \frac{p}{q^2}$$
We have an expression for how fast $n$ should change with the change of $q$. Now, this function we can tabulate. Actually might be more practical to tabulate $$-\frac{1}{q^2}$$
Now we we can make an estimate for how large a step we should take in the $n$ direction for each step of length 1 in the $q$ direction. It should be $-\frac{p\Delta p}{q^2}$. Assuming we have made the tabulation above to some precision, this can be done by 3 multiplications. Possibly we will need some interpolation on the table for better precision, but that can once again be done division-free, usually as linear combination of low order polynomials.
For example a small portion of primes: $\left[\begin{array}{cccccccc}83&89&97&101&103&107&109&113\end{array}\right]$ and we are to test the primality of a number the magnitude of $10^6$. $$\frac{\partial n}{\partial q} = - \frac{10^6}{(10^2)^2} \approx -100$$
With some interpolation and deploying central difference estimate for differential we get estimates
$$\begin{array}{cccccccc}[ -811.25 & -924.96 & -408.12 & -192.23 & -362.81 & -171.47 & -324.65 ]\end{array}$$
Which are rather close to the correct $\Delta q$:
$$ \begin{array}{cccccccc}[ -812.24 & -926.68 & -408.29 & -192.25 & -362.94 & -171.48 & -324.75]\end{array}$$

Even if we would not get very close, modern CPUs have instructions in hardware both to calculate multiply+add and then $$\min_{i}|a-b_i|$$ for 8 or 16 $i$ at a time. That means in practice an ability to determine 3 or 4 additional bits of precision for a number per clock cycle!

Stepbased division algorithm.


Meaning of arm loader script

Question: OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_ram_entry)
SECTIONS
{
    . = 0xA0008000;

    . = ALIGN(4);
    .text : { *(.text) }

    . = ALIGN(4);
    .rodata : { *(.rodata) }

    . = ALIGN(4);
    .data : { *(.data) }

    . = ALIGN(4);
    .got : { *(.got) }

    . = ALIGN(4);
    .bss : { *(.bss) }
}

I get the output_format, output_arch, entry... maybe meaning that the output will be as elf32-littlearm and so on.
But the Sections part is what I don't get.
this '. =' is the start.
and '. = ALIGN(4)' and .text : { *(.text) } ....
can anybody help me on this T_T
thanks for reading.
Answer: Actually, this linker description language is defined in the documentation for ld last I checked.  It's not as bad as it looks.  Basically, the '.' operator refers to the "current location pointer".  So, the line
. = 0xA0008000

says move the location pointer to that value.  The next entry, .text, basically says place all text objects into a .text section in the final ELF file starting at the location pointer (which is also adjusted to have a 4-byte (32-bit) alignment.)  Note that the first use of the ALIGN is probably redundant since 0xA0008000 is already 32-bit aligned!
The next sections simply instructs the linker to emit the collection of all .rodata, .data, .got and .bss sections from all input objects into their final respective sections of the ELF binary in order, starting at 32-bit aligned addresses.
So the final ELF binary that the linker produces will have those five sections respectively and sequentially.  You can see the structure of that final ELF binary using the readelf utility.  It's quite useful and helps to make sense of all of this stuff.  Usually there is a cross-version of readelf, something like arm-linux-gnueabi-readelf, or whatever prefix was used to generate the compiler/linker you are using.  Start with readelf -S to get a summary of the sections that your ELF file contains.  Then you can explore from there. Happy reading!
Answer:     . = 0xA0008000;

I think, but I'm not 100% sure, is where the arm will start executing the binary
    . = ALIGN(4);

defines how to align the following instruction.
.text, .data, .rodata, .got and .bss are the sections of the program. text is for instructions, data and rodata for initialized data sections and bss for uninitialized data section. got is global offset table.
    .text : { *(.text) }

This copies all the instructions, similar commands are for data and global offset table.
Comment: what do u mean about 'this copies all the instructions'? Is it like, it alignes all the data(instructions + data)????
Comment: I mean it puts the instruction starting from a 4 byte aligned address, the it puts all the data and so on...

Meaning of arm loader script


Carregar Spinner vazio

Question: Ao gerar um Spinner, ele trás o primeiro valor do ArrayList gerado já selecionado.
Como faço para trazê-lo "vazio" ?
A melhor opção seria populá-lo com uma função onClick ao invés de fazer isso no onCreate, por exemplo ?
Answer: Você pode adicionar um campo vazio antes de popular com o array, este mesmo index sendo 0 você pode usar também como validação caso o usuário não tenha selecionado nenhuma opção.
Exemplo:
ArrayList<String> meuArray = new ArrayList<>();
meuArray.add("");

//Popular array

mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        if (position == 0)
            //Não selecionou
        else
            //Selecionou
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {

    }
});

Espero que ajude.

Carregar Spinner vazio


What is this bass belt strap?

Question: I have never seen a bass belt strap like this:

My guess would be that it is kind of safer than the normal strap, but I'm not sure
Can I use a normal belt? Do I need some kind of special belt?
Comment: A lot of them are designed so an ordinary strap will still fit. Guitar and bass use the same thing. Some tie-clips from the past used the same sort of mechanism.
Comment: Here are some more pics: [Dropbox](https://www.dropbox.com/sh/kc14u5weip7kv2g/AABmeNDTnD7GLSrN-Yq58Mwua?dl=0)
Comment: In fact, a traditional [I mean really old style] clip-on beer bottle top rubber surround is almost as good. Grolsch used that old-style bottle for quite some time, all my other guitars have the 'rubber ring' strap lock - one free with every beer ;)
Answer: It's a strap-lock, unfortunately without the corresponding locking part.

Mine on my old Rikki are Schaller, same as this, though no doubt there are other makers.
From comments, a Grolsch beer bottle 'rubber washer' from their old-fashioned bottle tops makes a great free substitute
Comment: They do look like a 'copy' yes, without the chamfered edge. Mine are definitely the ones in the picture above. (I've had them 30 years & the strap never came off without me telling it to;) Functionally the same, I'd guess - but unlikely to be interchangeable.
Comment: The images in the question are rather poor, but they don't seem to be the classic Schaller's you've posted. But it's definitely some system like it.
Comment: Can I buy just the top part of a new one? Or a whole new one and just replace the top part?
Comment: Also, I use a normal belt, right?
Comment: You'd have to figure out what make it is - yours doesn't look interchangeable with the Schaller. I haven't looked, but my guess would be they all come as a complete kit. It's only a case of unscrewing one pair of buttons & screwing in the other; even if the threads don't quite match, either re-using the old screws, or a bit of wood filler would sort it. I actually had zero difficulty when I swapped mine, all those years ago.
Comment: Normal strap, yes. The 'lock' part goes through the regular hole at each end & then you just add the metal washer & tighten it down with the nut. In use, the strap just hooks onto the button & clicks in - slightly different move to a regular strap but takes an whole minute to get used to it ;) It will only come off again if you pull the knob that sticks out the top.
Comment: The only downside is that a normal strap can be used on strap-lock buttons, but once you fasten the locks to a strap, you can only use it on a strap-lock guitar

What is this bass belt strap?


Getting started with the c++ taskflow library

Question: I have tried out the taskflow librabry https://github.com/taskflow/taskflow for c++ and got one most basic program running. Next, I wanted to adopt this example https://www.cs.cmu.edu/~15210/pasl.html#_parallel_fibonacci of calculating Fibonacci numbers while using the taskflow library.
Now, I get a error message which I don't understand. Maybe you people here can help me.
The eror message says:
abort() has been called

(Press Retry to debug the application)
Ausnahme ausgelöst bei 0x760A4402 in TestTaskFlow.exe: Microsoft C++-Ausnahme: std::system_error bei Speicherort 0x220BE0F0.
TestTaskFlow.exe hat einen Haltepunkt ausgelöst.

Translation:
Exception thrown at 0x760A4402 in TestTaskFlow.exe: Microsoft C++-Exception: std::system_error at memory 0x220BE0F0.
TestTaskFlow.exe has triggered a breakpoint.

My code looks like this:
#include <iostream>
#include <stdio.h>

#include <taskflow.hpp>

/*
F(n) = F(n-1) + F(n-2)
*/

// parallel calculation of F(n)
long fib_par(long n) {
    long result;
    if (n < 2) {
        result = n;
    }
    else {
        tf::Taskflow tf;
        long a, b;

        tf::Task taskA = tf.emplace([&]()
            {
                a = fib_par(n - 1);
            }
        );

        tf::Task taskB = tf.emplace([&]()
            {
                b = fib_par(n - 2);
            }
        );

        tf::Task taskResult = tf.emplace([&]()
            {
                result = a + b;
            }
        );

        taskA.precede(taskResult);
        taskB.precede(taskResult);

        tf::Executor().run(tf);
    }

    return result;
}

int main() {
    int n(40);

    long par = fib_par(n);

    return 0;
}

So the question is: What am I doing wrong?
Thank you.
Comment: Start your program in a debugger and find out the line of the of the crash and the stacktrace.
Comment: I would say is a bad idea to put  tf::Taskflow tf inside your function. As far as there is no debugging details I am there is no way to tell what is exactly the problem. Even more it is specific to taskflow.
Answer: The problem is that you are recursively creating Taskflow and Executor instances. The executor manages the workers and the task queue, creating separate instances for each call means there is no overall management of the tasks. Each executor will create at least one worker and the number of workers created will be >= n!. And by creating separate taskflows the executors can't see the overall graph, all they can see are the three tasks.
There is a fibonacci example in taskflow handbook now. I rewrote the example to use your variable names and stripped out the graph printing.
int fib_par(int n, tf::Subflow &sbf) {
    if (n < 2) return n;
    int a, b;
    sbf.emplace([&a, n](tf::Subflow &sbf) {
        a = fib_par(n - 1, sbf);
    });
    sbf.emplace([&b, n](tf::Subflow &sbf) {
        b = fib_par(n - 2, sbf);
    });
    sbf.join();
    return a + b;
}

int main(int argc, char *argv[]) {

    int n = 10;
    int par;

    tf::Executor executor;
    tf::Taskflow taskflow;
    taskflow.emplace([&par, n](tf::Subflow &sbf) {
        par = fib_par(n, sbf);
    });

    executor.run(taskflow).wait();

    std::cout << "Fib[" << n << "]: " << par << std::endl;

    return 0;
}

The key here is the use of dynamic tasking. emplaceing a callable that takes a tf::Subflow parameter creates a dynamic task which can extend the task graph by creating sub-graphs. This is all managed by the single executor declared in main, which becomes aware of the new preceding tasks with the call to sbf.join() in fib_par.


How to prove that a subset of an ordinal is an element of the ordinal by transitivity.

Question: I'm reading Jech's set theory, and in chapter two (page 19) in defining ordinals it states

a set is transitive if $\alpha \in \beta \implies \alpha \subset \beta $

it then defines an ordinal as a transitive set well ordered by $\alpha \in \beta \Leftrightarrow \alpha <\beta $
It then goes on to state that if $\alpha,\beta$ are ordinals and
$\alpha \subset \beta$ such that $\alpha \not= \beta$ then $\alpha \in \beta$.
It proves this by saying take $\gamma$ to be the least element of $\beta - \alpha$ then $\alpha$ is the segment of $\beta$ given by $\gamma$, using transitivity.
I'm wondering how we can rule out that there's some $x \in \alpha$ such that $x > \gamma$, so that even though the set $s_\gamma=\{ y | y <\gamma \}$ is contained in $\alpha$ (by the fact that gamma is the least element of $\beta-\alpha$), perhaps $\alpha \not\subset s_\gamma$.
Comment: You must be assuming that $\alpha$ is itself an ordinal here, right?
Comment: If we had that, we'd have $\gamma \in x \in \alpha$. But $\alpha$ is an ordinal, hence transitive. So $\gamma \in \alpha$, a contradiction.
Comment: Yes, I'm gonna edit to clarify that.
Answer: If we had that, we'd have γ ∈ x ∈ α. But α is an ordinal, hence transitive. So γ ∈ α, a contradiction.
Answer: Let $\gamma$ be the least element of the set $\beta - \alpha$. Then each $\delta ∈ \gamma$ is an element of the set $\alpha$. If not, $\delta$ is a element of the set $\beta - \alpha$ by transitivity of $\beta$, and is smaller than $\gamma$, a contradiction.
Conversely, each $\delta ∈ \alpha$ is an element of $\gamma$. If not, $\gamma$ is an element of an element of $\alpha$ by well-ordering, and $\gamma ∈ \alpha$ by transitivity of $\alpha$, a contradiction.
So, $\alpha = \gamma ∈ \beta$.


How to add a card widget dynamically whenever floating action button is clicked in flutter?

Question: I am very new to flutter and was just curious to know how can we create a new card widget everytime a button (lets say FAB) is clicked.
Suppose this is the card widget :
return Card(
 child: Column(
  children: [
  Text('name'),
  Text('standard'),
  Text('Roll No'),
    ],
   ),
 );

I want the cards to build with the same content everytime the FAB is clicked. Can someone help me with this ?
Comment: You need to check about 'listsview' state full widget and set state.
Answer: First declare a List of widget type
List<Widget> _cardList = [];

Then create your widget which you want to add on button click, e.g.
  Widget _card() {
    return Card(
      child: Column(
        children: [
          Text('name'),
          Text('standard'),
          Text('Roll No'),
        ],
      ),
    );
  }

add your widget in List on button click
FloatingActionButton(
            child: Icon(Icons.add),
            onPressed: () {
              setState(() {
                _cardList.add(_card());
              });
            },
          ),

Now use a ListView.builder for create a list of widget
 ListView.builder(
      shrinkWrap: true,
      itemCount: _cardList.length,
      itemBuilder: (context, index) {
        return _cardList[index];
      },
    )

Comment: just use remove method of array like this ` _cards.removeAt(index)`
Comment: You have index of every item in list view, just store whatever index you want to remove in separate variable and use this index in removeAt parameter.
Comment: Thanks it worked. Any idea regarding how can we remove the cards that we want ?
Comment: I got your idea but here the problem is that the card widget is defined outside the class. So, setState() can't be used. I had given a cancel icon at the right of the card but i can't use the cardList because it is not defined here. Any suggestions ?


Erro Laravel / linha 24

Question: Estou com um problemao, com esse arquivo .Esse erro persiste apenas nessa linha,na maioria dos arquivos que abro da isso.
Eu queria poder saber oque exatamente errado para eu aprender e corrigir.
Da esses seguintes erro,e a linha do erro é extamente essa
CODIGO COM ERRO:
require __DIR__ . '/../vendor/autoload.php';

CODIGO ATÉ UMA PARTE
<?php

/**

 * Laravel - A PHP Framework For Web Artisans

 *

 * @package  Laravel

 * @author   Taylor Otwell <firstname.lastname@example.com>

 */

define('LARAVEL_START', microtime(true));

/*

|--------------------------------------------------------------------------

| Register The Auto Loader

|--------------------------------------------------------------------------

|

| Composer provides a convenient, automatically generated class loader for

| our application. We just need to utilize it! We'll simply require it

| into the script here so that we don't have to worry about manual

| loading any of our classes later on. It feels great to relax.

|

*/

require __DIR__ . '/../vendor/autoload.php';

/*

|--------------------------------------------------------------------------

| Turn On The Lights

|--------------------------------------------------------------------------

|

| We need to illuminate PHP development, so let us turn on the lights.

| This bootstraps the framework and gets it ready for use, then it

| will load up this application so that we can run it and send

| the responses back to the browser and delight our users.

|

*/

Comment: O Laravel por defeito utiliza a pasta public você parece estar a utilizar a pasta public_html
Comment: Porque está mexendo na pasta, nas configurações? Qual o motivo pertinente pra fazer isso?
Comment: Eu não estou mexendo,eu coloquei no local host,e esta apresentando esse erro,logo eu vi que seria essa linha
Comment: já executaste o comando `composer install`?
Answer: Olá,
Antes de executar sua aplicação você deve instalar suas dependências, neste caso aparentemente falta instalar as dependências do composer execute composer install deverá resolver seu problema.
Comment: Poderia me ajudar? Achei que já estava configurado isso já. Essas dependências. Onde eu executo o composer install ? na posta do meus arquivos ou uma especifica?

Erro Laravel / linha 24


Integral representation of Zeta function

Question: Currently studying Complex Analysis and was baffled by the following
$$
\Gamma(s) \zeta(s)=\sum_{n=1}^{\infty} \frac{\Gamma(s)}{n^{s}}=\int_{0}^{\infty} \sum_{n=1}^{\infty} \frac{e^{-t} t^{s-1}}{n^{s}} \mathrm{d} t=\int_{0}^{\infty} \sum_{n=1}^{\infty} e^{-n t} t^{s-1} \mathrm{d} t
$$
How does one obtain the right hand side from the equation before it?
Comment: Change the integration variable from $t$ to $n x$ and then call the $x$ as $t$.
Comment: It does work: $$
\int_0^{ + \infty } {\sum\limits_{n = 1}^\infty  {\frac{{e^{ - nx} (nx)^{s - 1} }}{{n^s }}} (ndx)}  = \int_0^{ + \infty } {\sum\limits_{n = 1}^\infty  {\frac{{e^{ - nx} n^s x^{s - 1} }}{{n^s }}} dx}  \\ = \int_0^{ + \infty } {\sum\limits_{n = 1}^\infty  {e^{ - nx} x^{s - 1} } dx}  = \int_0^{ + \infty } {\sum\limits_{n = 1}^\infty  {e^{ - nt} t^{s - 1} } dt} .$$
Comment: Yes, you are correct, I should have written it like that. One does the substitution before actually moving the summation inside the integral.
Comment: @Gary Doesn't work
Comment: @Gary Didn't do it correctly, my bad. Also, one more question, I'm assuming we can make this substitution because the integral and summation can be exchanged, right?
Comment: @Gary Thanks! If you want to write it out and i'll accept it as the answer.
Answer: The correct way to derive the formula is
\begin{align*}
\Gamma (s)\zeta (s) = \sum\limits_{n = 1}^\infty  {\frac{{\Gamma (s)}}{{n^s }}}  = \sum\limits_{n = 1}^\infty  {\int_0^{ + \infty } {\mathrm{e}^{ - t} \frac{{t^{s - 1} }}{{n^s }}\mathrm{d}t} }&\, \mathop  = \limits^{t = nx} \,\sum\limits_{n = 1}^\infty  {\int_0^{ + \infty } {\mathrm{e}^{ - nx} x^{s - 1}\, \mathrm{d}x} } \\ &\;\, = \int_0^{ + \infty } {\sum\limits_{n = 1}^\infty  {\mathrm{e}^{ - nx} } x^{s - 1} \,\mathrm{d}x} .
\end{align*}
Comment: How to justify the inversion of sum and integral?
Comment: @Julien Use Tonelli's theorem or the monotone convergence theorem. A sum with positive terms can always be integrated term-wise.
Comment: Here the sequence is complex
Comment: @Julien Assume $s>1$ and use analytic continuation in the end to extend the result to $\operatorname{Re}(s)>1$.


Express [413 too large] with QuillJS image

Question: I am trying to use QuillJS to let the user write a rich text, and then store it as JSON to display later on. There are 2 of these rich text areas in a single form, and may include images. QuillJS encodes images as base64 strings, and my POST request results in 413 by Express.
I have tried to change the limits by adding express json parameters, even trying extreme numbers.
// app.js
//----------------------------------------------------
// Middlewares
//----------------------------------------------------
app.use(express.json({limit: '2000mb'}));
app.use(express.urlencoded({extended: true, limit:'2000mb'}));

Even this did not help and I think it is not logical to let these parameters with such values.
I tried with json and urlencoded enctypes. When I tried to post with multipart/form, req.body was empty.
// My html page (pugJS)

form(enctype='application/x-www-form-urlencoded', action='/editor/page',
     method='POST', onsubmit='return addContent()')

.form-control
        label Content-1
        div#toolbar
        div#editor
        input#content(name='content', type='text',  hidden)

addContent() function that runs before form submit simply changes input#content's value with JSON.stringify(#editor.getContents())
I want to be able to store two quill content in a single database row, to display later.
Answer: I fixed my problem few hours before @argo mentioned and I did it that way. So I wanted to post little bit of detail to the solution. I have been also guided by a github issue but can't seem to find the link again, in case I find it I will edit the post and add it.
// Quill - EN content
var quillEn = new Quill('#editor-en', {
  modules: {
    toolbar: toolbarOptions
  },
  theme: 'snow'
});

// set custom image handler
quillEn.getModule('toolbar').addHandler('image', () => {
  selectLocalImage(quillEn);
});

// create fake input to upload image to quill
function selectLocalImage(editor) {
  const input = document.createElement('input');
  input.setAttribute('type', 'file');
  input.setAttribute('accept', 'image/png, image/jpeg')
  input.click();

  // Listen upload local image and save to server
  input.onchange = () => {
    const file = input.files[0];
    saveImageToServer(editor, file);
  };
}

// upload image to server
function saveImageToServer(editor, file) {
  const fd = new FormData();
  fd.append('image', file);

  const xhr = new XMLHttpRequest();
  xhr.open('POST', '/api/page/upload_image', true);
  xhr.onload = () => {
    if (xhr.status === 200) {
      // this is callback data: url
      const url = JSON.parse(xhr.responseText).data;
      insertToEditor(editor, url);
    }
  };
  xhr.send(fd);
}

// manipulate quill to replace b64 image with uploaded image
function insertToEditor(editor, url) {
  // push image url to rich editor.
  const range = editor.getSelection();
  editor.insertEmbed(range.index, 'image', url.toString());
}

In the backend where you POST image, you must return json as { data: FullUrlToImg } with 200 response, if you want to change your status to 201 or something else, don't forget to update it in saveImageToServer function.
So to summarize, you set custom image handler for your quill editor, you post the image to server as soon as user chooses to insert, then you replace the URL with your uploaded image in the editor.
Thanks.
Answer: A better approach to this would be to overwrite the image upload function and then save the image in Amazon S3 or some cloud server. Then you paste it inside the editor as  This would solve your problem of maximum memory issue.