If my normality test is non-significant, am I safe to use the t-test?

Question: I took a 30 unit sample from a population. The sample distribution resulted to be normal. Can I state that the population distribution is normal too? If so, with what level of confidence?
Comment: Thanks for such a quick response! The sample I refer to were 30 readings of force. Since it is a continuous data I assumed that it may be modeled with a random variable normally distributed. Additionally, I used Minitab software to run the statics summary report and it presented, among other things, the Anderson-Darling normality test results, with the P values of 0.812.
Comment: One more thing, what I'm actually trying to do is to test a hypothesis that the two populations means aren't too different, using a paired T-test. But, if I'm not mistaking first I have to make sure the populations are distributed normally and this is why I thought I may infer that from the sample. Sorry for any obvious errors.
Comment: While you need normality for the t-test-statistic to have a t-distribution under the null, it's not especially sensitive to that. Further, a hypothesis test isn't an especially good way to deal with assessing normality, because it answers the wrong question ("can you detect non-normality" rather than 'is it big enough to matter' - it tends to reject in large samples, exactly when it matters least). You may benefit from searching on the various keywords in your question.
Comment: After reading your answers I think I definitely messed up all these concepts. Thanks for spreading for the clarification!
Comment: The fault is unlikely to be yours. The approach you wanted to take is often suggested to beginning students in a variety of subject areas. There's a widespread culture of general advice and rules of thumb which is at best not especially useful, and which seems to have been turned into unnecessarily proscriptive recipes.
Answer: We will need to clarify some ideas here. Your sample, being finite, cannot possibly be normal, which is infinite. Also, this quote seems relevant.

$30$ is a fairly small sample, & the Anderson-Darling test is not the most powerful test of normality to start with.  You may believe that the population is normal as a result, but it certainly isn't proven.  For more information on the underlying topics here, it may help you to read these:

Is normality testing 'essentially useless'?
Why do statisticians say a non-significant result means "you can't reject the null" as opposed to accepting the null hypothesis?

Regarding the issue of verifying your assumptions for a $t$-test, what needs to be normal for a paired $t$-test are the differences, not the original data.  You are probably good enough, the $t$-test is pretty robust anyway.  However, the check then test strategy has been criticized.  If you are concerned that the test may not be appropriate, it is generally better to simply use a test that doesn't rely on that assumption, in this case the Wilcoxon.
Comment: I found your initial sentence confusing. Any sample from a normal distribution "will be finite". The issue is that if the *possible* range of the observed variable is finite (like test scores for example) then it can't be exactly normal. In this case (force), it presumably will be bounded above and below, so is arguably not exactly normal for that reason.
Comment: @Glen_b, if the *population* is bounded, then it cannot be truly normal (although it may be close enough), but a *sample* can never be truly normal, b/c samples are always bounded. The only meaningful questions to ask about samples are 'is this close enough for my purposes?', & 'is it reasonable to imagine the population from which this was drawn is normal?', but the sample is simply not ever normal. There is a (common) confusion here between the properties of a sample & inferences about the underlying population.
Comment: Samples only have discrete distributions (they only take $n$ different values after all); they nevertheless might be effectively samples from continuous distributions (leaving rounding of their values to a finite number of figures aside). When people say "sample A has distribution F" one generally presumes they intend "sample A comes from a population with distribution F" -- because without that presumption the assertion would make no sense. The boundedness of the *sample* doesn't enter into that. ...(ctd)
Comment: (ctd)... When using boundedness to assert non-normality, it's the boundedness of the *possible* values of the variable, not the observed sample from it, that's the primary issue. A sample of size two only contains two values, but that doesn't mean those two values are the limit of the possible values for the variable being observed.
Comment: @Glen_b, '[w]hen people say "sample A has distribution F" one generally presumes they intend "sample A comes from a population with distribution F"' is perfectly reasonable. But consider that the question asks '[t]he sample distribution resulted to be normal... [c]an I state that the population distribution is normal too?'. That isn't consistent w/ your presumption. It is clear that there is some conceptual confusion here. Also, be aware the the top 2 portions of my answer were adapted from comments & I also subsequently edited the Q.
Comment: I appreciate fully that the OP has conceptual confusion that needs to be addressed. But I'm concerned about (at least by implication) seeming to confirm the assertion that for a sample from some distribution, there's a meaningful "distribution of the sample" that is seemingly neither the ECDF (which is only discrete) nor the underlying distribution of the population from which the sample was drawn (which may be unbounded, at least conceptually). If we're not talking about either of those, what are we discussing?
Comment: @Glen_b, I don't understand your comment here. I did not mean to assert that the distribution of the sample differed from the ECDF.
Comment: Hmm. In that case I definitely find some of your earlier phrasing puzzling, but I think it's best if I leave it and come back another time and see if maybe I'm making more of it than is really here; it may well be I'm taking something in a way other than you intend. Thanks for all your kind responses.
Comment: may be what confuses me more is that the normal random variable density function involves two known population parameters- u and std dev- and how those could be known if the population is infinite ?
Comment: In practice we never *know* those parameter values, we use our estimates. When mathematical statisticians are working on the underlying theory, they use the symbols $\mu$ & $\sigma^2$ to represent the unknown constants, or just assume that the parameter values are known for the sake of what they're working on. Either way, no sample is ever normal; the test (eg AD) assesses the probability of getting a sample as far or further from normality as yours if the sample was drawn from a true normal. The more important question is: 'is it close enough?', & the answer is probably 'yes'.


Sending ZeroMQ data using TCP

Question: I am trying to make a simple server.
A language I am restricted to use is c++.
I am using ZeroMQ.
I have creatred a simple server and a client, as in documentation.
ZeroMQ uses TCP instead of HTTP.
I know that HTTP's underlying layer is TCP, so I want to know will it have any performance issues by using TCP instead of HTTP.
And for HTTP I can use curl to test the application.
What should I use for TCP ( curl command to send request to a socket with a string parameter ).

Server:
#include <zmq.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>

int main (void)
{                                                  // Socket to talk to clients
   void *context = zmq_ctx_new ();
   void *responder = zmq_socket (context, ZMQ_REP);
   int rc = zmq_bind (responder, "tcp://*:5555");
   assert (rc == 0);

   while (1)
   {
      char buffer [10];
      zmq_recv (responder, buffer, 10, 0);
      printf ("Received Hello\n");

                                                   // trying to send json object
      zmq_send (responder, "World", 5, 0);
   // zmq_send (responder, "World", 5, 0);
      sleep (1);                                   // Do some 'work'
   }
   return 0;
}

client:
// Hello World client
// Connects REQ socket to tcp://localhost:5555
// Sends "Hello" to server, expects "World" back

#include <zmq.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
int main (void)
{
   void *context = zmq_ctx_new ();
                                                   // Socket to talk to server
   printf ("Connecting to hello world server...\n");
   void *requester = zmq_socket (context, ZMQ_REQ);
   zmq_connect (requester, "tcp://localhost:5555");
   int request_nbr;
   for (request_nbr = 0; request_nbr != 10; request_nbr++)
   {
       zmq_msg_t request;
       zmq_msg_init_size (&request, 5);
       memcpy (zmq_msg_data (&request), "Hello", 5);
       printf ("Sending Hello %d...\n", request_nbr);
       zmq_msg_send (&request, requester, 0);
       zmq_msg_close (&request);
       zmq_msg_t reply;

       zmq_msg_init (&reply);
       zmq_msg_recv (&reply, requester, 0);
       printf ("Received World %d\n", request_nbr);
       zmq_msg_close (&reply);
   }
   zmq_close (requester);
   zmq_ctx_destroy (context);
   return 0;
}

Comment: Using a lower layer can only improve performance, not make it worse.
Comment: From RFC 2616:
HTTP communication usually takes place over TCP/IP connections. The default port is TCP 80, but other ports can be used. This does not preclude HTTP from being implemented on top of any other protocol on the Internet, or on other networks. HTTP only presumes a reliable transport; any protocol that provides such guarantees can be used; the mapping of the HTTP/1.1 request and response structures onto the transport data units of the protocol in question is outside the scope of this specification.
Comment: @Yogesh I understand that http is built over  tcp. also i understand the request response structure of http. my question is how to query using curl to a socket. and using tcp will it create any performance overhead?
Comment: While I tend to agree, it's not a lower layer but a paralle one, because it's ZeroMQ on top of TCP, just as it's HTTP on top of TCP. Concerning the testing, use a ZMQ lib implemented in a simple scripting language, like e.g. Python. It provides an interactive shell to quickly send a few messages.
Answer: Q1: will it have any performance issues by using TCP instead of HTTP?
A1: yes, it will. Both performance and latency will benefit from avoiding HTTP-rich-re-wrapping of data
Q2: What should I use for TCP to send a request to a socket with a string parameter?
A2: No command ( curl command ) will help you. ZeroMQ uses certain line-code ( assume it as a trivial protocol between communicationg peers ), so a standalone command-line tool will not be able to match the line-code requirement off-the-shelf. Solution? Create a simple c-programme, that will consume a cmd-line arguments ( the string, as an example ) and assemble a ZeroMQ-layer compatible data-framing so as to communicate with the remote peer. Also you shall notice, that for ZeroMQ REQ/REP Formal Communication Pattern to work, this proxy-tool will have to become the sole respective REQ, resp. REP entity in the step-forward-locking diadic-communication relation, thus also providing an awaited response, the REQ-side is expecting to receive after the REP-side has received a message.

Sending ZeroMQ data using TCP


Definition Simple Stochastic Process

Question: Can anybody explain what concretely is a simple (stochastic) process?
(...and yes I tried to google it but without success)
Answer: A simple stochastic process $f$ on $[0,T]$ is one for which there exists times $0=t_1<t_1<t_2<\dots<t_n=T$ such that $f(t)$ is almost surely constant (in $t$) on each interval $[t_{i-1},t_i)$. This means that there are random variables $\xi_i,\dots,\xi_n$ such that
$$
f(t) = \sum_{i=1}^n\xi_i\cdot {\bf 1}_{[t_{i-1},t_i)}(t)
$$
Additionally, if there is a filtration $(\mathcal F_t)_{t\in [0,T]}$, then it is required that $f$ be adapted to this filtration, which is equivalent to saying that $\xi_i\in \mathcal F_{t_{i-1}}$.
Just like simple functions are used to define the integral in measure theory, simple processes are used to define the stochastic integral $\int f(t)\,dB_t$.
Comment: $\xi_{i} \in \mathcal{F}_{t_{i-1}}$ implies, that the process is predictable. Don't You mean, that $\xi_{i} \in \mathcal{F}_{t_{i}}$ is equivalent when $f$ is adapted to the filtration ?
Comment: If the process is adapted, then in particular $f(t_{i-1})\in \mathcal F_{t_{i-1}}$, which means that $\xi_{i}\in \mathcal F_{t_{i-1}}$. This does let you "look info the future" a bit, but if you were only given $\xi_i\in \mathcal F_{t_i}$, then you would never know the value of $f(t)$ at time $t$.

Definition Simple Stochastic Process


Rank these time complexities

Question: Can someone please help me rank these time complexities ?
functions with same order have to be given same rank.
<code>Take n > 1

rank => functions :
1 => n log_2(n) , 10n log_10(n)
2 => n^(log_2log_2(n))
3 => n^2
4 => n^3
5 => 2^(log_50(n))
6 => n!
7 => (n + 1)!
</code>
The above is how I have ranked. Can any one correct it if I have made a mistake ? Also if there is any website to visualize these functions, it would be great.
Comment: I don't think anyone will do your homework for you. Check here for answers: http://en.wikipedia.org/wiki/Time_complexity
Comment: I was asking for help in validating my answer. thanks for the suggestion though.
Answer: n^(log_2log_2(n)) is going to grow faster than n raised any constant eventually so it comes after n^2 and n^3
there's a relation between all logarithms log_c1(x) = log_c2(x)/log_c2(c1) so 2^(log_50(n)) will be equal to 2^(log_2(n)/log_2(50)) 2^log_2(n) = n, so that comes before n^2.
Comment: `log_50(n) = log_2(n)/log_2(50)`, so `2^(log_50(n)) = 2^(log_2(n)/log_2(50)) = n^(1/log_2(50))`
Comment: Actually `2^(log_50(n))` grows even slower than `n`

