Using a KeyValuePair<> as Property vs. Separate Class vs. something else

Question: What is the proper way to show "Admin Tables" in my "Business Objects"?  I have the following on my Address object.
public class Address
{
    public int AddressID { get; set; }
    public KeyValuePair<short, string> County { get; set; }
    ...
}

Now how would I instantiate this object, as far as the KeyValuePair<,> properties go?
My guess is:
var myAddress = new Address { AddressID = 3, County = new KeyValuePair<short, string>(32, "La Crosse")}

EDIT
This is what I am replacing with the KeyValuePair<> on the recommendations of another Programmer.
.....Address.cs.....
public County County { get; set; }

.....County.cs.....
public class County
{
    public short? CountyID { get; set; }

    public string CountyName { get; set; }
}

Is there a better way between the two or a third way that is even better?
Comment: I would advise against using a `KeyValuePair` in this situation; a developer cannot clearly see what the `Key` or `Value` actually is (what is the `short` `Key` for `County`?. Make your own type which has appropriate property names to make life easier for yourself and colleagues.
Comment: Are the values for the KVP coming from a database?  Is it possible to extract them to an enumerated type so your magic numbers/characters are a bit less magical?
Comment: Your code works. So what is your problem?
Comment: I have removed irrelevant members. Please revert if you disagree.
Comment: @Lukazoid: Please see my edit and let me know if this makes more sense or if your statements still hold.
Comment: @Lukazoid or perhaps an enum, that is what the OP seems to be simulating with the KVP
Comment: @CodeInChaos: So my guess at the end is correct, that is how I would instantiate an object that has a `KeyValuePair<>` property?
Comment: Since it worked, it must be correct.
Comment: @RefractedPaladin That seems much better to me and should make the code a lot easier to understand for everyone.
Comment: @48klocs: I appologize but I would not know where to start with your suggestion as this is all pretty new to me.  As a guess; I would populate some enumerated types from the DB and then use that in my app?  Do this for all applicable Admin Tables I am guessing...
Comment: @BenRobinson An enum would be another solution, however enums are very static, whereas it seems the OP wants more dynamic data.
Comment: @Lukazoid: The way shown in my Edit you mean?  The separate object for County.
Comment: @RefractedPaladin Yes, the edit is what I mean, the separate object for `County` is probably the approach I would have gone for.
Comment: Sorry all for the confusion.  I guess my question really had a deeper question of KeyValuePair Property vs. Seperate Class for all my Admin types.  I apologize for the confusing nature this Question has taken on...
Comment: @RefractedPaladin as Lukazoid said, the approach you take is going to depend on where the values live - if they can change dynamically then you'll want to build up a list of valid counties/county IDs.  You'd want to convert that KVP to a type.  If it's defined in code and is static as of compile time, an enumeration type is a far simpler way to accomplish the same goal.
Answer: I just ran your code, and it worked as expected.
The country property has correct value Key = 32 and Value = La Crosse.

Your new code is ugly. I'd either remove the setter of the Country property, or make the Country class immutable. This kind of double mutability, is a bug waiting to happen.
Making the Country class immutable, is probably the right decision, since the Id=>Name mapping is fixed.
I'd use:
public class County
{
    public short? ID { get; private set; }
    public string Name { get; private set; }

    private Country(short? id,string name)
    {
      ID=id;
      Name=name;
    }
}

Comment: Then if the name of a `County` needed to be change? Which is a very likely possibility. It doesn't feel right to be creating a new `County`, when what is desired it to actually update an existing one. I'm interested in hearing what your approach would be to this.
Comment: Most of the time you don't need to change a country name at runtime, only once at load time. It's not like countries change there names all the time. But even if you do, the change should only happen from inside the Country class itself, and not through a place where a country is just used. For example by loading a new country definition file.
Answer: KeyValuePair<T1, T2> buys you nothing in this case.
Why not just be explicit?
public class Address
{
    public int AddressID { get; set; }
    public int CountyCode { get; set; }
    public string CountyName { get; set; }
}

or another version would be that you define a type County with the two properties, then have a property of that type instead.
In code, clarity is king.
Answer: Lukazoid gives a good hint why not to do this, bus in fact, the Initialization you are showing would work well. You could have proofen this rather easy using your Debugger. What is the question?
Answer: Create a Country object so it is clear what that short and string are supposed to represent.


Are bayesian methods inherently sequential?

Question: Ie, to do sequential analysis (you don't know ahead of time exactly how much data you will collect) with frequentist methods requires special care; you can't just collect data until the p-value gets sufficiently small or a confidence interval becomes sufficiently short.
But when doing Bayesian analysis, is this a concern? Can we freely do things like collect data until a credible interval becomes sufficiently small?
Comment: Depends. If you collect data until you have a certain amount of information that is generally not an issue, whether you are Bayesian or frequentist. If you care about frequentist operating characteristics (e.g. coverage probabilities for credible intervals, type 1 error), it is still an issue to stop e.g. once the credible interval excludes no effect.
Comment: Certain amount of information = e.g. Fisher information (e.g. for survival analysis up to a certain number of cases). For the second question: yes, if you use the likelihood reflecting how you sampled  (i.e. e.g. reflecting, in which cases you would have stopped collecting more data). No, if you ignore what the correct likelihood is (and e.g. just use a standard normal likelihood ).
Comment: @Björn Can you explain what "a certain amount of information" means in this context? And even if we don't get constant type 1 error rates with sequential bayesian testing, are we still "allowed" to? Can we still safely make the usual claims made in a Bayesian analysis? (ie, statements about the probability distribution of a parameter)
Comment: Ah, I see now, so the problem is really in the likelihood I guess. A stopping rule makes future observations conditionally dependent on prior ones.
Comment: @Bjorn Do you know of any reference for a Bayesian analysis that takes into account a stopping rule in its liklihood function?
Comment: Some of the references [here](http://stats.stackexchange.com/a/83970/17230) are relevant.
Answer: Rouder (2014) has a nice paper on this (written for psychologists), explaining why sequential testing (so-called data peeking) is fine from a Bayesian perspective. (Paper is freely available online if you do a search for it.)
Schoenbrodt et al. (in press) present nice analyses showing how to use sequential analysis with Bayes factors to determine when to stop data collection.
From a Bayesian parameter estimation procedure, John Kruschke has a very nice blog post that compares different Bayesian methods during sequential testing.
Hope you find them of help.
References
Rouder, Jeffrey N. (2014). Optional stopping: No problem for Bayesians. Psychonomic Bulletin & Review, 21, 301-308.
Schoenbrodt, F. D., Wagenmakers, E.-J., Zehetleitner, M., & Perugini, M. (in press). Sequential hypothesis testing with Bayes factors: Efficiently testing mean differences. Psychological Methods.
Comment: Could you summarize the papers instead of providing just the citations?
Answer: SPRT is good example of a frequentist method that is sequential.
On the other hand, while Bayesian models have priors to overcome sparsity of data, the more data you have the "narrower" your posterior distribution becomes making it less suitable for online temporal learning.


What is the limit of $v_n$?

Question: Let $x$ be nonnegative real number. The function $f_n$ is defined by:
$$
\begin{align}
f_n : &\mathbb{R}_{+}\mapsto\mathbb{R}\\
  &x\phantom{R}\mapsto 3x^ne^{-x^2}-1.
\end{align}
$$
Let $v_n$ be a real number for all $n>1$ such that :
$$
v_n >1,\;\text{and}\;f_n(v_n)=0.
$$
Calculate the limit of $v_n$, i.e., find $\ell$ that satisfies $\lim\limits_{n\to\infty}v_n=\ell.$
I tried to do it by contradiction. First, since $v_n>1$, then $\ell\geqslant1$.
Suppose that $\ell$ is not $\infty$. We have $3v_n^ne^{-v_n^2}=1\iff3v_n^n=e^{v_n^2}$.

If $\ell\neq1$:
$$3\ell^n=e^{\ell^2}$$
gives $$\infty=e^{\ell^2}$$
If $\ell=1$:
$$3\ell^n=e^{\ell^2}$$
gives $$3=e$$

So $$\ell=\infty$$.
Answer:
If $\ell\neq1$:
  $$3\ell^n=e^{\ell^2}$$

Sorry, but no. $\lim_{n\to\infty} g(n,n) = L$ does not imply that $\lim_{m\to\infty}g(n,m) = L$ or even $\lim_{n\to\infty}(\lim_{m\to\infty}g(n,m)) = L$, which is what you need for your conclusion. But it just doesn't hold in general.
And your demonstration that $1$ is not a solution assumes that $1^\infty = 1$, which is not in general the case.
I suggest using $v_n = 3^{-1/n} e^{v_n^2/n}$, from which you can show that if $v_n$ grows more slowly than $\sqrt n$ - more particularly that $\lim_{n\to\infty} v_n^2/n = 0$, then the limit converges to $1$.
But you still have to show that $v_n$ does indeed grow more slowly than $\sqrt n$.
Answer: I would do it from the definition of a limit being infinite.  First note that for all $n,\ f_n(1)=\frac 3e-1 \gt 0$ and as $x$ gets large $f_n(x) \to -1$, so there is a root in $(1,\infty)$, which is $v_n$.  Also note that for a given $x \gt 1$, $f_n(x)$ is increasing with $n$.  Then convince yourself that there is only one such root by noting $f_n'(1) \gt 0$ and there is only one place where $f'_n(x)=0$, so each $f_n$ rises to a maximum and then falls, crossing the axis, and approaches $-1$.  Now note that given a value for $x$, you can always find an $n$ large enough so that $f_n(x) \gt 0$ by solving $x^n=e^{x^2}, n=\frac {x^2}{\log x}$.  Thus given $x$, you can find $N$ so that for all $n \gt N, v_n \gt x$, so $v_n \to \infty$ with $n$

What is the limit of $v_n$?


User cannot save changes to HTML Formatted e-mails in Public Folder

Question: I'm transitioning people in our office to "new" (refurb) machines running Win7 from their current WinXP machines. The only user that has gotten hers so far is having an issue where she is unable to save changes to e-mails in Public Folders through Outlook 2003 that are from external users (i.e. a client) in the state they were received (HTML; we rarely receive Plain Text e-mails from our clients, so I haven't tested her ability to save changes to those.)
To clarify, she can view the e-mail, go to edit it using Edit Message, and make changes, but hitting Save/Ctrl+S doesn't retain the changes nor does it prompt her to save changes if she closes the e-mail without hitting Save/Ctrl+S.
However, I've found that if she does the following steps she can save changes:

Open e-mail and go to Edit Message
Change the Format to Plain Text
Save and close the e-mail

if she doesn't save, she will be prompted to do so at this point

Re-open the e-mail and go to Edit Message again

She appears to retain her ability to edit it if she changes the Format back to HTML.
She is able to make changes using an instance of Outlook 2003 through Citrix without jumping through these hoops, and on her previous workstation she was using Office 2010 and had no problems (we don't have enough licenses to give everyone 2010 and I'm concerned this will affect the others as they receive theirs, so just getting her back to Office 2010 is not a desired solution.)
Office 2003 SP3 is installed and Windows Update finds nothing for it, nor can I find anyone else reporting this problem online.
EDIT: I should add that she was upgraded to 2010 because, when she had 2003 on her old desktop, some e-mails in public folders would consistently appear blank after we upgraded Exchange from 2003 to 2010 (part of going to SBS 2011). I don't believe this problem is related, but I thought I'd mention it. Two others had the same issue and were also upgraded to 2010. However, the remainder of our office (8 other people) had no issue continuing with 2003.
I also just confirmed that the second person to switch, who got hers about a half hour ago, is having the same issue.
EDIT 2: I forgot to mention: She can update the Subject and Importance (it will ask her to save if she doesn't do so explicitly) of these e-mails. So I don't believe this is any kind of permissions issue, rather something with the Outlook editor (I've already unchecked the Use Word for Editing settings.)
UPDATE (3/21): After restoring the factory image and installing nothing but Office, I am able to edit the e-mails just fine. I am now slowly installing updates, other applications, and making various customizations, testing after each installation (or batch of updates.) If I figure out what is interfering (which would be nice, so I can just uninstall/remove it from the other systems that were ready for deployment) I'll post the answer.
UPDATE (3/25): It continued to work fine through other setup steps, but right before I was about to deploy the image it did a huge batch of Windows updates (only after I left the domain, so I'll have to look at our SBS setup to see why it wasn't passing those updates...). 100ish in total. Once that happened, the problem returned. I am now looking through each update to find ones that might be related and will try uninstalling those one by one until it works again. For reference, of those updates the most recent was KB2930275 and least recent was KB2670838. (There was also IE11, English Spelling Package, and English Hyphenation Package.) Hopefully I can find a single update that causes the issue and post that.
Answer: Uninstalling Internet Explorer 11 fixed the issue. After removing a host of other updates, I jumped the gun and uninstalled that and was able to edit these HTML emails just fine.
I found a number of other complaints about IE11 causing Outlook 2003 to send saved drafts instead of completed e-mails (if the final e-mail hadn't been saved), resulting in e-mails that look like they were truncated. In every case removing IE11 was the answer; I found some that suggested checking the Use Microsoft Office Word 2003 to edit e-mail messages option under Tools->Options->E-mail Format, but I didn't see anyone that reported their issue fixed by this.
I'm going to reinstall IE11 and see if I can't fiddle with settings in either Outlook or IE11 to break this connection; I think Outlook 2003 might treat e-mails moved into public folders as some sort of draft, which would be why it was discarding any changes while AutoSave is enabled (which I believe is the default.) While it's no problem using IE10 and disabling the auto-update, at some point someone will push for getting IE11, and I don't want to deal with this problem again when that day comes
If I find a way to make it work with IE11, I'll update this post. (Though I don't know if it would fix the issue with truncated e-mails being sent.)
EDIT: I tried a few different settings in Outlook (in particular, turning off autodraft and toggling Word as editor) and checking settings in IE11 but couldn't break the connection. I need to move forward and can't spare anymore time on this, so I just uninstalled IE11 and set IE10 to not auto-update. Hopefully this is fixed in a future update to IE11 so we won't have to worry about upgrading.


I can't add links to any of my menu

Question: I can't add links to any of my menus.
I go to the menu, click on add link, and fill all the required data; I get the message, "Your configuration has been saved." It doesn't seem it is what it is done.

All modules and core are updated to the last versions.
Comment: Did you try clearing the cache just in case?
Comment: Fixed. Problem was that path contained a 20% instead of the `space`.
Answer: I fixed it. The problem was that the path contained "20%" instead of a space.
Comment: can you please describe the path contained "20%" instead of space, as i have the same issue
Answer: I encountered something similar, but in my case I hadn't noticed that I had unchecked the 'published' checkbox, so eventually ended up with about a dozen duplicate links after retrying!
Answer: If you do want to be able to provide a menu link to unpublished content there's a module for that - http://drupal.org/project/menu_view_unpublished

I can't add links to any of my menu


Why can't I upgrade compose_version from compose_version = '1.1.0-beta01' to 1.2.1?

Question: I create an project based the wizard Empty Compose Activity of Android Studio Chipmunk | 2021.2.1 Patch 1.  It can be compiled, and it works well.
I get the following running error after I upgrade compose_version from compose_version = '1.1.0-beta01' to 1.2.1.
Could not resolve all files for configuration ':app:kotlin-extension'.
   > Could not find androidx.compose.compiler:compiler:1.2.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/androidx/compose/compiler/compiler/1.2.1/compiler-1.2.1.pom
       - https://repo.maven.apache.org/maven2/androidx/compose/compiler/compiler/1.2.1/compiler-1.2.1.pom

But the app can run well when I remove kotlinCompilerExtensionVersion compose_version in build.gradle (Module), why?
build.gradle (Project)
buildscript {
    ext {
        compose_version = '1.1.0-beta01'  //I will upgrade it to 1.2.1
    }
}
plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}

build.gradle (Module)
plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdk 25
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    composeOptions {
        kotlinCompilerExtensionVersion compose_version //OK after I removed it
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }

    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}

Answer: The problem is that there is no Compose Compiler 1.2.1 version. Currently, Compose Compiler follows a different release schedule than other Compose libraries.
Here is the compatibility map and the available versions of Compose Compiler to use together with Kotlin.
In case you're wondering about using different versions between Compose Compiler and the other Compose libraries, it's totally ok to do that, and that's what you should do to have access to the latest versions of them.
You can configure your gradle as follows:
Project module
buildscript {
    ext {
        kotlinVer = '1.7.10'
        composeCompilerVer = '1.3.1' // should be compatible with kotlin version
        composeVer = '1.2.1'
    }
}

plugins {
    id 'com.android.application' version '7.2.2' apply false
    id 'com.android.library' version '7.2.2' apply false
    id 'org.jetbrains.kotlin.android' version "$kotlinVer" apply false
    // ...
}

App module
// ...

android {
    // ...

    composeOptions {
        kotlinCompilerExtensionVersion composeCompilerVer
    }

    // ...
}

dependencies {
    implementation "androidx.compose.ui:ui:$composeVer"
    implementation "androidx.compose.ui:ui-tooling-preview:$composeVer"
    // ...
}

Comment: Thanks!  Do you mean the code generated by android studio automatically is not good? I should to set two paramters  `composeCompilerVer` and `composeVer`, right?
Comment: Yes, the default build uses the same version for Compose Compiler and others Compose library, but since Compiler now follow a different release schedule you should make some changes to uses the latest version from each one (including the Kotlin version, because it needs to be compatible with the Compose Compiler)
Answer: The version androidx.compose.compiler:compiler:1.2.1 doesn't exist.
You can check it in the google maven repo
You can in any case use the stable version of the module compiler 1.3.0 and all the other compose dependencies at 1.2.1:
buildscript {
    ext {
        compose_compiler = '1.3.0'
        compose_version = '1.2.1'
    }
    //...
}

and then:
composeOptions {
    kotlinCompilerExtensionVersion compose_compiler
}

dependencies {
   // stable 1.2.1 releases
   implementation "androidx.compose.material:material:$compose_version"
   //...
}

As described in the documentation the compiler 1.3.0 requires kotlin 1.7.10:
Comment: Thanks!  Do you mean the code generated by android studio automatically is not good? I should to set two paramters  `composeCompilerVer` and `composeVer`, right?
Comment: @HelloCW Yes. the compiler has different releases


Probability density function with the help of the Laplace (Fourier) transform

Question: I am reading a paper that derives a closed form expression of the following probability using properties from Fourier transform,
$$ \mathbb{P} \biggl( F \geq T \ (I+W) \biggl)$$
Assumptions:
1- Assume that the $F$ has a finite first moment and admits a square integrable density $f(y)$.
2- $I$ and $W$ are independent and either one admits a density which is square integrable.
3- $I+W$ admits a density $g(t)$.
4- $T$ is a constant
The proof is presented next,
Proof
$$\begin{align}
\mathbb{P} \biggl( F \geq T(I+W) \biggl)&= \int_{0}^{\infty} f(y) \  \mathbb{P} \biggl(I+W<y/T \biggl)\\
&= \int_{0}^{+\infty} f(y) \ \int_{-\infty}^{+\infty} g(t) \ 1(0<t<y/T) dt \\
&\stackrel{?}{=} \int_{0}^{+\infty} f(y)\int_{-\infty}^{+\infty} \mathcal{L}_{I}(-2 i \pi s)\mathcal{L}_{W}(-2i\pi s)\times \frac{e^{2i\pi ys/T }-1}{2i\pi s} ds dy\\
&\stackrel{?}{=} \int_{0}^{+\infty} f(y)\int_{-\infty}^{+\infty} \mathcal{L}_{I}(-2 i \pi s T)\mathcal{L}_{W}(-2i\pi sT)\times \frac{e^{2i\pi ys }-1}{2i\pi s} ds dy\\
&\stackrel{?}{=}\int_{-\infty}^{+\infty} \mathcal{L}_{I}(2 i \pi s T)\mathcal{L}_{W}(2i\pi sT)\times \frac{\mathcal{L_F}(-2i\pi s )-1}{2i\pi s} ds
\end{align}$$
where the notation $\mathcal{L}_{I}(.),\mathcal{L}_{W}(.), \mathcal{L}_{F}(.)$ represent the Laplace transform of $I,W$ and $F$.
Questions
My questions are regarding the last three steps marked with (?).
I understand that there is a convolution step for the probability density function $I+W$ which becomes in the frequency domain multiplication between two transforms, however I don't understand how the authors arrive to the argument of the Laplace that is $-2 i \pi s$.
The authors claim that this can be done using Plancherel-Parseval theroem. I have added the theorem below
$$\int_{\mathbb{R}} f(t)\ g(t) \ dt = \int_{\mathbb{R}}\hat{f}(s)\ \overline{\hat{g}(s)} \ ds $$
where for all functions $f,g$ from $\mathbb{R}$ to $\mathbb{R}$, the Fourier of Transform at $s\in \mathbb{R}$ when it exists is given by  $$\hat{f}(s)= \int_{\mathbb{R}}e^{-2i\pi t s} f(t) \ dt $$
$$\hat{g}(s)= \int_{\mathbb{R}}e^{-2i\pi t s} g(t) \ dt $$
and $ \ \overline{\hat{g}(s)}$ denotes the complex conjugate of $\hat{g}(s)$.
Many thanks
Answer: First, it seems to me that the densities of $I,W$ are only supported
on $\left[0,\infty\right)$, otherwise I don't see how the derivation
can be true. Hence, I will assume this in the following.
Then, let us denote the densities of $I,W$ by $g_{I},g_{W}$, respectively.
This implies
$$
\overline{\widehat{g_{I}}\left(\xi\right)}=\overline{\int_{-\infty}^{\infty}g_{I}\left(x\right)\cdot e^{-2\pi ix\xi}\,{\rm d}x}=\int_{0}^{\infty}g_{I}\left(x\right)\cdot e^{2\pi ix\xi}\,{\rm d}x=\mathcal{L}_{I}\left(-2\pi i\xi\right).
$$
An analogous formula holds for $\mathcal{L}_{W}$.
Now note that
\begin{eqnarray*}
\left(\mathcal{F}1_{0<t<y/T}\right)\left(\xi\right) & = & \int_{0}^{y/T}e^{-2\pi it\xi}\,{\rm d}t\\
 & = & \frac{e^{-2\pi it\xi}}{-2\pi i\xi}\bigg|_{t=0}^{y/T}\\
 & = & \frac{e^{-2\pi iy\xi/T}-1}{-2\pi i\xi}
\end{eqnarray*}
Finally, $g=g_{I}\ast g_{W}$ (because $I,W$ are independent), so
that $\mathcal{F}g=\widehat{g_{I}}\cdot\widehat{g_{W}}$ (by the convolution theorem).
As $g_{I},g_{W}$
are square integrable, so are the Fourier transforms $\widehat{g_{I}},\widehat{g_{W}}$
(by Plancherel's theorem). But densities are always integrable, so
that $\widehat{g_{I}},\widehat{g_{W}}\in C_{0}\left(\mathbb{R}\right)$.
Hence $\widehat{g_{I}}\cdot\widehat{g_{W}}\in L^{1}\left(\mathbb{R}^{d}\right)\cap L^{\infty}\left(\mathbb{R}^{d}\right)\subset L^{p}\left(\mathbb{R}^{d}\right)$
for all $p\in\left[1,\infty\right]$. Furthermore, $1_{0<t<y/T} \in L^2$, so that the same is true of its Fourier transform.
Now Plancherel (Parseval if you want) implies
\begin{eqnarray*}
 &  & \int_{-\infty}^{\infty}\mathcal{L}_{I}\left(-2\pi is\right)\cdot\mathcal{L}_{W}\left(-2\pi is\right)\cdot\frac{e^{-2\pi iys/T}-1}{-2\pi is}\,{\rm d}s\\
 & = & \int_{-\infty}^{\infty}\overline{\widehat{g_{I}}\left(s\right)\cdot\widehat{g_{W}}\left(s\right)}\cdot\left(\mathcal{F}1_{0<t<y/T}\right)\left(s\right)\,{\rm d}s\\
 & = & \int_{-\infty}^{\infty}\overline{\widehat{g}\left(s\right)}\cdot\widehat{1_{0<t<y/T}}\left(s\right)\,{\rm d}s\\
 & \overset{\text{Plancherel}}{=} & \int_{-\infty}^{\infty}\overline{g\left(t\right)}\cdot1_{0<t<y/T}\,{\rm d}t\\
 & = & \int_{-\infty}^{\infty}g\left(t\right)\cdot1_{0<t<y/T}\,{\rm d}t.
\end{eqnarray*}
In the first integral, we can now make the substitution $\omega=s/T$
(with ${\rm d}s=T\cdot{\rm d}\omega$), which yields
\begin{eqnarray*}
 &  & \int_{-\infty}^{\infty}g\left(t\right)\cdot1_{0<t<y/T}\,{\rm d}t\\
 & = & \int_{-\infty}^{\infty}\mathcal{L}_{I}\left(-2\pi is\right)\cdot\mathcal{L}_{W}\left(-2\pi is\right)\cdot\frac{e^{-2\pi iys/T}-1}{-2\pi is}\,{\rm d}s\\
 & = & \int_{-\infty}^{\infty}\mathcal{L}_{I}\left(-2\pi i\omega T\right)\mathcal{L}_{W}\left(-2\pi i\omega T\right)\cdot\frac{e^{-2\pi i\omega y}-1}{-2\pi i\omega T}\, T\cdot{\rm d}\omega\\
 & = & \int_{-\infty}^{\infty}\mathcal{L}_{I}\left(-2\pi i\omega T\right)\mathcal{L}_{W}\left(-2\pi i\omega T\right)\cdot\frac{e^{-2\pi i\omega y}-1}{-2\pi i\omega}\,{\rm d}\omega.
\end{eqnarray*}
If we finally integrate this against $f\left(y\right)$ and use Fubini's
theorem, we arrive at
\begin{eqnarray*}
 &  & \int_{0}^{\infty}f\left(y\right)\cdot\int_{-\infty}^{\infty}g\left(t\right)\cdot1_{0<t<y/T}\,{\rm d}t\\
 & = & \int_{0}^{\infty}f\left(y\right)\cdot\int_{-\infty}^{\infty}\mathcal{L}_{I}\left(-2\pi i\omega T\right)\mathcal{L}_{W}\left(-2\pi i\omega T\right)\cdot\frac{e^{-2\pi i\omega y}-1}{-2\pi i\omega}\,{\rm d}\omega\,{\rm d}y\\
 & = & \int_{-\infty}^{\infty}\mathcal{L}_{I}\left(-2\pi i\omega T\right)\mathcal{L}_{W}\left(-2\pi i\omega T\right)\int_{0}^{\infty}f\left(y\right)\cdot\frac{e^{-2\pi i\omega y}-1}{-2\pi i\omega}\,{\rm d}y\,{\rm d}\omega\\
 & \overset{\left(\ast\right)}{=} & \int_{-\infty}^{\infty}\mathcal{L}_{I}\left(-2\pi i\omega T\right)\mathcal{L}_{W}\left(-2\pi i\omega T\right)\left[\frac{1}{-2\pi i\omega}\underbrace{\int_{0}^{\infty}f\left(y\right)\cdot e^{-2\pi i\omega y}\,{\rm d}y}_{=\mathcal{L}_{F}\left(2\pi i\omega\right)}+\frac{1}{2\pi i\omega}\right]\,{\rm d}\omega\\
 & = & \int_{-\infty}^{\infty}\mathcal{L}_{I}\left(-2\pi i\omega T\right)\mathcal{L}_{W}\left(-2\pi i\omega T\right)\left[\frac{\mathcal{L}_{F}\left(2\pi i\omega\right)-1}{-2\pi i\omega}\right]\,{\rm d}\omega\\
 & \overset{\gamma=-\omega}{=} & \int_{-\infty}^{\infty}\mathcal{L}_{I}\left(2\pi i\gamma T\right)\mathcal{L}_{W}\left(2\pi i\gamma T\right)\left[\frac{\mathcal{L}_{F}\left(-2\pi i\gamma\right)-1}{2\pi i\gamma}\right]\,{\rm d}\gamma.
\end{eqnarray*}
At $\left(\ast\right)$, we used the fact that $f$ is a density on
$\left(0,\infty\right)$, so that
$$
\int_{0}^{\infty}\frac{f\left(y\right)}{2\pi i\omega}\,{\rm d}y=\frac{1}{2\pi i\omega}.
$$
Hence, the final result is true. I can not completely reproduce the
exact intermediate steps that you posted (I don't completely get the step at the first "?"). But the arguments used in my derivation are essentially the same that are used to justify the last two "?" and the first "?" is similar to what I did above with Plancherel's theorem. I hope this helps :)
Comment: Thanks for this detailed explanation it actually helps alot :). Going back to my question and specifically the first (?) I have there, it looks to me as if they took the conjugate of both functions in this integral $\int_{-\infty}^{\infty} g(t) 1_{0<t<y/T}$, because they have $\frac{e^{+ 2j\pi y/Ts}-1}{2j\pi s}$ instead of $\frac{ e^{- 2j\pi y/Ts}-1}{- 2j\pi s}$ do you think the paper has a typo?
Comment: Yes, I think it is a typo. But I will think about that more closely this evening or tomorrow.
Comment: Hi @PhoemueX I was wondering if I can ask you one more question regarding your analysis above. The question is, are $\xi \in \mathbb{R}^+$ in your notation or is it complex?
Comment: Above, I always have $\xi \in \Bbb{R}$. Otherwise, you will (for example) only have $\overline{e^{2\pi i x \xi}}= e^{-2\pi i x \overline{\xi}}$ instead of $e^{-2\pi i x \xi}$.
Comment: Thanks for responding, so in general the integrand of this integral  $\int_{-\infty}^{+\infty} \mathcal{L}_{I}(2 i \pi s T)\mathcal{L}_{W}(2i\pi sT)\times \frac{\mathcal{L_F}(-2i\pi s )-1}{2i\pi s} ds $ is complex, (given that $s \in \mathbb{R}$), do you happen to know why the result of the integral is real in the end ( since its a probability afterall)?
Comment: The "reason" is the last **big** calculation in my proof, which shows that this integral is equal to $\int_0^\infty f(y) \int_{-\infty}^\infty g(t) 1_{0<t<y/T} \, dt \, dy$, which is real. But this is not (at all) an intuitive reason. One additional "reason" could be that $\int \widehat{f} (\xi) \cdot \widehat{g}(\xi) \cdot e^{2\pi i x \xi} \, d\xi = \mathcal{F}^{-1}(\widehat{f} \cdot \widehat{g}) = f \ast g$ using the **convolution theorem** and Fourier inversion. Here, I have written $\widehat{f}$ for the Fourier transform of $f$, which is closelsy related to the Laplace transform.
Comment: I understand the reasoning thank you very much
Comment: One last question, assume $I,W=0$ then we have $\mathbb{P}(F\geq 0)$, do you think one case say that $\int_{-\infty}^{+\infty} \frac{\mathcal{L}(- 2\pi i s )-1}{2\pi i s}ds$ is exactly:  1- the CDF of $ F $ ? where CDF stands for the cumulative density function. @PhoemueX
Comment: Sorry I think I have bothered you :). In any case your answers helped me alot. @Phoemuex


Accessing scope within directive

Question: I have a controller which is charge of getting event json data and if there is data, update the dom with data, else update dom with error message:
<code>//Controller.js
myApp.controller('EventsCtrl', ['$scope','API', function ($scope, api) {
    var events = api.getEvents(); //events: {data: [], error: {message: 'Some message'}}
}]);

//Directives.js
myApp.directive('notification', function () {
    return {
        restrict: 'A',
        link: notificationLink
    };
});
/**
 * Creates notification with given message
 */
var notificationLink = function($scope, element, attrs) {
    $scope.$watch('notification', function(message) {
        element.children('#message').text(message);
        element.slideDown('slow');
        element.children('.close').bind('click', function(e) {
            e.preventDefault();
            element.slideUp('slow', function () {
                element.children('#message').empty();
            });
       });
    });
};
//Services.js
...
$http.get(rest.getEventsUrl()).success(function (data) {
        // Do something with data
    }).error(function (data) {
        $window.notification = data;
    });
</code>
Issue is that the element changes are triggered but $window.notification has nothing in it.
Edit: Attempted to try with $watch.
Edit: After moving both sets of html to one controller, the DOM manipulation works with $watch(). Thanks to both you of you for your help!
Comment: empty isolated scope in directive is one issue...get rid of it, other is that AJAX is asynchronous so `if(events.data)` will always be false...use $http callbacks to set the data
Comment: So I took out the isolated scope in the directive, and the $http callback for error currently is just setting the return value to a variable.So do I need to be able to call the directive to trigger the dom changes?
Comment: `getEvents()` will return promise, assuming is using `$http`.....try wrap `if(events.data` in `.then()`. Show the `getEvents()` code
Comment: I edited the above to try it with a $watch. Is that the direction I want to head? I just want to trigger the dom manipluation when the error occurs in the $http call.
Comment: might work...except is watching for scope property   wouold need `$scope.notification =$window.notification` the way you have it
Comment: Well I found out that I can't pass $scope in the service unless I'm not setting it up right.
Comment: right... put the `notication=$window.notification` in scope
Answer: Try setting the result of your http request to a scope variable in your controller. Then watch that variable in your directive.
<code>myApp.controller('EventsCtrl', ['$scope', 'API',
    function ($scope, api) {
        $scope.events = api.getEvents(); //events: {data: [], error: {message: 'Some message'}}
    }
]);

//Directives.js
myApp.directive('notification', function () {
    return {
        restrict: 'A',
        link: notificationLink
    };
});

var notificationLink = function (scope, element, attrs) {
    scope.$watch('events', function (newValue, oldValue) {
        if (newValue !== oldValue) {
            if (scope.events.data.length) {
                //Display Data
            } else {
                //Display Error
            }
        }
    });
};
</code>
Comment: This would work except the scope for the notification should be global and the events should be only for the event controller.

Accessing scope within directive


Controlo de cache para um ficheiro especifico

Question: Se pretendemos implementar um controlo de cache para um tipo de ficheiros em particular, através do htaccess podemos proceder da seguinte forma:
<IfModule mod_expires.c>
    ExpiresActive on
    ExpiresDefault "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 year"
</IfModule>

Mas isto é uma solução para todos os ficheiros de determinado tipo, no exemplo em cima, para ficheiros de JavaScript.
Pergunta
Como aplicar controlo de cache para um ficheiro especifico, por exemplo: script.js ?
Answer: Analisando a documentação do mod_expires parece não ser possível diferenciar arquivos a não ser pelo tipo.
Alternativas que consigo pensar são:

Usar uma extensão diferente de js para o arquivo específico e associá-la a outro mime type que dê o mesmo resultado.
Aplicar diferentes configurações de expiração para diferentes diretórios.

Exemplo do item #2 (fonte):
<Directory /var/www/js/expire_fast>
  <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/javascript "access plus 60 minutes"
  </IfModule>
</Directory>


Check the existence of partial derivatives and continuity of $f(x,y)$ at $(1,0)$ : $f(x,y) = \frac{3y(x-1)} {{({x-1})^2} +y^2}$

Question: Check the existence of partial derivatives and continuity of $f(x,y)$ at $(1,0)$ : $f(x,y) = \frac{3y(x-1)} {{({x-1})^2} +y^2}$ when $(x,y)\neq (1,0)$ and $0$ otherwise. I decided to check continuity first - I calculated limit by considering different paths of approach and I got $0$ in all cases (confirmed continuity). I checked that in Wolfram and found out that limit shouldn't exist. Where have I done mistake and how to check the existence of partial derivatives?
Comment: Showing us the calculation you did can help.
Comment: To prove that a function is continuous, you can't just show that it is continuous along *some* paths.  Rather, you would have to show that it is continuous along *all* paths.  Usually, one does not show continuity in this manner–working along paths is typically more useful for showing that something is **not** continuous.  That being said, this function is not continuous at $(1,0)$.  You might consider lines of slope $\pm 1$ through that point.
Answer: Note that if $x=y+1$, then$$f(x,y)=\frac{3y^2}{2y^2}=\frac32$$and that therefore if you approach $(1,0)$ along the line $x=y+1$, then the limit is $\frac32\neq0$.
Comment: Note that $(1,0)$ does not belong to the line $y=x$. But the partial derivatives exist at $(1,0)$: they are both equal to $0$.
Comment: Outside $(1,0)$, that function is the quotient of two functions where the denominator has no zeros. So, the partial derivatives exist at any $(x,y)\neq(1,0)$.
Comment: Oh, I used $y=x$. So we know function is not continous at $(1,0)$, what's then?
Comment: What about partial derivatives at $\neq(1,0)$


Definition of galois extensions in rings

Question: Im reading the Paper "Galois Theory of commutative Ring: A historical perspective" of Sharon Zhou availbel as PDF in google. Im troubling with one of the first definitions:
We say that $R \to T$ is a $G$-Galois extension iff the maps:
$ i:R \to T^G$ and $h: T\otimes T \to \prod_G T$ are both isomorphisms.
I have several questions to this definition. Firstly, how does the map $i$ work in general? Than the first condition says that $R$ is a fixed ring, so its basically the same thing, as in Galois Theory for Fields. Why do I need for rings also the second condition? Does somebody have an example of an map which suffices the first but not the second condition, and an argument why this extension should not be galois?
In his paper the author writes, that $h$ measueres the extent to which the extension is ramified. What does this mean? And why should a galois extension me unramified?
A last question. For fields Galois theory starts with saying what an algebraic and finite extension is. For rings we have analogous notions like integral and finite ring extensions. But it seems to me that this notions dont appear in the theory of Galois Theory in rings. Is there a specific reason, why we dont use this definitions as starting points and is there still maybe a connection (e.g is it true $R\to T$ is a Galois extension, iff this is a integral and finite map?)
Answer: We don't care of the map $i$,
simply assume that $G$ is a finite subgroup of $Aut(T)$, $R=T^G$ and $T\otimes_{T^G}T \cong \prod_{g\in G} T$.
Try $T^G=\Bbb{C}$, $T = \Bbb{C}[x]/(x^2), G = \{1,g,g^2,g^3\}, g(a+xb)=a+ixb$. Then $T\otimes_{T^G}T\cong \Bbb{C}[x,y]/(x^2,y^2)$ is a free $T^G$ module of rank $4$, and it has only one prime ideal (the ideal of nilpotents which is $(x,y)$) so it is not isomorphic to $T^4$.
$T/T^G$ should not be said Galois for example because $x$ is a root of $X^2 \in T^G[X]$ of degree $2$ whereas $x$ has $4$ conjugates.


Plateau while learning piano sight-reading

Question: As a 12 year old I had piano lessons for several months until the teacher retired due to ill health and I never kept going with lessons (which I've regretted ever since). On the plus side I've always remembered how to read music.
Fast forward nearly 40 years and I'd like to learn piano again. I bought a keyboard many years ago which spends most of its time gathering dust, but every couple of years I get it out with a view to learning again, spend a couple of months on it, but always hit a plateau.
I'm able to play basic pieces such as nursery rhymes and children's/beginner's pieces with simple rhythms, and I have no difficulty with the first 3 sight reading books in the "Accelerated Piano Adventures for older beginners" series, whose exercises again consist of fairly simple rhythms and note combinations.
However as soon as I tackle something a little more complex then it seems to stump me, for example the "Really Easy Piano" book series. Here, any semblance of sight reading goes out of the window and I seem to spend all my time stopping on each beat to figure out the notes. It's painfully slow and I can spend hours doing this with a single piece, with little overall progress. Sometimes I might eventually manage to play part of a piece, but that's only because I've spent so long going over it again and again that I've learnt that section off by heart and am playing from memory.
It's a very frustrating experience, so what can I do to improve my sight reading? Should I consider taking lessons, or am I at the stage where I just need to practice, practice, practice and work my way through more and more books (sight reading or otherwise)?!
As requested below, here's an example page from the aforementioned sight reading book 3:
And here's another from one of the "Really Easy Piano" books:
Comment: Does this answer your question? [How can I improve my piano sight reading?](https://music.stackexchange.com/questions/142/how-can-i-improve-my-piano-sight-reading)
Comment: Hi Andrew. Welcome to the site. Please accept a couple of suggestions from an interested reader: 1) if possible, post a few measure of a piece you find comfortable to read and one you find difficult; 2) recommendations for books are off-topic here, so consider recasting your question in terms of better understanding what differentiates Piece A from Piece B in sight-reading terms.
Comment: I can't believe this isn't a duplicate of several earlier questions. E.g. some from the 'related' pile opposite.
Comment: @aaron thanks for the quick reply. Done and done.
Comment: I just converted the image links to inline images (which should appear once the moderators approve).  When working through these, do you do each hand separately all the way through, or try to do both from the start?
Comment: Could be helpful to do a bit of sight singing!
Answer: The two pieces given as examples make significantly different demands on the reader. This post will be devoted to addressing those differences. For improving sight reading in the more broad sense, my own "philosophy" is outlined in Acquiring advanced level sight reading. Although the question may not seem directly relevant, my answer will also apply at the basic level being worked through.

"as soon as I tackle something a little more complex"
First of all, rest assured that the arrangement of "Thank You for the Music" is not "a little more complex" than that of "Night of the Tarantella" — it's a lot more complex. Some comparisons:

"Night" is written such that once your hands are in place, neither has to move; "Thank You" requires both hands to move around the keyboard.
Because "Night" keeps your hands in one place, fingering — which finger to use on which key — is not a concern; "Thank You" requires several different fingering techniques, not all of which are at a beginning level.
"Night" has no sharps or flats in the key signature or as accidentals (written next to the notes); "Thank You" has both.
In "Night", the left hand always strikes a chord on a strong beat and at the same time that the right hand also strikes a key — that is, the left hand is rhythmically tied to the right hand; in "Thank You" the hands are significantly independent of each other rhythmically.
"Night" incorporates several identifiable patterns of pitch and rhythm; "Thank You" does not.
If you're counting "in 6", every note and chord in "Night" occurs "on the beat"; "Thank You" is heavily syncopated.
"Thank You" requires that one hand simultaneously hold a note while moving others (see the last line, first two measures, right hand).
Another factor that may or may not be at play here: "Night" was written for the book it's in, so probably unfamiliar beforehand; "Thank You" is a recognizable tune, but the piano arrangement may sound different enough to create confusion or uncertainty.

How to practice toward "Thank You for the Music"
Here I refer to the post linked earlier. Below are the steps recommended in that post, applied to the specific matter at hand.

Read lots and lots and lots of simple music, By continuing to read "dead simple" music (the easier the better, IMO), the various problems of "Thank You" can be encountered individually, in simpler contexts, so they can be conquered one at a time and better learned before moving on.

Practice scales, chords, arpeggios, and common chord progressions. To make the leap from "Night" to "Thank You", this part you could arguably skip; it's of only indirect relevance. However, practicing and memorizing the D major and B minor scales, both of which contain F# and C#, can assist in keeping track of the key signature.

Practice rhythm. This one is essential for "Thank You". There are whole books dedicated to rhythm exercises, and many method books also include them. My personal favorite is The Rhythm Book by Richard Hoffman (Belmont University Faculty Page).1 It can be ordered from the author and might also be found at sites or stores that sell used books. It's also beneficial to, say, clap the right hand and then the left hand (or vice versa) of a piece before trying to play it.

Study music theory. Like scales/chords, this is less directly relevant  here, but can offer some insight into why the various accidentals are there, which in turn can help ease the reading.

Extra bonus suggestion. I really, really, really like the book Introduction to Classics to Moderns, compiled by Denes Agay (Amazon). The pieces are graded — meaning, they progress from easier to harder — and they move from roughly the level of "Night" to something closer to (but short of) "Thank You".

1 Not to be confused with Rory Stuart's book by the same name. I know nothing about that book.
Comment: Thank you, you were spot on with your first list of bullet points, many of which I couldn't articulate when trying to describe my problem. Also some good advice for me to take on too, and look forward to trying some of those books.
Answer: I think you may find that investing in piano lessons would be the best way to relearn what you learnt as a child and to then go on to learn more complex skills. It is, however, entirely possible that you can learn by yourself, as with the internet and YouTube it is more accessible than ever to learn the piano. Despite this, having lessons would be beneficial because 1) you are getting hands on (hopefully not lessons over zoom) instruction that will allow you to learn more easily than by yourself, and 2) you will be expected to practice more regularly to prepare for each coming lesson. The latter reason is perhaps the most beneficial in your case given that you said you tend to plateau after a few months. Also remember that there is of course much more to the piano than being able to read notes and being able to play: having lessons will allow you to develop (or relearn) proper technique that can be hard to develop by yourself. Lessons will also prevent you from developing bad habits during your practice.
For your issue with sightreading: this will correct itself with extensive practice of basic musical "building blocks" such as scales, arpeggios, chords, etc. These should be learned from a music book (such a book would definitely be in the hands of a piano teacher). Once you gain familiarity with these, you will find sight reading to be much easier.
Overall, I think you should get lessons. They are a great way to keep you on track in your (re) learning of the piano and have many benefits that are absent when you try to teach yourself. From a combination of lessons (I think once per week is good, but of course this is dependent on your schedule) and dedicated practice (at least 30 minutes per day; does not have to all be in one go) you will find your piano skills to develop very quickly, and in no time you will be playing the pieces you now struggle with with ease. I wish you the best of luck going forward, and hope that you stick with it.
Answer: The only thing I can tell you with certainty is that you should indeed take lessons. Aside from your current problem (that you may well be able to solve by asking strangers on the internet given enough time and effort), playing the piano (or any other instrument) is a complex skill that involves, chiefly, hearing, motorics, something related to language skills and various kinds of memory. Most of this can not be learned from a book. You could learn to read notes and maybe some rudimentary technique this way, but making music is a skill only transmitted orally (and visually, when it comes to technique) and no book can beat personalised advice from an expert. Taking lessons with a good and engaging teacher guarantees incomparably better results.
However, reading your question some things come to mind of various degrees of importance, helpfulness and applicability.
First of all: practicing is a complicated skill in itself too. (Again, a teacher is in a much better position to provide you with specific help with this.) The way you describe your practicing, I would guess you spend a long continuous time essentially reading the notes and when you have figured out a note, playing it and moving on to the next, until you have made it through the piece. (Of course, this is speculation.) This way, you will have forgotten the start of the piece long before you have a chance to return to it, and you have to start from zero each time – voilà, a plateau. Instead, a much better way would be to practice a much smaller unit (in the order of magnitude of half a bar) until you can play it comfortably (that includes much more than just notes - rhythm, dynamics, comfortable motorics, articulation…), then linking these units together when you have a few of them. You can practice a few units in parallel, but no more than you have time for in a single day (otherwise the forgetting will get you again). Practicing should be done in chunks of no longer than 20 minutes (I guarantee you that two blocks of 20 minutes will give better results than 1 of 40 or even 60). Practicing every day also helps prevent the forgetting. I am describing an idealised practice plan and I am aware real life, motivation and discipline do not work this way - this is just to provide you at least some information on how to practice, take from it what you want.
Of course, this poses the problem of dividing the music in such smaller units. Ideally they should be musically meaningful and reasonably self-contained. As long as you don't have a teacher to help you with this, you could try and figure this out by ear if a recording is available, but that could take a lot of time and effort and subdividing blindly by half-bars should be fine too - just keep your ears open and just deciding whether this one note across a boundary actually belongs on the other side is a great exercise for phrasing.
Secondly, you might be helped by the fact that it is possible to play in a way in between sight-reading and fully from memory. Here we can reuse above-mentioned units. If you remember all units individually (and contained in them each note) using mostly your muscle memory, you can use the sheet music as essentially a memory aid, seeing which unit comes when (recognising them visually and by basic aspects such as whether they are ascending or descending, stepwise or in jumps, have long notes or short notes, etc). Whether this could be helpful to you or even whether this is an achievable goal for you currently is impossible to tell for me through the internet.
Lastly, the second piece you posted is not at all the same difficulty as the first. The first only contains five distinct notes in each hand. (Actually the left never has a B so only four for the left hand.) That of course eases the note reading. Additionally, these two sets of five notes also happen to be adjacent, which means the hand can remain relaxedly in the same place for the whole piece (this is called "position playing"). The right hand only has one note at a time. (While the left hand has chords, they are very comfortable and straightforward because of the position playing.) There aren't any flats or sharps at the clef either (or any accidentals for that matter).
The second piece, however, has two sharps as a key signature and regular accidentals. The right hand occasionally has two notes simultaneously (without any position playing to take away the complications that inherently brings). In fact, there is no trace left of position playing at all, whereas the normal learning trajectory eases out of position playing by first changing only one note in one hand once in the piece, then expanding to regularly in both hands, occasionally a piece which moves to a different position halfway the piece and then back again, then slowly expanding this. The two pieces are not at all of the same difficulty level. And I haven't even mentioned the rhythmical complications of the second piece and the issue of fingering.
I hope these thoughts will be of some help to you, but none of it can substitute for lessons with a good teacher. That is the best advice anyone could give you.
Comment: (From my answer that I never got around to finishing: "There are a lot of reasons for having a teacher (correcting what you don't know you're doing wrong, etc.), but not the least is the job of managing motivation and assigning curricula that help you progress gradually, so you're always just slightly challenged and never jump into something that you haven't laid the groundwork for.")
Answer: All other answers provide very good pointers how to tackle learning to (sight)read. However, this part of the question made me think there probably is a more fundamental issue:

