How to append a domain to a PTR resolution?

Question: I have a bind9 server authoritative for my domain example.com. Forward resolution works, PTRs as well up to a point.
I currently have
254.10.10   IN  PTR srv.

in my PTR zone for 10.x, which correctly resolves to
root@srv ~# dig -x 10.10.10.254
(...)
;; ANSWER SECTION:
254.10.10.10.in-addr.arpa. 604800 IN    PTR     srv.

I would like the resolution to be a FQDN and therefore replaced srv. by srv (removed the dot) in the configuration above, leading to a resolution of
root@srv ~# dig -x 10.10.10.254
(...)
;; ANSWER SECTION:
254.10.10.10.in-addr.arpa. 604800 IN    PTR     srv.10.in-addr.arpa.

How can I inform bind9 to resolve 10.10.10.254 into srv.example.com instead of srv.10.in-addr.arpa?
Note: I know that I could have
254.10.10   IN  PTR srv.example.com.

in my configuration. What I am looking for is how to set the default appended domain.
Answer: As far as I know Bind will only append/substitute the implicit zone name 10.10.10.in-addr.arpa. or the explicit value of $ORIGIN (which usually would also be the zone name 10.10.10.in-addr.arpa.) when the trailing dot . is missing or when the @ shorthand is used.
You will need to use FQDN's and can't use any shorthand.
Or rather you can't expect to use different shorthands to be used for the resource record and it's value.
A typical reverse zone looks like:
$ORIGIN 1.0.10.in-addr.arpa.
$TTL 86400
@     IN     SOA    dns1.example.com.     hostmaster.example.com. (
                    2001062501 ; serial
                    21600      ; refresh after 6 hours
                    3600       ; retry after 1 hour
                    604800     ; expire after 1 week
                    86400 )    ; minimum TTL of 1 day

      IN     NS     dns1.example.com.
      IN     NS     dns2.example.com.

20    IN     PTR    alice.example.com.
21    IN     PTR    betty.example.com.
22    IN     PTR    charlie.example.com.
23    IN     PTR    doug.example.com.
24    IN     PTR    ernest.example.com.
25    IN     PTR    fanny.example.com.

What you can do is change/redefine $ORIGIN - the domain name that gets used/appended to unqualified records, such as those with the hostname and nothing more. You can even change $ORIGIN multiple times...
Although technically this should work as intended it is a very uncommon approach and likely to introduce human error and overall a Bad IdeaTM
The following means that you can't use 25 anymore but will need to use the FQDN  22.214.171.124.in-addr.arpa. as the RR, but you can use short hostnames for the actual hosts.
$ORIGIN 1.0.10.in-addr.arpa.
$TTL 86400
@     IN     SOA    dns1.example.com.     hostmaster.example.com. (
                    2001062501 ; serial
                    21600      ; refresh after 6 hours
                    3600       ; retry after 1 hour
                    604800     ; expire after 1 week
                    86400 )    ; minimum TTL of 1 day

      IN     NS     dns1.example.com.
      IN     NS     dns2.example.com.

$ORIGIN example.com.
126.96.36.199.in-addr.arpa.    IN     PTR    alice
22.214.171.124.in-addr.arpa.    IN     PTR    betty
184.108.40.206.in-addr.arpa.    IN     PTR    charlie
22.214.171.124.in-addr.arpa.    IN     PTR    doug
18.104.22.168.in-addr.arpa.    IN     PTR    ernest
188.8.131.52.in-addr.arpa.    IN     PTR    fanny

$ORIGIN example.co.uk.
18.104.22.168.in-addr.arpa.    IN     PTR    geoff
18.104.22.168.in-addr.arpa.    IN     PTR    honey

Comment: That said, I'd strongly discourage using `$ORIGIN` in this way. It violates the [principle of least astonishment](https://en.wikipedia.org/wiki/Principle_of_least_astonishment) as the new origin will always result in out-of-zone data when used in the left hand side of the record definition. This is particularly egregious when you consider that the target (right hand side) of a DNS record is not always a name, but the left side will *always* be.
Comment: @AndrewB I agree that redefining $ORIGIN  is not a very intuitive thing to do, but AFAIK it **is** allowed but I will add a warning tha it is a bad idea...
Answer: you need to edit /etc/bind/named.conf.local
add your addr PTR zone :

zone "9.0.10.in-addr.arpa" {
type master;
file "/etc/bind/db.10.10.10";
};
create file db.10.10.10
vi db.10.10.10
add this :

$TTL 3D
@       IN      SOA     srv.example.com. root.example.com. (
2       ; Serial
8H      ; Refresh
2H      ; Retry
4W      ; Expire
1D)     ; Minimum TTL
@ IN NS srv.example.com.
254 IN   PTR     srv.example.com.

restart bind9
/etc/init.d/bind9 restart
check with nslookup -q=PTR 10.10.10.254
Comment: My question was not about how to configure PTR resolution at all (it works according to the examples I provided) but how to set a defualt domain name appended on dot-less PTR entries.


Different ways to write interaction terms in lm?

Question: I have a question about which is the best way to specify an interaction in a regression model. Consider the following data:
d <- structure(list(r = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
     1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("r1","r2"),
     class = "factor"), s = structure(c(1L, 1L, 1L, 1L, 1L,
     2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L),
    .Label = c("s1","s2"), class = "factor"), rs = structure(c(1L, 1L,
     1L,1L, 1L,2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L),
    .Label = c("r1s1","r1s2", "r2s1", "r2s2"), class = "factor"),
     y = c(19.3788027518437, 23.832287726332, 26.2533235300492,
     15.962906892112, 24.2873740664331, 28.5181676764727, 25.2757801195961,
     25.3601044326474, 25.3066440027202, 24.3298865128677, 32.5684219007394,
     31.0048406654209, 31.671238316086, 34.1933764518288, 36.8784821769123,
     41.6691435168277, 40.4669714825801, 39.2664137501106, 39.4884849591932,
     49.247505535468)), .Names = c("r","s", "rs", "y"),
     row.names = c(NA, -20L), class = "data.frame")

Two equivalent ways to specify the model with interactions are:
lm0 <- lm(y ~ r*s, data=d)
lm1 <- lm(y ~ r + s + r:s, data=d)

My question is if I could specify the interaction considering a new variable (rs) with the same levels of interaction:
lm2 <- lm(y ~ r + s + rs, data=d)

What advantages/disadvantages have this approach? And why the results from these two approaches are different?
summary(lm1)

lm(formula = y ~ r + s + r:s, data = d, x = TRUE)
            coef.est coef.se
(Intercept) 21.94     1.46
rr2         11.32     2.07
ss2          3.82     2.07
rr2:ss2      4.95     2.92
---
n = 20, k = 4
residual sd = 3.27, R-Squared = 0.87

summary(lm2)

lm(formula = y ~ r + s + rs, data = d, x = TRUE)
            coef.est coef.se
(Intercept) 21.94     1.46
rr2         11.32     2.07
ss2          8.76     2.07   # ss2 coef is different from lm1
rsr1s2      -4.95     2.92
---
n = 20, k = 4
residual sd = 3.27, R-Squared = 0.87

