Anti-symmetric and associative binary operation that satisfies Jacobi identity?

Question: Question
Assume a vector space $V$ and a binary operation $*$ that satisfies for all $u, v, w \in V$:

$u * v \in V,$
$u * v = - v * u\,,$
$u * (v * w) = (u * v) * w.$

Can this operation satisfy the Jacobi identity
$u * (v * w) + w * (u * v) + v * (w * u) = 0 \quad \forall u, v, w \in V$?
I believe the answer is no, but I cannot prove it.
Attempted solution
Assuming the Jacobi identity holds, I tried to arrive at a contradiction.
\begin{align}
0 &= \phantom{-} u * (v * w) + w * (u * v) + v * (w * u) \\
  &= -(v * w) * u + w * (u * v) + v * (w * u) \\
  &= -v * (w * u) + w * (u * v) + v * (w * u) \\
  &= w * (u * v).
\end{align}
I.e., we have $w * (u * v) = 0$ for all $u, v, w \in V$. This doesn't look like a contradiction to me. It is as far as I could get.
Maybe a different approach makes more sense?
Comment: The zero product always works.
Answer: You have lots of possibilities. In what follows I will assume that you want to product to be bilinear.
What you proved is that a product of $3$ elements is always zero. Let us write $U\subset V$ the subspace of elements $u\in V$ such that $u*v=0$ for all $v\in V$. Then for any $u,v\in V$, $u*v\in U$.
Conversely, to define a product which satisfies your conditions, choose a subspace $U\subset V$, and a basis $(e_1,\dots,e_n)$ such that $(e_1,\dots,e_r)$ is a basis of $U$. You can then define the product by
$$ e_i*e_j = \sum_{k=1}^r a_{i,j,k}e_k$$
for all $1\leqslant i,j\leqslant n$ with the only conditions that $a_{i,j,k}=-a_{j,i,k}$, and $a_{i,j,k}=0$ if $i\leqslant r$.
This means you have to choose (freely) some scalars $a_{i,j,k}$ for $r<i<j\leqslant n$ and $1\leqslant k\leqslant r$ (if the charateristic of the base field is $2$, you also have to include $i=j$).
Answer: A Lie algebra $L$ is also associative if it is $2$-step nilpotent, i.e., if $[x,[y,z]]=0$ for all $x,y,z\in L$. The converse is also true. See the posts at MSE:
Associative Lie algebra
Does there exist a non-trivial, associative Lie algebra?
So your computation arriving at $u\cdot (v\cdot w)=0$ for the algebra product is completely correct. It is not a contradiction, on the contrary, it precisely describes the class of such algebras, being skew-commutative,
satisfying the Jacobi identity, being associative, and $2$-step nilpotent as a Lie algebra.
Comment: But is $w * (u * v) = 0$ for all $u, v, w$ a contradiction? In other words, does that imply that an anti-symmetric and associative operation cannot satisfy the Jacobi identity?
Comment: @user3749105 No, all $2$-step nilpotent Lie algebras satisfy $w\cdot (u\cdot v)=0$ (see the answer), so there is no contradiction. Except, if the Lie algebra is not $2$-step nilpotent. Then we obtain a contradiction. Note that people usually write $x\cdot y$ as $[x,y]$ for Lie algebras.


solving a singular integral equation using Mellin transform

Question:
Solve the following singular integral equation using suitable integral
  transform : $$\int_0^\infty u(t)\cos(xt)dt=e^{-x}$$

One easy method is if I use fourier cosine transform. But instead I chose to apply Mellin transform, to see what happens next. We know that $$\mathcal{M}\bigg(\int_0^\infty u(t)\cos(xt)dt;s\bigg)=U(1-s)\Gamma(s)\cos\bigg(\frac{s\pi}{2}\bigg)$$ where $U(s)=\mathcal{M}(u(x);s)$ and $$\mathcal{M}(e^{-x};s)=\Gamma(s)$$ Now, we have fom the given equation $$U(1-s)\Gamma(s)\cos\bigg(\frac{s\pi}{2}\bigg)=\Gamma(s)$$ $$\implies U(s)=\text{cosec}\bigg(\frac{s\pi}{2}\bigg)$$ Taking Mellin inverse $$u(x)=\frac{1}{2\pi i}\int_{c-i\infty}^{c+i\infty} x^{-s}\text{cosec}\bigg(\frac{s\pi}{2}\bigg)ds$$
Now I can't apply the method of residues as the cosecant term being present in the integrand. How to evaluate the above complex integral? Any help is appreciated.
Answer: Clearly, the Mellin transform identity for $\cos$ is valid only when $0<\Re s<1$. Hence, we are forced to choose $c\in (0,1)$ for Mellin inverse.
Let's first solve for $u(x)$ when $0<x<1$.
In this case, the integrand decays exponentially on the left half plane due to $x^s=e^{(\ln x)s}$. Hence, we choose a contour from $c-i\infty$ to $c+i\infty$, and close the contour by attaching a infinitely big semicircle on its left.
Obviously, the integral over the arc vanishes. Therefore, by residue theorem, the Mellin inverse equals
$$\sum\text{residues of $x^{-s}\csc\frac{\pi s}2$ on the left half plane}$$
Note that singularities enclosed are simple poles and are at $s=-2n$, $n=0,1,2,\cdots$. The residue is
$$x^{2n}\lim_{s\to -2n}(s+2n)\csc\frac{\pi s}2=\frac{2}{\pi}(-1)^n x^{2n}$$
Summing the residue from $n=0$ to $\infty$, we found that the Mellin inverse is
$$u(x)=\frac{2}{\pi}\frac{1}{x^2+1}$$
It is (un)surprising that we get the same result for $x>1$ (semicircle on the right half plane) - this is an instance of analytic continuation. Hence, we conclude that $\frac{2}{\pi}\frac{1}{x^2+1} $ is the solution of $u(x)$ for all $x>0$.
Note that this question is highly similar to another one I recently answered. The two different solutions are respectively the real and imaginary parts of $\frac 2\pi \frac1{1-ix}$, depending on whether it is a $\cos$ or a $\sin$.
Comment: I don't see the point of your answer, just to say that $\frac1{x^{-2}+1}$ is analytic for $|x|<1$ ?
Comment: @reuns To facilitate the OP's understanding of your answer.
Comment: @Szeto can you give me please a book that contains and explain in details the tools you used (the Mellin transform) ?
Comment: @SAKLY Mellin transform is the theme of the problem, but in my answer the main tool was residue theorem. For more details, you may consult any standard complex analysis book e.g. chapter 9 section III 'Calculus of Residues' of Visual Complex Analysis by T. Needham. You might want to go through previous chapters too if you find residues difficult in your first read.
Answer: $u(t)$ is defined for $t>0$ but $$\int_0^\infty u(t)\cos(xt)dt=e^{-|x|}$$
is defined for all $x\in \Bbb{R}$.
The inverse Fourier transform gives the unique solution $$u(t)=A(\frac1{t+i}+\frac1{-t+i}), t > 0$$
Expand in power series at $t=0$ you'll find that for $c\in (0,1)$, $t\in (0,1)$ it fits with $$\sum_{\Re(s) < 0} Res(t^{-s}\text{cosec}\bigg(\frac{s\pi}{2}\bigg),s)=\frac{1}{2\pi i}\int_{c-i\infty}^{c+i\infty} t^{-s}\text{cosec}\bigg(\frac{s\pi}{2}\bigg)ds$$
Then you need the analytic continuation theorem :

$\text{cosec}(\frac{s\pi}{2})$ has exponential decay on  the vertical line $\Re(s)=c$ thus its inverse Fourier/Laplace/Mellin transform is analytic.
Whence its inverse Mellin transform is the analytic continuation of $\sum_{\Re(s) < 0} Res(t^{-s}\text{cosec}\bigg(\frac{s\pi}{2}\bigg),s)$ ie. it is $A(\frac1{t+i}+\frac1{-t+i})$

The whole thing is called Ramanujan master theorem.
Comment: Please explain further what you have written in the quotation. I am not familiar with this concept. I just know what is analytic continuation.
Comment: The inverse Fourier transform is given by an integral, the exponential decay implies this integral converges and is holomorphic and analytic not only for $t$ real but also for every $t\in \Bbb{C}$ with $|\Im(t)|$  not too large
Comment: Ok. But why the inverse Mellin transform is the analytic continuation?
Comment: If you don't see that inverse Mellin transform and inverse Fourier transform are the same thing then you have a problem


When data size is very large, would it still matter which model to use?

Question: I'm new to machine learning models and do not have an opportunity to run real business models.
Doing some studies on classification models using SK-learn (SVM, Logistic, tree based models and etc.) I wonder if I have really large data size to do the training, would it still be a matter what model I choose to fit the data and then use on test data? My naive guess is the more data you have, the less likely the type of the model matters. Also, if we really have huge amount of data, we probably cannot run many alternative models to see which one is better, because it may take days to fit even just one model.
Therefore my naive conclusion is, in real business where people running model against their huge customer base, they won't have the needs of trying many model options or grid search many parameter settings but still can come up well performed model.
Is my naive understanding valid? :)
Answer: Model selection definitely matters.  If you choose a model with high bias,  all the data in the world will not improve the fit.  For instance, no matter what the training size is, a linear regression won't be able to fit data generated from a quadratic process (and yes I know you can include a quadratic term, but what happens when you have hundreds of variables?  How will you know what kinds of terms to include?).
Comment: Thank you Demetri for your answer. I wonder what people do in real business, with super large data. Do you think they pre-select the model with smaller sampled data set to play with fancy models and tons of tuning before applying the best choice onto the real large one?
Comment: In my experience, highly flexible models are used with sampled data.  There is not a ton of time to play with parameter tunings.  Often times, good enough is good enough.  Keep in mind that companies often have HUGE compute to throw at a problem.  They aren't making models on their laptop.


Causal model assumptions - regression adjustment to experiments

Question: Suppose we want to explain an experiment with the following model:
$$Y \sim \beta_1 X + \beta_2R + \varepsilon$$
where $X$ are endogenous variables and $R$ is a randomized treatment level. To interpret the outcome of an OLS fit of this model as causal it seems like we want to verify different assumptions: (1) $ R \perp \varepsilon$, and (2) $ X \perp \varepsilon$. If (1) holds but (2) doesn't, can we still interpret the coefficient for $\beta_2$ as causal? What other options do we have?
Comment: Is your equation meant to be a causal model or just a regression? Why do you worry about causality if R is actually randomized? And from where do you get the assumption that $R \perp \epsilon$?
Comment: @JulianSchuessler it's meant to be a causal model - R is a randomization that the experimenter controls (assumed perfect as random numbers can be)
Comment: You can view it as analyzing data from a randomized controlled trial while adjusting for a (non-randomized) baseline covariate. This is a standard thing to do and one can find plenty of discussion thereof, e.g. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2886040/
Answer: There are some things that need clarification here.
Is $Y = \beta_1X + \beta_2R + \epsilon$ a structural equation? That is, do you believe the structural relationship between the variables  you listed and the outcome is truly linear?
If this is the case, that is, if you truly believe the regression represents the structural equation of the model, then the answer is trivial --- if $R\perp \epsilon$ then you can identify $\beta_2$ regardless of the relationship between $X$ and $\epsilon$ (since you randomized $R$, we  also have that $R \perp X$, assuming $X$ is not a collider or mediator --- more on that below).
However, if $Y = \beta_1X + \beta_2R + \epsilon$ is not a structural equation then things are more nuanced.
First you have to define what it is that you want to estimate, since $\beta_2$ is not a structural parameter per se. Usually you want to estimate the average treatment effect (ATE).
The first thing to keep in mind is that, since you performed an experiment, you can obtain the ATE by a simple difference in means, with no need to perform a regression.
Sometimes you want to control for other factors outside the experiment though, in order to reduce the variance of your estimate. When doing regression with experiments, you can stil get a consistent estimate of ATE, even if the true relationship is not linear.
But you have to keep some things in mind. As Freedman (2008) has shown, using a finite sample potential outcomes model:

Regression estimates are biased (though the bias gets small with
large samples);
The effect on asymptotic precision is not unambiguous: it may
improve or make it worse, depending mainly on balance between
treatment and control (if it's not balanced, it depends on other
things which are hard or impossible to measure);
Usual (homoskedastic) estimated standard errors can overstate precision.

However, as Lin (2013) points out, with sufficiently large samples, these problems can be fixed. OLS adjustment cannot hurt asymptotic precision when a full set of treatment-covariate interactions is used. Also, asymptotic valid confidence intervals can be obtained using heteroskedastic consistent estimators.
Another big problem is that once you start including covariates and different specifications to your model, you are doing specification searches. As soon as the researcher try different sets of covarites looking for a "preferred" specification, the nominal type I error does not hold anynore.  So if you are using frequentist statistics (like p-values) to make judgements about your data you have to keep this in mind.
In short, you can perform multiple regression adjustment to your experiment but: (i) make sure you have enough samples and include full sets of interactions; (ii) use the appropriate standard errors; (iii) always show your reader the unadjusted simple difference in means, which is the more "trustable" "hands of the table" estimate.
One final note, even if your $R$ is randomized, you should be careful about what variables you are controlling for., You should not control for colliders and you should not control for mediators if you're interested in the total effect, for instance.
Comment: If the R variable is actually randomised , then there should not be any significant (meaningfull) difference in the estimate of $\beta_2$ regardless of whether X is included or not...
Comment: @Repmat you can have "small sample bias"
Comment: Let me posed a related specific question about this model. We are interested on ATE. If we eliminate the controls ($X$) we achieve the easiest case where $\beta_2$ represent anyhow the average causal/treatment effect of $X$ on $Y$. This result holds even if  the researcher know nothing about the difference between regression and structural model, or better, he never heard the concept of structural model.
Comment: Also in this case the above result holds, or at least I think so. Considering that, until now, we say nothing about the meaning of $X$ and $Y$, we have a causal conclusion but where are the causal assumptions?
Comment: More clearly: it is not clear to me if causal assumptions are necessary in experimental paradigm. If yes, why?
Comment: @markowitz the technical definition of a causal assumption is a constraint on the causal model. In the case of randomization the constraint is $Y_r \perp R$, that is, the potential outcome is independent of treatment assignment. This is the assumption you make in an experiment, which amounts to saying you believe the experiment was successful.


How to execute custom code at Drupal startup

Question: What's the correct way to execute code from an existing custom module at Drupal startup? The code checks certain private_tempstore values and sets other values based on what it finds. It should be executed before page processing occurs so that pages can respond to the changed values.
I've read many posts, looked through the list of hooks, tried a few without success, looked at event subscribing, etc. All my searching and trying hasn't found an approach that works correctly for my situation.
Example custom code (not the real code):
$rsc = \Drupal::service('user.private_tempstore')->get('rsc');
$val = $rsc->get('temp_val');

if ($val == 100) {
  $rsc->set('temp_val', 200);
}

What I've tried:
hook_page_build() // in mymodule.module
hook_page_alter() // in mymodule.module
path: '/*' // in mymodule.routing.yml

No error messages, just no results via an error_log() in the custom code to show that it was executed.
Comment: Could you please you tell us more about what you specifically tried and maybe share some code, as well as error codes or descriptions of what didn't work?
Comment: More context around what you're specifically hoping to accomplish would be useful too, as that will probably steer where the code needs to go, how you approach caching, etc
Comment: Something like this article? http://www.drupal8.ovh/en/tutoriels/357/event-subscriber-replace-hookboot-and-hookinit
Comment: This is essentially the same info as @RyanHartman's comment, but maybe easier to grasp: https://chromatichq.com/blog/replacing-hookboot-and-hookinit-functionality-drupal-8
Comment: @Beau I have added some example code and showed what I've tried.
Comment: @Ryan Hartman I had read this article before I posted, but don't understand how it would be used in my case. Seems like some bit of instruction is missing (probably only me).
Comment: @Beau I found this link easier to follow. It led me to https://www.chapterthree.com/blog/how-to-register-event-subscriber-drupal8 which I'm going to try.
Answer: First of all, User module's user.private_tempstore and user.shared_tempstore services moved to core. So we want to use the tempstore.private.
The code below will get your started. you will want to read more about how getSubscribedEvents() works, as here is where you tweak the where and when of your event.
Don't forget an .info.yml file!
/mymodule/mymodule.services.yml
services:
  mymodule.mymodule_subscriber:
    class: Drupal\mymodule\MyModuleSubscriber
    arguments:
      - '@tempstore.private'
    tags:
      - { name: 'event_subscriber' }

/mymodule/src/MyModuleSubscriber.php
<?php

/**
 * @file
 * Contains \Drupal\mymodule\MyModuleSubscriber.
 */
namespace Drupal\mymodule;

use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\Core\TempStore\PrivateTempStore;

/**
 * Provides a MyModuleSubscriber.
 */
class MyModuleSubscriber implements EventSubscriberInterface {

   /**
   * The PrivateTempStore Service
   *
   * @var PrivateTempStore
   */
   protected $privateTempStore;

   /**
   * MyModuleSubscriber constructor.
   *
   * @param PrivateTempStore $privateTempStore
   */
   public function __construct(PrivateTempStore $privateTempStore)
   {
     $this->privateTempStore = $privateTempStore;
   }