"I seem to spend all my time stopping on each beat to figure out the
notes. It's painfully slow and I can spend hours doing this with a
single piece, with little overall progress."

How good are you at identifying notes? How fast can you shout out the notes when you see them. I think this is more essential than you might think! You may think you can find the notes fast, but if you're still struggling and stopping, there is probably still a lot of improvement to be made.
Try to work with flashcards or similar. Or just pick up a score and try to just shout out the notes you see. You can do the same with seeing the note and instead of shouting the note name, finding it on the keyboard. Aim for accuracy first, but also try to speed it up gradually.
There's a booklet called "Super sightreading secrets" which has an interesting appoach with this. It has two pages with a lot of random notes intended to be used like this. Maybe it is possible to find it online.
On the issue of taking lessons: altough lessons are wonderful and will help you in many ways, you should make sure that if you take lessons they will train you in reading, many teachers don't focus on this, and will try to focus on technique and interpretation, by studying a relative small number of pieces.
Taking a class in sight singing (solfège) on the other hand would be great!
Answer: Sight reading is a combination of a couple of skills.  The first is having the technical facility to play what is in front of you.  If you can't play a series of notes in front of you, you will stumble over the execution of them.  The second is knowing music theory.
Just as you can look at a sentence and just read the words without sounding them out, you must be able to look at music and your brain will just know what the chords and scales are.  You won't actually see every note.  Have you seen this paragraph?
"It deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteer be at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe."
You can read that because you know the alphabet, the rules of spelling and how to sound out letters.  Your brain does all the decoding.  Music is much the same.  Nothing exists in isolation.  Technique and theory will improve your reading.