Rank these time complexities


What if the level set of Lyapunov function is disconnected? - when estimating region of attration

Question: Consider $\frac{dx}{dt}=f(x)$, where $x\in\mathbb{R}^n$. Suppose $x=0$ is a stable equilibrium.
It is classical way to estimate region of attraction of $0$ by finding a $C^1$ function $V(x)$ such that when $x\in D\subset \mathbb{R}^n$
(1) V(x) is lower bounded
(2) $\frac{dV(x)}{dx}\frac{dx}{dt}<0$, $V(x)=0$ if and only if $x=0$
(3) solution $x$ cannot leave the region $D$. This can be guaranteed by imposing compactness and positive invariance on region $D$.
The level set $\{ x|V(x)\leq c \}$ satisfies the condition (3). Thus, level set of $V(x)$ is an estimate of region of attraction of $x=0$. Please see Section 8.2 - H. K. Khalil, Nonlinear systems.
I am a bit confused on this, once I start to think of the level set of $V(x)$ might be disconnected. In this case, for the connected components that do not contain $x=0$, they cannot be part of region of attraction for sure.
Do we need to change the conclusion to: The connected component who contain $x=0$ is an estimate of region of attraction? Or the level set should be connected such that it becomes an estimation.
I didn't see any literature noticing the connectedness of level set. Am I missing something or the literature are not rigorous?
Comment: A *domain* (the word Khalil uses) is usually interpreted as a (non-empty) open, connected set. Also did you see the footnote 11 on pg 317?
Comment: @RollenS.D'Souza "The set $\{ V(z)\leq c \}$ may have more than one component, but there can be only one bounded component in D, and that is the component we work with". I see! But I didn't get why there can be only one bounded component? I think there can be a few.
Comment: @RollenS.D'Souza I am not sure whether this is true: I have a Lyapunov function $V(x)$ that satisfies all requirements. Now I want to verify whether a subset $D$ is the estimation of DOA (of the stable equilibrium $x=0$) or not. How could we do that? I think I need verify these 3 conditions: (1) The set $D$ is connected; (2) The set $D$ contains $x=0$; (3) The set $D$ is a subset of sublevel set of $V(x)$, i.e. there exists a constant $c$ such that $D\subset \{ x|V(x)\leq c \}$.
Comment: I posted a similar question 2,5 years ago [here](https://mathoverflow.net/questions/385181/subset-of-the-domain-of-attraction) on MathOverflow, unfortunatly with no response so far (even though I offered a bounty back then). So I would be very interested in an answer too.
Comment: @SampleTime I feel this is a very natural question But a bit strange that seems no where address the problem explicitly. maybe intuitively only the connected component who contains the equilibrium can be considered as an estimation of roa.
Comment: @happyle Yes I think it is obvious that only the connected component containing the origin can be a subset of the roa but as far as I can see the definition in the linked MO post does not rule out the option of multiple disconnected regions within $F$, but I guess I am missing something here.
Answer: If $\forall x\ne 0, x \in\Omega_C\; \dot V(x)<0$ (where $\Omega_C=\{ x:V(x)\leq C \}$), then there can be no bounded connected components of $\Omega_C$ other than the one containing $0$.
Indeed, let $\Omega_C^1$ be the bounded connected component of $\Omega_C$, $0\notin \Omega_C^1$. Since $\dot V(x)$ is continuous on the compact set $\Omega_C^1$, it reaches on this set some maximum value $M$, $M<0$. Thus, $\forall x\in \Omega_C^1\; \dot V(x)\le M<0$. Let us recall that any trajectory that enters $\Omega_C^1$ remains in it. But then the function $V(x)$ cannot be bounded below, because for any trajectory in $\Omega_C^1$ and for any initial moment $t_0$, $x(t_0)\in \Omega_C^1$
$$
V(x(t))=V(x(t_0))+\int_{t_0}^t \dot V(x(t))\, dt\le
V(x(t_0))+M(t-t_0),
$$
i.e. $\lim_{t\to\infty} V(x(t))=-\infty$. We got a contradiction.
Comment: It should be highlighted that the fact that $0 \notin \Omega_C^1$ is being used in the claim that $M < 0.$


How configure Ehcache for recalculation key instead of eviction?

Question: Let say that object in the cache need to be evicted. But instead of eviction a new value should be calculated and put in the cache. It is important that until old value should be used until new value is generated to guarantee that there is no lock. Can Ehcache be configured for such behavior?
Comment: Well I usually "ovverride" the old value when the new value is generated but I don't use any kind of annotation....
Comment: I mean the scenarion: key evidicted, client try to get value, new value generation starts, client is blocked, generation ends, new value is put into cache, client gets value. So the goal is to remove locking.
Answer:
Let say that object in the cache need to be evicted.

A cache entry could be evicted due to capacity limits and because the cache entry wasn't requested (hit) recently. Resources need to be freed, nothing about the entry is known any more. When the respective key is requested again, the value needs to be computed again and you cannot hide the additional latency.
A cache entry could expire, e.g. because there is a time to live time span configured. Expiry can happen, while there are lots of incoming requests for that entry. Of course, in this case you may not want that the entry gets removed from the cache, you just want that the value to be refreshed.
Refreshing a value automatically when it expired is called refresh ahead or background refresh. The answer about that is here:  Refreshing Caches while under load with Spring/EHCache
Answer: I am not sure what you mean by "needs to be evicted". The normal Ehcache flow would be the following:

Set an entry in the cache
Things getting this entry
The entry is now obsolete so the application set the new value
Things getting this entry (with the new value)

There is no locking involved. Anything getting the entry will directly get the old or the new value without waiting. Unless you are using a loader.


Evaluation of limits and finding the value of $\lambda$

Question:
If $f(x)= \lim_{n\to \infty}\dfrac{\left(1- \cos \left(1- \tan \left(\dfrac {\pi}{4}-x\right)\right)\right)(x+1)^n+ \lambda\sin((n - \sqrt{n^2 -8n})x)}{x^2(x+1)^n+x}$ ,$x\ne 0$  is continuous at $x=0$, then find the value of $(f(0)+ 2\lambda)$

Attempt:
I know that we are supposed to evaluate limit as $n \to \infty$ and $x \to 0$ but I am facing real trouble while doing that. It's $0/0$ form LHopital doesn't help here because differentiation of that function would be really long.
The term inside cos simplifies to $\dfrac{2\tan x}{1+\tan x}$
For $\dfrac {P(x)}{Q(x)}$'s limit when $x\to 0$ we see the ratio of the lowest powers of $x$ so according to that the ratio of lowest powers of $x$ is $\lambda(n- \sqrt{n^2-8n}) $ whose limit is $4\lambda$ but I am not sure we can use this method when we have double limits (limit on both $x$ and $n$).
Tl;dr:
Is the method of the last paragraph above allowed here? Why or why not?
What is the apt way to solve this problem?
Comment: How can a function not defined at $0$ be continuous at $0$?
Comment: @Egreg good point, I think they intend to define $f(0)$ as the limit, but nowhere is it mentioned, I silently assumed it..
Answer: Rewrite the given function as:
$$f(x) = \lim_{n\to\infty}\frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)(x+1)^n + \lambda \sin\left(\frac{8nx}{n+\sqrt{n^2-8n}}\right)}{x^2(x+1)^n+x}$$
We need left and right limits at $x=0$ to be equal as $n\to \infty$. First let us consider individual limits:

For right hand limit, as $n\to \infty,$ and $x\to 0^+$, note that $\sin \left(\frac{8nx}{n+\sqrt{n^2-8n}}\right) \to 4x \to 0$. But $(x+1)^n \to \infty$. So the limit is of form $\infty / \infty$. Divide by $x^2(x+1)^n$ on numerator and denominator and the limit is
$$\lim_{x\to 0^+, n\to \infty} \frac{\frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)(x+1)^n}{x^2 (x+1)^n}+\frac{\sin \left(\frac{8nx}{n+\sqrt{n^2-8n}}\right)}{x^2(1+x)^n}}{1+\frac{x}{x^2(1+x)^n }} \\
=  \frac{\lim_{x\to 0^+, n\to \infty}\frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)(x+1)^n}{x^2 (x+1)^n}+0}{1+0}
\\=\lim_{x\to 0^+} \frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)}{x^2 } = 2$$
For left limit, as $n\to \infty$ and $x\to 0^-$, $(x+1)^n \to 0$ , so limit is of form $0/0$:

$$\lim_{x\to 0^-,n\to \infty} \frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)(x+1)^n + \lambda \sin\left(\frac{8nx}{n+\sqrt{n^2-8n}}\right)}{x^2(x+1)^n+x} \\
=\lim_{x\to 0^-, n\to \infty} \frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)\frac{(x+1)^n}{x} + \frac{\lambda}{x} \sin\left(\frac{8nx}{n+\sqrt{n^2-8n}}\right)}{x(x+1)^n+1}  \\
= \frac{0+4\lambda}{0+1}$$
For continuity we need $4\lambda = 2 = f(0)$ or $\lambda = 1/2$. So $f(0)+2\lambda = 2+1 = 3$.


How to set folder display name with e.g. "SHGetSetFolderCustomSettings()"?

Question: Looks like SHGetSetFolderCustomSettings allows you to set an icon, a tooltip, a web view template and stuff, but I could not find how to set the LocalizedResourceName in the associated desktop.ini (see SHFOLDERCUSTOMSETTINGS structure).
Therefore I am currently writing to desktop.ini directly, however this comes with a caveat:
Explorer does not properly update its views even when you tell it to refresh with F5 or Ctrl+R.
This is what I want to write, using Python (though non-Python code should be less of an issue):
[.ShellClassInfo]
LocalizedResourceName=My Folder Name
InfoTip=A customized folder

Any ideas how to set the folder name and have Explorer properly update it ?
I have tried with SHChangeNotify(SHCNE_ALLEVENTS, SHCNF_PATH, path, path), but this does not seem to update the display name (and also with SHCNE_RENAMEFOLDER, SHCNE_RENAMEITEM, SHCNE_UPDATEDIR, SHCNE_UPDATEITEM).
(The worst approach would probably be to edit the desktop.ini twice... once directly, then with that API function... rather not what I want).
About the why (I guess at least one of you will ask):
I am storing project data using GUIDs as folder names.
The user should however see a friendly name that can also be used for sorting (and maybe even be able to edit it without interfering with the internal name).
Furthermore, the low-level file system layout should be backwards-compatible with older versions of the software.
Answer: Use simple call of IShellFolder.SetNameOf:
procedure UpdateLocalizedResourceName(const ADirectory, ANewResourceName: UnicodeString);
var
  Desktop: IShellFolder;
  Eaten: DWORD;
  DirIDList1, Child, NewChild: PItemIDList;
  Attr: DWORD;
  Folder: IShellFolder;
begin
  OleCheck(SHGetDesktopFolder(Desktop));
  try
    Attr := 0;
    OleCheck(Desktop.ParseDisplayName(0, nil, PWideChar(ADirectory), Eaten, DirIDList1, Attr));
    try
      OleCheck(SHBindToParent(DirIDList1, IShellFolder, Pointer(Folder), Child));
      try
        OleCheck(Folder.SetNameOf(0, Child, PWideChar(ANewResourceName), SHGDN_INFOLDER, NewChild));
        CoTaskMemFree(NewChild);
      finally
        Folder := nil;
      end;
    finally
      CoTaskMemFree(DirIDList1);
    end;
  finally
    Desktop := nil;
  end;
end;

