$\Lambda_R [\alpha_1,...,\alpha_n]$ is the graded tensor product over $R$ of $\Lambda_R [\alpha_i]$ where the $\alpha_i$'s have odd dimension.

Question: In Example 3.16 of Hatcher's Algebraic Topology, it is written that the exterior algebra $\Lambda_R [\alpha_1,...,\alpha_n]$ is the graded tensor product over $R$ of the one-variable exterior algebras $\Lambda_R [\alpha_i]$ where the $\alpha_i$'s have odd dimension.
The definition of the exterior algebra is a given by:
The exterior algebra $\Lambda_R [\alpha_1,...,\alpha_n]$ over a commutative ring $R$ with identity is the free $R$-module with basis the finite products $\alpha_{i_1}...\alpha_{i_k}$ ($i_1<...<i_k)$, with associative, distributive multiplication defined by the rules $\alpha_i \alpha_j = - \alpha_j \alpha_i$ for $i \neq j$ and $\alpha_i^2=0$. The empty product of $\alpha_i$'s are allowed, and provides an identity element $1$ in $\Lambda_R[\alpha_1,...,\alpha_n]$. The exterior algebra becomes a (anti)commutative graded ring by specifying odd dimensions for the generators $\alpha_i$.
I understood the  definition of the exterior algebra, but I cannot understand the statement in Example 3.16. What is a "graded tensor product"?
Is it just meaning that $\Lambda_R[\alpha_1,...,\alpha_n]$ is isomorphic as $R$-algebras, to the tensor product $\Lambda_R[\alpha_1] \otimes _R .... \otimes _R \Lambda_R[\alpha_n]$?
Comment: @ConnorMalin I think I am reading quite carefully, but I can't see an explicit definition. For two graded $R$-algebras $A= \oplus _k A_k$ and $B=\oplus _l B_l$, does $A \otimes _R B$ is also a graded $R$-algebra with $A \otimes _R B= \oplus _{n}( \oplus _{k+l=n} (A_k \otimes_R B_l)) $?
Answer: Let $A=\bigoplus_{n=0}^\infty A_n$ and
$B=\bigoplus_{n=0}^\infty B_n$ be graded algebras over the ring $R$. We define
$C=A\otimes_R B$ as the vector space with grading
$$C_n=\bigoplus_{k=0}^n A_k\otimes_R B_{n-k}.$$
There are a couple of ways to make $C$ into a graded $R$ algebra. Here is the
less obvious way. Define, for $a\in A_k$, $b\in B_l$, $a'\in A_r$ and $b'\in B_s$,
$$(a\otimes b)(a'\otimes b')=(-1)^{lr}(aa')\otimes (bb')\in A_{k+r}\otimes_R
B_{l+s}\subseteq C_{k+l+r+s}.$$
If we define graded tensor product this way, then we can extend to products
of three or more graded algebras with no difficulty. If we consider
$R[\alpha_i]$ where $\alpha_i^2=0$ and $\alpha_i$ is in dimension $1$,
then the sign rule enforces the relation $\alpha_i\alpha_j=-\alpha_j\alpha_i$
in the tensor product $R[\alpha_1]\otimes_R\cdots\otimes_RR[\alpha_n]$.


is it possible to make target shared library file name variable according to environment variable in cmake?

Question: I'm not familar with cmake but in CMakeLists.txt we  set the target shared library name like this.
add_library( mylib SHARED ${source_list} )

This generates libmylib.so and other settings in CMakeLists.txt are defined for mylib like
about the mylib
and also we can use shell environment variable to do some selective settings like
target_compile_definitions( mylib PRIVATE -DQQQ -D... )

Also it is possible to use shell environment variable to do some selective things.
if(defined env{MYVAR})
set(CMAKE_C_FLAGS "-g -DXYZ")
else()
set(CMAKE_C_FLAGS "-DXYZ")
endif()

I would be happy if I could set the target shared library name as a variable according to the environment variable and use that selected name variable as the shared library name in all other settings.  In other words, is it possible to do things like below?
if (defined ENV{FOR_QEMU})
set_name(target_name "simlib_qemu")
else ()
set_name(target_name "simlib")
endif ()
add_library(target_name SHARED ${source_list} )
target_compile_definitions( target_name PRIVATE -DQQQ -D... )
...

Answer: You can set the output name of a target to anything you like via:
set_target_properties(target_name PROPERTIES OUTPUT_NAME "whatever")

Then instead of libtarget_name.so, you'll get libwhatever.so. You would continue to refer to the target as target_name in your CMakeLists.txt.

However, since this will only work during configure time anyway, I strongly urge you to use a normal CMake variable instead. You may initialize it from the environment if it is not set, like so:
option(FOR_QEMU "Enable if building with Qemu support" "$ENV{FOR_QEMU}")

add_library(simlib SHARED ${source_list})
target_compile_definitions(simlib PRIVATE -DQQQ -D...)

if (FOR_QEMU)
  set_target_properties(target_name PROPERTIES OUTPUT_NAME "simlib_qemu")
endif ()

This way, the CMake variable FOR_QEMU is the de-facto control and it is initialized on the first execution if the matching env-var is set. It will also appear with documentation in the cache, so other developers may query the build system directly for all its configuration points. Bear in mind: CMake is not Make and reading from the environment on every configure is a surprising behavior and generally bad practice.
Comment: Thanks, it works good and that was convenient! (but now I'm thinking of making two versions at the same time because they'll be exclusively used with different names now..)


Is backpropagation algorithm same for both full-connected and local-connected neural network?

Question: Is the backpropagation (BP) algorithm the same for both fully-connected and locally-connected (or partially-connected) neural networks? I know how to use BP for a fully-connected network, but I don't know how to use BP for a locally-connected network. How would I calculate the derivative for those links which are not connected, is there any documentation for this?
Answer: Yes, it's the same.  A locally connected network can just be thought of as a fully connected with 0-valued weights for "distant" connections.  In the backwards pass through these "non-connections", the gradient is multiplied by 0 and therefore ignored.
If your "local" connectivity is convolutional, then you pass back your gradient by reversing your kernel and doing another convolution.  (This gives you the same result as if you considered it to have full connectivity with 0-weights for non-local connections).


javascript callback function after several jQuery calls

Question: I got the following code:
$('#some_object_id').hide();
$('div#some_version_div').hide();
$('#some_another_object_id').show();
someFunction();

