C - Warning ( passing 2 arguments .. )

Question: I have 2 warnings with my program, how to fix it ?

Warning: expected 'int' but argument is of type 'int *'
Warning: passing argument 2 of 'copie' makes integer from pointer without a cast

Main.cpp
#include <stdio.h>
#include <stdlib.h>

void copie(int tableauOriginal[],int tableauCopie,int tailleTableau);

int main(int argc, char  *argv[])
{
    int tableauOriginal[4]={1,2,3,4};
    int tableauCopie[]= { };
    copie(tableauOriginal,tableauCopie,4);
    int i;
    for (i = 0; i < 4; i++)
        printf("Case: %d\n", tableauCopie[i]);
    return 0;
}

void copie(int tableauOriginal[],int tableauCopie,int tailleTableau)
{

   int i ;
   for (i = 0; i < tailleTableau; i++)
      tableauCopie=tableauOriginal[i];
}

Comment: Because `tableauCopie` in `main` is an array, not an `int`.
Comment: tableauCopie is an array of integers, not an integer...
Comment: The error message is correct. The function expects an int and you give it a pointer. (which is mistreated in the function body, too, but that is a different issue)
Answer: This is an error:
int tableauCopie[]= { };

If your compiler accepts it then it must be a compiler extension - probably creating a zero-sized array. Then you cause undefined behaviour when you write beyond its bounds with copie.
You have to specify the size:
int tableauCopie[4];

You could zero-initialize it with = { 0 }; however that is unnecesary as copie is about to fill it in.
Of course, the copie function should accept the array as int tableauCopie[] - not a single int as you have currently; and its loop should have tableauCopie[i] = tableauOriginal[i];;
Answer: Should be
void copie(int tableauOriginal[],int tableauCopie[],int tailleTableau)

instead of
void copie(int tableauOriginal[],int tableauCopie,int tailleTableau)

Answer: You have declared tableauCopie as an array. And in case of array only base address of array is passed so you should prototype your function as below.
void copie(int tableauOriginal[],int tableauCopie[],int tailleTableau);
or
void copie(int tableauOriginal[],int *tableauCopie,int tailleTableau);
Answer: You should pass array name as pointer:
#include <stdio.h>
#include <stdlib.h>
void copie(int *tableauOriginal,int *tableauCopie,int tailleTableau);

int main(int argc, char  *argv[])
{
    int tableauOriginal[4]={1,2,3,4};
    int tableauCopie[4]= {0};
    copie(tableauOriginal,tableauCopie,4);
    int i;
    for (i = 0; i < 4; i++)
        printf("Case: %d\n", tableauCopie[i]);
    return 0;
}

void copie(int *tableauOriginal,int *tableauCopie,int tailleTableau)
{
   int i ;
   for (i = 0; i < tailleTableau; i++)
      tableauCopie[i]=tableauOriginal[i];
}

Comment: Thank you soo much ! But can you explain me ? please
Comment: There is no problem with passing arrays with brackets. You should then explain why using the pointer notation over the bracket one.
Comment: @user3521273: In C/C++, the array name is used as a pointer. Through the pointer, you can modify the content in the memory.
Comment: @user3521273 If it helped you solve your problem, consider accepting this answer.
Answer: should be as below as tableauCopie is an array.
void copie(int tableauOriginal[], int tableauCopie[], int tailleTableau)
  {
  int i ;
  for (i = 0; i < tailleTableau; i++)
    tableauCopie[i] = tableauOriginal[i];

}

C - Warning ( passing 2 arguments .. )


Right continuity of the cumulative distribution function and an almost sure constant $X$

Question: The dozens of proofs I've seen for showing that a tail sigma-algebra measurable random variable $X$ is almost surely a constant use the infimum $T := \inf \{t \in \mathbb{R}\mid \mathbb{P}[\{X \leq t\} = 1\}$, and state that: "[...] by the right continuity of the cumulative distribution function it follows that $\mathbb{P}[\{X \leq T\}] = 1$ and $\mathbb{P}[\{X < T\}] = 0$".
I have to say that it is not quite clear to me the events $\{X \leq T\}$ and $\{X < T\}$ have the stated probabilities.
Is the following equivalent to the hidden reasoning behind the claimed value $\mathbb{P}[\{X \leq T\}] = 1$?
Let $t_n = T + \frac{1}{n}$.  By right continuity of the CDF we know that if $t_n\downarrow t$, then $F(t_n)\downarrow F(t)$.Then $t_n\downarrow T$, and thus $1 = F(T) \leq F\left(T + \frac{1}{n}\right)\downarrow F(T) = 1$, where I suppose $F(T) = 1$ by definition, even though we are giving the CDF the infimum of a set, so that isn't it possible for $T = \pm \infty$? As for the $\mathbb{P}[\{X < T\}] = 0$, I get that the idea is that as $T$ is the smallest real number (0r $\pm\infty$?) for which $\mathbb{P}[\{X \leq T\}] = 1$ and $F$ takes only the  values of $0$ or $1$, it then follows that for any $t < T: F(t) \neq 1 \implies F(t) = 0$. But I don't know how to show this with some real sequence.
Comment: Do you agree that $P(T-\frac1n)<X<T+\frac1n)=1$ for every positive integer $n$? Taking the intersection we find P(X=T)=1$.
Comment: @drhab That is also a neat way of proving the claim! Do you know was that the intent behind the stated claim (the quote), or is there yet another way of showing that $\mathbb{P}[X < T] = 0$?
Comment: I would go for $\{X<T\}=\bigcup_{n=1}^{\infty}\{X<T-\frac1n\}$. So a countable union of sets that all have probability zero.
Comment: Also $P(X<T)=0$ is a *direct consequence* of $P(X=T)=1$.
Answer: You are right that $T$ might be $\infty$ or $-\infty$. These exceptional cases are easily handled. So assume that $T \in \mathbb{R}$. $F(T) = 1$ is not true by definition. What you know by definition is that if $t < T$, then $F(t) = 0$. To get the full graph of $F$, it remains to prove that $F(T) = 1$. By definition of $\inf$, for any $n > 0$, there exists $t < T + 1/n$ such that $F(t) = 1$. Thus $F(T + 1/n) = 1$ for all $n > 0$. Now letting $n \to \infty$ and using right continuity of $F$ gives $F(T) = 1$.
Since $P(X < T) = \lim_{t \nearrow T}F(t) = 0$, it follows that $P(X = t) = 1$.


Changes in R-squared

Question: I was reading online, and I found that
If the Variance of X increases then the value of R-squared increases
If the Variance of the residuals increases then the value of R-squared decreases
Can someone explain the intuition behind these two statements.
I am generally confused about the impact of variance of X or the residuals on the explanatory power of the regression.
Comment: The relationship between $R^2$  and the spread of the independent variables ($X$) is discussed and illustrated at http://stats.stackexchange.com/questions/13314.  The relationship with the residuals is obvious once you recognize that $1-R^2$ is directly related to the variance of the residuals.
Comment: Especially if it's online, you should link to your source for context.
Comment: It's a general question on the impact of new regressors on R-squared. The website didn't give an example.
Answer: It's best to think in terms of ratios, how much error is explained by $x$, how much is residual.
If we think of a super-simple regression with one independent variable and slope = 1, just $y = x + \epsilon$, then $\mathrm{Var}(Y) =\mathrm{Var}(X) + \mathrm{Var}(\epsilon)$. (Of course, using the assumption that the residual error $\epsilon$ is uncorrelated with $X$.) From that, it's straightforward that as the variance of $X$ increases, so does the variance of $Y$--if you observe a wider range of $X$ values, you'll also observe a wider range of $Y$ values.
However, we assume that the residual error is fixed, it doesn't change with $X$. And we know that R^2 is defined as the ratio of "explained variance" to "total variance". So
$$
R^2 = \frac{\mathrm{Var}(X)}{\mathrm{Var}(Y)} = \frac{\mathrm{Var}(X)}{\mathrm{Var}(X) + \mathrm{Var}(\epsilon)}
$$
And it's pretty clear that, given a fixed value of $\mathrm{Var}(\epsilon)$ as $\mathrm{Var}(X)$ increases the $R^2$ approaches 1.
This extends easily if the slope isn't equal to 1--the important assumption is that $\mathrm{Var}(X)$ and $\mathrm{Var}(\epsilon)$ are uncorrelated.
I find simulation a nice way to understand things too, you can see the effect with the following R code which simulates data for various values of $\mathrm{Var}(X)$ and $\mathrm{Var}(\epsilon)$, fits models, extracts the R squared values, and plots the results in a heatmap.
rsqd <- function(varx = 10, varresid = 3, n = 30, betax = 2) {
    x <- rnorm(n, sd = sqrt(varx))
    y <- betax * x + rnorm(n, sd = sqrt(varresid))
    return(summary(lm(y ~ x))$r.squared)
}

vx <- 1:20
vr <- 1:20

results <- expand.grid(vx = vx, vr = vr)
results$rsq <- numeric(nrow(results))

for (i in 1:nrow(results)) {
    results$rsq[i] <- rsqd(varx = results$vx[i], varresid = results$vr[i])
}

library(ggplot2)
ggplot(results, aes(x = vx, y = vr, fill = rsq)) + geom_tile()

Despite the model always being "right", if the variation in x is small but the residual error is large, the R-squared is quite low (upper left corner). The situation is reversed in the lower right, where the residual error is small compared to the variation of x, and thus compared to the variation explained by x.

Changes in R-squared


Using monthly product usage data to predict customer churn

Question: I've been reading tons of papers detailing methods on predicting customer attrition, but none of them have mentioned using product usage data over time. We keep detailed logs of how many times User A uses X feature in the past month, but I'm not sure how to incorporate these into a predictive model. For example, the model ideally would look at past cancellations and look at their trending behavior a few months before they cancel their contract. Unlike other time series papers I've read, we don't want to predict the customers' usage based on their past usage -- we want to predict whether or not based on present usage, a customer is on track to cancel.
Answer: One option would be to approach this as a classification problem, rather than a time-series prediction problem. Find customers who canceled, and create a feature vector of their usage of each feature, concatenated over several months before cancellation. For example if you had usage data on two features (F1/F2) and three-month window (M1-M3), your feature vector would look like [F1_M1 F2_M1 F1_M2 F2_M2 F1_M3 F2_M3].
Then, you need to mine for many negative examples, by grabbing random three-month windows from customers who did not cancel, and computing the same features.
You can then use any standard machine learning classification machinery (e.g. SVM) to try to find features which discriminate between these two groups. If this has above-chance accuracy, then you can use the decision value of this classifier (how strongly it believes you are in the "cancel" class) as a signal that a user is about to cancel.
Exactly how you set the time window will depend on some intuition about your product. You may also want to try using features from, say only 2-3 months before cancellation and see if you can predict cancellation 1 month ahead of time (which gives you more time to retain that customer).
Comment: You want to give your model examples of "normal" behavior (when cancellation is not imminent) as well as "about-to-cancel" behavior. It could be that usage of certain features tends to oscillate up and down during normal usage, so you'll see decline in feature usage in random windows as well as about-to-cancel windows. Hopefully the model will find some usage pattern that distinguishes about-to-cancel windows from random "normal" windows.
Comment: Currently we're using random forests/ID trees/logit regression to predict based on other features. If a company did not cancel, why does picking a random segment of time work?
Comment: This is a pretty interesting approach. Can you please elaborate on the mining for negative examples?
Answer: I agree with Chris, reducing the churn into a classification problem is a good direction.
I suggest that you will build the classification dataset with respect to the situation your classifier will have to cope with.
In most churn problems you actually have to predict, "Out of the active users today, who will cancel in 30 days".
In order to get such a dataset you can go 30 days before, see who were the active customers back then and label them by whether they canceled.
Of course you can do it with many points in time.
Actually, many time in is beneficial to go deeper into history and decide what is the churn period you should use.
Note that if you had taken all the historical data your classifier will be trained to answer a different question.
I don't think that you should NOT use the entire historical data.
There are many benefits to using it - you get more data, you are less sensitive to seasonality, and so.
However, you should evaluate your classifier on the way it will be evaluated in production. All other  features, classifiers or what ever you will built on different dataset should aid to increase performance on this measure.


