Is the function continuous

Question: $$f(x)=\begin{cases} x^{2}-1  & x  \leq 1\\x- \frac{1}{x}  & x  \geq 1\end{cases} $$
How can you show if these kind of functions are continuous or not?
Comment: There is a typo in the definition of the function I think, you must have meant $x\geq 1$ and not $x\geq0$
Comment: This function is not difined well.
Comment: Hint: Check continuity of $x^2 - 1$ for $x \leq 1$ and continuity of $x - \frac{1}{x}$ for $x \geq 1$.  Afterwards, show that

$$\lim_{x \rightarrow 1^{+}}{x - \frac{1}{x}} = \lim_{x \rightarrow 1^{-}}{x^2 - 1}.$$
Answer: For functions with piecewise definitions, there are two things you need to do:

check continuity inside the pieces,
check continuity at the connections points between the pieces, if any.

In the given case, the first piece is a polynomial so it is continuous everywhere.
The second piece is the sum of a polynomial and the inverse function; the latter is continuous (it is the inverse of a polynomial) except at the root $x=0$, but this value is outside the domain of the piece.
There remains the case of the common bound $x=1$, which causes no difficulty here as the value of the function on both sides is well defined and identical ($0$).
Comment: It's worth noticing that even if the second piece were defined for, say, $x>-1, x\neq0$, it would still be continuous.
Comment: @Jean-Claude: yep, this can be expressed by stating that $f(x)=1/x$ for $-10$. These are two continuous pieces, with no connection point.
Answer: Show the right hand limit of the function define for $x\leq1$ is same as the left hand limit of the function defined for $x\geq1$. That is show that
$$\lim_{x\uparrow1}(x^2-1)=\lim_{x\downarrow1}(x-1/x)$$
 both of which are $0$ and hence the function is continuous.
Answer: For these "piecewise continuous" functions, your intuition is probably that they are continuous if and only if they agree at the "transition points" - this turns out to be true. I'll make a general statement and briefly describe the proof.
Suppose  $a<c<b$, $g:[a,c] \rightarrow \mathbb R$ and $h:[c,b] \rightarrow \mathbb R$ are continuous, and $f:[a,b] \rightarrow \mathbb{R}$ is defined as follows; $$f(x) = \begin{cases}g(x) & x \in [a,c] \\ h(x) & x\in (c,b]. \end{cases} $$
Then $f$ is continuous at $c$ if and only if $g(c)=h(c)$.
To prove this; Suppose first $g(c) \neq h(c)$; then if you approach $c$ from the left you get a different value than from the right. To formalise this, take sequences $x_n$ and $y_n$ that approach $c$ from the left and right respectively and show the limits of $f(x_n)$ and $f(y_n)$ are different (this shows more, that you can't define it at $c$ in any way to make it continuous).
Now suppose $g(c) = h(c)$. $g(x)$ is close to $g(c)=f(c)$ when $x$ is close to $c$ from the left. $h(x)$ is close to $h(c) = f(c)$ when $x$ is close to $c$ from the right. Combine this to get that $f(x)$ is close to $f(c)$ when $x$ is close to $c$ from either side; i.e. continuity.
A similar proof strategy also applies when you have say, a function defined with a different value on the rationals and irrationals.
Answer: Two continuous functions $f:[a,b]\rightarrow\mathbb R$ and $g:[b,c]\rightarrow\mathbb R$ defines a continuous function
$f\cup g:[a,c]\rightarrow\mathbb R$ if and only if $f(b)=g(b)$.
If $f$ and $g$ are defined on closed intervals and $f\cup g\subset\mathbb R^2$ is a function, then it is a continuous function.

Is the function continuous


How to find $p\in \Bbb C[X]$ given $p(p(X))$

Question: Assume you're given $p(p(X))$ in the form
$$p(p(X))= \sum_{i≥0} a_i X^i$$
Is there any quick algorithm to retrieve $p$?
What can be said about the degree of $p(p)$ I think it's twice the degree of $p$.
Comment: If $p(x)$ has degree $n$, then $p(p(x))$ has degree $n^2$, not $2n$. For an easy example: let $p(x) = x^3$, then $p(p(x)) = (x^3)^3 = x^9$. This is far from being a linear map so I'm not certain that a fast algorithm exists.
Comment: There might be several $p$ leading to the same $p(p(X))$. For example $p = X$, and $p = a-X$ (for any $a \in \mathbb{C}$) lead to the same polynomial $p \circ p$.
Comment: If $p$ has degree $1$, then so does $p\circ p$.
Comment: I see what you mean, Joel. Even if that's the case, is there an algorithm to find a $p$ that works?
Comment: If deg(p)>1<deg(q)
Comment: Do you know the maximal degree of p(x) or can it be arbitrarily large?
Comment: It can be arbitrarily large.
Answer: I've thought about this quite a lot and come up with part of a solution.
We call the coefficients of the original polynomial $c_i$ and have it of degree $n$, s.t.
$$p(p(X))=\sum\limits_{i=0}^{n^2} a_iX^i$$
$$p(X)=\sum\limits_{i=0}^n c_iX^i$$
The first five coefficients of $p(x)$ are given by
$$c_{n} = a_{n^2}^{-n-1}$$
$$c_{n-1} = F(1)$$
$$c_{n-2} = F(2)-H_2(2)$$
$$c_{n-3} = F(3)-H_2(3)-H_3(3)$$
$$c_{n-4} = F(4)-H_2(4)-H_3(4)-H_4(4)$$
The formulas do not hold if $c_i$ has $i<0$, as that coefficient does not exist.
The additional functions are given below
$$ F(i) = \frac{1}{n}\frac{a_{n^2-i}}{c_n^n} + \begin{cases}
\frac{1}{4}\frac{c_{n-1}}{c_{n}} & i=n\\
0 & otherwise
\end{cases}
$$
$$ H_2(i) = c_{n-1}^i\prod\limits_{j=1}^{i-1}\frac{n-j}{j+1}\frac{1}{c_n} $$
$$ H_3(i) = c_{n-2}\prod\limits_{j=1}^{i-2}\frac{n-j}{j} \frac{c_{n-1}}{c_n}$$
$$ H_4(i) = \frac{(c_{n-1}c_{n-3}+\frac{3i}{2}c_{n-2}^2)}{c_{n-1}} \prod\limits_{j=1}^{i-2}\frac{n-j}{j} \frac{c_{n-1}}{c_n}
$$
Sadly this is not the complete solution, since I can't find a general formula for $H_j(i)$
It only something I've found by looking at the solutions generated by CAS software for specific values of $n$, and then chosen functions that work for all tested values, so technically I haven't proved that it's correct, but I find it unlikely that it will break down, if it works for all values of $n$ between 1 and 20.
I hope it can help someone.


Unable to download PHP page even web server is running in SUSE Linux

Question: I am unable to view a .php page in a browser after installing apache2 (Version - 2.4.9) and PHP5.5. Instead of the page opening in a browser it just downloads the PHP page.  OS is SUSE Linux.  Why is the .php page geting downloaded instead of being rendered?
Comment: Your apache/php configuration is b0rken. Go through everything and verify that all is as it should be. Don't forget to restart apache as well, so that it loads up mod_php.
Comment: Thanks, uninstalled apache and php5 completely and re-installed it.There is only onw package apache2-mod_php5 in repo, is also got installed. Finally restarted the apache server.
Answer: Ensure that mod_php is installed. You can verify with apache2ctl -D DUMP_MODULES; if you do not see mod_php then that is why it's not displaying.
If you do have mod_php installed then it's most likely an issue with your mime-types; if that's not the issue then make sure you have the DocumentRoot defined properly.
Comment: Thanks for update, apache2-mod_php5 is installed for php5. Document Root is set perfectly.
Comment: apache2ctl -D DUMP_MODULES show's a list of Loaded modules where php5_module is missing. Yes apache module is loaded.Individually apache is tested.
Comment: Everything is removed and installing again. Starting with apache, php and mysql is the process is followed to install
Comment: just apache2 and PHP is installed and apache server is restarted. But same issue unable to open .php page ,it just downloads
Comment: Yes, josten you are right we found the PHP5 module is missing. For this we found the apache config file which describes the list of loaded modules using apache2ctl -D DUMP_MODULES or httpd/httpd2 -M. The apache config file (/etc/sysconfig/apache2) does not contains PHP5 module in SUSE. Got the list before apache server start and Added the "php5" in it , restarted the server again and listed the modules to verify. Now, it is successfully loaded and can view php file on web browser.
Answer: U might be missing a package, try doing this:
sudo apt-get install libapache2-mod-php5

Should fix the problem
Comment: There is no package with name "libapache2-mod-php5". Searched for rpm but failed to get the package for SUSE
Comment: then use yast2 -i apache2-mod_php5
Comment: Yes, josten you are right we found the PHP5 module is missing. For this we found the apache config file which describes the list of loaded modules using apache2ctl -D DUMP_MODULES or httpd/httpd2 -M. The apache config file (/etc/sysconfig/apache2) does not contains PHP5 module in SUSE. Got the list before apache server start and Added the "php5" in it , restarted the server again and listed the modules to verify. Now, it is successfully loaded and can view php file on web browser
Comment: you can check the correct answer for this post then :)


Who is run out if both batsmen are out of their grounds?

Question: See following image. Who is Run-out?

A is crossed the crease and B is crossed half of the pitch. Run-out happening in B's side. Then who is out? A or B?
Answer: B is out. The batsmen haven't crossed each other and B is closer to the end where the fielder puts the wicket down.
From the wikipedia Page

The batsman can be judged run out when he is closest to the end where
  the wicket has been put down by the opposition and no other batsman is
  available inside the crease of the same end.

Another Reference.Check the 3rd Point
Answer: It is not a question of which batsman has covered the greater proportion of the pitch, but rather it is a question of whose is the ground where the wicket is put down.

Law 38.3 Which batsman is out
The batsman out [...] is the one whose ground is at the end where the wicket is put down.
Law 29.2 Which is a batsman's ground
[...]
(c) If there is no batsman in either ground, then each ground belongs to whichever batsman is nearer to it, or, if the batsmen are level, to whichever batsman was nearer to it immediately prior to their drawing level.

In this case, B's is the ground where the wicket b has been put down. Therefore B will be out.


Redirect all http requests

Question: Scenario:
Linux machine running as a DHCP, DNS, Webserver.
This is what I'm looking for:
When another machines connects to the network and try to surf, every attempt to browse a web page, they will land on the Webserver mentioned above.
Solution:
Can the DNS server do this for me? Redirect all requests to a specified webadress?
Is Captive Portal the only way to do this? I would really like the DNS just to do this instead.
Answer: DNS resolves (host)names to IP addresses. You can configure wildcard-records to resolve any given name to the address of your server. However, it will only work as long as the clients use your DNS server for name resolution, and it will affect any DNS lookup against your server, not only HTTP requests. A transparent proxy might be a better solution.
Comment: I'm not that experienced with bind, but theoretically, the record will be similar to *.* goes to mywebpage.com. So attempts to go to google.com, serverfault.com etc will go to mywebpage.com?
Comment: With a global wildcard record: yes.

Redirect all http requests


Radio selection for each record returned from mysql db

Question: On my website, I have a PHP query that returns various deli results from mysql database. For each result that is returned, I would like the same set of radio options to appear. The radio buttons will always be the same and represent how many pounds.
An example of what I currently have
Returned results:
-Roast Beef (CheckBox)
-Ham (CheckBox)
-Salami (CheckBox)
Here is what I would like to have
Returned results:
-Roast Beef (CheckBox)

1 (Radio)
2 (Radio)
3 (Radio)

-Ham (CheckBox)

1 (Radio)
2 (Radio)
3 (Radio)

-Salami (CheckBox)

1 (Radio)
2 (Radio)
3 (Radio)

I have one table called deli_items. Do I need another table that contains quantities? How would I change my PHP code?
SELECT
$sql_deli_meat="SELECT * FROM $tbl_name WHERE enabled = 1 AND ingredient_type = 'deli_meat' ORDER BY sort ASC";

$result_deli_meat=mysql_query($sql_deli_meat);

PHP
        <?php while($rows=mysql_fetch_array($result_deli_meat)){ ?>

<input type="checkbox" name="meats[]" id="<? echo $rows['itemname']; ?>" value="<? echo $rows['label']; ?>" style="display:none;" onclick="ShowMe();" class="green-border-meats price-update"  />
<a id="<? echo $rows['itemname']; ?>" class="radio-picture-meats" href="javascript:set_radio('<? echo $rows['itemname']; ?>');"><? echo $rows['displayname'];?>Per Pound
$<? echo $rows['price'];?><img class="box" src="<? echo $rows['imagepath']; ?>" width="300px" height="215px"/>

        <?php } ?>