Is it possible to run nodemon to restart server upon changes on front-end?

Question: I'm rather new to this area, so please excuse if this question is completely basic. I've seen some tutorials use nodemon to watch files, and restart servers on Nodejs backend. I've seen others use webpack to watch files such as create react app on frontend. Can you actually use nodemon to watch files and refresh pages on the front end?
Answer: Yes I believe you can set it up with your package.json scripts!
For instance with a node server with a create-react-app within a client folder you could declare a start script along the lines of:
"start": "concurrently \"nodemon server.js\" \"cd client && nodemon start\""

Then when you run npm start this will run nodemon on both the server file and the client folder
Just be aware this assumes your server file is named server.js and your client files are in a folder named client and will require you to have the concurrently dependency installed.
Answer: You could use something like this one if you already have create react app within a client folder.
"server": "nodemon server.js",
 "client": "cd client && yarn start",
 "dev": "concurrently --kill-others-on-fail \"yarn server\" \"yarn client\""
Concurrently allows us to run both on one terminal as well as it allows us to pass --kill-others-on-fail which means that if one breaks (control + c on mac), the other one will also break
Answer: Nodemon is primarily used for backend development with Node.js, as it monitors changes in server-side files and automatically restarts the server when changes are made. However, it is possible to use Nodemon for frontend development as well, especially in cases where you are using a tool like Webpack to build and bundle your frontend assets.
For example, if you have a frontend project that uses Webpack to compile your JavaScript, CSS, and HTML files, you can use Nodemon to monitor changes in your source files and automatically trigger a rebuild of your project whenever changes are detected. This can save you time and make your frontend development workflow more efficient.
That being said, Nodemon is not a frontend-specific tool, and there may be other tools and frameworks that are better suited for frontend development, depending on your specific needs and requirements.