Comment: I guess is related the way in the variables are relationated see `attr(terms(lm1),"factors")` and `attr(terms(lm2),"factors")`
Comment: You mean that `rs` is defined as `interaction(r, s)`?
Comment: Perhaps you could show us the code that created rsr1s2?
Comment: The rs factor was defined manualy (simply paste factors r and s). See the data set.
Answer: The results are different because the way lm sets up the model with the interaction is different from how it is set up when you set it up yourself.  If you look at the residual sd, it's the same, which indicates (not definitively) that the underlying models are the same, just expressed (to the lm internals) differently.
If you define your interaction as paste(d$s, d$r) instead of paste(d$r, d$s) your parameter estimates will change again, in interesting ways.
Note how in your model summary for lm1 the coefficient estimate for ss2 is 4.94 lower than in the summary for lm2, with the coefficient for rr2:ss2 being 4.95 (if you print to 3 decimal places, the difference goes away).  This is another indication that an internal rearrangement of terms has occurred.
I can't think of any advantage to doing it yourself, but there may be one with more complex models where you don't want a full interaction term but instead only some of the terms in the "cross" between two or more factors.
Comment: The approaches are the same, but the exact parameterizations of the model being estimated are different, so the results appear different.  Consider a model with two binary regressors $x_1, x_2$ and an interaction.  You have four categories, but you can write the model several different ways, e.g., let 1 be a constant term, with variables $(1, x_1, x_2, x_1*x_2)$ or $(x_1, x_2, x_1*x_2, (1-x_1)*(1-x_2)$, or others.  The variables are just linear combinations of each other.  The coefficient estimates will be different, but the model is really the same.
Comment: The only advantage I see to define the interactions as in lm2 is that it is easy to perform multiple comparisons for the interaction term. What I do not quite understand is why different results are obtained if, in principle, it seems that the 2 approaches are the same.
Comment: Therefore, although different, both approaches are correct, aren't it?
Comment: Right.  Mathematically the matrices of independent variables in the various formulations are just linear transforms of each other, so the parameter estimates of one model can be calculated from the parameter estimates of another if one knows how the two models were actually set up.
Answer: You might understand this behavior better if you look at the model matrices.
 model.matrix(lm1 <- lm(y ~ r*s, data=d))
 model.matrix(lm2 <- lm(y ~ r + s + rs, data=d))

When you look at these matrices, you can compare the constellations of s2=1 with the other variables (i.e. when s2=1, which values do the other variables take?). You will see that these constellations differ slightly, which just means that the base category is different. Everything else is essientially the same. In particular, note that in your lm1, the coefficient on ss2 equals the coefficients ss2+rsr1s2 of lm2, i.e. 3.82=8.76-4.95, short of rounding errors.
For instance, executing the following code gives you exactly the same output as using the automatic setting of R:
  d$rs <- relevel(d$rs, "r1s1")
  summary(lm1 <- lm(y~ factor(r) + factor(s) + factor(rs), data=d))

This also provides a quick answer to your question: the really only reason to change the way factors are set up is to provide expositional clarity. Consider the following example: Suppose you regress wage on a dummy for high school completion interacted with a factor indicating if you belong to a minority.
That is: $wage =  \alpha + \beta \ edu + \gamma \ edu*minority + \epsilon $
If said minority factor takes value 1 if you do belong to a minority, the coefficient $\beta$ can be interpreted as a wage difference for non-minority individuals who have completed high school. If this is your coefficient of interest, then you should code it as such. Otherwise, suppose the minority factor takes the value of 1 if you do not belong to a minority. Then, in order to see how much more non-minority individuals earn when they complete high school, you would have to "manually" compute $\beta+\gamma$. Note though that all information is contained in the estimates though, and substantial results do not change by setting up the factors differently!
Answer: I think there are good reasons not to use
lm(y ~ r + s + rs, data=d)
When you create rs and put it into the formula, R will think of rs as just another variable, it has no way of knowing that it is an interaction of r and s.
This matters if you use drop1() or stepwise regression.
It is invalid to drop a variable x while keeping an interaction with x in the formula.
R knows this so drop1() will only drop variables that result in valid formulas.
If the formula contains rs, it has no way of knowing that attempting to drop r (or s) is invalid.
d$rs <- paste(d$r, d$s)
lm1 <- lm(y ~ r + s + r:s, data=d)
lm3 <- lm(y ~ r + s + rs, data=d)

drop1(lm1)
Single term deletions

Model:
y ~ r + s + r:s
       Df Sum of Sq    RSS    AIC
<none>              171.05 50.924
r:s     1    30.619 201.67 52.218 # only the interaction term can be dropped

drop1(lm3)
Single term deletions

Model:
y ~ r + s + rs
       Df Sum of Sq    RSS    AIC
<none>              171.05 50.924
r       0     0.000 171.05 50.924 # invalid
s       0     0.000 171.05 50.924 # invalid
rs      1    30.619 201.67 52.218

Incidently I believe the following will all be equivalent
lm0 <- lm(y ~ r*s, data=d)
lm1 <- lm(y ~ r + s + r:s, data=d)
lm2 <- lm(y ~ r + s + r*s, data=d)

The formula parts all get converted into the same formula.


Beautiful Soup returns 'none'

Question: I am using the following code to extract data using beautiful soup:
import requests
import bs4
res = requests.get('https://www.jmu.edu/cgi-bin/parking_sign_data.cgi?hash=53616c7465645f5f5c0bbd0eccccb6fe8dd7ed9a0445247e3c7dcb4f91927f7ccc933be780c6e558afb8ebf73620c3e5e3b2c68cd3c138519068eac99d9bf30e1e67ce894deb3a054f95f882da2ea2f0|869835tg89dhkdnbnsv5sg5wg0vmcf4mfcfc2qwm5968unmeh5')
soup = bs4.BeautifulSoup(res.text, 'xml')
soup.find_all("span", class_="text")

I've tried different variations of the last line trying to get the program to display anything at all but each time it returns "None" or an empty list. The only thing i can get to display is the entire html of the site using: print(soup.contents). The data I am trying to extract is the "Display" tag value within each of the signID tags. The data is clearly there when it prints the entire HTML of the site.
Additional Information: The the number I am trying to extract is the current number of spaces in a parking deck, so the website is updated by the second.
Additional Information 2: This site is an iframe of https://www.jmu.edu/parking/. The data I am after is in the bottom right corner under "commuter parking"
Website URL: https://www.jmu.edu/cgi-bin/parking_sign_data.cgi?hash=53616c7465645f5f5c0bbd0eccccb6fe8dd7ed9a0445247e3c7dcb4f91927f7ccc933be780c6e558afb8ebf73620c3e5e3b2c68cd3c138519068eac99d9bf30e1e67ce894deb3a054f95f882da2ea2f0|869835tg89dhkdnbnsv5sg5wg0vmcf4mfcfc2qwm5968unmeh5
Answer: I can see that you're trying to extract Display tag values under each Sign tags. Hope this helps for you.
Code:
import requests
from bs4 import BeautifulSoup
res = requests.get('https://www.jmu.edu/cgi-bin/parking_sign_data.cgi?hash=53616c7465645f5f5c0bbd0eccccb6fe8dd7ed9a0445247e3c7dcb4f91927f7ccc933be780c6e558afb8ebf73620c3e5e3b2c68cd3c138519068eac99d9bf30e1e67ce894deb3a054f95f882da2ea2f0|869835tg89dhkdnbnsv5sg5wg0vmcf4mfcfc2qwm5968unmeh5')
soup = BeautifulSoup(res.text, 'lxml')
for data in soup.find_all('sign'):
    print(data.signid.text, data.display.text)

Output:
1  442
2  442
3  442
4 Happy Holidays
5 Happy Holidays

I have showed output for 5 values only and this gives 57 signId and Display values.
You can directly use soup.find_all('display') if you want only Display values. I have used signId and Display in the example just for reference.

Beautiful Soup returns 'none'


Second solution to $ \sin(x) - \sqrt{2} \cos(x) = 1$?

Question: I think I'm missing a solution to the following problem:

Solutions to the equation $ \sin(x) - \sqrt{2} \cos(x) = 1$ are....

I get $x = 1.571 \pm 2 n \pi$. This matches the answer in the book I'm using, Engineering Mathematics, 5th Edition, by Stroud.
However, shouldn't there be 2 answers per period? Unlike their previous example, $ 4 \sin(x) - 3 \cos(x) = 5$, this solution isn't at the peak amplitude. I would think there is an additional solution as the function decreases after the peak?
I don't know how to find it if that's the case, or maybe I'm turned all around and thinking about this wrong. What am I missing? Thanks for your help.
Answer: You are correct, there is another solution per period. I found it as follows. Start by squaring both sides to get
$$
(\sin(x)-\sqrt{2}\cos(x))^2 = \cos^2(x) - 2 \sqrt{2} \sin(x) \cos(x) + 1 = 1^2 = 1
$$
Then subtracting 1 from both sides, and dividing by $\cos^2(x)$ (you already found the solution where $\cos(x) = 0$) we have
$$
1 - 2 \sqrt{2} \tan(x) = 0.
$$
Solving then gives $\tan(x) = \sqrt{2}/4$, from which we find the solutions $\arctan(\sqrt{2}/4) + \pi n$. Checking these back in the original equation (we squared so we may have extra incorrect solutions!) we see that these solutions work exactly when $n$ is odd. That is, $x = \arctan(\sqrt{2}/4) + (2n+1)\pi$.
Answer: Let $\tan(x/2)=t$. then
$$\sin x-\sqrt{2} \cos x=1 \implies \frac{2t}{1+t^2}-\sqrt{2} \frac{1-t^2}{1+t^2}=1$$
$$\implies (\sqrt{2}-1)t^2+2t-(\sqrt{2}+1)=0 \implies t=1,-(3+2\sqrt{2})$$ So this equation has two branches of solutions:
$$x/2=\pi/4+n\pi \implies x=\pi/2+2n\pi,n0,1,2,...$$ and
$$x/2=-\tan^{-1}[(3+2\sqrt{2}]+m\pi\implies x=-2\tan^{-1}(3+2\sqrt{2})+2m\pi, m=0,1,2,..$$
$$\implies x\approx -0.89 \pi+2m\pi$$
In $[0,2\pi]$ two roots are $1.57, 3.48,$ when $n=0,m=1.$ See  the Fig. below:
Comment: @Matt L Thanks for your edit.
Answer: $$\sin x-\sqrt2\cos x=\sqrt3\left(\frac1{\sqrt3}\sin x-\sqrt{\frac{2}3}\cos x\right)=\sqrt3\sin\left(x-\arccos\frac1{\sqrt3}\right)$$
Therefore $$\sin x-\sqrt2\cos x=1\iff\sin\left(x-\arccos\frac1{\sqrt3}\right)=\frac1{\sqrt3}$$
In $[0,2\pi)$, this has solutions $$x=\arcsin\frac1{\sqrt3}+\arccos \frac1{\sqrt3}\lor x=\pi-\arcsin\frac1{\sqrt3}+\arccos\frac1{\sqrt3}$$
which are $\frac\pi2$ and $\approx3.481$ respectively. So you're right, one is missing.


Problemas com a nova versão do Meteor por causa do MongoDB

Question: Acabei de instalar a nova versão do meteor 1.4 e estou seguindo o tutorial do Alura. Ocorreu tudo OK na instalação e na inicialização do host:3000 e apareceu as informações do meteor. Porém assim que eu crio uma pasta chamada "models" e insiro um arquivo chamado "tarefas.js" para utilizar o MongoDB ele dá este erro e o server não roda mais. Inseri o mongoDB no patch das Variaveis de ambiente também não funcionou:

Your app is crashing. Here's the latest log:
C:\Users\thiag\AppData\Local.meteor\packages\meteor-tool\1.4.1_2\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:280
                        throw(ex);
                        ^
TypeError: Mongo.Collections is not a function
      at meteorInstall.models.tarefas.js (models/tarefas.js:1:11)
      at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
      at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
      at C:\Users\thiag\Documents\gabarito\tasklist.meteor\local\build\programs\server\app\app.js:13:1
      at C:\Users\thiag\Documents\gabarito\tasklist.meteor\local\build\programs\server\boot.js:292:10
      at Array.forEach (native)
      at Function..each..forEach (C:\Users\thiag\AppData\Local.meteor\packages\meteor-tool\1.4.1_2\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
      at C:\Users\thiag\Documents\gabarito\tasklist.meteor\local\build\programs\server\boot.js:128:5
  Exited with code: 1 Your application is crashing. Waiting for file
  change.
Answer: Tenta usar Mongo.Collection, sem o 's' no final.
Caso você ainda não tenha resolvido, espero que te ajude!


ClassNotFoundException: kotlin.KotlinNothingValueException using Android Studio 4.2 Canary 8 with build.gradle.kts

Question: After updating to Android Studio 4.2 Canary 8 and now getting following error when I do gradle sync. It seems like it's related to using root level build.gradle.kts .....if I switch back to using build.gradle then issue is "fixed"
java.lang.NoClassDefFoundError: kotlin/KotlinNothingValueException
    at com.android.build.gradle.options.BooleanOption.parse(BooleanOption.kt:427)
    at com.android.build.gradle.options.BooleanOption.parse(BooleanOption.kt:28)
    at com.android.build.gradle.options.ProjectOptions$OptionValue.lambda$setValueForUseAtConfiguration$0(ProjectOptions.java:365)
    at org.gradle.api.internal.provider.DefaultProvider.calculateOwnValue(DefaultProvider.java:66)
    at org.gradle.api.internal.provider.AbstractMinimalProvider.getOrNull(AbstractMinimalProvider.java:93)
    at com.android.build.gradle.options.ProjectOptions$OptionValue.getValueForUseAtConfiguration(ProjectOptions.java:345)
    at com.android.build.gradle.options.ProjectOptions$OptionValue.access$000(ProjectOptions.java:331)
    at com.android.build.gradle.options.ProjectOptions.get(ProjectOptions.java:186)
    at com.android.build.gradle.options.SyncOptions.getModelQueryMode(SyncOptions.java:41)
    at com.android.build.gradle.internal.plugins.BasePlugin.createProjectServices(BasePlugin.java:868)
    at com.android.build.gradle.internal.plugins.BasePlugin.basePluginApply(BasePlugin.java:262)
    at com.android.build.gradle.internal.plugins.BasePlugin.lambda$apply$0(BasePlugin.java:246)
    at com.android.build.gradle.internal.crash.CrashReporting.runAction(crash_reporting.kt:27)
    at com.android.build.gradle.internal.plugins.BasePlugin.apply(BasePlugin.java:244)
    at com.android.build.gradle.internal.plugins.BasePlugin.apply(BasePlugin.java:136)
    at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:43)
    at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:51)
    at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:177)
    at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:51)
    at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:272)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.plugins.DefaultPluginManager.lambda$doApply$0(DefaultPluginManager.java:157)
    at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:43)
    at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:156)
    at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:136)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:160)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:42)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:97)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:183)
    at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:49)
    at com.android.build.gradle.AppPlugin.apply(AppPlugin.kt:29)
    at com.android.build.gradle.AppPlugin.apply(AppPlugin.kt:25)
    at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:43)
    at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:51)
    at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:177)
    at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:51)
    at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:272)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.plugins.DefaultPluginManager.lambda$doApply$0(DefaultPluginManager.java:157)
    at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:43)
    at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:156)
    at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:127)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.lambda$applyPlugins$0(DefaultPluginRequestApplicator.java:127)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:176)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.lambda$applyPlugins$1(DefaultPluginRequestApplicator.java:125)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:125)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:121)
    at org.gradle.kotlin.dsl.provider.PluginRequestsHandler.handle(PluginRequestsHandler.kt:48)
    at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator$InterpreterHost.applyPluginsTo(KotlinScriptEvaluator.kt:198)
    at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.applyPluginsTo(Interpreter.kt:360)
    at Program.execute(Unknown Source)
    at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.eval(Interpreter.kt:502)
    at org.gradle.kotlin.dsl.execution.Interpreter.eval(Interpreter.kt:178)
    at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator.evaluate(KotlinScriptEvaluator.kt:120)
    at org.gradle.kotlin.dsl.provider.KotlinScriptPluginFactory$create$1.invoke(KotlinScriptPluginFactory.kt:51)
    at org.gradle.kotlin.dsl.provider.KotlinScriptPluginFactory$create$1.invoke(KotlinScriptPluginFactory.kt:36)
    at org.gradle.kotlin.dsl.provider.KotlinScriptPlugin.apply(KotlinScriptPlugin.kt:34)
    at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:65)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.configuration.BuildOperationScriptPlugin.lambda$apply$0(BuildOperationScriptPlugin.java:62)
    at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:43)
    at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:62)
    at org.gradle.configuration.project.BuildScriptProcessor$1.run(BuildScriptProcessor.java:45)
    at org.gradle.internal.Factories$1.create(Factories.java:26)
    at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:245)
    at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:226)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:42)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
    at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:35)
    at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject$1.run(LifecycleProjectEvaluator.java:102)
    at org.gradle.internal.Factories$1.create(Factories.java:26)
    at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:180)
    at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
    at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withProjectLock(DefaultProjectStateRegistry.java:271)
    at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:265)
    at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:226)
    at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.run(LifecycleProjectEvaluator.java:91)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:63)
    at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:710)
    at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:145)
    at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:36)
    at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:64)
    at org.gradle.configuration.DefaultProjectsPreparer.prepareProjects(DefaultProjectsPreparer.java:61)
    at org.gradle.configuration.BuildOperatingFiringProjectsPreparer$ConfigureBuild.run(BuildOperatingFiringProjectsPreparer.java:52)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.configuration.BuildOperatingFiringProjectsPreparer.prepareProjects(BuildOperatingFiringProjectsPreparer.java:40)
    at org.gradle.initialization.DefaultGradleLauncher.prepareProjects(DefaultGradleLauncher.java:235)
    at org.gradle.initialization.DefaultGradleLauncher.doClassicBuildStages(DefaultGradleLauncher.java:170)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:155)
    at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:131)
    at org.gradle.internal.invocation.GradleBuildController$1.create(GradleBuildController.java:72)
    at org.gradle.internal.invocation.GradleBuildController$1.create(GradleBuildController.java:67)
    at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:180)
    at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
    at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:67)
    at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:56)
    at org.gradle.tooling.internal.provider.runner.ClientProvidedPhasedActionRunner.run(ClientProvidedPhasedActionRunner.java:60)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(BuildOutcomeReportingBuildActionRunner.java:63)
    at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
    at org.gradle.tooling.internal.provider.FileSystemWatchingBuildActionRunner.run(FileSystemWatchingBuildActionRunner.java:52)
    at org.gradle.launcher.exec.BuildCompletionNotifyingBuildActionRunner.run(BuildCompletionNotifyingBuildActionRunner.java:41)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(RunAsBuildOperationBuildActionRunner.java:49)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(RunAsBuildOperationBuildActionRunner.java:44)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:409)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:399)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:94)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:44)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:50)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:47)
    at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:87)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:47)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:31)
    at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:44)
    at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:29)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:87)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:55)
    at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:60)
    at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:38)
    at org.gradle.tooling.internal.provider.SessionScopeBuildActionExecuter.execute(SessionScopeBuildActionExecuter.java:68)
    at org.gradle.tooling.internal.provider.SessionScopeBuildActionExecuter.execute(SessionScopeBuildActionExecuter.java:38)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:37)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:26)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:60)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:32)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:56)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:48)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:32)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:68)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:39)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:29)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:35)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:78)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:75)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:75)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
    at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:63)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: java.lang.ClassNotFoundException: kotlin.KotlinNothingValueException