UPDATE
Important notice! LocalizedResourceName parameter must exists in desktop.ini before you call UpdateLocalizedResourceName. Otherwise SetNameOf function fails.
Comment: SHSetLocalizsedName does this at one shot.
Comment: Hm, looks more complicated than I had hoped for... I also want to set an info tip, so would I have to use some combo of `desktop.ini` handling, `IShellFolder.SetNameOf()` and/or `SHGetSetFolderCustomSettings()`, or is there some more efficient way to accomplish my goal ? For a little bit more context: I am working on a Python solution interfacing with Windows APIs, so everything is possible but a bit more cumbersome than in Windows languages.
Comment: @Archimedix As I understand you must use combination of SHGetSetFolderCustomSettings and IShellFolder.SetNameOf.
Comment: @RaymondChen, how would I call [`SHSetLocalizedName()`](http://msdn.microsoft.com/en-us/library/windows/desktop/bb762250%28v=vs.85%29.aspx) to set an arbitrary string ? The documentation says that it is called with the path whose display name should be set, a resource file with the localized string and a resource ID. According to the documentation, the function will also persist the text in the registry, rather than in `desktop.ini`, which is a bit confusing.
Comment: Looks like `SHSetLocalizedName()` does not support arbitrary strings but only references to resource files like DLLs.
Comment: True, SHSetLocalizedName requires a DLL and resource. Using the LocalizedResourceName to set a non-localized resource name is not really the intent of LocalizedResourceName.


Node form with fields loaded from another node or other entity

Question: I am stuck on this problem, I was making a 'field' to be available on many content types, but this field has itself many fields, so i decided making an entity to have those fields seperate. I choose an entity because i don't these information to be accessible in the searchs etc, and I don't need revisions. Now on the node form submission i would like to have both the fields of the node and the fields of the entity showing up on the same form, as if this entity was a field.  How can i do that ?

If I use form_alter: ok i understood how to add widgets to the form, but then that means i have to re-write all the validation code etc from all fields ? Is it possible to load fields so that they will keep all their properties? (validation, submission etc)
Would it be possible to create a field module that would load other fields from a node/entity type on each hook ?
Any other solution ?

Idealy i would to find or make an 'entity-reference' module that does that job! (load field from one in the other when creating, editing, loading a node) !!
any help welcom, thanks !
dylan
Answer: Isn't module Inline Entity Form exactly what you are looking for? Here is a quote about it (from the module's project page):

Provides a widget for inline management (creation, modification, removal) of referenced entities.
The primary use case is the parent -> children one (product display -> products, order -> line items, etc.), where the child entities are never managed outside the parent form.
Existing entities can also be referenced.


"TypeError: 'NoneType' object is not iterable" on what should be a list

Question: I've got some code that I based off of what I found here, but because of my low reputation I can't comment to ask a question. I've also looked through all other posts related to this same error, but, probably due with my lack of familiarity with programming and Python, I haven't found a solution.
Right, so I've got the following code:
import zipfile, os

def dirEntries(dir_name):
    ''' Creates a list of all files in the folder 'dir_name' which we assign when we call the function later'''

    fileList = []
    '''creates an empty list'''
    for file in os.listdir(dir_name):
        '''for all files in the directory given'''
        dirfile = os.path.join(dir_name, file)
        '''creates a full file name including path for each file in the directory'''
        if os.path.isfile(dirfile) and os.path.splitext(dirfile)[1][1:]!='lock':
            '''if the full file name above is a file and it does not end in 'lock' it will be added to the list created above'''
            fileList.append(dirfile)

def makeArchive(fileList, archive, root):
    """
    'fileList' will be a list of file names - full path each name
    'archive' will be the file name for the archive with a full path (ex. "C:\\GIS_Data\\folder.zip")
    """
    a = zipfile.ZipFile(archive, 'w', zipfile.ZIP_DEFLATED)

    for f in fileList:
        a.write(f, os.path.relpath(f, root))
        '''I don't completely understand this, but the 'relpath' part seemed integral to not having the entire folder structure saved in the zip file'''
    a.close()

makeArchive(dirEntries(ptdir), ptdir+"pts.zip", ptdir)
makeArchive(dirEntries(polydir), polydir+"polys.zip", polydir)

'ptdir' and 'polydir' are defined in an earlier part of the code.
And I get the following:
Traceback (most recent call last):
  File "C:\Python27\ArcGIS10.1\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\GIS_Data\Working\Python\DatabaseExport\ExportScriptTEST.py", line 181, in <module>
    makeArchive(dirEntries(ptdir), ptdir+"pts.zip", ptdir)
  File "C:\GIS_Data\Working\Python\DatabaseExport\ExportScriptTEST.py", line 177, in makeArchive
    for f in fileList:
TypeError: 'NoneType' object is not iterable

I've gone through the process in the interactive window and don't have a problem populating the list when I take apart the functions and feed them in bit by bit, but when I run this all together I get the error. Is the issue that the list is not being populated for some reason, or is there something else going on.
Any assistance would be greatly appreciated!
Comment: Here's a hint for the "low reputation" thing...just sign up for another Stack Overflow site.  You'll get a +100 boost to your rep, and can then comment at will.
Comment: Please note that it is not idiomatic to use docstrings `"""` as comments in python.  You should use actual comments `#` instead.  A docstring explains how to *use* a function, comments are used to explain *how it works*.
Answer: You're not returning anything in this function dirEntries(dir_name), so by default it returns None.
Add a return statement at the end to fix this:
def dirEntries(dir_name):
    ''' Creates a list of all files in the folder 'dir_name' which we assign when we call the function later'''

    fileList = []
    '''creates an empty list'''
    for file in os.listdir(dir_name):
        '''for all files in the directory given'''
        dirfile = os.path.join(dir_name, file)
        '''creates a full file name including path for each file in the directory'''
        if os.path.isfile(dirfile) and os.path.splitext(dirfile)[1][1:]!='lock':
            '''if the full file name above is a file and it does not end in 'lock' it will be added to the list created above'''
            fileList.append(dirfile)
    return fileList


Datetimepicker considerando dia como mês

Question: Tenho um inputText que criei para data, ele é inicialmente preenchido com um DateTime do meu Model que está populado:
<code>@Html.TextBoxFor(model => model.Data, "{0:dd/MM/yyyy}", new { @class = "form-control input-md", @id = "datetimepickerDataFato" })
</code>
E meu javascript do datetimepicker
<code>$(document).ready(function () {
  $('#datetimepickerDataFato').datetimepicker({
     locale: 'pt-br',
     format: 'DD/MM/YYYY',
     allowInputToggle: true,
     maxDate: Date.now()
  });
});
</code>
O meu problema é que quando esse código javascript do datetimepicker é lido, ele sobrepõe a minha data para o dia de hoje, e ainda considera o dia como se fosse mês, ou seja, não posso colocar nenhum dia que seja maior que 12.
Comment: Você tem 'pt-br' no seu arquivo de locale? Tentou também incluir `language: 'pt'`?
Comment: @RicardoPontual Tem o 'pt-br' no locale sim. Tentei fazer o esquema do language mas também não deu certo
Answer: Tente utilizar o seguinte formato: 'dd/MM/yyyy' no seu javascript.
Comment: Eu tentei, mas ele traz o ordinal do dia da semana, tipo 5ª, 6ª
Comment: Isso já está no datapicker, o que você quer dizer com "*no seu javascript*"? O código do datapicker já está no javascript, resposta confusa e superficial, coloque mais detalhes e um exemplo de código. O conteúdo atual da sua resposta poderia ser um simples comentário.


Viewing a kernel as a probability density: Why are we only integrating with respect to $x$ and not $x^\prime$?

Question: I am currently studying the textbook Learning with kernels: support vector machines, regularization, optimization and beyond by Schölkopf and Smola. Chapter 1.2 A Simple Pattern Recognition Algorithm says the following:

We are now in the position to describe a pattern recognition learning algorithm that is arguably one of the simplest possible. We make use of the structure introduced in the previous section; that is, we assume that our data are embedded into a dot product space $\mathcal{H}$. Using the dot product, we can measure distances in this space. The basic idea of the algorithm is to assign a previously unseen pattern to the class with closer mean.
We thus begin by computing the means of the two classes in feature space;
$$\mathbf{c}_+ = \dfrac{1}{m_+} \sum_{\{i \vert y_i = +1\}} \mathbf{x}_i, \tag{1.7}$$
$$\mathbf{c}_- = \dfrac{1}{m_-} \sum_{\{i \vert y_i = -1\}} \mathbf{x}_i, \tag{1.8}$$
where $m_+$ and $m_-$ are the number of examples with positive and negative labels, respectively. We assume that both classes are non-empty, thus $m_+, m_- > 0$. We assign a new point $\mathbf{x}$ to the class whose mean is closest (Figure 1.1). This geometric construction can be formulated in terms of the dot product $\langle \cdot, \cdot \rangle$. Half way between $\mathbf{c}_+$ and $\mathbf{c}_-$ lies the point $\mathbf{c} := (\mathbf{c}_+ + \mathbf{c}_-)/2$. We compute the class of $\mathbf{x}$ by checking whether the vector $\mathbf{x} - \mathbf{c}$ connecting $\mathbf{c}$ to $\mathbf{x}$ encloses an angle smaller than $\pi / 2$ with the vector $\mathbf{w} := \mathbf{c}_+ - \mathbf{c}_-$ connecting the class means. This leads to
$$\begin{align} y &= \text{sgn} \langle (\mathbf{x} - \mathbf{c}), \mathbf{w} \rangle \\ &= \text{sgn} \langle ( \mathbf{x} - ( \mathbf{c}_+ + \mathbf{c}_- ) / 2), ( \mathbf{c}_+ - \mathbf{c}_- ) \rangle \\ &= \text{sgn}( \langle \mathbf{x}, \mathbf{c}_+ \rangle - \langle \mathbf{x}, \mathbf{c}_- \rangle + b). \tag{1.9} \end{align}$$
Here, we have defined the offset
$$b := \dfrac{1}{2} ( \left| \right| \mathbf{c}_- \left| \right|^2 - \left| \right| \mathbf{c}_+ \left| \right|^2), \tag{1.10}$$
with the norm $\left| \right| \mathbf{x} \left| \right| := \sqrt{\langle \mathbf{x}, \mathbf{x} \rangle}$. If the class means have the same distance to the origin, then $b$ will vanish.
Note that (1.9) induces a decision boundary which has the form of a hyperplane (Figure 1.1); that is, a set of points that satisfy a constraint expressible as a linear equation.
It is instructive to rewrite (1.9) in terms of the input patterns $x_i$, using the kernel $k$ to compute the dot products. Note, however, that (1.6) only tells us how to compute the dot products between vectorial representations $\mathbf{x}_i$ of inputs $x_i$. We therefore need to express the vectors $\mathbf{c}_i$ and $\mathbf{w}$ in terms of $\mathbf{x}_1, \dots, \mathbf{x}_m$.

To this end, substitute (1.7) and (1.8) into (1.9) to get the decision function
$$\begin{align} y &= \text{sgn} \left( \dfrac{1}{m_+} \sum_{\{i \vert y_i = +1 \}} \langle \mathbf{x}, \mathbf{x}_i \rangle - \dfrac{1}{m_-} \sum_{\{i \vert y_i = -1 \}} \langle \mathbf{x}, \mathbf{x}_i \rangle + b \right) \\ &= \text{sgn} \left( \dfrac{1}{m_+} \sum_{\{i \vert y_i = +1 \}} k( x, x_i ) - \dfrac{1}{m_-} \sum_{\{i \vert y_i = -1 \}} k( x, x_i ) + b \right). \tag{1.11} \end{align}$$
Similarly, the offset becomes
$$b := \dfrac{1}{2} \left( \dfrac{1}{m^2_-} \sum_{\{(i, j) \vert y_i = y_j = -1 \}} k( x_i, x_j ) - \dfrac{1}{m^2_+} \sum_{\{(i, j) \vert y_i = y_j = +1 \}} k( x_i, x_j ) \right). \tag{1.12}$$
Surprisingly, it turns out that this rather simple-minded approach contains a well-known statistical classification method as a special case. Assume that the class means have the same distance to the origin (hence $b = 0$, cf. (1.10)), and that $k$ can be viewed as a probability density when one of its arguments is fixed. By this we mean that it is positive and has unit integral,
$$\int_\mathcal{X} k(x, x^\prime) \ dx = 1 \ \text{for all} \ x^\prime \in \mathcal{X}. \tag{1.13}$$

In chapter 1.1 Data Representation and Similarity, $k$ was defined as follows:

Let us consider a similarity measure of the form
$$\begin{align} k: &\mathcal{X} \times \mathcal{X} \to \mathbb{R} \\ &(x, x^\prime) \mapsto k(x, x^\prime), \tag{1.2} \end{align}$$
that is, a function that, given two patterns $x$ and $x^\prime$, returns a real number characterizing their similarity. Unless stated otherwise, we will assume that $k$ is symmetric, that is, $k(x, x^\prime) = k(x^\prime, x)$ for all $x, x^\prime \in \mathcal{X}$. For reasons that will become clear later (cf. Remark 2.16), the function $k$ is called a kernel.