What is the name for this unintuitive result with OLS on a very "asymmetric" regressand, and how should it be addressed?

Question: Say our sample consists of about a hundred Belgian (x = 0) and Swiss (x = 1) chocolate bars. We test them to see if they have safe (y = 1) or lethal (y = 0) levels of arsenic. As it turn out, 90% are safe. We then regress y on x with OLS to check whether the country of origin is correlated with safety:
<code>------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       swiss |        -.9   .3030152    -2.97   0.004    -1.501248   -.2987522
       _cons |         .9   .0301511    29.85   0.000     .8401736    .9598264
------------------------------------------------------------------------------
</code>
Goodness! I'm never going to eat a Swiss chocolate bar again. The point estimate is exceedingly large, and the test is exceedingly significant. But looking at the data more closely, there is only one Swiss bar in our sample. It so happens that it is unsafe.
In other words, if the null hypothesis is true (i.e. x is uncorrelated with y), and if we were to repeat this experiment arbitrarily many times with a single "x = 1" observation in each sample, then 10% of the time our model would lead us to reject the null with 99.6% confidence (i.e. a type I error).
The result seems misleading.

Does this phenomenon have a name?
Is there an intuitive explanation for what appears to be a gross predilection to type I errors?
Should this result be "corrected"? If so, how? (Without collecting more data, of course.)
Is there a way to identify this phenomenon in published tables, if an accompanying summary table of descriptive statistics is not presented? Are there any red flags in the regression results below?