Comment: Looks like issue has been created for this https://issuetracker.google.com/issues/166468915
Answer: One other workaround (from above issue)
"
Once workaround is to add Kotlin 1.4.0 stdlib to buildSrc e.g update buildSrc/build.gradle.kts with
dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.0")
}

"
Answer: In my case:
I found the org.jetbrains.kotlin:kotlin-test library with any version fails somehow. I use org.jetbrains.kotlin:kotlin-test-junit:1.4.30 on gradle and it passes all fine.
Comment: had the same issue, thanks!


Save File to a remote Url

Question: first of all sorry for my english , not my main lang.
I need to export some data to a remote folder from android.
I have a file on android "file.xml" and i need to export it to a folder (under iis)
"http://192.168.x.xx/folder/fileuploaded.txt"
It seems most of the examples out there are using an upload script in php, but i need to do it only from android. Doing the opposite way (from remote url to android app) is easy with Url.openStream(), but i cannot find a working example to put back the file on the server.
Maybe im missing something, this is my first android (and java btw) app.
anyone could point me in the right direction?
Thanks!
Answer: Diego, what you are trying to achieve is not possible only from Android. You cannot put a file on the server using HTTP unless there is a receiving application running.
You can only post your binary data to the server (url) but to write it locally and make it available on the http again for download, can only be done if you have a server app. It could be created using any language PHP, JSP, ASP etc.
Comment: Thanks! I'm going to try doing it with a SOAP web service. Time to Study :)
Answer: You cannot just upload files to server of your wish unless there is something on the server side that allows file uploads. That is usually a ASP/Perl/PHP script.
If you don't want to use such a script, then one way to do this is to run ftp on your server and upload files using that.

Save File to a remote Url


Why can't I see my full rbindlist result?

Question: I used the rbindlist() function to try and merge two melted data frames (means_melt and means_melt_50). I'm wondering why it comes up with the break in the data? And whether I can use the whole list as I ultimately intend to create two graphs, each with 5 sets of data (grouped by variable), and using facet_grid(). I want the two graphs separated based on "Accuracy".
> compiled_means <- list(means_melt, means_melt_50)
> rbindlist(compiled_means, use.names = TRUE, fill=FALSE, idcol = NULL)
             Divisions Accuracy variable value
   1:         1        0        mean20    16
   2:         2        0        mean20    20
   3:         3        0        mean20    21
   4:         4        0        mean20    17
   5:         5        0        mean20    20
   ---
  196:        16       50       mean_2     2
  197:        17       50       mean_2     2
  198:        18       50       mean_2     2
  199:        19       50       mean_2     4
  200:        20       50       mean_2     3

If anyone has a more efficient way for me to format the data so that it can be put in the  graphs I want, I'm happy to hear suggestions. I'm not sure if the route I'm taking if effective or long-winded...
Comment: You might want to replace one of those tags with [tag:data.table], since it's the package that rbindlist comes from. Similarly, I'm sure `facet_grid` comes from some package you are not mentioning.
Comment: Anyway, your answer is in the FAQ for the package, item 2.11: https://github.com/Rdatatable/data.table/wiki/Getting-started
Comment: Thank you - I didn't actually know that these existed. I knew it would be something simple!
Answer: Simply a matter of preferences and options - by default the function shows a summary of data.tables that have >100 rows. The following direct print gives the full data table.
print(your.data.table, nrows = Inf)

https://rawgit.com/wiki/Rdatatable/data.table/vignettes/datatable-faq.html#only-the-first-10-rows-are-printed-how-do-i-print-more


subalgebras and finitely generated modules

Question: Let $A$ be a $k$-algebra, $B$ be a subalgebra of $A$, and $K$ be a left ideal of $B$ which is finitely generated as a $B$- module. Is $AK$ necessarily a finitely generated $A$-module?
Comment: I wrote $K=Bk_1+Bk_2+\cdots+Bk_n$, and so I could write each element in $AK$ as $ab_1k_1+\cdots+ab_nk_n$. I am not to sure if I am done here though, or I may have missed out something.
Answer: Every element from $AK$is of the form $\sum_ia_ix_i$ where  $a_i\in A, x_i\in K$. Then write $x_i$ as in your comment: $x_i=\sum_j b_{ij}k_j$ and you will get the desired.
Comment: @ Babak S.: Sorry, I am not sure I could use chat. Would you like to use e-mail?
Comment: I sent my question. :-)


Understanding this hypothesis testing exercise using P-value

Question: The exercise states that:

Your team evaluates a new cannon ball and compares its distance
performance to a new ball from your competitor. In an initial
evaluation you test 10 of your new cannon balls and 10 of the
competitor's balls with the goal of determining if the average
distance in yards travelled by your new ball is greater than the
average distance travelled by the competitor's ball. The resulting
data is shown below. You might assume equal variances when using a
statistical test. Which one of the following statements is correct?

The properly calculated P-value is in the range 0.15 < P <0.45. You have statistical evidence that your new ball travels farther on
average than the competition's ball.

None of the statistical hypothesis tests discussed are appropriate
for the analysis of this data.

The properly calculated P-value is in the range 0.075 < P< 0.25. No evidence is found that your new ball travels farther on average
than the competition's new ball.

A statistical hypothesis test cannot be applied in this case, because we have less than 12 data points for each type of ball.

Competitor ball
My new ball

341.0
314.2

308.2
315.0

314.0
354.2

306.4
301.2

291.7
327.8

333.1
332.0

314.2
320.5

318.0
314.6

301.6
321.3

319.0
311.1