   /**
   * // only if KernelEvents::REQUEST !!!
   * @see Symfony\Component\HttpKernel\KernelEvents for details
   *
   * @param Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   *   The Event to process.
   */
  public function MyModuleLoad(GetResponseEvent $event) {
    // @todo remove this debug code
    drupal_set_message('MyModule: subscribed');
    // Interact with the tempstore
    $value = $this->privateTempStore->doSomething();
  }

/**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array('MyModuleLoad', 20); // Like hook_init (Cached)
    // Priority greater than 200 alow to skip caching, like functionality of hook_boot.
    //$events[KernelEvents::REQUEST][] = array('MyModuleLoad', 300); // Like hook_boot (not Cached)
    return $events;
  }
}

Comment: Thanks, I'll give this a try and report/accept the answer.
Comment: This worked for me after a little trial and error. Thanks so much @Ryan Hartman!


$(a) \sum_{n=2}^{\infty} \frac{3}{n^2+2n}$ Determine whether it converges and find sum

Question: Determine whether the following are convergent or divergent. If it is
convergent find its sum. Make sure to fully justify all of your work.
$$(a) \sum_{n=2}^\infty \frac{3}{n^2+3n}$$
Solution (My attempt):
Let $f(n) = a_n$
On $[2,\infty), f(x) = \frac 3 {x^2+3x} > 0$
$$f'(x) = 3\left(\frac{-(2x+3)}{(x^2+3x)^2}\right) < 0, \forall x \in [2,\infty)$$
Therefore the hypothesis of the integral test is met.
Consider
$$\lim_{A\to\infty} \int_2^A \frac 3 {(x)(x+3)} \, dx$$
$$\lim_{A\to\infty} \int_{2}^{A} \left( \frac{1}{x} - \frac{1}{x+3} \right)dx \text{ By pfd}$$
$$\lim_{A\to\infty} \left( \ln \right(\frac A {A+3}\left) - \ln \right(\frac 2 5 \left)\right) $$
$$= \ln 1 - \ln \left(\frac{2}{5}\right)$$
Therefore by Integral test the original series converges.
I was never thought how to find the sum of this type of series. The only way I know how to find the sum of a series is if its geometric. Does anyone know how too find the sum?
Comment: Hint:
Use the following identity:
$$\frac{3}{n^2+2n}=\frac{3}{2n}-\frac{3}{2(n+2)}.$$
Answer: To compute the sum observe
\begin{align}
\frac{1}{n(n+2)} = \frac{1}{2n}-\frac{1}{2(n+2)}
\end{align}
which means
\begin{align}
\sum^\infty_{n=2}\frac{3}{n^2+2n} =&\ \frac{3}{2}\sum^\infty_{n=2}\left( \frac{1}{n}-\frac{1}{n+2}\right)\\
=&\ \frac{3}{2}\sum^\infty_{n=2}\left(\frac{1}{n}-\frac{1}{n+1}\right)+\frac{3}{2}\sum^\infty_{n=2}\left(\frac{1}{n+1}-\frac{1}{n+2}\right)\\
=&\ \frac{1}{2}+\frac{3}{4}.
\end{align}
Comment: Is  this telescoping? So if i telescope i get this answer?
Comment: Yes, this is telescoping sum.
Answer: An alternative approach. The given series is absolutely convergent since the main term behaves like $\frac{1}{n^2}$ and $\sum_{n\geq 1}\frac{1}{n^2}$ is convergent by the $p$-test. We have
$$ \frac{3}{n(n+3)}= \int_{0}^{1}\left(x^{n-1}-x^{n+2}\right)\,dx \tag{1}$$
hence the whole series equals
$$ \int_{0}^{1}\sum_{n\geq 2}\left(x^{n-1}-x^{n+2}\right)\,dx = \int_{0}^{1}(x+x^2+x^3)\,dx = H_4-1=\color{red}{\frac{13}{12}}.\tag{2}$$
Answer: An often used technique in this situation is called partial fraction decomposition; set:
$$\frac{3}{n(n+2)} = \frac{A}{n} + \frac{B}{n+2}$$
and solve for $A$ and $B$. You will find $A = 3/2$ and $B = -3/2$, which means:
$$\frac{3}{n(n+2)} = \frac{3}{2n} - \frac{3}{2(n+2)}$$
The series now "telescopes" as others have just posted. If you have never seen this method before, here is how you actually solve for $A$ and $B$:
Multiplying the first equation by $n(n+2)$ on both sides yields:
$$3 = A(n+2) + Bn \implies 0n + 3 = (A+B)n + 2A$$
The $0n$ is included for emphasis, for this means $A = -B$. Now, all there is to do is observe that you have $2A = 3$, i.e., $A = 3/2$, which yields $B = -3/2$ as desired.

Also, for what it's worth: A different way to show that the series converges is to observe that each term is less than $3/n^2$, which means the series is bounded above by $3 \sum_{n>1}1/n^2$, which is just three multiplied by a convergent series (perhaps what you call a $p$-series). Since the series is monotonically increasing and bounded above, it must converge.
Answer: Consider the partial sum $$S_p=\sum_{n=2}^p\frac{3}{n^2+3n}=\sum_{n=2}^p\frac{1}{n}-\sum_{n=2}^p\frac{1}{n+3}$$ $$S_p=\left(\frac 12+\frac 13+\frac 14+\frac 15+\cdots+\frac 1p\right)-\left(\frac 15+\frac 16+\frac 17+\frac 18+\cdots+\frac 1{p+3}\right)$$ What is left is $$S_p=\frac{13}{12}-\frac{1}{p+1}-\frac{1}{p+2}-\frac{1}{p+3}=\frac{13}{12}-\frac{3 p^2+12 p+11}{p^3+6 p^2+11 p+6}$$ Now, for large $p$, perform the long division (or Taylor series) to get $$S_p=\frac{13}{12}-\frac{3}{p}+\frac{6}{p^2}-\frac{14}{p^3}+O\left(\frac{1}{p^4}\right)$$ For $p=10$, $S_{10}=\frac{119}{143}\approx 0.8322$ while the expansion gives $\frac{311}{375}\approx 0.8293$.
You also could use the harmonic numbers and arrive to $$S_p=\frac{13}{12}+H_p-H_{p+3}$$ and using the asymptotics $$H_n=\gamma +\log \left({n}\right)+\frac{1}{2 n}-\frac{1}{12
   n^2}+O\left(\frac{1}{p^4}\right)$$ and arrive to the same result.


flot bar graph clickable bars displaying incorrect information

Question: I'm trying to make it so that when a bar on my graph is clicked, the x-axis label of that specific bar is printed out/displayed in a span. My ultimate goal is to make it so that when a bar is clicked, another bar graph is created underneath that displays more detailed information about that specific bar, think broad information on the first graph and when a bar is clicked, more detailed information is displayed in another bar graph underneath.
Test table in my db:

x -------------   y
  0 -----------   1000
  1 -----------   2000
  2 -----------   3000
  3 -----------   4000
  4 -----------   5000
  5 -----------   6000
  6 -----------   7000
  7 -----------   8000
  8 -----------   9000

Query:
   $sql = "SELECT * FROM flotTest";
   $result = mysqli_query($dbc3, $sql);

    while($row = mysqli_fetch_assoc($result))
    {
        $dataset1[] = array($row['x'],$row['y']);
    }

flot js:
     // BAR CHART
        var percentagehrs = [];
        for (var i = 0; i <= 8; i += 1){
        percentagehrs.push([i, parseInt(Math.random() * 200)]);
}
        var dataset = [{
            label: "Percentage Hours",
            data: percentagehrs,
            color: "#5482FF" }];

        //x-axis label and index pulled from database (testing purposes)
        //I'm thinking this might be where my issue is

        var ticks =  <?php echo json_encode($dataset1); ?>;

        $(document).ready(function () {
            $.plot($("#group-flot-placeholder"), dataset, {
            series: {
                bars: {
                    show: true,
                    clickable: true
                }
            },
            bars: {
                align: "center",
                barWidth: 0.8
            },
            xaxis: {
                axisLabel: "Job Number",
                axisLabelUseCanvas: true,
                axisLabelFontSizePixels: 12,
                axisLabelFontFamily: 'Verdana, Arial',
                axisLabelPadding: 10,
                ticks: ticks
            },
            yaxis: {
                axisLabel: "Percent",
                axisLabelUseCanvas: true,
                axisLabelFontSizePixels: 12,
                axisLabelFontFamily: 'Verdana, Arial',
                axisLabelPadding: 3,
                tickFormatter: function (v, axis) {
                    return v + "%";
                }
            },
            grid: {
                clickable: true,
                hoverable: true,
                borderWidth: 2,
                backgroundColor: { colors: ["#ffffff", "#EDF5FF"] },
                markings: [ { xaxis: { from: -1, to: 12 }, yaxis: { from: 100, to: 300 }, color: "#FFA5A5" }]
            }
        });
            $("#group-flot-placeholder").UseTooltip();

            $("#group-flot-placeholder").bind("plotclick", function (event, pos, item) {
            if (item) {
                $("#clickdata").text(" - click point " + item.dataIndex + " in " + item.series.label);
                plot.highlight(item.series, item.datapoint); //Output here is: - click point 0(0 being the position of the first bar) in Percentage Hours
            }
        });

        });

What am I doing wrong and how can I make it so that when a specific bar is clicked, I can pull data from my database to another bar graph underneath for that specific bar?
Comment: Could you make a jsfiddle with this, just to be more clear. ?
Comment: @Sergio http://jsfiddle.net/MKWB6/ Thats basically what it looks like right now. The big difference is that I'm parsing data from a db as you can see above where it says var ticks =

I will edit the above to show my sql and table as well.
Answer: You don't say what <?php echo json_encode($dataset1); ?> resolves to, but it should be in the form of:
var ticks = [[0,"A"],[1,"B"],[2,"C"],[3,"D"],[4,"E"],[5,"F"],[6,"G"],[7,"H"],[8,"I"]];

So, in your click callback:
$("#group-flot-placeholder").bind("plotclick", function (event, pos, item) {
    if (item) {
        var tickClicked = item.series.xaxis.ticks[item.dataIndex].label;
        $("#clickdata").text(tickClicked);
    }
});

Here's a fiddle demonstration.
Comment: Edited my post to show what json_encode($dataset1) resolves to

EDIT: Just tried your click callback and it worked. I'm now getting the job number to display from the x-axis, thanks. Do you have a suggestion for my second question?
Comment: @MikeOscarEcho, was the second question "how to display a aecond plot after the click?"  If so, it's awfully a broad question but in a nutshell, I would: in the click handler, make an AJAX call back to the PHP to fetch data appropriate for that column, in the success handler of the AJAX call I would make the `$.plot` call.


Can I use semi-acoustic guitar with overdrive (or compressor) without getting feedback?

Question: Old-school method like to put lots of paper into body of guitar is not recommended in here =))
Anyway, I saw on youtube that one guy having delay+compressor+overdrive+reverb played with epiphone DOT, and his amp was not so far from his guitar infact.. how it's possible? When I turning on my distorsion and especially reverb, speakers goes mad about feedback that squicky sound (don't know how it called in english).
How can I control this kind of stuff and what the theory of this "effect"? My semi-acoustic guitar is twice fatter then epi-dot.
Answer: The "Theory" is called resonance. I'm sure you've seen this video before: Tacoma Bridge
Every object have frequencies which they vibrate easiest at. You can think of it as if you shook it at a certain frequency it will be easier than at other frequencies.
An acoustic guitar is designed to vibrate easily at many frequencies(a whole range) i.e., so you can get a louder sound. This is basically resonance at work. When the strings vibrate on an acoustic guitar they move the are around them which goes into the guitar hole and change the pressure in the guitar. The strings are also attached to the neck and bridge which causes the guitar to "flex" which causes the air around the guitar to move too.
Now a guitar has some frequencies that it is better at amplifying than others. When a loud sound is played with those frequencies in it near the guitar it will amplify them much more than other frequencies. Since you have  transducer which takes that sound and feeds it back into the guitar(Through the amp's speakers) you have a feedback system. This is called positive feedback because it results in a net gain in amplification.
Notice how your guitar seems to feedback at a certain frequency? This is one of the frequencies that the guitar resonates at. If you play a sound without this frequency in it or much lower than others it will resonant but not as much. Why? Because generally resonances works on an exponential scale(or better a logistics scale). The feedback cycle can grow very quickly then reaches a point where just can't go any higher(the high cannot produce any louder sound).
So, how can one control such feedback? One is to find the resonant peaks of the guitar and EQ them down. This may not be preferable because of the tonal repercussions.
Another way is to change the position of the guitar relative to the speakers. The guitar is 3 dimensional and it's resonating frequencies are actually modes that exist in 3D space. They are not symmetric. Also the frequency may be dampens by the human body or guitar body along it's path to the guitar's cavity.
Changing the amount of acoustic resonance can shift the resonant frequencies or dampen them enough to reduce the feedback. You can do this by adding/removing weight to the guitar or adding material into the cavity of the guitar that alters the shape of the cavity.
The problem is, is that acoustic guitars are designed to amplify pressure waves. Your amp is creating pressure waves and your pickup is picking them both up. The acoustic guitar cavity is basically taking the sound from your amplifier and adding it into the pickup's. This creates a vicious cycle. If you were to draw the way a sound would move through the signal chain you would see that some of it would go into a circle.
Sound out of guitar -> into Amp -> out of Speakers -> (some) Into Guitar's Acoustic Cavity -> Picked up by transducers -> Becomes part of the sound out of the guitar -> Sound out of the guitar
Each time you go through the cycle though you get more and more sound out of the amp since at first you start with no sound from the amp and each time the amp's output gets louder.
Even solid body's can have a lot of feedback. Low amp volume is the only way to ultimately control it(there is a point where no matter what you do you'll get feedback and it will always be positive).
Note though, Amp's can be designed for low feedback. If your amp is a high gain amp then it will have a tendency to feedback more than a low gain one. They can't completely eliminate the problem but an Amp's circuitry can also experience positive feedback and resonate. This can easily compound the problem of acoustical feedback.
No one will be able to offer you a specific solution because it will depend on way to many factors. You are simply going to have to sit down and figure out how to reduce the feedback. For all you know the guy was running his amp very quite and just enough to mic it? Or maybe he did use paper in his guitar? Or maybe his guitar was just not very resonant? The Guitar, Amp, Room, Effects, Body shape, Cloths you were, etc all have an effect on it.
Comment: It may be worth mentioning that when using an amp "clean", having the volume low enough not to totally blast the guitarist will usually mean the gain is low enough not to cause feedback *but* using a compressor or distortion will cause the gain at low volumes to be much higher than it otherwise would.  If with loud sounds the gain is set at 5% of the point that would cause feedback noises, but quieter sounds are boosted 100-fold, then the amplifiers will generate annoying feedback noises at whatever level would cause gain to fall back to a factor of 20.
Answer: From my on the road experience, the best way to control feedback is to reduce stage volume. I understand this is not easy to do on a crowded stage (if you play small bars and whatnot), and especially if your bassist enjoys turning his amp to thunderous volume levels (been there) but from my limited experience, there's a couple of things you can do. AbstractDissonance nailed the reason why you get feedback, and here's a couple of strategies that I have used to reduce it:
In Ear Monitors. These things are expensive, but will help you reduce stage volume. Wedges tend to generate muddy mixes anyway--unless you have a really nice set.
Turn all amplifiers away from stage front, or isolate them in a different room. This is just good common sense. If you are using your amplifier as a monitor then you likely aren't hearing the rest of the band enough. That's a mistake. Never live in "guitar world" when playing with a full band. Also most amplifiers have a tendency to "beam" certain frequencies at different positions on the speaker cone which is a natural effect from the physical properties of the speakers. Having a blasting amplifier pointed straight at your audience is a sure way to deafen some folks, and will likely annoy your sound engineer (they're a controlling lot when it comes to volume).
Turn it down. Even if your amp goes to 11, that doesn't mean you have to play with it there all the time. Although most tube based amplifiers sound good at higher volume levels (there's some physical properties at work there) you can definitely find a happy medium if you must use your amp as a monitor, else isolate the amp and turn it as loud as you want.
All of these strategies basically function to lower your stage volume. These won't work in 100% of cases, but they're a good starting point.
Answer: Feedback (technically 'positive audio feedback') is the noise you hear when an input (guitar pickup/mic) sends a signal to an output (an amp) and then picks up the amplified sound again, and sends that down to the output and outputs that. This loop continues, creating that sound. Feedback increases in volume over a short period of time because of the different levels of re-ampfliciation happening as the signal travels around the loop. There are more technical reasons to do with why feedback occurs, but I do not have enough knowledge to be able to explain them :(
How much feedback occurs can depend on a number of factors. It can differ depending on the frequencies that the mic/pickup picks up, the frequencies the amp is set at, how much gain is added, room resonance and direction of the input device in relation to the output.
The guy you mention may have turned the guitar pickup volume down, and the amp volume up to compensate for the loss in volume. By doing this, the pickups would not have been 'inputting' as much signal as if they were at full volume, hence it does not pick up the amp sound as much.
To reduce it yourself, you could try the trick I outlined above (it seems to work for me), as well as not having your guitar face your amp when you play. Feedback also depends on room frequencies, so experiment with the EQ on your amp and find works best to reduce feedback both on your guitar, and in the environment in which you play. In my experience I have found that generally boosting the mids causes a greater feedback effect.
Hope this helps.


How to prevent Content type from appearearing in built-in Search results

Question: I've got thousands of nodes which were created by importing using a Feeds module. I only want them to be searchable via the views search form, not by the built-in site search.
Is it possible to disable these nodes from being searchable by the built-in search, while still making it available to the search generated by a View?
Answer: There are two modules you can check out.
Search Config

Restrict search results by the content type. This is a role based
  restriction.

Search Restrict

Restrict by role who can search for each content type.
Approach of this module is to re-write the search query, so that
  content is indexed and available as search results to users in role(s)
  that have permissions to view it, but not displayed to other roles.

OR
You can write your own query alter function.
<code>function mymodule_query_alter(&$query) {
  $is_search = FALSE;
  foreach ($query->getTables() as $table) {
    if ($table['table'] == 'search_index') {
      $is_search = TRUE;
    }
  }

  if ($is_search) {
    $query->condition('n.type', 'node-type-name', '<>');
  }
}
</code>
And yes as webkenny suggested Custom Search as well.

Basic options
The module adds options to select:

which content type(s) to search,
which specific module search to use (node, help, user or any module that implements search),
advanced criteria

For all these choices, there are options to switch between a select
  box, checkboxes or radio buttons, and also customize the selector
  label and the default - Any - text.
Comment: You totally won this one. ;)
Answer: As we say in this community, "There's a module for that" - http://drupal.org/project/custom_search
Good module to add-on if you're using the core search module. Won't affect your views in any way since those are two different flows.


Feeds auto create is not working

Question: Am using Drupal 7 Feeds module and I have "Autocomplete term widget (tagging)" field in content type.
As well as I have configured as "Auto create". But, when I import nodes that auto creation does not working, its shows the blank field.
Any other way to do?
Answer: If Feeds creates empty values on Auto create, you need to verify your mapping. Make sure your Context Value in XML Xpath parser is fetching the right data by enabling Debug option, so you can see exact value being imported. If it's not, please validate your XPath on your sample data (for example, on XPath Tester).
If your XPath is correct, then use hook_feeds_after_parse() to debug your feed items.
/**
 * Implements hook_feeds_after_parse().
 * Invoked after a feed source has been parsed, before it will be processed.
 */
function MYMODULE_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) {
  foreach ($result->items as &$item) {
    drupal_set_message(print_r($item, TRUE));
  }
}