I want to issue my someFunction() only after the last of these 3 finishes its action. The problem is that from time to time they finish in different order (ie now the last may be the second, the other time the first one etc.) Now someFunction() fires without waiting for these 3 to finish. Any ideas how to fix it? Thank you.
Comment: You're not passing a duration parameter to `show()` or `hide()`, so their effects should be immediate. So it seems to me the order should be reliable and the effects instantaneous.
Comment: @Utkanos - the default is actually 400ms (http://api.jquery.com/hide/)
Comment: In fact they are not instantaneous. They are made with some noticeable delays
Comment: It's default 400 only when passing params. If you pass none, it's null. From the docs: "[When called with no duration param,] the matched elements will be hidden immediately, with no animation. This is roughly equivalent to calling .css( "display", "none" )"
Comment: Because in your example you are actually setting the speed - to `null`!   -- The docs go on to say "When a duration, a plain object, or a "complete" function is provided, .hide() becomes an animation method. " meaning it will take on the default speed of 400ms of not set.
Comment: OK, here's the same result without passing null: https://jsfiddle.net/q7e9toxu/
Comment: However, I do concede that, even when effectively instantaneous, it's still asynchronous because, looking at the jQ source code, it still defers to its animation module, just with a duration of 0.
Comment: Good question for begineers
Answer: jQuery's hide() and show() functions accept a function as their argument which is called when they finish. (aka, a callback).
$('selector').hide(function onFinish() {
  console.log('done')
})

To combine three of them together, I'd convert them to a Promise, like so:
function promisify(func,selector){
  return new Promise(function (resolve) {
    $(selector)[func](resolve)
  })
}

Promise.all([
  promisify('hide', '#test'),
  promisify('hide', '#test1'),
  promisify('show', '#test2')
]).then(function onFinish() {
  console.log('done!')
})

Comment: Well actually binding where you did is kind of pointless, here is a way without needing bind at all: https://jsfiddle.net/5o6btpnd/ just pass the function name, and selector and build the call in function.
Comment: How can I use Promise? Is it provided in javascript?
Comment: @artgb Yes, Promises are part of JavaScript. There's tons of great tutorials. Here's one: https://developers.google.com/web/fundamentals/getting-started/primers/promises
Comment: @PatrickEvans At this point I feel like you should get credit for the answer. But thanks for the suggestions!
Answer: You can pass a callback function to hide, and show that gets executed when the animation is complete. So if you want them to execute in order just call each one in the callback of the previous one.
$('#some_object_id,div#some_version_div').hide(()=>{
  $('#some_another_object_id').show(()=>{
    someFunction();
  });
});

And if you want to prevent a bunch of inner callbacks, and not require each animation run dependent of the others, you could use a flag. Increment the flag in each callback, check to see if its at a certain value, and then execute your function if it is.
var flag = 0;
function incrementFlag(){
   flag++;
   if(flag>=2){
     flag=0;
     someFunction();
   }
}
$('#some_object_id,div#some_version_div').hide(incrementFlag);
$('#some_another_object_id').show(incrementFlag);

You could also modify the above to use a Promise, but will leave that for you to try.
Comment: @artgb, how so?
Comment: If the code contains more hide and show you have to change further
Comment: Well the question wasn't about how to make a callback for an arbitrary number of calls.
Comment: Good question for beginners
Answer: You should use a variable that you initially set to 0 and increase on every complete call. As soon as the variable hit the value 3 and can call your function:
var completed = 0;
elem.hide(400, function(){
    completed++;
    if(completed > 2) someFunction();
});
//same for other elements...


Pegar evento click dentro de iframe com jQuery

Question: Estou usando o Google Forms para fazer uma pesquisa de satisfação em um site. Nesse site eu mostro uma barra no topo, pedindo ao usuário que participe. Se ele fechar a mensagem, é gravado um cookie que expira em 24 horas para que não veja mais a mensagem naquele dia.
Eu gostaria de gravar um cookie, caso o usuário responda o questionário para que ele não veja mais a mensagem no site.
Alguém sabe de um jeito de fazer isso?

Edição:
  Consigo gravar o cookie com jQuery.
  Existe alguma forma de pegar o evento click do form? Via javascript ou jquery.
  Ele está em um iframe e não consigo usar jquery, por exemplo, e pegar o evento click.

Iframe:
Carregando...

JQuery:

Comment: #ss-submit é o id do button. Peguei pelo devtools.
Comment: Vi que não posso pegar o evento por causa das políticas da mesma origem. Alguém sabe alguma forma de fazer isso?
Comment: Pelo que entendi, você não pode interagir com o conteúdo de um iframe vindo de outro domínio que não seja o do seu site. Mas você pode criar um botão FECHAR fora do iframe e assim gravar o cookie válido por 24h. No caso do usuário responder à pesquisa, você precisa de um callback do Google com o ID da pesquisa que será enviado ao seu site de forma que vc identifique isso e grave um cookie com validade "ilimitada" para que a pesquisa não apareça mais praquele usuário.
Answer: Para ver o conteúdo deste iframe faz isso:
var frame = window.frames[0].document;
O .frames[0] -> 0 representa o único iframe na tela, caso exista outro é necessário colocar qual index do iframe.


Showing multiplicative inverse has the same order $\pmod{p}$?

Question: Suppose that $a$ has order $h \pmod{p}$ and $a\overline{a} \equiv 1 \pmod{p}$. Show $\overline{a}$ also has order $h$.
I'm a little confused as to how to start proving this -- I know that if $a$ has order $h \pmod{p}$, then the positive integers $k$ such that $a^k \equiv 1 \pmod{p}$ are precisely those for which $h|k$. This would lead me to conclude that if I can prove $a|\overline{a}$, then I'm done. But is this the correct approach? Thanks.
Comment: Calculate $a^h\bar{a}^{h}\pmod p$.
Comment: Any element of any group has the same order as its inverse. In fact _all_ the integers $k$ (non-positive ones too) for which $a^k \equiv 1 \pmod p$ are those for which $h\mid k$; in particular $(\bar a)^h=a^{-h} \equiv 1 \pmod p$.
Answer: We know that $a^h \equiv 1$. Suppose that $\overline a$ does not have order $h$, and consider the product $(a \overline a)^h$.
On the one hand, this is $1^h \equiv 1$. On the other hand, this is $a^h \overline a ^h \equiv 1 \overline a^h$. So we conclude that $\overline a^h \equiv 1$. This doesn't necessarily mean that $\overline a$ has order $h$ yet - just that $\overline a$ has order dividing $h$.
So now we need to show that the order of $\overline a$ is not less than $h$. To do this, we use the same idea. Suppose the order of $\overline a$ is $d < h$, a divisor of $h$. Then $ 1 \equiv (a \overline a)^d \equiv a^d$. This is false, as the order of $a$ is $h$, and therefore not $d$. So the order of $\overline a$ is $h$ by contradiction. $\diamondsuit$
This proof works in generality, showing that in any group, the order of an element is the same as the order of its inverse.


Showing consistency of an estimator

Question: I have $\log X \sim Exp(\vartheta - 1)$ and I would like to show
$$ P \Big [ \Big |\frac{1}{\frac{1}{n} \sum_{i=1}^n \log X_i} - (\vartheta - 1) \Big | > \varepsilon \Big ] \rightarrow 0  \hspace{5 mm} \forall \vartheta (n \rightarrow \infty)$$
In the answer to this question it states that all moments of the exponential distribution that are necessary for the strong law of large numbers exist. Therefore $\frac{1}{\frac{1}{n} \sum_{i=1}^n \log X_i}$ converges almost surely towards $\frac{1}{\vartheta - 1}$.
Can someone explain to me why the moments need to exist for the law of large numbers? And how this proof works? Many thanks for your help!
Comment: Wikipedia claims that the law of large numbers holds whenever the random variable has finite expectation, and you don't need any higher moments.
Answer: First, the convergence of $\frac{1}{{\frac{1}{n}\sum\nolimits_{i = 1}^n {\log X_i } }}$ is towards $\vartheta  - 1$, not $\frac{1}{{\vartheta  - 1}}$, of course. Second, as Yuval indicated, it suffices that the first moment (expectation) exists. This guarantees that the average converges to the expectation almost surely, hence also in probability. (An assumption of finite variance is often used for convenience, but is not necessary.) Finally, it is relevant to note that continuous functions are limit-preserving even if their arguments are sequences of random variables, see continuous mapping theorem.

Showing consistency of an estimator


How to trace the cause of an error result?

Question: When writing code that uses Result type, you may want different behavior for users and developers.

When writing an application that gracefully handles errors, it's nice to use Result.
During development you may want to "catch" the error to see what line of code creates the error or get a stack-trace the moment the Err value is created.

If you make a unique error it's not hard to search for it, but if the error is from the standard library, the error may be very generic.
For example, it's impossible to know which read command caused an unexpected end-of-file without manually changing every file.read()? to file.read().unwrap().
Is there a convenient way to get a stack-trace from a Result?
A  weak but workable solution could be to make a macro for reading, read_in_release_unwrap_in_debug!(file, data)... but this feels very awkward.

I have a file reader with many read calls and one fails. I'm not sure which. At run-time, I want to push the result back to the caller. For debugging, I want the failed read call to stop or somehow let me know its line number.
Answer: If you use anyhow you can get this for free! You enable an environment variable:
RUST_BACKTRACE=1 cargo +nightly run

Also enable the backtrace crate feature.
Comment: On Rust `1.65` with `anyhow` `1.0.66` I needed the `backtrace` feature enabled in `Cargo.toml`. ie. `anyhow = { version = "1.0.66", features = ["backtrace"] }`
Comment: Looks like it's now on stable per the linked PR.
Comment: `RUST_BACKTRACE=1` `use anyhow::Result` `cargo add anyhow --features backtrace` is that all? I can't see the origin of errors with them though. Is `+nightly` needed still?
Comment: That should do the trick. Nightly isn't required. Not sure why it isn't working for you. Maybe it only works on some platforms?
Answer: A result by itself doesn't have any backtrace information, but you can add it to custom error types.
The error_chain crate (which is unfortunately no longer maintained) is an example which generates an error type for you, for which you get backtrace generation for free when the RUST_BACKTRACE environment variable is set.
You could also use the backtrace library directly and do it yourself.
Answer: I resolve this requirement with easy-error crate, while error-chain crate is fine also.
Use Result defined in easy-error as return type, then use context method to convert other Result types.
Most important thing is to pass information to context method with line number.
use easy_error::{Result, ResultExt};
use std::path::PathBuf;

fn test_open() -> Result<()> {
    let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
    p.push("resources/test/songs.json");
    File::open(p).context(format!("{}:{}", file!(), line!()))?;
    Ok(())
}

To avoid typing format!("{}:{}", file!(), line!()) all the time, define a macro:
#[macro_export]
macro_rules! code_loc {
    () => {
        format!("{}:{}", file!(), line!())
    };
}

And finally code will be:
File::open(p).context(code_loc!())?;


Find a polynomial $p(x)$ with degree lesser than or equal to $3$, with $p(1) = 2, p(2) = 3, p(4) = 5, p(6) = 7$

Question:
Find a polynomial $p(x)$ with degree lesser than or equal to $3$, with $p(1) = 2, p(2) = 3, p(4) = 5, p(6) = 7$.

Also, prove that there is exactly one polynomial that satisfies the above criteria.
I've tried this using the Lagrange interpolating formula. But without much clarity.
EDIT 1: I think I've figured out a way, and I will post it answer soon...
EDIT 2: I cannot see why I got so many downvotes; I can't understand what should I do to make this question better...
Can somebody please suggest?
Comment: Why wouldn't a "naive" approach where you solved a system of 4 linear equations do the job?
Comment: Per the comment of @Deepak, exactly.  That is, set $p(x) = ax^3 + bx^2 + cx + d$.  You end up with 4 linear equations in 4 unknowns that may or may not be solvable.  As you *solve* the system, you will (presumably) simultaneously be *proving* that the solution (i.e. the solved values for $a,b,c,d$) is unique.
Comment: thanks, guys...
Answer:
solution:

We see that $g(x) =x+1$ works. Then polynomial $h(x) = p(x)-g(x)$ is of degree $3$ or less and has $4$ zeroes. That means that it is identical to $0$ which give us $p(x)$ is unique.

solution:

Write $p(x) =ax^3+bx^2+cx+d$ and write system: $$2 = p(1) =a+b+c+d$$ and so on and solve the system. You see that $a,b,c,d$ are uniqly determined.


send whats popping up in the console?

Question: I have a run command with my discord bot, it basically runs a bash command from the terminal. It works perfectly fine, but I want the discord bot to send what the command is saying in the console. for example if you type .run pwd, it should send a message saying the current directory.
This is my code so far
<code>@commands.check(owner)
async def run(ctx, *, arg):
  response = os.system(arg)
  ctx.author.send(response)
</code>
Any help would be appreciated! thanks
Answer: Are you looking for something like this?
<code>@commands.is_owner()
@client.command()
async def run(ctx, *, arg):
    response = os.popen(arg).read()
    try:
        await ctx.author.send(response)
    except:
        await ctx.author.send(f'/bin/sh: 1: {arg}: not found')
</code>

send whats popping up in the console?


set maximum length to image title

Question:
I'm trying to figure out how I can limit the maximum length of an image title to 40.
I have enabled title from the image field in my content and it works fine except that it seems to take unlimited number of letters. I want to reduce the maximum length of image title to 40.
Does anyone have any idea how to do it?
Thanks
Answer: Something like this may work:
<code>/**
 * Implements hook_field_widget_form_alter
 */
function mymodule_field_widget_form_alter(&$element, &$form_state, $context) {
  if ($context['field']['type'] == 'image' && $context['instance']['widget']['type'] == 'image_image' && !empty($context['instance']['settings']['title_field'])) {
    foreach (element_children($element) as $delta) {
      $element[$delta]['#process'][] = 'mymodule_image_field_widget_process';
    }
  }
}

/**
 * Image field process callback
 */
function mymodule_image_field_widget_process($element, &$form_state, $form) {
  // Set title maxlength, if accessible
  $maxlength = variable_get('imagefield_maxlength', 40);
  if ($element['title']['#access']) {
    $element['title']['#maxlength'] = $maxlength;
  }

  return $element;
}
</code>
Comment: I got this working by editing the image module's image.field.inc file. Changed to '#maxlength' => 100
Comment: Hacking core is bad practice

set maximum length to image title


What is the growth rate of $h(n)?$

Question: $$h(n) = \#\{ \pi(x)\pi(n-x),x\le n\}$$
What is the growth rate of $h(n)?$
(the notation means find the distinct values of $h(n)$ for each $n \in \Bbb N)$
for example, plotting the point $(12,4)$ corresponds to $n=12$ and $4$ distinct values for $n=12.$
If the answerer(s) could include plot(s) in their answer with many more values that would be great. I'm interested in seeing a better plot and learning about a possible pattern.
Prime counting function is in light green for reference

Updated plot:

It seems to grow about the same as $\pi(x)$ for this sample set of points, which makes sense because $f(x)$ is defined using the multiplication of prime counting functions. It seems to be less than or equal to $\pi(x)$ for all values.
Comment: reading your question is annoying me greatly. I don't want to have to read the whole thing and wade through some confusion to figure out what you're asking. Can you please just be precise about what you're counting. You fix $n$ and then count the number of $k$ such that...? What is $x$? Can you please just start your question off with a precisely stated question? Cmon, this is a math website, it's not difficult
Comment: dude, I have no idea what that means. write it out algebraically in your question. is $k$ a variable as well? how can $k$ solve an equation if $x$ is a variable? Precisely state what the variables are and what is given.
Comment: $\vert\{(x,n): \pi(x)\pi(n-x)=k\}\vert$  it's only odd if $({n\over 2},{n\over 2})$ is in there. This is due to intersection of the lines $y=x$ and $y=-x+n$ at that point. I can partially relate Goldbach to those lines so I'm weirded out.
Comment: Is $\pi$ by any chance the prime-counting function? If so, that crucial piece of information should be mentioned in the body of the question.
Comment: Good. Now, the only question I see in the above is (I think) for each $n$ from $2$ to $1000$, compute the number of distinct values taken on by $\pi(x)\pi(n-x)$. But surely this is just a matter of letting your computer run long enough. In any event, what is so interesting or important about the number of distinct values of $\pi(x)\pi(n-x)$ that anyone would want to know it? What does it tell us about primes? What does it help us learn? What useful properties does it have? It seems completely unmotivated.
Comment: This is a very low quality post. Delete everything and just type "for each $n$, let $h(n) = \#\{ \pi(x)\pi(n-x),x\le n\}$, what is $h(n)$'s growth rate ?". Then you are supposed to plot $h(n)$. The obvious guess is $h(n)\sim C\pi(n)^2$ where $C=1/2$. Thus you are supposed to estimate $C$ numerically. And Gerry's comment is correct : you have no good reason to look at such weird functions, this is not how number theory works.
Comment: @reuns you can actually restrict to less than the ceiling of half n by my previous comment, as it counts things twice if you count the full range.
Comment: @mathworker21 fix $n$ and then count each horizontal line, $k$ that solves the equation. $x$ is a variable. for a given $n$ there will be a finite number of horizontal lines that solve the equation. I'm taking the number of horizontal line solutions, for each $n$ and recording them as $|k|$ and then plotting $(n,|k|)$
Comment: @reuns that isn't a very good guess because $\pi(n)^2$ increases faster
Answer: Here's a bound on your function:
$h(n)\leq\pi(n)$
This can be proved because there are only $\pi(n)$ choices for the first value, and $\pi(n)$ options for the second value, giving us a square of different pairs of options. When x starts low, we choose values in the top left corner of the square, since $\pi(x)$ is low and $\pi(n-x)$ is high. As we increase x by one, we choose the same point in our square until either $\pi(x)$ increases, or $\pi(n-x)$ decreases, or both happen at once; in this case we take a step in our square either one step to the right, one square down, or one square diagonally left and down. This means we can only move right and down in our square, and h(x) almost counts all the squares we hit along the way to the diagonal, after the diagonal, we just get repeats since the product is symmetric. it misses some because some happen to have the same product. Since this path is completely down and to the right, it will reach the diagonal in at most $\pi(n)$ steps.

What is the growth rate of $h(n)?$


Question about early stopping

Question: I've got a question regarding early stopping and I was hoping to get some insights here!
When would be best to stop training for a model that converges after a few epochs. It would make sense to stop training after training loss drops below the validation loss, but even after this point, validation loss keeps on decreasing, so would it be safe to assume the model is improving? or should the training be stopped when training loss drops below the validation loss?
I've attached two examples below, where in your opinion would be the best epoch to stop training?
Also, as in the second example, the model converges quickly, does that mean the learning rate should be decreased even further (it's currently set as 0.0001, with an Adam optimizer).
Thanks!
Answer: To avoid overfitting on the training dataset, we use Early Stopping as a form of regularization. While using Early Stopping, there are three factors to consider,
First is what metric to track, here in your case, it is validation loss. Second factor is Patience; it is the number of epochs with no improvement after which training would be stopped. Third is to define what qualifies as an improvement, a minimum value of the absolute change from epoch to epoch in the tracked metric. There are no standard values for these, I'll link these answers for your reference.
In addition to that, which might also clear your second question too, I'd suggest you to try reducing the learning rate when your tracked metric has stopped improving (hitting a plateau) or decaying the learning rate by a fixed factor every few epochs. Both Tensorflow and PyTorch have libraries to do this for you.

Question about early stopping


NFS + SMB sharing file locks

Question: Is there any way to share file locks between samba(smbd) and nfs(-kernel-server)?
I assume that this is hard to impossible on most linux distributions. The regular smb/nfs implementations have no way of communicating file locks with one another. Is that correct?
I get that NFS permissions/locking differs significantly from SMB. From what I gather there are commercial solutions (such as NetApp, Dell unity/unify, IBM, ..). If I understand correctly, these work on an filesystem abstraction layer, that is shared higher up in the io stack over nfs/smb. Is this achievable in the FOSS realm as well?
Comment: What's the specific use case? Why do you need this particular combination? More detail would help for other people who may visit this question.
Answer: In general, the kernel nfs locks and smbd locks are not really play together as the first one implemented in the kernel space, the second one is either in filesystem of smbd itself, thus they don't see/respect each other. The new in-kernel ksmbd implementation aims address this issue in the future, but currently it's not the case.

NFS + SMB sharing file locks


Power method without unique largest eigenvalue

Question: Consider this question

I was able to do the first part of (a) with

and all of (b) in which I showed that the three vectors are dependent through which I was able to get, through some manipulation two eigenvalues and the  corresponding eigenvectors.
I am struggling to answer the second case of (a). That is

Describe the asymptotic properties of the sequence $\mathbf{x}^{(k)}$,  $\lambda_i|<| \lambda_{n-1}|=| \lambda_n \mid, i=1, \ldots, n-2$. In the latter case explain how the (possibly complexalued) eigenvalues $\lambda_{n-1}, \lambda_n$ and their corresponding eigenvectors can be determined.

This case has never been covered by the course so I assume it should be a simple tweak of the argument in the afore mentioned theorem. Therefore, I wouldn't  find it too suprising if the result was
$$
\operatorname{dist}\left(\boldsymbol{x}^{(k)}, \operatorname{span}\left(\boldsymbol{w}_1,\boldsymbol{w}_2\right)\right)=\mathcal{O}\left(\rho^k\right).
$$
If this is true, then I do not know how to answer the other part of (a). In particular, the above will tell me that we go to a vector in the plane spanned by the two vectors, but I don't see how this helps me in finding them.
Question: What happens in the case
$$
\left|\lambda_i\right|<\left|\lambda_{n-1}\right|=\left|\lambda_n\right|, i=1, \ldots, n-2
$$
and how can the eigenvalues/eigenvectors be determined (in that case)?
Comment: Based on the wording of the question, it looks like that would be sufficient and a formal proof is not required. Regarding finding the eigenvalues and eigenvectors, I put an explicit procedure into my answer.
Comment: A generalization of the manipulation that you did in part (b) is exactly what they're looking for when they ask how to find the eigenvalues/eigenvectors in part (a)
Comment: You're right about the convergence rate, with $\rho = |\lambda_{n-2}|/|\lambda_n|$
Comment: Hi @BenGrossmann, thank you for this. Do you think that it is sufficient to say that? I tried to be explicit but I do not believe this will always work. Also feel free to post the above as answer and I will gladly accept it.
Answer: Your guess that
$$
\operatorname{dist}\left(\boldsymbol{x}^{(k)}, \operatorname{span}\left(\boldsymbol{w}_1,\boldsymbol{w}_2\right)\right)=\mathcal{O}\left(\rho^k\right)
$$
is correct, with $\rho = |\lambda_{n-2}|/|\lambda_n|$. Here, $\boldsymbol w_1, \boldsymbol w_2$ are eigenvectors associated with $\lambda_{n-1}$ and $\lambda_n$ respectively. As you say, it should be possible for you to tweak whatever proof you were presented in order to show that this is the case.
Regarding the computation of the eigenvectors: denote $U = \operatorname{span}\left(\boldsymbol{w}_1,\boldsymbol{w}_2\right)$. Notably, $U$ is an invariant subspace of $A$. For sufficiently large $k$, you can guarantee that $\mathbf y_k \in U$ (up to numerical precision). Thus, the vectors $\mathbf y_k,\mathbf y_{k+1}, \mathbf y_{k+2}$ are all elements of the invariant subspace $U$. Also, assuming that we weren't astronomically lucky and happened to converge to $\text{span}(\boldsymbol w_i)$ for $i = 1$ or $i = 2$, we know that the vectors $\mathbf y_k, \mathbf y_{k+1}$ are linearly independent. Thus, $\mathbf y_k, \mathbf y_{k+1}$ form a basis of the 2-dimensional $U$.
Now, the eigenvalues/eigenvectors we're after are the eigenvalues of the restriction $A|_U$. We may compute the matrix of the restriction $A|_U$ relative to the basis $\mathcal B = \{\mathbf y_k, \mathbf y_{k+1}\}$. If $\mathbf y_{k+2} = a\mathbf y_{k} + b\mathbf y_{k+1}$, then the fact that $A \mathbf y_k = \mathbf y_{k+1}$ gives us
$$
[A|_U]_{\mathcal B} = \pmatrix{0 & a\\1 & b} =: M.
$$
All this leads to the following procedure by which we can obtain the eigenvalues/eigenvectors that we're after.

Obtain vectors $\mathbf y_k, \mathbf y_{k+1}, \mathbf y_{k+2}$ for a sufficiently large $k$
Solve the linear system $a\mathbf y_k + b \mathbf y_{k+1} = \mathbf y_{k+2}$.
Obtain eigenvalues $\mu_1,\mu_2$ of the matrix $M$ described above and corresponding eigenvectors $\mathbf v_1 = (v_{11}, v_{12})$ and $\mathbf v_2 = (v_{21}, v_{22})$.
The eigenvalues we're after are $\lambda_{n-1} = \mu_1$ and $\lambda_{n} = \mu_2$. The corresponding eigenvectors are
$$
\boldsymbol w_1 = v_{11}\mathbf y_1 + v_{12} \mathbf y_2, \qquad
\boldsymbol w_2 = v_{21}\mathbf y_1 + v_{22} \mathbf y_2.
$$


SOLR - Rank better smaller documents that have less "EXTRA" words

Question: My SOLR documents are wine entities. When a user search for a keyword "Haut Bailly" (it's a wine from bordeaux), I would like to get first a closely matching document with shorter title length, ex:

"Château Haut-Bailly - Pessac-Léognan"
"Château Haut-Bailly La Parde de Haut Bailly - Pessac-Léognan"

However with default solr queries, the keywords "haut bailly" return this ranking:

"Château Haut-Bailly La Parde de Haut Bailly - Pessac-Léognan"
"Château Haut-Bailly - Pessac-Léognan"

Is there any parameters that I could play with to increase the score of a match that is closer to phrase searched (in terms of length) and shorter field (here it's title)? So that here the right wine ("Château Haut-Bailly - Pessac-Léognan") comes up in ranking?
Thank you!
Comment: You should share the schema for the field you are searching on.
Answer: Using a duplicate filter might work
  http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.RemoveDuplicatesTokenFilterFactory
Answer: I think default scoring would already do that (if you are not omitting norms with omitNorms). The first document scores higher cause it has the search twice (most possibly it is matching Haut-Bailly as well, or one of the words, depending on the tokenizer/parser you are using)


Command of CMD,Object reference not set to an instance of an object

Question: I have a problem with the code  Launcher  to game. All comes down to a few lines of code, it's exactly the command cmd.exe ,I encountered with error
"Object reference not set to an instance of an object".

I do not know how to solve this because I wrote here that I have no idea, and my knowledge is limited. Line string argument "Start".
Code :
public string nn;
this.nn = Name;

string newlok = System.IO.Directory.GetCurrentDirectory()+"\\"+nn;
string TempFilePath = System.IO.Directory.GetCurrentDirectory() +"\\"+ System.Reflection.Assembly.GetExecutingAssembly().GetName().Name+".exe";

private void UpdateApplication(string tempFilePath1,string newlok)
{
   here there is a problem --->    string argument = "/C  Start \"\" /D \"{0}\" \"{1}\"& choice /C Y /N /D Y /T 4 & Del /F /Q \"{2}\" & choice /C Y /N /D Y /T 4";

                ProcessStartInfo Info = new ProcessStartInfo();
                Info.Arguments = String.Format(argument, Path.GetDirectoryName(newlok.ToString()) + "\\", Path.GetFileName(newlok.ToString()), tempFilePath1);
                Info.WindowStyle = ProcessWindowStyle.Normal;
                Info.CreateNoWindow = true;
                Info.FileName = "cmd.exe";
                Process.Start(Info);
}

OK, now some explanation.
Name is taken from XML, all is read because I checked, returns Programs.exe and probably the rest catch on :D
Maybe for some little vaguely explained but my language English regrets...
Comment: When does the exception occur? can you include the full stack trace?
Comment: What is `lokali`, and is it null? Which line of code **exactly** is the error thrown on? (The exception should give you a line number)
Comment: Can I suggest that you try a string literal for argument (argument = @"/c ... etc?
Comment: When you are done checking the Update, the code here I did not give, but only the part that perhaps has to do with the problem
Comment: Sorry ,I forgot change this,but it does not work.Is string newlok.returns properly or "Program.exe".
Comment: Can you be slightly more specific that "it does not work"?
Comment: Okay, I've just put your example into a console app and it compiles and runs file (I obviously didn't go as far as deleting anything), and I had to reconcile the various compile errors (as others have already pointed out lokali doesn't exist, also, you seem to have some code outside of a function that should be inside.
Comment: Yes lokali doesn't exits .. lokali was converted on string newlok ,but still the same error
Answer: Object reference not set to an instance of an object
This error happens when you try to use a property or call a method of an object that is null.
A simple use of Visual studio DEBUGGER can tell you the object because of which it is happening. Just look at the stack trace and put a debugger on that line. Check the objects of that line and see if any one is null and you are trying to use that objects property. Handle the same.


Sessão não identificada em alguns logins no django

Question: estou fazendo uma manutenção em uma app Django versão 1.5 com DRF 2.3. Essa app possui uma autenticação de usuários fora do padrão do Django, e que funciona bem. Veja um resumo abaixo:
accounts/views.py
class Autentica(TemplateView):
template_name = 'checkuser.html'

def get(self, request, *args, **kwargs):
    self.request.session['token'] = request.GET['token']
    self.request.session['idUser'] = request.GET['idUser']
    #resto do código ...

Porém quando tento acessar essas duas variaveis de sessão (idUser e token) por meio de outro endpoint do mesmo sistema (EM ALGUNS CASOS) os valores de "idUser" e "token" não existem, como se não tivessem sido definidos na autenticação, sendo que fiz o mesmo processo e verifiquei no método de autenticação e ambos os valores estão sendo definidos normalmente.
Aqui está o endpoint que estou tentando acessar
core/views.py
class PainelGestaoUsuariosView(LoginRequiredMixin, View):
def get(self, request):
    # OUTROS TRATAMENTOS....
    idUser = self.request.session['idUser']
    token  = self.request.session['token']
    #ou request.session['...']
    return HttpResponseRedirect('%URLPARAOSISTEMATERCEIRO/check?token=%s&idUser=%s'%(token,idUser))

Obs.:

Habilitei o 'django.contrib.sessions' e 'django.contrib.sessions.middleware.SessionMiddleware' no settings.py
Praticamente quase todos logins funcionam (consigo acessar as variáveis de sessão), salvo 3 logins que não encontrei diferença.
Como a autenticação é feita de forma diferente a padrão do django o request.user é igual a "Anonymous User" mas acredito que não tenha influenciado nisso.
Answer: Bom, no final das contas devido ao cansaço não percebi um detalhe exdrúxulo porém não menos importante, que é a URL a qual você faz um redirect, cuja a qual estava no ALLOWED_HOSTS sem o www. Item resolvido!


Find all kinds of homomorphisms from $(\Bbb Z_n, +)$ to $(\Bbb C^*, \times)$.

Question: Find all kinds of homomorphisms from $(\Bbb Z_n, +)$ to $(\Bbb C^*, \times)$ and from $(\Bbb Z, +)$ to $(\Bbb C^*, \times)$.
Explain why they are the complete collection.

My intuition is:

1) we can construct $\phi:\Bbb Z_n \to \Bbb C^*$ then $Im(\phi)\le n $
Again $\Bbb Z_n/{\ker \phi} \cong Im(\phi)$.
Some finite subgroups of $\Bbb C^*$ are in $S^1$, i.e.,
$\phi:\Bbb Z_n \to S^1$ s.t $x \mapsto e^{2x\frac{\pi}{n}} $, if $n$ is not prime then we can construct more like this also in each case we have the trivial homomorphism.
So are these the only possibilities or there are more?? Again prove whatever your conclusion is.
2) Same like 1) here we can construct $\phi:\Bbb Z \to S^1$ s.t $x \mapsto e^{2x\frac{\pi}{r}} $ , where $r \in \Bbb R \setminus \Bbb Q$. What next now??
Comment: For someone who's been on the site for a few months, posted nearly 50 questions and another 60 answers or so... you show a terrible lack of efforts to give some context to your question.
Comment: Note that both of these groups are finitely generated. If you specify the value at $1$, you will have the general form of the homomorphism.
Comment: What context do I give more..? Will you explain?
Comment: (1) What did you try? (2) What sort of things which are relevant to this problems you might know. Stuff like that. Something much closer to the other question that you posted earlier today, not to something that you might have copied out of a book, or a homework sheet.
Comment: Yes and I thaught that I can express it in more simpler way. Thats why I posted only the question.
Comment: That's much better. I changed my downvote to an upvote.
Comment: @  Asaf Karagila In the previous question if you saw the comment I thaught people can't get what my question is?? Thats why I remain silent to get a better reply here.
Comment: @ Cameron Williams So where can I specify the value of $1$. Will you explain the whole thing more precisely & give me the answer.
Comment: In part 2,you've written a map $x \mapsto e^{2x \frac{\pi}{r}}$ where $r \in \Bbb R - \Bbb Q$ . Since $x \in \Bbb Z$ and $r\in \Bbb R - \Bbb Q$ ,when $x \ne 0$ and $r \ne \frac{k}{\pi}$ for some $k \in \Bbb Z$ we get $\frac{x}{r} \in \Bbb R - \Bbb Q$ so the homomorphis defines a rotation where the rotation factor is an irrational but not a multpile of $\frac{1}{\pi}$ , then from Dynamical systems point-of-view (hint : use Hurwitz theorem) ,the image is actually dense in the Unit circle and also not periodic! Hence not cyclic but that contradicts that $\Bbb Z$ is cyclic and hence $\phi(\Bbb Z)$
Answer: Let $\varphi$ such morphism so we have $\varphi(\overline 0)=1$ and let $a=\varphi(\overline 1)$ then we have
$$\varphi(\overline n)=\varphi(n\times \overline 1)=a^n=1\implies  a=\exp\left(\frac{2ik\pi}{n}\right),\quad k\in\{0,\ldots,n-1\}$$
Finally we verify easily that the $n$
 maps defined by
$$\varphi_k(\overline1)=\exp\left(\frac{2ik\pi}{n}\right),\quad k\in\{0,\ldots,n-1\}$$
are morphism of groups.
Comment: for $Z$?? What will be the process??
Answer: From the idea of Sami Ben Romdhane
For $\Bbb Z$, I have got $\phi (0)=1$ & $\phi (1)=a\in \Bbb C^*$ then $\phi (n)=a^n$. These are all homomorphisms.
Comment: Would you kindly explain how you jumped to the homomorphisms?


Invalid Object Name SSISDB.dbo.DDLEvents

Question: I am using Sql server 2017.I have admin access to Server.When I am trying to create a role and provide read to any Db I am getting the error message.
TITLE: Microsoft SQL Server Management Studio
Create failed for User '\XXXXX.  (Microsoft.SqlServer.Smo)
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

Invalid object name 'SSISDB.dbo.DDLEvents'. (Microsoft SQL Server, Error: 208)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=14.00.3238&EvtSrc=MSSQLServer&EvtID=208&LinkId=20476

BUTTONS:
OK
------------------------------.
Note::while providing admin access this error does not occur.
Answer: This error comes from a trigger.
Find the trigger, fix the underlying error by debugging the code in the trigger or disable the trigger and the error will go away.
Comment: Yes It was a trigger defined at db level and associated table was missing


MySQL error when trying to get unique values using DISTINCT together with LEFT JOIN

Question: I have two mysql tables, courses and student_courses, I need to get unique course_names from the course table. But I get a erro when trying to execute my query.
Heres my query
        SELECT
            sc.c_id,
            DISTINCT c.course_name
        FROM
            Courses AS c
        LEFT JOIN Student_Courses AS sc ON c.c_id = sc.c_id
        WHERE
            sc.s_id = 4

This is the error I get
CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT c.course_name

FROM
Courses AS c
LEFT JOIN Student_Courses AS ' at line 3
Answer: DISTINCT is a keyword to be used immediately after SELECT (Have a look at the Mysql SELECT syntax). You cannot select columns distinctively, you rather do a SELECT DISTINCT query. What you possibly want is a GROUP BY. But then you need an aggregate function (to tell mysql what to do with the other columns - the ones you are not GROUPing BY.) Example using GROUP_CONCAT as aggregate function (Which just concatenates all columns in each group using a comma):
SELECT c.course_name, GROUP_CONCAT(sc.c_id),
FROM Courses AS c
LEFT JOIN Student_Courses AS sc ON c.c_id = sc.c_id
WHERE sc.s_id = 4
GROUP BY course_name

Answer: SELECT
        DISTINCT sc.c_id,
        c.course_name
FROM
        Courses AS c
LEFT JOIN Student_Courses AS sc ON c.c_id = sc.c_id
WHERE
        sc.s_id = 4

the DISTINCT keyword must be the first word after select because it will apply to the whole row.
It's as if you say :
SELECT DISTINCT(sc.c_id, c.course_name, ...) FROM ...

you can't say :
 SELECT sc.c_id, DISTINCT(c.course_name, ...) FROM ...


Bounding fundamental solution of the pell equation

Question: I am looking for the best known upperbound and lowerbound for $m$ in the equation          $m^2 - v(z^2) = 1$ such that $(m,z)$ is the fundamental solution of the pell's equation $x^2 -v(y^2) = 1$.
I.e is it true that the fundamental solution $(m,z)$ satisfies $m < v!$
Answer: The fundamental solution of Pell's equation $x^2-Dy^2=\pm1$ can be computed from the continued fraction of $\sqrt{D}$ (see Yang, Theorem 2.6, and Mathworld), that by Lagrange's theorem has the following form:
$$ \sqrt{D}=[a,\overline{c_1,c_2,\ldots,c_m,\ldots,c_2,c_1,2a}] \tag{1}$$
so that
$$ \frac{x}{y}=[a,c_1,c_2,\ldots,c_m,\ldots,c_2,c_1] \tag{2} $$
It follows that the size of the fundamental solution depends on the length $\ell$ of the period of the continued fraction of $\sqrt{D}$. Since $c_i\leq a\leq\sqrt{D}$, a bound that is not far from being sharp in many cases is $x\leq D^{\ell/2}$. $\ell$ depends on the class number of $\mathbb{Q}(\sqrt{D})$, hence
$$ x\leq D^{c\sqrt{D}} \tag{3}$$
for some explicit constant $c$ follows from Minkowski's bound. So we have that $x\leq D!$ holds for sure for any $D$ large enough.


Installing Windows Server AppFabric

Question: I'm trying to install Windows Server AppFabric using Web Platform Installer on my testing Windows Server 2008 Enterprise Edition. Although I have SQL Server (Developer Edition) installed on the server, WPI is still "insisting" that I need SQL Server Express, and I don't have option to change that.
The question is: how can I tell the setup that I already have SQL Server and don't need the Express Edition? The same goes when I go production; I'll have my SQL Server on separate server, so how can I tell AppFabric what SQL Server it need to connect to, as well as preventing SQL Server Express Edition from being installed.
P.S. I'm intending to use AppFabric for caching only and only on a single server; i.e. no WCF and WF fancy stuff or distributed cache.
Thanks
TheBlueSky
Answer: It may be that WPI isn't your best bet in this instance - you can download the standalone installer here. Also, although Web PI insists on installing SQL Sexpress, there's no requirement for you atually use it :-) - I have the same setup as you with SQL Server Developer installed, which is what I use for my AppFabric setup.
Once AppFabric is installed you can select a SQL Server to use when you run the configuration wizard:
Comment: +1. We had the same problem; this solution worked for us a while back.
Comment: I'll accept this answer as the limitation comes from PI and AppFabric setup is capable of handling my requirement.

Installing Windows Server AppFabric


Maximum number of linearly independent quadrics containing a curve in $\mathbb{P}^4$ not contained in a hyperplane?

Question: Consider everything over $\mathbb{C}$. My question is:
What is the maximal number $k$ of linearly independent homogeneous quadratic forms $Q_1,\dots,Q_k$ in $5$ variables such that the intersection $V(Q_1) \cap \dots \cap V(Q_k) \subseteq \mathbb{P}^4$ has a connected component that is positive dimensional and does not lie on a hyperplane?
I think the answer might be $k=6$; the example I have in mind is that $6$ linearly independent quadrics vanish on the quartic rational normal curve in $\mathbb{P^4}$.
The motivation for my guess comes from the analogous question in $\mathbb{P}^3$; we can ask for the maximal number $k$ of linearly independent homogeneous quadratic forms $Q_1,\dots,Q_k$ in $4$ variables such that the intersection $V(Q_1) \cap \dots \cap V(Q_k) \subseteq \mathbb{P}^3$ has a connected component that is positive dimensional and does not lie in a hyperplane. Here, one can show that the answer is $k=3$, and in fact any such connected component must be a twisted cubic curve.
Update: The only nondegenerate (irreducible and not lying on a hyperplane) surface in $\mathbb{P}^4$ lying on the intersection of $3$ quadrics is a cubic scroll, which contains a quartic rational curve. Perhaps we can use the fact that that if we have some linearly independent quadrics $Q_1,\dots,Q_k$ for $k \geq 6$ containing a nondegenerate curve in their intersection, then if the intersection $V(Q_1) \cap V(Q_2) \cap V(Q_3)$ is $2$-dimensional, it must be a cubic scroll?
Update: crossposted to this question on mathoverflow
Answer: The answer is indeed $k=6$; see Proposition 12.18 of Akhil Matthew's course notes for Joe Harris' algebraic curves course. I am still not sure whether the rational normal curve is the only extremal examples for curves!


Simple question about integration by substitution.

Question: Integration by substitution rule states, that if $\phi:[a,b] \rightarrow I$ and $f$ is continuous on $I$ then $$\int_{\phi(a)}^{\phi(b)}f(x)dx=\int_{a}^{b}f(\phi(t))\phi'(t)dt$$
But is it also true, that:
$$\int_{\phi(a)}^{\phi(b)}p(x)g(x)dx=\int_{a}^{b}p(\phi(t))g(\phi(t))\phi'(t)dt$$ where $p$ and $g$ are also continuous on $I$?
The proof in my opinion would be the same as here, but we would put $f(x)=p(x)g(x)$ and everything else would be the same. Am I breaking some rules here?
Comment: No you're correct.
Answer: You don't need to go through the same proof a second time.  You have that
$$
\int_{\phi(a)}^{\phi(b)}f(x)dx=\int_{a}^{b}f(\phi(t))\phi'(t)dt
$$
For any continuous $f$.  In other words, all that is required of $f$ is that it be a function, and that it is continuous.  So, in particular, let $f(x) = p(x)g(x)$ for all $x$.  This defines a function $f$, and $f$ is continuous because the product of continuous functions is continuous.  Therefore integration by substitution (above) applies, and we get directly that
$$
\int_{\phi(a)}^{\phi(b)}p(x)g(x)dx=\int_{a}^{b}p(\phi(t))g(\phi(t))\phi'(t)dt.
$$


Openldap problems with adding attribute

Question: I'm new to serverfault but I've alredy use google and serverfault searchs but cannot find answer to my problem. I need to add new attribute in ldap called permission and be able to set privilige levels.
Found several "ways to do" but non of them working. Stuck exacly like here add new attribute to ldap users and submit to ldap
Trying
dn: cn=core,cn=schema,cn=config
changetype: modify
add: olcAttributeTypes
olcAttributeTypes: <new value>

dn: cn=core,cn=schema,cn=config
changetype: modify
add: olcAttributeTypes
olcAttributeTypes: ( 22.214.171.124.5.6.7
 NAME ( 'test' 'test' )
 DESC 'test'
 SYNTAX 18.104.22.168.4.1.1422.214.171.124.3
 SINGLE-VALUE )

But in the best way I get
modifying entry "cn=core,cn=schema,cn=config"
ldap_modify: No such object (32)
    matched DN: cn=schema,cn=config

ldap_modify: Invalid syntax (21)
additional info: attributetypes: value #0 normalization failed

or
ldap_add: Undefined attribute type (17)
    additional info: add: attribute type undefined

And I'm out of ideas how to add this attribute :/
Since I must to do this I still trying (also create new server ) and getting following results
    dn: cn=config
    changetype: add
    olcAttributeTypes: ( 188.8.131.52 NAME 'permission'
    DESC 'RFC2256: For Supermicro user'
    SYNTAX 188.8.131.52.4.1.14188.8.131.52.15{255} )
ldap_add: Object class violation (65)
additional info: no objectClass attribute

So adding a objectClass
    ldap_add: Object class violation (65)
    additional info: object class 'person' requires attribute 'sn'
And now what ? Of course I want that permission be a part of person objectclass as MAY but still no idea how to modify objectclass
Result of
    ldapsearch -H ldap://ldap.ogicom.net -x -s base -b "" +
    base <> with scope baseObject
    # filter: (objectclass=*)
    # requesting: +
    dn:
    structuralObjectClass: OpenLDAProotDSE
    configContext: cn=config
    namingContexts: private
    supportedControl: 2.16.840.1.113722.214.171.124
    supportedControl: 2.16.840.1.113718.104.22.168
    supportedControl: 220.127.116.11.4.1.4184.108.40.206
    supportedControl: 188.8.131.52.1.22
    supportedControl: 1.2.840.1135220.127.116.119
    supportedControl: 1.2.822.214.171.12444810.2.3
    supportedControl: 220.127.116.11.1.13.2
    supportedControl: 18.104.22.168.1.13.1
    supportedControl: 22.214.171.124.1.12
    supportedExtension: 184.108.40.206.4.1.1466.20037
    supportedExtension: 184.108.40.206.4.1.418.104.22.168
    supportedExtension: 22.214.171.124.4.1.418.104.22.168
    supportedExtension: 184.108.40.206.1.8
    supportedFeatures: 22.214.171.124.1.14
    supportedFeatures: 220.127.116.11.4.1.422.214.171.124
    supportedFeatures: 184.108.40.206.4.1.418.104.22.168
    supportedFeatures: 18.104.22.168.4.1.4220.127.116.11
    supportedFeatures: 184.108.40.206.4.1.4220.127.116.11
    supportedFeatures: 220.127.116.11.4.1.422.214.171.124
    supportedLDAPVersion: 3
    supportedSASLMechanisms: DIGEST-MD5
    supportedSASLMechanisms: NTLM
    supportedSASLMechanisms: CRAM-MD5
    entryDN:
    subschemaSubentry: cn=Subschema
# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

Comment: Can you check is `core` schema exists:
`ldapsearch --hostname --port  --baseDN "cn=schema,cn=config"  --searchScope base "(objectclass=*)"` and post it?
Comment: @Slipeer After doing it I've got

    ldap_sasl_interactive_bind_s: Invalid credentials (49) additional info: SASL(-13): user not found: no secret in database
Comment: Of course it was necessary to execute a command with authorization `ldapsearch --hostname --port  -x -D  -W --baseDN "cn=schema,cn=config" --searchScope base "(objectclass=*)"`
Comment: Ehh my mistake - I did not think that user may be different that admin ;)
    # extended LDIF
    #
    # LDAPv3
    # base  with scope baseObject
    # filter: cn=schema,cn=config
    # requesting: (objectclass=*)
    #