I'm using Minitab, Two-Sample t for the Mean for this exercise. My question is about what the right interpretation is for the alternative hypothesis. It could be u1-u2 ≠ 0 or u1-u2 < 0 which means u2 (my ball's mean) is greater than u1 (competitor's ball mean).
If u1-u2 ≠ 0 then P value = 0.330 and the answer is option (1).
If u1-u2 < 0, then P value = 0.165 but this does not really fit the options.
Answer: I put your data into R. Both Welch and pooled 2-sample t tests
gave $T\approx -1,$ and P-value about $0.168 > 5\%$ for a one-sided test
that your cannon balls go farther than your competitor's.
This is in agreement with your first block of Minitab output
and with item (3) in your multiple-choice list.
I think the question is poorly worded, but decipherable, and don't
understand why you did not choose response (3). Please leave a note
if you need further clarification.

DTA = matrix(c(
341.0,  314.2,
308.2,  315.0,
314.0,  354.2,
306.4,  301.2,
291.7,  327.8,
333.1,  332.0,
314.2,  320.5,
318.0,  314.6,
301.6,  321.3,
319.0,  311.1), byrow=T, ncol=2)

t.test(DTA[,1], DTA[,2], alt="less")

        Welch Two Sample t-test

data:  DTA[, 1] and DTA[, 2]
t = -1.0017, df = 18, p-value = 0.1649
alternative hypothesis:
  true difference in means is less than 0
95 percent confidence interval:
     -Inf 4.730536
sample estimates:
 mean of x mean of y
    314.72    321.19

Boxplots and stripcharts show variability too large to distinguish
a significant difference in sample locations.
boxplot(DTA, col="skyblue2", pch=20, horizontal=T)

stripchart(list(DTA[,1], DTA[,2]), pch="|", ylim=c(.5,2.5))

Comment: @Jim (1) _statistical evidence_ vs (3) _no evidence_ . Using a p-value less than 5% to assert "statistical evidence", there is no evidence here, choice (3).
Comment: Understood. Thank you!
Comment: I also believe the question is poorly worded. My confusion comes because P = 0.168 falls in both ranges of items (1) and (3)


Add days to a Java textfield through combobox

Question: LINK TO GUI IMAGE HERE -------> https://i.stack.imgur.com/b9qyc.jpg
public class MainMenu extends javax.swing.JFrame {

public MainMenu() {
    initComponents();
    cmbRoomNumber.setEnabled(false);
    jPanel1.setVisible(false);
    btnBook.setEnabled(false);
    //SETTING COMBOBOXES TO NONE
    cmbPhotoId.setSelectedIndex(-1);
    cmbStayDuration.setSelectedIndex(-1);
    //LABELS VALIDATION
    jlblNameVer.setVisible(false);

    //SETTING DATE TODAY
    Date now = new Date();
    //Set date format as you want
    SimpleDateFormat sf = new SimpleDateFormat("dd/MM/yyyy");
    this.ftxtCheckinDate.setText(sf.format(now));

}

As you can see i want to add days to Check-out Date(ftxtCheckOutDate) depending on how many days selected in the combobox(cmbStayDuration)
Im using netbeans JFrame
Thanks :)
private void cmbStayDurationActionPerformed(java.awt.event.ActionEvent evt) {

}

Answer: Calendar c = Calendar.getInstance();

c.setTime(new Date());

c.add(Calendar.DATE, combobox number);

Basically Calendar class has a function to add days.
Get the date now, get the combo box day, then add it.
For example:
 public static void main(String[] args) {
    // TODO code application logic here

    Calendar c = Calendar.getInstance();
    Date d = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

    c.setTime(d);
    System.out.println(sdf.format(c.getTime()));

    c.setTime(d);
    c.add(Calendar.DATE, 10);
    System.out.println(sdf.format(c.getTime()));

}

Output:
05/11/2015
15/11/2015

As for changing the value of Check-out Date form as the ComboBox changes, you can add either an ActionListener to listen to it change.
Example


Trouble accessing Json from Web API call in ADF and inserting in SQL table

Question: I have a REST API that I use to extract the data.
I am using Azure data factory to do that by using web component and then taking that Json output and using Stored Procedure and trying to insert into database table.
When i do the test in SQL with sample Json it works fine, where as json that's coming from WEB call in ADF has the "" in front of each node value like below.
[{\"company_id\":\"test\",\"condition_assessments_ID\":\"SON-testMOTION-SON-MOTION ANALYSIS - SMA & test-2022-04-27@10_00_00\"}]

And i think because of that i was getting error like

"Execution fail against sql server. Sql error number: 13609. Error Message: JSON text is not properly formatted. Unexpected character 'S' is found at position 0."

This is one issue and to avoid it so i was converting the Json as string and which is putting more back slashes and its not helping.
How to preserve the json formatting so its straight forward for a stored proc to insert it?
Answer: Escape character backslash \ appears wherever double quotes are present in the Azure data factory.
Even though the Stored procedure input is shown with a backslash, when data is loaded to Sink (SQL Table) it removes backslashes and data is inserted in JSON format.
I have repro'd in my lab with sample API data and was able to load as expected.

Web activity output:

Pass output of web activity to stored procedure parameter by converting it to string. Here I am only passing the data part from the output.

@string(activity('Web1').output.data)

Stored procedure Input:

SQL table data after the stored procedure is run:


A limit property on sequences

Question: Like the D'Alembert test case for convergence of series I have seen something similar for sequences in my math homework which required proof for this:
If we have a sequence $a_{n}$ such that $\space\lim_{n\rightarrow \infty}|\frac{a_{n+1}}{a_{n}}|<1$ then $\space\lim_{n\rightarrow \infty}a_n=0$.
How can I prove something like this without using the concept of convergency for series ? ( i.e. just using the Cauchy definition of the limit of a sequence) I have been trying to show that $|a_{n}|$ is a decreasing sequence but I don't know how to go further.
Comment: https://math.dartmouth.edu/archive/m8w10/public_html/m8l08.pdf
Answer: Suppose we already know that $q^n \to 0$ if $|q| < 1$. If this is unclear, leave a comment and I'll post a proof for this as well.
If $\lim \left\vert \frac{a_{n+1}}{a_n} \right\vert < 1$, then there exists some $0 < c < 1$ and some $n_1 \in \mathbb N$ such that
$$\left\vert \frac{a_{n+1}}{a_n} \right\vert < 1 - c$$
for all $n \geq n_1$.
Now let $\varepsilon > 0$. Since $(1-c)^n \to 0$, there exists some $n_2$ such that
$$(1-c)^n < \frac{\varepsilon}{|a_{n_1}|}$$
for all $n \geq n_2$. Hence, for all $n > n_1 + n_2$, we have
$$|a_n| = \left\vert a_{n_1} \right\vert \cdot \left\vert\frac{a_{n_1+1}}{a_{n_1}} \right\vert \cdot \ldots \cdot \left\vert\frac{a_n}{a_{n-1}} \right\vert < |a_{n_1}| \cdot (1-c)^{n - n_1} < |a_{n_1}| \cdot \frac{\varepsilon}{|a_{n_1}|} = \varepsilon$$
because $n-n_1 > n_2$.
So, what have we shown? For any $\varepsilon > 0$ there exists $N \in \mathbb N$ such that
$$|a_n| < \varepsilon$$
for all $n \geq N$. Hence, $|a_n| \to 0$ and it is not hard to see that this implies $a_n \to 0$ as well.
Comment: Thanks, this is really helpful.

A limit property on sequences


How to access span id in code behind

Question: I have an asp website with the following control:

        + Show Expired Continuing Education

I want to hide this based on a condition set in the code behind. Can I access a span id like that? (the website is built using visual basic)
Answer: You can use a Label instead of a html-span (which is also rendered as span) or you could add runat="server". Setting runat="server" allows you to access the HTML element in the code behind just as any other server control, via its ID.

somewhere in codebehind(the span is a HtmlGenericControl on serverside):
expTrainingShow.InnerHtml = yourText ' set the text '

or
expTrainingShow.Visible = False ' hide it '

Note that Visible=False on serverside means that the control is not rendered at all on clientside, hence it does not exist in the html and can be accessed only on serverside.
If you just want to hide it but render it anyway, you should use CSS or expTrainingShow.Style.Add("display","none").
Comment: You can use `runat=server` and use it as any other html control. But note that it won't be rendered at all on clientside if you set `Visible=False` (see my edit). I you just want to hide but render it, you should use css or `expTrainingShow.Style.Add("display","none")`.
Comment: We need the onlick function to run client side. Will adding runat="server" interfere with the method or just the span id display?
Comment: I just need it to work when it is visible. You are saying that as long as it is visible the onclick method (some simple clientside javascript at the top of the page) will be executed client side?
Comment: You can use  it as any other html control, so on clientside the `runat=server` does not exist and javascript works also.
Comment: What is the corresponding .net control for HTML label and span from the System.Web.UI.HtmlControls namespace? I couldn't find any in the class collection - there are for inputs with all their associated types (text, button, radiobuttons, etc) but nothing for spans and labels. Any clue? Well what I need in fact is to be able to get the corresponding control type programatically (eg. Control c; if (c is HtmlLabel) {c.innerText = "something"} ;
Comment: @Sergiu:  `span` and `label` are  `HtmlGenericControl` at serverside if you make them `runat=server`.

How to access span id in code behind


execute terminal command within jsp application

Question: I am developing a web application in jsp. At some point I have to execute the following terminal command within the application (code behind, of course).
java -jar rdfslice_1.42.jar -source test.nt -patterns "{?s ?p ?o}" -out output.out -order "S"

Any help will be highly appreciated.
Thanks in advance
Emrah
Comment: `ProcessBuilder` can help you.
Answer: It simply works as
Runtime.getRuntime().exec(COMMAND);

ProcessBuilder also works.


Powers of a function being analytic

Question: Question is as follows :
Suppose that $f:\mathbb{C}\rightarrow \mathbb{C}$ is continuous such that $f^3,f^4$ are analytic in $\mathbb{C}$ then prove that $f$ is analytic in
$\mathbb{C}$..
Choose $z_0\in \mathbb{C}$. Suppose that $f(z_0)\neq 0$. As $f$ is continuous, in a nbd around $z_0$ the value of $f$ is nonzero.
So, $f^4(z)/f^3(z)=f(z)$ in a small open ball centered at $z_0$.. So, $f$ is analytic at $z_0$.
Suppose $z_0$ is such that $f(z_0)=0$ then we can not say that $f^4(z)/f^3(z)=f(z)$ for all $z$ in a small open ball around $z_0$ as $f(z_0)=0$ we can not cancel.
But then we can certainly say that there is a ball where $f(z)$ is non zero except at $z_0$. Then in this ball we do have that $f^4(z)/f^3(z)=f(z)$. So, $f(z)$ is analytic in punctured disk around $z_0$.
I some how feel that function being analytic on punctured disk and function being continuous imply that function is analytic..
Could not figure out the proof for my supposedly correct statement.
As $f$ is analytic on punctured disk around $z_0$ we have laurent expansion for $f(z)$ as
$$f(z)=\cdots+\frac{a_{-2}}{(z-z_0)^2}+\frac{a_{-1}}{z-z_0}+a_0+a_1(z-z_0)+a_2(z-z_0)^2+\cdots$$
Suppose there is atleast one coefficient of $\dfrac{1}{z-z_0}$ that is non zero, then $|f(z)|\rightarrow \infty$ as $z\rightarrow z_0$..
But then, it is given that $f(z)$ is continuous.. continuous function on compact set is bounded so $f(z)$ has to be bounded on the disk where as we have $|f(z)|\rightarrow \infty$ if atleast one coefficient of negative powers of $(z-z_0)$ is non zero. So, this says all negative powers coefficients are zero..
So, we have $f(z)=a_0+a_1(z-z_0)+a_2(z-z_0)^2+\cdots$ in a nbd around $z_0$.
Could not deduce anything from here.
I think i am very close to final answer but could not see it immediately.
Comment: @CameronWilliams : Thanks for showing interest in my question.. So, we define $g(z)=f(z)$ for $z\neq z_0$ and $g(z_0)=\lim_{z\rightarrow 0}f(z)$ then $g$ is analytic.. But then, $f$ is continuous so $\lim_{z\rightarrow z_0}f(z)=f(z_0)$ so, we have $g(z)=f(z)$ for $z\neq z_0$ and $g(z_0)=\lim_{z\rightarrow z_0}f(z)=f(z_0)$.. So, $f(z)$ is actually equal to $g(z)$.. So, $f(z)$ is analytic..
Comment: The result is actually true if we assume only $f$ is continuous and $f^3$ is analytic
Comment: @zhw. : Is that so? How?
Answer: "I somehow feel that function being analytic on punctured disk and function being continuous imply that function is analytic.."
Yes, that's true. Actually:
Suppose that $ \varnothing \neq \Omega \subset \Bbb C$ is an open convex set and let $z_0 \in \Omega$. If $f$ is continuous on $\Omega$ and $f$ is holomorphic on $\Omega \setminus \{z_0\}$, then $f$ is holomorphic on $\Omega$.
Proof:
Let $a \in \Omega$ and define:
$$F(z) = \int_{[a,z]} f(\xi) d\xi$$
Let $\eta \in \Omega$ and let $\epsilon > 0$. The continuity of $f$ gives a $\delta > 0$ such that $|z - \eta| < \delta \implies |f(z) - f(\eta)| < \epsilon$. Now let $z$ be such that $0 < |z - \eta| < \delta$. Then, where in the first step we will use Cauchy's theorem for triangles:
$$\left|\frac{F(z) - F(\eta)}{z - \eta} - f(\eta) \right|= \left| \frac{\int_{[\eta, z]} f(\xi) d\xi}{z - \eta} - f(\eta) \right| \\ = \left|\frac{\int_{[\eta, z]} (f(\xi) - f(\eta))d\xi}{z - \eta}\right| \\ \le \frac{\int_{[\eta, z]} |f(\xi) - f(\eta)|d\xi}{|z - \eta|} \le \max_{\xi \in [z, \eta]} \{|f(\xi) - f(\eta)| \}< \epsilon$$
Comment: Can you give some reference for the statement aboyt $F'=f$..
Comment: @topgeomj I think that this result is called "Cauchy's theorem for a convex set"
Comment: I will check that.. thanks :)
Comment: @topgeomj you're welcome. I provided a proof anyway.
Answer: You could also use Riemann's removable singularity theorem: If $f$ is bounded and analytic in $\{0<|z-a|<r\},$  then  f  has a removable singularity at $a.$

Added in response to comment: Suppose $f$ is continuous on $\mathbb C$ and $f^3$ is analytic on $\mathbb C.$ Then $f$ is analytic on $\mathbb C.$
Proof: Suppose $f(a) \ne 0.$ We have
$$\frac{f(z)^3 -f(a)^3}{z-a} = \frac{f(z) -f(a)}{z-a} \cdot [f(z)^2 + f(z)f(a) + f(a)^2].$$
Now $f$ is continuous at $a,$ so for $z$ close to $a,$ the term in brackets is nonzero, and has limit $3f(a)^2.$ It follows that
$$\frac{(f^3)'(a)}{3f(a)^2}=f'(a).$$
Thus $f'(a)$ exists on the open set where $f\ne 0.$ You handle the case $f(a) = 0$ as already discussed.
Comment: you have suggested that there is a more strong result... $f$ is continuous and $f^3$ is analytic then $f$ is analytic. Can you help me to see that...
Comment: Oh.. This is great.. So, the other condition is unnecessary.. I remember using this kind of trick in some other question.. I will let you know if i recall... Thanks again..
Comment: http://math.stackexchange.com/questions/1734399/power-of-a-function-is-analytic is link of the question i was mentioning in last comment... So, why did they give that $f^4$ is analytic? Can we ignore the condition that $f$ is continuous?

Powers of a function being analytic


MVC and fail AJAX call

Question: I have a controller method:
    public async Task SaveRouting(string points, int tripId, decimal totalMileage)
    {
        if (Request.IsAjaxRequest())
        {
            //....
            await _serviceTrip.UpdateTotalMileageAsync(tripId, totalMileage);
        }
        else
            throw new Exception("Only ajax calls are allowed");
    }

so, as we can see, this method returns Task, so nothing to client. But if something wrong (i.e. totalMileage is less or equal 0) I want to return 422 status code and dictionary with invalid data, like:
{ "totalMileage" : "Total mileage should be greater than 0" }
How to do it?
I try to do it:
            if (totalMileage <= 0)
            {
                Response.StatusCode = 422; // 422 Unprocessable Entity Explained
            }

but how to describe an error?
Comment: why not returning `Task` ?
Comment: @derloopkat how to describe errors in this case?
Comment: your task has no return statement, and anyway it should be returning some sort of response object or data, not just Task - you can't serialise a Task to JSON. Lots of tutorials and example online which would give you sample code to structure it correctly.
Comment: @OlegSh, one option is returning http error and add details as response headers.
Answer: If you want to describe the error after setting Response.StatusCode, then you have to write into the body of the http response by calling Response.Body.Write(byte[],int, int).
Therefore, you can convert your response message to a byte array using the following method:
public byte[] ConvertStringToArray(string s)
{
    return new UTF8Encoding().GetBytes(s);
}

And then use it like this:
byte[] bytes = ConvertStringToArray("Total mileage should be greater than 0");
Response.StatusCode = 422;
Response.Body.Write(bytes,0,bytes.Length);

But you can further simplify this using extension methods on ControllerBase

MVC and fail AJAX call


Can a server in any case request a client for any service?

Question: Can a server in any case request a client for any service?
Answer: How can a server request a client for a service? Its a client that will request the server for a service.
Well what exactly is your question? Can you add more details?
Comment: Unless we're talking about X11, in which case client means server and server means client...
Answer: If you are taking in respect of web application then no. Server will always provide response for any request made by the client.
Answer: What you can do is install some type of plug in or active x object on the client that runs on the client, and sends information back to the server.  However, there are security concerns there.  In any case, it is not the server requesting anything, it is the client that runs an application and then connects to the server again.
If you can be more clear about what you need to accomplish I think you will get a clearer answer.


What happens if kicks from the penalty mark are drawn indefinitely?

Question: In football, what is the rule when both the team score equally indefinitely in kicks from the penalty mark?
Do they keep going and going or will they toss or something to decide the winner?
Comment: Partially relevant: `... the longest penalty shoot-out in a first-class match is 48 penalties during the 2005 Namibian Cup  ...` https://en.wikipedia.org/wiki/Penalty_shoot-out_(association_football)#Records
Answer: Yes, they will continue, even if all players have taken a penalty kick. The procedure is described e.g. here on Wikipedia:

If after five rounds of kicks the teams have an equal number of successful kicks, additional rounds of one kick each will be used until one team scores and the other misses. This is known as sudden death.
Answer: The Laws Of The Game are unambiguous. Law 10.3, Kicks from the penalty mark, says

If, after both teams have taken five kicks, the scores are level, kicks continue until one team has scored a goal more than the other from the same number of kicks

There is no exception and no other criteria. The game ends when one team has scored more than the other, no matter how long that takes. Competitions are not permitted to choose any other methods except those in the laws, so changing the process would be illegitimate:

National FAs have the option to approve different modifications for different competitions - there is no requirement to apply them universally or to apply them all. However, no other modifications are allowed without the permission of The IFAB.

emphasis in original.


Close FTP connection with ncftpput command line

Question: I have a bash script to make backup from server to FTP. The backup does in a few minutes, but the FTP connection is still active for 20 hours.
How can i close it?
The important line is:
<code>CMD="ncftpput -R -v -u "user" -p "password" -P 21 remotehost.com /localdir"
</code>
So, i have read in documentation that i can close connection with "close" command, but, how can i put it to close after the backup it's done?
Thanks!
Answer: Look to -X (if you transfer only one file) or -T options.


A modification of a theorem on the concept of elementary family in Folland's real analysis book

Question: In Real Analysis by Folland, an elementary family $\mathscr E$ on a set $X$ is defined to be a collection of subsets of $X$ such that it containes the empty set, it is closed under finite intersection, and the complement of any $S\in \mathscr E$ is a disjoint union of sets in $\mathscr E$.
Folland proves that the collection $\mathscr A$ of finite disjoint unions of sets in $\mathscr E$ forms an algebra, but his proof indeed works even if we assume that $\mathscr A$ is just the collection of finite union of, not necessarily disjoint, sets in $\mathscr E$. Am I correct? If so, why does he assume the extra condition of disjointness?
Answer: The collection of finite unions and finite disjoint unions of sets from $\mathcal E$ turn out to the same. He could have defined $\mathcal A$ without the disjointness condition.
Comment: So I was correct, thanks

A modification of a theorem on the concept of elementary family in Folland’s real analysis book


Questions about union of conjugates and index of subgroup.

Question: For the following question:

Let $G$ be a group and $H$ be a subgroup of $G$.  Prove that $|\cup_{a\in G} a^{-1}Ha|\leq 1 + |G| - [G:H]$

What do conjugates have to do with $[G:H]$?  I just learn about the definition of what a conjugate is.  I have not learn about the class equation.  I try looking up from other abstract algebra text, and I was not able to find anything related to this question in the section related to the class equation.  The question is taken from question 20 of chapter 8's supplementary exercises from the book A First Course in Group Theory by Bijan Davvaz,
Thank you in advance
Answer: You ask:

What do conjugates have to do with $[G:H]$?

Well, the number of conjugates of $H$ is $[G:N_G(H)]$, the index of the normalizer of $H$ in $G$.
Since $H \leq N_G(H) \leq G$, you get $[G:H] = [G:N_G(H)][N_G(H):H]$. So that is one answer to your question.
In particular, the number of conjugates is $\leq [G:H]$. As a hint, you can use this fact to prove inequality in the question.
Comment: The fact that $[G:N_G(H)]$ is the number of conjugates should be in any basic group theory text. This is also a special case of the orbit-stabilizer theorem. Look at e.g. Rotman, Introduction to the Theory of Groups, Chapter 3, section on $G$-sets.
Comment: do you have any reference concerning the relation between conjugates, normalizer and centralizer in terms of counting principles.  I see that in most abstract algebra texts, there are lots of properties listed for cosets, but not so much for conjugates.  I think that is one of the reasons why I have difficulty with this question.  Also, as far as how normalizer, centralizers, conjugates, orbits, etc relate to each other in terms of the topic of counting.  It seems that other than the class equation, there is not much that are talked about in many beginning algebra texts.
Comment: ah kk.  Thank you for the reference.
Answer: And one more hint:
$$
\bigcup_{a\in G}a^{-1}Ha=\left(\bigcup_{a\in G}(a^{-1}Ha\setminus\{1\})\right)\cup\{1\}.\tag1
$$
Addition.
All the hints required to solve the problem:

Formula $(1)$.

The number of different subgroups of the form $a^{-1}Ha$ is not larger than the index $|G:H|$.
(This follows from the simple statement: If $Ha=Hb$, then $a^{-1}Ha=b^{-1}Hb$.)

Lagrange's theorem $|G|=|H|\cdot|G:H|$.
Comment: Note that $1$ is removed from each subgroup $a^{-1}Ha$, but added only once. To emphasize this I added one more pair of brackets to the formula.
Comment: what is the intuition behind $a^{-1}Ha\setminus\{1\}$?  I see that you add it back too.  As I asked spin, I can't find any good algebra texts that talks about properties of conjugates the way cosets are discussed.
Comment: can I ask if this topic is part of which group theory topic in introductory abstract algebra course?  Does it have to do with the orbit stabilizer theorem or class equation.  When you are subtracting the identity element from each conjugate element, aren't you subtracting too much by only adding back the identity back only once.  I can't separate cosets and conjugate elements in the sense I don't know if all the properties for cosets carry over to conjugate elements.
Comment: @Seth  I expanded my answer a little bit (no normalizers or centralizers are required).
Comment: so conjugate elements are like cosets, meaning they partition a group the way coset does.  Also, does it have to do with the following problem:   Let $G$ be a finite group, and let $H\leq G.$  Assume that $\bigcup_{g\in G}g^{-1}Hg=G$.  Show that $|G|\leq 1 + |G:N_{G}(H)|(|H|-1).$
Comment: Or in an equivalent formulation in another text: If $H\neq G$ is a subgroup of a finite group $G$, show $G\neq \bigcup_{g\in G}g^{-1}Hg$.  Hint:  Reduce to the case of $H$ not normal so that $|G/N_{G}(H)|\geq 2,$  Show that the number of distinct sets of the form $g^{-1}Hg$ is $|G|/|N_{G}(H)|$ and show that $\bigcup_{g\in G}g^{-1}Hg\leq 1+(|H-1|)(|G|/|N_{G}(H)|)$
Answer:
What do conjugates have to do with $[G:H]$?

$G$ acts by left multiplication on the left quotient set $G/H$, whose size is $[G:H]$, and the pointwise stabilizer of $aH\in G/H$ is precisely the conjugate to $H$ by $a$, namely $aHa^{-1}$.


Show that $Z_t = Z_0 \exp\left( \mu t + X_t \right)$ is well defined where $X_t$ is a Jump process (Lévy process)

Question: Consider $X= \left( X_t \right)_{t\geq 0}$ is a Lévy process whose characteristic triplet is $\left(  \gamma,  \sigma ^2, \nu \right)$ and where its Lévy measure is
$$ \nu \left( dx\right) = A \sum_{n=1} ^{\infty} p^n \delta_{-n} \left( dx \right) + Bx^{\beta-1}\left( 1+x \right)^{-\alpha -\beta}e^{-\lambda x } \mathbf{1}_{\left ]0,+\infty \right[}\left( x\right)dx.$$
I'd like to know how to show that $Z_t = Z_0 \exp\left( \mu t + X_t \right)$ is well defined and admits first and second order moments.
I'm kind of lost here. I don't see what is the problem with this definition. Could someone please enlighten me ?
Must I show that $Z_t < \infty \  a.s.$ ?
Or maybe aplly Itô-Lévy lemma for derive the SDE $Z_t$ satisfies and so conclude that it's well defined as the unique strong solution of this SDE?
Or maybe another thing I've not even think about?
Comment: (1.) $\delta_n$? (2.) Surely you have (been given) some hints?
Comment: @did: (1) it's $\delta_{-n}$ actually. (2) I'm really not familiar with lévy process so I don't see the definition problem of $Z_t$. Could you please enlighten me?
Comment: @Did : Can you help me ? This question had no too much attention.  I'll appretiate your enlightement
Answer: Let us look at the simple case where $\gamma=\sigma^2=B=\mu=0$ and $A=Z_0=1$. By definition of the Lévy measure $\nu$, for every real number $\theta$,
$$
\mathbb E(\mathrm e^{\mathrm i\theta X_t})=\exp\left(t\int_{\mathbb R\setminus\{0\}}(\mathrm e^{\mathrm i\theta x}-1-\mathrm i\theta x\mathbf 1_{|x|\lt1})\,\nu(\mathrm dx)\right),
$$
thus,
$$
\mathbb E(\mathrm e^{\mathrm i\theta X_t})=A(\mathrm i\theta),\qquad A(z)=\exp\left(t\sum_{n\geqslant1}p^n(\mathrm e^{-nz}-1)\right).
$$
The function $A$ is analytical on the disk $D=\{z\in\mathbb C\mid |z|\lt-\log p\}$ hence there exists some complex sequence $(A_n)_n$ such that, for every $z$ in $D$,
$$
A(z)=\sum_{n\geqslant0}A_n\frac{z^n}{n!}.
$$
Differentiating $2n$ times the identity $\mathbb E(\mathrm e^{\mathrm i\theta X_t})=A(\mathrm i\theta)$ with respect to $\theta$ at $\theta=0$ yields $\mathbb E(X_t^{2n})=A^{(2n)}(0)=A_{2n}$. This proves that, for every $z$ in $D$, $\mathbb E(\cosh(zX_t))$ converges, hence $z\mapsto\mathbb E(\mathrm e^{zX_t})$ is analytic on $D$, and equal to $A$ there. Thus, for every real number $\theta$ such that $|\theta|\lt-\log p$,
$$
\mathbb E(\mathrm e^{\theta X_t})=\exp\left(t\sum_{n\geqslant1}p^n(\mathrm e^{-\theta n}-1)\right).
$$
For example $\mathrm e^{X_t}$ and $\mathrm e^{-X_t}$ are integrable if $p\lt\mathrm e^{-1}$. What happens if $p\geqslant\mathrm e^{-1}$ is that the jumps of length $-n$ for $n\geqslant1$ generated by the discrete part of $\nu$ are too numerous hence $X_t=-\infty$ almost surely, for every $t\gt0$.
The proof when one includes the continuous part of $\nu$ on $(0,+\infty)$ is similar but the final result might depend on a balance between the parameters $p$ and $\lambda$ which describe the behaviour of $\nu((-\infty,-x))$ and $\nu((x,+\infty))$ when $x\to+\infty$ since $\nu((-\infty,-x))=p^{x+o(x)}$ and $\nu((x,+\infty))=\mathrm e^{-\lambda x+o(x)}$.
Comment: It's $\delta_{-n}$ not $\delta_n$. So at the end you should have $
\mathbb E(\mathrm e^{\theta X_t})=\exp\left(t\sum_{n\geqslant1}p^n(\mathrm e^{-\theta n}-1)\right).
$. Of course $p \in (0,1)$, but I forgot to say. Also, $A,B, \lambda, \mu \geq$
Comment: Most important, I didn't get why and how have you past from the expected value of Fourier trasformation for Laplace's one. Could you please detail it formally? Thank you in advance!
Comment: See Edit. $ $ $ $
Comment: Thank you very much for your answer. It really helps me to understand it all.


Mostrar todos os dias entre duas datas

Question: Preciso exibir todas as datas que existem entre duas datas definidas.
Não preciso das informações da diferença entre essas datas, nem de dados que estejam no intervalo entre elas e sim exibir as datas referentes a cada dia do intervalo.
Exemplo:
Data de inicio: 01/07/2015
Data de fim: 05/07/2015
Resultado:
01/07/2015
02/07/2015
03/07/2015
04/07/2015
05/07/2015

Answer: Pelo que entendi na sua pergunta a data 30/07/2015 não entraria, sendo que o resultado seria:
01/07/2015
02/07/2015
03/07/2015
04/07/2015
05/07/2015

Segue código que pega a data e o intervalo entre elas.
declare @startDate date;
declare @endDate date;

select @startDate = '20150701';
select @endDate = '20150705';

with dateRange as
(
  select dt = @startDate
  where @startDate < @endDate
  union all
  select dateadd(dd, 1, dt)
  from dateRange
  where dateadd(dd, 1, dt) <= @endDate
)
select convert(varchar(MAX),dt,103)
from dateRange

Answer: Uma pratica comum em Data Warehouses é a criação de uma dimensão (geralmente uma tabela) com todas as datas possíveis.
Você pode criar uma tabela com todas as datas no seu banco de dados e recuperar o resultado por uma query simples:
SELECT date FROM allDates WHERE date BETWWEN 20150401 AND 20150501;

A vantagem de utilizar esse tipo de tabela está no ganho de desempenho caso precise fazer grandes joins com esse intervalo de datas.
Você pode criar essa tabela utilizando um script e caso deseje pode inserir mais colunas de acordo com sua necessidade.
Segue um script de exemplo:
BEGIN TRY
    DROP TABLE [dbo].[DimDate]
END TRY

BEGIN CATCH
    /*No Action*/
END CATCH

/**********************************************************************************/

CREATE TABLE    [dbo].[DimDate]
    (   [DateKey] INT primary key,
        [Date] DATETIME,
        [FullDateUK] CHAR(10), -- Date in dd-MM-yyyy format
        [FullDateUSA] CHAR(10),-- Date in MM-dd-yyyy format
        [DayOfMonth] VARCHAR(2), -- Field will hold day number of Month
        [DaySuffix] VARCHAR(4), -- Apply suffix as 1st, 2nd ,3rd etc
        [DayName] VARCHAR(9), -- Contains name of the day, Sunday, Monday
        [DayOfWeekUSA] CHAR(1),-- First Day Sunday=1 and Saturday=7
        [DayOfWeekUK] CHAR(1),-- First Day Monday=1 and Sunday=7
        [DayOfWeekInMonth] VARCHAR(2), --1st Monday or 2nd Monday in Month
        [DayOfWeekInYear] VARCHAR(2),
        [DayOfQuarter] VARCHAR(3),
        [DayOfYear] VARCHAR(3),
        [WeekOfMonth] VARCHAR(1),-- Week Number of Month
        [WeekOfQuarter] VARCHAR(2), --Week Number of the Quarter
        [WeekOfYear] VARCHAR(2),--Week Number of the Year
        [Month] VARCHAR(2), --Number of the Month 1 to 12
        [MonthName] VARCHAR(9),--January, February etc
        [MonthOfQuarter] VARCHAR(2),-- Month Number belongs to Quarter
        [Quarter] CHAR(1),
        [QuarterName] VARCHAR(9),--First,Second..
        [Year] CHAR(4),-- Year value of Date stored in Row
        [YearName] CHAR(7), --CY 2012,CY 2013
        [MonthYear] CHAR(10), --Jan-2013,Feb-2013
        [MMYYYY] CHAR(6),
        [FirstDayOfMonth] DATE,
        [LastDayOfMonth] DATE,
        [FirstDayOfQuarter] DATE,
        [LastDayOfQuarter] DATE,
        [FirstDayOfYear] DATE,
        [LastDayOfYear] DATE,
        [IsHolidayUSA] BIT,-- Flag 1=National Holiday, 0-No National Holiday
        [IsWeekday] BIT,-- 0=Week End ,1=Week Day
        [HolidayUSA] VARCHAR(50),--Name of Holiday in US
        [IsHolidayUK] BIT Null,-- Flag 1=National Holiday, 0-No National Holiday
        [HolidayUK] VARCHAR(50) Null --Name of Holiday in UK
    )
GO

/********************************************************************************************/
--Specify Start Date and End date here
--Value of Start Date Must be Less than Your End Date

DECLARE @StartDate DATETIME = '01/01/2013' --Starting value of Date Range
DECLARE @EndDate DATETIME = '01/01/2018' --End Value of Date Range

--Temporary Variables To Hold the Values During Processing of Each Date of Year
DECLARE
    @DayOfWeekInMonth INT,
    @DayOfWeekInYear INT,
    @DayOfQuarter INT,
    @WeekOfMonth INT,
    @CurrentYear INT,
    @CurrentMonth INT,
    @CurrentQuarter INT

/*Table Data type to store the day of week count for the month and year*/
DECLARE @DayOfWeek TABLE (DOW INT, MonthCount INT, QuarterCount INT, YearCount INT)

INSERT INTO @DayOfWeek VALUES (1, 0, 0, 0)
INSERT INTO @DayOfWeek VALUES (2, 0, 0, 0)
INSERT INTO @DayOfWeek VALUES (3, 0, 0, 0)
INSERT INTO @DayOfWeek VALUES (4, 0, 0, 0)
INSERT INTO @DayOfWeek VALUES (5, 0, 0, 0)
INSERT INTO @DayOfWeek VALUES (6, 0, 0, 0)
INSERT INTO @DayOfWeek VALUES (7, 0, 0, 0)

--Extract and assign various parts of Values from Current Date to Variable

DECLARE @CurrentDate AS DATETIME = @StartDate
SET @CurrentMonth = DATEPART(MM, @CurrentDate)
SET @CurrentYear = DATEPART(YY, @CurrentDate)
SET @CurrentQuarter = DATEPART(QQ, @CurrentDate)

/********************************************************************************************/
--Proceed only if Start Date(Current date ) is less than End date you specified above

WHILE @CurrentDate < @EndDate
BEGIN

/*Begin day of week logic*/

         /*Check for Change in Month of the Current date if Month changed then
          Change variable value*/
    IF @CurrentMonth != DATEPART(MM, @CurrentDate)
    BEGIN
        UPDATE @DayOfWeek
        SET MonthCount = 0
        SET @CurrentMonth = DATEPART(MM, @CurrentDate)
    END

        /* Check for Change in Quarter of the Current date if Quarter changed then change
         Variable value*/

    IF @CurrentQuarter != DATEPART(QQ, @CurrentDate)
    BEGIN
        UPDATE @DayOfWeek
        SET QuarterCount = 0
        SET @CurrentQuarter = DATEPART(QQ, @CurrentDate)
    END

        /* Check for Change in Year of the Current date if Year changed then change
         Variable value*/

    IF @CurrentYear != DATEPART(YY, @CurrentDate)
    BEGIN
        UPDATE @DayOfWeek
        SET YearCount = 0
        SET @CurrentYear = DATEPART(YY, @CurrentDate)
    END

        -- Set values in table data type created above from variables

    UPDATE @DayOfWeek
    SET
        MonthCount = MonthCount + 1,
        QuarterCount = QuarterCount + 1,
        YearCount = YearCount + 1
    WHERE DOW = DATEPART(DW, @CurrentDate)

    SELECT
        @DayOfWeekInMonth = MonthCount,
        @DayOfQuarter = QuarterCount,
        @DayOfWeekInYear = YearCount
    FROM @DayOfWeek
    WHERE DOW = DATEPART(DW, @CurrentDate)

/*End day of week logic*/

/* Populate Your Dimension Table with values*/

    INSERT INTO [dbo].[DimDate]
    SELECT

        CONVERT (char(8),@CurrentDate,112) as DateKey,
        @CurrentDate AS Date,
        CONVERT (char(10),@CurrentDate,103) as FullDateUK,
        CONVERT (char(10),@CurrentDate,101) as FullDateUSA,
        DATEPART(DD, @CurrentDate) AS DayOfMonth,
        --Apply Suffix values like 1st, 2nd 3rd etc..
        CASE
            WHEN DATEPART(DD,@CurrentDate) IN (11,12,13) _
            THEN CAST(DATEPART(DD,@CurrentDate) AS VARCHAR) + 'th'
            WHEN RIGHT(DATEPART(DD,@CurrentDate),1) = 1 _
            THEN CAST(DATEPART(DD,@CurrentDate) AS VARCHAR) + 'st'
            WHEN RIGHT(DATEPART(DD,@CurrentDate),1) = 2 _
            THEN CAST(DATEPART(DD,@CurrentDate) AS VARCHAR) + 'nd'
            WHEN RIGHT(DATEPART(DD,@CurrentDate),1) = 3 _
            THEN CAST(DATEPART(DD,@CurrentDate) AS VARCHAR) + 'rd'
            ELSE CAST(DATEPART(DD,@CurrentDate) AS VARCHAR) + 'th'
            END AS DaySuffix,

        DATENAME(DW, @CurrentDate) AS DayName,
        DATEPART(DW, @CurrentDate) AS DayOfWeekUSA,

        -- check for day of week as Per US and change it as per UK format
        CASE DATEPART(DW, @CurrentDate)
            WHEN 1 THEN 7
            WHEN 2 THEN 1
            WHEN 3 THEN 2
            WHEN 4 THEN 3
            WHEN 5 THEN 4
            WHEN 6 THEN 5
            WHEN 7 THEN 6
            END
            AS DayOfWeekUK,

        @DayOfWeekInMonth AS DayOfWeekInMonth,
        @DayOfWeekInYear AS DayOfWeekInYear,
        @DayOfQuarter AS DayOfQuarter,
        DATEPART(DY, @CurrentDate) AS DayOfYear,
        DATEPART(WW, @CurrentDate) + 1 - DATEPART(WW, CONVERT(VARCHAR, _
        DATEPART(MM, @CurrentDate)) + '/1/' + CONVERT(VARCHAR, _
        DATEPART(YY, @CurrentDate))) AS WeekOfMonth,
        (DATEDIFF(DD, DATEADD(QQ, DATEDIFF(QQ, 0, @CurrentDate), 0), _
        @CurrentDate) / 7) + 1 AS WeekOfQuarter,
        DATEPART(WW, @CurrentDate) AS WeekOfYear,
        DATEPART(MM, @CurrentDate) AS Month,
        DATENAME(MM, @CurrentDate) AS MonthName,
        CASE
            WHEN DATEPART(MM, @CurrentDate) IN (1, 4, 7, 10) THEN 1
            WHEN DATEPART(MM, @CurrentDate) IN (2, 5, 8, 11) THEN 2
            WHEN DATEPART(MM, @CurrentDate) IN (3, 6, 9, 12) THEN 3
            END AS MonthOfQuarter,
        DATEPART(QQ, @CurrentDate) AS Quarter,
        CASE DATEPART(QQ, @CurrentDate)
            WHEN 1 THEN 'First'
            WHEN 2 THEN 'Second'
            WHEN 3 THEN 'Third'
            WHEN 4 THEN 'Fourth'
            END AS QuarterName,
        DATEPART(YEAR, @CurrentDate) AS Year,
        'CY ' + CONVERT(VARCHAR, DATEPART(YEAR, @CurrentDate)) AS YearName,
        LEFT(DATENAME(MM, @CurrentDate), 3) + '-' + CONVERT(VARCHAR, _
        DATEPART(YY, @CurrentDate)) AS MonthYear,
        RIGHT('0' + CONVERT(VARCHAR, DATEPART(MM, @CurrentDate)),2) + _
        CONVERT(VARCHAR, DATEPART(YY, @CurrentDate)) AS MMYYYY,
        CONVERT(DATETIME, CONVERT(DATE, DATEADD(DD, - (DATEPART(DD, _
        @CurrentDate) - 1), @CurrentDate))) AS FirstDayOfMonth,
        CONVERT(DATETIME, CONVERT(DATE, DATEADD(DD, - (DATEPART(DD, _
        (DATEADD(MM, 1, @CurrentDate)))), DATEADD(MM, 1, _
        @CurrentDate)))) AS LastDayOfMonth,
        DATEADD(QQ, DATEDIFF(QQ, 0, @CurrentDate), 0) AS FirstDayOfQuarter,
        DATEADD(QQ, DATEDIFF(QQ, -1, @CurrentDate), -1) AS LastDayOfQuarter,
        CONVERT(DATETIME, '01/01/' + CONVERT(VARCHAR, DATEPART(YY, _
        @CurrentDate))) AS FirstDayOfYear,
        CONVERT(DATETIME, '12/31/' + CONVERT(VARCHAR, DATEPART(YY, _
        @CurrentDate))) AS LastDayOfYear,
        NULL AS IsHolidayUSA,
        CASE DATEPART(DW, @CurrentDate)
            WHEN 1 THEN 0
            WHEN 2 THEN 1
            WHEN 3 THEN 1
            WHEN 4 THEN 1
            WHEN 5 THEN 1
            WHEN 6 THEN 1
            WHEN 7 THEN 0
            END AS IsWeekday,
        NULL AS HolidayUSA, Null, Null

    SET @CurrentDate = DATEADD(DD, 1, @CurrentDate)
END

/*******************************************************************************************/

/* Update HOLIDAY fields of UK as per Govt. Declaration of National Holiday ****/

-- Good Friday  April 18
    UPDATE [dbo].[DimDate]
        SET HolidayUK = 'Good Friday'
    WHERE [Month] = 4 AND [DayOfMonth]  = 18

-- Easter Monday  April 21
    UPDATE [dbo].[DimDate]
        SET HolidayUK = 'Easter Monday'
    WHERE [Month] = 4 AND [DayOfMonth]  = 21

-- Early May Bank Holiday   May 5
   UPDATE [dbo].[DimDate]
        SET HolidayUK = 'Early May Bank Holiday'
    WHERE [Month] = 5 AND [DayOfMonth]  = 5

-- Spring Bank Holiday  May 26
    UPDATE [dbo].[DimDate]
        SET HolidayUK = 'Spring Bank Holiday'
    WHERE [Month] = 5 AND [DayOfMonth]  = 26

-- Summer Bank Holiday  August 25
    UPDATE [dbo].[DimDate]
        SET HolidayUK = 'Summer Bank Holiday'
    WHERE [Month] = 8 AND [DayOfMonth]  = 25

-- Boxing Day  December 26
    UPDATE [dbo].[DimDate]
        SET HolidayUK = 'Boxing Day'
    WHERE [Month] = 12 AND [DayOfMonth]  = 26

--CHRISTMAS
    UPDATE [dbo].[DimDate]
        SET HolidayUK = 'Christmas Day'
    WHERE [Month] = 12 AND [DayOfMonth]  = 25

--New Years Day
    UPDATE [dbo].[DimDate]
        SET HolidayUK  = 'New Year''s Day'
    WHERE [Month] = 1 AND [DayOfMonth] = 1

--Update flag for UK Holidays 1= Holiday, 0=No Holiday

    UPDATE [dbo].[DimDate]
        SET IsHolidayUK  = CASE WHEN HolidayUK   IS NULL _
        THEN 0 WHEN HolidayUK   IS NOT NULL THEN 1 END

/*Update HOLIDAY Field of USA In dimension*/

    /*THANKSGIVING - Fourth THURSDAY in November*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'Thanksgiving Day'
    WHERE
        [Month] = 11
        AND [DayOfWeekUSA] = 'Thursday'
        AND DayOfWeekInMonth = 4

    /*CHRISTMAS*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'Christmas Day'

    WHERE [Month] = 12 AND [DayOfMonth]  = 25

    /*4th of July*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'Independance Day'
    WHERE [Month] = 7 AND [DayOfMonth] = 4

    /*New Years Day*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'New Year''s Day'
    WHERE [Month] = 1 AND [DayOfMonth] = 1

    /*Memorial Day - Last Monday in May*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'Memorial Day'
    FROM [dbo].[DimDate]
    WHERE DateKey IN
        (
        SELECT
            MAX(DateKey)
        FROM [dbo].[DimDate]
        WHERE
            [MonthName] = 'May'
            AND [DayOfWeekUSA]  = 'Monday'
        GROUP BY
            [Year],
            [Month]
        )

    /*Labor Day - First Monday in September*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'Labor Day'
    FROM [dbo].[DimDate]
    WHERE DateKey IN
        (
        SELECT
            MIN(DateKey)
        FROM [dbo].[DimDate]
        WHERE
            [MonthName] = 'September'
            AND [DayOfWeekUSA] = 'Monday'
        GROUP BY
            [Year],
            [Month]
        )

    /*Valentine's Day*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'Valentine''s Day'
    WHERE
        [Month] = 2
        AND [DayOfMonth] = 14

    /*Saint Patrick's Day*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'Saint Patrick''s Day'
    WHERE
        [Month] = 3
        AND [DayOfMonth] = 17

    /*Martin Luthor King Day - Third Monday in January starting in 1983*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'Martin Luthor King Jr Day'
    WHERE
        [Month] = 1
        AND [DayOfWeekUSA]  = 'Monday'
        AND [Year] >= 1983
        AND DayOfWeekInMonth = 3

    /*President's Day - Third Monday in February*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'President''s Day'
    WHERE
        [Month] = 2
        AND [DayOfWeekUSA] = 'Monday'
        AND DayOfWeekInMonth = 3

    /*Mother's Day - Second Sunday of May*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'Mother''s Day'
    WHERE
        [Month] = 5
        AND [DayOfWeekUSA] = 'Sunday'
        AND DayOfWeekInMonth = 2

    /*Father's Day - Third Sunday of June*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'Father''s Day'
    WHERE
        [Month] = 6
        AND [DayOfWeekUSA] = 'Sunday'
        AND DayOfWeekInMonth = 3

    /*Halloween 10/31*/
    UPDATE [dbo].[DimDate]
        SET HolidayUSA = 'Halloween'
    WHERE
        [Month] = 10
        AND [DayOfMonth] = 31

    /*Election Day - The first Tuesday after the first Monday in November*/
    BEGIN
    DECLARE @Holidays TABLE (ID INT IDENTITY(1,1), _
    DateID int, Week TINYINT, YEAR CHAR(4), DAY CHAR(2))

        INSERT INTO @Holidays(DateID, [Year],[Day])
        SELECT
            DateKey,
            [Year],
            [DayOfMonth]
        FROM [dbo].[DimDate]
        WHERE
            [Month] = 11
            AND [DayOfWeekUSA] = 'Monday'
        ORDER BY
            YEAR,
            DayOfMonth

        DECLARE @CNTR INT, @POS INT, @STARTYEAR INT, @ENDYEAR INT, @MINDAY INT

        SELECT
            @CURRENTYEAR = MIN([Year])
            , @STARTYEAR = MIN([Year])
            , @ENDYEAR = MAX([Year])
        FROM @Holidays

        WHILE @CURRENTYEAR <= @ENDYEAR
        BEGIN
            SELECT @CNTR = COUNT([Year])
            FROM @Holidays
            WHERE [Year] = @CURRENTYEAR

            SET @POS = 1

            WHILE @POS <= @CNTR
            BEGIN
                SELECT @MINDAY = MIN(DAY)
                FROM @Holidays
                WHERE
                    [Year] = @CURRENTYEAR
                    AND [Week] IS NULL

                UPDATE @Holidays
                    SET [Week] = @POS
                WHERE
                    [Year] = @CURRENTYEAR
                    AND [Day] = @MINDAY

                SELECT @POS = @POS + 1
            END

            SELECT @CURRENTYEAR = @CURRENTYEAR + 1
        END

        UPDATE [dbo].[DimDate]
            SET HolidayUSA  = 'Election Day'
        FROM [dbo].[DimDate] DT
            JOIN @Holidays HL ON (HL.DateID + 1) = DT.DateKey
        WHERE
            [Week] = 1
    END
    --set flag for USA holidays in Dimension
    UPDATE [dbo].[DimDate]
SET IsHolidayUSA = CASE WHEN HolidayUSA  IS NULL THEN 0 WHEN HolidayUSA  IS NOT NULL THEN 1 END
/*****************************************************************************************/

Fonte
Comment: Já vi uma solução assim em um projeto, e foi feita por questões de performance. Funcionou (e funciona) muito bem.
Answer: O seguinte código imprime todas as datas em um intervalo.
DECLARE @Data1 DATE, @Data2 DATE
SET @Data1 = '20150701'
SET @Data2 = '20150705'

SELECT CONVERT(varchar, DATEADD(DAY, number + 1, @Data1), 103) [Data]
FROM master..spt_values
WHERE type = 'P'
AND DATEADD(DAY, number + 1, @Data1) < @Data2

Fiz um Fiddle.
Comment: Excelente. Eu não tinha conhecimento sobre a `spt_values` e achei muito interessante o uso.
Comment: @ErlonCharles `spt_values` é uma dessas tabelas misteriosas cuja documentação é meio arcana. Basicamente, o que ela faz neste código é servir como um incrementador. `type = P` estou indicando que quero uma sequência *packed*, ou seja, uma sequência númerica que começa em 0 e termina em 2047. [Aqui tem uma excelente explicação sobre ela](http://stackoverflow.com/a/4280038/1314276).
Comment: Não consegui ver seu fiddle, =/
Comment: @ErlonCharles Corrigi o link. Veja agora.
Comment: Deu certo, muito boa solução também, mas queria entender um pouco mais sobre ela, a principal dúvida é o que seria `type = 'P'`?
Comment: Muito bom, obrigado
Answer: Outra sugestão:
/* SQLQUERY - MONTA LISTA COM DATA INICIAL ATÉ HOJE */
DECLARE  @TMP TABLE
    (
    DATA DATETIME NULL
    )

DECLARE @DATAINI    DATETIME

SELECT  @DATAINI    = '2017.01.01 00:00:00.000'

INSERT INTO @TMP
SELECT @DATAINI

WHILE (SELECT MAX(DATA) FROM @TMP) <= GETDATE()
BEGIN
    INSERT INTO @TMP
    SELECT DATEADD(DD,1,MAX(DATA))
      FROM @TMP
END

SELECT * FROM @TMP

Answer: DECLARE @dataInicio DATE
DECLARE @dataFim DATE

BEGIN
    CREATE TABLE #calendario
      (
         data      DATE,
         yearmonth VARCHAR(9)
      )

    SET @dataInicio = ( '1900-01-01' )
    SET @dataFim = ( Cast(Getdate() AS DATE) )

    WHILE @dataInicio <= @dataFim
      BEGIN
          INSERT INTO #calendario
          VALUES      (@dataInicio,
                       (SELECT Format(@dataInicio, 'MM-yyyy')))

          SET @dataInicio = Dateadd(day, 1, @dataInicio)
      END

    SELECT *
    FROM   #calendario
    ORDER  BY data DESC
END

Answer: Bom dia tive a mesma duvida e encontrei uma solução mais simples para essa questão, utilizo Firebird 2.5 e IBExpert para testar.
with recursive dt as (
  select cast('2022-02-01' as date) as dt
  from rdb$database
  union all
  select dt.dt + 1
  from dt
  where dt < cast('2022-03-31' as date))
select dt.dt from dt

Comment: Isto não responde realmente à pergunta. Se você tiver uma pergunta diferente, pode fazê-la clicando em [Fazer pergunta](https://pt.stackoverflow.com/questions/ask). Você também pode [adicionar uma gratificação](https://pt.stackoverflow.com/help/privileges/set-bounties) para chamar mais atenção a esta pergunta quando tiver [pontos de reputação](https://pt.stackoverflow.com/help/whats-reputation) suficientes. - [Da Revisão](/review/late-answers/388697)

Mostrar todos os dias entre duas datas


Bayesian Time Series Analysis

Question: I am interested in Bayesian modeling but neither very experienced nor do I fully understand the different models and how they could be used.
I often have the use case to predict if it's likely that an event will happen based on some time series data from let's say the last couple of days.
An specific example would be predicting traffic jams based on traffic data collected the last month.
Another example would be to predict if it's likely that an owner of a house needs to turn on the lights in his living room based on his behaviour the last 3 days or so.
So the time series datas duration is rather short with only some samples. The model should be able to estimate the likelihood of the event (Traffic conditions: green/yellow/red, Light in Livingroom: on/off) happening. From what I've learned so far Bayesian models may be a good choice, but I find it quite difficult to find out which kind of models fit on that use case and which I should learn more about or if its feasible what I am trying to do.
I would appreciate if you could point me into the right direction, perhaps also aome hints of how to implement these models in software (I prefer to use python over R but I am able to use both).
Answer: One thing you could do is check out the bsts (Bayesian structural time series) library for R and its documentation. Facebook's prophet is also Bayesian and very powerful but slightly more complex.
I would suggest however to learn the basics of Bayesian inference before tackling a Bayesian time series method.
Comment: prophets stan code seems to be available : https://github.com/facebook/prophet/blob/master/R/inst/stan/prophet.stan
Comment: @user2957945 Thanks, I fixed that. Though it's still hard to believe that the entire thing takes up only 130 lines.

Bayesian Time Series Analysis


X-axis goes farther than last time interval

Question: If I set a time interval, [0 10], and I plot something according to that time interval, plot(t, y()), then the graph will have its x-axis going all the way to 11.
It used to not do this. It used to produced a better fitting graph, but now it produces a graph with white space attached to the end of the graph between points 10 and 11.
I must have accidentally changed a setting. How do I get the plot function to best fit the graph?
Comment: Please have a look at [Setting Axis Parameters](http://www.mathworks.ch/help/techdoc/creating_plots/f6-7929.html).
Comment: I have an old version of MATLAB, so I don't know if this is up to date: Go in your figure into the menu `edit->Axes properties`. There you can set the limits of `x` and `y` either manually or choose `auto` which will fit your axes automatically.
Answer: If you want to make a polished plot, you almost always have to adjust the plot axis limits yourself.  Some useful commands:
axis tight;         %Squeeze the data as closely as possible
xlim([xMin xMax]);  %Adjust the x axis limits, do not touch the y limits
ylim([yMin yMax]);
axis([xMin xMax yMin yMax]);  %Adjust all axis limits

You your case you would probably add a line like this to your code:
xlim([min(t) max(t)]);

Or, if you know that t is sorted (very common)
xlim(t([1 end]));