Comment: Please don't use `mysql_` functions. They have been deprecated since PHP 5.5 (released in June, 2013 and so old it doesn't receive security updates anymore) and removed completely in PHP 7. Instead, use the `mysqli_` functions or PDO.
Comment: I will switch this over to mysqli at a later time
Answer: You're already inside of your PHP tags, so you do not need to re-enter PHP when echoing rows.
This is what your updated while loop should look like:
while($row = mysql_fetch_array($result_deli_meat)){
    $itemName = $row['itemname'];
    echo '<input type="checkbox" name="meats[]" id="'$itemName'" value="'$itemName'">';
}

Just as a little heads up, you should DEFINITELY update from the older, deprecated mysql_* to something such as PDO or the newer MySQL improved extension. The old extension is extremely unsafe and prone to SQL injection.
Comment: How about the radio buttons?


Como mostrar o indicador de loading no Swift 4 com o WKViewWeb

Question: Olá, estou tentando mostrar o indicador de loading enquanto minha página está sendo lida, mas não funcionou. Pesquisei na internet, mas não tem o código completo e sou iniciante no Swift. Podem ajudar?
import UIKit
import WebKit

class ViewController: UIViewController, WKNavigationDelegate {

@IBOutlet weak var indicador1: UIActivityIndicatorView!
@IBOutlet weak var webview: WKWebView!
override func viewDidLoad() {
    super.viewDidLoad()
    loadadress()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}
func loadadress(){

    let url: URL = URL(string: "http://www.google.com.br")!
    let urlRequest: URLRequest = URLRequest(url: url)
    webview.scrollView.isScrollEnabled = false;
    webview.scrollView.bounces = false;
    webview.load(urlRequest)
}

func webViewDidStartLoad(_: UIWebView){
    indicador1.startAnimating()
}
func webViewdDidFinishLoad(_:UIWebView){

    indicador1.stopAnimating()
}

}

Comment: Como está o `UIActivityIndicatorView` na view? Ele aparece mas não anima ou ele nem aparece? Poderia verificar também, por favor, se durante a execução, os métodos  `webViewDidStartLoad` e `webViewdDidFinishLoad` executam?
Comment: ele está na View por cima do webview, o debug não passa pela função didstart e nem didfinish, coloquei um print nessas funções e não gerou nada no console. Quando ativo o indicador manualmente eu vejo por cima da webview e fica ativado.
Comment: Certo, então tente implementar o `didFinish` do `WKNavigationDelegate` e chame o `indicador1.stopAnimating()` nele. Aí o `indicador1.startAnimating()` você pode chamar logo depois do `webview.load(urlRequest)` na sua função `loadadress()`.
Answer: No seu caso, ele não entra nos métodos pois você não disse para sua WKWebView associar o delegate dele com os que tais implementando nessa classe. Pra resolver isso, só fazer isso:
webview.delegate = self

A partir daí, a sua webview irá chamar os métodos que você está implementando nessa classe quando os delegates da webview forem acionados.
Comment: muito obrigado, funcionou.
Answer: Caro colega,
Existem 2 questões que você tem que observar ao iniciar o loading e parar ele:
1 - Ele inicia como hidden?, se sim você precisa adicionar:
indicador1.startAnimating()
indicador1.isHidden = false

2 - Se isso já foi feito o segundo ponto é que toda essa parte de iteração de tela tem que rodar na thread principal, tenta adicionar o seguinte codigo:
No start loading:
DispatchQueue.main.async {
    indicador1.startAnimating()
    indicador1.isHidden = false
}

No stop loading:
DispatchQueue.main.async {
    indicador1.stopAnimating()
    indicador1.isHidden = true
}


How to use Omake build system for a Visual studio 2010 project

Question: I have a project, which works fine in VS-2010. And runs fine.
But I want to create a make-file by using Omake. How to build the same in Omake.
I have gone through all the documentation of Omake, but it does not say how to make it.
My VS-2010 project contains .c, .cpp, .h, .rc MFC and many subdirectories too.
Answer: There is no direct way to convert a project from VS to Omake: you have to write the 'OMakefile's by hand since the two build systems (MSBuild is behind VS) and concepts are somewhat different. Once the OMakefile's are working, you can always create a Visual Studio project of type "Makefile" that calls the omake utility behind the scene.
If the reason for change is that you want to make the projet multi-platform (well, I doubt so since you use MFC), you may consider CMake, a widely-used project generation tool. CMake can generate both Makefiles (GNU) and VS projects, depending on the platform, from a project description.


2 NICs Windows 2k8 Server DHCP

Question: Hi I have 2 NICs on my Windows 2008 R2 Server and I want to be able to have 1 NIC connected to the router (Wan) and 1 connected to a standalone switch (Lan) and act as an DHCP server. I want it to act like its sharing the internet from the Wan to the Lan but be able to manage the ip addresses with DHCP server. Any help appreciated!
Answer: You want to use RRAS to handle the routing and you want to use the DHCP server role to assign addresses. Just bind DHCP to the internal interface and configure it as normal. No magic here, both are well documented on Technet.

2 NICs Windows 2k8 Server DHCP


autocomplete funciona apenas com jQuery 1.2.6

Question: Bom estou usando um plugin autocomplete com 2 input, onde coloco o valor em 1 input e o 2º e preenchido. O problema e que meu sistema trabalha com jQuery 1.7.2, pois tenho várias funções com ele. E este auto complete so funciona com jQuery 1.2.6. Como resolvo isso?
Segue meu código:

$().ready(function () {

        $("#singleBirdRemote").autocomplete("search.php", {
            width: 260
        });

        $("#singleBirdRemote").result(function (event, data) {
            if (data) {

                $(this).parent().find("input[@name=b]").val(data[1]);

            }
        });

    });
<input type="text" id="singleBirdRemote">

    <input name="a" >
    <input name="b" >
    <input name="c" >
Comment: Você não precisa do "@" no seletor ! "input[name=b]"!
Comment: E poderia utilizar simplesmente a pergunta anterior http://pt.stackoverflow.com/q/118778/42575
Comment: o problema era por causa do @ vlw
Comment: coloca a solução como resposta aqui pra vc dar o "check" verde.
Answer: Reproduzindo o comentário:
Você não precisa do "@" no seletor, use simplesmente
input[name=b]

Answer: A solução foi remover o @
$(this).parent().find("input[@name=b]").val(data[1]);


what when displaying a variable with kint crashes?

Question: I am trying to find the variable name for the content link in a view.
{{ kint(content) }} makes the page crash, probably because the variable is too big.
The same is true for the following code.
function my_theme_preprocess_field(&$variables, $hook) {
    var_dump($variables);
}

How can I find out what I am looking for?
Answer: Usually D8 $variables contain way too much data, and browser struggle to render it for you.
I strongly suggest to use xdebug or similar debugger, all modern IDEs support it. It makes developer's life much easier.
However, there is a workaround without having xdebug configured:
function my_theme_preprocess_field(&$variables, $hook) {
    var_dump(array_keys($variables));
    // or better:
    kint(array_keys($variables));
    // or:
    dpm(array_keys($variables));
}

This will return you top-level keys, then you can drill down to the next level:
dpm(array_keys($variables['some_key']));

For objects use type casting:
dpm((array) array_keys($object));

Set Kint as Variables Dumper on /admin/config/development/devel (with Devel Kint module enabled) and you'll get nicely structured output.
In Twig templates you can use something like this:
{% for key, value in content %}
    {{ key }}
{% endfor %}

UPD: Valuable comment from Kevin for TWIG:
{{ kint(content|keys) }}

Comment: in twig template you can use {{ kint(content|keys }}


Need to use hyphen in a Builder function name

Question: I'm trying to use Builder to build up a xml document for project I am working on. The xml has a very strict structure so I can't change it.
The problem I am running into is this. I am trying to add a child to a node "linking-phrase-list"
The name of the child must be "linking-phrase". So in order to do this I would call:
test = Builder.new do |xml|
  xml.map {
    xml.send(:"linking-phrase-list") {
      xml.linking-phrase("label" => "edge1", "id" => "idedge1")
    }
  }
end

Of course then ruby interprets this as (xml.linking)-phrase() which is not at all what I want. So I need to know if there is some way I can convince ruby that is one function call not two? That or tell nokogiri that I mean that when I'm not using that function.
Answer: Use the tag! method provided by builder for exactly this purpose.
test = Builder.new do |xml|
  xml.map {
    xml.tag!("linking-phrase-list") {
      xml.tag!("linking-phrase", "label" => "edge1", "id" => "idedge1")
    }
  }
end

Answer: So, you have the answer in your question, use send method:
require 'nokogiri'

test = Nokogiri::XML::Builder.new do |xml|
  xml.map {
    xml.send(:"linking-phrase-list") {
      xml.send(:"linking-phrase", "label" => "edge1", "id" => "idedge1")
    }
  }
end

puts test.to_xml

output:
<?xml version="1.0"?>
<map>
  <linking-phrase-list>
    <linking-phrase label="edge1" id="idedge1"/>
  </linking-phrase-list>
</map>


How to calculate Quantile 95 in Oracle SQL

Question: How to calculate Quantile 95 value, using  SQL or PL/SQL?
Comment: please read [how-to-ask](https://stackoverflow.com/help/how-to-ask) first.
Comment: @VamsiPrabhala - The question is pretty clear to me. It is a very general question (not specific to any tables, values etc.)  with a very simple, general answer.
Comment: @mathguy .. i get that..but wanted the OP to know.
Answer: With the SQL aggregate or analytic function PERCENTILE_DISC() (or perhaps PERCENTILE_CONT()). Google for your version of Oracle and the function name to find the Oracle documentation for these functions.
Here is how I can find the 95th percentile salary in the HR.EMPLOYEES table (HR is the standard HR schema that is installed with many Oracle databases):
select percentile_disc(0.95) within group (order by salary) as sal_95th_pctile
from   hr.employees
;

SAL_95TH_PCTILE
---------------
          13000

If instead I wanted to find the 95th percentile salary in each department, I would use the analytic version:
select percentile_disc(0.95) within group (order by salary)
                             over (partition by department_id) as sal_95th_pctile
from   hr.employees
;

For the HR.EMPLOYEES table this makes little sense, since each department has only a few employees, so "95th percentile" is meaningless; but that's how you would do it when all "departments" had many values from which to compute the 95th percentile.
Comment: I don't understand where you specify the column your running the percentile on? is it literally pulling it from the order by? I suppose it makes sense as that would allow you to control the percentile and what it meant, high or low.
Comment: @TommyHolman - what does the documentation say?


Insert data from database to table

Question: I want to insert data from database to table.
I am able to get data from database and insert that into table,but only the last data is inserted in all rows of table. I have used the code as
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
     Action *actionInformation;

    if(cell == nil){

        cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 320, 460) reuseIdentifier:@"MyIdentifier"] autorelease];

        PrepopulatedActionsDao * preAction = [[PrepopulatedActionsDao alloc] init];

        [preAction getDataFromDatabase];

        NSMutableArray *allPreActions=[preAction getDataFromDatabase];

        for(int i=0;i<[allPreActions count];i++){

            actionInformation=[allPreActions objectAtIndex:i];

            cell.textLabel.text = [NSString stringWithFormat: @"%@",actionInformation.action];

        }
    }
    return cell;
}

Here PrepopulatedActionsDao is the class where I am getting all datas from database.
I want to insert all datas of database in table not only the last one.
please anybody help.
Comment: what is the value in numberOfRowsInSection of uitableview class??
Comment: @Sarah : Its 100 as data in database is 100.
Answer: cellForRowAtIndexPath will be called for each row, so you need to provide the correct data in each call. So, instead of the "for loop", you can do
actionInformation=[allPreActions objectAtIndex:[indexPath row]];
cell.textLabel.text = [NSString stringWithFormat: @"%@",actionInformation.action];