What is the reasoning behind
$$\int_\mathcal{X} k(x, x^\prime) \ dx = 1 \ \text{for all} \ x^\prime \in \mathcal{X} \tag{1.13}$$
only being integrated with respect to $x$? What about the $x^\prime$?
Comment: The statement below (1.2) states $k$ is symmetric, which implies integrating over $x$ will give the same result as integrating over $x^\prime.$
Comment: If you think the point isn't entirely trivial then posting an answer would be good.
Comment: @whuber Ok, thanks for the clarification.
Comment: Could you please clarify your question, then?  If it isn't answered by the symmetry, what are you trying to ask?
Comment: @whuber You indeed answered my question. Am I supposed to delete this? Or should I post a community answer?
Answer: As whuber stated in the comments, the statement below (1.2) states $k$ is symmetric, which implies integrating over $x$ will give the same result as integrating over $x^\prime$.


Second differences notion behind GAM penalties

Question: I'm going back through Simon Wood's book on generalized additive models (GAMs) and came back across the definition of the penalty term employed, which is supposed to combat overfitting of smooths. The equation used is the following:
$$
\Vert{y-X\beta}\Vert^2 + \lambda \sum_{j=2}^{k-1}\{ f(x^*_{j-1})-2f(x^*_j) + f(x^*_{j+1}) \}^2
$$
The book goes on to explain this formula in the following sentence:

The summation term measures wiggliness as a sum of squared second
differences of the function at the knots (which crudely approximates
the integrated squared second derivative penalty used in cubic spline
smoothing: see section 5.1.2, p. 198). When f is very wiggly the
penalty will take high values and when f is 'smooth' the penalty will
be low. If f is a straight line then the penalty is actually zero.

So here is what I get from this paragraph:

The summation from the right side of the equation, if higher, indicates high wiggliness and will be penalized thereafter.
The second differences are some kind of approximation of quadratic, cubic, etc. relations with the variable.
There is no penalty assigned when the function is linear because there is no wiggliness to add to the right side of this equation.

My question is the following...how exactly does this equation achieve this? I'm not sure if the $\lambda$ component is part of the confusion, because from what I see it is simply labeled as the smoothing parameter on the next page. The three functions within the equation confuse me as to what they are doing exactly, and the exponent on the outside of the brackets also doesn't make it immediately clear what is going on.
Answer: The three bits of this equation
$$
\Vert{y-X\beta}\Vert^2 + \lambda \sum_{j=2}^{k-1}\{ f(x^*_{j-1})-2f(x^*_j) + f(x^*_{j+1}) \}^2
$$
are:

$\Vert{y-X\beta}\Vert^2$ is the sum of squared errors, which is measuring the lack of fit of the piecewise linear spline being fitted

$\lambda$ is the smoothing parameter, which we use to control how much penalty we pay for the wiggliness of the estimated spline

$\sum_{j=2}^{k-1}\{ f(x^*_{j-1})-2f(x^*_j) + f(x^*_{j+1}) \}^2$ is the sum of squared second differences

The last term is the same as a second order central finite difference of the values of the spline $f()$ at the knot locations. The second order central finite difference is
$$
f^{\prime \prime}(x) \approx \frac{f(x + h) - 2f(x) + f(x - h)}{h^2}
$$
which as shown is an approximation of the second order derivative of the function $f()$. As we are differencing evenly spaced knots, $h = 1$ and so the $h$s disappear yielding essentially the same thing as in the equation you quoted.
What we are doing here is getting an estimate of the "curvature" (second derivative) of the spline at each internal knot by differencing the values of the spline at the focal knot plus the previous and next knots.
If the spline were flat, the values of the function at the focal knot and the previous and next knots would be the same value so the bit in {} for a single focal knot would be equal to 0. If the spline was a straight line, then $f(x^*_{j+1})$ would be twice as large as $f(x^*_{j-1})$, but as we subtracted off $2f(x^*_j)$ so the sum also equals 0. The constant function or other straight line have 0 curvature and this is what we see when we think about those functions in terms of the second order central finite difference.
We square this second order difference because the spline could be curved down or up (concave or convex) and as such a spline that oscillated about some value would likely have zero second order finite difference when summed over the spline because of all the peaks and valleys cancelling each other out. But this would incorrectly measure the wiggliness of such a function; intuition tells us that an oscillating function (say a sine wave) has a lot of wiggliness. Squaring the finite difference estimate of the second derivative solves this problem. It is the same idea as summing squared errors rather than summing errors as a measure of lack of fit.
As for $\lambda$, this controls how much penalty we pay for wiggliness in the spline. If we let $\lambda \rightarrow \infty$, then any wiggliness in the spline will dominate the equation, so the smallest value of the entire equation will be when the penalty (the summation term) is 0, i.e. when we have a straight line. Then we recover a linear model (in this case). If we let $\lambda \rightarrow 0$ then we pay no penalty for the wiggliness and we recover an unpenalised piecewise linear regression fit. This latter fit model would likely be overfitted to the data, while the former would be underfitted if the true relationship was not linear. Hence there will be some optimal value of $\lambda$ that allows the spline/model to fit the data reasonably well without overfitting, and we can recover a non-linear estimate of the relationship between $y$ and $x$ if one exists (given sufficient data for the noise level).
You can think of $\lambda$ as controlling the trade off between the smoothness of the estimated function (the spline) and the closeness of the fit to the data.
If you flip the page to p. 168 Simon goes on to explain that the summation can be written more concisely if we realize that for the tent basis functions he is using in the example, the value of the function at the $j$th knot ($f(x^*_j)$) is the same as the coefficients of $f$, i.e. $\beta_j = f(x^*_j)$. Substituting these coefficients into the term in the sum we would get ${\beta_{j-1} - 2\beta_j + \beta_{j+1}}$. If we write out all the terms in the sum (for $j=2$ through $j=k-1$), and stack them in a matrix, we get
$$
\begin{bmatrix}
\beta_1 - 2\beta_2 + \beta_3\\
\beta_2 - 2\beta_3 + \beta_4\\
\beta_3 - 2\beta_4 + \beta_5\\
\vdots \\
\end{bmatrix}
$$
and we can decompose this matrix into a a vector of coefficients $\boldsymbol{\beta}$ and a difference matrix $\mathbf{D}$
$$
\begin{bmatrix}
\beta_1 - 2\beta_2 + \beta_3 \\
\beta_2 - 2\beta_3 + \beta_4 \\
\beta_3 - 2\beta_4 + \beta_5 \\
\vdots
\end{bmatrix} =
\begin{bmatrix}
1 & -2 & 1  & 0 & \cdots & \cdots & \vdots \\
0 & 1  & -2 & 1 & 0 & \cdots & \vdots \\
0 & 0 & 1  & -2 & 1 & 0 & \vdots \\
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \ddots
\end{bmatrix}
\begin{bmatrix}
\beta_1 \\
\beta_2 \\
\beta_3 \\
\vdots
\end{bmatrix} = \mathbf{D}\boldsymbol{\beta}
$$
To make progress with other kinds of splines (and the more compact notation used by Simon in the rest of his book), we want to write the penalty in quadratic form, $\boldsymbol{\beta}^{\mathsf{T}}\mathbf{S}\boldsymbol{\beta}$ for a penalty matrix $\mathbf{S}$. We can turn $\mathbf{D}$ into $\mathbf{S}$ via
$$
\mathbf{S} = \mathbf{D}^{\mathsf{T}}\mathbf{D}
$$
and hence we can equate each of the main topics we have discussed into
$$
\sum_{j=2}^{k-1}\{ f(x^*_{j-1})-2f(x^*_j) + f(x^*_{j+1}) \}^2 = \boldsymbol{\beta}^{\mathsf{T}}\mathbf{D}^{\mathsf{T}}\mathbf{D}\boldsymbol{\beta} = \boldsymbol{\beta}^{\mathsf{T}}\mathbf{S} \boldsymbol{\beta}
$$
Comment: Wow this is a wonderful answer. Thank you for spending the time writing out a comprehensive explanation.


autozoom canvas to fit bitmap

Question: In my custom views OnDraw method I draw a Bitmap to the center of the Canvas with
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    Rect r = canvas.getClipBounds();
    displayWidth = r.right;
    displayHeight = r.bottom;
    camera.applyToCanvas(canvas);
    float zW = (float)bitmapWidth / (float)displayWidth;
    float zH = (float)bitmapHeight / (float)displayHeight;
    float z = 0.0f;
    if (zW>1 || zH>1) {
        z = Math.max(zW, zH);
    }
    canvas.drawColor(Color.DKGRAY);
    canvas.drawBitmap(bitmap, (displayWidth/2.0f - (bitmapWidth)/2.0f), (displayHeight/2.0f - bitmapHeight/2.0f), paint);
    if (z>0) {
        camera.translate(z, -z, z);
    }
}

If the Bitmap is larger in height or width is larger then Canvas size (displayWidth, displayHeight), how can I use the Camera class to autozoom to fit the Bitmap and center it to the Canvas. Any ideas?
Answer: Try to create a Matrix instance and initialize it using
public boolean setRectToRect (RectF src, RectF dst, Matrix.ScaleToFit stf)
You need to do this only once and keep the matrix in memory. Note that Matrix.ScaleToFit define the CENTER value.
Later when you draw the bitmap use this version of the drawBitmap:
public void drawBitmap (Bitmap bitmap, Matrix matrix, Paint paint)

autozoom canvas to fit bitmap


What characteristics of a single-coil (Telecaster) sound to consider for simulation?

Question: I am in the course of simulating a Telecaster guitar with supercollider, i.e. electronically. I started with the low E-String and results were satisfactory. Then I tried the high e-String and had nothing but trouble.
When I compare the synthesized high-e with a sampled high-e I noticed a number of differences:

The sampled string sounds like there is a light chorus effect applied. I had noticed this while live playing and it only happens when you use both pickups (the sample was taken with both pickups) and only on the higher strings. Adding a chorus is one of the easiest things to do, but in order to make it realistic, I would need to understand the physics behind it.
I suspect that there are waves travelling up and down the string which reach the two pickups with a small delay, but for a chorus effect I would need a detune, which would not happen with a simple delay.
The sampled string sounds a lot brighter and exhibits the typical single-coil "twang" while the synthesized string sounds more like a nylon string. No matter how much EQ I applied, I didn't succeed in getting the twang into the synthesized sound. I could make it ultra-bright and it just sounded shitty and artificial.

So can anybody explain