# search result
search: 2
result: 34 Invalid DN syntax
text: invalid DN

# numResponses: 1
Comment: Strange result. Try other query: `ldapsearch -x -h   -b "" -s base \* +` note - the authorization is not needed. This request will give data about available baseDN.
Comment: # extended LDIF
    #
    # LDAPv3
    # base <> with scope baseObject
    # filter: (objectclass=*)
    # requesting: * +
    #

    #
   dn:
   objectClass: top
   objectClass: OpenLDAProotDSE
   structuralObjectClass: OpenLDAProotDSE
   configContext: cn=config
   namingContexts: dc=removed,dc=removed

   subschemaSubentry: cn=Subschema

Also additional question - how to greyed text? Maybe I misunderstanding help but it wrotes about 4 spaces to create an escaped   block but this dont work
Comment: Ehh and another mistake in cli - the correct result of your first command

# extended LDIF
#
# LDAPv3
# base  with scope baseObject
# filter: (objectclass=*)
# requesting: ALL
#

# search result
search: 2
result: 32 No such object
Comment: I edited the original post
Answer: Alright, let's clean things up a bit:

ldapmodify can both create and modify nodes within your LDAP tree. This behaviour is identified by the parameter changetype. So if you use changetype: add you try to add a new node. Obviously you would need to give that new node an object class, therefore you got the error
ldap_add: Object class violation (65) additional info: no objectClass attribute (still this operation would have been unsuccessful because the dn cn=config already exists).
You first of all need to find out, which node holds the object class (for example my node cn={0}core,cn=schema,cn=config holds the object class 'person', whereas 'inetOrgPerson' lies in cn={3}inetorgperson,cn=schema,cn=config). The curly brackets in front of the first dn attribute (in this case 'core' or 'inetorgperson') are set by OpenLDAP in order to determine the order in which the nodes are loaded. BTW: that's the reason why you received ldap_modify: No such object (32) when looking for cn=core,... - you missed the brackets :)
Object classes and attribute types are stored in nodes with the object class of olcSchemaConfig as attributes with the attribute type of olcObjectClasses or olcAttributeTypes respectively. Just look at your schemes (e.g. ldapsearch -xLLLWD cn=admin,cn=config -b cn=schema,cn=config -s one or ldapsearch -xLLLWD cn=admin,cn=config -b cn={0}core,cn=schema,cn=config -s base) and you get an idea what this looks like. So be clear what you want to do: You are trying to modify a node in the form that you replace one of the olcObjectClasses' attributes (in the form that you redefine it including your attribute type. If the attribute type has not been defined before, you would need to add it as another attribute of type olcAttributeTypes either in the same node or another olcSchemaConfig). You would do this with