Feeds auto create is not working


How does ScyllaDB/Cassandra handle partial update?

Question: Assuming there is one row which has 10 columns.
If I only update one column, before the merging/compaction, will the database create a new partition with only the updated column (containing the new value) in SSTable or it will create a new partition with all the 10 columns (the new column containing the new value)?
Answer: Just the one column will be written, it's a bit different pre/post 3.0 on how its actually stored though. You can use the sstabledump tool to examine whats actually stored to test it if you would like.


Symfony3: form: populate select with related model entries

Question: I have two models, topic and user. Both are related by many-to-one relationship (a topic is defined by only one user) such as:
class User
{
    private $idUser;
    private $username;
}

class Topic
{
    private $idTopic;
    private $topicName;

    private $idUser;
}

MAIN CONCERN: I would like (using symfony-forms) to create a creation form for the topic model. The form would contain:

a topic name input
a user select (list populated by the existing users in the database. The displayed value would be the username of course).

I have created a TopicType class that will build the topic creation form:
class TopicType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->
            ->add('topicName')
            ->add(/* 'idUser', 'choice',  'THE USER LIST ???*/)
    }

    public function configureOptions(FormBuilderInterface $builder, array $options)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AppBundle\Entity\Topic'
    ));
    }

}

How can I retrieve the list of users and populate the choices considering I don't have access to the entity manager in TopicType context?
Could I pass a $users array in the controller as a parameter when invoking createForm method ? If so, how ?
If you understood what I'm trying to do, Is there a better/simplier way to get it done ? Am I missing something ?

I know this question might look similar but all the solutions I found on related topics are somehow deprecated in Symfony3
Any help would be much appreciated.
Have a good day to you all.
Answer: you should try something like this (you must adapt the code):
  ->add('User', EntityType::class, array(
    'class'    => 'xxxBundle\Entity\User',
    'choice_label' => 'username',
    'required' => true,
    'multiple' => false,
  ))

do not forget :
use Symfony\Bridge\Doctrine\Form\Type\EntityType;

More info here : http://symfony.com/doc/current/reference/forms/types/entity.html


Qual a diferença entre ponteiro e referência?

Question: Uma das primeiras coisas que aprendi sobre Java é que essa linguagem "não possui ponteiros, somente referências", seguida de algumas afirmações genéricas de como o primeiro é complexo e o segundo é mais simples. Mas nunca entendi exatamente qual a diferença de um para o outro. Há alguma diferença, ou conceitualmente eles são a mesma coisa?
Esclarecendo, eu sei que nem Java nem a maioria das linguagens que só suporta referências permite que seja feita aritmética com essas referências. Algo como:
Object x = ...;
x++;

não é permitido. Mas seria isso apenas uma restrição às operações que a linguagem deixa fazer ao mesmo tipo (ponteiro)? Ou são de fato conceitos diferentes?
Answer: TL; DR
Ponteiro é um mecanismo com baixo nível de abstração que contém um endereço de memória para um objeto qualquer. Esse endereço é o foco dele e esse valor pode ser manipulado livremente pela aplicação como um dado qualquer. Muitas linguagens escondem totalmente sua existência.