Stata code to replicate this result:
<code>// Create data (101 obs)
clear
input   y x n
        0 1 1
        0 0 10
        1 0 90
end
expand n

// Describe data
tab y x

// OLS regression
reg y x

/*
// A variety of alternative estimations, with SE listed
reg y x, vce(ols)       // 0.3
reg y x, vce(robust)    // 0.03
reg y x, vce(cluster x) // ~0
reg y x, vce(bootstrap) // 0.03
reg y x, vce(jackknife) // 0.03
reg y x, vce(hc2)       // 0.03
reg y x, vce(hc3)       // 1.1
*/

exit
</code>
Results:
<code>.     // Describe data
.     tab y x

           |           x
         y |         0          1 |     Total
-----------+----------------------+----------
         0 |        10          1 |        11
         1 |        90          0 |        90
-----------+----------------------+----------
     Total |       100          1 |       101

.     // OLS regression
.     reg y x

      Source |       SS           df       MS      Number of obs   =       101
-------------+----------------------------------   F(1, 99)        =      8.82
       Model |  .801980198         1  .801980198   Prob > F        =    0.0037
    Residual |           9        99  .090909091   R-squared       =    0.0818
-------------+----------------------------------   Adj R-squared   =    0.0725
       Total |   9.8019802       100  .098019802   Root MSE        =    .30151

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           x |        -.9   .3030152    -2.97   0.004    -1.501248   -.2987522
       _cons |         .9   .0301511    29.85   0.000     .8401736    .9598264