the cause of the chorus effect?
why and how a steel string sounds different than a nylon string.
the characteristics of the single-coil twang
Comment: Are you sure it is not just a non-uniform delay? the very short delays involved in a wave passing from one pickup to the other will produce (non-modulated) flanger-like notches in the spectrum.
Comment: FFT FTW  :-).  Which is to say: generate graphs of the Fourier Transform of both the sample and synth, and see if some obvious peaks match or don't match between them.   BTW,  **all** frequencies a string generates are travelling waves.  The standing waves are simply superpositions of travelling waves, and most certainly the various harmonics will have different phase relations at the physical location of the pickup.
Comment: The question is: why should the delay not be constant? For a chorus-like effect either the delay or the pitch needs to change ove time. Otherwise the notches stay at the same pace all the time
Comment: Non-uniform might not have been the right word.  All of the delays are of constant latency, but there is more than one of them, and they all have different (short) delay times.
Comment: @MartinDrautzburg - if delay changes, it shouldn't alter the pitch. Digitally it won't, but if we're  talking old tape echoes, changing the speed of the delay often changed the pitch.
Comment: I looked at the average and peak fft and it gave me some clues about how to apply EQ. This improved the twang somewhat (but still not satisfactory). The chorus is still a mystery to me.
Comment: You might find relevant and interesting information regarding string and guitar synthesis here: http://www.soundonsound.com/sos/Aug01/articles/synthsecrets28.asp here: http://www.soundonsound.com/sos/Sep01/articles/synthsecrets29.asp and here: http://www.soundonsound.com/sos/Oct01/articles/synthsecrets30.asp
Answer: Answering my own question after a fair amount of research.
A steel string sounds different than a nylon string
Unlike a nylon string, a steel string does not vibrate like an ideal string, because it has a significant inner stiffness. This has the effect, that the partials/harmonics are not exact multiples of the fundamental, but are shifted towards higher frequencies.
This is a well-known phenomenon and the reason why grand pianos are tuned in a "stretched" way, so the partials of the low strings coincide with the fundamentals of the higher strings.
This is well in line with my supercollider experiments, where detuning the partials indeed turns a nylon string into a steel string. See also Miguel Negaro's thesis.
The cause of the chorus effect
Now when there is some non-linearity involved, this will create partials, which are exact multiples of the fundamental (or exact multiples of another partial). In any case, the partials caused by non-linearity do not have the excact same pitch as the partials caused by the viabrating (stiff) string itself. Eh voila, you have a chorus effect.
Now where should a non-linearity come from? The thing is, a guitar pickup simply does not have to be linear with respect to a single string. You can add a fair amount of distortion to a single string, and you would only percieve a slightly increased brightess. It is the sum and difference frequencies which makes non-linearity sound unpleasant. This happens when you run the guitar through an "overdrive", but it doesn't happen, when you look at only one string.
A real pickup is close to six individual pickups, one for each string, because it has six individual magnets. So a pikckup has some non-linearity, simply because nobody bothered to make it super linear.
The only thing I cannot explain, is why the chorus effect is more pronounced when I use both pickups. It may simply be caused by cancellation effects (or the absence therof), but I am not sure.
The characteristics of the single-coil twang
Most of the information I found, suggest that the "twang" is not caused by single coil pickups, but by a particular playing style. The twang comes from your fingers and many insist, that humbuckers can twang as well, when played properly.
Comment: Nice analysis! — "_Unlike_ a nylon string"? I was always under the impression that nylon strings had _stronger_ inharmonicity, have you measured otherwise? (Of course, on a nylon string the higher harmonics decay faster, so it might just be less noticable.)
Comment: No I dind't measure this. You may be right, that the inhamonicity simply decays faster on a nylon string and therefore it sounds more like an ideal string.
Comment: Many cheap pickups have one magnet, but six ferromagnetic pole pieces which direct the magnetic field along six essentially-independent paths.
Answer: Just a thought. The neck pup on Telecasters is placed exactly under a harmonic node. I found this when I 'lost' the double octave on mine, playing the harmonic at that point (24th fret position - which, on Telecasters, obviously has no fret), When I changed from neck pup to bridge pup, the harmonic was audible again. It MAY be that as the neck pup and the bridge pup hear slightly different notes, or yours is out of intonation, a chorus effect is apparent. Try the top string on different frets - this phenomenon will only be there with an open string. - Or try using only one pup.
Comment: Interesting point. Yesterday I added a Comb-filter to mimick the effect, that a pickup is at a certain position and thus may emphasize or deemphasize certain modes. When I modulate the frequencies of the comb filter I get this chorus effect, althought I feel like I am cheating.
Comment: I added the pickup position by adding a delay with 180 degree phaseshift. It lowers the frequency of the fundamental and this is a small step forwards. Still not as much twang as I had hoped for and no chorus at all (unless I fake it)
Comment: @MartinDrautzburg How does a delay (where?) change the input frequency?  Are you sure you haven't just created a difference frequency output?
Comment: The idea is that a wave along the string bounces back from the bridge with 180 degree phaseshift. I add the delayed signal to the original signal. If you are close to the bridge everything gets compeltely cancelled. As you move away from the bridge the higher frequencies will recover more quickly than the lower frequencies. Thus each spot below the strings has a characteristic frequency response.
Comment: I wonder if that's the reason why, when playing harmonics, they are easier to sound when you pluck very close to the bridge
Comment: I doubt that. You will get a different excitation which affects the proportion of the harmonics
Answer: "I suspect waves travelling reach the two pickups with a small delay"
Sounds plausible. Have you tried to verify the hypothesis? You could modify a guitar so as to make the pickups moveable, and then make multiple samples while varying the position of the pickups.
"why should the delay not be constant?"
waves of different freq travel at different speed. So it seems to me that, if your hypothesis is correct, this effect you're hearing would vary with the pitch. Naively I would say that the delay would become less and less as the pitch gets higher, since the wave nodes are closer to each other.
Another thought: if the hypothesis is correct, then perhaps you could synthesize the effect by making two samples, one for each pickup, and then mix those back together.
Comment: Even if the delay depends on the frequency, I would still not get a chorus effect. For a chorus I need a delay which changes over time (not frequency). I did simulate the output of the two pickups and mixed them (though not by using samples, but with the Karplus Strong algorithm). I don't get a chorus effect and I wouldn't know why I should.


Dúvida filtro com linq, ASP NET MVC

Question: Estou com uma dúvida em um filtro usando Linq,
Tenho um objeto critica
Dentro de crítica tem um ienumerable
Preciso retornar uma lista de criticas que o status do  ultimo movimentocritica for igual a 2
Porém o código abaixo está dando erro
var Criticas = from a in Db.Criticas select a;
Criticas = Criticas.Where(c => c.MovimentacoesCritica.LastOrDefault().Status.Equals(2));

Comment: li vinte vezes e nao entendi a sua dúvida! :D
Comment: Você disse que está com uma dúvida, mostrou um pouco de código e deu uma explicadinha básica no que você está tentando fazer. Mas no fim, você não disse qual é a dúvida afinal!
Comment: Você quer obter o ultimo registro com o status igual a 2? Tá bem confuso.
Comment: Está muito confuso... Você deseja pegar o ultimo item da lista quando o mesmo possui status igual a 2? ou deseja pegar o ultimo da lista que esteja com status 2?
Answer: Simulei seu código no LinqPad com Lists e Enumerable e funcionou corretamente, provavelmente o problema está porque a sua query (var Criticas = from a in Db.Criticas select a;)retorna um objeto IQueryable e ao chamar o Where ele não consegue processar o LastOrDefault para um novo IQueryable.
Tente converter Criticas para List ou Enumerable
var Criticas = (from a in Db.Criticas select a).ToList();
    var ListCriticas = Criticas.Where(c => c.MovimentacoesCritica.LastOrDefault(o => o.Status.Equals(2)) != null);

Comment: O correto aí seria: `c.MovimentacoesCritica.LastOrDefault(e => e.Status.Equals(2))`
Comment: dá o seguinte erro: An exception of type 'System.ArgumentNullException' occurred in System.Core.dll but was not handled in user code

Additional information: Valor não pode ser nulo.
Comment: @KleberBarros, deve ser que o LastOrDefault esta retornando null porque não tem nenhum item na lista. o LastOrDefault gera este null quando não existem itens na lista.
Comment: @FilipeOliveira, realmente, vou editar a resposta, isso vai até resolver a questão de lista vazia que o Kleber comentou. vlw
Comment: Continua dando ArgumentNullException
Comment: @KleberBarros O campo Status aceita valores nulos? pode ser que algum item da lista esta com a propriedade nula e neste caso o .Equals lança exceção tente mudar a condição para (o => o.Status != null && o.Status.Equals(2))

Dúvida filtro com linq, ASP NET MVC


Asp.net formatting lists of grouped data

Question: I have a asp.net page where i query a list of url and the groups in the urls.  In the code behind i loop through each group and create a group header and then list all of the links.
something like this:
Group 1
 Link 1
 Link 2
 Link 3
Group 2
 Link 1
 Link 2
 Link 3
Now that i have a lot of links, this create one long list on the page and you have to scroll down.
What are the best suggestions for formatting this data using multiple columns or other layout options so it looks better on a single page rather than one long list.
Any example code would be great . . .
Comment: This is really a design / aesthetics question.
Answer: For ASP.NET 3.5 you could use ListView the control. A nice tutorial for grouping can be found here. If you are using ASP.NET 1.x or 2.0 you can try the DataList control (check the RepeatColumns and RepeatDirection properties). The ListView is more powerful.


Cosine Trigonometry Question

Question: Find the radian measure of $\theta$ if $0 \leq \theta \leq 2\pi$ and $$\cos(\theta)(2\cos(\theta)-1) = 0.$$ I'm very new to this topic, so what I did was to take the inverse of $\cos$ from both sides, and then you're left with $$2\cos(\theta) - 1 = 1.570\,\,\, (\text{radians}).$$ Then get rid of the 2 and -1: $\cos(\theta) = 0.285$. Now take the inverse from both sides again and you end up with 1.281 radians.
My calculations are probably complete B.S. Can anyone help me out here?

Why are there more than 1 answers on my answer sheet?
Can you please help me get the right answers?
This is on a non calculator paper - (however my teacher admits that several questions belong in the calculator paper) - Is it likely that the question will be in the calculator paper instead, or am I just missing the big point of it all?

Thanks so much,
John.
Comment: So you find the values of $\theta$ within $[0,2\pi]$ that satisfy $\cos\theta=0$ or $\cos\theta=\frac12$...
Comment: ...you may want to recall the unit circle and those special angles at that point.
Comment: I've added LaTeX formatting to your question, John.
Comment: Possibly the idea of taking the inverse $\cos$ came from the parentheses. The analysis may be more obvious if the equation is written as $(\cos\theta)(2\cos\theta -1)=0$. Or, if we really want parentheses around $\theta$, $[\cos(\theta)][2\cos(\theta)-1]=0$.
Answer: Note that, for any two numbers $x$ and $y$,
$$xy  =0 \qquad\text{ if and only if }\qquad x=0,\text{ or }y=0.$$
Thus,
$$\cos(\theta)(2\cos(\theta)-1)=0\qquad\text{ if and only if }\qquad \cos(\theta)=0,\text{ or }(2\cos(\theta)-1)=0.$$
So, there are two possibilities; either $\cos(\theta)=0$, or $2\cos(\theta)-1=0$. Rearranging the second equation, we get that either
$$\cos(\theta)=0\qquad\text{ or }\qquad \cos(\theta)=\frac{1}{2}.$$
Do you know which values of $\theta$ are between $0$ and $2\pi$ (i.e. $0\leq \theta\leq 2\pi$) and  make $\cos(\theta)=0$? (Look at the graph of $\cos$ if you're not sure.)
What about the values of $\theta$ between $0$ and $2\pi$ that make $\cos(\theta)=\frac{1}{2}$? Note that if $\cos(\theta)=\frac{1}{2}$, then we can make a right triangle with $\theta$ as one of the angles, and

Can you find the value of OPP using the Pythagorean theorem? Do you know what kind of triangle has sides in these proportions? Take a look here.

Your approach of dividing by $\cos(\theta)$ on both sides of the equation
$$\cos(\theta)(2\cos(\theta)-1)=0$$
is flawed, because if $\cos(\theta)=0$ then we have just divided by $0$, which isn't allowed. To make this clearer, suppose we are looking for the values of $x$ such that
$$x^2-x=0.$$
There are two solutions: $x=0$ and $x=1$. We can't divide both sides by $x$ to get
$$x-1=0$$
which has only one solution (namely, $x=1$) because then we will miss the solution $x=0$.
Comment: @John: You actually *should* have the values of $\theta$ for which $\cos(\theta)=0$ and $\cos(\theta)=\frac{1}{2}$ memorized; they are pretty important (even better, make sure you understand **why** it is those values of $\theta$; then if you forget, you can always work it out for yourself). And, personally, I would **not** treat this is as a calculator question; you can express these $\theta$'s as precise fractions of $\pi$ (like $\frac{\pi}{2}$ or $\frac{2\pi}{3}$, for example), and (in my opinion) you should give your answers like this, not as decimals.
Comment: @John: "Look at the graph of $\cos$ if you're not sure." is one way; the other (if you happen to be more familiar with it) would be to recall that the cosine corresponds to the x-coordinate of a point on the unit circle. Now, you will have to recall some of the special angles your teacher may have asked you to commit to memory...
Comment: Thanks so much! I assume that this is a calculator paper question then, cause I doubt she wants us to remember specific values. On the calculator I can call up the cos graph by typing y=cos(x) right? How do I check for certain values on that graph? Its one of those graphic Texas INstruments Calculators that schools supply.
Comment: Sorry I have been teaching the whole of precalc to myself in the past 2 weeks. I am doing great on everything else now, but trig is hard without a teacher.
Comment: If you're using the TI-83 Plus (the one that I recall is pretty common) @John, press the `[TRACE]` button and then you can enter values for checking...
Comment: Thats to check for the X, but I need the Y, dont I? Y=cos(x)
Comment: @John: I was assuming you already had the cosine plotted... :)