dn: cn={0}core,cn=schema,cn=config
changetype: modify
replace: olcObjectClasses
olcObjectClasses: {4}( 126.96.36.199 NAME 'person'...
HOWEVER:
You don't want to do this. Seriously, don't. It is never a good idea to mess with the preexisting classes and attributes.
Instead, there are better options, which are way cleaner and should be chosen instead:

The quick way: When creating the next user node, you could use a structural object class (e.g. 'person') and add the auxiliary object class 'extensibleObject' to the mix; this let's you add attributes of any existing attribute type.
The right way: You can easily define your own object classes. What you would want to do in this way is either create your own structural class (which can inherit from any other object class and be extended by your attribute) which you would then use for your node as the only object class, or you could also create an auxiliary object class which holds the attribute and which would be used as an additional object class.
If you choose this way, please make sure that you use a namespace (the numbers in the definition, like '126.96.36.199') which will not conflict with the existing classes and/or attributes. This is what this would look like:

ldapadd -xWD cn=admin,cn=config
dn: cn=<schemaName>,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: <schemaName>
olcAttributeTypes: ( <your namespace>.01.01 NAME <attributeTypeName> DESC <description> EQUALITY <equalitySettings> SYNTAX <syntaxSettings> )
olcObjectClasses: ( <your namespace>.02.01 NAME <objectClassName> DESC <description> AUXILIARY MUST <attributeTypeName> )
Learning how to handle cn=config might be a little confusing at first, but once you understand the concepts behind it, you realize it is way cooler than the way it was before. It's definitely worth learning it.
Have fun!
Comment: If you want to learn the concepts, I suggest you check out Zytrax' guide at http://zytrax.com/books/ldap/
Comment: Thansk for instruction but still got the same error - DN not available H=4 and I don't know how to handle with this and without this attribute cannot login to Supermicro IPMI by ldap :/
Answer: Well it not my idea but I've got an aswer. I do it maunally
·         Edit config file,
$ vim /etc/ldap/schema/core.schema

·         Add attribute type,
attributetype ( 188.8.131.52 NAME 'permission'

        DESC 'my desc '

        SYNTAX 18.104.22.168.4.1.14188.8.131.52.15{255} )

·         add 'permission' to objectclass 'person'
objectclass ( 22.214.171.124 NAME 'person'

        DESC 'RFC2256: a person'

        SUP top STRUCTURAL

        MUST ( sn $ cn )

        MAY ( userPassword $ telephoneNumber $ seeAlso $ description $ permission ) )

·         Create core.conf file
$ vim /etc/ldap/core.conf

·         Add below line to core.conf
include /etc/ldap/schema/core.schema

·         Remove or backup old /etc/ldap/slapd.d/cn=config/cn=schema/cn={0}core.ldif file
$ rm /etc/ldap/slapd.d/cn=config/cn=schema/cn={0}core.ldif

·         Generate new /etc/ldap/slapd.d/cn=config/cn=sch
$ slaptest -f /etc/ldap/core.conf -F /etc/ldap/slapd.d

Openldap problems with adding attribute


Comparing a random sample and a non random sample extracted from a finite population

Question: I am not able to formulate a more descriptive title.
I have a population of five million people, I code it with R programming language:
pop <- 5e6

41% of them have brown eyes, 42% of them have green eyes.
brown <- ceiling(.41*pop)
green <- ceiling(.42*pop)
other <- pop-(brown+green)

Then I have 7000 people belonging to the population which test positive to a disease, obviously this is not a random sample taken from the population.
sample_size <- 7000

The percentage of eyes color for these 7000 people is the following: 38% have brown eyes, 44% have green eyes.
brown_in_sample <- ceiling(.38*sample_size)
green_in_sample <- ceiling(.44*sample_size)
other_in_sample <- sample_size-(brown_in_sample+green_in_sample)

Now a very naïve conclusion is that green eyed people are more prone to test positive to the disease because 38% is slightly less than 41% and 44% is slightly greater than 42%; that conclusion smells like meaningless to me because I feel that the proportions of brown eyes in the full population (41%) and in the positive-to-the-disease sample (38%) are too close and the same happens for the green eyes.
How can I get some convincing arguments to support my intuitions?
I have a vague idea that I have to use a multivariate hypergeometric distribution and compare the percentage of brown and green eyes found in a true random sample with the ones found in the positive-to-the-disease sample but I do not know how to proceed.
As an additional constraint, I would like to follow a Bayesian approach.
Answer: Let me first place here your data:
pop <- 5e6
brown <- ceiling(.41*pop)
green <- ceiling(.42*pop)
other <- pop-(brown+green)

sample_size <- 7000
brown_in_sample <- ceiling(.38*sample_size)
green_in_sample <- ceiling(.44*sample_size)
other_in_sample <- sample_size-(brown_in_sample+green_in_sample)

My first approach would be to use resampling. Let's select an appropriate statistic to check if its measured value for the real sample is significant or not. I choose the absolute value of the difference in the number of people with green and brown eyes (as a percentage of the sample size), that is,
stat <- function(pop1, pop2, sample_size) {
  abs( pop1 - pop2 ) / sample_size
}

What we should do now is to sample from the population, selecting new samples of the same size and then computing the same statistic. We will get lots of sample statistics that can be used to compare with the observed effect.
# brown=1, green=2, other=0
universe <- c( rep(1,brown),
               rep(2,green),
               rep(0,other))

n.sims <- 10000

replicate(n.sims, {
  sampling <- sample(universe, sample_size, rep=FALSE)
  n.browns <- length( sampling[sampling==1] )
  n.greens <- length( sampling[sampling==2] )
  stat(n.browns, n.greens, sample_size)
}) -> results

If you plot the results against the observed effect,
observed.effect <- stat(brown_in_sample, green_in_sample, sample_size)

The conclusion from this simulation is that there is strong evidence that the difference in your sample is significant.
This is the vizualization code I used,
compute.p.value <- function(results, observed.effect, precision=3) {
  # n = #experiences
  n <- length(results)
  # r = #replications at least as extreme as observed effect
  r <- sum(abs(results) >= observed.effect)
  # compute Monte Carlo p-value with correction (Davison & Hinkley, 1997)
  list(mc.p.value=round((r+1)/(n+1), precision), r=r, n=n)
}

present_results <- function(results, observed.effect, label="", breaks=50, precision=3) {
  lst <- compute.p.value(results, observed.effect, precision=precision)

  hist(results, breaks=breaks, prob=T, main=label, col = "dodgerblue",
       sub=paste0("MC p-value for H0: ", lst$mc.p.value),
       xlim=c(0,max(c(results,observed.effect))),
       xlab=paste("found", lst$r, "as extreme effects for", lst$n, "replications"))
  abline(v=observed.effect, lty=2, lwd=2, col="red")
}

present_results(results, observed.effect)

If you like a Bayesian approach, one possibility I see is using a model for a Binomial Test with two rates, testing for one eye color at a time. Something like,
$$k_i \sim \text{Binomial}(n_i, \theta_i) ~, ~ i=1\ldots m$$
$$\theta_i \sim \text{Beta}(1,1) ~, ~ i=1\ldots m$$
$$\delta_{ij} = \theta_i - \theta_j$$
herein, $m=2$.
Ie, we would like to compare if the difference of, say, brown eyes in the population and brown eyes in the sample, is significant.
The null hypothesis is $H_0 : \delta_{1,2} = 0$. If the credible interval for $\delta_{1,2}$ includes zero, we must retain the null, not reject it. If it does not include zero, we would reject it.
Here is a possible Stan model,
data {
  int<lower=2> m;     // at least two groups
  int<lower=1> n[m];
  int<lower=0> k[m];
}

parameters {
  real<lower=0,upper=1> theta[m];
}

model {
  theta ~ beta(1, 1);

  k ~ binomial(n, theta);
}

generated quantities {
  real delta[m,m];

  for ( i in 1:m ) {
     for ( j in 1:m ) {
        if (i==j)
           delta[i,j] = normal_lpdf(0|0,1); // dummy values
         else
           delta[i,j] = theta[i] - theta[j];
     }
  }
}

After the fit of this model with the brown eyes data, we get a 99% credible interval of $[0.016,0.044]$ which, given the large numbers we are dealing with, would mean a rejection of the null hypothesis despite being close to zero.
The code to perform the fit:
library(rstan)
library(rethinking)
library(latex2exp)

n <- c(pop, sample_size )       # runs
k <- c(brown, brown_in_sample ) # successes
m <- length(n)

# model1 is a string containing the Stan model above
fit1 <- sampling(model1,
                 data    = list(n=n, k=k, m=m),
                 iter    = 10000,
                 chains  = 2,
                 refresh = 0
)

precis(fit1, depth=3, prob=0.99)

Let's also plot the posterior of $\delta_{1,2}$
samples <- rstan::extract(fit1)

samples_theta <- samples$theta
samples_delta <- samples$delta

credible_interval <- PI(samples_delta[,1,2], prob=0.99)
h <- hist(samples_delta[,1,2], breaks=40, prob=T, yaxt='n',
          col=rgb(0,0,1,0.15), border=rgb(1,1,1,0.6), main="",
          xlab=TeX(paste0('$\\theta_',1,'-\\theta_',2,'$')), ylab="")

y.seg <- max(h$density) / 15
segments(credible_interval[1], y.seg, credible_interval[2], y.seg,
        lwd=5, col="dodgerblue")
text(credible_interval[1], y.seg*2.5, round(credible_interval[1],3),
    col="dodgerblue")
text(credible_interval[2], y.seg*2.5, round(credible_interval[2],3),
    col="dodgerblue")

Comment: Thank you very much! Since I am a very novice in Stan, could you please add the code to fit the model? Also, I would extend the x scale in the histogram in order to see the red line of the observed effect.
Comment: @AlessandroJacopson, Just added the remaining code you asked. Also, changed to a 99% credible interval just to show how strong is the available evidence.
Comment: Thank you very much! `sampling` with a string as first argument does not work in my environment. I had to change it to `sm <- stan_model(model_code = model1)` followed by `fit1 <- sampling(sm, data = list(n=n, k=k, m=m), iter = 10000, chains=2, refresh = 0)` where `model1` is a string containing the Stan model of your answer.


Limit of multivariable functions Do not understand solution.

Question: I have just started looking at limits at multivariable functions and the textbook have provided me with this:

Now I tried plotting the graph, which made it easier to see the limit.

However I am not able to see how this is solved. I first of all do not see where the inequality $x^2\leq x^2+y^2$ comes from. As far as Im aware this hold in any given case but is it usual to find such "constructed elements" second I do not see how they have used it in the equation below. Could someone please give a in dept explanation, this is very important that I understand this in depth. PS, studying. g this by myself so do not have a professor to ask!

I also wonder particularly in part ii) of definition what this actually mean ;$\delta =\delta (\epsilon )$. Cause on right hand side that to me is a function.
Comment: $x^2\le x^2+$ something nonnegative.
Comment: Yes thats what I meant by: as far as I'm aware that holds in any given case"
Answer: Yes, this kind of inequality is very commonly used. $x^2\leq x^2+1, x^2\leq x^2 + 2, \dots$. When you add something positive, you get a bigger number. So
$$\left|\frac{x^2y}{x^2+y^2}\right|\leq \left|\frac{x^2+y^2}{x^2+y^2}\right| |y|=|y|$$
Then $|y|=\sqrt{y^2}\leq \sqrt{x^2+y^2}$
where we used the same kind of inequality.
For the $\delta$-$\epsilon$ definition, you want your $f(x,y)$ to be within the distance $\epsilon$ of $L$, you have to define the distance of $(x,y)$ to $(a,b)$ to satisfy that. Usually the smaller $\epsilon$ is, the smaller $\delta$ should necessarily be, so that $f(x,y)$ is close enough to $L$. That is why this $\delta$ is dependent on $\epsilon$.
In your above example, the $\delta$ is chosen to be $\epsilon$ itself. But for example, if there was a $2$ in the numerator, you might want to choose $\delta$ to be $\frac{\epsilon}{2}$ to satisfy the condition $|f(x,y)-L| < \epsilon$.
Comment: Great thank you! Also Im going to update the question a bit. Cause I realise that Im missing something that is directly related to this question. Would you be able add a bit of extra information on top of what you already written in your answer?
Comment: I have updated it now.
Comment: @ALEXANDER: I have updated my answer.
Comment: @ALEXANDER: You are welcome! :) Please see the comment below by SantiagoCanez. I changed the answer a little according to his advice.
Comment: You are implicitly assuming that $x \ne 0$ when you use the inequality $1/(x^2+y^2) \le 1/x^2$, since otherwise the term on the right is undefined. This is fine as long as you also say what happens when $x=0$ separately. It would be better to use the given inequality to bound the numerator as: $|x^2||y| \le |x^2+y^2||y|$ to avoid this subtlety.
Comment: @SantiagoCanez: Thank you for pointing that out. I will edit my answer.