------------------------------------------------------------------------------
</code>
Comment: Side note: you are modelling a binary (0,1) outcome using a linear regression model; this does not sound very good. However, this comment does not answer your main question.
Comment: Exactly what is this "phenomenon" to which you refer? How do you deduce that "if we were to repeat this experiment arbitrarily many times with a single "x = 1" observation in each sample, then 10% of the time our model would lead us to reject the null with 99.6% confidence (i.e. a type I error)."  It's not even clear what "this experiment" is.
Comment: You sample consists of 101 items.
Comment: Red flags: grossly unbalanced sample and also zero in the count table.
Comment: Alecos: (1) Alright, I've changed "a hundred" to "about a hundred". (2) But how would I know if the sample were grossly unbalanced if the count table were not present?
Comment: William: (1) The "phenomenon" is that the standard error on the point estimate for Swiss is much smaller than my intuition tells me it ought to be. I would have interpreted the estimation result to indicate that Swiss chocolate bars are extremely likely to be more dangerous than Belgian ones, but I don't think the data supports that. (2) If the null is true, then 10% of the time our single Swiss chocolate bar will be poisonous, and we will have the result shown above, that Swiss chocolate bars are significantly (p = 0.004) more poisonous than Belgian ones.
Comment: Richard: Thank you. See Scortchi's response, and my comment on his response. Would you think that a Fisher's exact test is more appropriate here? When would you use an LPM?
Answer: @RichardHardy's observation that you're modelling a dichotomous response using ordinary least squares regression is at the heart of the matter: the distribution of errors is far from normal, & with a single observation at $x=1$, the  distribution under the null of the standardized coefficient estimate for $x$ will show a gross departure from a t-distribution.
Your description of the situation & the predictor distribution are enough to raise a red flag, but the usual regression diagnostics will highlight the issue: a clearly non-normal distribution of the residuals & the hugely disproportionate leverage of a single point. In general tables of coefficient estimates, standard errors, t-statistics, &c. don't help you to check whether the model's badly mis-specified (that's why we have diagnostics)—in this case, knowing that $x$ is dichotomous & that reference-level coding was used, & without other predictors to muddy the waters, the large difference in standard errors between the estimates for the intercept & for the $x$ coefficient reflects the discrepancy in sample size between the two groups.
<code># make data & fit model
x <- c(rep(0,100),1)
y <- c(rep(1,90),rep(0,10),0)
lm(y~x) -> lmod

# leverage plot
plot(hatvalues(lmod), type="h")

# normal quantile-quantile plot
qqnorm(residuals(lmod))

# simulate y values under the null of common 10% probability for Y=1
t.stat <- numeric(10000)
for (i in 1: 10000){
y.sim <- rbinom(101, 1, 0.9)
lm(y.sim~x) -> mod.sim
summary(mod.sim)$coef["x", "t value"] -> t.stat[i]
}

# plot kernel-smoothed density estimate of t-statistic distribution
# for the x coefficient
plot(density(t.stat))

# plot empirical distribution function of t-statistic
plot(ecdf(t.stat))

# compare to theoretical distribution
t.cumve <- function(x) pt(x, df=lmod$df.residual)
curve(t.cumve, add=T, col="blue", lty=2)

# show observed value of t-statistic
abline(v=summary(lmod)$coef["x", "t value"], col="red", lty=3)
</code>
Comment: (1) Yes FET; or, more generally, exact logistic regression. I'm planning to add a paragraph about that when I have time. (2) You've only one dichotomous predictor, so it makes no difference in this case whether you assume linearity in probability, or in log-odds, or in whatever else. See [here](http://stats.stackexchange.com/questions/80033).
Comment: This is an excellent response. Thank you. A chi-square test yields p = 0.004, but perhaps a chi-square test is not suitable for this unbalanced/small sample. From what I have read, I think Fisher's exact test might be suitable. It does seem to agree with my intuition, yielding p = 0.109 ("tab x y, exact" in Stata). Do you think Fisher's test is proper here? Also, when would you say a Linear Probability Model is appropriate? (My original post uses LPM, correct?)


How to set a validation error via ajax?

Question: I am using the formapi to create a form. On one of my fields I have an #ajax call. When the field is changed I call the function. I recreate the form and then replace the whole form on the page. This works fine.
When creating the form I have some logic that sets the form state to see if a field has a value. If it has a value then I show some more fields. If the value is not set then I don't show the fields. I am showing the fields by setting the #access on the field.
I need to add some validation on the form when the ajax call is triggered. I have tried adding the validation using form_set_error() in the function that creates the form and in the ajax callback but the error is not displayed on the screen.
Am I going about this the wrong way completely? How can I get the form error to display?
Answer: If the name of your form is modulename_admin_form() then you can add a function modulename_admin_form_validate(&$form, &$form_state).
In that validate function you can form_set_error() from in that validate function.
Comment: So when the form is submitted the validation kicks in as requested. However when I do the ajax callback the form does not update.
Comment: What do you mean by 'does not update'? What specifically are you (or are you not) seeing?

How to set a validation error via ajax?


Proof verification: showing that $f(x) = \begin{cases}1, & \text{if $x = 0$} \\0,&\text{if $x \ne 0$}\end{cases}$ is Riemann integrable?

Question: Let I be an interval which contains 0 and let $f(x) = \begin{cases}1, & \text{if $x = 0$} \\0,&\text{if $x \ne 0$}\end{cases}$ which is defined on I.
Proof:
Choose $\epsilon > 0$. Now, let I = $[a,b]$ and let $p \in P_{[a,b]}$. We must show that $U(f,p) - L(f,p) < \epsilon$. Indeed, $L(f,p) = 0$. Without loss of generality, suppose $0 \in p$ such that $0 = x_{i} \in p$. Then, $U(f,p) = (x_{i-1} - x_{i}) + (x_i - x_{i+1}) = (x_{i-1} + x_{i+1}) \le 2(l(p))$ (where $l(p)$ is the length of $p$). Hence, $U(f,p) \le 2 \space inf_{p\in P}l(P) = 0$. So, $U(f,p) - L(f,p) \le 0 < \epsilon$.
I'm mainly worried about the $2 \space inf_{p\in P}l(P) = 0$ part. I know that as the partition become finer, the length of p will approach 0, but I'm not sure if I can say that it equals 0.
Answer: The length will never equal zero, but the infimum is zero. This is essentially the kind of problem the meaning of infimum was defined for.
For a strict proof: You can take the length of this interval to be $1/n$ for any $n$. Thus, the infimum is less than any $\epsilon>0$. Thus it is zero.
Answer: You just need to show that for any $\epsilon>0$ there is a partition $P$ such that $U(f,P) < \epsilon$.
Take $P=(0,{1 \over 2}\min(1, \epsilon),1)$, then $U(f,P) = {1 \over 2}\epsilon < \epsilon$.
Comment: So if I'm showing $U(f,p) -L(f,p) \le \epsilon$ I can choose an explicit partition?
Comment: @BeepBoop: Of course. Why not? In this case it is straightforward, but that is not always so.


How to get started with Android Studio C++ development

Question: I heard at Google I/O 15 that Android Studio has now C++ support, the official documentation for the NDK only has instructions for Eclipse.
How does one get started with Android C++ development using Android Studio?
Comment: Have you considered using [Visual Studio Community 2015](https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx) instead?
Answer: There is detailed instructions on the Android NDK Preview site.
The gist of it

Download Android Studio 1.3+
Install the NDK bundle from Tools > Android > SDK Manager

Import the hello-jn sample using File > Import Sample (Note: This sample is using the new gradle-experimental plugin)

Click Run > Edit Configurations... and andd a new Android Native configuration

(source: android.com)
Run and debug your application as usual

A few things to try from there:

Generate JNI bindings for Native Java function.

Put breakpoint in native code (with the current limitation that breakpoint on init/onCreate get skipped, should be already fixed in Android Studio 1.4 Preview)
Give feedback to the team
Try and contribute to the new sample on GitHub
Explore the new documentation and API reference.


Make the Web App on Azure portal only Available few hours in a Week

Question: I am building a ASP.Net Core Web App which I am trying to host in the Azure portal. We have requirement that these Applications can be accessed only certain times in a week, those times are stored in the Azure Database. Is it possible to make the App Available/Accessible to the users upon looking at database

Here the Setting is that the application should be available only between 14:00 - 16:30 on TUESDAY. When I tried to research we can schedule tasks/workflows in the portal but couldnt find what I am looking for. All I wanted to know is this requirement possible, if so please share the idea.. I am new  Web App development and Azure deployment, any help is greatly appreciated
Answer: This feature is not available in Azure out of the box. This is something you will have to handle yourself.
One obvious way to implement this would be to check if the application should be available on every request. If the request day and time falls between the available times set in the database, you show your users the website content otherwise show them some kind of not available message.
A more complicated way would be to make use of App_offline.htm file to make your site unavailable. You can dynamically add/delete App_offline.htm file to your WebApp based on the day/time when you want your site to be offline/online.
However please note that while your site is offline, you will still be charged for the WebApp as the resources keep remain provisioned.
Comment: No worries. Yeah, in that case you can use Timer Triggered Azure Function that will run on a scheduled basis to check if the application should be available/unavailable. In this Function, you can query the database to find this information.
Comment: @TinyWang - Of course. But stopping the web application will make it inaccessible and the users will get some error. I am not sure if this is what OP is looking for. My understanding is that OP would want the web application available all the time but users will only be able to access it between certain times.
Comment: Thank you so much if we plan to go ahead and hosting application on prem will the 1st option work..? How does the 1st one work, so when the Call to the App is made, inside the home controller call the Settings tables in the DB and check against current datetime? If we have enabled the Azure AD Authentication wont the Call to the application by default goes the Authentication?
Comment: `How does the 1st one work, so when the Call to the App is made, inside the home controller call the Settings tables in the DB and check against current datetime?` - You can certainly do that. If this information does not change often, you can also cache it so that you don't have to make repeated database calls. `If we have enabled the Azure AD Authentication wont the Call to the application by default goes the Authentication?` - I think it will but only thing the user will be able to do is just login. Once they login into the application, they will be shown the site offline message.
Comment: `if we plan to go ahead and hosting application on prem will the 1st option work` - Both of these options will work regardless of where you host your application. 1st option is application specific and the 2nd option is web server specific (IIS, if I am not mistaken). HTH.
Comment: @GauravMantri Is it possible to using a time trigger function to call [this api](https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/stop) to stop the service?
Comment: Thanks for your reply sir : ) You're thoughtful
Comment: @TinyWang Can the time trigger function on the Azure refer to the Azure DB to check when tha app needs to hosted/stopped?
Comment: @GauravMantri Sorry for not being clear.  We can even have the application go inaccessible but just make the app available only between the time that is given in the database.. Can then time trigger function on Azure be used here, again can it refer to the Azure DB to check when the start and end time and then host the app/stopped?
Comment: Thanks a ton.. This really help
Comment: @trx Yes, function time trigger can realize it as Gaurav Mantri sir said.
Comment: @TinyWang I was searching for an example of an timed trigger azure function that does lookup at the DB.. Do you have any references to help me get started that will be really appreciated.. New to Application building and the azure platrform and kind of stuck .. Thanks again
Comment: @trx Can [this](https://learn.microsoft.com/en-us/azure/azure-functions/functions-scenario-database-table-cleanup) help you?
Comment: @TinyWang Thank you It did help. I am in the process of building a Azure function an ran in to an issue which is in https://stackoverflow.com/questions/69723458/calling-the-post-api-call-from-the-timer-triggered-azure-function can you please help me with it
Answer: You can use Azure Automation Service to orchestrate processes like this. You will have to create a runbook (script in python or powershell) that will query the DB and figure out the times when the Azure Website hosting your webapplication should be started or stopped.
Comment: I believe OP does not want the site to be stopped. The intent is to show some kind of site not available message.
Comment: If we are going with this option to take the site down on other days then we may charged  only on those days/time the application is hosted?
Comment: `If we are going with this option to take the site down on other days then we may charged only on those days/time the application is hosted?` - No, you will still be charged. To stop the billing you will have to delete the WebApp resource completely.
Comment: @GauravMantri Is this something easily achievable? Since I am new to the Web App development I what to choose the easier solution
Comment: I can only think of these two options :).


Show that $\int_{0}^{1}P(x)f(x)=0$

Question: Let $f:[0,1] \rightarrow \mathbb{R}$ a continuous function, such that $\exists (u,v)\in [0,1]$; $ f(u)>0, f(v)<0$.
Show that there exists $P$ a polynomial such that $P>0$ over $[0,1]$ and
$\int_{0}^{1}P(x)f(x)=0$
Comment: Sorry I didn't get it
Comment: How about considering $P(x)=\alpha(x-u)^2+\beta(x-v)^2$, with $\alpha,\beta>0$, and using continuity of $(\alpha,\beta)\to\int P(x)f(x)$ ?
Comment: It was just an idea, which I don't think actually works. See MotylaNogaTomkaMazu's answer for a solution.
Answer: There exists two polynomials $P,Q\in\mathbb{R} [x]$ such that $P(x) >0 , Q(x)>0$ for $x\in [0,1] $ and $$\int_{[0,1]} P(x) f(x)dx =\alpha >0 \wedge \int_{[0,1]} Q(x) f(x)dx =-\beta <0$$ hence if we take $W(x) =\alpha^{-1} P(x) +\beta^{-1} Q(x) $ we get $W(x) >0 $ for $x\in [0,1] $ and $$ \int_{[0,1]} W(x) f(x)dx =0.$$
Comment: @AlexM. I am guessing the existence of $P$ can be shown using the density of polynomials in $\mathcal C([0,1])$, approximating a function $g\geq\epsilon>0$ that has a spike on a neighbourhood of $u$ where $f>0$. Same goes for $Q$. Given such $P$ and $Q$, the positivity of $W$ is automatic, is it not?
Comment: First, it's not clear why such $P$ and $Q$ exist. Second, it's not clear why $W>0$.
Comment: @AlexM. I think you misread, $\beta$ is actually $>0$. Since both $P$ and $Q$ are $>0$, $W$ is the sum of two positives functions.

Show that $\int_{0}^{1}P(x)f(x)=0$


View gets Json displayed on the page. not the data

Question: I have an action which returns a JsonResult. The only thing gets displayed on the view is my json which is like
ProcessOrder{"IsValid":true,"url":"/Home/ProcessOrder"}

While debugging the code, I noticed that it gets displayed because of this below line.
 var ProcessOrderData = new { IsValid = true, url = Url.Action("ProcessOrder") };
                return new JsonResult() { Data = ProcessOrderData };

Can any body please tell me why it gets only json to be displayed on the view?
is something null here that is causing this to get this displayed or any other stuff?
Code:
 private ActionResult SubmitAccount(UserAccountModels UserAccountModels)
    {
        SessionInfo userSession = SiteSetting.Visitor;

        if (userSession != null)
        {
            if (userSession.products.Where(rec => rec.IsAddedToCart).Count() > 0)
            {
                SiteSetting.Visitor.User.FirstName = UserAccountModels.FirstName;
                SiteSetting.Visitor.User.LastName = UserAccountModels.LastName;
                SiteSetting.Visitor.User.Phone = UserAccountModels.Phone;
                SiteSetting.Visitor.User.Email = UserAccountModels.Email;
  var ProcessOrderData = new { IsValid = true, url = Url.Action("ProcessOrder") };
                return new JsonResult() { Data = ProcessOrderData };

            }}}

Answer: It will only display Json because you are returing JsonResult not a View
Comment: so should i return something like
return RedirectToAction("ProcessOrder");
Comment: yes return a view or action and instead of JsonResult return a model or model object in viewbag whatever is suitable in your scenario


width 100% on an overflow scroll element in flex container

Question: Because a picture is worth a thousand words, I'll show it first:

In red is my flex container, in blue is an element with a fixed width of 50px, in green is a section with a 100% width, in yellow is a list also with a 100% width and an overflow scroll, and finally in purple are my list elements width a fixed width of 100px.
I want the green element to fit in my red flex container. How can I do that?
Here's the codesandbox used to make the screenshot above (it's made in React but the html is in App.js and the css in styles.css):
https://codesandbox.io/s/rough-moon-0rsfc?file=/src/styles.css
Answer: You can add overflow: hidden to the green box to make it stay in the bounds of it's parent.
section {
    width: 100%;
    padding: 5px;
    box-sizing: border-box;
    background: green;
    overflow-x: hidden;
}