Cosine Trigonometry Question


Influence of water temperature on swimmer performance

Question: What is the optimal water temperature for a swimmer performance?
Are there records of swimmer performance vs. water temperature?
I'm not a swimmer but in general I would like to understand if there is specific knowledge about this
Answer: The viscosity of water decreases with temperature - this means that swimming is quicker in warmer water. As such, FINA regulations require that

Water Temperature shall be 25° - 28°.

(FR 2.12) so that times are comparable between different pools.
Comment: But additionally, there's impacts on the body (circulation, nerve response, etc)... so it'd be nice to see real data to see what the complete effect is, and how much it varies by person.  Additionally, since the variation within even those 3 degrees is rather significant (3% of the 2°-25° difference), if it has more than a few millisecond impact, it should be a bit factor in times.
Comment: And additionally there's maybe even the added consideration that slight differences in the pool cause big handicaps: 1° is ~2% viscosity difference... if that has the same difference in speed... that'd, for example drop the 2012 gold winner in the 400m (Ryan Lochte) to 4th.  There's only so much you can do to perfect conditions, but it'd be interesting to know what impact a degree might really have on a racer!
Comment: Obviously the viscosity decrease reverses severely as you get close to 0 C/32 F. :D
Comment: While the stated temperature limit is true (similar wording in USA Swimming regulations), a direct causal connection to viscosity of the water may not be warranted. As an added data point, the open water rules are, not surprisingly, broader, with a minimum of 16C, and for 5K and longer a maximum of 29.45C, and then further limits on (air+water) temperatures (USA Swimming 702.2). These rules are for athlete safety, particularly after Fran Crippen died in an open water event.
Answer: I can not comment. Otherwise I would have and most of my answer may be regarded as opinion based.
My children are/were competition swimmers (almost national level) and have the following observations.

Water is too cold, their muscles can not perform.
Water is too warm, they can not sweat out their heat (yes, even in water your body transpires heat out!) and this affects performance.

So, it's more a range of temperatures to fit optimal performance ranges. I doubt that it would affect record times as much as being noticeable. Obviously, each athlete has their own optimal temperature range. This would hold for any sport.
Having said that, the shorter distances would be expected to have a positive effect of higher water temperatures as you would be able to absorb the heat. Longer distances may even suffer from high temperatures as you can not dissolve the heat.
The regulations (as linked to in another answer) do not state why the temperature needs to be in a specific range. It can not be determined if this is due to less resistance in warmer water or due to the effect of water temperature on bodily performance.


Log Trig $\int_0^{\pi/2}\log^4 \tan \frac{x}{2}dx=\frac{5\pi^5}{32}$