Manipulate Database from Drupal

Question: I'm new to Drupal 7. Right now I'm trying to use D7 to build an interface that allows me to directly manipulate the tables in the database.
I have installed a couple modules such as Data, Migrate, Feeds, and etc. I managed to create a view to display the table that I created using Data Module, but I need to add and update the rows from the interface.
Furthermore, is it possible to set up relational tables so that I can update or delete related rows at the same time using Drupal?
Thanks in advance
Yea, I just started learning Drupal, even new to the whole CMS thing. I decided to take the chance to learn Drupal for my project. But thanks all for the help I really appreciate the helps. I will come back and vote up the answers when I have enough rep.
Answer: Drupal isn't an MVC framework.
Content types and entities give you a way to insert records into a database, and edit them as well.
Making a "view" of one kind of record is possible with the Views module, and also the VBO module.
Deleting "related things" is trickier and requires the use of built-in hooks to remove related items from the database typically. Or if using Entities you could wire removing relationships into the Entity Controller.
Simply put, Drupal isn't a Ruby on Rails-like framework where you get CRUD capability for free; it currently acts more like the Linux kernel (in my opinion) where you register or "hook-into" the lifecycle of a thing and alter it to your needs.
You may find these 2 modules useful:

Model Entities uses Entities to kind of create a CRUD like interfaces for custom objects built with D7 Entity(s).
SBDO an ORM for custom object tables in drupal
Comment: Thanks alot, I appreciate it. So what would you recommend me to achieve my objective right now? Should I still use Drupal? I just started using it, and totally noob to RoR.
Comment: you can use drupal with content types, entities ... also the entity_reference module or the Relation module to do whatever you want ... my only point is that Drupal is more a CMS than a framework. You seem to be asking this question from an MVC point of view, "I have records and need to relate them" ... You need to evaluate Drupal and see if it can meet your needs in your timeframe.
Comment: @tenken +1 for the answer, but Drupal is definitely more of a framework than a CMS these days, it's just not based on MVC
Answer: The short answer is: yes, you can. I don't think you'll find a module that will provide a pointy clicky view of random tables and allow you to manipulate them. However, there are modules and frameworks that allow you to do just about anything you can imagine with your database. For example, OG provides a rich infrastructure for creating, modifying, deleting, and relating content.
For a more hands on approach, take a look at the Drupal 7 database abstraction layer documentation
http://api.drupal.org/api/drupal/includes%21database%21database.inc/group/database/7
Answer: I found a way to get create, modify, and delete working just using feeds, views, and content type.
I create a content type and added fields for the table I wanted. And then I used feeds to import the csv file mapping to the content type I created. Use views to create a display to display the table, and then add extra field (Content: Edit Link) to provide a link to edit specific node.
Haven't figured out how to relate multiple tables yet, in this case, relating fields of different content type. But I got most of the work done.
Hope this can help someone else who happens to have the same goal.