Comment: If you set the overflow property on the x axis to `overflow: hidden;`, it will only let the element expand to the width of its parent container and everything else extra will be cutoff.
Comment: Yes, it did the trick, thanks. I'm struggling to understand why though, can you explain?
Answer: You had set widths that I removed. Also, I see that You may not need the div container.
I left it commented out in case you decide you want to keep the blue div.
main {
  height: 100px;
  padding: 5px;
  background: red;
  display: flex;
}
/*
div {
  width: 100%;
  background: blue;
} */

section {
  width: 100%;
  box-sizing: border-box;
  background: green;
  margin: 0;
}

ul {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 5px;
  box-sizing: border-box;
  background: yellow;
  display: flex;
  overflow-x: auto;
  list-style-type: none;
}

li {
  flex: 0 0 auto;
  background: purple;
  width: 100px;
  margin: 0 2px;
}

Comment: I think you might have misunderstood my issue. I need the exact same layout, the fixed width on the red container was to easily reproduce the issue,  the blue div is actually a real element that I need to keep.


Properties of conditional probability distributions

Question: This is a problem from a machine learning pset that I'm self-learning from http://www.seas.harvard.edu/courses/cs281/assignment-1.pdf.

Suppose we are provided with a hierarchy of three distributions:
  $p(\alpha)$, $p(\theta | \alpha)$ and $p(y | \theta, \alpha)$.
  Write expressions to compute the following related distributions:
$p(y|\theta)$,  $p(y|\alpha)$,  $p(y)$,  $p(\theta|y,\alpha)$,
  $p(\alpha|y,\theta)$, $p(\theta)$, $p(\theta|y)$, $p(\alpha|y)$

I see that I integrate over the joint distribution to get the marginal probability
$$p(y|\theta) = \int p(y|\theta,\alpha)p(\alpha)d\alpha$$
This gives me the first expression in terms of the givens.
However, I don't know how to get the others. I know I can set up various equations using Bayes' Theorem
$$p(\theta|\alpha) = p(\alpha|\theta) * p(\theta)/p(\alpha)$$
But the above equation has two unknowns ($p(\theta)$ and $p(\alpha|\theta)$). Is there another property that I can exploit besides marginalizing the joint distribution and utilizing Bayes' Theorem?
Comment: Hint: You can find $p(\theta) = \int p(\theta\mid\alpha)p(\alpha)d\alpha$ and use this to get $p(y\mid\alpha)$ from $p(y\mid\theta,\alpha)$
Comment: Your expression for $p(y|\theta)$ is wrong.  It should be $$\int p(y|\theta\alpha)p(\alpha|\theta)d\alpha=\frac{\int p(y|\theta\alpha)p(\alpha)p(\theta|\alpha)d\alpha}{\int\int p(y|\theta\alpha)p(\alpha)p(\theta|\alpha)d\alpha dy}$$
Comment: Just realised you can remove $p(y|\theta\alpha)$ and the integration over $y$ in the denominator of my answer, as $\int p(y|\alpha\theta)dy=1$
Comment: @probabilityislogic thanks so much for pointing that out! Yes, I think the correct expression should have been $p(y|\theta) = \int p(y|\theta,\alpha)p(\alpha|\theta)d\alpha$ which contains an unknown
Answer: The given conditionals allow you to find the joint density of the three random variables using the product rule
$$
  p(y,\theta,\alpha)=p(y\mid\theta,\alpha) \, p(\theta\mid\alpha) \, p(\alpha) \, .