You may also want to cache allPreActions instead of filling it in each call.
Answer: There is no need of the for loop. The cellforrow method is called for every row in the tableview. So u just need to put the following line cell.textLabel.text = [NSString stringWithFormat: @"%@",[[allPreActions objectAtIndex:indexPath.row] action]; instead of the for loop.
Hope this solves your problem.
Answer: This gets allocated every time. So declare it outside.
PrepopulatedActionsDao * preAction = [[PrepopulatedActionsDao alloc] init];

[preAction getDataFromDatabase];
  NSMutableArray *allPreActions=[preAction getDataFromDatabase];

Also you don't need for loop, Instead do it in this manner :
    actionInformation=[allPreActions objectAtIndex:indexpath.row];
    cell.textLabel.text = [NSString stringWithFormat: @"%@",actionInformation.action];

Comment: Also retain the NSMutableArray after allPreActions=[preAction getDataFromDatabase];
Answer: Declare NSMutableArray member allPreActions in .h file (Declare it as a class member) and populate it in viewDidLoad or somewhere else before cellForRowAtIndexPath:
So this code will come in viewDidLoad
PrepopulatedActionsDao * preAction = [[PrepopulatedActionsDao alloc] init];

if( allPreActions )
{
   [allPreActions releaseAllObjects];
   [allPreActions release];
}

allPreActions = [[preAction getDataFromDatabase] retain];
[preAction release];

And your cellForRowAtIndexPath: will look like as follows
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
    Action *actionInformation;

    if(cell == nil){
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 320, 460) reuseIdentifier:@"MyIdentifier"] autorelease];
    }
    actionInformation=[allPreActions objectAtIndex:indexPath.row];
    cell.textLabel.text = [NSString stringWithFormat: @"%@",actionInformation.action];

    return cell;
}

Insert data from database to table


Symmetric difference of sum of sets included in sum of their symmetric differences

Question: I've got the following problem. I am supposed to prove that:
$$(A1\cup A2)\oplus(B1\cup B2)\subseteq (A1\oplus B1) \cup (A2\oplus B2)$$
where $\oplus$ is the symmetric difference.
I know that from definition:
$$X\oplus Y = (X\setminus Y)\cup (Y\setminus X)$$ what can also be written as: $$X\oplus Y = (X\cap Y')\cup (X'\cap Y)$$
I tried messing with the left side and get to the right side and vice versa using various set transformations, but I had no luck. I've also tried other approach, using:
$$(A1\cup A2)\to x\in A1 \lor x\in A2...$$
but still I got stuck and got nothing similar to the other side.
This is kinda upsetting especially that I got graphical solution quickly (refer to link). I would be grateful for any help, clues or tips on how to approach this problem.
There is also a second question asking if:
$$(A1\cap A2)\oplus(B1\cap B2)\subseteq (A1\oplus B1) \cup (A2\oplus B2)$$
is true for any $A1, A2, B1, B2$. For what i tried to do, again, graphically, I came to conclusion it is indeed true.
My tries to do things graphically - imgur
Answer: Take any $x\in (A_1\cup A_2)\oplus (B_1\cup B_2)=\left((A_1\cup A_2)\setminus(B_1\cup B_2)\right)\bigcup\left((B_1\cup B_2)\setminus (A_1\cup A_2)\right)$. Then either $x\in (A_1\cup A_2)\setminus(B_1\cup B_2)$ or $x\in(B_1\cup B_2)\setminus (A_1\cup A_2)$.
Case $1$: $x\in (A_1\cup A_2)\setminus(B_1\cup B_2)$
Then $x\in A_1\cup A_2$ and $x\not\in B_1\cup B_2$. It follows that $x\in A_1\setminus (B_1\cup B_2)$ or $x\in A_2\setminus(B_1\cup B_2)$. Since $A_1\setminus(B_1\cup B_2)\subseteq A_1\setminus B_1$, we have that if $x\in A_1\setminus (B_1\cup B_2)$, then $x\in A_1\setminus B_1$. Similarly, $A_2\setminus (B_1\cup B_2) \subseteq A_2\setminus B_2$, so if $x\in A_2\setminus(B_1\cup B_2)$, then $x\in A_2\setminus B_2$. Therefore, $x\in (A_1\setminus B_1)\cup (A_2\setminus B_2)$.
Case $2$: $x\in(B_1\cup B_2)\setminus (A_1\cup A_2)$.
By an almost identical argument, you can show $x\in(B_1\setminus A_1)\cup(B_2\setminus A_2)$.
Therefore, $x\in(A_1\setminus B_1)\cup (A_2\setminus B_2)\cup (B_1\setminus A_1)\cup(B_2\setminus A_2)$.
But $(A_1\setminus B_1)\cup (A_2\setminus B_2)\cup (B_1\setminus A_1)\cup(B_2\setminus A_2)=(A_1\oplus B_1)\cup (A_2\oplus B_2)$.
Comment: Thank you for your contribution. This solution is great, I think I would never get to this myself.
So now, talking about the second task, I probably can assume that because: union of A1 and A2 is included in sum of A1 and A2 (same for B), the second statement will also be true regardless of A1, A2, B1 and B2?
Comment: I don't think this works. The second one is true (but your venn diagram isn't quite right - see http://math.gmu.edu/~eobrien/Venn4.html for what a venn diagram with 4 sets should look like). To prove it, use a similar approach to the above: if $x\in(A_1\cap A_2)\setminus (B_1\cap B_2)$, then either $x\not\in B_1$ or $x\not\in B_2$, so $x\in (A_1\cap A_2)\setminus B_1\subseteq A_1\setminus B_1$ or $x\in (A_1\cap A_2)\setminus B_2\subseteq A_2\setminus B_2$. And then do the same thing for $x\in (B_1\cap B_2)\setminus (A_1\cap A_2)$.
Comment: The reason I don't think your suggestion works is that $E\subseteq X, F\subseteq Y$ does not imply $E\oplus F\subseteq X\oplus Y$


How to find the largest disk in a square when there are points we must avoid?

Question: We have $n$ points $X =\{x_1, x_2, \dots, x_n\}$ inside (let's say) the unit square $Q$. We must find a disk $D\subset Q$ such that none of the points of $X$ are inside the disk. (The points can be on the boundary of $D$, otherwise we couldn't even find a solution, I guess.)
What I've done so far (I'm trying to make a program to solve this) is to construct the Delaunay triangulation of the points of $X$ and check the circumscribing circle of every triangle. I only take into account the circles that stay inside $Q$.
Here is an example of the problem and the disk found by my program:

Then, I think, I should check the circles that are solutions to the Apollonian problem of being tangent to the sides of $Q$ and to a pair of points on the "outerlayer" of the triangulation (the ones forming the convex hull of the points), or tangent to two sides and one point. For these circles I have to check if there are any points of $X$ inside the solution circle (since this could of course happen if I check every pair of points).
Will this type of handling solve the problem?
Comment: Almost, but not quite. Consider the skinny triangle on the boundary at the bottom right of your figure. Suppose one edge of the square is close to and parallel to its long edge. The largest circle in this neighbourhood is tangent to the edge and the upper two points. One of those points does not lie on the convex hull, so the configuration is not of the forms you consider.
Comment: I believe what you need to check are the circles centered at the vertices of a generalized Voronoi diagram, whose sites are the $n$ given points and the $4$ edges of the square.
Answer: Sounds mostly feasible. You'll test $O(n)$ circles this way. However, I'm afraid you need to be more careful with the convex hull vs. square edges part.
See for example the large circle in the lower left of your image. It extends beond the left image (=square) boundary, and if you would construct the circle that touches the left boundary and passes through the same points of the convex hull, it would contain the third vertex of that triangle. I suppose you must also check all pairs consisting of one convex hull vertex and one "next inner" vertex (third vertex of a triangle with one edge belonging to the convex hull).
Comment: I think if you arrange the points so that they fill the square with a big circular bite taken out of it, you can have the points supporting the largest empty circle be arbitrarily far from the convex hull.


Which variable is the equals function camparing Character sets to?