Question: Hi I am trying to integrate a log trigonometric integral given by
$$
I:=\int_0^{\pi/2}\log^4 \tan \frac{x}{2}dx=\frac{5\pi^5}{32}.
$$
This is very similar to a previous integral posted except the power of the logarithm.
Note this integral is also equal to
$$
\int_0^{\pi/2}\log^4 \tan x \, dx=\frac{5\pi^5}{32}.
$$
I have wrote I as
$$
I=\int_0^{\pi/2} \left(\log \sin \frac{x}{2}-\log \cos \frac{x}{2}\right)^4 dx
$$
but got stuck here since factoring this out seems like a mess.  Having seen how David H solved a similar integral I posted, I tried another method starting with I and using $t=\tan x/2$, and obtained
$$
I=2\int_0^{1}\log^4 t \frac{dt}{1+t^2}.
$$
Following this I tried $u=-\log t$ but got stuck after this.  Thanks, it would be nice to see a solution that doesn't reduce the integral to a difficult sum to evaluate
Comment: Try expanding the $1/(1+t^2)$ using a geometric series, then using the result that
$$
\int_0^1 \log^4(t) t^{2n} \ \mathrm{d}t = \frac{4!}{(2n+1)^5}.
$$
Edit - just saw the caveat about difficult sums. Nevermind.
Comment: It is similar to [this one](http://math.stackexchange.com/a/770707/85343).
Comment: @BennettGardiner Yes, thank you for the suggestion though!  It is nice to see it done another way than having to evaluate a  non-trivial sum at the end.
Answer: $\newcommand{\+}{^{\dagger}}
 \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\down}{\downarrow}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}
 \newcommand{\wt}[1]{\widetilde{#1}}$
By following my previous answer you'll arrive to
\begin{align}
&\half\,\lim_{\mu \to 0}\partiald[4]{\sec\pars{\pi\mu/2}}{\mu}={\pi \over 2}\times
\\[3mm]&\lim_{\mu \to 0}\bracks{%
{5 \over 16}\,\pi^{4}\sec^{5}\left(\frac{\pi\mu}{2}\right)+\frac{9}{8} \pi ^4 \tan ^2\left(\frac{\pi\mu}{2}\right) \sec^3\left(\frac{\pi\mu}{2}\right)
+\frac{1}{16}\pi^{4}\tan^{4}\left(\frac{\pi\mu}{2}\right)\sec\left(\frac{\pi\mu}{2}\right)}
\\[3mm]&={\pi \over 2}\,{5\pi^{4} \over 16}
=\color{#00f}{\large{5\pi^{5} \over 32}}
\end{align}
Comment: Very helpful, thanks.  This seems like a brute force method to solving these integrals for any power of the log $\int_0^{\pi/2} \log^n \tan \frac{x}{2}dx $,  Thanks +1, EDit: $\Re(n)>-1/2$ for this to be convergent.
Comment: @Integrals For $n$ odd it must be zero.
Comment: Yes I have realized this.  Thanks again.
Comment: @FelixMarin. Why should it be zero if $n$ is odd ? I thought that, for any $n$, the result would express as $$(-1)^n 2^{-2 n-1} \left(\zeta \left(n+1,\frac{1}{4}\right)-\zeta
   \left(n+1,\frac{3}{4}\right)\right) \Gamma (n+1)$$ Where am I wrong ? Thanks.
Comment: @ClaudeLeibovici Yes. You are right. It's the integral from $0$ to $\infty$ ( original from $0$ to $\pi$ ) which has that property. I was confused. Thanks for your remark.
Answer: This post and related comments and answers are very interesting and allow the generalization of the problem to $$I(n)=\int_0^{\pi/2}\log ^n\left[\tan \left(\frac{x}{2}\right)\right]dx$$ for which the result is $$I(n)=(-1)^n 2^{-2 n-1} \left[\zeta \left(n+1,\frac{1}{4}\right)-\zeta
   \left(n+1,\frac{3}{4}\right)\right] \Gamma (n+1).$$ When $n$ is even, one can find a simple formula in terms of the Euler numbers: $$I(2n)=(-1)^nE_{2n}\left(\dfrac\pi2\right)^{2n+1},$$ e.g. $$I(0)=\frac{\pi}{2}$$ $$I(2)=\frac{\pi ^3}{8}$$ $$I(4)=\frac{5 \pi ^5}{32}$$ $$I(6)=\frac{61 \pi ^7}{128}$$ $$I(8)=\frac{1385 \pi ^9}{512}$$ $$I(10)=\frac{50521 \pi ^{11}}{2048}$$ and so on.
When $n$ is odd, all values are negative and cannot be expressed in any form simpler than the $\zeta$ function.
Comment: Thank you for a good problem and you are very welcome. Cheers.
Comment: Thanks!  Yes, The generalization of this problem is very nice. +1
Answer: \begin{align}
J&=\int_0^{\frac{\pi}{2}}\log^4 \left(\tan x\right) \, dx\\
&\overset{y=\tan x}=\int_0^\infty \frac{\ln^4 x}{1+x^2}\,dx\\
J_n&=\int_0^\infty \frac{\ln^n x }{1+x^2}\,dx\\
J_0&=\frac{\pi}{2}\\
K_n&=\int_0^\infty\int_0^\infty \frac{\ln^n(xy) }{(1+x^2)(1+y^2)}\,dx\,dy\\
&\overset{u(x)=xy}=\int_0^\infty \int_0^\infty \frac{\ln^n u}{(u^2+y^2)(1+y^2)}\,du\,dy\\
&=\int_0^\infty \frac{\ln^{n+1}u }{u^2-1}\,du\\
&=\int_0^1 \frac{\ln^{n+1}u }{u^2-1}\,du+\int_1^\infty \frac{\ln^{n+1}u }{u^2-1}\,du\\
&=\Big(1+(-1)^n\Big)\int_0^1 \frac{\ln^{n+1}u }{u^2-1}\,du\\
&=\Big(1+(-1)^n\Big)\left(\int_0^1 \frac{\ln^{n+1}u }{u-1}\,du-\int_0^1 \frac{u\ln^{n+1}u }{u^2-1}\,du\right)\\
&=\Big(1+(-1)^n\Big)\left(1-\frac{1}{2^{n+2}}\right)\int_0^1 \frac{\ln^{n+1}u }{u-1}\,du\\
&=\Big(1+(-1)^n\Big)\left(1-\frac{1}{2^{n+2}}\right)(-1)^{n+2}(n+1)!\zeta(n+2)\\
&=\Big(1+(-1)^n\Big)\left(1-\frac{1}{2^{n+2}}\right)(n+1)!\zeta(n+2)\\
K_n&=\sum_{k=0}^n \binom{n}{k} J_kJ_{n-k}\\
K_2&=\pi J_2\\
K_2&=\frac{45}{4}\zeta(4)\\
K_4&=\pi J_4+6J_2^2\\
K_4&=\frac{945}{4}\zeta(6)\\
\end{align}Therefore,
\begin{align}
J_4&=\frac{K_4-6{J_2}^2}{\pi}\\
&=\frac{K_4-6\left(\frac{K_2}{\pi}\right)^2}{\pi}\\
&=\frac{K_4-6{J_2}^2}{\pi}\\
&=\frac{\frac{945}{4}\zeta(6)-6\left(\frac{45}{4}\zeta(4)\times\frac{1}{\pi}\right)^2}{\pi}\\
&=\frac{945\zeta(6)}{4\pi}-\frac{6075\zeta(4)^2}{8\pi^3}\\
\end{align}
Moreover, if you assume,
\begin{align}
\zeta(4)&=\frac{\pi^4}{90}\\
\zeta(6)&=\frac{\pi^6}{945}
 \end{align}
Therefore,
\begin{align}
J&=J(4)\\
&=\frac{945}{4\pi}\times \frac{\pi^6}{945}-\frac{6075}{8\pi^3}\times \left(\frac{\pi^4}{90}\right)^2\\
&=\boxed{\frac{5}{32}\pi^5}
\end{align}
Answer: You've established that $$\int_0^{\pi/2}\log^4\tan\frac{x}{2}\,dx=\int_0^{\pi/2}\log^4\tan x\,dx,$$
now use $\log\tan x=\log\sin x-\log\cos x$ as well as
$$\int_0^{\pi/2}\log^m(\sin x)\log^n(\cos x)dx=\left[\left(\frac{\partial}{\partial a}\right)^m\left(\frac{\partial}{\partial b}\right)^n\frac{\Gamma(\tfrac{a+1}2)\Gamma(\tfrac{b+1}2)}{2\Gamma(\tfrac{a+b}2+1)}\right]_{(a,b)=(0,0)},$$
which comes from repeated differentiation of
$$\int_0^{\pi/2}\sin(x)^a\cos(x)^bdx=\frac{\Gamma(\tfrac{a+1}2)\Gamma(\tfrac{b+1}2)}{2\Gamma(\tfrac{a+b}2+1)}.$$
This should yield the result.
Answer: As OP did, $$
\int_0^{\frac{\pi}{2}} \log ^4\left(\tan \frac{x}{2}\right) d x=2 \int_0^1 \frac{\ln ^4 t}{1+t^2} d t=2 I^4(0),
$$
where $\displaystyle  I(a)=\int_0^1 \frac{t^a}{1+t^2} d t$.
By the expansion $\frac{1}{1+t^2} =\sum_{n=0}^\infty (-1)^nt^{2n}$ for $|t|<1$, we have
$$
I(a) =\int_0^1 \frac{t^a}{1+t^2} d t=\sum_{n=0}^{\infty}(-1)^n \int_0^1 t^a t^{2 n} d t =\sum_{n=0}^{\infty} \frac{(-1)^n}{2 n+1+a}
$$
Differentiating $I(a)$ by $4$ times w.r.t. $a$ yields
$$
I^{(4)}(a) =\sum_{n=0}^{\infty} \frac{(-1)^n4!}{(2 n+1+a)^4} =4!\left[\sum_{n=0}^{\infty} \frac{1}{(4 n+1+a)^5}-\sum_{n=0}^{\infty} \frac{1}{(4 n+3+a)^5}\right]
$$
Putting $a=0$ gives
$$
\begin{aligned}
I^{(4)}(0) & =4!\left[\sum_{n=0}^{\infty} \frac{1}{(4 n+1)^5}-\sum_{n=0}^{\infty} \frac{1}{(4 n+3)^5} \right]\\
& =\frac{3}{128} \left[ \zeta\left(5, \frac{1}{4}\right)-\zeta\left(5, \frac{3}{4}\right)\right]
\end{aligned}
$$
Hence we can conclude that
$$\int_0^{\frac{\pi}{2}} \log ^4\left(\tan \frac{x}{2}\right) d x =2 I^4(0) = \frac{3}{64}\left[\zeta\left(5, \frac{1}{4}\right)-\zeta\left(5, \frac{3}{4}\right) \right]= \frac{5 \pi^5}{32} $$
In general, $$
\int_0^{\frac{\pi}{2}} \log ^n\left(\tan \frac{x}{2}\right) d x=\frac{ n !}{2^{2n+1}}\left[\zeta\left(n+1, \frac{1}{4}\right)-\zeta\left(n+1, \frac{3}{4}\right)\right]
$$


$x^2+y^2=4x+8y+5$ intersects $3x-4y=m$ at two distinct points

Question:
$x^2+y^2=4x+8y+5$ intersects $3x-4y=m$ at two distinct points. What are $m$'s possible values?

I got that the centre of the circle is $C=(2,4)$ and its radius is $r=5$. If the line $l$ intersects the circle at two points, the distance between the line and $C$ is less than $r$:
$$\frac{|6-16-m|}5<5\implies-35<m<15$$
Is this correct?
Comment: The way the question is typed is unclear. Also, please include your efforts. What have you tried when solving this problem, and where did you get stuck?
Comment: @RaadShaikh It was all in there already.
Comment: @ParclyTaxel Ah, my bad, apologies for misunderstanding.
Comment: @FaaSaifee Yes, your solution is correct!
Answer: Your solution looks fine. If this was on a test or an assignment or something that I was correcting, I would personally prefer it if you added an intermediate step or two on how you found the circle, on how you set up the inequality, and on how you solved it. But that's a matter of presentation, not of math.
Alternately, consider the function in the plane given by $$x^2+y^2-4x-8y-5$$ It is zero exactly on the circle. Now restrict this function to the line. On the line, the value of $y$ is the same as the value of $\frac{3x-m}4$. So on the line, the entire function has the same value as $$x^2+\left(\frac{3x-m}4\right)^2-4x-8\cdot\frac{3x-m}4-5$$Whether this has zero, one, or two roots is determined by the discriminant of that quadratic. Which gives you a quadratic inequality to solve.
Is this more work? Looks like it is. But this way you can solve similar problems with ellipses and hyperbolas with little to no modification, which isn't true for your approach. Does that make one approach better than the other? Not at all. They are good at different things.
Comment: +1 : in addition to generalizing well, your answer is more elegant than my approach.
Answer: An alternative approach is, solve $3x - 4y = m$ for $y$.  Plug that into the other equation:
$$x^2 + \left(\frac{3x-m}{4}\right)^2 = 4x + 8\frac{3x-m}{4} + 5$$
Then solve for $x$ using quadratic:
$$x=\frac{3m+80 \pm 4\sqrt{-m^2-20m+525}}{25}$$
2 solutions will exist when $-m^2-20m+525 = -(m-15)(m+35) > 0$
This will tell you whether your final result is correct.
Comment: +1 : more elegant than my approach.
Answer: My approach involves Calculus, which may reasonably be regarded as off-limits, given the euclidean-geometry and analytical-geometry tags.
$\color{red}{\text{However}}$:
See editing in $~\color{red}{\text{red}}~$ to see how this answer may be salvaged, without Calculus.
I agree that the locus of satisfying points $(x,y)$ is represented by the circle of radius $(5)$, centered at $(x,y) = (2,4)$.  This is explicitly demonstrated by completing the square, so that the original equation is transformed into
$$(x^2 - 4x + 4) + (y^2 - 8y + 16) = 5 + 4 + 16.$$

Any line whose equation is $3x - 4y = m$ can have it's equation re-expressed as
$$y = \frac{3}{4}x - \frac{m}{4}.$$
Such a line has slope $\displaystyle \left(\frac{3}{4}\right).$
So, my plan of attack is:
Identify all points $(x,y)$ that satisfy both of the following equations:

$(x-2)^2 + (y-4)^2 = 5^2.$

$\displaystyle y' = \frac{dy}{dx} = \frac{3}{4}.$

Then, having found the two pertinent points $(x_1,y_1)$ and $(x_2,y_2)$ that satisfy both of the above requirements, I will compute the two values of $(m)$ such that the equations
$\displaystyle y_1 = \frac{3}{4}x_1 - \frac{m_1}{4}$
$\displaystyle y_2 = \frac{3}{4}x_2 - \frac{m_2}{4}$
are satisfied.
Then, having identified these two points as $m_1$ and $m_2$, I will infer that you must have that $m$ lies strictly between $m_1$ and $m_2$.

Using implicit differentiation,
$(x-2)^2 + (y-4)^2 = 25 \implies $
$2(x-2) + 2(y-4)y' = 0.$
Since $y'$ is required to be $\dfrac{3}{4}$, I am looking for the points on the circle such that
$$\frac{x-2}{4-y} = \frac{3}{4} \implies (12 - 3y) = (4x - 8) \implies $$
$$(20 - 4x) = 3y \implies y = \frac{20 - 4x}{3}. \tag1 $$
$\color{red}{\text{Salvaging the answer, without Calculus}}$
If the two pertinent points are $(x_1,y_1)$ and $(x_2,y_2)$, and if you construct the line segments
$$\overline{(2,4),(x_1,y_1)}, ~~~ \overline{(2,4),(x_2,y_2)}, $$
then (in the Analytical Geometry world), each of these line segments must be perpendicular to the required slope.  This is because the line segment going from the center of the circle to the point of tangency must be perpendicular to the tangent line.
Therefore, the two line segments must each have slope $~\dfrac{-4}{3}.~$
That is, in $~\Bbb{R^2},~$ two (non-vertical, non-horizontal) lines are perpendicular, if and only if the product of their slopes is $(-1)$.
So, the two points $(x_1,y_1), (x_2,y_2)$ must each satisfy:
$$\frac{4 - y}{2 - x} = \frac{-4}{3},$$
which is equivalent to (1) above.

This implies that $x$ must satisfy
$$(x - 2)^2 + \left[\frac{20 - 4x}{3} - 4\right]^2 = 25 \implies $$
$$(x - 2)^2 + \left[\frac{8 - 4x}{3}\right]^2 = 25 \implies $$
$$(x - 2)^2 \left\{ ~\left[1\right]^2 + \left[\frac{-4}{3}\right]^2 ~\right\} = 25 \implies $$
$$(x - 2)^2 \left[1 + \frac{16}{9}\right] = 25 \implies $$
$$(x-2)^2 \times \frac{25}{9} = 25 \implies $$
$$(x - 2)^2 = 9 \implies (x - 2) \in \{\pm 3\} \implies $$
$$(y - 4) \in \{\pm 4\}.$$
Note
In the Analytical Geometry world, a shortcut is to realize that since the line segment going from the center of the circle to the two points of tangency has slope $~\dfrac{-4}{3}~$, you must have that the two triangles represented by
$$\triangle\{(2,4),(x,4),(x,y)\}$$
must each be a $3-4-5$ right triangle.

Therefore, the $4$ elements $\{(-1,0), (-1, 8), (5,0), (5,8)\}$ must be individually examined, to determine which of these elements satisfy (1) above, which is:
$$y = \frac{20 - 4x}{3}.$$
The pertinent points are $\{(5,0),(-1,8)\}.$
Therefore, the next step is to identify the two values $m_1, m_2$ such that
$$0 = \left[\frac{3}{4}\times (5)\right] - \frac{m_1}{4}, ~~ 8 = \left[\frac{3}{4}\times (-1)\right] - \frac{m_2}{4} \implies $$
$$m_1 = 15, m_2 = -35.$$
Therefore, you must have that
$$-35 < m < 15.$$


The Hessian matrix A may be Indefinite or what is known Positive Semidefinite or Negative Semidefinite

Question: We are about to look at an important type of matrix in multivariable calculus known as Hessian Matrices. We will then formulate a generalized second derivatives test for a real-valued function $z=f(x_1,x_2,...,x_n)$ of n variables with continuous partial derivatives at a critical point $a=(a1,a2,...,an)∈D(f)$ to determine whether $f(a)$ is a local maximum value, local minimum value, or saddle point of $f$
Definition: Let $x=(x1,x2,...,xn)$ and let $z=f(x1,x2,...,xn)=f(x)$ be an n variable real-valued function whose second partial derivatives exist. Then the Hessian Matrix of f is the n×n matrix of second partial derivatives of f denoted $$\mathcal H (\mathbf{x}) = \begin{bmatrix} f_{11} (\mathbf{x}) & f_{12} (\mathbf{x}) & \cdots & f_{1n} (\mathbf{x})\\ f_{21} (\mathbf{x}) & f_{22} (\mathbf{x}) & \cdots & f_{2n} (\mathbf{x})\\ \vdots & \vdots & \ddots & \vdots \\ f_{n1} (\mathbf{x}) & f_{n2} (\mathbf{x}) & \cdots & f_{nn} (\mathbf{x}) \end{bmatrix}$$.
a)$\mathcal H (\mathbf{x})$ is said to be $\textbf{Positive Definite}$ if $D_i>0$ for i=1,2,...,n.
b) $\mathcal H (\mathbf{x})$ is said to be $\textbf{Negative Definite}$ if $D_i<0$ for odd i∈{1,2,...,n} and Di>0 for even i∈{1,2,...,n}.
c) $\mathcal H (\mathbf{x})$ is said to be $\textbf{Indefinite}$ if $det(\mathcal H (\mathbf{x}))=D_n≠0$ and neither a) nor b) hold.
d) If $det(\mathcal H (\mathbf{x}))=D_n=0$, then $\mathcal H (\mathbf{x})$ may be Indefinite or what is known Positive Semidefinite or Negative Semidefinite.
I'm studying a function that has a $det(\mathcal H (\mathbf{x}))=D_n=0$
What is the appropriate way to classify critical points if $det(\mathcal H (\mathbf{x}))=D_n=0$
For example
Assume we have this function
$$f(x_1,x_2,x_3)=x_1 x_2+x_1 x_3-x_1x_2 x_3 $$
therefore, we found the critical point by solve this system
$$\begin{equation}
\begin{cases}
\frac{df}{dx_1}=x_2+x_3-x_3 x_2=0\\
\frac{df}{dx_2}=x_1-x_1 x_3 =0\\
\frac{df}{dx_3}=x_1-x_1 x_2 =0
\end{cases}
\end{equation}$$
we get $c=(0,0,0)$
,use the Hessian matrix of f
$$\mathcal H (\mathbf{f(x_i)})=\left(
\begin{array}{ccc}
 0 & 1-x_3 & 1-x_2 \\
 1-x_3 & 0 & -x_1 \\
 1-x_2 & -x_1 & 0 \\
\end{array}
\right)$$
$det(\mathcal H (\mathbf{f(x_i)}))=D_n=0$
This test fails to determine the type of critical points
Is there another way?
Or modification of the solution and correction.
Thanks for the help.
Comment: @user7530 can you help me
Comment: $(0,0,0)$ isn't the only critical point of $f$. There's an entire curve along which $\nabla f=0$. This should give you a clue as to the nature of these critical points.
Answer: Compute the eigenvalues of the hessian.
If all the eigenvalues are nonnegative, it is positive semidefinite.
If all the eigenvalues are positive, it is positive definite.
If all the eigenvalues are nonpositive, it is negative semidefinite.
If all the eigenvalues are negative, it is negative definite.
Otherwise, it is indefinite.
Edit:
For that example, you have found $c=(0,0,0)$.
$$H(f(c))=\begin{bmatrix} 0 & 1 & 1 \\ 1 & 0 & 0 \\ 1 & 0 & 0\end{bmatrix}$$
$$H(f(c))-\lambda I= \begin{bmatrix} -\lambda & 1 & 1 \\ 1 & -\lambda & 0 \\ 1 & 0 & -\lambda\end{bmatrix}$$
\begin{align}\det(H(f(c))-\lambda I)&= \det\left(\begin{bmatrix}1 & 1 \\ -\lambda & 0 \end{bmatrix} \right) -\lambda \det \left( \begin{bmatrix}-\lambda & 1 \\ 1& -\lambda  \end{bmatrix} \right)
\\&=\lambda-\lambda(\lambda^2-1)
\\&=\lambda(2-\lambda^2)\end{align}
Hence, the eigenvalues are $0$, $\sqrt{2}$ and $-\sqrt{2}$. Hence it is indefinite.
Comment: Please can you solve the example in question, or give me the titles of some references on the subject
Comment: Edited the post.
Comment: Thank you so much for your answer @SiongThyeGoh