$$
(Of course this is a sloppy notation, since the $p$'s are not the same function.)
You know the three densities on the rhs of the former equation, and your answers should be given in terms of those three densities. Now you can get any conditional density that you need using the definition and integrating to get the marginals.
For example, we have
$$
  p(\theta\mid y,\alpha) = \frac{p(y,\theta,\alpha)}{p(y,\alpha)} \quad ,
$$
where the marginal in the denominator is
$$
   p(y,\alpha) = \int p(y,\theta,\alpha) \,d\theta =  p(\alpha) \int p(y\mid\theta,\alpha) p(\theta\mid\alpha)\, d\theta  \, .
$$
Therefore, we have
$$
  p(\theta\mid y,\alpha)=\frac{p(y\mid\theta,\alpha) \, p(\theta\mid\alpha)}{\int p(y\mid\theta,\alpha) p(\theta\mid\alpha)\, d\theta} \quad\qquad .
$$
And so on.
This is a general boring way to do it, but of course, in many cases, you have shortcuts using Bayes's rule directly, etc.
As an example, the lazy way to compute $p(\alpha\mid y,\theta)$ is to notice that by Bayes's rule it is proportional to $p(y,\theta\mid \alpha)\,p(\alpha)$, which is equal, by the product rule, to $p(y\mid\theta,\alpha)\,p(\theta\mid\alpha)\,p(\alpha)$. Hence, we normalize (integrate in $\alpha$) and find
$$
  p(\alpha\mid y,\theta) = \frac{p(y\mid\theta,\alpha)\,p(\theta\mid\alpha)\,p(\alpha)}{\int p(y\mid\theta,\alpha)\,p(\theta\mid\alpha)\,p(\alpha)\,d\alpha} \quad\qquad .
$$
Answer: Note that you have the joint pdf factored into three parts:
$$p(y\alpha\theta)=p(\alpha)p(\theta|\alpha)p(y|\alpha\theta)$$
Once you have this all other distributions follow from marginalising this joint distribution and the rule for conditional probability.


CDF of derived distribution $|X-Y|$ when $X$ and $Y$ are exponential random variables

Question: I recently had to solve this same problem, except $X$ and $Y$ were uniform on $[0,1]$. The joint probability distribution was uniform, so I just needed to find the proportion of the area inside the region of the unit square where $|X-Y|\leq z$ for a given $z$.
I was wondering: what should I do if $X$ and $Y$ are independent exponential random variables with parameter $\lambda$? I believe I would have to integrate $$\int_{y_0}^{y_1} \int_{x_0}^{x_1} \lambda^2 e^{-\lambda(x+y)} \, \mathrm dx \, \mathrm dy$$
but I'm not sure what the bounds would be. How should one approach this?
Answer: You can use:
$$ P(\lvert X - Y \rvert < z ) = P(X - Y < z, X - Y > -z) = P(X - Y < z) - P(X - Y < z, X - Y < -z) = P(X- Y < z) - P(X-Y<-z)$$
While $X-Y$ has pdf that's quite easy to calculate - see another answer. Moreover, it's form allows us for closed-form expression for cdf. Said PDF is:
$$ f(x) = \frac{\lambda \mu}{\lambda+\mu}
\cases{e^{-\mu x} & if $x > 0$\cr
       e^{\lambda x} & if $x < 0$\cr}$$
where $\mu, \lambda$ are parameters of $X, Y$ respectively.


Why is my MONTH view still showing a DAY as the title?

Question: UPDATE: I see the issue was not fixed in the current release so am especially interested in any suggestions for workarounds. For example, maybe I could hide the default header with CSS and add the correct title in the view.
ORIGINAL QUESTION: I know this was a bug in the 7.x-2.x-dev version of the Date module, but it seems to have been patched. I am running 7.x-2.8 (the latest) in which it should be fixed.
Why am I having this problem, and more importantly how can I work around it? I am working on a site where I only have access to the site administration, and not the server (ie: I can't patch the module myself).
Comment: How do you tell it's supposed to be fixed if all patch files apparently failed testing? Also, if you can't patch, why bother asking? It is how it is, it'll change when it'll change, why bother if you're helpless anyway? Unless your GUI allows module uploads. If so, you can patch.
Answer: It appears that the fix isn't in the latest release (7.x-2.8) yet and is instead in the current (7.x-2.x-dev) version. According to the comment #70 in that thread you posted, the patch is meant to be applied to the current release and not the latest dev (which is why it failed). If you run the patch in comment 70 against your 7.x-2.8 version it should correct the issue. As you stated that isn't an option, you can try to have the drupal update page grab the latest dev.
You can always check the release date for different branches on the project page. For example, Date currently shows the 7.x-2.8 branch as having been released on July 29th, 2014 while the latest commit, 7.x-2.x-dev, was released on June 16th, 2014. Hope that helps
Comment: Thanks, I had assumed that because they closed the issue that it had been fixed in that release. My bad.


comando 'code .' não funciona nos terminais

Question: Atualizei a versão do meu node para 20.9.0, e acredito que depois que fiz isso não consigo mais utilizar o comando 'code .'
O comando que funcionava no CMD e no powershell do VSCode, agora não funciona mais. Procurei algumas soluções e tudo que achei até agora não funcionou.
Uma das soluções é instalar a extensão Shell no VSCode, apertar F1 pra abrir o command pallet e executar o comando "Shell Command: Install 'code' commando in PATH", mas esse comando nem aparece na lista de comandos.
Alguém sabe como posso resolver isso?
inserir a descrição da imagem aqui
Answer: Se ele não acha o executável é porque a instalação não está mais no Path do sistema.
Normalmente basta você adicionar o caminho "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio Code"
no Path do Windows.

O PATH é uma variável do sistema usada pelo sistema operacional para localizar executáveis necessários da linha de comandos ou da janela Terminal.
A variável do sistema PATH pode ser definida usando o Utilitário do Sistema no painel de controle no Windows ou no arquivo de inicialização do shell no Linux e no Solaris.
Fazer alterações na variável PATH do sistema em geral não é necessário para computadores que executam o Windows ou o Mac OS X.

https://www.java.com/pt-BR/download/help/path_pt-br.html
Para Alterar o path no Windows:
No seu caso ao invés de código Java será o comando code .

Windows 10 e Windows 8
Em Pesquisar, procure e selecione: Sistema (Painel de Controle)
Clique no link Configurações avançadas do sistema.
Clique em Variáveis de Ambiente. Na seção Variáveis do Sistema localize a variável de ambiente PATH e selecione-a. Clique em Editar. Se a variável de ambiente PATH não existir, clique em Novo.
Na janela Editar Variável de Sistema (ou Nova Variável de Sistema), especifique o valor da variável de ambiente PATH. Clique em OK. Feche todas as janelas restantes clicando em OK.
Reabra a janela Prompt de comando e execute o código Java.
Comment: Como está escrito atualmente, sua resposta não é clara. Por favor, pode [edit] para adicionar mais detalhes, que ajudarão outras pessoas a entender como isso resolve a pergunta feita. Você pode encontrar mais informações sobre como escrever boas respostas [na Central de Ajuda](/help/how-to-answer).


How do I set the pacemaker cluster name with pcs?

Question: I'm running two pacemaker clusters on the corosync stack on CentOS 7 with all packages up to date with the distro release/updates packages.
Both clusters shows no cluster name with the command pcs status:
Like this:

Cluster name:
Last updated: Mon Nov  3 09:55:58 2014
Last change: Fri Oct 31 11:09:22 2014 via cibadmin on beaker
Stack: corosync
Current DC: scooter (2) - partition with quorum
Version: 1.1.10-32.el7_0.1-368c726
5 Nodes configured
21 Resources configured

There is a cluster_name: entry in the totem section of /etc/corosync/corosync.conf, but I can't find anything related to the cluster name in the pacemaker CIB.
The clusters were created with pcs cluster setup --name clustername node1 node2 node3 node4 node5 (with clustername being the intended name of the cluster).
The /etc/corosync/corosync.conf is world-readable, as well as the directories above it.
Answer: In the sources of pcs-0.9.115-32.el7 the getClusterName function is implemented:
def getClusterName():
    if is_rhel6():
        try:
            dom = parse(settings.cluster_conf_file)
        except (IOError,xml.parsers.expat.ExpatError):
            return ""

        return dom.documentElement.getAttribute("name")
    else:
        try:
            f = open(settings.corosync_conf_file,'r')
        except IOError as e:
            return ""

        p = re.compile('cluster_name: *(.*)')
        for line in f:
            m = p.match(line)
            if m:
                return m.group(1)

    return ""

This function check  for rhel6 to extract the cluster name from /etc/cluster/cluster.conf (attribute name) or in other case from /etc/corosync/corosync.conf.
The regular expression expected at least one space between cluster_name and name ('cluster_name: *(.*)') in corosync.conf file, maybe this is the problem.

def is_rhel6():
    try:
        issue = open('/etc/system-release').read()
    except IOError as e:
        return False

    if re.search(r'(Red Hat Enterprise Linux Server|CentOS|Scientific Linux) release 6\.', issue):
        return True
    else:
        return False

Check if exist file /etc/corosync/corosync.conf with the proper permissions. I think this bug can be relevant for you: https://bugzilla.redhat.com/show_bug.cgi?id=1094812 and https://bugzilla.redhat.com/show_bug.cgi?id=1029129
I hope this help.
Comment: Actually, the regular expression expects zero or more spaces between the colon and the cluster name. I've tested the regex on `/etc/corosync/corosync.conf` with `grep -E` and it does match. My pcs is indeed `pcs-0.9.115-32.el7.x86_64`, but I wonder what `is_rhel6()` actually returns.
Comment: @MattBianco I updated my answer with more info.


Unable to insert serialized XML Array to Database (MySQLi)

Question: I am trying to integrate a PHP plugin with my web app, but I am stuck with storing the values that I receive from an XML file to a table in my database.
This is what I have so far, but when I run the PHP script it does not save to the database. I have created a table in my database with one column (type=text, name=test)
    global $mysqli;

    $str = serialize($Items);
    printF($str);
    $result = $mysqli->query("INSERT INTO nepremicnine (test) VALUES ('$str');");

Comment: Have you checked your error logs? You're making an assumption the query is working.
Comment: You do have an extra semicolon toward the end of your result statement. Logs would show this. `('$str');");`
Answer: $Items probably contains some strings with single quotes, and this is causing a syntax error when you substitute it into the INSERT query. Use a prepared statement to avoid problems with special characters.
$stmt = $mysqli->prepare("INSERT INTO nepremicnine (test) VALUES (?);");
$stmt->bind_param("s", $str);
$result = $stmt->execute();

Comment: This was correct, sorry for the late approval, but your solution helped me out :)


A doubt regarding KL-divergence for estimating a distribution

Question: Suppose given a probability distribution $q$. I'm trying to estimate it by $p$ such that the KL-divergence between $p$ and $q$ is minimized. Now which one of the two: $KL(p||q)$, $KL(q||p)$ should be minimized and why?
I understand that minimizing one of them will also minimize the other but for EM-like situation the first-one is used. I need some explanation for the same.
Thank you !
Answer: Following the definition given by Wikipedia, if we want to approximate a fixed distribution $Q$ with a tailor-made distribution $P$ we have to minimize
$$ D_{KL}(Q\,||\,P)=\int_\mathbb{R}q(x)\log\frac{q(x)}{p(x)}\,dx.$$
Comment: I got the reason: $KL(q||p) = H(p,q) -H(q)$ where $H(p,q)$ $H(q,p)$ is the cross entropy of $q$ and $p$, and $H(q)$ is the entropy of $q$. Which gives the information lost when $p$ is used to approximate $q$