Term for One person performing a whole Arrangement with nothing else accompanying (As a Cover)

Question: Like how "Unplugged Version" means the Original Song has been performed with 0 usage of technology-stuff (other than Microphone) [No editing, Acoustic Instruments only, No Faders, No Compressors],
What's the name given to a Version in which One Person is emulating the whole song, playing as many parts he/she can at once?
For example, take Hotel California, one person is playing all the parts written in the below snap.
Well basically a cover but only one person and he/she is playing as many parts possible to bringing in as many elements as possible.
(Hoping the question belongs here, not english.stackexchange.com)
Comment: One man band..?
Comment: "A whole arrangement"?! "Playing all the parts"?! He's singing, playing a guitar and tapping his foot. Anyone can do that! Dylan can probably do any of his songs without a band, AND throw in a mouth organ! It's called doing a song **on your own**.
Comment: @Tim So... if 'One-man-band' is the only word for the performer, I wish to know what the term would be for the performance, like for titling the performance.
Comment: If one person plays, it's technically called a solo.
Comment: @OldBrixtonian , I only took an example, maybe this wasn't a good example.
Comment: "Herb Alpert and the Tijuana Brass"
Answer: The guy in the Hotel California is playing a 3 guitar song on one guitar.  Try to play it, it's not easy reading.  Jeff Beck does a solo guitar cover of the Beatles' entire Sergeant Pepper album.  So maybe "Beck style solo guitar cover arrangement."
Answer: I would call it a solo performance.
Answer: Since nobody has come up with anything better, my suggestion is: "A singer accompanying themself".


What exercise is this (guitar)?

Question: I have read on a website that "the maestro" Andre Segovia suggests these/this exercise(s) but I didn't understand a bit of how this exercise works, can anybody of you help me with it?
This is written by a user in a forum (I copied his text):

I remember reading also that Segovia appreciated the different effects
  of the nail and the flesh, and used both in combination. As I recall,
  the main thing about the right-hand excercises was the fact that you
  pick groups of four notes with three fingers, leaving the pinky in bed
  for a snooze. So a sequence would be imai maim aima imai...and so on.
  Also in the other direction. The benefit comes from having to accent
  the first note of each group of four with a different finger each
  time....Imai Maim Aima Imai etc I started on the top string with rest
  strokes down to the second, no left hand. Then work on the top two
  strings, then all three, all the time using rest strokes down to the
  string below. The rest stroke thing is important...like a 'walking
  upstairs' or 'downstairs', kind of action. Once mastered, this
  produces a powerful string damping action, and you always feel exactly
  where your fingers are!.Once you get going with the right, bring in
  the left hand, and watch it all slow down again !! Not for long.
  Simple, slow 1234 4321, then, with the left, then more interesting
  variations.......1324....4231. Obviously try to get musical as soon as
  you can. Also each of the three right-hand fingers on a string each.
  At some point, bring in the thumb to do 'thumby' things! I remember
  thinking....'why am I doing this?' ......when I gave these exercises a
  go....the rest strokes felt strange and clumsy for a while. But,
  suddenly, one day............. Eventually, your three right-hand
  fingers can roll around in both directions in co-ordination with
  anything the left hand chooses to do, and you can accent any note at
  will, at any volume. Result....has to be felt to be believed, if
  you've never done it.
Comment: @Mafii Thanks for your comment! :D
how has it improved your guitar playing? And why picking strings with a finger which shouldn't pick that string?
Comment: Well it helped me with picking in non-continuous pieces, where your fingers of the right hand go all over the place. It teaches you more control over your attack and string of use of your picking. I'm not sure why you consider it to be a "finger that shouldn't pick that string" - every finger should be able to pick every string, for certain classical pieces. See Sunburst for example: http://www.guitguid.com/files/downloads/6_0313/Andrew%20York%20-%20Sunburst.pdf - your fingers pick strings that feel quite random at some times. As said, it's a exercise for advanced players.
Answer: It is not clear what you are confused about so I'm going to dissect your post and explain several aspects.  It would help if you stated, for example, what is a rest stroke?, or what is imami?, etc.
The post is describing exercises for developing the fingers of the right hand so that they are capable of independently producing different volume and tone when striking notes.  There are several techniques to develop for the right hand.  Two that come to mind are playing arpeggios on 4 strings while holding a chord and tremolo (playing one note on a single string very fast).  There are left hand exercises that do not use the right hand, and right hand exercises that do not use the left hand, each designed to isolate the hand and develop skills without confusion.  Once each hand works independently there are exercises that help develop synchronization of the hands, and of course MUSIC.
Some classic examples are "La Technica Degli Arpeggi", and the Giuliani exercises.  The first are finger combinations in 4, 6, and 8 notes (at least) on open string followed by some left hand finger patterns while Giuliani provides the same with chord progressions (usually I V7 I over and over).
Technical points.
Right hand fingers (the letter is derived from the Spanish word for each, I think)
i = index
m = middle
a = ring
p = thumb
It is tough enough to get a smooth flow of finger movement but the specific point made in the post is to develop the ability to accent one of the 4 without losing the flow.  The capital letter indicates accent (think of playing that one loudly compared to the others).
"Rest stroke" refers to the techniques of letting the finger or thumb come to rest on the next string after striking the string you are playing.  This other techniques is free stroke where the fingers do not touch the neighboring strings.  This was once heralded as a superior technique for producing a full, rich, tone with volume.  The fact is free stroke can be developed to be just as strong with practice and many classical guitarists prefer free to rest.  It is really a mater of taste in my opinion.  But once you've spent years training yourself it will be hard to retrain yourself, you'll feel like a beginner.
As for the variety of tone produced by flesh, nail, and angle of attack...  The "tone" of the note depends on the attack on the string.  Much of this is understood from the physics of vibrating strings.  Turning the finger just a few degrees before striking or releasing the string can radically change the quality of sound.  Many guitarists will create a brighter tone by plucking the strings closer to the bridge.  While the physics of this makes sense one sacrifices other qualities.  Pepe Romero's book teaches that one should develop variety of tone by adjusting the right hand angle and pressure at the back end of the sound hole (typically the preferred location of the right hand) rather than moving the right hand around.
Pinky sleeps: An interesting description.  We almost never use the pinky (at least it doesn't seem to be traditional) but Eliot Fisk (one of Segovia's students) has recommended doing all of Segovia's scales exercises using the pinky to develop better strength and agility in the right hand.  It seems that exercising the pinky helps the ring finger.
It seems that the post you've cut and pasted is describing the whole process of 1. working the right hand on one string, 2. working differing pressure and attack, 3. Adding in the left hand.  This is done systematically to help develop independent skills and eventually two hand coordination.
I've never heard the specific quote attributed to Segovia.  Many young guitarists are happy enough being able to play a chord progression or a few quick runs.  But in fact you have 8 independent instruments (1, 2, 3, 4) fingers of the left hand and (p, i, m, a) of the right.  It is possible to produce several sounds at once with practice.  You can hear that quality in people like Fisk, Parkening, Verdery, etc.
Comment: I'm glad it helped.  I have a lot of these exercises in books.  If you need more info message me in chat (if possible).

What exercise is this (guitar)?


limit string to first 5 words or first 42 characters in PHP

Question: If I have a string in PHP that is obnoxiously long string in PHP and I want to shorten it and then append something to it.
I want to shorten it to the first 6 words or 42 characters, whatever is shorter and then append a '...' to it if it was shortened.
The only case it would not be shortened and the '...' not added would be if it was originally less than 6 words or 42 characters.
How can I do this in PHP?
Logically, I would think I would split the string by white-space and then add each thing before the white-space in an array and take only the first 6 elements out of that array and write them to a new string.
Here is the code I have so far:
str_1 = 'The quick brown fox jumped over the lazy dog';
$words = explode(" ", $str_1);
$counter = 0;
str_2 = '';
foreach($words as $word){
    if($counter < 5){
        //append $words[counter] to str_2;
        counter++;
    }
    else{
        break;
    }
}

I don't know how to do the rest for character count or comparison or appending.
Does anyone have any ideas?
Comment: You seem to have an idea of how to proceed, what code do you have so far ? What particular part is blocking you ?
Comment: Why not just get the first six words and use css for the ...?
Comment: @Lepidosteus The appending and character count is blocking me. I updated the question with code.
Comment: @Jack because :after isn't supported in all browsers.
Comment: Whereby not all refers to the antique browsers? :)
Comment: @jack I don't understand what that means
Answer: This function I made seems pretty tidy:
function truncate($input, $maxWords, $maxChars)
{
    $words = preg_split('/\s+/', $input);
    $words = array_slice($words, 0, $maxWords);
    $words = array_reverse($words);

    $chars = 0;
    $truncated = array();

    while(count($words) > 0)
    {
        $fragment = trim(array_pop($words));
        $chars += strlen($fragment);

        if($chars > $maxChars) break;

        $truncated[] = $fragment;
    }

    $result = implode($truncated, ' ');

    if ($input == $result)
    {
        return $input;
    }
    else
    {
        return preg_replace('/[^\w]$/', '', $result) . '...';
    }
}

Some tests:
$str = 'The quick brown fox jumped over the lazy dog';

echo truncate($str, 5, 42); // The quick brown fox jumped...
echo truncate($str, 3, 42); // The quick brown...
echo truncate($str, 50, 30); // The quick brown fox jumped over the...
echo truncate($str, 50, 100); // The quick brown fox jumped over the lazy dog