Manipulate Database from Drupal


This class inherits from a class marked as @immutable, and therefore should be immutable (all instance fields must be final)

Question: Getting the below issue, and not able to solve it, Can anyone help me in solving this.

This class inherits from a class marked as @immutable, and therefore should be immutable (all instance fields must be final). dart(must_be_immutable)

Thanks.
Comment: What prevents you from doing what the error suggests (changing `var` to `final`)?
Comment: Yes it does. You create a StatelessWidget and add a variable state. That's somewhat contradicting ;-)
Comment: What is the question here? Do you understand what the error message means? Is your question how to make your own class immutable?
Comment: The error suggests all the instance fields must be final @GünterZöchbauer
Answer: This issue occurs when all the class variables are not declared as final. You can either make them final or for ignoring this warning you can add the following comment above the class declaration:
//ignore: must_be_immutable

Comment: What's the consequence of creating mutable variables in a StatelessWidget? Will it just be a loss of efficiency or something worse?
Comment: but when using bloc pattern things are not just normal, we have builder that return different widget based on state. So immutable is just a warning.
Answer: All fields in a class extending StatelessWidget should be final.
From the documentations.

StatelessWidget class. A widget that does not require mutable state.

https://api.flutter.dev/flutter/widgets/StatelessWidget-class.html
Comment: I am getting the same warning for StatefulWidget.
Comment: @ASADHAMEED  non final variables can be in state class of your stateful widget not in widget class. Widget class must have final variables.
Answer: Make sure that all your instances variable in class are marked as final and the object is also marked as final.
In class
class Items {
  final String title;
  final String author;
  final String event;
  final String img;
  Items({this.title, this.author, this.event, this.img});
}