copy files in different location after the build

Question: To copy files in different location after the build is published, I tried the following:
Editing the csproj file, and adding this code, copies the dlls to bin of the relative path.
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
    CustomCollectFiles;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
  <ItemGroup>
    <_CustomFiles Include="..\*project*\**\*.dll" />
    <FilesForPackagingFromProject  Include="%(_CustomFiles.Identity)">
      <DestinationRelativePath>bin\%(Filename)%(Extension)</DestinationRelativePath>
    </FilesForPackagingFromProject>
  </ItemGroup>
</Target>

This works absolutely fine. I was just wondering if this can be done using post build events
something like this.. ( this doesnt work).
if $(ConfigurationName) == Release xcopy /y "$(ProjectDir)$(OutDir)$(TargetFileName)" "$(SolutionDir)$(OutDir)"

Is the first way is the "only way of doing it" with oneclick publish in VS2010? The concern being, the changes in the csproj files will not be shown anywhere, in VS2010.
Answer: Yes, you can do it without hacking using AfterBuild target and Copy task:
  <Target Name="AfterBuild">
    <ItemGroup>
      <_CustomFiles Include="..\**\*.dll" />
    </ItemGroup>
      <Copy
            SourceFiles="@(_CustomFiles)"
            DestinationFiles="@(_CustomFiles->'bin\%(Filename)%(Extension)')"
            SkipUnchangedFiles="true" />
  </Target>

Comment: "Hacking" or CopyAllFilesToSingleFolderForPackageDependsOn is still necessary, if you want this to work with WebDeploy. I ended up using AfterBuild target for Debug configuration and CopyAllFilesToSingleFolderForPackageDependsOn for Nightly configuration which gets deployed automatically.
Comment: Says exited with code 255. The bin folder is of other proj, and all its contents should be part of this proj while making the build.
Comment: I agree with you. I can say it is a [recommended](http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx) way. But @Priya10 asked a bit different thing.
Comment: In order to copy files in all publishing context, I found that you should also add a property node named 'CopyAllFilesToSingleFolderForMsdeployDependsOn' (i.e. with *Msdeploy* instead of *Package*). See [here](http://stackoverflow.com/questions/2747081/how-do-you-include-additional-files-using-vs2010-web-deployment-packages)
Answer: This will also work and is maintainable across different Visual Studio versions.
<Target Name="CustomFolderDeploy" AfterTargets="CopyAllFilesToSingleFolderForPackage" BeforeTargets="MSDeployPublish">
    <PropertyGroup>
      <CustomFolder>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\..\..\..\Lib\CustomFolder'))</CustomFolder>
    </PropertyGroup>
    <CreateItem Include="$(CustomFolder)\*.*">
      <Output TaskParameter="Include" ItemName="CustomFiles" />
    </CreateItem>
    <Copy SourceFiles="@(CustomFiles)" DestinationFolder="$(MSBuildProjectDirectory)\obj\$(Configuration)\Package\PackageTmp\bin" SkipUnchangedFiles="True" ContinueOnError="False" />
  </Target>


Which key are these notes and how to transpose it to the key of D?

Question: I am a beginner in music theory so please bear with me. I was looking up a document which talks about transposing music and I understand a few things I think about transposing music. But if I, for example, have a sequence of these notes:

    E D# E D# E E D# E F# G# F# G# A B A# B A# B

how do I determine which key they are in?
how do I transpose them to a key of D? Is this online tool accurate? https://transposr.com/
Answer: (It's going to be tough to explain all of this in a single answer. If you're interested in this, I strongly recommend finding a music theory text, either online or in hard copy. But I'll do my best to address it all here!)
When it comes to major and minor keys, the best way to determine tonality, in my opinion, is to determine the location of half steps. (You can also determine the location of the tritone, but really that's just a fancier way of determining the half steps.)
Major scales have a pattern of WWHWWWH, where H is a half step and W is a whole step (two half steps). Minor scales are a bit trickier, because there are three uses of minor—natural minor, harmonic minor, and melodic minor—but we can skip that for this answer.
Looking at your example, there are half steps between E and D♯, between G♯ and A, and between A♯ and B. (There's also a half step between A and A♯, but we'll address that in the next paragraph.) If we try to compare this to our WWHWWWH pattern, we see that the best fit starts on E. E to F♯ is a whole step, F♯ to G♯ is a whole step, G♯ to A is a half step, and so on.
The only trouble is the appearance of A♯. Here's where it gets tricky, but not too tricky, because we have a rule in tonal music: each note name will only appear once in a major scale. If another version of that note name appears, it will be a chromatic pitch. So since A makes sense in our E-major scale, we can view the A♯ as a chromatic pitch. All of this tells us that these pitches are likely in E major, with a brief move towards (what we call a tonicization of) B.
(Note: B major fits just as well as E major, and we could call the A a chromatic pitch in B major. My decision of E major comes from years of experience with tonal music, where it's a very common move for music to begin in the original key and move to the fifth scale degree. This is also more common than the ♭7 that would be the A at the beginning of a B-major excerpt.)
As for transposition, the quickest method (again, just my opinion) is to think in terms of scale degrees. In E major, the pitches you wrote are 1 7 1 7 1 1 7 1 2 3 2 3 4 5 ♯4 5 ♯4 5. Now we can just think in D major—D E F♯ G A B C♯ D—and write out those scale degrees in D to transpose. This results in D C♯ D ♯ D D C♯ D E F♯ E F♯ G A G♯ A G♯ A.
Comment: Seems more likely in key E, with the B/A# copying the E/D#.
Comment: So, the same melody may be in several different tonalities at once?
Comment: @BarafuAlbino Not exactly, but close. A melody is usually in *one* tonality, but it can have passing references to other keys. We call these passing references "tonicizations."
Comment: Very nice, concise description.  I was thinking the same thing myself.  Another reason for preferring E Major is the strong establishment of E with the opening phrase.  It's just screaming "E Major!"
Comment: Nice answer. Just to point out: taking the original to be in E major means that the altered note is a #11, which is a common alteration, but taking B major to be the key means that the alteration is a b7, which would seem less common.
Comment: @DavidBowling Exactly right. I meant to put that...edit coming soon!
Comment: @DavidBowling as further evidence in support of the hypothesis that A is the unaltered note, lowering the seventh would be more common in a descending passage, while this is an ascending passage.  Another point in support of that hypothesis is that raising the fourth scale degree is quite common as a lower neighbor to the fifth scale degree (indeed, raising any scale degree is common as the lower neighbor of the next-higher scale degree when the two scale degrees are a whole step apart).
Comment: @DavidBowling. #11 would be a chord tone. The #4 is a scale degree. The example is just a line. Why bring in the idea of a hypothetical/implied chord?
Answer:
how do I determine which key they are in?

A) Recognise that those notes are the start of the overture to Mozart's The Marriage Of Figaro, but two semitones higher.
B) Note that that piece is in D major.
C) Infer that the notes in the question are therefore in E major.
:-)
More seriously, I don't think you can say definitively just from the notes.  They don't all fall in the same major or minor (or modal) scale, so either are from some bizarre scale, or include some non-scale notes.  (The A#s, if it's really from Figaro.)  Or it splits into sections, from different scales.  (For example, the first 13 notes are from the E major scale, and the rest from the B major scale, which happens to match the harmonies of Figaro.)
Comment: Great job catching that it's *Figaro!* That didn't even cross my mind since it was in E.
Comment: Could it be that the music is indeed already 'in D'. But written for a Bb transposing instrument - clarinet, maybe? That would need to be written a tone higher than concert D, making it in E.
Comment: I'm surprised no-one else spotted it first :-)  It doesn't help that the notes don't indicate a rhythm, but immediately after reading them I had the vague feeling of recognition, and it didn't take many moments to identify the piece.  (That's good, coz sometimes a tune can go round and round in my head for *days* without identification…)  I don't have perfect pitch, so a change of key makes no difference to me.  — Of course, it's a bit of a cheat answer, but someone had to say it!  You answer's much more general.
Answer: The piece appears to be in the key of Emaj(1), with a modulation to Bmaj at the end. I speculate this because on the surface it appears that the last 5 notes appear to be a repeat the the first 5, but in the dominant key (i.e. Bmaj(5)). Of course it's impossible to tell without more context.
Taking the Emaj/Bmaj above to be correct for the sake of argument, the transposition to D would be D as the tonic and A as the dominant, hence:
D C# D C# D D C# D E F# E F# G A G# A G# A
Kudos to Richard. Scale degrees is an excellent metaphor for direct transposition.
Comment: See [gidds' answer](https://music.stackexchange.com/a/78396/21557) for more context.  Also, welcome to Music StackExchange!
Comment: Re-read @Richard's answer. It isn't a _modulation_ to B, but a _tonicization_ of B.
Answer:
how do I determine which key they are in?

Learn Major, minor scales and circle of fifth.
Then apply the notes into each Key in the circle of fifth.
Most notes will fit into one key
Most piece will end in key note

In this case all notes(expcet A) fit into Key B Major and the piece ends in B, so this could be most probably in key of B major.

how do I transpose them to a key of D?

Find the distance from original key to the new Key in number of semitones.
Increment each note by the distance

In this case the difference from B to D is 3 semitones.
And the transposed piece would have the following notes.

G F G F# G G F# G A B A B C D C# D C# D
Comment: I suspect rather strongly that this is in E rather than B.  There are more A-sharps than A-naturals, but the A-sharps appear in a context in which chromatic alteration is common, while the A-natural appears in a context in which it is not.
Answer: Most tunes start with which is the basic note of the major scale, many others with the fith, a few with the third:
Your first tone is E, that means E major is correct, modulating to B.
For transposing the notes 2 scales of 12 halftones over 2 octaves will fit to find the results for this notes and a million other compositions.
This means you can take 2 sheets or strips of paper and with squares and mark every second square for a halftone. just write into the squares the names (2 squares per note) as:
(C,C#,D,D#,E,F,F#,G,G#,A,A#,B,C,C#,D,D#,E,F,F#,G,G#,A,A#,B,C) and then transpose one sheet along the other and you can read the result of the transposition.
and Mozart's Figaro, yeah!
http://www.free-scores.com/download-sheet-music.php?pdf=2077
here you will get the sheet music,  and the midifile, where you can change the tempo up and down and also the key online, or you can download the midifile and play it on midiplayer.
https://www.flutetunes.com/tunes.php?id=614
There are several free apps where you can play midi files and transpose and watch the sheet music or the piano keyboard (like van basco midi file player, sweet sheet music player etc.)