It won't cut words in half either, so if a word pushes the character count over the supplied limit, it will be ignored.
Answer: count words (assumes spaces delimit words):
$words = explode(' ', $string);
$wordCount = count($words );

count characters
$length = strlen($string);

together
if($wordCount > 5) {
    $words = array_slice($words, 0, 5);
    $string = implode(' ', $words);
    $length = strlen($string);
}
if($length > 42) {
    $string = substr($string , 0, 42);
}

Comment: I'd keep the original string around, so i could say `if ($string !== $original) $string .= '...';`.
Answer: This will give you the first 6 words, or the first n words where the total length of the words is less than 42.
$words = explode(' ', $string);
$newstring = "";
$i=0;
while (strlen($newstring . $words[$i]) <= 42) && $i < 5) {
   $newstring .= $words[$i];
}
if (strlen($string) > strlen($newstring)) $newstring .= "...";

Answer: $string = "Your Text Here";
$string_length = 80; // give a random character value including whitespace.
if(strlen($string)>$string_length){
do{
    $new_string = substr($string,0,$string_length);
    $string_length++;
    }while(ctype_graph(substr($new_string,-1)));
  }
else {
   $new_string = $string;
}

echo $new_string;

Comment: Welcome to Stack Overflow.  You should explain what this does and how it solves the problem.


Why do I get the error: No module named 'pyodide'

Question: I installed pyodide.http but I cannot import it. What did I do wrong?
C:\Users\malik>pip install pyodide.http
Requirement already satisfied: pyodide.http in c:\users\malik\appdata\local\programs\python\python310\lib\site-packages (0.2.0)
WARNING: You are using pip version 22.0.4; however, version 22.3.1 is available.
You should consider upgrading via the 'C:\Users\malik\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command.

C:\Users\malik>python
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import  pyodide.http
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyodide'
>>>

Comment: I guess you mean `pyodide-http`. But this package doesn't install `pyodide`. That you have to install separately.
Comment: Trying to install `pyodide`, I get this error: ValueError: Pyodide is a Python distribution that runs in the browser or Node.js. It cannot be installed from PyPi. Do you guys know how can I install it?
Comment: Skimming the documentation, it seems like `pyodide` is a package that allows Python code to run in other environments (such as javascript).  Python itself can (obviously) already run Python code, so installing it as a Python package would be useless.  Why are you trying to do that?
Answer: The pyodide Python module is a module that makes using Python easier in the browser and in particular includes the Python <-> Javascript Foreign Function Interface (FFI).
Outside of the browser, you can install it from the pyodide-py package,
pip install pyodide-py

However most of its functionality doesn't make sense outside of the browser (or Node.js runtime), so it is mostly intended to avoid import errors, in code that imports but does not directly need it.
Similarly pyodide-http is intended for monkeypatching request & HTTP client-related libraries for the browser. So I'm not sure why you are trying to install it outside of the browser.
If you are running in the browser, you would install pyodide-http with micropip rather than pip, and the pyodide module is included by default (in the Pyodide distribution).


Prove that the planes $( M_k N_k P_k )$ have the same direction for any positive strictly real number $k$