Inside widget that you in,
 final Items item2 = new Items(
    title: "Country",
    author: "Balaji",
    event: "4 Items",
    img: "assets/panda.png",
  );

Comment: What is the relation of `Items` to `Episode3`, of this post to the question?
Answer: Use That way
   class Frog extends StatelessWidget {
      const Frog({
      Key key,
      this.color = const Color(0xFF2DBD3A),
      this.child,
   }) : super(key: key);

  final Color color;
  final Widget child;

  @override
  Widget build(BuildContext context) {
    return Container(color: color, child: child);
  }
}

Comment: @Kobazzo Then you need another variable. And initial that final value to the new variable. Example- You get int value as final ( final int f)  from other screens. Get a new variable int n; Create a initstate() methord and initial  the final value f to n by using setstate()
Comment: If i need to make a variable final, how can i modify it? ad example i have an int variable that i need do increase or decrease, if it's is final i cannot do it.
Comment: @Abir Ahsan but that would throw an ext.flutter.inspector.getRootWidgetSummaryTree Error??
Answer: Maybe this will be helpful to someone else:
I am new to Flutter and I ran into this issue recently. I couldn't set my variables as final, though, because I needed to be able to change the values of the variables. I found out that in my case I needed to use a StatefulWidget instead of a StatelessWidget.
Comment: unless you need the state in the stateful widget there is no need to declare that widget as stateful, just use the linter ignore comment and you're good.
Answer: From flutter doc:

The following is a skeleton of a stateless widget subclass called GreenFrog.
  Normally, widgets have more constructor arguments, each of which corresponds to a final property.

Just like this
class IconContainer extends StatelessWidget {
final double size;
final Color color;
final IconData icon;
IconContainer(this.icon, {this.color=Colors.white, this.size=32});
Widget build(BuildContext context) {
 //TODO...
}

Answer: Any an immutable class add after it "final" to next line of flutter code, this will solve your problem,
For example:-
class Register extends statelesswidget {
static const string idScreen = 'register';
final TextEditingController name  = TextEditingController();
final TextEditingController email = TextEditingController();
}

Answer: In case that it is possible you can make your field static. This will also solve your issue.
A static field is independent of any class. As long as you don't try to pass it in the constructor and it is not private, it should be fine. If you must have a private field then, you can go with the accepted answer.
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Answer: Simply add this line top of the warning:
//ignore: must_be_immutable

Comment: This is not the solution.
Comment: @Arijeet If it compile with the warning, why have a warning in the first place? It's obvious that there are a lot of cases that class-members change during executing... Bad design of a programming language.
Answer: The problem is you cannot make the class immutable with out making all its properties 'final'. Sometimes we have to make a property not required and have to remove final. In this case your class never be immutable. You can simply ignore the warning. this will not harm your performance.
Answer: If the class you design requires a member that can change values after it construct (in build() or other method) for best practice design, I suggest using StatefulWidget instead. Because StatelessWidget has designed for @immutable, it not design for change value of member after create and not support initState() and dispose().
If you still resist and need to using StatelessWidget, you can add ignore to your code
// ignore: must_be_immutable

or ignore for whole file
// ignore_for_file: must_be_immutable

and change you class member value in class method(s) without warning,
or use final object to collect value instead. Yeah! no warning but not good design.
class IdotCare extends StatelessWidget {
    final Map _myData = {};

    IdotCare({super.key});

    void _todayText() {
        _myData['dynamic_value'] = 'Today is ${DateTime.now()}';
    }

    @override
    Widget build(BuildContext context) {
       _todayText();
       return Text(_myData['dynamic_value']);
    }
}

sorry for my bad english.


Ukulele friction pegs are slipping

Question: I have a soprano Favilla uke. About a month ago I replaced the original pegs, which were slipping, with Waverly's, recommended by a luthier. (To be clear, these are not "violin pegs"; rather, they are metal and pinch the top and bottom of the headstock for the friction to resist turning.) When I changed the pegs, I put on a new set of Aquila strings. I'm sure the strings have gone through their "stretching out" period by now.
I'm having trouble with the 2nd string (E). Sometimes when it's a tiny bit flat, I nudge it up - and when I let go it drops a half tone or more. I can see the peg turning.
I have cautiously tried tightening the screw, but I've heard it's easy to tighten it too much and cause some other sort of damage. To me it seems as if there's insufficient friction between the metal washers and the wood of the headstock. Any suggestions for how to solve this?
Answer: On a friction ukulele tuning peg, the standard solution to slipping of the peg  (not holding the tuning tension) is to tighten the screw at the end of the peg button.
Other things to check are to be sure your string has enough turns around the post so that the string itself is not slipping on the tuning post as well as a proper knot at the bridge to be sure the string is not slipping there.
I have discovered that when Waverly's are installed even by a luthier, they will slip if not installed properly using the proper countersink bit to modify the headstock for the way the Waverly's are designed.  They usually don't fit properly when replacing most vintage style pegs unless you have a 60-degree peghole chamfer.
Stewmac sells this Countersink for Waverly Ukulele Friction Pegs:
Countersink for Waverly Ukulele Friction Pegs
If the installation is not the issue, try tightening the screw a little at a time until you no longer experience the slippage problem.  If you find that you can't get it tight enough, it could be that the screw is "bottoming out" (reaching it's maximum capacity to tighten any further).  If that is the case, take the screw to a hardware store or hobby shop to try to get a shorter version of the same type screw or carefully cut just a tiny bit of the end of the screw off to shorten it.
Good luck.
Comment: Good list of things to try. It looks like I just need to tighten the screw a little more.
Answer: It would be a more expensive upgrade, but do you know about PegHeds? They are actual geared tuners (like a banjo or guitar tuner) that have the external appearance of traditional friction pegs. The PegHeds company website doesn't have a lot of detailed information, but your local musical instrument repair person may have information on PegHeds for ukulele. Some high-end ukulele manufacturers make PegHeds available as standard equipment on their instruments.
Comment: I do! I put a set of Gotohs, which also use planetary gearing, on my Martin 1T. Pegheds will be the next step for this soprano if I can't get the Waverlys to work.
Comment: I would guess that geared tuners on a soprano uke might tend to make them feel top heavy due to the weight of the gears in relation to the overall weight of such a small uke.  But there is no doubt that PegHeds or any good quality geared tuner would offer better tuning stability than most friction tuners.

Ukulele friction pegs are slipping


Function that takes a value and return a percentage

Question: I can't figure out how to create a function that takes as input a value between 0 and 180 and returns a percentage:
For a value 1 for example : 176 return 100%
For a value 2 for example : 86 return 0%
and return a big value of percentage if the value is near value 1 for example:  176
and return a small value of percentage if the value is near value 2 for example:  86
I created the image below to simplify my problem :
Image1
Edit 1 : The input of the function is always between 0 and 180.
Comment: You have not defined your function precisely enough to construct one.  How big is big?  How close is close?  Do you want a linear function from $176$ to $86$?  Can the argument of the function be outside the range?
Comment: Just a linear function, No the argument are always in the range
Answer: If the first value is $a$ and the second is $b$, you have
$$f(x)=\frac {x-b}{a-b}\cdot 100\%$$


Need help on divisors of the form $4n+1$.

Question: For the case of a number of the form $2^a\cdot 3^b\cdot5^c\cdot7^d,$ need to find the divisors of the form $4n+1$. Please vet my knowledge of the same::

Only the number of terms of $3,7$ matter when the sum of their powers is even, as the product of the residue classes of both leads to the needed
residue class, i.e.: $(4n-1)(4n'-1) = 4n''+1$.
Have a confusion here, as it is stated elsewhere that $2$ as a multiplier would not affect the roots. I am confused about it, particularly the residue class of $2$ is $4n+2$, and of $2^2$ is $4n+1$. So, is it the odd power of $2$ that does not affect, or is it the even power too.
For a small number as $2^2\cdot3\cdot7\cdot5 = 420$, it leads to divisors of the stated form as: $5, 21, 105$. However, the divisors possible are having the exponents values for sum of $a,b$ as even, i.e. both odd, or both even: (i) $a=1, b=1$ (ii) $a=0, b=0.$
For the latter case, the divisor can be $5$, as it is not divisible by $3,7$. While for divisor $21$, it does not matter to have $5$ as factor. For $105$, all three matter.
However, $2$ as occuring in pair is not visible in any of the divisors.
To check for an odd power of $2$, let us take another number $2\cdot3\cdot7\cdot5 = 210$, it leads to the same divisors as earlier, i.e.: $5, 21, 105$. How to explain this fact.
I also read elsewhere, that the number of divisors is a function of the power of $5$. Why?
Comment: If you multiply a number of the form $4n+1$ with $5$, you again get a number of the form $4n+1$. So, if you have the number of divisors of the form $4n+1$ which are not divisible by $5$, you have to multiply it with $e+1$ (where $e$ is the exponent in $5^e$) to get the total number of divisors of the form $4n+1$
Comment: @Peter Please elaborate it to make an answer. Seems interesting and useful.
Answer: Answer to the last part : Suppose, you have the number of divisors of $$2^a\cdot 3^b\cdot 7^d$$ which have the form $4k+1$ , denote if with $n$. The the number of divisors of $$2^a\cdot 3^b\cdot 5^c\cdot 7^d$$ of the form $4k+1$ is $(c+1)\cdot n$ because for every divisor $q$ of the form $4k+1$, the numbers $5q,25q,\cdots 5^c\cdot q$ are also divisors of the form $4k+1$, hence for each $q$ we have $c+1$ such divisors.
Comment: An even number cannot be of the form $4k+1$, hence we only need to consider the odd divisors.
Comment: $3^a\cdot 7^b$ is of the form $4k+1$ if and only if $a+b$ is even. This follows from $$3^a\cdot 7^b\equiv (-1)^a\cdot (-1)^b=(-1)^{a+b}\mod 4$$
Comment: The exponent of $2$ does not matter, as stated. Take the exponents of $3$ and $7$ (suppose, they are $a$ and $b$). List all pairs $(u/v)$ of non-negative integers such that $u+v$ is even and $u\le a$ and $v\le b$ holds. This gives the number of divisors of $3^a\cdot 7^b$ of the form $4k+1$.
Comment: @jitender There is no "counting issue". You can just multiply. Duplicates cannot occur.
Comment: So, you mean that (i) only $5$ matters?, why not an even power of $2$, it also leads to the needed form (ii) how is the impact of an even sum of the exponents of $3,7$.  Also, please vet: For $210=2\cdot3\cdot7\cdot5$, there need be 2 divisors with a power of $5 = \{5, 105\}$. For $1050= 2\cdot3\cdot7\cdot5^2$, there need be 3 divisors (of stated form) with a power of $5 = \{5, 105, 525\}$.
Comment: I am sorry but, this thing confuses me that even though can take an even number of powers of 2, still the analysis does not matter. So, it is okay, but then the issue is : when to multiply the residue classes. Do we need to do that only when check for even or odd factor first.
Comment: One last thing: In case the sum of exponents of $3,7$ are even, then the number of such possibilities should also lead to same analysis as the exponent of $5$. It is just that such divisors may not be mutually exclusive, and hence need a better combinatorial approach.