Referência é um conceito mais abstrato e nem sempre visível na linguagem. Ela cria um conjunto de dados formado pelo objeto que é o seu foco e a referência que indica onde o objeto está. Essa referência pode ser composta por um ponteiro. A manipulação da referência é limitada, inclusive porque ela dá preferência para a manipulação do objeto.
São duas maneiras de conceituar algo muito parecido e muitas vezes o mesmo. Isto tem implicações nos detalhes de uso, mas servem pro mesmo propósito.
Introdução
Eu não tenho informações baseadas em estudos confiáveis publicados, então para responder eu me baseio principalmente na Wikipedia e no que sempre aprendi.
Vou tentar dar uma interpretação universal que me parece ser a intenção da pergunta e não para uma tecnologia específica e mostrar quando é algo especifico de uma linguagem sem entrar em detalhes.
Ponteiro
Ponteiro (em inglês) é uma construção mais concreta. Ela existe mesmo no nível mais baixo da programação. Um processador manipula ponteiros. Conforme a Wikipedia, um ponteiro - ou apontador para os gajos e gajas do velho continente - é um valor que se refere a outro valor alocado em outra área da memória.
Eu não gosto muito dessa definição por que ela implica que ponteiros só apontam para dados. Ok, qualquer coisa no computador de alguma forma pode ser considerada um dado, até mesmo código. Mas é uma interpretação ambígua. Por isso prefiro ver o ponteiro como um apontamento para alguma área da memória.
Porém, gosto que ele cita a memória. Me parece que o conceito de ponteiro seja mais específico para a memória. Ainda que eu mesmo utilize o termo em outras situações, me parece mais adequado que ele seja usado apenas para o tratamento de memória.
Algumas linguagens permitem manipulação direta de ponteiros em maior ou menor grau. Podemos dizer que essa é uma das formas que ajudam classificar linguagens pelo seu nível de abstração. Ou seja, se a linguagem manipula o ponteiro de forma muito liberal, concreta e direta, a linguagem é mais baixo nível, como é o caso dos Assemblies. Outras linguagens como C, C++, D, Rust, Go, Pascal, só para ficar em alguns exemplos, também fazem uso liberal dos ponteiros mas com algumas limitações e cada uma delas com menos incentivo, fornecendo outras formas mais abstratas de obter o mesmo resultado. Outras linguagens abandonam completamente a manipulação de ponteiros, como o Java, Python e JavaScript. Outras impõem grandes limitações, como o C#. Essas linguagens são mais alto nível.
Provavelmente C é a linguagem mainstream que mais incentiva e que mais popularizou o uso de ponteiros. De fato C não possui referências (diretamente). E muitas definições do que é ponteiro irão se confundir com o que se usa em C.
Ponteiros são sempre valores, então parâmetros do tipo ponteiro são passados por valor, ou seja, o endereço guardado no ponteiro é copiado. Há uma independência do que ele está apontando. Quando você se refere ao ponteiro, está se referindo ao endereço contido nele. Se quer o objeto deste endereço, precisa explicitar isto.
É comum usar ponteiros para obter performance, afinal ele se aproxima o processamento concreto. Uma das operações comuns em ponteiros é a aritmética, assim manipula o acesso às posições de memória de forma muito fácil e rápida. Claro que sempre há o risco de alguma operação ser irregular e causar resultados indesejados. Ponteiros não costumam ser seguros para manipular indiscriminadamente. Embora sua flexibilidade de fazer, até mesmo, operações potencialmente irregulares é que dá grande poder a ele. Grande poder, grandes responsabilidades. O programador tem que saber tudo o que fazer e como fazer. Ele não automatiza "nada".
Mas não se engane, o ponteiro ainda é uma abstração. O ponteiro é uma forma de se referenciar objetos na memória.
Referência
Uma referência (em inglês) me parece ser algo mais amplo. Você pode ter referências para algo que vai além da memória. Mesmo na memória você pode ter referências que por si só ainda não podem ser considerados ponteiros. Referência, como o próprio nome diz, se refere a algo, mas esse algo pode ser mais livre. O artigo da Wikipedia diz que ela é um objeto que contém informação que indica dados armazenados em algum outro local ao invés de conter o próprio dado.
Uma referência é composta de duas partes. Um endereço que indica onde o dado está e o próprio dado. Isto é diferente do ponteiro que não tem uma relação direta com o dado. Você não faz muitas operações com referências, não tem aritmética, por exemplo. Você pode trocar o valor da referência mas não pode manipulá-lo livremente. Claro que em memória uma referência direta provavelmente será implementada através de um ponteiro. Mas é possível ter uma referência que não seja um ponteiro.
A referência é um conceito mais abstrato e por isto, dependendo de como ela será usada, esse nível de abstração pode ser um pouco diferente. A forma como se lida com esta referência pode ser diferente. Em alguns casos o programador talvez possa até ignorar que aquilo seja uma referência.
Uma coisa que aprendi lendo os excelentes artigos do Eric Lippert é que uma referência deve ser interpretada como um alias para um dado, para um objeto.
Ou seja, é só um nome que damos para o objeto, por isso ela sempre é uma variável. E você pode ter quantos aliases quiser para ele. Ter apenas um alias tem implicações na forma como o dado será manipulado. Claro que internamente esse alias provavelmente será manipulado com ponteiros mas a forma será diferente e principalmente, não será problema do programador.
Quando dizemos que passamos algo por referência, significa que passamos o valor da referência - há uma cópia da referência, mas nossa intenção é passar o dado a que ela se refere. É comum, mesmo em linguagens de mais baixo nível que possuem mecanismos próprios de referência, não dar acesso direto ao endereço da referência, porque ele não é importante e sim o seu dado referenciado. Assim, referências são muito mais seguras que ponteiros. Quando acessamos uma referência, está implícito que queremos acessar seu objeto referenciado. É até uma questão de semântica clara.
Em linguagens de muito baixo nível, como Assembly e C, não possuem mecanismos que tratam de referências, você as simula com ponteiros. Em outras, como C++ e D, isso pode ser feito explicitamente. Nas linguagens de mais alto nível o uso delas é tão opaco que o programador pode até usá-las sem ter ciência que está usando uma referência. Não importa muito o quanto a linguagem esconda a implementação, se é uma referência, é muito mais fácil manipular que um ponteiro. O fato dela ser menos flexível, dar mais garantias, muitas preocupações são desnecessárias. E até o compilador pode se beneficiar já que ele pode ser mais agressivo por conta das garantias fornecidas pelo mecanismo, o que pode facilitar ter um ganho de performance.
Referências costumam ter informações adicionais além do endereço onde a outra parte está. Pelo menos o seu tamanho e o tipo de informação contida na parte referida são comuns, mesmo que a informação só esteja disponível em tempo de compilação, nas linguagens mais simples.
C++ provavelmente é uma das linguagens onde a diferenciação é mais importante já que ela possui explicitamente tanto ponteiro quanto referência. Em C++ ponteiro e referência são tipos de dados. Claro que algumas linguagens possuem referências embutidas em outros mecanismos. Como é o caso de um slice de Go. Mas não é que C, por exemplo, não tenha referências, ela só não tem um mecanismo específico para tratá-las. Elas são conceituadas e manipuladas por completa discrição do programador.
Tanto ponteiro quanto referência são indireções.
Intercâmbio de nomenclatura
Tudo que fazemos em estrutura de dados usam referências. E até que precise explicitar que ela é concretizada através de um ponteiro, esta deveria ser a nomenclatura preferencial. Eu e meio mundo intercambiamos os termos quando não é o mais apropriado sem causar grandes prejuízos ou mal-entendidos. Em documentações e outras publicações formais o equívoco não pode ocorrer.
A intenção desta resposta não é esgotar o assunto, mas apenas dirimir as diferenças dos termos já que todos usamos o tempo todo e nem sempre paramos para pensar sobre exatamente o que eles são.
Conclusão
Como eu comecei, eu não tenho como afirmar, nunca li algo canônico e indiscutível sobre o assunto, até gostaria de ver algo assim, mas o que posso ajudar é mostrar que são conceitos diferentes, um é um mecanismo concreto, poderoso e flexível e o outro é mais abstrato, mais seguro (mais automatizado), mais universal, e mais fácil de entender.
Referência, nas linguagens de mais alto nível, como o Java, é um conceito mais abstrato que indica uma indireção de dado, sequer é um mecanismo acessível ao programador na maioria delas. Ponteiro é um dos mecanismos mais concretos usados para implementar a referência. É importante ter alguma consciência sobre o funcionamento de referências para evitar surpresas mas não é necessário entender profundamente o seu funcionamento. Podemos dizer que nestas linguagens ponteiro, estritamente, nem deveria ser citado. Não que eu esteja pregando alienação do programador.
Não sei se respondi totalmente a dúvida e sei que esta resposta não pode ser considerada definitiva. Não que ela esteja errada também. Mas acredito que os links fornecidos ajudam começar a procura por mais informações sobre o assunto.
Coloquei no GitHub para referência futura.
Comment: Difícil escolher, mas aceitei essa resposta pois não só é bastante completa como - apesar de extensa - evidencia de forma bem clara a principal diferença entre os conceitos no meu entender (ver as partes em negrito). As demais respostas também são boas, em particular [a do Miguel Angelo](http://pt.stackoverflow.com/a/56491/215) - mais concisa e didática, porém menos precisa e mais focada no C#.
Answer: Tanto ponteiro como referência tratam de algo que vou chamar de "fenômeno de apontamento". Assim como no eletromagnetismo temos um único fundamento, e duas formas de observar o efeito desse fundamento.
Vou falar sobre o ponto de vista do C# sobre isso. Ainda assim acredito que esse ponto de vista, transite entre linguagens sem muitos atritos.
Ponteiro
No ponto de vista do C# pelo menos, ponteiro é um tipo de dado que consta em um endereço de memória e deve apontar para uma dada estrutura, ou pode ser nulo. Se não for nulo, então o ponteiro é considerado inválido caso a estrutura apontada não seja do tipo correto. Ainda assim é possível ter ponteiros do void, que apontam para algo indefinido (ou seja, são meros endereços de memória).

ponteiro void: void*

Ponteiros permitem operar o apontamento com operações matemáticas, e no geral se parecem mais com um número inteiro qualquer do que com um objeto.

Para ter acesso ao objeto apontado, é necessário usar operadores de * ou ->. O primeiro obtém a estrutura apontada como valor, e o segundo serve para ter acesso direto a um membro da estrutura apontada.

Como ponteiros permitem atribuir qualquer valor numérico à variável, eles só podem ser usados em contexto inseguros, marcados com a palavra chave unsafe. Isso é causado pois o tipo de dado presente no destino apontado pelo endereço de memória pode não corresponder ao tipo do ponteiro:

Com ponteiros é possível criar uma cascata de apontamentos, que levam ao objeto final.

DateTime****

Referência
Referência é um tipo de dado que possui por baixo dos panos um ponteiro, mas sem permitir fazer operações matemáticas, e dando acesso direto ao objeto apontado.

No C# existem duas formas de referência:

na passagem de variável para uma função
void Metodo(ref int valor)

 == ou ==

void Metodo(out int valor)

Com referências não é possível alterar o valor numérico do endereço, sendo que ao atribuir um valor à referência vai ser alterado o valor apontado e não a referência em si.
Fazendo x = y
usando tipos-referência (ou classes no C#)
class Xpto // Xpto agora é um tipo-referência

Com tipos-referência é possível atribuir valor do endereço, usando uma outra referência do mesmo tipo-referência, ou definindo o valor como nulo. Essas são as únicas formas de alterar o valor numérico do ponteiro que está por baixo dos panos em um tipo-referência.
 Atribuindo instâncias de classe

O C# permite dupla referência apenas ao passar um tipo-referência por referência para um método.

void Metodo(out Xpto classeXpto)

O acesso à estrutura é feito sem usar operador especial algum. Usa-se a referência como se fosse o próprio tipo referido.
Comparações

Tanto referência como ponteiro permitem alterar o objeto apontado, sem alterar o valor numérico do endereço que o representa. Portanto ambos podem ser usados para fazer a "passagem por referência", em que o chamador passar algo para que um método altere.
Ambos possuem um endereço de memória por baixo dos panos.

Mesmo fenômeno, dois pontos de vista
Ponteiro/referência podem ser entendidos como duas formas de observar o mesmo fenômeno do "apontamento". Ponteiros observam o fenômeno de apontar a partir da origem do apontamento. Referências observam o fenômeno de apontar a partir do destino do apontamento.
Dualidade do mesmo fundamento.
Answer: Ponteiros são variáveis que armazenam endereços de memória e permitem referênciá-los.
Referências dizem respeito a objetos ou variáveis específicos, abstraindo-se totalmente o lugar e forma de armazenamento.
Como ponteiros armazenam (e te permitem manipular) endereços, as linguagens que tornam visíveis os ponteiros te dão algumas propriedades como aritmética de ponteiros, aliasing (tratar o mesmo endereço de memória como tipos de dados diferentes) e acesso a endereços inválidos (ainda que esta última seja normalmente indesejável).
Como linguagens de nível mais alto tendem a abstrair a alocação de memória, fica conveniente abdicar ou minimizar o conceito de ponteiro e usar conceitos mais abstratos, como variáveis de referência em C++ (que nem é de tão alto nível assim):
void bleah(int &a)
{
  a = 2;
}

void test()
{
  int var = 1;
  bleah(var);
  // neste ponto var tem o valor 2.
}

Em C++ uma variável de referência quer dizer "crie um alias (apelido) para o mesmo objeto/variável" em outro escopo.  Se o objeto foi alocado no heap, ou é um inteiro em um registrador que nem endereço de memória tem, pouco importa, tudo isto é abstraído e gerido pelo compilador.
Em C e C++ a passagem de parâmetros para funções por padrão se dá por valor (e o valor poderia ser um ponteiro), e em C++ a variável de referência indica que você quer ter acesso ao mesmo objeto sem precisar copiá-lo, mas sem explicitar um ponteiro, provendo um mecanismo específico para passagem de parâmetros para funções por referência.
O "truque" é que você já tem uma variável, que representa um objeto, e a linguagem te permite referenciá-la sem ter que se preocupar com a sua localização.
Então existem dois conceitos aqui, as "variáveis de referência" e "passagem por referência". O primeiro é específico, o segundo é mais geral.
ISO/ANSI C por exemplo não tem uma variável de referência, e a passagem de parâmetros é por valor (ainda que o valor possa ser um ponteiro, e o ponteiro tem a propriedade de permitir fazer a referência a um objeto, se ele estiver armazenado em um local na memória).
Em C++, uma variável de referência não tem a sintaxe nem a semântica um ponteiro embora você possa tomar o endereço de uma variável de referência e torná-la em um ponteiro.
Entre ponteiros e variáveis de referência existe ao menos outra substancial diferença: geralmente você precisa ter um objeto do tipo correto já declarado (e frequentemente, já inicializado) para passar por referência. Como você não manipula o endereço, em tese isto evita o uso de ponteiros "selvagens" (cujo valor aponta para o lugar errado, inclusive uma área inexistente, bugs comuns quando se usa ponteiros).
A variável de referência em C# é similar. Se você tentar passar um ponteiro nulo (É possível fazer isto passando código não-gerenciado ou PInvoke) onde ela espera uma referência, a runtime normalmente vai disparar uma Exception. Isto é intencional, pois as referências, via de regra, precisam ser válidas!
Em Java, não há um tipo de "variável de referência". E a passagem de argumentos não se dá por referência, mas pelo valor da referência, e isto é quase que totalmente abstraído.
Como você não manipula endereços em Java, toda variável é implicitamente uma variável que armazena uma referência, mas a semântica é outra já que você não acessa a referência, e sim o objeto referenciado.
Quando você passa um objeto java entre funções, está passando "o valor da referência", em uma nova variável. Se você tentar fazer uma função com as do exemplo acima, terá que remover o "&" da declaração do parâmetro, e independentemente do tipo do objeto passado para a função, terá o seguinte comportamento:
void bleah(Object a)
{
  // Isto não altera o objeto referenciado por a: faz ela referenciar outro objeto. A variável "a" local não tem nenhuma relação com a variável da função chamadora (a não ser que o valor atribuido a ela originariamente era o mesmo).
  a = new String("b")
}

void test()
{
  Object var = new String("a");
  bleah(var);
  // neste ponto var.toString() ainda retorna "a".
}

O que muda é o efeito do operador atribuição: toda variável implicitamente armazena a referencia, mas se você atribuir a uma variável, estará atribuindo nova referencia, e não alterando o objeto apontado pela referência anterior. Em C++ você estaria invocando o operador '=' do objeto apontado, em Java isto não acontece, o objeto cuja referência é passado simplesmente não é usado para nada na função acima.
Agora, se ao invés de uma String (que é imutável), você tivesse outro objeto com um método "append" que alterasse suas propriedades e você invocasse o método:
void bleah(Weird a)
{
  a.append("whatever");
}

Então a função que chamasse bleah enxergaria quaisquer efeitos da chamada a append, pois a referencia a ainda é a mesma. A variável 'a' contem uma referência implícita, mas não é uma "variável de referência" como em C++ pois ela não tenta ser um alias da variável original: a semântica de atribuições é diferente (assim como outras sutilezas).Se passasse por valor, 'a' seria uma cópia do objeto passado, e não o mesmo.
Há linguagens que aceitam variáveis tipo referência (entre as que não aceitam ponteiros, como C#: você não consegue compilar um código com ponteiros em modo "seguro", mas pode usar referências), e há linguagens que não as aceitam;
Há linguagens que fazem a passagem de parâmetros por valor, por referência, pelo valor da referência (!!!) ou algumas combinações das anteriores (como C++ que permite passagem por valor ou por referência, mas esta última de forma explícita).
O conceito abstrato por trás da passagem por referência está em contrapor a passagem por valor: passar um objeto por valor significa passar uma cópia dele. Para um objeto tipo um inteiro ou ponto flutuante ou mesmo um ponteiro, normalmente se passa por valor por questão de performance, já que o custo em copiar o objeto é menor do que manter internamente ponteiros para ele. Mas aí você não pode alterar o valor da variável original (e isto tem muito a ver com a discussão entre funções puras e impuras).
Isto significa que ao passar por cópia, perde-se a referência (!) ao objeto original.Passar uma referência (seja por uma variável de referencia, seja por um ponteiro, seja pelo valor da referencia, como em Java) significa ter como referenciar (ha!) o mesmo objeto e também permite evitar cópias, relevante em objetos grandes ou complexos.
Isto é possível (e mais conveniente) com variáveis tipo referencia, mas Java demonstra que ainda sem ponteiros, elas não são necessárias se a passagem envolver ao menos o valor da referência.
Ponteiros são formas de referências a endereços de memória, referências à variáveis ou a objetos podem ser implementadas com ponteiros, eis a confusão.
Answer:
Nota do moderador: esta resposta foi publicada como uma brincadeira de 1º de abril. Normalmente esse tipo de conteúdo não é aceito no site, mas nessa data específica é feita uma exceção. Passada a data, a publicação foi bloqueada, não podendo mais receber votos nem ser editada. Divirta-se!

Apesar das respostas anteriores serem bastante elucidativas, não posso deixar de
juntar mais uma resposta para melhor clarificar estes importantes conceitos.
Ponteiros e Referências são coisas completamente distintas.
Ponteiros
(Do Latim Ponte+eiro: fabricante de pontes)
Embora as máquinas actuais tenham reduzido subtancialmente o uso de ponteiros,
estes são ainda de elevada importância.
Há vários tipos de ponteiros (normalmente 2 ou 3 tipos), e nem sempre têm a mesma dimensão.

Referências
(Do grego Re+ferir=ferir repetidamente; como refere @bfavaretto há aqui uma
clara relação com o lado pontiagudo dos ponteiros)

No que diz respeito às linguagens de programação há dois tipos de referência essenciais:

os manuais de referência (toda a linguagem que se preza deve ter pelo menos um, que por definição, deve evitar falar dos non-documented features)
as cartas de referência (para garantir e atestar a idoneidade co seu autor e a ausência de efeitos laterais perniciosos como sejam, formatar o disco)

Conclusão

Como referido pelo OP, linguagens como o Java, recusam a existência de
ponteiros numa clara referência a que é sempre boa hora para tomar café.

Algumas operações com ponteiros envolvem muito processador e por vezes problemas de sincronização (ainda este fim se semana
houve mudança da hora, com a consequente aritmética envolvida)
(*ponteiro)++

Para correcto entendimento da resposta sugere-se a execução do seguinte programa
echo lirba 1 aid zilef | rev
Comment: @bfavaretto, É bem verdadeira e pertinente a observação que levantaste e que vou tentar incluir na resposta. Alguns cientistes referem até as "cicatrizes do tempo" (embora "com tempo tudo se cura"). Está à vontade para melhorar outras incorreções encontradas.
Comment: Até que enfim entendi. Exemplos ilustrados são muito bons, e este aponta claramente os detalhes importantes. Vou guardar como referência.
Comment: Se os ponteiros é que têm pontas, então por que não são eles que ferem repetidamente?
Comment: @Bacco, muito obrigado. É reconfortante saber que haja quem tire porveito de tão douta resposta envolvendo tanta tecnologia de ponta :)
Comment: @bfavaretto, Nunca pensaram em criar uma medalha de mau comportamento para quem nunca responda do modo que era suposto fazer e que acaba por dar cado da cabeça aos mederadores e ao meta? :)
Comment: Não, mas estamos considerando criar uma pelo bom-humor com pitadas de [imprópria linguagem desbragada](http://pt.stackoverflow.com/questions/56483/por-que-a-ordem-destes-scanfs-faz-diferen%c3%a7a-no-resultado/56484#comment116204_56484) :)
Comment: Melhor resposta do grupo de sites SE de sempre! :)
Answer: Em C++, uma referência é um ponteiro que garantidamente aponta para o objeto do tipo. Por exemplo, A* pode apontar para um objeto A ou pode ser nulo, e pode ser mesmo inválido, já A& é garantido pelo compilador que aponta para um objeto válido.
Java oculta parcialmente os ponteiros (não se pode fazer aritmética de ponteiros com uma referência, nem força-la a apontar para um objeto inválido) mas ainda permite que a referência seja null, o que as torna algo parecidas com os ponteiros C++.
Linguagens como Swift e Kotlin permite que se especifique se a referência é anulável. O tipo "A" é uma referência garantidamente válida, já o tipo "A?" pode ser nulo. O programador precisa usar o ponto de exclamação quando quer forçar o uso de uma variável A? como válida.
Answer: A diferença entre ponteiro e referência é sutil.
Conceitualmente são dois acessos de indiretos à dados. Tanto ponteiros quanto referência o fazem através de um endereçamento. A diferença é que nas referências esse endereçamento é mais abstrato que no caso dos ponteiros.
Na prática, tanto um quanto o outro são implementados como variáveis inteiras que armazenam o endereço dos dados que realmente se quer. A diferença fica por conta de como os ponteiros e as referências são usadas.
Com ponteiros, o endereço está explícito e o programador "tem acesso" ao endereço, podendo, inclusive, realizar operações sobre estes endereços, como, por exemplo, incrementar ou decrementar a variável apontadora. Exemplos de linguagens que dão suporte à ponteiros: C, C++, Algol, Modula, Pascal etc.
Com referências, o endereço está "oculto" ao programador, que não tem acesso direto a ele e não há operações sobre este endereço. Na verdade há inúmeras operações sobre o endereço, mas são feitas todas indiretamente pelo compilador/máquina virtual que implementa as referências. Por exemplo, em Java, o operador new aloca um espaço suficiente e inicializa um objeto, cujo endereço é colocado na variável referência; quando a variável sai do escopo, admite-se que aquele objeto não mais é necessário; o compilador gera código para terminar o objeto (chamar o destrutor) e liberar a memória anteriormente ocupada. Exemplos de linguagens que dão suporte à referências: C++, Java, C# etc.
Referências são uma evolução, em certo sentido, do conceito ponteiros.


Find the sum of he series to infinity : $\tan^{-1} (\frac 12) + \tan^{-1} (\frac 18) + \tan^{-1} (\frac{1}{18})...$

Question: The series is
$$\tan^{-1} (\frac{1}{(2)(1^2)}) + \tan^{-1} (\frac{1}{(2)(2^2)})+ \tan^{-1} (\frac{1}{(2)(3^2)}).....$$
I know the series will telescope, but I don't know how it would work. These problems usually reduce to $\tan^{-1} a- \tan^{-1} b$, but that's not happening here
Comment: https://math.stackexchange.com/questions/1849546/evaluate-sum-n-1-infty-cot-12n2   OR https://math.stackexchange.com/questions/3053616/find-sum-n-1-infty-tan-1-frac2n2
Answer: You can prove by induction the $n$th partial sum is $\arctan\frac{n-1}{n}$, so the series has limit $\arctan1=\frac{\pi}{4}$. So your telescoping strategy works viz. $a=\frac{k}{k+1},\,b=\frac{k-1}{k}$.


How can I add a constraint to a custom field I created?

Question: I have created a complex field type (my class extends DateRangeItem) that supports recurring dates by adding a property for storing an RRULE string:
class DateTimeRecurItem extends DateRangeItem {

  /**
   * {@inheritdoc}
   */
  public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    $properties = parent::propertyDefinitions($field_definition);
    // Prevent early t() calls by using the TranslatableMarkup.
    $properties['rrule_string'] = DataDefinition::create('string')
      ->setLabel(new TranslatableMarkup('RRule String'))
      ->setRequired(FALSE);

    return $properties;
  }

  ...

I want to validate the RRule string (there's a RFC to validate it against). I can do this by creating a custom constraint and applying it like this:
$properties['rrule_string'] = DataDefinition::create('string')
  ->setLabel(new TranslatableMarkup('RRule String'))
  ->setConstraint('MyCustomConstraint')
  ->setRequired(FALSE);

The problem is I also need to know the value for the value property of the field (which is inherited by DateRangeItem). Implemented as above, my constraint validator will only be passed the raw string value of the rrule_string property.
I can't figure out how I can define a constraint that applies to the entire field (thereby having access to all of its field properties). There seems to be no interface for doing that.
To be clear, this is not a field I've added to a custom entity definition. This is just a custom field I defined that can be added to any entity.
Answer: In case of a field type, you can simply put it in the annotation.
Have a look at FileItem for example:
/**
 * Plugin implementation of the 'file' field type.
 *
 * @FieldType(
 *   id = "file",
 *   label = @Translation("File"),
 *   description = @Translation("This field stores the ID of a file as an integer value."),
 *   category = @Translation("Reference"),
 *   default_widget = "file_generic",
 *   default_formatter = "file_default",
 *   list_class = "\Drupal\file\Plugin\Field\FieldType\FileFieldItemList",
 *   constraints = {"ReferenceAccess" = {}, "FileValidation" = {}}
 * )
 */
class FileItem extends EntityReferenceItem {

Actually a bit surprised that the date classes don't have any constraints, that sounds like a bug.
Comment: Thanks! I originally looked at the `FieldType` annotation class but didn't see a defined property for `constraints` so I didn't think this was possible.
Answer: Override the getConstraints method.
public function getConstraints() {
  $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
  $constraints = parent::getConstraints();
  $constraints[] = $constraint_manager->create('CustomConstraint', array());
  return $constraints;
}

Comment: Alternatively `$constraint_manager = $this->getTypedDataManager()->getValidationConstraintManager()`


What should be the path to the file while using #attached in a custom_module_block_view()?

Question: I have created a custom module and was trying to add javascript file to a block using #attached method which was described here. I am confused with the Path/to/file as I have tried to give a full path which is "/var/www/html/sites/all/modules/custom_module/js/file.js". and shorter path "js/file.js"
but it doesn't load.
It just say file_get_contents("/var/www/html/sites/all/modules/custom_module/js/file.js"): unable to load, no such file or folder present /var/www/html/common.inc .....
Why I am getting the file_get_contents error when I am not using this method?
Answer: You should use drupal_get_path() function to construct the path of your asset file (in your case the JS file).
To include the YOUR_MODULE.js file which sits in a subfolder js, part of your custom module
$block = array
(
    'subject' => t('My block title'),
    'content' => array(
        '#markup' => '
' . t('This is some text that will go in the block.') . '
',
        '#attached' => array(
            'js' => array(drupal_get_path('module', 'YOUR_MODULE_NAME') . '/js/YOUR_MODULE.js'),
        ),
    ),
);

Comment: Hi Mike, Thanks for the reply. I have tried this way but I still get the same warning, <>
2) How do I make sure if the file has been called or the file has been added?
Comment: Well if you got the warning, it means the file you are trying to load doesn't exist. Did you create the `file.js` under `js` directory in your custom module directory?
Comment: yes my module was "/var/www/html/sites/all/modules/custom_module/" and my file was here "/var/www/html/sites/all/modules/custom_module/js/file.js" I tried the "drupal_add_js" as well but it didn't work. I don't know, I may have done something wrong. But at the end I got it working by adding it to theme.info file.
But I want it to be appear only on front page, not on all the pages. I assume theme.info add it to every webpage.
Comment: Well, in your case it should work using: `'js' => array(drupal_get_path('module', 'custom_module') . '/js/file.js'),`. Yes, exactly, adding it in the `theme.info` will add it on every page.
Comment: Yeah I tried this way. I don't know why it didn't work. How do you verify if this method works? I assume if it finds the file, we can look using the "inspect element" in Chrome and then if we go to "Network". I verified it there, it didn't load the file.js


ElasticSearch Server Randomly Stops Working

Question: I have 2 ES servers that are being fed by 1 logstash server and viewing the logs in Kibana. This is a POC to work out any issues before going into production. The system has ran for ~1 month and every few days, Kibana will stop showing logs at some random time in the middle of the night. Last night, the last log entry I received in Kibana was around 18:30. When I checked on the ES servers, it showed the master running and the secondary not running (from /sbin/service elasticsearch status), but I was able to do a curl on the localhost and it returned information. So not sure what's up with that. Anyway, when I do a status on the master node, I get this:
<code>curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
{
  "cluster_name" : "gis-elasticsearch",
  "status" : "red",
  "timed_out" : false,
  "number_of_nodes" : 6,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 186,
  "active_shards" : 194,
  "relocating_shards" : 0,
  "initializing_shards" : 7,
  "unassigned_shards" : 249
}
</code>
When I view the indexes, via "ls ...nodes/0/indeces/" it shows all indexes being modified today for some reason and there are new file for today's date.So I think I'm starting to catch back up after I restarted both servers but not sure why it failed in the first place. When I look at the logs on the master, I only see 4 warning errors at 18:57 and then the 2ndary leaving the cluster. I don't see any logs on the secondary (Pistol) on why it stopped working or what truly happened.
<code>[2014-03-06 18:57:04,121][WARN ][transport                ] [ElasticSearch Server1] Transport response handler not found of id [64147630]
[2014-03-06 18:57:04,124][WARN ][transport                ] [ElasticSearch Server1] Transport response handler not found of id [64147717]
[2014-03-06 18:57:04,124][WARN ][transport                ] [ElasticSearch Server1] Transport response handler not found of id [64147718]
[2014-03-06 18:57:04,124][WARN ][transport                ] [ElasticSearch Server1] Transport response handler not found of id [64147721]
</code>

[2014-03-06 19:56:08,467][INFO ][cluster.service          ]
  [ElasticSearch Server1] removed
  {[Pistol][sIAMHNj6TMCmrMJGW7u97A][inet[/10.1.1.10:9301]]{client=true,
  data=false},}, reason:
  zen-disco-node_failed([Pistol][sIAMHNj6TMCmrMJGW7u97A][inet[/10.13.3.46:9301]]{client=true,
  data=false}), reason failed to ping, tried [3] times, each with
  maximum [30s] timeout [2014-03-06 19:56:12,304][INFO ][cluster.service
  ] [ElasticSearch Server1] added
  {[Pistol][sIAMHNj6TMCmrMJGW7u97A][inet[/10.1.1.10:9301]]{client=true,
  data=false},}, reason: zen-disco-receive(join from
  node[[Pistol][sIAMHNj6TMCmrMJGW7u97A][inet[/10.13.3.46:9301]]{client=true,
  data=false}])

Any idea on additional logging or troubleshooting I can turn on to keep this from happening in the future? Since the shards are not caught up, right now I"m just seeing a lot o debug messages about failed to parse. I'm assuming that will be corrected once we catch up.

[2014-03-07 10:06:52,235][DEBUG][action.search.type       ]
  [ElasticSearch Server1] All shards failed for phase: [query]
  [2014-03-07 10:06:52,223][DEBUG][action.search.type       ]
  [ElasticSearch Server1] [windows-2014.03.07][3],
  node[W6aEFbimR5G712ddG_G5yQ], [P], s[STARTED]: Failed to execute
  [org.elasticsearch.action.search.SearchRequest@74ecbbc6] lastShard
  [true] org.elasticsearch.search.SearchParseException:
  [windows-2014.03.07][3]: from[-1],size[-1]: Parse Failure [Failed to
  parse source
  [{"facets":{"0":{"date_histogram":{"field":"@timestamp","interval":"10m"},"global":true,"facet_filter":{"fquery":{"query":{"filtered":{"query":{"query_string":{"query":"(ASA
  AND
  Deny)"}},"filter":{"bool":{"must":[{"range":{"@timestamp":{"from":1394118412373,"to":"now"}}}]}}}}}}}},"size":0}]]
Comment: I see this problem quite regularly, and it appears that it is some issue with Kibana getting lost and not reconnecting.  As I can open a new Kibana window and connect just fine.
Answer: Usual suspects for ES with Kibana are :

*Too small amount of memory available for ES** (which you can investigate with any probe system such as Marvel, or something that will send you JVM data outside the VM for monitoring)
Long GC durations (turn on GC logging and see if they do not happen when the ES stop responding)

Also the "usual" setup for ES is 3 servers to allow better redundancy when one server is down. But YMMV.
You can try the new G1 garbage collector too, which has (in my case) a much better behavior than CMS in my Kibana ES.
The GC duration problem is usually the one that happens when you're looking somewhere else and will typically lead to a loss of data because ES stops responding.
Good luck with these :)
Comment: Thanks for your input. I've been using Bigdesk and haven't seen an obvious problem with my available memory. I'm getting 3 production servers setup now but wanted to work through the issues with my 2 server instance while it was still in the dev environment.


Logistic regression and classification: Adjusting or removing decision boundaries

Question: I'm taking Andrew Ng's Machine Learning Course. In the lesson on classification algorithms, he presents the logit function ($\frac{1}{1+e^{-x}}$) and the way it converts parameterized functions to probabilities. He marks the "decision boundary" at .5, noting that the logit function cross .5 at $x=0$. If the value of the logistic regression function is .5 or greater, the result is given as 1. If it's less than .5, it's given as 0.
This sounds arbitrary. In real-world applications, is it common to adjust the decision boundary, or disregard the boundary and list only the probabilities?

Scenario 1 Adjusting the decision boundary: In the logit function, when x is -.3, y is .4256. Because y is less than .5, the predicted value is 0. If the lump in my patient's breast has a 42.56% probability of being malignant, I don't want that rounded down to 0%.
I would adjust the decision boundary from .5 to maybe .01. 1% or less probability is the threshold where I'd tell my patient their lump is nothing to worry about.
Scenario 2 Removing the decision boundary: My team of social workers helps teens in my city. My classification parameters predict that 15% of the teen population is at high risk of committing a crime. That is, it predicts a positive result for 15% of P. My team is small, however, and can only reach 3% of the teen population.
Knowing that the 15% prediction includes teens at 51% probability along with teens at 99% probability, I disregard the binary predictions entirely and order teens based on their probability, thus reaching the most at-risk teens first.

Are these scenarios—where you adjust decision boundaries and/or list probabilities alone—common in real-world usage?
Comment: Its absolutely critical to adjust the boundary in real world applications of these ideas.  And, as you mention, for some applications a decision boundary is irrelevent.
Answer:
Logistic regression can be viewed as a model output probabilities, not just a classifier.
As @Matthew Drury mentioned, adjusting the boundary is used very frequently in real world to make trade-off between true positive and false positive rates. Details see [ROC curve] for details (https://en.wikipedia.org/wiki/Receiver_operating_characteristic)

In addition to optimizing the logistic loss, which is the view from the machine learning perspective. There are very rich literature in statistics about logistic regression can answer your question perfectly and give more interpretation of the probability produced from the model.
These literatures also establish the relationship between max likelihood and binomial assumptions of logistic regression. (Note, not any number between 0 and 1 is a probability number. When we talk about probability we also want to think about the distribution.) The link function (sigmoid, $\text{logit}^{-1}$) is carefully designed with rigorous math behind.
I would strongly recommend you to re-learn logistic regression from statistics literature in addition to machine learning.
Here are some starting resources:
FAQ: HOW DO I INTERPRET ODDS RATIOS IN LOGISTIC REGRESSION?
LOGIT REGRESSION | R DATA ANALYSIS EXAMPLE
And some related topics in CV
What is the difference between linear regression and logistic regression?
Is there i.i.d. assumption on logistic regression?
Comment: Thank you very much. I imagine that, after completing Dr. Ng's course, I've only scratched the surface of regression studies. Thanks for giving me some places to start.
Comment: @Bagheera thanks for accepting my answer. I also learned logistic regression from machine learning first. Optimization plays an important role in machine leanring. However, people are doing linear regression and logistic regression for a very long time in statistics community. There are many books talk about "Generalized Linear Model", that tells every detail about the probabilistic interpretation of it.
Comment: As an example, in credit risk (banking)  you use it for scorecards for acceptance/rejection of clients for credit cards for example application (that's when you need the boundary threshold) or for classifying clients in terms of probabilities of default (between 0 and 1)  which is then used further down for pricing  (mortgages) for capital buffer calculation.


Problemas com download no CodeIgniter 3

Question: Na view eu criei este link:

    <?php
        echo anchor("./anexos/cartao-confirmacao.pdf",
            "",
            ['class' => 'btn btn-primary btn-block', 'name' => 'baixar']);
    ?>

De dentro dessa pasta anexos existe o arquivo .pdf, mas quando clico no link, vai para uma página que diz o seguinte erro:

404 Page Not Found The page you requested was not found.

link que a function anchor cria: http://localhost/fideliza/anexos/cartao-confirmacao.pdf
eu não quero que ele vá para uma página e sim faça o download do arquivo que está na pasta anexos
Answer: Se tá retornando o cabeçalho (erro) 404 é porque o link tá quebrado, ou seja, ele não ta achando o arquivo, olhe se o caminho está certo.
Se você não quer ser redirecionado pra outra página na hora de clicar no link, você tem que adicionar o atributo download no link, segue exemplo:
<?php echo anchor("./anexos/cartao-confirmacao.pdf", "", ['class' => 'btn btn-primary btn-block', 'name' => 'baixar', 'download' => 'nome_da_imagem']); ?>

Comment: sim... agora está fazendo download com essa tag, mas dá falha no download, como se o arquivo não existisse, mas ele existe..
Comment: Foi o que eu comentei, o seu link não está apontando pro arquivo corretamente. O link está quebrado.
Qual o caminho onde está as imagens ?
Comment: http://localhost/fideliza/anexos/cartao-confirmacao.pdf... a pasta chama anexos e não é uma imagem é um arquivo pdf
Comment: No link, ao invés de abreviar o caminho, coloque o caminho literal e vê se funciona, coloca lá `href="localhost/fideliza/anexos/cartao-confirmacao.pdf"`
Comment: não funciona ainda... tentei isto: `base_url("anexos/cartao-confirmacao.pdf")` e nao foi tambem
Comment: Inspeciona o link que você criou e olha pra onde o `href=` tá apontando, tem algum erro lá.
Comment: eu inspecionei: ``... tá certo o caminho... dentro da pasta do projeto `fideliza` tem oma pasta chamada `anexos`.. tá correto.. e o arquivo tá lá
Answer: <a href="<?php echo base_url(); ?>anexos/cartao-confirmacao.pdf" downloadBaixar

Use isto

Problemas com download no CodeIgniter 3


Person-time still contributed after censorship? (Stata)

Question: I feel like I might be going a little crazy here, so I'd appreciate some advice.
I have a multiple-record-per-subject dataset that goes something like this:
 id | day  | failure
----+------+--------
 1  |  1   |    .
 1  |  2   |    .
 1  |  3   |    .
 1  |  4   |  fail
 1  |  5   |    .
 1  |  6   |    .
    |      |
 2  |  1   |    .
 2  |  2   |    .
 2  |  3   |    .
 2  |  4   |    .
 2  |  5   |    .
 2  |  6   |  censor
 2  |  7   |    .
 2  |  8   |    .

I know that id==1 should not contribute any more time to the at-risk pool after day 4 (day of failure).
However, should id==2 contribute any more time to the at-risk pool after day 6 (day of censorship)?
I was under the impression that the answer was no, time after censorship is not considered "at-risk," just as time after failure is not considered "at-risk." However, Stata is continuing to count this post-censorship time in the person-time denominator. Perhaps my understanding of survival analysis is flawed?
UPDATE: To provide more info here's how I stset the data (where censorship:failure == 0 or failure == 2; and where failure:failure == 1):
stset day, failure(failure == 1) id(id)

Comment: You really need to show us how you `stset` your data. In particular, you need to use something like `exit(failure==fail)` and `exit(failure==censor)`.
Comment: @DimitriyV.Masterov Thanks, I just updated the post with that info. I ran the stset with your suggestions, and it worked. I'm just baffled that the Stata help file doesn't explicitly state that censorship in multiple-records-per-subject data doesn't mean a default exit from the study. That just seems insane.
Answer: (Answering my own question after digging through the Stata manual and per suggestions of @DimitriyV.Masterov)

I was under the impression that the answer was no, time after censorship is not considered "at-risk," just as time after failure is not considered "at-risk."

As far as I know, this is true. Censorship means exit from the study, just as failure means exit from the study.

However, Stata is continuing to count this post-censorship time in the person-time denominator.

Incredibly, this is a default "feature" of Stata's survival analysis program stset when dealing with multiple-records-per-subject data. I dug through the Stata manual and found an example:

      patno    t    x1    x2    died
          1    4    23    11       1
          2    5    21     9       0
          2    8     7    20       5
          3    7    20     5       0
          3    9    22     5       0
          3   11    21     5       0
          4  ...
Typing
.    stset t, id(patno) failure(died)
would treat
patno==1 as dying at t==4
patno==2 as dying at t==8
patno==3 as dying at t==11
Intervening records on the same subject are marked as "censored". Technically, they are not really censored if you think about it carefully; they are simply marked as not failing. Look at the data for subject 3:
      patno    t    x1    x2    died
          3    9    22     5       0
          3   11    21     5       0
The subject is not censored at t = 9 because there are more data on the subject; it is merely the case that the subject did not die at that time. At t = 9, x1 changed from 22 to 21. The subject is really censored at t = 11 because the subject did not die and there are no more records on the subject.

Stata ignored the censorship coding because there were more data listed for this subject. Aside from my irritation that this is a default feature, wasn't hinted at in the help file, and is contradicted elsewhere in the manual, it describes my observations.
The fix for this involves explicitly telling Stata to exit upon failure or censorship by specifying the exit option. In my case, this would mean the following:
stset day, failure(failure == 1) id(id) exit(failure == 0, 1, 2)


Let $G$ be a graph with $n\ge3$ vertices and more than $n^2/4$ edges

Question: Let $G$ be a graph with $n\ge3$ vertices and more than $n^2/4$ edges.
I have to prove that G contains a triangle.
I thought to use induction. Base cases are: $n=3, n=4,$ but when I start my induction I get confused...
Thanks!
Comment: What does the problem say about when $n$ is odd? Because $\frac {n^2}4 $ does not make sense in that case.
Comment: Just seen the edit! :)
Answer: Proof. (By induction on $n$).
If $n<0$, the claim is vacuously true.
Assume $n\ge0$ and $G$ has $n$ vertices and $e$ edges where $e>\frac{n^2}4$. Then also $e>\frac{n^2+1}4>0$.
Pick an edge $ab$. If each of $a,b$ has $\ge \frac{n+1}2$ neighbours, they have a neighbour $c$ in common, which leads to a triangle $abc$ and we are done.
Hence we may assume that there is a vertex $v$ with $\le \frac{n}2$ neighbours.
Removing $v$ and its edges from $G$, we end up with a graph $G'$ with $n-1$ vertices and with at least
$$e-\frac n2>\frac{n^2+1}4-\frac{n}2 =\frac{n^2-2n+1}{4}=\frac{(n-1)^2}4$$
edges. By induction hypotheses, $G'$ has a triangle, which is also a triangle in $G$. $\square$


Double to string Java Loop

Question: Hey so I am trying to get the GC-content of a DNA string is given by the percentage of symbols in the string that are C or G. For example, the GC-content of "AGCTATAG" is .375 or 37.5%. Here is what I came with up. I am having trouble with the calculations and returning the double as string.
public static double gcContent(String dna) {
    //TODO Implement this method
      double gcContent = 0;
      double count=0;
      for (int i = 0; i < dna.length(); i ++) {
          if (gcContent == dna.length()){
              gcContent = (dna.length()/ 2) ;
          }
          return double.toString (gcContent);
      }
  }

Comment: Your method always returns 0. And you must not convert to String if your method returns double. Can you please correct your example.
Comment: Okay I'll leave it as a double but how can I get the correct output?
Answer: Your calculation doesnt make sense.
You have to iterate over each char of your dna-string and compare this with your expected value char ('C' or 'G', upper and lower case?)
If you want to return the result as string, you have to change the return type to String, too.
public static String gcContent(String dna) {
    //TODO Implement this method
    char c = 'C';
    char g = 'G';
      double gcContent = 0;
      double count=0;
      for (int i = 0; i < dna.length(); i ++) {

          if (dna.charAt(i) == c || dna.charAt(i) == g){
              count++;
          }
      }
      gcContent = count / (double)dna.length();
      return String.valueOf(gcContent);
  }

Comment: jep, thats it. But i would not convert to String in this method. Seperate the concern. You have a method that does the calculation - and it returns double. Then you have a UI or a report or just some simple `System.out...` - there you convert to String.
Comment: Yeah, it's the cleaner way to return the double-value and convert to string later, when u need it as string. But the TS wanted to "returning the double as string" :)
Answer: You cant call toString() in primitive type variable. You can use :
String.valueOf(gcContent)

Answer: There are many ways to do this.
String.valueOf and Double.toString will work but gives you no control over the format.
Using a number formatter would be much more powerful as it lets you control the way the output is presented. So you can make it a decimal fraction, or a percentage.
Some reading for you:
https://docs.oracle.com/javase/tutorial/java/data/numberformat.html
http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html
Answer: If you insist to use toString you can box the value in a Double object like this:
new Double(gcContent).toString();

Else the most apropriate way I think is to use String.format, because
you can format the string. For example if you want two digits after the decimal point you have:
return String.format("%.2f", gcContent);

Answer: I think you can use Double.toString(gcContent);
Answer: This might not be best one, but I use this,
return gcContent + "";

How does this work can be see here : Java: How to concatenate Double to String and here : How does the String class override the + operator?
Also, you need to change your function's return type to String.
Answer: You need to count the C and G characters. Then you can use String.format(String, Object...) to return a formatted String. Something like,
public static String gcContent(String dna) {
    if (dna == null || dna.isEmpty()) return "0%";
    int count = 0;
    for (char ch : dna.toUpperCase().toCharArray()) {
        switch (ch) {
        case 'G': case 'C':
            count++;
        }
    }
    return String.format("%.1f%%", 100 * (count / (double) dna.length()));
}

public static void main(String[] args) {
    System.out.println(gcContent("AGCTATAG"));
}

Output is (as requested)
37.5%

Double to string Java Loop


Has my conjecture using Pell's Equation been discovered before

Question: We have $$\sqrt{d} = \frac{x}{y} - \frac{1}{f_0\cdot y} - \frac{1}{f_0\cdot f_1\cdot y}- \ldots - \frac{1}{f_0\cdot f_1\cdot\ldots\cdot f_n\cdot y}-\ldots\,,$$
where
$$f_0 = 2x\,,$$
$$f_{n+1} = (f_n)^2 - 2\text{ for }n=0,1,2,\ldots,$$
and $x$ and $y$ are nontrivial solutions to Pell's Equation $x^2 - d\cdot y^2 = 1$.
For example:
$$\sqrt{5} = 9/4 - 1/72 - 1/23184 - 1/2043763488 -\ldots\,.$$
Comment: Welcome to StackExchange. As you see in the edited answer you can use the usual LaTeX syntax here to make your math nicely formated.
Comment: Maybe there is a limit on the right hand side? LHS is irrational, RHS is rational as it stands
Answer: I don't know if it is published somewhere, but in my opinion it has little to do with Pell equation.
From $x^2-d y^2=1$ you deduce $d=\left(\frac xy\right)^2-\frac1{y^2}=\left(\frac xy\right)^2\left(1-\frac1{x^2}\right)$, hence $\sqrt d = \frac xy \sqrt{1-\frac1{x^2}}$. Your identity can be written as
$$
\sqrt{d} = \frac xy \left(1-\frac1{f_0x}-\frac1{f_1f_0x}-\frac1{f_2f_1f_0x}-\dots\right),
$$
therefore it is basically stating that
$$
\sqrt{1-\frac1{x^2}} = 1-\frac1{f_0x}-\frac1{f_1f_0x}-\frac1{f_2f_1f_0x}-\dots
$$
This is just an asymptotic expansion of the square root, and is completely decoupled from the original Pell equation.


How to view encrypted html code in c#

Question: I have an application that uses HttpWebRequest and HttpWebResponse to get the html text of a page but the text I get the information I need is inside a Div however to that Div when I get it in the application it appears empty with no information inside.
Using google chrome in inspect mode I can see the information inside the div already in the view source the information does not appear.
Can someone help me out as I get this information using C#
My code:
request = (HttpWebRequest)WebRequest.Create("https://portal.cfm.org.br/index.php?option=com_medicos&Itemid=59");
request.Proxy = webProxy;
request.Timeout = 80000;
request.Method = "GET";
request.KeepAlive = true;
response = (HttpWebResponse)request.GetResponse();
sr = new StreamReader(response.GetResponseStream(), encoding);
html = sr.ReadToEnd();
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);

Div that comes with the code:

A sequência de caracteres digitada não confere com a da imagem exibida. Por favor, preencha o campo novamente.

Original Div(with the information i need):

Nome do Médico
Situação
CRM
Estado

Alan Felipe Sakai
Regular
152756
SP

Comment: If you need to get some data on the Server side - you have to POST it. You could use simple form or some JS for that purposes
Comment: Div contents are not normally submitted on forms. Can you provide code samples for more insight?
Comment: @rabelloo I put my code and how the div comes through my code and how is it original with the information the way I need it
Answer: The message translates to: "The typed sequence of characters does not match that of the displayed image. Please fill in the field again."
Looks like the site is using a CAPTCHA to prevent you from scraping the data in this way.
Unless you can get the site owners to provide you with a direct feed of their data, you're not going to be able to extract the information.

How to view encrypted html code in c#


sum column based on flag

Question: I have a file with a format similar to (in reality there are many more columns and rows)
ID flag
1   a
2   n
3   n
4   a
5   n
6   n
7   a
8   a
9   n
10  n
11  n
12  n

I want to find out how many rows have the value n in $2.
I have tried awk '{if ($2 == 'n') SUM += 1} END {print SUM}' filename
This does not work. Any ideas?
Answer: One way:
awk '$2=="n"{x++}END{print x}' file

sum column based on flag