Question: Question
We consider the cube $ABCDA'B'C'D'$ and the points: $M_k \in ( A' D'), N_k \in ( C C' ), P_k \in ( A B )$ so that:

$\frac{A' M_k}{M_k D'}= \frac{C' N_k}{N_k C}= \frac{B P_k}{P_k A}=k$

where $k$ is a strictly positive real number.
Prove that the planes $( M_k N_k P_k )$ have the same direction for any positive strictly real number $k$
drawing

My idea
I let the point $M_a, M_b, N_a, N_b, P_a, P_b$ where $a,b$ are some values that $k$ can take, just so I can un-generalise the problem.
If we can show that $(M_AN_AP_A)$ is parallel with $(M_BN_BP_B)$, then I believe the problem should be solved.
If yes, I don't know where to start. I think using the reciprocal of Thales' theorem will help but I don't know where to start.
I say this cause I don't understand how I should prove that some planes have the same direction.
Hope one of you can help me! Thank you!
Comment: The OP keeps editing the title just to add "HELP ME UNDERSTAND ANSWER".
Answer: We may suppose that the length of a side of the cube is $1$.
Then, we have
$$M_kD'=P_kA=N_kC=\frac{1}{k+1}$$
$$M_kA'=P_kB=N_kC'=\frac{k}{k+1}$$
Let $E$ be a point on $C'D'$ such that $ED'=\frac{1}{k+1}$ and $EC'=\frac{k}{k+1}$.
Let $F$ be a point on $BC$ such that $CF=\frac{1}{k+1}$ and $FB=\frac{k}{k+1}$.
Let $G$ be a point on $AA'$ such that $GA'=\frac{k}{k+1}$ and $GA=\frac{1}{k+1}$.
Let $H$ be the intersection point of $EM_k$ with $B'A'$.
Let $I$ be the intersection point of $EM_k$ with $B'C'$.
Let $J$ be the intersection point of $N_kF$ with $B'B$.
Then, the points $E,F,G,H,I,J$ are on the plane $M_kN_kP_k$. (I think you see why.)
Since
$$A'H=C'I=BJ=\frac{k}{k+1}$$
we have
$$B'B:B'J=B'A':B'H=B'C':B'I$$
So, we can say that the plane $HIJ$, i.e. the plane $M_kN_kP_k$ is parallel to the plane $BA'C'$.
Therefore, the claim follows.
Comment: @IONELA BUCIU : Let me explain my idea. It is sufficient to prove that $F,G,H,I,J,N_k$ are on the plane $M_kEP_k$. Using the idea written in [this your question](https://math.stackexchange.com/questions/4800414/prove-some-results-in-a-cube), we can say that $H,I$ are on the plane. Then, we can say that $G,J$ are on the plane. Then, we can say that $F,N_k$ are on the plane. Does this help?
Comment: @IONELA BUCIU : The line $M_kE$ is the intersection of the plane $A'B'C'D'$ with the plane $M_kEP_k$. Since $H,I$ are on the line $M_kE$, the two points $H,I$ are on the plane $M_kEP_k$. The line $HP_k$ is the intersection of the plane $A'B'BA$ with the plane $M_kEP_k$. Since $G,J$ are on the line $HP_k$, the two points $G,J$ are on the plane $M_kEP_k$. The line $JI$ is the intersection point of the plane $BCC'B'$ with the plane $M_kEP_k$. Since $N_k,F$ are on the line $JI$, the two points $N_k,F$ are on the plane $M_kEP_k$.
Comment: @IONELA BUCIU : Three triangles $\triangle{HA'G},\triangle{GAP_k}$ and $\triangle{P_kBJ}$ are isosceles right triangles with $HA'=A'G,GA=AP_k$ and $P_kB=BJ$. Since $\angle{A'HG}=\angle{A'GH}=\angle{AGP_k}=\angle{AP_kG}=\angle{BP_kJ}=\angle{BJP_k}$, we see that $G,J$ are on the line $HP_k$.
Comment: Thank you so much for your idea! I don't really understand why the points $E,F,G,H,I,J$ are on the plane $M_kN_kP_k$...I see that $M_k E|| P_KF$, which makes $M_kEFP_k$ a parallelogram so $M_kP_k||EF$ From here we have 2 possibilities: 1) EF is parallel with that plane or 2) EF $\in$ that plane .what should I do next?
Comment: Sorry, but i can't figure out if we can say that $G,J, F, N_k$
 are on the plane, but I succeeded in showing that HI are on that plane... I think the intersection might be wrong. Thank you!
Comment: there is $M_k,E,I,H$ that are in the planes $(A'B'C'D')$ and $(M_KEP)$ which means they are collinear
Comment: i understand the idea, but how you know that $G,J$ are on the $HP_k$ line... ,, Using the idea written in this your question" I don't think would help/
Answer: Let $r$ be the rotation around the axis $B'D$ by $120^\circ$. Note that: $r(B)=C'$, $r(C')=A'$ and $r(A')=B$. Also $r(A)=C$, $r(C)=D'$, $r(D')=A$. Since $P_k, N_k, M_k$ divide the segments $BA$, $C'C$, $A'D'$, respectiely, with equal ratio, it follows that $r(P_k)=N_k$, $r(N_k)=M_k$, $r(M_k)=P_k$. In particular, $P_kN_kM_k$ is an equlateral triangle contained in a plane perpendicular to the axis of rotation $r$. This shows that regardless of what $k$ is, the direction of the plane $P_kN_kM_k$ is the same.
Answer: ** Produced by ChatGPT
The problem you're working on involves proving that certain planes within a cube are parallel for any positive real number $ k $. This is a geometry problem that can be approached using vector geometry or analytical geometry methods.
Given the cube $ ABCDA'B'C'D' $ and the points $ M_k $ on $ (A'D') $, $ N_k $ on $ (C'C) $, and $ P_k $ on $ (AB) $, where the distances $ \overline{A'M_k} $, $ \overline{C'N_k} $, and $ \overline{BP_k} $ are in the ratio of $ k $ to the lengths $ \overline{M_kD'} $, $ \overline{N_kC} $, and $ \overline{P_kA} $ respectively, you want to show that the planes $ (M_kN_kP_k) $ are all parallel to each other for any value of $ k $.
Here's a sketch of how you might proceed with a proof:

Define the cube with vertices at coordinate points for ease of calculation. For example, let $ A $ be at the origin (0,0,0), and since it's a cube, let each edge be of unit length.

Express the coordinates of $ M_k $, $ N_k $, and $ P_k $ in terms of $ k $. For example:

$ M_k $ would be $ (0, k/(k+1), 1) $.
$ N_k $ would be $ (1, 1, k/(k+1)) $.
$ P_k $ would be $ (k/(k+1), 0, 0) $.

Determine the vectors that lie on the plane $ (M_kN_kP_k) $. Two such vectors can be determined by taking $ \vec{M_kN_k} $ and $ \vec{M_kP_k} $.

Find the normal vector to the plane $ (M_kN_kP_k) $ using the cross product of the vectors found in step 3. The normal vector will give you the direction perpendicular to the plane.

Show that the normal vector is independent of $ k $, which would imply that the direction perpendicular to each of these planes is the same for all $ k $, and hence the planes are parallel.

Alternatively, if the direction vectors of the planes (found in step 3) are proportional for different values of $ k $, this would also imply that the planes are parallel.

Remember, two planes are parallel if and only if their normal vectors are proportional, or equivalently, if direction vectors lying on the planes are proportional. If you demonstrate that the vectors you find in step 3 or the normal vectors from step 4 do not change direction as $ k $ varies (they may change in length, but not in direction), then you have proven that the planes are parallel for any $ k $.
This approach relies on being precise with vector calculations and careful in the manipulation of expressions involving $ k $. The algebra can become complex, so meticulousness is key. If you'd like, I can walk you through the detailed calculations of these steps.
Comment: -1 for "Produced by ChatGPT"
Comment: Thank you so much for your idea. But is there any way to transform this answer into one that doesn't use vector geometry or analytical geometry methods? Im didn't learn about them yet at school.


Find a good candidate for a closed-form solution of this recurrence relation: $P(n-1)+n^2$.

Question: I want to find a candidate for this recurrence relation:
$$
P(n) = \left\{\begin{aligned}
&1 &&: n = 0\\
&P(n-1)+n^2 &&: n>0
\end{aligned}
\right.$$
Starting from 0 the first 8 values are 1,2,6,15,31,56,92,141.
I can't figure out a formula for this.
Comment: Hint: try writing out what $P(1)$, $P(2)$, $P(3)$ are in terms of lower $P$'s using your recurrence. For example $P(1) = P(0) + 1^2$, $P(2) = P(1) + 2^2  = P(0) + 1^2 + 2^2$ etc
Comment: the list should be $1,2,6,15,31,56,92,\color{red}{141}$.
Answer: The first few values are 1,2,6,15,31....
The General Term is$${n*(n+1)*(2n+1)\over6}+1$$
Which is the Sum of Squares of first $n$ natural numbers + 1.
Comment: Fine. Up Vote $0 k.$.
Answer: Write $P(n) - P(n-1) = n^2 = 2{n \choose 2} + {n\choose 1}$.  But ${n \choose 2} = {{n+1} \choose 3}-{n \choose 3}$, and ${n\choose 1} = {{n+1} \choose 2} - {n\choose 2}$, so we have $P(n) - P(n-1) = Q(n) - Q(n-1)$, where $Q(n) = 2{{n+1} \choose 3} + {{n+1} \choose 2} $.  Since $P(0) = 1$ and $Q(0) = 0$, we can now conclude that $P(n) = Q(n) +1 = 2{{n+1} \choose 3} + {{n+1} \choose 2} + 1$.
Unfortunately, there is not a very nice closed form for this.  But here's the best I can do (the first term here is the sum of the first $n$ squares, a fairly well-known quantity): $\frac{(n-\frac{1}{2})\cdot n\cdot (n+\frac{1}{2})}{3} + 1$
Comment: If a polynomial expression is not a nice closed form, what is?
Comment: Niceness is relative.  Every sum of the form $\sum_{m=0}^n m^k$, for $k$ a nonnegative integer, can be expressed as a degree $k+1$ polynomial.  But the polynomials you get out are way more complicated than the polynomials you put in, so it's often more trouble than it's worth to simplify sums like that for $k$ bigger than $1$.

By comparison, $\sum_{m=0}^n {m \choose k}$ has a truly nice closed form, ${{n+1} \choose {k+1}}$, which is why you actually see it used in proofs from time to time.
Comment: The polynomials you get are only complicated in comparison to the polynomials you are summing. The sums have a variable number of terms, while the resulting polynomials have a fixed number of terms and are quite suitable for computation. Besides, your ideal answer $\binom{n+1}{k+1}$ still takes $k+1$ multiplies and divides to evaluate, which is about the same as a polynomial of degree $k$.
Comment: @martycohen Are you making some point, or just trying to be argumentative?  Yes, of course there are various reasons why, in principle, a polynomial closed form might be more useful than the sigma notation, and I'm sure there are lots of contrived examples to illustrate this.  But as far as practical human understanding goes, we care a lot more about these operations when applied to bases they behave well on; it is no more worthwhile to write down $\sum_{m=0}^n m^10$ as a polynomial than it is to write down $\int_0^x {y\choose 10} dy$ as one. Heaven forbid that I do not find the latter _nice_.


Change Windows Event Log storage location on WIN2003

Question: I've changed, with regedit, the storage location from C:\WINDOWS\system32\config\AppEvent.Evt to somewhere else.
After restarting computer, it seems it doesn't work out - Event Log still adopts original location to store the log fie.
Any step I neglected to achive this?
Answer: The procedure is outlined here: http://support.microsoft.com/kb/315417
Quoted:
To move Event Viewer log files to another location on the hard disk, follow these steps:

Locate the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog
Click the subkey that represents the event log that you want to move, for example, click Application.
In the right pane, double-click File.
Type the complete path to the new location (including the log file name) in the Value data box, and then click OK. For example, if you want to move the application log (Appevent.evt) to the Eventlogs folder on the E drive, type e:\eventlogs\appevent.evt.
Repeat steps 4 through 6 for each log file that you want to move.
Click Exit on the Registry menu.
Restart the computer.

Hmm.. seems not, odd.
Answer: Did you change the path in HKLM\SYSTEM\CurrentControlSet or in HKLM\SYSTEM\ControlSetX? And are you sure che active ControlSet didn't switch upon reboot (it sometime does)?
Check which ControlSet is actually active (look at the value of HKLM\SYSTEM\Select\Current).
Answer: If anyone is still looking for the answer here...
Change the registry entry in the CurrentControlSet hive as described above (you do NOT have to touch the other control set hives), reboot, in Event View change the log file location for each log you wish to move. Bingo.


Integral of an exponential with matrices

Question: The goal is to have an explicit formula for the following integral:
$$\int_{\mathbb{R}^2}\exp({x^t N x+ x^tAy}) dx$$
where $x \in \mathbb{R}^2$ is the variable ($x^t$ is the transpose), $y \in \mathbb{C}^2$ is fixed, $N \in Mat(2x2,\mathbb{C})$ is a symmetric matrix with negative definite real part, and $A \in GL(2,\mathbb{R})$.
My first thought was to use a square root of $N$, change variable and complete the square, but the existence/uniqueness of $\sqrt{N}$ is not guaranteed. I would expect the integral to converge because the real part of $N$ is negative definite and the integral of the imaginary part oscillates quickly enough.
Does anyone have any hint/solution? Thanks.
Answer: This is equivalent to
$$I=\int_{R^{2}}e^{-x^{T}Nx+x^{T}Ay}$$
Where $N$ has a positive definite real part. As $N$ is symmetric one may orthogonally diagonalize it $N=O\Lambda{O}^{T}$. You let $x=Oz$ and $s=O^{T}Ay$ and the integral becomes
$$I=\int_{R^{2}}e^{-z^{T}\Lambda{z}+z^{T}s}\det{O}dz=\int_{R^{2}}e^{-z^{T}\Lambda{z}+z^{T}s}dz=\int_{R}e^{-\lambda_{1}z_{1}^{2}+s_{1}z_{1}}dz_{1}\int_{R}e^{-\lambda_{2}z_{2}^{2}+s_{2}z_{2}}dz_{2}$$
$$=\frac{\pi}{\sqrt{\lambda_{1}\lambda_{2}}}e^{\frac{s_{1}^{2}}{4\lambda_{1}}+\frac{s_{2}^{2}}{4\lambda_{2}}}=\frac{\pi}{\sqrt{\det{N}}}e^{\frac{1}{4}s^{T}\Lambda^{-1}s}=\frac{\pi}{\sqrt{\det{N}}}e^{\frac{1}{4}y^{T}A^{T}O\Lambda^{-1}O^{T}Ay}=$$
$$=\frac{\pi}{\sqrt{\det{N}}}e^{\frac{1}{4}y^{T}A^{T}N^{-1}Ay}$$
And here, the fact that
$$\int_{\mathbb{R}}e^{-az^{2}+bz}dz=\sqrt{\frac{\pi}{a}}e^{\frac{b^{2}}{4a}}$$
was used.
Comment: https://mathoverflow.net/questions/23629/non-diagonalizable-complex-symmetric-matrix here I see that the diagonalization of $N$ is not so obvious.
Comment: Wow! You are right! It seems my logic works only in the case of real $N$. In the complex case you can only implement this logic, i guess, if $N$ is hermitian, not only symmetric.
Comment: That is why I have troubles.


Value does not fall within the expected range with T4MVC in ASP.NET MVC site

Question: I have this property below that gets called fine but every once in a while I get the error System.ArgumentException: Value does not fall within the expected range..  The ID going in looks like so what else could be making this error?
protected readonly Controller Controller;

        public EventUrls(Controller controller, string storeHost = null)
        {
            Controller = controller;
            StoreHost = storeHost;
        }

     public virtual string HomeUrl { get { return Controller.Url.Action(MVC.Event.Index(EventId, EventName.GenerateSlug())); } }

Full Stack
System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'. ---> System.ArgumentException: Value does not fall within the expected range.
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Web.Hosting.IIS7WorkerRequest.GetServerVariableInternal(String name)
   at System.Web.WebPages.UrlRewriterHelper.WasThisRequestRewritten(HttpContextBase httpContext)
   at System.Web.WebPages.UrlUtil.GenerateClientUrlInternal(HttpContextBase httpContext, String contentPath)
   at System.Web.WebPages.UrlUtil.GenerateClientUrl(HttpContextBase httpContext, String contentPath)
   at System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues)
   at System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, String protocol, String hostName, String fragment, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues)
   at System.Web.Mvc.UrlHelper.RouteUrl(String routeName, RouteValueDictionary routeValues, String protocol, String hostName)
   at System.Web.Mvc.T4Extensions.Action(UrlHelper urlHelper, ActionResult result)
   at Tournaments.Models.ViewModels.EventUrls.get_HomeUrl() in F:\Rankings\Websites\Tournaments\Models\ViewModels\EventUrls.cs:line 30
   at ASP._Page_Views_Event_Controls_EventHeader_cshtml.Execute() in C:\StoreBeta\Views\Event\Controls\EventHeader.cshtml:line 5
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
   at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>c__DisplayClass5_0.<Wrap>b__0()
   at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func)
   at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
   at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)
   at System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter)
   at System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues)
   at ASP._Page_Views_Shared__Event_cshtml.Execute() in C:\StoreBeta\Views\Shared\_Event.cshtml:line 72
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
   at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
   at System.Web.WebPages.WebPageBase.<>c__DisplayClass40_0.<RenderPageCore>b__0(TextWriter writer)
   at System.Web.WebPages.WebPageBase.Write(HelperResult result)
   at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body)
   at System.Web.WebPages.WebPageBase.PopContext()
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Edit
I was able to replicate this, as the Season.Id is 2025386, Organization.Id is 1294, and Team.DivisionId is 1919.  Which all are within value range so I am not sure why this is throwing that error?
Comment: Looks relevant? https://stackoverflow.com/a/30515564/68432
Comment: I thought so too but I am not doing anything async.
Comment: Add a debug statement to the value going in. What are the values of `EventName.GenerateSlug()` and `EventId` causing this error?
Comment: Maybe this post can lead to a solution? https://stackoverflow.com/questions/650357/httprequest-servervariables-throws-argumentexception-in-wcf-with-iis7
Answer: if it is about arguament and if you are getting the error sometimes ı think it can be you are trying to pass value to that method which does not match the type or range of parameter
For example if you are passing a value 123213123434212312 to a parameter of type int then you will get ArgumentException
Comment: I'm going to log this but the parameters are always coming from the query strings and those are fine.
Comment: can be over max length value let me know if you can solve it
Comment: My values are within an integer range so that isnt the issue.


in private message: also match last names in auto-complete of To-field

Question: I am using the private message module and I do understand that one can use realname integration in the "To"-field to send a message. The auto complete feature helps finding the name.
Suppose I want to write to "John Smith". When I start typing "Jo.." it auto completes to "John Smith", but when I start typing "Smi.." auto completion fails. For my website it would be very nice to have that feature, since sometimes people don't know other peoples first names, but the last names.
How could I alter private message in the easiest way? Do you think other people would be interested in a more comprehensive auto completion?
Comment: Here is a nice example of such an auto-complete tool http://baymard.com/labs/country-selector using selectToAutocomplete jQuery plugin. If you start writing for example Dem... it gives you all of the Democratic Republic... and so on. Maybe this could be used as a basis.
Answer: There is an issue in the Privatemsg queue with an incomplete patch, privatemsg_realname: Permits to search inside realname field using "LIKE %...%".  You're welcome to help re-roll and test the patch.
The patch is for 6.x-2.x but it could fairly easily be re-written for 7.x-2.x.


Básico - Java: error: class, interface, or enum expected

Question: Estou aprendendo POO por Java e este seria o meu primeiro código, fora o clássico hello world kkk.
Quanto tempo compilar ele via bash, o seguinte erro aparece:
aula2.java:12: error: class, interface, or enum expected
package aula2;
^
1 error
Pela minha mínima experiência, o erro seria na linha 12 do código, com o nome "package aula2;", mas não consigo entender qual erro acontece nesta linha...
Segue o código:
package aula2;
public class Aula2 {
public static void main(String[] args)
{
    Caneta c1 = new Caneta();
    c1.color = "Blue";
    c1.model = "Bic";
}

}

package aula2;
public class Caneta
{
    String model;
    String color;

    void status()
        {

        System.out.print("Uma caneta " + this.color);
        System.out.print("A marca da caneta é " + this.model);

        }
}

Poderiam me dar uma luz para entender kk?
Agradeço!
Comment: Mas esses são arquivos separados? Declarar o nome do pacote duas vezes no mesmo arquivo é um erro mesmo, além disso, você não pode declarar duas classes públicas no mesmo arquivo, pois cada arquivo só pode exportar uma classe.
Comment: Fiquei na dúvida para te responder, mas acho que é o mesmo arquivo... quanto as classes, não sabia. O vídeo que eu vi mostrou assim. Como ficaria com as mudanças?
Answer: Tente executar desta forma:
 package aula2;

 public class Aula2 {

        public static class Caneta {

            String model;
            String color;

            public void status() {

                System.out.print("Uma caneta " + this.color + ".");
                System.out.print("A marca da caneta é " + this.model);

            }
        }

        public static void main(String[] args) {
            Caneta c1 = new Aula2.Caneta();
            c1.color = "Blue";
            c1.model = "Bic";

            c1.status();
        }
    }

Ou desta:
package aula2;

public class Aula2 {

    public static void main(String[] args) {
        Caneta c1 = new Caneta();
        c1.color = "Blue";
        c1.model = "Bic";

        c1.status();
    }
}

class Caneta {

    String model;
    String color;

    public void status() {
        System.out.print("Uma caneta " + this.color + ".");
        System.out.print("A marca da caneta é " + this.model);
    }
}

Answer: Você não pode declarar pacotes duas vezes no mesmo arquivo. Além disso, apenas uma classe pública pode ser declarada por arquivo.
Divida sua classe em dois arquivos com a mesma declaração de pacote:
// Arquivo Aula2.java
package aula2;

public class Aula2 {
    public static void main(String[] args) {
        Caneta c1 = new Caneta();
        c1.color = "Blue";
        c1.model = "Bic";
        c1.status();
    }
}

--
// Arquivo Caneta.java
package aula2;

public class Caneta {
    String model;
    String color;

    public void status() {
        System.out.print("Uma caneta " + this.color + ".");
        System.out.print("A marca da caneta é " + this.model);
    }
}


Error when installing NLTK on Windows10 Pro

Question: I am trying to install NLTK on Windows10 Pro 64 bit. It gives me following error.

Python version -32 required, which was not found in the registry.

I have installed python 3.5.0 (32 bit) in my machine and have added following to path variable.
C:\Users\MYNAME\AppData\Local\Programs\Python\Python35-32\Scripts\
C:\Users\MYNAME\AppData\Local\Programs\Python\Python35-32\
Can anyone help me to proceed with NLTK installation?
Answer: If you are a newcomer to Python, it may be simple (even if bigger) to use a pre-assembled Python Distribution.
For  example:
Anaconda-4.2.0 in Python 3.5 "flavor" should have nltk in the box https://docs.continuum.io/anaconda/pkg-docs
Answer: I am not running Windows 10, but rather Windows 8. However, I would like to share what I learned in recent days regarding the problems installing NLTK on a 64 bit Windows platform, because I believe it is probably applicable here (and to a number of other similar questions).
NLTK, the most recent version nltk-3.2.2.win32 (msi installer) will not install with a local 64-bit Python host (in other words, if you are on a Windows 64 platform and previously decided to install a 64 bit version of Python). However, it doesn't tell you that. It complains that Python 32 is required and cannot be found and then will not allow you to type in the path to your Python installation (mine is ActivePython-22.214.171.124-win64-x64). There is an excellent post that describes most of the solutions here Fix for NLTK install on Win 64.
In a nutshell, you can uninstall your Python 64 bit installation and install a 32 bit, which is what NLTK really wants, or you can try to build the NLTK installation locally with pip install pyyaml nltk (see the post I linked above).
My contribution is to add that although you will end up with NLTK installed you likely will still not properly build pyyaml because it must compile and build a c code extension (a Windows dll which for Python extensions in c will be a pyd extension rather than dll in order to spare additonal confusion if the name intersects with another dll somewhere on the system). Windows systems have a confusing array of user directory paths and the compiler (even if you have MSVC installed and know how to use it) cannot find the necessary library files typically when it is called from distutils (one of the python build helpers that is called). You could save the error output on your command console session and try to manually point the appropriate configuration files at your local path, but a simpler approach in this case is to simply obtain the correct compiled file that pyyaml is trying to build. Your install process above will typically go ahead and put the pyyaml python files (the .py files) in your site-packages directory (under your local Python installation directory), so all you need to do is obtain the compiled file, which happens to be named _yaml.pyd, and insert it into your yaml directory (that is what the install process above created in my site-packages directory), where all the pyyaml Python files reside.
You can obtain the necessary file at Python Packages, PyYAML 3.12. At that page you will see a list of available PyYAML packages. You should select the one that is congruent with your Python, Windows and NLTK requirements, which in this case is PyYAML-3.12-cp27-cp27m-win_amd64.whl (since I am running a 64 bit Python on a 64 bit Windows platform; if you running 32 bit Python then use the win32 whl). A little more explanation is required. This looks like even more headache, but it actually is not. The whl file is simply a zip package that you can extract with 7-Zip or whatever zip extractor is on your system (right click on the downloaded file to explore possibilities). Just extract it on your desktop or the like and you will find three items inside. Two will be folders, which you can ignore (you might want to verify that the yaml folder has the identical .py files to the ones you installed earler in your site-packages directory with pip, but if you are installing the latest NTLK that should be true). The third item is your target, _yaml.pyd. Copy or move that into your ...site-packages/yaml/ directory (mine is "C:\Python27\Lib\site-packages\yaml"). Don't be concerned that all the other files there are .py or .pyc files. It will be right at home. The author of this PyYAML package, Kirill Simonov, has made the use of this c extension easier than usual, providing the hooks locally for you with a .py file (cyaml.py). cyaml.py imports all the c code by "from _yaml import CParser, CEmitter," so it will be happy to find the _yaml.pyd you just copied in without further annoyance. I ran the NLTK unit tests yesterday after executing this strategy and a few of the tests offered at the NLTK site and it was fairly happy (just need to download a few more corpora and the like, but you will discover that soon enough if your first import nltk works).
I note that I have used this chicanery to avoid the obtuse installation process on several other occasions when all I needed was a wheel package, i.e., I just got the appropriate wheel, extracted the files and place them appropriately in the Python installation (something mentioned as one attractive feature of the Wheel package format).
Answer: You can try open the cmd as administrator and paste this command:
<code>"C:\Python\Python36-32\Scripts\pip3" install nltk
</code>
Note: The installation directory of python in your case may be different. In my case the command was
<code>"C:\Users\Faith\AppData\Local\Programs\Python\Python36-32\Scripts" install nltk
</code>


gcc inline - operand type mismatch for 'cmp'

Question: I get the following error:

Assembler messages:
  Error: operand type mismatch for `cmp'

The only cmp in my code is:
"cmpl %eax, $15\n\t"

I don't get what is wrong with that - I have a register and an immediate value which should be implicitly sign extended to 32bit.
Comment: When using att syntax (gcc's default), the constant needs to be the first param: `"cmpl $15, %eax\n\t"`.  Intel syntax puts the constant in the second parameter.  If all of your asm is intel format, use -masm=intel.
Comment: Ah, thank you. Even if I don't see why this is.
Answer: According to Official Intel ISA Reference 3.2 Instructions (A-L)

CMP EAX, imm32

Which means either in Intel Syntax
cmp eax, 15D

or in AT&T Syntax:
cmpl $15, %eax

Just the opposite :)

cmp doesn't have a form that subtracts the reg/mem from an immediate.  Instead, use the opposite branch / cmov condition if you wanted to check something other than equality.
Answer: i had the same problem, but in my case the error was with
cmp $0xFFFFFFFFFFFFFFFF, %rdx

and the solution was to do
movq $0xFFFFFFFFFFFFFFFF, %rcx

first, and then
cmp %rcx, %rdx

(afaik, for bigger numbers cmp needs two registers, not const and register)
Comment: No, that's a separate problem.  The OP had their instruction backwards; CMP only supports `cmp $imm, reg/mem`, not `cmp reg/mem, $imm`.  In your case, it's that `cmp` (and all instructions other than `mov`) only support 32-bit sign-extended immediates, not 64-bit.


LGBM Intuition to Non-technical individuals

Question: How can i explain LGBM to a non-technical person as it involves Trees/Ensembling and much more?
Using LGBM for solving a Regression problem and how does it helps in:

Better Prediction
Feature Importance distribution.
Which hyper-parameters to focus more.
Comment: Sorry, it's my fault . just remove the last "]" in the url's ..
Comment: There are lots of pages about gbm (that you need to explain in order to explain lgbm) on the net .. [http://uc-r.github.io/gbm_regression]  and for lgbm : [https://medium.com/@pushkarmandot/https-medium-com-pushkarmandot-what-is-lightgbm-how-to-implement-it-how-to-fine-tune-the-parameters-60347819b7fc]
Comment: Page not found for both the links
Comment: Don't make life difficult. Non-technical individuals have no reason to understand or have an intuition about LightGBM. What you might need to do is give them a basic idea of what boosting is. LightGBM vs "other ensemble algorithm name" is an implementation detail. The Wikipedia article on [boosting](https://en.wikipedia.org/wiki/Boosting_(machine_learning)) has more than enough details for a non-technical individual. (Also, neither of the three points is strictly true, especially the third one "*Which hyper-parameter...*" is model-dependant and opaque for anyone not using LightGBM anyway.)
Comment: I get your point. The main motive for this intuition is basically, how to convey them **how the boosting is making better predictions than normal RF Model** as they fail to understand that **every tree learns on the errors incurred by the previous tree/learner**.
Answer: In general, boosting algorithms use smaller batches and new small trees learn from the errors of the previous small trees, thus gradually decrease the error and increase the accuracy. At the end they are ensembled.
More intuitive info in Wikipedia:
https://en.wikipedia.org/wiki/LightGBM


Insert data in a parametrization table

Question: I need to INSERT new data to a parametrization table. It is an INSERT INTO clause type problem.
Table A Staging
Id    Owner           Brand        CreationDate CreationUser
1     Shakespeare   Rolls Royce      2011-04-22    Burbage
3     Aristotle     Tesla            2014-12-25    Plato
9     Einstein      MayFlower        2015-01-01    Bohr

Table B parametrization
Id   BrandDescription
1     Rolls Royce
2     Tesla
3     MayFlower

Table C after mapping the id of Brand (table b) to the Brand of table A
Id    Owner           BrandId      CreationDate CreationUser
1     Shakespeare       1           2011-04-22    Burbage
3     Aristotle         2           2014-12-25    Plato
9     Einstein          3           2015-01-01    Bohr

Now suppose that two new records enters in the table A staging.
  Id    Owner           Brand         CreationDate CreationUser
  1     Shakespeare   Rolls Royce      2011-04-22    Burbage
  3     Aristotle     Tesla            2014-12-25    Plato
  9     Einstein      MayFlower        2015-01-01    Bohr
  17    John Bardeen  Tesla2           2017-01-02    Nikola
  18    Sanger        Phaeton          2018-03-01    Curie

I want to add the two new brands to the parametrization table B...
so it could be:
    Id   BrandDescription  CreationDate  CreationUser
    1     Rolls Royce       2011-04-22      Automatic
    2     Tesla             2014-12-25      Automatic
    3     MayFlower         2015-01-01      Automatic
    4     Tesla2            2017-01-02      Automatic
    5     Phaeton           2018-03-01      Automatic

I have tried with:
    If not exists (select 1 from
                    from  table_b tb
                    inner join table_a ta on tb.BrandDescription=ta.Brand)      insert into table_b
values (ta.Brand,getdate(),'Automatic')

It throws an error:
The multi-part identifier "ta.Brand" could not be bound.
It must check always the parametrization table to check out if there is any brands that appear in the new records of table A staging... so, as Tesla2 and Phaeton did not exist in the old parametrization table they should be inserted. Otherwise, nothing happens.
Just one more new record as
(for table A)
Id    Owner           Brand         CreationDate CreationUser
(...)
17    John Bardeen  Tesla2           2017-01-02    Nikola
18    Sanger        Phaeton          2018-03-01    Curie
19    Sagan         Tt:              2019-02-01    Lok

If there is a : in the brand it should not be inserted in the parametrization table B.
If not exists (select 1
               from table_b tb
               inner join table_a ta on tb.BrandDescription=ta.Brand and ta.Brand not like '%' + ':' + '%')
    insert into table_b
    values (ta.Brand,getdate(),'Automatic')

the problem is to assign the Brand of table A to the BrandDescription of the parametrization table B.
Answer: You could try to do that without if clause, you are trying to access a column (ta.brand) that doesn't exists in the scope of insert statement.
Ex:
INSERT INTO table_b
SELECT DISTINCT ta.Brand, GetDate(), 'Automatic' --use DISTINCT to return unique row
FROM table_a ta
LEFT OUTER JOIN table_b tb on tb.BrandDescription=ta.Brand
WHERE ta.Brand not like '%' + ':' + '%'
AND tb.ID is NULL --check if row exists in table_b

Comment: it threw 0 rows... nothing was added... ah.. in this case we must drop the not in NOT LIKE :) Now it is working.

Insert data in a parametrization table


Dask.dataframe : out of memory when merging and groupby

Question: I am new to Dask and having some troubles with it.
I am using a machine ( 4GB RAM, 2 cores) to analyse two csv files ( key.csv: ~2 million rows about 300Mb, sig.csv: ~12 million row about 600Mb). With these data, pandas can't fit in the memory, so I switch to use Dask.dataframe, What I expect is that Dask will process things in small chunks that can be fit in the memory ( the speed can be slower, i don't mind at all as long as it works), however, somehow, Dask still uses up all of the memory.
My code as below:
    key=dd.read_csv("key.csv")
    sig=dd.read_csv("sig.csv")

    merge=dd.merge(key, sig, left_on=["tag","name"],
        right_on=["key_tag","query_name"], how="inner")
    merge.to_csv("test2903_*.csv")
    # store results into  a hard disk since it can't be fit in memory

Did I make any mistakes? Any help is appreciated.
Comment: You might want to try reducing the chunksize in `dd.read_csv`.
Comment: You may try using [Dask Distributed](http://distributed.readthedocs.io/en/latest/quickstart.html) running it with ["--memory-limit=auto" option](http://distributed.readthedocs.io/en/latest/worker.html#spill-excess-data-to-disk)
Comment: @MRocklin: thanks it works.
Answer: Big CSV files generally aren't the best for distributed compute engines like Dask.  In this example, the CSVs are 600MB and 300MB, which aren't huge.  As specified in the comments, you can set the blocksize when reading the CSVs to make sure the CSVs are read into Dask DataFrames with the right number of partitions.
Distributed compute joins are always going to run faster when you can broadcast the small DataFrame before running the join.  Your machine has 4GB of RAM and the small DataFrame is 300MB, so it's small enough to be broadcasted.  Dask automagically broadcasts Pandas DataFrames.  You can convert a Dask DataFrame to a Pandas DataFrame with compute().
key is the small DataFrame in your example.  Column pruning the small DataFrame and making it even smaller before broadcasting is even better.
key=dd.read_csv("key.csv")
sig=dd.read_csv("sig.csv", blocksize="100 MiB")

key_pdf = key.compute()

merge=dd.merge(key_pdf, sig, left_on=["tag","name"],
        right_on=["key_tag","query_name"], how="inner")
merge.to_csv("test2903_*.csv")

Here's a MVCE:
import dask.dataframe as dd
import pandas as pd

df = pd.DataFrame(
    {
        "id": [1, 2, 3, 4],
        "cities": ["Medellín", "Rio", "Bogotá", "Buenos Aires"],
    }
)
large_ddf = dd.from_pandas(df, npartitions=2)

small_df = pd.DataFrame(
    {
        "id": [1, 2, 3, 4],
        "population": [2.6, 6.7, 7.2, 15.2],
    }
)

merged_ddf = dd.merge(
    large_ddf,
    small_df,
    left_on=["id"],
    right_on=["id"],
    how="inner",
)

print(merged_ddf.compute())

   id        cities  population
0   1      Medellín         2.6
1   2           Rio         6.7
0   3        Bogotá         7.2
1   4  Buenos Aires        15.2


Unable to install pwn package for Python 2.7

Question: While trying to install pwn package for Python 2.7, I encountered an error about capstone.dll. I tried to install using the command line and using PyCharm, but it shows the same error.
Here's the installation's log:
Collecting pwn
  Using cached pwn-1.0.tar.gz
Collecting pwntools (from pwn)
  Using cached pwntools-3.1.1.tar.gz
Collecting paramiko>=1.15.2 (from pwntools->pwn)
  Using cached paramiko-2.0.2-py2.py3-none-any.whl
Collecting mako>=1.0.0 (from pwntools->pwn)
  Using cached Mako-1.0.6.tar.gz
Collecting pyelftools>=0.2.4 (from pwntools->pwn)
  Using cached pyelftools-0.24.tar.gz
Collecting capstone (from pwntools->pwn)
  Using cached capstone-3.0.4.tar.gz
Collecting ropgadget>=5.3 (from pwntools->pwn)
  Using cached ROPGadget-5.4.tar.gz
Collecting pyserial>=2.7 (from pwntools->pwn)
  Using cached pyserial-3.2.1-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): requests>=2.0 in c:\python27x64\lib\site-packages (from pwntools->pwn)
Requirement already satisfied (use --upgrade to upgrade): pip>=6.0.8 in c:\python27x64\lib\site-packages (from pwntools->pwn)
Collecting tox>=1.8.1 (from pwntools->pwn)
  Using cached tox-2.4.1-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): pygments>=2.0 in c:\python27x64\lib\site-packages (from pwntools->pwn)
Collecting pysocks (from pwntools->pwn)
  Using cached PySocks-1.5.7.tar.gz
Collecting python-dateutil (from pwntools->pwn)
  Using cached python_dateutil-2.6.0-py2.py3-none-any.whl
Collecting pypandoc (from pwntools->pwn)
  Downloading pypandoc-1.3.3-py2-none-win_amd64.whl (21.5MB)
Collecting packaging (from pwntools->pwn)
  Using cached packaging-16.8-py2.py3-none-any.whl
Collecting psutil>=2.1.3 (from pwntools->pwn)
  Downloading psutil-5.0.0-cp27-none-win_amd64.whl (177kB)
Collecting pyasn1>=0.1.7 (from paramiko>=1.15.2->pwntools->pwn)
  Using cached pyasn1-0.1.9-py2.py3-none-any.whl
Collecting cryptography>=1.1 (from paramiko>=1.15.2->pwntools->pwn)
  Downloading cryptography-1.5.3-cp27-cp27m-win_amd64.whl (1.3MB)
Collecting MarkupSafe>=0.9.2 (from mako>=1.0.0->pwntools->pwn)
  Using cached MarkupSafe-0.23.tar.gz
Collecting pluggy<0.5.0,>=0.3.0 (from tox>=1.8.1->pwntools->pwn)
  Using cached pluggy-0.4.0-py2.py3-none-any.whl
Collecting py>=1.4.17 (from tox>=1.8.1->pwntools->pwn)
  Using cached py-1.4.31-py2.py3-none-any.whl
Collecting virtualenv>=1.11.2 (from tox>=1.8.1->pwntools->pwn)
  Using cached virtualenv-15.0.3-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in c:\python27x64\lib\site-packages (from python-dateutil->pwntools->pwn)
Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\python27x64\lib\site-packages (from pypandoc->pwntools->pwn)
Collecting wheel>=0.25.0 (from pypandoc->pwntools->pwn)
  Using cached wheel-0.29.0-py2.py3-none-any.whl
Collecting pyparsing (from packaging->pwntools->pwn)
  Using cached pyparsing-2.1.10-py2.py3-none-any.whl
Collecting cffi>=1.4.1 (from cryptography>=1.1->paramiko>=1.15.2->pwntools->pwn)
  Downloading cffi-1.9.1-cp27-cp27m-win_amd64.whl (154kB)
Collecting idna>=2.0 (from cryptography>=1.1->paramiko>=1.15.2->pwntools->pwn)
  Using cached idna-2.1-py2.py3-none-any.whl
Collecting ipaddress (from cryptography>=1.1->paramiko>=1.15.2->pwntools->pwn)
  Using cached ipaddress-1.0.17-py2-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): enum34 in c:\python27x64\lib\site-packages (from cryptography>=1.1->paramiko>=1.15.2->pwntools->pwn)
Collecting pycparser (from cffi>=1.4.1->cryptography>=1.1->paramiko>=1.15.2->pwntools->pwn)
  Using cached pycparser-2.17.tar.gz
Installing collected packages: pyasn1, pycparser, cffi, idna, ipaddress, cryptography, paramiko, MarkupSafe, mako, pyelftools, capstone, ropgadget, pyserial, pluggy, py, virtualenv, tox, pysocks, python-dateutil, wheel, pypandoc, pyparsing, packaging, psutil, pwntools, pwn
  Running setup.py install for pycparser: started
    Running setup.py install for pycparser: finished with status 'done'
  Running setup.py install for MarkupSafe: started
    Running setup.py install for MarkupSafe: finished with status 'done'
  Running setup.py install for mako: started
    Running setup.py install for mako: finished with status 'done'
  Running setup.py install for pyelftools: started
    Running setup.py install for pyelftools: finished with status 'done'
  Running setup.py install for capstone: started
    Running setup.py install for capstone: finished with status 'error'
    Complete output from command C:\Python27x64\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Amit\\AppData\\Local\\Temp\\pycharm-packaging\\capstone\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\amit\appdata\local\temp\pip-ok0oub-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib
    creating build\lib\capstone
    copying capstone\arm.py -> build\lib\capstone
    copying capstone\arm64.py -> build\lib\capstone
    copying capstone\arm64_const.py -> build\lib\capstone
    copying capstone\arm_const.py -> build\lib\capstone
    copying capstone\hexagon.py -> build\lib\capstone
    copying capstone\hexagon_const.py -> build\lib\capstone
    copying capstone\mips.py -> build\lib\capstone
    copying capstone\mips_const.py -> build\lib\capstone
    copying capstone\ppc.py -> build\lib\capstone
    copying capstone\ppc_const.py -> build\lib\capstone
    copying capstone\sparc.py -> build\lib\capstone
    copying capstone\sparc_const.py -> build\lib\capstone
    copying capstone\systemz.py -> build\lib\capstone
    copying capstone\sysz_const.py -> build\lib\capstone
    copying capstone\x86.py -> build\lib\capstone
    copying capstone\x86_const.py -> build\lib\capstone
    copying capstone\xcore.py -> build\lib\capstone
    copying capstone\xcore_const.py -> build\lib\capstone
    copying capstone\__init__.py -> build\lib\capstone
    warning: build_py: byte-compiling is disabled, skipping.

    running build_clib
    running custom_build_clib
    building 'capstone' library
    'cmake' is not recognized as an internal or external command,
    operable program or batch file.
    'nmake' is not recognized as an internal or external command,
    operable program or batch file.
    running install_lib
    creating C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\arm.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\arm64.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\arm64_const.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\arm_const.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\hexagon.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\hexagon_const.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\mips.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\mips_const.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\ppc.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\ppc_const.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\sparc.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\sparc_const.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\systemz.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\sysz_const.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\x86.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\x86_const.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\xcore.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\xcore_const.py -> C:\Python27x64\Lib\site-packages\capstone
    copying build\lib\capstone\__init__.py -> C:\Python27x64\Lib\site-packages\capstone
    warning: install_lib: byte-compiling is disabled, skipping.

    running install_data
    error: can't copy 'src\build\capstone.dll': doesn't exist or not a regular file

I searched on the internet for solution with no success.
Does anyone know how to solve it?
Thanks!
Comment: did you solve this? i am having the same issue
Answer: It looks like the system is missing (or can't find) the cmake program. Try installing cmake on your machine (I'm assuming windows?) and make sure its in your PATH.
Answer: Installing Capstone for Python solved the issue:
http://www.capstone-engine.org/download.html


What methods could be used to determine the validity of results from meta analysis besides conflict of interest?

Question: Based on the answers I've read to a question1 on the Skeptics stack exchange, I began to wonder what methods besides the declaration of industry funding could be used to determine the validity of results from meta analysis?
In other words, can we only trust meta analysis if there is no apparent conflict of interest concerning a topic, or are there other methods?
1. Does the artificial sweetener aspartame cause cancer?
Comment: There are many resources on how to appraise a meta-analysis. Best starting point is probably the Oxman-Guyatt Index (but follow citing papers as it is an old contribution).
Comment: A valid meta analysis is intended to produce truth. However, if you have suspectful result, different approaches are available for a cross-validation of results of a meta-analysis.  Furthermore, to substantiate a relationship etc, you can design an experiment and execute it.
Answer: There are many methods, mostly falling under the category "try to understand exactly what they did and use your best judgement".
Some stuff I would look into:
1) What were the inclusion and exclusion criteria for studies? Are they sensible? To what extent was subjective judgement involved in selecting the studies? How was it handled? Usually metaanalysis will explicitly state a search strategy - if you try to replicate it, will you find papers that were not included but look relevant?
2) Are they open about their input data? Can you get to the list of studies? Can you get the list of studies that matched the search but were excluded? Is the input data for the statistical method they used available? (either individual-level data or summary of effects from the individual studies) Are the input studies truly from various sources or is there an author/research group/company that supplied disproportionate part of the underlying studies? If so, is this author/... credible?
3) Is the statistical method clearly described? What are its assumptions? Are those likely to hold? Do they account for between-study differences in a sensible way? Does it look like they didn't report some analysis that would be obvious/straightforward to use? Plus points if multiple ways to analyze the data are reported and the differences in their conclusions are honestly discussed.
4) Is code for the statistical analysis available? If so, can you rerun their analyses? (this would likely be a pretty high bar to cross) If so, do you get the same results? What happens if you fiddle with the meta parameters of their model?
5) Is there a plot of all the data included? Does it look like it is consistent with the conclusions of the paper? Is the result driven by a single/few large study/studies dwarfing all the other included? If so, the metaanalysis is only as good as those big studies - check if they are trustworthy.
6) Do claims in the abstract match what is written in the "Conclusions" section? What are the stated limitations? (beware a study that does not state limitations or only states some obvious boileplate - real limitations are always there)
7) If claims are made about a broader population is the population well represented in the underlying studies? (e.g. beware of sweeping generalizations from only U.S. studies - unless you only care about the U.S.).
8) Check numerical measures of publication bias in the set of studies included - e.g. P-curve but see also this commentary by Andrew Gelman
Note that basically no metaanalysis would meet all of the criteria above (because science is hard). So you should be careful to not dismiss an analysis just because you can find a problem - you will always be able to find a problem. Instead, you should ask whether the problems you found are important for the question at hand and what can you learn from the analysis despite the problems.


choosing lambda for multi-reponse lasso in glmnet

Question: I know that from Hastie et. al's paper, that in the single response $y$ LASSO, the $\lambda$ values are chosen such that:
$N\alpha\lambda_{max} = \max_l |< x_l, y_l > |$
Also, $y$ is by default standardised before forming the grid of $\lambda$ values on log-scale. Then, the grid is de-standardized by multiplying back by $\sigma_y$.
I'm trying to understand how this is done if $Y$ becomes a matrix (i.e multiresponse). Any ideas how $\lambda$ would then be formed?
Comment: Welcome to Crossvalidated. Can you include a link to your paper?
Comment: This question does not require a bounty, but instead more clarity. For instance... you ask *"how this is done if Y becomes a matrix"* but there is no mention at all of Y before that point.
Comment: Please write down the estimator too. In these contexts, the loss will decouple and people often take the penalty to the nuclear norm, to encourage similar betas across columns of $Y$ (as a convex relaxation of rank)
Answer: Short answer for the simplest case (no intercept, no standardization)
library(glmnet)
set.seed(125)

n <- 50
p <- 5
k <- 2

X <- matrix(rnorm(n * p), ncol=p)
y <- matrix(rnorm(n * k), ncol=k)

max(glmnet(X, y, family="mgaussian",
           standardize = FALSE,
           standardize.response = FALSE,
           intercept=FALSE)$lambda)

max(sqrt(rowSums(crossprod(X, y)^2))/n)

If you want to add intercept handling / standardization of $X$ and/or $y$, see discussion elsewhere on this site.
So where does this come from?
Let's review the standard lasso case first:
$$\text{arg min}_{\beta} \frac{1}{2n} \|y - X\beta\|_2^2 + \lambda \|\beta\|_1$$
The stationarity condition from the KKT conditions says that we must have
$$ 0 \in \frac{-X^T}{n}(y-X\beta) + \lambda \partial \|\beta\|_1 $$
The first term on the RHS is just the gradient of the smooth $\ell_2$-loss; the second term is the so-called subdifferential of the $\ell_1$-norm. It arises from an interesting alternate characterization of derivatives for convex functions which can be extended to non-smooth case quite easily. (See below for some details) For now, it's sufficient to know that it's a set of numbers and we need 0 to be in that set at the solution.
We are interested in the case where $\beta = 0$. In this case, the subdifferential of the absolute value function $\partial |\beta|_{\beta = 0}$ is the set $[-1, 1]$, so the subdifferential of the vector $\ell_1$-norm is $\partial \|\beta\|_1 = [-1, 1]^p$. That is, the set of all vectors in the $p$-dimensional hypercube.
Hence, we need to be able to find some $s \in [-1, 1]^p$ satisfying
$$0 = -\frac{X^Ty}{n} + \lambda s$$
for $\beta = 0$ to be a solution. Rearranging, we get
$$\frac{X^Ty}{n} = \lambda s$$
This is a set of vector equations with $p$ elements on each side, so let's look at just the first one:
$$\frac{(X^Ty)_1}{n} = \frac{X^T_1 y}{n} = \lambda s_1$$
We know that $s_1$ is in $[-1, 1]$, so $\lambda s_1$ is in $[-\lambda, \lambda]$. Hence, for this equation to hold, we must have $|X^T_1y/n| \leq \lambda$.
By symmetry, this must hold for all $i$, so we have $\max |X^T_iy/n| = \|X^Ty/n\|_{\infty} \leq \lambda$. Taking the smallest $\lambda$ that satisfies this equation, we get
$$\lambda_{\max} = \left\|\frac{X^Ty}{n}\right\|_{\infty}$$
Now, let's consider the group lasso penalty for the multi-response Gaussian, defined as
$$\text{arg min}_{B} \frac{1}{2n}\|Y - XB\|_2^2 + \lambda \|B\|_{1, 2}$$
where $Y \in \mathbb{R}^{n \times k}, X \in \mathbb{R}^{n \times p}$, and $B \in \mathbb{R}^{p \times k}$ and the penalty $\|B\|_{1, 2}$ is the $\ell_1/\ell_2$-mixed norm given by
$$ \|B\|_{1, 2} = \sum_{i=1}^p \|B_i\|_2 = \sum_{i=1}^p \sqrt{\sum_{j=1}^k B_{ij}^2} $$
We can do an analysis like before, but here we need the subdifferential of the $\ell_1/\ell_2$-mixed norm. It can be shown (below) that it is given by the $p$-fold Cartesian product of unit-or-smaller $k$ vectors.
As before, we get:
$$\frac{(X^TY)_i}{n} = \lambda s_i$$
except here the LHS is a $k$ vector and $s_i$ is a unit-or-smaller $k$ vector. Since $s_i$ is a unit vector, for there to be any solution, we must have $\|(X^TY)_i/n\|_2 < \lambda$. Again, taking the max over all $i$, we get
$$\max_i \|(X^TY)_i/n\|_2 = \|X^TY/n\|_{\infty, 2} \leq \lambda$$ so
$$ \lambda_{\max} = \|X^TY/n\|_{\infty, 2}$$
This is what we calculated above as max(sqrt(rowSums(crossprod(X, y)^2))/n).

So where does this all come from? Let's start by noting an important fact about convex functions: their Taylor series under-estimate them. That is, if $f$ is sufficiently smooth and convex, then the Taylor expansion of $f$ around $x$:
$$\tilde{f}_x(y) = f(x) + f'(x)(y-x)$$
will underestimate $f$:
$$ \tilde{f}_x(y) \leq f(y), \quad \forall x, y $$
This follows from Taylor's remainder theorem which says that the error will be of the form $f''(x)(y-x)^2/2$ - if $f$ is convex, then we have $f''(x) \geq 0$ everywhere, hence the Taylor series underestimates.
If we turn this around, we can say that for a convex function $f$, we can find $c$ such that
$$\tilde{f}_x(y) = f(x) + c(y-x)$$
Any $c$ satisfying this is called a subgradient of $f$ at $x$ and the set of all such $c$ is called the subdifferential of $f$ at $x$. If $f$ is differentiable, then there is only one subgradient which is just the gradient (and the subdifferential is just a set with one element), but if $f$ is not differentiable, then there are multiple possible subgradients (and hence a large subdifferential).
The classic example is $f(x) = |x|$, which is clearly non-differentiable at $0$. It is easy to see that any $c \in [-1, 1]$ is a subgradient:

Any of the blue lines (Taylor-type approximations using a subgradient) are everywhere below the red line (the function).
For the general $\ell_1$ norm on $\mathbb{R}^p$, it's not hard to see that the subdifferential is just the $p$-fold Cartesian product of the univariate subdifferential since the $\ell_1$-norm is separable across entries.
If we want to consider more general norms (e.g., the mixed $\ell_{1, 2}$ norm), we can invoke a more general theorem characterizing the subdifferential of norms.
Let $\|\cdot\|$ be a general norm. Then its subgradient is given by
$$\partial \|x\| = \{v : v^Tx = \|x\|, \|v\|_{*} \leq 1\}$$
where $\|v\|_{*} = \max_{z: \|z\| \leq 1} v^Tz$ is a different norm called the dual norm to $\|\cdot\|$. Evaluated at $x = 0$, we see that the subdifferential is the set of all vectors with dual norm at most 1.
One direction of the proof is easy: suppose $v$ is an element of the RHS above. Then consider the Taylor type expansion of $f(\cdot) = \|\cdot\|$ around $x$ evaluated at $y$ with (potential) subgradient $v$:
$$\begin{align*}
\tilde{f}_x(y) &= \|x\| + v^T(y - x) \\ &= \|x\| + v^Ty - v^Tx \\ & = v^Ty + \underbrace{\|x\| - v^Tx}_{=0 \text{ by assumption on $v$}} \\ &= v^Ty \\ & \leq \|v\|_*\|y\| \quad \text{(Holder's Inequality)} \\ &= \|y\|\end{align*}$$
so $v$ is indeed a subgradient of $f$.
Hence, finding the subdifferential reduces to calculating the dual norm. Fortunately, dual norms are exceptionally useful and hence well-studied. The simplest case is the standard $\ell_p$ norms where it can be shown that the dual of the $\ell_p$-norm is the $\ell_{p^*}$-norm where $p^*$ is the so-called Holder conjugate of $p$ and satisfies $1/p + 1/p^* = 1$.
For the $\ell_1$-case, $p=1$ and so $1/p + 1/p^* = 1 \implies 1/p^* = 1 - 1/1 = 0 \implies p^* = \infty$. Hence the subgradient is just the set of vectors with $\|v\|_{\infty} \leq 1$, which is exactly the set $[-1, 1]^p$ we claimed above.
For mixed-norms, the result is almost as easy. See Lemma 3 of [Sra12] for a proof of the fact that the dual of the $\|\cdot\|_{p, q}$ mixed-norm is simply $\|\cdot\|_{p^*,q^*}$ where $p^*,q^*$ are the Holder conjugates of $p, q$ respectively.
We hence note that the dual of the $\|\cdot\|_{1, 2}$ norm used for the group lasso is $\|\cdot\|_{\infty, 2}$ (because $1/2 + 1/2 = 1$) which has an associated unit ball which is the $p$-fold Cartesian product of vectors with Euclidean ($\ell_2$) norm at most 1, as claimed above.
[Sra12] "Fast projections onto mixed-norm balls with applications"
Suvrit Sra. ArXiv 1205.1437
Comment: @meylandt: If the penalty is $||B||_1$ (element-wise l1 norm), then is it true to say that $\lambda_{max} = ||X^TY/n||_{max}$?
Comment: Yes - This follows from the problem separating along the columns of $Y$ and then just taking the max of each individual (univariate Gaussian lasso) subproblem's $\lambda_{\max}$.
Answer: sorry I'm new to the community, still trying to get the hang of it! Thank for editing my question @F. Tusell. The link to the original article came from: https://web.stanford.edu/~hastie/Papers/glmnet.pdf.
But the paper did not mention much about what was done regarding multi-variate response. The vignette for the R package glmnet (link: https://web.stanford.edu/~hastie/Papers/Glmnet_Vignette.pdf), on page 17, explained how the objective function looked like, incorporating the group LASSO penalty. But, I can't seem to be able to reproduce value of lambda_max used to form the grids.
Comment: I think this is a clarifying comment on your question. If so you should not use it as an answer.


What's the order of initialization?

Question: Will it always works correctly?
public class Test
{
    public static List<int> a = new List<int>{1,2,3};

    public static List<int> b = new List<int>(a);
}

Because when I switched them
public class Test
{
    public static List<int> b = new List<int>(a);

    public static List<int> a = new List<int>{1,2,3};
}

then I received

Exception in user code:
System.ArgumentNullException: Value cannot be null.
  Parameter name: collection
     at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
     at .Test..cctor()

Are there any other things I have to worry about?
Comment: Same way you read a book.. top bottom - that's how code is compiled.
Comment: the order initialization is the same order you write your own code, on the 2nd sample `a` is simply not defined / is null when you try to pass it as parameter to `b`
Comment: @Adriani6 While that's true for field initializers, it certainly isn't true in general. Very few things in C# depend on the textual order of class members in the code, and it's not like C# is a single-pass compiler either (unlike e.g. Pascal, where you *can't* call a procedure that's defined below the call site).
Comment: Cause you just had to debug to notice that a is null, so as the error says, that value can't be null. In my opinion this isn't even a question, you just had to think instead of copypasting things..
Comment: @MarcoSalerno but I'm not asking why it is null or why there's an exception, but I'm asking whether there are any other things to worry about while trying to initialize two properties with data of eachother other, than their order.
Comment: @styx It would be fine if `a` weren't defined - at least that would produce a compiler error. It's actually null, which makes these dependencies in field initializers rather dangerous.
Comment: @Luaan Correct, I might of worded my comment wrong as what I said was relating to the code sample in the question.
Answer: If you need deterministic initialization, use a static constructor:
public static List<int> a;
public static List<int> b;

private static Test()
{
  a = new List<int>{1,2,3};
  b = new List<int>(a);
}

The C#/CLR specification ensures the order in which field initializers are executed, but as you've noticed, if you mess up the ordering of your fields in the class, things break down at runtime. That's a bad idea regardless of the contractual behavior, given how easy it is to switch the order of fields in a class.
So my advice is: if the field initializers don't depend on other fields, keep them. If they do, put the initialization in a constructor, where the ordering is very explicit.
The relevant quote from specification:

If a class contains any static fields with initializers, those initializers are executed in textual order immediately prior to executing the static constructor (§17.4.5).

So you can rely on the textual order contractually, but I'd still recommend against it. It's way too easy to break, and people usually don't consider the order of members in the code file of a class important. It would be fine if you got a compilation error, but you don't - if you're lucky, you get a runtime error. If you're not, you're going to be scratching your head with "impossible" situations that had nothing to do with your changes (right?).
Comment: That is in no way more deterministic than OPs code.
Comment: no need of an extra static constructor ... fields will get initialized in the order they are defined always
Comment: That's untrue. It is the same deterministic as do it in class
Comment: @Rahul There's no need for many things, and yet we do them. Just because something "works" doesn't mean it's a good idea to do it that way. You could define all your fields and locals as `object` or `dynamic`, and yet you probably don't. Why? The same reason why dependencies between field initializers are a bad idea - you're preventing the compiler from helping you realize your mistakes.
Comment: Sorry, help me understand your comment. Your posted code is no different than what OP already have. It will never make any difference. Irrespective or static or instance member; when instance member fields will start getting initialize .. they will initialize in the order defined.
Comment: @Rahul It is very different, both in the code produced, and in the way the textual code is maintained. I already mention this in the answer itself - order of members is unimportant almost every time in C#, so relying on the order of members in text is dangerous. People just don't treat members the same way they treat lines of procedural code, and there's very little reason to go against the grain here. Heck, even refactoring tools will reorder members according to your whimsy (e.g. alphabetical order, access modifiers, grouping...), breaking your code. And for what? Are the two lines worth it?
Answer: Yes as you have observed correctly the order has to remain as below since the member fields will get initialized in accordance order
public static List<int> a = new List<int>{1,2,3};
public static List<int> b = new List<int>(a);

What's the order of initialization?