Question: I was trying to decipher a code written for a text extractor for an RTF. I found a function that contains if statements comparing something to character sets with  control words like ansi pc mac. Its like:
private void processControlWord() {

if (inHeader) {
            if (equals("ansi")) {
                globalCharset = WINDOWS_1252;
            } else if (equals("pca")) {
                globalCharset = CP850;
            } else if (equals("pc")) {
                globalCharset = CP437;
            } else if (equals("mac")) {
                globalCharset = MAC_ROMAN;
            }

and so on...
What is the equals function comparing these character sets to? I've seen somestring.equals(someothersting) but how is it functioning here?
Comment: An `equals` member method must be in this class hierarchy which takes a Object and returns a boolean.

The written code equals calling `this.equals(...)`
Comment: The equals function is part of the object class, so it just calls it´s own equals method and compares whatever is written in there.
Comment: `equals` is like any other method. It calls an implementation if one exists in the current class else it calls the super's implementation. The chain of calling finally stops at `java.lang.Object`s implementation of `equals`.
Comment: Ohk I found out...They had a user defined function with same name as `equals`. It was overriding the `equals` behaviour. Thanks for the help though
Answer: It was just a user defined function that was overriding the behavior of java's equals function.
I don't think that it a good practice to name your functions with the same name as predefined functions. People like me waste a lot of time understanding the code when it comes to maintenence.
Answer: See this is how the equals method is implemented by default by java
 static public boolean areEqual(boolean aThis, boolean aThat){
//System.out.println("boolean");
return aThis == aThat;

}
So, according to that
a.equals(b) has returned true, meaning the condition a==b is satisfied
But in your case its only taking one argument that means , somewhere in your code the equals method has been overloaded.
please refer to this link:
enter link description here
Answer: Calling a method without referencing an object is shorthand for calling it on this. So this code could be read as:
private void processControlWord() {

    if (inHeader) {
        if (this.equals("ansi")) { // E.g., here
            globalCharset = WINDOWS_1252;
        } else if (this.equals("pca")) {
            globalCharset = CP850;
        } else if (this.equals("pc")) {
            globalCharset = CP437;
        } else if (this.equals("mac")) {
            globalCharset = MAC_ROMAN;
        }
    }
}


How can I bold some text in the UILabel?

Question: For example, I would like to display something like this:
It is myboldtext label.
But It is my's length cannot be expected, because, it may become
Oh! It is my bold text label.
So, I can't use 3 labels to do so. Any recommends? Thanks.
Comment: possible duplicate of [Have half a UILabel text bold and half not?](http://stackoverflow.com/questions/7180805/have-half-a-uilabel-text-bold-and-half-not)
Comment: @Thilo It might seem a dupe at first glance but I'm not convinced it is; the popularly accepted answer to this question is that, without 3rd party classes, the only way to do it is with multiple labels.  Unlike the question you linked and some others, Ted's question displays a prior understanding of this; he knows multiple labels are the common answer, but doesn't think they'll work in his case.  (Not true, as I've shown below).  But IMO it's not quite a dupe because of this distinction. (Though of course we can agree to disagree ^^)
Comment: i think this is what you are looking for http://stackoverflow.com/questions/3586871/bold-non-bold-text-in-a-single-uilabel
Answer: UILabel cannot do this out of the box.
I recommend using OHAttributedLabel, which is available on github.
Comment: OHAttributedLabel is not maintaining by the creator anymore
Answer: You can still use 3 labels :)
Assuming the It is my label is label1, write a wrapper function that you always call to change label1's text; this function should also recalculate label1's size and reposition label2 and label3.
-(void) setLabel1Text(NSString* newText)
{
    label1.text = newText;
    int label1TextLength = [label1.text sizeWithFont:label1.font];

    label2.x = label1.x + label1TextLength;
    label3.x = label2.x + label2.width;
}

And voila :)
Comment: works, but rather inflexible if you suddenly need more than three ranges. NSAttributedString-based solutions are better IMHO. Hopefully iOS 6 will have better support for it.
Answer: Using a 'UILabel', this is not strictly possible.  You can use bold fonts, however, if you want all text to be bold.  Reference thithis page for a list of fonts.  For example, instead of Helvetica, you can use Helvetica-Bold.  With plain UILabels, however, formatting is all or nothing; all the text has to be bold, or none of it is bold.  To display rich text with some parts bold, other parts not, however, check out NSMutableAttributedString.
Good luck!


Creating a model of two factors with synergy

Question: Hi dear mathematicians,
I'm currently trying to create a simple generic model in Excel where I use synergy effects between two factors. For example, the price of a product is determined by two factors - uniqueness and importance. If the product have high uniqueness it will be more expensive and if the product is of high importance for the buyer it will be more expensive. The effect of importance is quite small if the uniqueness is low since you can just buy the product from another supplier. However, if the product is both unique and of high importance this will create a synergy effect which will increase the price since the seller has great power. Below is a quick example where importance is on the vertical axis and uniqueness is on the horizontal axis (just made up some numbers to illustrate the effect):
<code>1    2    3
1.1  4   10
1.2  8   50
</code>
(sorry about not adding axis descriptions, I had some problems with the code function)
Earlier when I didn't had the trouble of synergy I used the formula p=I*U to calculate he price p with importance I and uniqueness U. Now the formula would be p=I*U*s(I,U) where s is the synergy effect coefficient as a function of s(I,U). What I need help with is how to calculate s(I,U).
This is not an Excel question, it's more how I solve this mathematically.
Any ideas on how to solve this problem? Any help would be appreciated. And sorry if I tagged it wrong, I'm new here.
Thanks!
Comment: I've changed [tag:algebra] tag to [tag:algebra-precalculus], since we don't use algebra tag anymore, see [meta](http://meta.math.stackexchange.com/questions/473/the-use-of-the-algebra-tag/3081#3081) for details. (Of course, feel free to retag the question again if you find a more appropriate tag.)
Answer: You might try $s(I,U) = a + b I^p U^q$ for some positive constants $a,b,p,q$.  Perhaps $p=q=1$ if you want to keep it simple.
Comment: Thanks, I'll try this. It looks promising, especially since I can use 0=p=q if there is no correlation.


GetPage binding not working with Navigator - GetX

Question: GetView is unable to find the controller i registered using Bindings in Navigator. i navigate to the GetView with Get.toNamed() and pass the route name and the Navigator ID;
Hey, i have the following setup (for illustration):
The controller:
class DetailsPageController extends GetxController {...}

The binding:
class DetailsPageBindings extends Bindings {
    @override
    void dependencies() {
        Get.put(DetailsPageController());
    }
}

The method Navigator.onGenerateRoute returns the following GetPage for route /detailsPage:
GetPage(
  name: "/detailsPage",
  page: () => const DetailsPage(),
  binding: DetailsPageBindings(),
)

The page itselft:
class DetailsPage extends GetView<DetailsPageController>() {...}

when i try to navigate to the page with Get.toNamed("/detailsPage", id:..., ), i get the following:
DetailsPageController() not found, you need to call Get.put() or Get.lazyPut()...

Answer: just replace your Get.put(); to Get.lazyPut(); in Bindings.
Example :
class DetailsPageBindings extends Bindings {
    @override
    void dependencies() {
        //Get.put(DetailsPageController()); remove this
        Get.lazyPut<DetailsPageController>(() => DetailsPageController());// add this line
    }
}

Comment: Thanks for your suggestion ! but using lazyPut() didnt help either.
Comment: One thing i noticed, is when i EXPLICITLY call DetailsPageBindings.dependencies() in GetPage.page callback before returning the DetailsPage() it works. But that is not what i want and the controller is not deleted automatically when i remove the page from the navigation stack.


Order Attributes for HeirarchicalRequirement's in RallyDev API v2.0

Question: Using a TypeDefinition Query:
https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition/?fetch=ObjectID&pagesize=100&pretty=true
I can grab the Object ID for Hierarchical Requirements definition.
Using that ID I can get all the attributes (inputs) for Hierarchical Requirement's (User Stories).
https://rally1.rallydev.com/slm/webservice/v2.0/TypeDefinition/[DefObjectID]/Attributes?pagesize=100&order=ObjectID&pretty=true
However I wondering how I can order this list in the order it is displayed in the "Create User Story" screen in RallyDev?
Answer: Not exactly sure what you mean by "Create User Story" screen.  The default view for "Plan -> User Stories" shows in Rank order.  If that's what you are looking for then the order would just be:
<code>order=Rank
</code>
Comment: The screen used for creating User Stories in RallyDev. All the input fields (attributes) are order like: ID, Name, Tags, Description,  Attachments, Owner, Project, Etc..
Comment: Ok, so you are trying to order the columns as opposed to the rows...well you can specify which columns specifically with the 'fetch' parameter, but I'm not sure that will change the order of the columns returned...
Answer: I don't believe there is a way to do this- there is no "category" field with which to group the fields.  Those editors are manually configured to logically group fields together.  You could fairly easily group some of them together based on whether they are required or custom, but other than that you'll have to manually arrange them...
Comment: Thanks Kyle, I'll just order the standard ones, and toss all the custom ones at the end :)


Manipulando listas em Elixir

Question: Estou iniciando na linguagem Elixir e gostaria de saber se há um repositório de 'modules' criado e alimentado pela comunidade e que são amplamente utilizados em projetos, gerando produtividade e confiabilidade pela sua maturidade na implementação.
Em minhas pesquisas, acabei achando exemplos de módulos isolados e com um fim especifico, disponibilizado pela comunidade.
Ex:

Manipulação de Listas
Manipulação de Json
Manipulação de Strings, com operações de Split, Trim, etc..
Outros tipos de manipulações

Caso não exista, no dia-a-dia vocês mesmos acabam implementando as operações que são necessarias?
Comment: Jason ou Poison para manipular JSON. O próprio módulo nativo String para strings. E o nativo Enum ou List para listas.
Answer: Acredito que vc esteja falando sobre um gerenciador de pacotes do Elixir como NPM do Javascript. O gerenciador utilizado é o Hex (https://hex.pm/).
Answer: A biblioteca padrão do Elixir é bem completa nesse sentido e possui alguns módulos para as operações que você citou:

Manipulação de listas: Enum (nativo), List (nativo)
Manipulação de JSON: Enum (nativo), Map (nativo), Poison, Jason
Manipulação de strings: String (nativo)

Veja que o módulo Enum aparece em diversos casos, pois é uma coleção de funções de tudo que responda ao protocolo Enumerable.

Manipulando listas em Elixir


Terraform refer to locals in another directory

Question: I have a directory name "3-tier" In which there are two more directories namely ec2 and vpc. The exact directory structure is as attached below

The main.tf in vpc directory has a locals block defined:
locals {
    owner = var.owner
    environment = var.environment
    Name = "${local.owner}-${local.environment}-${var.vpc_name}"
    common_tags = {
        Owner = local.owner
        Environment = local.environment
        Name = local.Name
    }
}

In the ec2 directory main.tf file I have loaded the module as below
module "vpc_module" {
    source = "../vpc/"
}

How can I refer to the locals present in vpc directory main.tf file from ec2 directory main.tf file?
Comment: I have defined the outputs in vpc and used them in ec2. However, i am not satisfied with this approach.  Sadly looks like there is no other way.
Comment: That's how tf works. You have to accept it or simply not use tf. Nevertheless my answer is correct and it's acceptance would be appreciated.
Answer:
How can I refer to the locals present in vpc directory main.tf file from ec2 directory main.tf file?

You can't do this directly. You have to add them as output values to your vpc module. Then you will be able to access them through outputs of your vpc module.
Comment: Is there any way other than defining the output? Any global definition that we can define?
Comment: @vidyadharreddy No, there is no such way.


Mean vector and covariance matrix

Question: I am given a home work for one subject, but my probability theory course is just started, so I dont have enough information. Could someone help me with that?
Given:
$$\begin{equation}
  p_\underline x(x)=\left\{
  \begin{array}{@{}ll@{}}
    \frac1\pi, & \text{if}\ x^2_1+x^2_2 < 1 \\
    0, & \text{otherwise}
  \end{array}\right.
\end{equation}  $$
Find the mean and covariance matrix of the random vector of:
$$ \underline y=\begin{bmatrix}
1 & -1 \\
0 & 2 \\
\end{bmatrix}\underline x + \begin{bmatrix} 2 \\ 3 \\ \end{bmatrix}
 $$
Marginal distribution, mean and variance is already determined.
Help me please with doing mean and covariance matrix. If this will be explained and possibly given a link to some resource it would be quite helpful for me.
Thanx
Answer: Hint: not a complete solution, since you've already done most of the work, given what you've stated. Write
$$\underline{y} = \begin{bmatrix}
y_1 \\
y_2
\end{bmatrix}, \underline{x} = \begin{bmatrix}
x_1 \\
x_2
\end{bmatrix}\text{.}$$
Then we have
$$\begin{bmatrix}
y_1 \\
y_2
\end{bmatrix} = \begin{bmatrix}
1 & -1 \\
0 & 2
\end{bmatrix}\begin{bmatrix}
x_1 \\
x_2
\end{bmatrix} + \begin{bmatrix}
2 \\
3
\end{bmatrix} = \begin{bmatrix}
x_1 - x_2 + 2\\
2x_2+3
\end{bmatrix}\text{.}$$
So, what this problem boils down to is finding the mean and covariance matrix of
$$\begin{bmatrix}
x_1 - x_2 + 2\\
2x_2+3
\end{bmatrix}\text{.}$$
The expected value is simply
$$\mathbb{E}\left[\begin{bmatrix}
x_1 - x_2 + 2\\
2x_2+3
\end{bmatrix} \right] = \begin{bmatrix}
\mathbb{E}[x_1 - x_2 + 2]\\
\mathbb{E}[2x_2+3]
\end{bmatrix}$$
and the covariance matrix is
$$\text{Cov}\left(\begin{bmatrix}
x_1 - x_2 + 2\\
2x_2+3
\end{bmatrix}\right) = \begin{bmatrix}
\text{Cov}\left(x_1 - x_2 + 2, x_1 - x_2 + 2\right) & \text{Cov}\left(x_1 - x_2 + 2, 2x_2+3\right) \\
\text{Cov}\left(2x_2+3, x_1 - x_2 + 2\right) & \text{Cov}\left(2x_2+3, 2x_2+3\right)
\end{bmatrix}\text{.}$$
I will let you handle it from here.
Comment: Thank you for your help

Mean vector and covariance matrix


How to let browsers know files have been updated? ASP.NET MVC

Question: I have a ASP.NET MVC website hosted in IIS.
Sometimes I push changes and user's browser may still using the previous files, causing functionality problems.
It is because the browser is caching those files right?
What can I do to ensure the user browser loading the updated files??
Thanks!
Answer: This is what ETag, If-None-Match (or If-Not-Modified), and HTTP 304 resopnses are for.
If a file is sent with an ETag header and an acceptable caching policy, the browser will cache the file, and for each subsequent request will send the If-None-Match header.
The web server should check that the generated ETag of the file matches the If-None-Match request, and return either an HTTP 200 with the new content, or an HTTP 304 indicating that the cached version is still current.
Here is how I'm, using it in ASP.NET MVC 1.0:
public ActionResult ViewAvatar(long id)
{
    UserAvatar avatar = this.AppManager.GetUserAvatar(id);

    if (avatar != null && true)
    {
        byte[] imageData = avatar.Avatar.ToArray();

        string eTag = LanLordzApplicationManager.CalculateMd5(imageData);

        if (this.Request.Headers["If-None-Match"] == eTag)
        {
            return this.NotModified(
                HttpCacheability.Public,
                DateTime.Now.AddMinutes(2)
            );
        }

        string mimeType = this.AppManager.GetImageMimeType(imageData);

        return this.Image(
            imageData,
            mimeType,
            HttpCacheability.Public,
            DateTime.Now.AddMinutes(2),
            eTag
        );
    }
    else
    {
        return this.HttpError(404, this.View("NotFound"));
    }
}

Comment: Thanks for your reply.
So do I set the Response's status code in my updated controllers?(Sorry, not understanding this ETag thing)
What if the updated file is a js or a css though?
Comment: Well, .JS and .CSS files are generally sent by the web server directly, not through ASP.  You will have to configure the cacheability under the IIS settings.  That is, you may need to lower the cache time, and use ETags.
Answer: The easiest thing to do is append a date or version number on the URL as a querystring. Something like:
<link rel="stylesheet" href="http://mysite.com/styles.css?2010-06-10-0700">

or

The browser will request a new file because the URL is different. The server will ignore the querystring (unless you are doing something clever).
The etag/last-modified suggestions are good, but do not address the problem of "telling" the browser that there is a new version of the file.
Comment: +1:  Yeah, I had kinda skipped the cache-invalidation side of this.


JavaFX ListView basic app

Question: I am newbie in JavaFX and i wanted to try something to begin with.. So i created simple ListView, but when i tried to run the program, instead of 4 listView items (Cat, Dog, Mouse, Horse) There is only submit button in rigt top corner.
Can someone help me out what i did wrong? Thanks for any advice!
package main;

import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.SelectionMode;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.scene.control.ListView;

public class Main extends Application {
 Stage window;
    Scene scene;
    Button button;
    ListView<String> listView;

    public static void main(String[] args) {
        launch(args);

    }
    @Override
    public void start(Stage primaryStage) throws Exception {
        window = primaryStage;
        window.setTitle("Try listView");
        button = new Button("Submit");

        listView = new ListView<>();
        listView.getItems().addAll("Cat", "Dog", "Mouse", "Horse");
        listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        button.setOnAction(e -> buttonClicked());

        VBox layout = new VBox(10);
        layout.setPadding(new Insets(20, 20, 20, 20));
        layout.getChildren().addAll(button);

        scene = new Scene(layout, 300, 250);
        window.setScene(scene);
        window.show();

    }
    private void buttonClicked() {
        String message = "";
        ObservableList<String> movies;
        movies = listView.getSelectionModel().getSelectedItems();

        for (String m: movies) {
            message += m + "/n";
        }
        System.out.println(message);
    }

}

Comment: You don't add the `ListView` to a layout/the scene.
Answer: When you create your scene, you are only adding the Button to it.  Change the following line of code:
layout.getChildren().addAll(listView, button);

By doing this, you will add the ListView followed by the Button.
Comment: Yes, that was the problem.. Thanks a lot for helping!

JavaFX ListView basic app


Removing Older Survey Observations for the Same Student in the Same Week

Question: My dataframe contains Week 1 and Week 12 course survey results for individuals, and some individuals have taken the Week 1 survey twice like student #100 below.  There are other vectors in the df beyond those show in the example, but I want to delete the oldest observations for these individuals.
St#   Week  Date
100     1   15-Jun
100     1   18-Jun
100     12  25-Aug
101     1   17-Jun
101     12  25-Aug
102     12  26-Aug

Also, how may I delete observations where students have only taken the Week 1 or the Week 12 like student #102?
Thanks in advance
Answer: Here are data.table and plyr solutions.
dat <- read.table(text = "St   Week  Date
100     1   15-Jun
100     1   18-Jun
100     12  25-Aug
101     1   17-Jun
101     12  25-Aug
102     12  26-Aug  ", header = TRUE, stringsAsFactors = FALSE)

dat$Date <- as.Date(paste(dat$Date, "2014"), format = "%d-%b %Y")

library(data.table)

DT <- data.table(dat)
DT[order(Date), head(.SD, 1), by = list(St, Week)][duplicated(St) | duplicated(St, fromLast = TRUE)]

##     St Week       Date
## 1: 100    1 2014-06-15
## 2: 101    1 2014-06-17
## 3: 100   12 2014-08-25
## 4: 101   12 2014-08-25

library(plyr)

out <- ddply(dat, .(St, Week), function(x) head(x[order(x$Date),], 1) )
out[duplicated(out$St) | duplicated(out$St, fromLast = TRUE),]

##    St Week       Date
## 1 100    1 2014-06-15
## 2 100   12 2014-08-25
## 3 101    1 2014-06-17
## 4 101   12 2014-08-25

Comment: Jake - not sure this did the trick as I end up with the same number of observations in DT that I started with - expected fewer observations with the deleted rows
Comment: OK - Just saw the plyr approach - let me try.


Preciso fazer um select de receitas e seus respectivos ingredientes, sem repetir os outros campos da receita

Question: Tenho o seguinte cenário:
Tabela Receita
---------------------
id
nome
modo de preparo
categoria
Tabela Ingrediente
--------------------------
id
nome
Tabela Ingrediente_receita
--------------------------------------
id
id_receita
id_ingrediente
Quero fazer um select que traga as receitas com seus respectivos ingredientes conforme os ingredientes que eu informar.
Ex: select das receitas que possuem farinha, ovo e açucar (Quero que traga receitas que possuem só esses 3 ingredientes, se a receita tiver mais algum ingrediente, não quero que apareça)
Supondo que um bolo de cenoura só tenha esses 3 ingredientes
Nao quero que traga assim:
1| Bolo de cenoura | modo de preparo: blablabla | Categoria: Doces | farinha
1| Bolo de cenoura | modo de preparo: blablabla | Categoria: Doces | ovo
1| Bolo de cenoura | modo de preparo: blablabla | Categoria: Doces | açucar
Quero que traga assim (Tudo na mesma linha):
1| Bolo de cenoura | modo de preparo: blablabla | Categoria: Doces | farinha | ovo | açucar
Banco de dados: Mysql
Podem me ajudar? Obrigado.
Comment: Oq vc ja tem de codigo ?
Answer: Vamos precisar de 2 parâmetros, os id's dos ingredientes que vamos procurar e a quantidade de ingredientes que estão sendo procurados. Aí faremos da seguinte maneira:
Estrutura de tabelas teste:
CREATE TABLE receita(id int, nome varchar(20), preparo varchar(20), categoria int);
CREATE TABLE ingrediente(id int, nome varchar(50));
CREATE TABLE ingrediente_receita(id int, id_receita int, id_ingrediente int);

INSERT INTO receita VALUES(1,'bolo','teste',1);

INSERT INTO ingrediente values(1, 'farinha'),(2,'açucar'),(3,'ovo');

insert into ingrediente_receita VALUES(1,1,1);
insert into ingrediente_receita VALUES(1,1,3);

não criei relacionamento pois é apenas para referenciar os campos ao campo da consulta para ficar claro, sendo assim, segue a consulta:
SELECT
    r.id,
    r.preparo,
    r.categoria,
    GROUP_CONCAT(i.nome SEPARATOR ' | ') AS ingrediente
FROM receita r
INNER JOIN ingrediente_receita ir
ON ir.id_receita = r.id
INNER JOIN ingrediente i
ON i.id = ir.id_ingrediente
WHERE r.id IN(
SELECT
    r.id
FROM receita r
INNER JOIN ingrediente_receita ir
ON ir.id_receita = r.id
INNER JOIN ingrediente i
ON i.id = ir.id_ingrediente
WHERE ir.id_ingrediente IN(1,3)[id_ingredientes]
HAVING (SELECT COUNT(*) FROM ingrediente_receita WHERE id_receita = r.id) = 2[qtd_ingredientes])

no parâmetro [id_ingredientes] vamos passar os id's separados por ',', e no paramêtro [qtd_ingredientes] vamos passar a quantidade de ingredientes.
o retorno da consulta com os parâmetros acima será este:

Aí para futuro testes pode ir trocando os id's e as quantidades, exemplo IN(1,2) por mais que ele encontre a farinha não irá retornar pois estamos procurando alguma receita que tenha 2 ingredientes[qtd_ingredientes] e nesse retorno ele traria apenas 1 linha representando a farinha.
Comment: arllondias tentei fazer o que voce passou, porém mesmo informando a quantidade de ingredientes 2, ele trouxe a receita e mostrou os 3 ingredientes que ela possui.

Sou novo no fórum, consigo inserir uma imagem aqui?
Comment: Quantos parâmetros você enviou dentro do IN e qual o valor colocou em quantidade, não é para retornar não, se quiser mande no meu e-mail a imagem, e tento auxiliar por lá. email@example.com
Comment: colooquei 2 parâmetros no IN e a quantidade 2, mas mesmo assim ele retornou a receita e mostrou os 3 ingrdientes que ela possui, mandei a imagem no seu email, obrigado.
Comment: deu certo, obrigado arllon
Comment: Tranquilo, por nada.
Answer: Vamos supor que ja fez sua busca e deu um fetch array nela, ficando com o resultado:
1| Bolo de cenoura | modo de preparo: blablabla | Categoria: Doces | farinha
1| Bolo de cenoura | modo de preparo: blablabla | Categoria: Doces | ovo
1| Bolo de cenoura | modo de preparo: blablabla | Categoria: Doces | açucar
$rs = [
   0 => [
      'id' => '1',
      'receita' => 'bolo de cenoura',
      'modo' => 'bla bla bla',
      'categoria' => 'doces',
      'ingrediente' => 'farinha'
   ],
   1 => [
      'id' => '2',
      'receita' => 'bolo de cenoura',
      'modo' => 'bla bla bla',
      'categoria' => 'doces',
      'ingrediente' => 'açucar'
   ],
   2 => [
      'id' => '3',
      'receita' => 'bolo de cenoura',
      'modo' => 'bla bla bla',
      'categoria' => 'doces',
      'ingrediente' => 'ovo'
   ]
]

O que você vai fazer é selecionar uam coluna, no caso 'ingredientes', e implodir os dados dessa array em uma string:
$ingredientes = array_column($rs, 'ingrediente');
$lista_ingredientes = implode(',', $ingredientes);
echo $lista_ingredientes; //farinha,açucar,ovo

Exemplo funcional no Ideone
Comment: Não seria melhor fazer uma query mais elaborada pra trazer tudo apenas uma vez ?


Is OEIS A248049 an integer sequence?

Question: The OEIS sequence A248049 is defined by
$$ a_n \!=\! \frac{(a_{n-1}\!+\!a_{n-2})(a_{n-2}\!+\!a_{n-3})}{a_{n-4}} \;\text{with }\; a_0\!=\!2, a_1\!=\!a_2\!=\!a_3\!=\!1.$$
is apparently an integer sequence but I have no proofs. I have numerical evidence using PARI/GP and Mathematica only. It is a real
problem because its companion
OEIS sequence A248048 has the same
recursion with $\,a_0=-1, a_1=a_2=a_3=1\,$ but now $\,a_{144}\,$ has a denominator of $2$. There is a
resemblance to the Somos-4 sequence but that probably won't help with an integrality proof.
I have some interesting unproven observations about its
factorization algebraically and $p$-adically for a few small values of $p$, but nothing that would prove integrality. For example, if
$\,x_0,x_1,x_2,x_3\,$ are indeterminates, and
we use initial values of
$$ a_0=x_0,\; a_1=x_1,\; a_2=x_2,\; a_3=x_3 \;\text{ and }\;
x_4 := x_1+x_2,$$ with the same recursion, then $\,a_n\,$ has denominator a monomial in
$\,x_0,x_1,x_2,x_3,x_4\,$ with
exponents from OEIS sequence A023434.
Since $\,x_0=x_4=2\,$ with the original sequence I can't prove that the numerator
has enough powers of $2$ to compensate. Another
example is that $\,a_{12n+k}\,$ is odd for $\,k=1,2,3\,$ and
even for the other residue classes modulo $12$. I also have
some further observations about its $2$-adic valuation
behavior which I can't prove.
By the way, the sequence grows very fast. My best
estimate is $\,\log(a_n) \approx 1.25255\, c^n\,$
where $\,c\,$ is the plastic constant OEIS sequence A060006. Note
that $$x^4-x^3-x^2+1 = (x-1)(x^3-x-1) $$ and
$\,c\,$ is the real root of the cubic factor.
Can anyone give a proof of integrality of A248049?
Comment: @Vepir Probably not surprising because the author of  OEIS sequence A248049 is
Michael Somos.
Comment: Reminds me of [Somos Sequence's](https://mathworld.wolfram.com/SomosSequence.html).
Comment: @darijgrinberg Thanks for your helpful comment! The sequence $p_n$ you wrote (and several other similar sequences) was known to me early in 2013 eight years ago. A simpler recursion is $p_n p_{n-6}=(p_{n-1}+p_{n-5})p_{n-3}.$ I agree that proving integrality of this would imply integrality of A248049. Unfortunately, I did not have time then to explore all of the sequences I found and their interelations. Thanks for reminding me!
Comment: Similar to https://math.stackexchange.com/questions/1905063/is-a276175-integer-only (note: the proof is less than 100% verified and rather unsatisfactory in its brute-force component).
Comment: If you have $p$-integrality for all $p$, then the (global) integrality follows.
Comment: @pregunton Your $\,b_n\,$ is [OEIS sequence A078918](https://oeis.org/A078918). Your recurrence for $\,b_n\,$ is the first formula in the sequence entry. I seem to not indicate its relation to A248049 and also a few other sequence relations.
Comment: It seems that there is an integer sequence $\left(p_0, p_1, p_2, p_3, \ldots\right) =$ $(2, 3, 4, 10, 33, 140, 715, 7909, 277165, 19819657, 4750144681,$ $9404100347731, 260679781038269672, \ldots)$ such that every $n \geq 4$ satisfies $a_n = p_n p_{n-1} p_{n-2} p_{n-3}$. This sequence will then satisfy the recursion $p_n p_{n-1} p_{n-6} p_{n-7} = p_{n-3} p_{n-4} \left(p_{n-1} + p_{n-5}\right) \left(p_{n-2} + p_{n-6}\right)$. Maybe its integrality is easier to prove?
Comment: I don't know if this is useful, but defining $b_0=2$ and $b_n=a_{n-1}/b_{n-1}$, we obtain the slightly simpler recurrence $b_n= b_{n-2}(b_{n-1}\!+\!b_{n-3})/b_{n-4}$. This sequence also seems to be integral as far as I could check, and satisfies the additional recurrence $b_n = (b_{n-1}\!+\!b_{n-3})(b_{n-3}\!+\!b_{n-5})/b_{n-6}$.
Comment: Just came here to post that simpler recursion! (Also, I forgot to start the sequence $\left(p_0, p_1, p_2, p_3, \ldots\right)$ with three $1$s before the $2,3,4,10,33,\ldots$ part. Sorry!)
Comment: Actually, we can start the sequence $\left(p_0, p_1, p_2, p_3, \ldots\right)$ with six $1$s as starting values, and it just shifts by three positions. Thus, proving the Laurent phenomenon for its $p_n p_{n-6}=(p_{n-1}+p_{n-5})p_{n-3}$ recursion would finish the proof of integrality for $p_n$ and therefore also for $a_n$.
Comment: Oh, and I can show that the numbers $q_n := p_n p_{n+2}$ are integers. Indeed, they satisfy the recurrence $q_n q_{n-4} = q_{n-1} q_{n-2} + q_{n-2} q_{n-3}$ with starting values $1, 1, 1, 1$; but this is well-known to be an integral recurrence (particular case of Exercise 8.1.9 in http://www.cip.ifi.lmu.de/~grinberg/t/20f/mps.pdf ).
Comment: OK, I now think I can prove everything claimed here. Will take me a while to write it up, thouhg.
Comment: Actually, the detour through the $q_n$ can be avoided: Just show that each $n \geq 8$ satisfies $p_n = b p_{n-3} p_{n-4} p_{n-5} - p_{n-4} - p_{n-8}$, where $b = 6$. (The $b$ will be different for other starting values.)
Comment: @darijgrinberg Yes, just show that $(p_n+p_{n-4}+p_{n-8})/(p_{n-3}p_{n-4}p_{n-5})$ is constant.
Answer: A proof of integrality can be based on elementary algebra and some fortunate observations. The Darij Grinberg comments reminded me of some of my work I did in 2013 and which I did
not follow up on adequately.
Factorization of the $\,a_n\,$ sequence suggests the Ansatz
$$ a_n = p_n p_{n+1} p_{n+2} p_{n+3} $$
where $\,p_n\,$ is some sequence yet to be determined.
The sequence $\,a_n\,$ is supposed to satisfy a recurrence. For example, we must have
$$ a_4a_0 = (a_1+a_2)(a_2+a_3). $$
Rewriting this equation in terms of $\,p\,$ and solving for
$\,p_7\,$ gives the rational solution
$$ p_7 = \frac{(p_1 + p_5)(p_2 +p_6) p_3 p_4}{p_0 p_1 p_6}. $$
Rewrite this as a polynomial equation to get
$$ p_6p_0p_7p_1 = (p_1 + p_5)p_3(p_2 + p_6)p_4. $$
Now suppose that $\,p_n\,$ satisfies the recurrence
$$ p_n = p_{n-3}\frac{p_{n-1} + p_{n-5}}{p_{n-6}}. $$
Check that this recurrence satisfies the polynomial
equation for $\,p_7.\,$
From the $\,p_n\,$ recurrences for $\,n=9\,$ and
$\,n=6\,$ we have
$$ p_9p_3 = (p_4 + p_8)p_6 \quad \text{ and }
\quad p_6p_0 = (p_1 + p_5)p_3. $$
Combine the two equations to simply get
$$ (p_0 + p_4 + p_8)p_6 = (p_1 + p_5 + p_9)p_3. $$
This implies that the number
$$ c := \frac{ p_0 + p_4 + p_8 }{p_3 p_4 p_5} =
  \frac{ p_1 + p_5 + p_9 }{p_4 p_5 p_6}$$
is constant and thus, the sequence $\,p_n\,$ satisfies the
equation
$$ p_{n}+p_{n-4}+p_{n-8} = c\,p_{n-3}p_{n-4}p_{n-5}. $$
By the way, defining another constant
$$ s := \sqrt{(a_2+a_1)a_2a_0/(a_3a_1)} $$
implies the equation
$$ c = s\frac{(a_0+a_1+a_2)(a_1+a_2+a_3)}{a_0a_2(a_1+a_2)}, $$
or more symmetrically, this can be written as
$$ c = \frac{(a_0+a_1+a_2)(a_1+a_2+a_3)}
   {\sqrt{a_0a_1a_2a_3(a_1+a_2)}}. $$
Given values of $\,p_0\,$ and $\,p_1\,$ then
$\,p_2 = s/p_0\,$ and $\,p_3 = a_0/(p_1s)\,$
while the two sequences are related by
$\,p_n = p_{n-4}a_{n-3}/a_{n-4}.\,$
If the sequence terms $\,p_0, p_1,\dots, p_7\,$ are integers
and the constant $\,c\,$ is an integer, then this implies that
$\,p_n\,$ is an integer sequence, and also $\,a_n\,$ using the
Ansatz. In our case, $\,c=6\,$ and the sequence $\,p_n\,$
begins $\,1,1,1,1,1,1,2,3,4,10,33,140,\dots.\,$
This sequence was known to me in 2013 but I
do not think I connected it to A248049 at that time.

A simpler example of a sequence similar to $\,p\,$
is OEIS A064098 with
$$ a_na_{n-3} = a_{n-1}^2 + a_{n-2}^2 $$
and now with a constant
$$ c := \frac{a_n^2+a_{n+1}^2+a_{n+2}^2}
{a_na_{n+1}a_{n+2}} $$
such that the sequence $\,a_n\,$ also satisfies
$$ a_n + a_{n-3} = c\,a_{n-1}a_{n-2}. $$
Comment: For me, this is almost magic. In a positive way.

Is OEIS A248049 an integer sequence?


Pointwise and uniform convergence of power series

Question: I want to check the pointwise and uniform convergence of $$\sum_{n=1}^{+\infty}\frac{x^ne^{-n}}{\sqrt{n}}$$
For the pointwise convergence do we check the limit of the sequence?
I mean the following: $$a_n=\frac{x^ne^{-n}}{\sqrt{n}} \rightarrow \lim_{n\rightarrow +\infty}a_n=\lim_{n\rightarrow +\infty}\frac{x^ne^{-n}}{\sqrt{n}}=\lim_{n\rightarrow +\infty}\frac{x^n}{\sqrt{n}e^{n}}=0$$ Therefore the series converges pointwise to $0$.
Is that correct?
And for the uniform convergence do we check also the sequence?
Or do we have to do something else for the series?
Comment: It is not true that if $a_n \to 0$, then $\sum_n a_n$ converges, so your test is insufficient.
Comment: Uniform convergence mean set for $x$. Which one you have here?
Comment: It might help if you expand on what the definition of "pointwise and uniform convergence" is in this context. When one asks where a power series over $x$ converges pointwise, the question is: for which values of $x$ does it hold that the series converges?
Answer: By well known Cauchy–Hadamard theorem for power series $\sum\limits_{n=0}^{\infty}(z-z_0)^nc_n$ we have, that so called convergence radius $\frac{1}{R}=\lim\limits_{n \to \infty}\sup\sqrt[n]{|c_n|}$. In our case
$$\sqrt[n]{\frac{e^{-n}}{\sqrt{n}}} \to \frac{1}{e}=\frac{1}{R}$$
So we have pointwise convergence for $|x|<e$. In right border point we have divergence as for $\frac{1}{\sqrt{n}}$ and for left convergence $\frac{(-1)^n}{\sqrt{n}}$.
As it is known, uniform convergence we have on each closed segment within convergence interval.
Comment: @Mary Star. By the way, I wrote for you proof which you asked about on https://math.stackexchange.com/questions/3797499/check-the-convergence-of-teh-series/3797531#3797531 - do you see it?
Comment: For the n-th root test we don't consider the $x^n$-term,right?
Comment: @Mary Star. Right. Link and formulation added to answer. If/when you'll have more question for this or other answers, feel free to ask.
Comment: @zkutch the ratio accepted answers / answers recently received of this user is tiny! 2 in the last 28 i.e. about 7%. (28 is what's on one page of their account). Seems to be better towards the older of their questions (36 pages!)
Comment: @Calvin Khor. Thanks. I like that name "Mary"..
Comment: Ok! And we have to check also the border points $x=R$ and $x=-R$ ?
Comment: @Mary Star. Right.
Comment: Ok, so we have pointwise convergence for $x\in \left [-e, e\right )$. You said that "uniform convergence we have on each closed segment within convergence interval". In this case we don't have a closed interval, or do you mean something else?
Comment: I mean, every $[-r,r] \subset (-e,e)$.
Comment: Is it $[-r,r] \subset (-e,e)$ or $[-r,r] \subset [-e,e)$, i.e. do we consider also $-e$ ?
Comment: First one. $[-r,r] \subset (-e,e)$. You want to achieve some concrete result?
Comment: Ah ok! Why do we not consider also the boundary where we have convergence?
Comment: It comes from general theorem. If series is converged at boundaries, then, of course it will be uniformly converged on whole closed interval.
Comment: So in thiscase do we consider $[-r,r] \subset (-e,e)$ and not $[-r,r] \subset [-e,e)$ although we have convergence at $x=-e$ because we have only at the one boundary convergence and not at both? Or am I thinking wrong?
Comment: You thinking right. This site suggest move long dialogs to separate chat. Would you like to continue in chat?
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/112218/discussion-between-mary-star-and-zkutch).
Comment: Thank you for your help!! :-)


How to load jquery in twig file

Question: I need to run a jQuery file in a twig file in order to bind aqua lift segments.  but jQuery is not loaded yet .  How can I load jQuery at this point without loading it twice?
thanks
Answer: I think your question is that you want to put inline javascript in twig templates, but it does not work, because jquery is not loaded yet?
You can override the default that the libraries are loaded in the footer and put jquery and any of your own js in the header:
mytheme.libraries.yml:
mylibrary:
  version: 1.x
  header: true
  js:
    js/myjavascript.js: {}
  dependencies:
    - core/jquery

mytheme.info.yml:
libraries:
  - mytheme/mylibrary

The important part is header: true.
If you make a dependency on core/jquery for the header, jquery is not loaded a second time in the footer, even if there are multiple dependencies for core/jquery by other libraries.
Now you can put your jquery dependend js code in the header (in this example in myjavascript.js) or put inline js in twig templates.
Answer: {{ attach_library('core/jquery') }}

How to load jquery in twig file


Why does this error occur with my linear mixed models?

Question: I am attempting to run linear mixed effects models using the function lmer() in order to analyse the effect of the direction of change (single categorical fixed effect) in weather parameters over a fixed period of time (e.g. temperature) on the duration of different insect behaviours. My current model contains a single random effect - treatment (pertaining to conditions the insects were kept in during rearing in the lab). When I attempt to use the anova() function in order to determine the significance of the fixed effect (by comparing a model with and without it) I get the following error:
Warning message:
In optwrap(optimizer, devfun, x@theta, lower = x@lower, calc.derivs = TRUE,  :
  convergence code 3 from bobyqa: bobyqa -- a trust region step failed to reduce q

Would anyone be able to explain to me why this error occurs, how I would be able to fix it, and whether or not the p-value generated is only relevant once the error is fixed.
Added information:
The two models I am comparing take the following forms:
model.7<-lmer(winsorized.Tot.time.fence.secs~Direction.12hrs + (1|Sex.ratio.line.male), data = charlotte.agg.2)
model.8<-lmer(winsorized.Tot.time.fence.secs~(1|Sex.ratio.line.male), data = charlotte.agg.2)

Here is also the summary output of the first model:
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula:
winsorized.Tot.time.fence.secs ~ Direction.12hrs + (1 | Sex.ratio.line.male)
   Data: charlotte.agg.2

REML criterion at convergence: 3425.4

Scaled residuals:
     Min       1Q   Median       3Q      Max
-2.00084 -0.74868 -0.09043  0.68238  2.27442

Random effects:
 Groups              Name        Variance Std.Dev.
 Sex.ratio.line.male (Intercept)   820     28.64
 Residual                        25017    158.17
Number of obs: 265, groups:  Sex.ratio.line.male, 11

Fixed effects:
                        Estimate Std. Error     df t value Pr(>|t|)
(Intercept)               297.79      15.63  20.44   19.06 1.72e-14
Direction.12hrsIncrease    10.60      19.64 257.28    0.54     0.59

(Intercept)             ***
Direction.12hrsIncrease
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
            (Intr)
Drctn.12hrI -0.555

Comment: I think we will need more information. Can you share the output of `str(mydata)` along with the model formula you are using, and the output of `summary(mymodel)` please
Comment: @RobertLong I have edited the post with the required information
Answer: The error happens when running anova() because you fitted the models using restricted maximum likelihood and you can only do a likelihood ratio test of two models when they are fitted with maximum likelihood. The models are therefore refitted with ML prior to testing and that is where the convergence warning happens.
Sometimes a model doesn't converge because random effects do not behave nicely.  I am being deliberately vague because it's not possible to be specific.
The approach I would recommend here, since you only have 11 levels of the grouping factor is to fit a model with this factor as a fixed effect using lm and compare the output for your main exposure in both models.
However I do wonder why you are using a likelihood ratio test here. The t tests reported in the Fixed Effects section of the summary output are tests of the null hypothesis that the fixed effects coefficients are zero. You say that you want to "determine the significance of the fixed effect", well, that's what the t test does. I don't see a need to do a likelihood ratio test.
Try not to be too concerned with p values. I would interpret the model output by saying that you have an outcome which is almost constant with respect to the Direction.12hrsIncrease (assuming you have checked for a nonlinear assocation), and while you have repeated measures within Sex.ratio.line.male there is almost no variation attributable to it, that is there is very litte correlation within levels of it.


Navigation bar Searchbar Space Is not Hiding in Swift 4.2

Question:

HI i have implemented Searchbar in Navigationbar and
Hiding Navigationbar Progamatically but the space is not removing
PLease help how can i remove the space of searchbar hiding space
let search = UISearchController(searchResultsController: nil)

    search.searchResultsUpdater = self
    search.obscuresBackgroundDuringPresentation = false
    search.hidesNavigationBarDuringPresentation = false;
    search.searchBar.placeholder = "search..."
    self.definesPresentationContext = true
    self.navigationItem.searchController = search

for Hiding the SearchBar
search.searchBar.isHidden = false

Comment: Can you please show how your code looks like ?
Comment: where is your code?
Comment: Added My code  whatever i have used.
Answer: Hiding it won't be enough because it is still the navigationItem searchController, so you need to set it to nil
self.navigationItem.searchController = nil

and later restore it if you want, simple as that.


Eilenberg–MacLane space $K(\mathbb{Z}_2,n)$

Question: We know that the generalized classifying space / Eilenberg–MacLane space
$$
B\mathbb{Z}_2=\mathbb{RP}^{\infty}
$$
$$
BU(1)=\mathbb{CP}^{\infty}
$$

How do one construct/derive the (infinite dimensional) space explicitly:
$$
B^n \mathbb{Z}_2=K(\mathbb{Z}_2,n)=?
$$
How do one construct/derive, when $p$ is a prime:
$$
B^n \mathbb{Z}_p=K(\mathbb{Z}_p,n)=?
$$
Can one explain $B\mathbb{Z}_2$, $B^2 \mathbb{Z}_2=K(\mathbb{Z}_2,2)$, $B^n \mathbb{Z}_2=K(\mathbb{Z}_2,n)$, $B^n \mathbb{Z}_p=K(\mathbb{Z}_p,n)$, in a unified consistent but also intuitive way?
Answer: Given a connected topological space $X$ with $\pi_n(X) = G$ and $\pi_i(X) = 0$ for $i = 1, \dots, n - 1$, you can build a $K(G, n)$ by attaching cells of dimension at least $n + 2$ to kill the higher homotopy groups.
Suppose you start with $X = \mathbb{RP}^2$ which has $\pi_1(X) \cong \mathbb{Z}_2$. Then $\pi_2(\mathbb{RP}^2) = \mathbb{Z}$ and is generated by the covering map $S^2 \to \mathbb{RP}^2$. Attaching a three-cell to $\mathbb{RP}^2$ with attaching map given by the covering map $S^2 \to \mathbb{RP}^2$ gives a space $X'$ with $\pi_1(X') = \mathbb{Z}_2$ and $\pi_2(X') = 0$; in fact, $X'$ is homotopy equivalent to $\mathbb{RP}^3$. Now note that $\pi_3(\mathbb{RP}^3) \cong \mathbb{Z}$ generated by the covering map $S^3 \to \mathbb{RP}^3$. Attaching a four-cell to $\mathbb{RP}^3$ with attaching map given by the covering map $S^3 \to \mathbb{RP}^3$ gives a space $X''$ with $\pi_1(X'') = \mathbb{Z}_2$ and $\pi_2(X'') = \pi_3(X'') = 0$; in fact, $X''$ is homotopy equivalent to $\mathbb{RP}^4$. Repeating this procedure ad infinitum, we see that $\mathbb{RP}^{\infty}$ is a $K(\mathbb{Z}_2, 1)$.
Suppose now you start with $X = S^2$ which has $\pi_1(X) = 0$ and $\pi_2(X) \cong \mathbb{Z}$. Then $\pi_3(S^2) \cong \mathbb{Z}$ and is generated by the Hopf map $S^3 \to S^2$. Attaching a four-cell to $S^2$ with attaching map given by the Hopf map $S^3 \to S^2$ gives a space $X'$ with $\pi_1(X') = 0$, $\pi_2(X') \cong \mathbb{Z}$, and $\pi_3(X') = 0$; in fact, $X'$ is homotopy equivalent to $\mathbb{CP}^2$. Now note that $\pi_4(\mathbb{CP}^2) = 0$ so we don't need to glue on any five-cells, but $\pi_5(\mathbb{CP}^2) \cong \mathbb{Z}$ generated by the quotient map $S^5 \to \mathbb{CP}^2$. Attaching a six-cell to $\mathbb{CP}^2$ with attaching map given by the quotient map $S^5 \to \mathbb{CP}^2$ gives a space $X''$ with $\pi_1(X'') = 0$, $\pi_2(X'') \cong \mathbb{Z}$, and $\pi_3(X'') = \pi_4(X'') = \pi_5(X'') = 0$; in fact, $X''$ is homotopy equivalent to $\mathbb{CP}^3$. Repeating this procedure ad infinitum, we see that $\mathbb{CP}^{\infty}$ is a $K(\mathbb{Z}, 2)$.
The case for cyclic groups is similar to the first example. Note that $\mathbb{RP}^2$ can be viewed as a circle with a two-cell attached via the double covering map $S^1 \to S^1$. Likewise, a circle with a two-cell attached via the $k$-sheeted covering map $S^1 \to S^1$ is a topological space $X$ with $\pi_1(X) \cong \mathbb{Z}_k$. The above procedure then shows that the infinite lens space $S^{\infty}/\mathbb{Z}_k$ is a $K(\mathbb{Z}_k, 1)$. In order to obtain a $K(\mathbb{Z}_k, n)$, one can form the space $X$ obtained by attaching an $(n + 1)$-cell to $S^n$ with attaching map given by a degree $k$ map $S^n \to S^n$; equivalently, $X$ is the previous space suspended $n - 1$ times. This space has $\pi_n(X) \cong \mathbb{Z}_k$ and $\pi_i(X) = 0$ for $i = 1, \dots, n - 1$. I don't know of an alternate description of the space you obtain from the above procedure applied to $X$, other than it is a $K(\mathbb{Z}_k, n)$.
As for forming $K(\mathbb{Z}, n)$'s, there is a simple starting space, namely $X = S^n$ (which is $S^1$ suspended $n - 1$ times). Again, I do not know of an alternate description of the space you obtain from the above procedure applied to $X$, other than it is a $K(\mathbb{Z}, n)$.
For $n \geq 2$, a $K(G, n)$ only exists if $G$ is abelian. If in addition $G$ is finitely generated, then a $K(G, n)$ can be formed by taking products of the examples above (because $\pi_n(X\times Y) \cong \pi_n(X)\oplus\pi_n(Y)$).
For $n = 1$, if $G$ is abelian and finitely generated, then as before, you can just take a product of spaces constructed above to obtain a $K(G, 1)$. However, $G$ can be non-abelian, and taking products of the spaces above cannot produce a $K(G, 1)$ for $G$ not abelian. However, there is a simple way to construct a space $X$ with $\pi_1(X) = G$ which you can then apply the above procedure to in order obtain a $K(G, 1)$. Take a presentation for $G$. First form a bouquet of circles, one for each generator, and now attaching two-cells, one for each relation, with attaching map determined by the word used in the relation; this is the desired $X$ (which is sometimes called a presentation complex for $G$).  Again, I do not know of an alternate description of the space you obtain from the above procedure applied to $X$, other than it is a $K(G, 1)$.
Comment: Thanks again, so you/we do not have any simpler form of $K(ℤ_2,2)$, do we?
Comment: Well, $Top/PL$ is a $K(\mathbb{Z}_2, 3)$, so $\Omega(Top/PL)$ is a $K(\mathbb{Z}_2, 2)$. This isn't necessarily simpler though.
Answer: For an abelian group $A$ with a discrete topology we have
$$K(A,0)\simeq A,\qquad K(A,1)\simeq BA.$$
Note the homotopy equivalences rather than equalities. We can model $BA$ by using a bar construction to get a contractible free $A$-space $EA$, and then set $BA=(EA)/A$. I detailed this in an answer here Classifying space $B$SU(n).
One finds that the bar construction model for $EA$ is a topological monoid (that is, they carry an associative, unital product), and in the case that $A$ is abelian, this product descends to make $BA$ into a topological monoid. Hence the bar construction may be applied again to generate a contractible free $BA$-space $E(BA)$, whose $BA$ quotient is a classifying space $B(BA)=B^2A=E(BA)/BA$.
Since the projection $EBA\rightarrow B^2A$ is fibration with contractible total space and fibre $BA\simeq K(A,1)$ we study the long exact homotopy sequence to get
$$\pi_i(B^2A)\cong \pi_{i-1}(BA)$$
In particular, if $BA$ is a $K(A,1)$, then $B^2A$ is a $K(A,2)$.
Now for the same reasons as before $B^2A$ has a classifying space $B^3A\simeq K(A,3)$, and we can proceed by induction we get
$$K(A,n)=B^nA.$$
In general we have no nice way to model $K(A,n)$ except for basically the few cases you outline in the question. A useful fact is that
$$K(A\oplus B,n)\simeq K(A,n)\times K(B,n)$$
so one can apply the theorem on the classification of abelian groups to decompose things into easier to work with factors. Another useful fact is that if $A\rightarrow B$ is a homomorphism then there is an induced map $K(A,n)\rightarrow K(B,n)$, and in particular if $0\rightarrow A\xrightarrow{f} B\xrightarrow{g} C\rightarrow 0$ is short exact then there is a fibration sequence
$$\dots\rightarrow K(C,n-1)\rightarrow K(A,n)\xrightarrow{Kf} K(B,n)\xrightarrow{Kg} K(C,n)\rightarrow K(A,n+1)\rightarrow\dots$$
And this can be useful. For example $0\rightarrow \mathbb{Z}\xrightarrow{\times 2}\mathbb{Z}\rightarrow \mathbb{Z}_2\rightarrow 0$ gives us
$$\dots\rightarrow S^1\rightarrow \mathbb{R}P^\infty\rightarrow \mathbb{C}P^\infty\xrightarrow{\times 2} \mathbb{C}P^\infty\rightarrow K(\mathbb{Z}_2,2)\rightarrow\dots$$
Comment: First, the correct statement is that $K(\mathbb{Z}_2,1)\simeq \mathbb{R}P^\infty$. Eilenberg-Mac Lane spaces, like group classifying spaces, are only defined up to homotopy equivalence. As I've detailed there are various ways of generating a $K(\mathbb{Z}_2,2)$, some of which will make various features more or less accessible, but there is no "familiar" space which is a $K(\mathbb{Z}_2,2)$. You might like to pick up a copy of May's "Simplicial Objects in Algebraic Topology" if you would like to learn a little more about the bar construction.
Comment: thanks +1, but what is this infinite dimensional space precisely for $K(\mathbb{Z_2},n)$? Is that still $CP^\infty$?
Comment: Which infinite dimensional space do you mean? And I'm not sure I see the direct relation between $K(\mathbb{Z}_2,n)$ and $\mathbb{C}P^\infty$ that you are referring to.
Comment: Thanks Tyrone, $K(\mathbb{Z}_2,1)=\mathbb{RP}^{\infty}$, and $K(\mathbb{Z}_2,2)=?$
Answer: One way to understand Eilenberg-Maclane spaces is using the fact that they represent cohomology. Namely, over the category of CW-complexes, the functors $H^n(-; G)$ and $[-, K(G, n)]$ are naturally isomorphic. If $G$ is moreover an abelian group, then the multiplication map $G \times G \to G$ is a group homomorphism, therefore induces a multiplication map on $K(G, n)$ that makes it an $H$-space; hence $[X, K(G, n)]$ gets a group structure, and these are isomorphic as functors to $\mathsf{Grp}$.
Then $K(\Bbb Z_2, n)$ can be thought as the (unique upto homotopy equivalence) space which represents $H^n(X; \Bbb Z_2)$. For $n = 1$ there is an explicit way to describe this correspondence, since $K(\Bbb Z_2, 1) \simeq \Bbb{RP}^\infty$ and maps $X \to \Bbb{RP}^\infty$ classify line bundles on $X$ upto isomorphism. This bijection $\mathcal{L}(X) \to [X, \Bbb{RP}^\infty]$ can be established by sending a line bundle $\ell/X$ to the Gauss map of it's fiberwise embedding in some Euclidean bundle $X \times \Bbb{R}^\infty$, thinking of $\Bbb{RP}^\infty$ as a Grassmannian.
As Tyrone described, there is a tower of fibrations $$\cdots \to K(\Bbb Z, n) \to K(\Bbb Z, n) \to K(\Bbb Z_2, n) \to K(\Bbb Z, n+1) \to \cdots$$ induced from the short exact sequence $0 \to \Bbb Z \to \Bbb Z \to \Bbb Z_2 \to 0$, but the dual to this tower (or what this tower of fibrations represent) is the Bockstein long exact sequence $$\cdots \to H^n(X; \Bbb Z) \to H^n(X; \Bbb Z) \to H^n(X; \Bbb Z_2) \to H^{n+1}(X; \Bbb Z) \to \cdots$$ induced from the change-of-coefficients sequence $0 \to C^*(X; \Bbb Z) \to C^*(X; \Bbb Z) \to C^*(X; \Bbb Z_2) \to 0$ The snake map $H^n(X; \Bbb Z_2) \to H^{n+1}(X; \Bbb Z)$ is a natural transformation $H^n(-; \Bbb Z_2)\! \Rightarrow\! H^{n+1}(-; \Bbb Z)$ and by representability, is Yoneda-dual to the map $K(\Bbb Z_2, n) \to K(\Bbb Z, n+1)$ that is the "connecting morphism" in the fiber sequence. An alternative description of this map would be as classifying map $K(\Bbb Z_2, n) \to BK(\Bbb Z, n)$ of the fibration $K(\Bbb Z, n) \to K(\Bbb Z, n) \to K(\Bbb Z_2, n)$.
This is mostly how I think about higher Eilenberg-Maclane spaces, as usually they don't have an easy topological model.
There is a sort of striking geometry to $K(\Bbb Z_2, 3)$, and I'll try to explain my limited understanding of the story (if there are one or several misunderstandings here I'd really appreciate if someone could comment on that): Let's call $\text{TOP}(n)$ the group of germs-at-origin of homeomorphisms of $\Bbb R^n$ fixing the origin. Let $\text{PL}(n) \subset \text{TOP}(n)$ be the subgroup of germs of piecewise linear such homeomorphisms. There is a fibration $$\text{TOP}(n)/\text{PL}(n) \to B\text{PL}(n) \to B\text{TOP}(n)$$ There are natural morphisms $\text{TOP}(n) \to \text{TOP}(n+1)$ restricting to $\text{PL}(n) \to \text{PL}(n+1)$, given by sending a germ of a self-homeomorphism of $\Bbb R^n$ to that of $\Bbb R^{n} \times \Bbb R$, extended by identity on the $\Bbb R$-factor. Call the direct limit of the directed system given by these morphisms to be $\text{TOP}$ and $\text{PL}$ respectively. The aforementioned fibration should induce a fibration $$\text{TOP}/\text{PL} \to B\text{PL} \to B\text{TOP}$$ Kirby and Seibenmann proved that $\text{TOP}/\text{PL}$ is a $K(\Bbb Z_2, 3)$-space. A striking consequence of this seems to be the following: if $M$ is a topological manifold, there is a classifying map $M \to B\text{TOP}$ which lifts to a map $M \to B\text{PL}$ if and only if $M$ admits a PL-manifold structure. The $\text{TOP}/\text{PL}$-bundle over $B\text{TOP}$ is classified by a map $B\text{TOP} \to B(\text{TOP}/\text{PL})$, which has fiber $B\text{PL}$. So there seems to be another bundle $B\text{PL} \to B\text{TOP} \to B(\text{TOP}/\text{PL})$, which should be nothing but the one induced from $\text{PL} \to \text{TOP} \to \text{TOP}/\text{PL}$. Then the lifting condition is equivalent to demanding the pushforward $M \to B\text{TOP} \to B(\text{TOP}/\text{PL})$ is nullhomotopic as it factors through the fibers. But since $\text{TOP}/\text{PL} \cong K(\Bbb Z_2, 3)$, this is equivalent to saying the obstruction to $M$ having a PL-structure is homotopical nontriviality of a map $M \to BK(\Bbb Z_2, 3) \cong K(\Bbb Z_2, 4)$, which is an element of $[M, K(\Bbb Z_2, 4)] \cong H^4(M; \Bbb Z_2)$. If I understand correctly this is the Kirby-Seibenmann class. A consequence of this is that any manifold with $H^4 = 0$ has a PL structure (so for example, topological 3-manifolds automatically always have PL structures).
EDIT: As @MikeMiller points out in the comment below, the argument for this conclusion is going to be more subtle that I described. $\text{TOP}/\text{PL}$ is simply the fiber of the fibration $B\text{PL} \to B\text{TOP}$, so does not have an obvious group structure, which makes $B(\text{TOP}/\text{PL})$ nonsensical. Apparently if the obstruction theory is done, the obstruction classes for the existence of that lifting would belong to $H^{k+1}(M; \pi_k \text{TOP}/\text{PL})$, and using the fact that $\text{TOP}/\text{PL} \cong K(\Bbb Z_2, 3)$, one arrives at the fact that the only obstruction lies in $H^4(M; \Bbb Z_2)$.
I don't know if any other $K(\Bbb Z_2, n)$ has some tractable topological model though.
Comment: This is nice, but note 1) The KS class is rather obtained by obstruction theory on the fibration TOP/PL -> BPL -> BTOP, as opposed to constructing a map to some B(TOP/PL); 2) The obstruction theory in Kirby-Seibenman only works in dimension at least 5 - TOP = PL in dimension 3 is proved in different ways, and there are topological 4-manifolds with ks=0 that do not have a smooth structure; see Freedman's classification.
Comment: Thanks so much again, so you/we do not have any simpler form of $K(ℤ_2,2)$, do we?


Guitar inversions / triads / CAGED

Question: I've been studying the CAGED system for guitar, I know some people don't like it but to me it seems a great way to visualize the fretboard. Now, I understand what are triads and inversions but my question is... what happens if I remove the root and replace it with another notes from the scale? (moving it down one step to the 7, for example). It still sounds good but if there's no root I don't really know what I'm playing. Also, I've noticed that it's possible to play other CAGED shapes inside one shape just using the scale notes within that shape... here's a picture to explain it better:

This is the C  shape MAJOR G shape MAJOR scale... but the highlighted notes are also the 2nd inversion of the D shape minor chord.. how can this be possible ? If I play this triad does it mean I've switched to a minor or can I still think about it as a major?
Any help making sense of this confusion would be greatly appreciated. Thanks!
Comment: This is pattern 1 (C shape) of the CAGED system.  It's the G major scale because the roots are G notes.
Answer: I prefer to think of CAGED as chord shapes - all open that can be barred at any point to produce new chords. Seeing lots of blobs on a fretboard picture can never be anything but confusing!
That apart, shown is G major scale, or possibly B Phrygian!! Scales are far more frequently played root to root, whereas the one shown gives every possible note reachable between frets 7 and 10 - even more confusing, as playing them all, in order, doesn't sound like a 'proper' scale.
However, what you are experiencing, if I read the question right, is that diatonic triads can have one note changed, then they make a different chord. Of course this will happen. In key C major, the chord C is spelled CEG, in whichever order - called inversion, but only those 3 notes.
For the record - C = CEG.  Dm = DFA. Em = EGB. F = FAC. G = GBD. Am = ACE, Bo - BDF.
So, taking C, as CEG, and changing one note, will produce a different chord. Swap C for B, it's Em. Swap G for A, it's Am. Swapping the E for the note next will either make Csus2 or Csus4, which isn't really part of what you ask, even though it can be done - bearing in mind Csus2 = Gsus4...
From your diagram, using 6,2 and 4, in key G, that gives the notes E, A and C, making the ii chord in G - A minor. Look at the shape of the three notes on the top three strings - it's the same shape as an open Dm chord that beginners may play.
Minor chords are just that - minors; majors, majors. Within any key, there can be found 3 major and 3 minor chords (plus a less used diminished). So, in conclusion, taking notes from the major scale won't merely give major chords. I'm sure you're not the first person to consider this as confusing!
Answer: What you have discovered is that there are Diatonic chords for each key.
A diatonic chord is simply a chord that is made up of notes that are in the key.
So in the key of C major you can make the following chords from just notes that are in the key:
C Maj, d min, e min, F maj, G Maj, a min, and b diminished. (you could extend this further by adding the next 3rd up to get all the diatonic 7th chords.)
The relationship for all major keys will be the same: Maj, min, min, Maj, Maj, min, Dim.
In the key of G major the diatonic chords are G Maj, a min, b min, C Maj, D Maj, e min, f# dim.
(the diagram above is not C major, but G major)
On the 7th fret for example you have, on the highest 3 strings (3, 5, 7) which is a B minor triad, diatonic to the key (of G), it is the 3rd chord, the iii (3 minor)! If you kept looking you would actually find shapes for all of the diatonic triads.
Now take your "caged shapes", lets start with the A major shape on the 2, 3, 4 strings (b,g,d strings). If you find the A shape on the 7th fret you have a D major triad (which is diatonic to the key of G (D major is the V or 5th).
Now take your D shape on the top three string. On the 2nd fret it is a D, on the 4th fret it is a E, 5th fret it is a F and then on the 7th fret it is a G! Boom, there it is, in your diagram as a G major which is clearly diatonic as it is the I (1 major).
If you want to play a chord that is not in the key, you can do that by playing a known shape but just know that you are playing notes that are not marked in your diagram above. For example you can play d minor (not in the key of G) by taking your D major chord (using the A shape in my example above, 7th fret on the g,b,d strings) and flat the f# on the b string, 7th fret moved to the 6th fret), notice that this minor is the same shape that you would play an open A minor chord just slid up to the 7th fret, just like we played the D major with the A major shape slid up to the 7th fret.
One more point of clarification: The chord you are playing at the moment doesn't change the key you are in, since each key has many chords. What key you are in has more to do with the tonal center, where you feel the song is at rest (G in G major for example). You can play A minor > D major > G major and you will feel strongly that you were in the key of G since that is a ii > V > I cadence.
Comment: Just to clarify, i know the scale on the picture is G major because the roots are G... however the SHAPE is based on the open C chord, that's why i called it C shape. I understand how adding notes to a major/minor triad creates new chords like Sus/maj7 etc what confuses me is what happens when the root is removed but i'm still playing notes within that scale.
Comment: There are "formulas" for chords just like there are for scales. A major triad chord has a root, major 3rd, perfect 5th. Minor is root, minor 3rd, perfect 5th. Both of those chords can be found in a key. A scale is a series of notes that is whole step, whole, half step, whole, whole,whole, half. So, in the key of C you can play a d minor chord which has notes d, f, a but no C so it is missing root of the KEY. It's still a d minor chord which is diatonic to the key. You could also play a B, D, F and it could be a G7 chord without the root or a b diminished chord. Depends on the context.

Guitar inversions / triads / CAGED