java.net.UnknownHostException: Unable to resolve host

Question: I know that there were many questiones about this exception but i still can't find the main cause of this exception
It falls in the following line:
HttpResponse httpResponse = httpClient.execute(httpPost);

This is when i'm trying to get XML from web.
The xml is from out bank so its free and I used it before (Java swing).
Now in ANDROID it throws this exception and I really don't know why.

There's an internet permission in the application manifest.
I saw that maybe the problem is in the emulator - restart didn't help, and in my device it's the same behaviour.
The full exception error is:
java.net.UnknownHostException: Unable to resolve host "<url>: No address
 associated with hostname

The xml location is in http://www.bankisrael.gov.il/currency.xml
I will appreciate if someone advice me what can I do and if there are any workaround's.
Thank,
Udi
Comment: can you connect to the url via the regular browser?
Comment: Does the exception really say `"` or did you replace the url there?
Comment: I replaced it, But it doesn't really matter, I've tried 2 different hosts so that's not the issue
Comment: Just tried, and no....maybe it's the problem?
Comment: Seems that there's no connection at all to the internet from the emulator. Can you please advice me what to do? thanks
Comment: I don't know how to solve that, never had that problem. Try with a new emulator instance maybe
Comment: OK I find that its a connection problem. emulator didn't have access to network. I tested it in other environment and it worked. Thanks
Answer: I've faced same problem., in emulator HttpResponse working. when i execute kindle fire device. HttpResponse not worked. After added the permission its working.
Please make sure have you added permission on manifest file.
<uses-permission android:name="android.permission.INTERNET" />


JSON field is string containing JSON; how do I convert that to proper JSON?

Question: While converting a CSV file to JSON i am getting output like below:
 {
        "id": "8835435",
        "userid": "1111",
        "key": "diary_notifications",
        "setting": "{\n  \"standup_reminder\" : false,\n  \"weight_reminder_diary\" : true,\n  \"weight_reminder_notification\" : false,\n  \"meal_reminders_lunch\" : false,\n  \"meal_reminders_breakfast\" : false,\n  \"meal_reminders_snack\" : false,\n  \"weight_reminder_calendar\" : false,\n  \"weight_reminder_time\" : false,\n  \"meal_reminders_dinner\" : false,\n  \"water_reminders\" : false,\n  \"walking_reminder\" : false,\n  \"sleep_reminder\" : false\n}",
        "lastupdated": "2018-03-27 10:48:51",
        "creatd": "2014-11-13 15:47:23"
    }

How can I remove the newline characters from setting and convert the field to a proper list in Python code? My code is:
import csv
import json

with open('data.csv', 'r') as f:
    reader = csv.reader(f)
    next(reader)
    data = []
    for row in reader:
        data.append({"id":row[0],"userid":row[1],"key":row[2],"setting":row[3],"lastupdated":row[4],"creatd":row[5]})
with open ("users.json","w") as f:
    json.dump(data,f,indent=4)

What needs to be added above?
Comment: @RahulShukla: the question is not tagged with pandas, and pandas would be overkill here. Moreover, you proposal does not address OP's question...
Comment: Use df to read csv and then json.dump(df) to convert into proper json format
Comment: Can you post a few rows of the CSV
Answer: The setting field contains a Json string, so you should just parse it with the json module. Of course in only some lines contain a Json string and others only contain a plain one, you should protect the json.loads in a try block:
import csv
import json
with open('data.csv', 'r') as f:
    reader = csv.reader(f)
    next(reader)
    data = []
    for row in reader:
        try:
            row[3] = json.loads(row[3])
        except json.JSONDecodeError:
            pass
        data.append({"id":row[0],"userid":row[1],"key":row[2],"setting":row[3],
         "lastupdated":row[4],"creatd":row[5]})
with open ("users.json","w") as f:
    json.dump(data,f,indent=4)

It should give (more or less):
{
    "id": "8835435",
    "userid": "1111",
    "key": "diary_notifications",
    "setting": {
        "standup_reminder": false,
        "weight_reminder_diary": true,
        "weight_reminder_notification": false,
        "meal_reminders_lunch": false,
        "meal_reminders_breakfast": false,
        "meal_reminders_snack": false,
        "weight_reminder_calendar": false,
        "weight_reminder_time": false,
        "meal_reminders_dinner": false,
        "water_reminders": false,
        "walking_reminder": false,
        "sleep_reminder": false
    },
    "lastupdated": "2018-03-27 10:48:51",
    "creatd": "2014-11-13 15:47:23"
}

Comment: getting this error JSONDecodeError: Expecting value: line 1 column 1 (char 0). Is anything need to changed here:"setting":json.loads(row[3])
Comment: Please show your csv file **as text**. I tried to build one from your example and got no error but...
Comment: id userid key setting lastupdated created
5267840 1111 activation "{
  """" : ""2015-08-21"",
  ""food_rating_trial"" : ""2015-08-27"",
  ""diets"" : true,
  ""date"" : ""2014-07-24"",
  ""app_starts"" : 2,
  ""partners"" : true,
  ""recipe_date"" : ""2015-06-24""
}" 27/08/2015 10:13 14/07/2014 15:00
12 1111 brand_change YES 02/12/2013
Comment: Cannot paste more data as size limit.  Any suggestion.
Comment: @turitiw: the suggestion is that data should have been an edit to the question. It is much more easy to write formatted data in a question than in a comment :-) . Anyway the second line was enough to give me a hint.
Comment: thanks @Serge Ballesta for all your effort.


How do I see the value of one field of a multi-item field in views formatter

Question: I have a custom views formatter.
function template_preprocess_views_view_flot_views_time(&$variables) {
  $view = $variables['view'];
  $field_name = 'foo_bar';
  foreach ($view->result as $row) {
    $field_value = $view->field[$field_name]->getValue($row);
  }
}

This works when the field is a single-value field. However, I have a couple multi-value fields. The result of the above expression is always "1" for these fields. These fields can be identified because
 $view->field[$field_name]->multiple == TRUE

I can use
kint($view->field[$field_name]->getItems($row));

to see that this is an array with a render array and raw data.
The value as a string can be found at:
$view->field[$field_name]->getItems($row)[0]['rendered'][#markup']

If the multi-value field is named foo, and has three parts, 'bar', 'baz', and 'qux', is there a better way to get the value of foo_bar or foo_baz?
I've been looking at the documentation for core/modules/views/src/Plugin/views/field/Field.php but it's not helping.
Answer: You don't need to search for another method, Field::getValue() returns the array you are looking for:
if ($view->field[$field_name]->multiple) {
  $field_array = $view->field[$field_name]->getValue($row);
}

I don't know if there is a documentation, but you can see this in code:
https://api.drupal.org/api/drupal/core!modules!views!src!Plugin!views!field!Field.php/function/Field%3A%3AgetValue/8.2.x
Difference between field values from view result and entity
If you have a standard multivalue field like text or number in a view and don't change any options, getValue($row) returns a one-dimensional array with the values from the main property of the field. If not you have somehow configured the view so that it shows a different result.
You can although get the original entity field data, which is independent from the configuration of the view. For this the field needs to be in the row entity:
$field_array = $row->_entity->{$field_name}->getValue();

This is then a two-dimensional array with multiple values and multiple properties.
Comment: In my installation, it returns $args array(1)

    →array(1)

        string(1) "1", while the '#markup' method in my question returns '99.000', the correct value.
Comment: `getItems()` collects the data differently, so the result may be different. Not all fields in views are real entity fields.
Comment: What I meant is kint($field_array = $view->field[$field_name]->getValue($row)) returns $args array(1) →array(1) string(1) "1" instead of string(6) "99.000"
Comment: That's what I meant, the result of both method has not to be the same. Try another field or another view. The field handling of views is sometimes a bit strange, dependent on how a view is configured.
Comment: Got a chance to test your code in one of my views. See the edited answer.


ImportError: No module named captchia.fields

Question: I am using python 2.7 django 1.11 and django simple captcha 0.56,
when I using python manage.py test captcha, error popup as below,

appreciated if any assistance.
Answer: You achieved to have 2 typos in 1 import
<code>from captcha.fields  import CaptchaField
</code>
On line 18 of /django-app/expo/registration/forms.py
Comment: Thank, iklinac. Another error come out now.
[code] File "/Users/wzy/django-app/expo/registration/forms.py", line 18, in
    from captcha.fields import CapchaField
ImportError: cannot import name CapchaField
Comment: @wupeter that is your second typo look at my answer CaptchaField
Comment: Thanks iklinac, you are correct. Now the problem is truly fixed. Many thanks.


forbid custom php config settings on apache 2.2 + mod_php server

Question: I have a server where php is running as an apache module.
Every user on the server is restricted to his own directory with open_basedir.
I have disabled the following functions:
disable_functions = exec,passthru,shell_exec,system,proc_open,popen,curl_multi_exec,parse_ini_file,show_source
Now I'd like to forbid custom php config settings, such as:
memory_limit
max_execution_time
max_input_time
post_max_size
upload_max_filesize
How would you go about it?
ty
Answer: You can use the php_admin_value and php_admin_flag directives to hard code the values into your apache config, this will prevent both .htaccess and ini_set from overriding the values you set.
You can read about these directives in the PHP documentation
Comment: Ah! Thanks SubOracle, I read that page but missed the "Any directive type set with php_admin_value can not be overridden by .htaccess or ini_set()". Do you reckon this will still be true even if there is "AllowOverride all" in my httpd.conf? Well I'll make a test myself asap and report back.
Comment: php_admin_value memory_limit 128M worked even with AllowOverride All


Why does the random forest OOB estimate of error improve when the number of features selected are decreased?

Question: I am applying a random forest algorithm as a classifier on a microarray dataset which are split into two known groups with 1000s of features.  After the initial run I look at the importance of the features and run the tree algorithm again with the 5, 10 and 20 most important features.  I find that for all features, top 10 and 20 that the OOB estimate of error rate is 1.19% where as for the top 5 features it is 0%.  This seems counter-intuitive to me, so I was wondering whether you could explain whether I am missing something or I am using the wrong metric.
I an using the randomForest package in R with ntree=1000, nodesize=1 and mtry=sqrt(n)
Comment: Just to be clear: Are you applying RFs in an iterative manner, that is by selecting the top-ranked features (according to Gini index or decrease in MSE) from the whole input space? I know that RFs may not necessarily improve with increasing trees number, but what you are depicting seems to make sense (the best features allow to predict with 100% accuracy the OOB samples), although there is clearly a risk of overfitting when proceeding this way.
Comment: @chl, could you explain why there is a risk of overfitting by using only 5 features?
Comment: Yes that's what I am doing
Answer: This is feature selection overfit and this is pretty known -- see Ambroise & McLachlan 2002.
The problem is based on the facts that RF is too smart and number of objects is too small. In the latter case, it is generally pretty easy to randomly create attribute that may have good correlation with the decision. And when the number of attributes is large, you may be certain that some of totally irrelevant ones will be a very good predictors, even enough to form a cluster that will be able to recreate the decision in 100%, especially when the huge flexibility of RF is considered. And so, it becomes obvious that when instructed to find the best possible subset of attributes, the FS procedure finds this cluster.
One solution (CV) is given in A&McL, you can also test our approach to the topic, the Boruta algorithm, which basically extends the set with "shadow attributes" made to be random by design and compares their RF importance to this obtained for real attributes to judge which of them are indeed random and can be removed; this is replicated many times to be significant. Boruta is rather intended to a bit different task, but as far as my tests showed, the resulting set is free of the FS overfit problem.
Answer: I thought I would add an intuitive explanation for this pattern.
In each decision tree comprising the random forest, the data are iteratively split along single dimensions. Crucially, this procedure involves
1) considering only a small, randomly-selected subset of all the explanatory variables, and
2) selecting the most strongly associated explanatory variable within this randomly-selected variable subset to split the data along.
Therefore, the probability of the n most important variables being selected at any particular node decreases as the number of explanatory variables increases. Therefore, if one adds in a large number of variables that contribute little-to-no explanatory power, it automatically leads to an increase in the forest's error rate. And conversely, choosing only the most important variables for inclusion will very likely lead to a decrease in the error rate.
Random forests are quite robust to this and it typically requires a very large addition of these 'noise' parameters to meaningfully reduce performance.


How to split correctly when using bash script

Question: I have a bash command which the result is something like this in my file:
sm-apolo: 2.1-835
sql-apolo: 1.0-2
srmq-processor: 1.0-214

I want to get a result of all items that have sql at the start and only the first part before ":" so need the second part to be removed. Then I want to use the result in choiceParam in Jenkins pipeline to be shown as a drop-down list.
If I run something like this:
names = sh (script: "A command here | grep sql", returnStdout: true).trim()
names_list = names.trim().tokenize("\n")

In the drop-down I get
sql-apolo: 1.0-2
How I can get rid of everything after the name including ": 1.0-2" to show up in the drop down list? something like:
sql-apolo
sql-sxdf
sql-pokf

Comment: Where do `sxdf` and `pokf` come from in your shown example?
Comment: `awk -F':' /^sql/{print $1}' file.yaml`
Comment: In the full file I have them but in that sample, there is only sql-apolo
Answer: With GNU grep and a Perl-compatible regular expression (-P):
grep -Po '^sql.*(?=:)'

or:
grep -o '^sql[^:]*'

See: man grep and The Stack Overflow Regular Expressions FAQ


Comprehensive list of combination techniques for word-level embeddings with pros/cons

Question: Are there any reference document(s) that give a comprehensive list combination techniques for word-level embeddings along with their pros/cons (and ideally some pointers to publications where they were successful or not so successful)?

Example of combination techniques for word-level embeddings: sum.
Answer: The team around Bengio published an article a few years ago. Maybe this is good enough?

Turian, J., Ratinov, L., & Bengio, Y. (2010). Word representations: a simple and general method for semi-supervised learning (pp. 384–394). Association for Computational Linguistics.


How can I use ratios to set priors on multinomial probabilities?

Question: I have a vector, $k$, that determines allocation to five pools.
I'd like to set priors on these probabilities, and I can provide informative priors on a few of the ratios, e.g.:
$$ \frac{k1}{k2} \sim \text{beta}(6,1)$$
$$ \frac{k1}{k3} \sim \text{beta}(2,12)$$
$$ \frac{k1+k2+k3}{k4+k5} \sim \text{beta}(50,1)$$
$$ \frac{k4}{k5} \sim \text{beta}(1,1)$$
The fact that these values are all correlated makes it unclear how I can start with these priors and then sample $k$ from a multinomial distribution.
Are there any good papers or common methods for doing so?
Comment: There is not enough information for priors. You need also some priors for k1+k2+k3+k4+k5, or for k1 etc.
Comment: @user31264 I don't have any additional information to set informative priors - the additional ones can be flat (e.g. $k1\sim(\text{beta}(1,1)$)
Comment: So you (1) have an information like k1∼(beta(1,1)), or (2) have no any additional information?
Comment: @user31264 I meant (2), that I don't have any additional information, and I can state this lack of information as, e.g., $k1\sim\text{beta}(1,1)$. However, that is not true. I know k1 is not 0 or 1, and would probably be closer to $k1\sim\text{beta}(1,3)$. So maybe I should say that I can come up with priors for other parameters that I need, but the ones I listed are where I am starting.
Comment: Maybe I am missing something, but I afraid that without any additional information, you cannot obtain the priors.
Comment: @user31264 how much more / what additional information is required?
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/17613/discussion-between-david-and-user31264).
Comment: Can you clarify a little more? You have a random vector $(k_1,k_2,k_3,k_4,k_5)$. What are the possible values for the $k_i$'s? What do they mean in your problem?
Comment: @zen the meaning of k is the proportional allocation of resource to different pools (specifically carbon to leaves, roots, stems, etc). Technically I'd say that 'possible' values are [0,1], though I know they are more constrained than this.
Answer: Check out the Dirichlet distribution: https://en.wikipedia.org/wiki/Dirichlet_distribution
It's a generalization of the Beta distribution and is ideal for modeling beliefs about multinomial probabilities.
Answer: If you just want to sample $k$, then this is easy from the distributions given (plus a distribution for $k1$).  The procedure is:

Draw $k1$.
Draw $b2 \sim {\rm beta}(6,1)$ and set $k2 = \frac{k1}{b2}$.
Draw $b3 \sim {\rm beta}(2,12)$ and set $k3 = \frac{k1}{b3}$.
Draw $b4 \sim {\rm beta}(50,1)$ and $b5 \sim {\rm beta}(1,1)$ then solve the system
$$
k4+k5 = \frac{k1+k2+k3}{b4}
\\
k5 = \frac{k4}{b5}
$$
whose solution is $k5 = \frac{k1+k2+k3}{b4(1+b5)}$, $k4 = b5 k5$.
Finally, if any of the $k$'s are larger than 1, reject the sample and start over.\

You could avoid the rejection step by noting that all of the later $k$'s scale linearly with $k1$.  So once you've got $(b2, ..., b5)$, find the range of $k1$ values that ensure everyone is less than 1 and draw $k1$ within this range.


Equivalent ODE forward integration

Question: Consider a Cauchy problem $$\dot x(t)=f(t,x(t)),\quad x(T)=x_T \qquad (*)$$ where $T>0$ and we would like to compute $x(0)$.
I wonder how to construct an ode such that integrating forward the latter would lead to $x(0)$.
I don't have precise idea on how to obtain such equivalent ode: I would use time reparameterization, change of coordinates ...

I propose the ode:
$$\dot z(t) = -f(t,z(T-t)),\quad z(0)=x_T, \quad t\in [0,T]
$$
then we can recover $x$ from $x(t)=z(T-t)$.
But in the general case (without symmetry on the solutions), this may be difficult to handle numerically, because in numerical implementation, we must provide $g(t,z(t))=-f(t,z(T-t))$ which is not suitable because we can't express (in general) $z(T-t)$ in terms of $z(t)$.
Are there any other odes that could be integrated forward to obtain $x(0)$ ?
Answer: Your approach works, because it yields another ODE:
Let $z(t)=x(T-t)$. Then
$$
\frac{\partial }{\partial t}z(t)=\frac{\partial }{\partial t}x(T-t)\\
=-x'(T-t)=-f(T-t,x(T-t))\\
=-f(T-t,z(t)).
$$

Equivalent ODE forward integration


chi squared fit in 3D

Question: I want to fit a line to $N$ 3D data points $(x,y,z)$, where $x,y$ are fitted and $z$ is fixed for all data points.
To fit the data, I use the following $\chi^2$ fit:
$$
\chi^2(a, b)_h=\sum_{i=1}^N \left (\frac{h_i-a-bz_i}{\sigma_i}\right)
$$
Would it be correct if, to receive the best set of parameters, the following is minimized:
$$f_{min}=\text{min}(\chi^2_x+\chi^2_y).$$
My reasoning for this is that
$$\sum d_{x,y}^2=\sum d_x^2+ \sum d_y^2$$
holds. If it is correct, can I use $f_{min}$ for the gof, or do I need to consider something additionally?
Thanks in advance!
Comment: Did you make a typo in that sum and forgot a square?
Answer: If the distribution of $x$ and $y$ is independent when corrected for $z$ then you could regard the fit as a fit with 1D data. (by treating the pairs $x_i,y_i$ as two independent data points with the same value of $z$ as predictor)
Then you are fitting a line with 4 parameters and can use the least squares method and use the sum of squares as a hypothesis test for the goodness of fit (which might likely fail if a straight line is not exactly correct so I actually wonder what you want to prove with a gof test).
But you might have a situation where the $x$ and $y$ variables are not independent. In that case the least squares method is not the 'best' (instead you probably want to use generalized least squares) and the sum of squared errors is not chi-squared distributed.
See the Gauss Markov theorem for more about the conditions and background that makes the least squares method the 'best' method. The least squares method is only the best among unbiased linear estimators when the errors are distributed with equal variance and are independent. Also the method is only the best in terms of having the lowest variance of the estimate, potentially with other measures of performance the least squares method is not the best (the UMVE is also the best estimator for other convex functions. But I am not sure this generalizes to linear estimators. I also imagine this requires the distribution of the errors to be identical and not just the same variance).

chi squared fit in 3D


Implementation of HttpClient request limiter and buffer

Question: In our project, we have a few services that make requests to a 3rd party API, using a key.
This API has a shared rate limit between all endpoints (meaning request to one endpoint will require 2 seconds cooldown before we can use a different endpoint).
We've handled this using timed background jobs, only making requests to only one of the endpoints at any time.
After some architectural redesign, we've come to a spot where we don't rely as much on the timed background jobs, and now all HttpRequests cannot be moderated since multiple service  instances are making requests to the API.
So, in our current example:
We have a few HttpClients set up to all needed API endpoints, i.e.:
<code>   services.AddHttpClient<Endpoint1Service>(client =>
   {
       client.BaseAddress = new Uri(configOptions.Services.Endpoint1.Url);
   });

   services.AddHttpClient<Endpoint2Service>(client =>
   {
       client.BaseAddress = new Uri(configOptions.Services.Endpoint2.Url);
   });
</code>
Endpoint1Service and Endpoint2Service were before accessed by background job services:
<code>    public async Task DoJob()
    {
        var items = await _repository.GetItems();

        foreach (var item in items)
        {
            var processedResult = await _endpoint1Service.DoRequest(item);

            await Task.Delay(2000);

            //...
        }

        // save all results
    }
</code>
But now these "endpoint" services are accessed concurrently, and a new instance is create every time, therefore no way to moderate the request rates.
One possible solution was to create some sort of singleton request buffer is injected into all services that uses this API, and moderates these requests to go out at a given rate. Problems I see with this is it seems dangerous to store requests in a in-memory buffer, in case something goes wrong.
Is this a direction I should be looking towards, or is there anything else I can try?
Comment: How are you invoking the `DoJob` method? Are you invoking it in a [fire-and-forget](https://blog.stephencleary.com/2014/06/fire-and-forget-on-asp-net.html) fashion?
Comment: @TheodorZoulias we were using hangfire for this, so basically just a cron schedule.
It had a retry system, but basically yes.
Comment: @TheodorZoulias
Now we are using MassTransit library that pushes events and triggers the EndpointServices, sometimes faster than we ideally would like
Comment: A shared (or even distributed) rate limiter sounds like what you need. This can be patterned as a buffer (i.e., Channel) with a single consumer, very similar to what you had before. I recommend including a `TaskCompletionSource` in the requests, so that the senders have something to `await`.
Comment: "now these "endpoint" services are accessed asynchronously" - no, it is ***concurrently***, not ***asynchronously***.
Answer: Hope this helps:
I created the following for similar scenarios. Its objective is concurrency throttled multi threading. However it also gives you a convenient wrapper over your request processing pipeline. Additionally it provides a max number of concurrent requests limit per client (if you want to use that).
Create one instance per end point service and set its number of threads to 1 if you want a throttle of 1. Set it to 4 if you want it at 4 concurrent requests to the given end point.
https://github.com/tcwicks/ChillX/blob/master/src/ChillX.Threading/APIProcessor/AsyncThreadedWorkItemProcessor.cs
or
https://github.com/tcwicks/ChillX/blob/master/src/ChillX.Threading/APIProcessor/ThreadedWorkItemProcessor.cs
The two implementations are interchangeable. If using in a web server context the former is probably better as it offloads to the background thread pool instead if using foreground threads.
Example Usage
In your case probably set: _maxWorkerThreads  to a value of 1 if you want to rate limit it at 1 concurrent request. Set it to 4 if you want to rate limit it at 4 concurrent requests.
<code>//Example Usage for WebAPI controller
class Example
{
    private static ThreadedWorkItemProcessor<DummyRequest, DummyResponse, int, WorkItemPriority> ThreadedProcessorExample = new ThreadedWorkItemProcessor<DummyRequest, DummyResponse, int, WorkItemPriority>(
            _maxWorkItemLimitPerClient: 100 // Maximum number of concurrent requests in the processing queue per client. Set to int.MaxValue to disable concurrent request caps
            , _maxWorkerThreads: 16 // Maximum number of threads to scale upto
            , _threadStartupPerWorkItems: 4 // Consider starting a new processing thread ever X requests
            , _threadStartupMinQueueSize: 4 // Do NOT start a new processing thread if work item queue is below this size
            , _idleWorkerThreadExitSeconds: 10 // Idle threads will exit after X seconds
            , _abandonedResponseExpirySeconds: 60 // Expire processed work items after X seconds (Maybe the client terminated or the web request thread died)
            , _processRequestMethod: ProcessRequestMethod // Your Do Work method for processing the request
            , _logErrorMethod: Handler_LogError
            , _logMessageMethod: Handler_LogMessage
            );

    public async Task<DummyResponse> GetResponse([FromBody] DummyRequest _request)
    {
        int clientID = 1; //Replace with the client ID from your authentication mechanism if using per client request caps. Otherwise just hardcode to maybe 0 or whatever
        WorkItemPriority _priority;
        _priority = WorkItemPriority.Medium; //Assign the priority based on whatever prioritization rules.
        int RequestID = ThreadedProcessorExample.ScheduleWorkItem(_priority, _request, clientID);
        if (RequestID < 0)
        {
            //Client has exceeded maximum number of concurrent requests or Application Pool is shutting down
            //return a suitable error message here
            return new DummyResponse() { ErrorMessage = @"Maximum number of concurrent requests exceeded or service is restarting. Please retry request later." };
        }

        //If you need the result (Like in a webapi controller) then do this
        //Otherwise if it is say a backend processing sink where there is no client waiting for a response then we are done here. just return.

        KeyValuePair<bool, ThreadWorkItem<DummyRequest, DummyResponse, int>> workItemResult;

        workItemResult = await ThreadedProcessorExample.TryGetProcessedWorkItemAsync(RequestID,
            _timeoutMS: 1000, //Timeout of 1 second
            _taskWaitType: ThreadProcessorAsyncTaskWaitType.Delay_Specific,
            _delayMS: 10);
        if (!workItemResult.Key)
        {
            //Processing timeout or Application Pool is shutting down
            //return a suitable error message here
            return new DummyResponse() { ErrorMessage = @"Internal system timeout or service is restarting. Please retry request later." };
        }
        return workItemResult.Value.Response;
    }

    public static DummyResponse ProcessRequestMethod(DummyRequest request)
    {
        // Process the request and return the response
        return new DummyResponse() { orderID = request.orderID };
    }
    public static void Handler_LogError(Exception ex)
    {
        //Log unhandled exception here
    }

    public static void Handler_LogMessage(string Message)
    {
        //Log message here
    }
}
</code>


Drum and dotted notes

Question: I am trying to practice Smell like a teen spirit on drums and there is something I don't understand with dotted notes.
Here is the sheet:
I don't understand the use of dotted notes in this sheet. If there were no dots I would have played this measure the same way, that is to say crash and kick on the 1 and kick on the d. For me the dotted notes don't bring any additional information on how I am supposed to play the song. Is there something I don't understand ?
Thank you.
Comment: Curious - do you count "1 e an d" instead of "1 e and a"?
Comment: Without the dots, the semiquavers would need to become quavers for the bar to be complete?
Answer: This drum part is written as a single voice, only one rhythm which incorporates different drums and cymbals being played at different times, sometimes only one, sometimes two simultaneously. Regardless of the vertical position of the notes or how many notes are played the overall rhythm in the bar has to add up to 4 beats in any combination of quarters, eighths, sixteenths, etc. Because there is a 16th at the end of the 1st beat the cymbal must be a dotted eighth since they are rhythmically linked.
This is one way of writing drum parts. Another way is to use two voices, one for drums and one for cymbals. You do this by using stems up and down. Here is an example of the same exact rhythm written with 2 voices:

(Disclaimer: I wrote this on my iPad with my index finger)
As you can see, with two voices the cymbal and hat are just playing quarters (stems up)and the back and forth rhythm between the bass and snare (stems down) is notated separately. One important note especially if writing by hand, everything MUST line up vertically. Some say (myself included) this is a better way to write drum parts because it is more accurate and separates the top and bottom of the kit (i.e. in version one you don't REALLY play a dotted 16th on the cymbal, it just rings through). It takes a little more time and effort to write 2 voices so many people have adopted the one voice method of writing drum parts like in your example. Ask other drummers you know who are good readers about their preferences. Also check drum method books and see how they are written, one or two voice.
Comment: These are important reasons for which I consider 2-voice drum parts better in general. In fact: 1. they properly separate the "tempo" (hat/cymbal) from the rhythm; 2. they don't create confusing rhythms like the one shown by the OP. This is also conceptually better as the cymbals might have a longer sustain (like in this case, with the open hihat) that doesn't match the written duration, especially in the third beat. Writing a good drum part is not always easy (and even drummers often don't get it right): you have to balance proper notation *and* readability, and you can't always have both.
Answer: Just checking, do you understand what dots do to rhythm? As Tom mentions, if you took away the dots you would have made the first note a quaver (or 8th note), and you'd have to make the kick note one as well, so you'd be playing it at a different time (halfway through the beat instead of 3/4 of the way through the beat).
If all of this is news to you, then we'll start at the beginning: a dot makes a note longer by adding half of whatever it already was. If a quarter note is a beat, then a dotted quarter is 1.5 beats. An 8th note is half of a beat, so a dotted 8th is 3/4 of a beat. To figure out how to play it, start imagining 16th notes inside all of the beats; you can try counting "One ee and a Two ee and a" (or many other types of patterns). Using that pattern, the kick note would fall on the "a" that represents the last of the four 16th notes that subdivide the first beat.
Answer: I appreciate that a lot of drum sounds cannot be made to sound longer than the fraction of a second they're hit, but there's more to music - particularly written down - .
Written music follows technical rules, one of which is that there must be the requisite number of notes in each bar.
Those dotted quavers can't make the actual sound any longer, but they need to be written as such, otherwise the semi-quavers that follow could be played too early or too soon. Without the dots, they're too short as notes.

Drum and dotted notes


Extracting information about Programming skills from dbpedia using Python?

Question: Suppose I have some tokens and I want to know whether a particular token is programming skill or not so I want to cross validate it with dbpedia to know whether it is programming skill or not. How I can do this? I used some code:
from SPARQLWrapper import SPARQLWrapper, JSON

sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("""
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    SELECT ?label
    WHERE { <http://dbpedia.org/resource/Python_(programming_language)> rdfs:label ?label }
    """)

sparql.setReturnFormat(JSON)
results = sparql.query().convert()

for result in results["results"]["bindings"]:
print(result["label"]["value"])

but from the output I am not getting info about whether Python is a programming language or not.
Answer: In my opinion, if entity Python_(programming_language) exists, it means Python is a programming language. With your approach, if you want to check token X is a programming or not, you can query whether page X_(programming_language) exits. But this fact is not true for all programming languages.
A better way is getting a list of all programming languages, then check wheter your token in this list or not. You can use this query
from SPARQLWrapper import SPARQLWrapper, JSON

sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("""
    SELECT ?pl ?label
    WHERE {
        ?pl rdfs:label ?label .
        ?pl rdf:type dbo:ProgrammingLanguage .
        FILTER (LANG(?label)='en')
    }
    """)

sparql.setReturnFormat(JSON)
results = sparql.query().convert()
results = results["results"]["bindings"]
programming_languages = [item["label"]["value"] for item in results]
print programming_languages
# [u'ALGOL', u'AMOS (programming language)', u'APL (programming language)', ...]

Comment: Actually I want to implement the concept:                                                 Suppose I have skills dictionary with some known skills.A sentence in job description identified as having at least two known skills (known skills are those present in the skills database).Sentence is converted into tokens . Each unknown token is validated to be an actual skill
by cross-referencing with DBpedia .  Now suppose that unknown token  is "Data Structure", so how I can validate this token as skill using dbpedia.
Comment: I haven't understood clearly, what do you expect if the unknown token is "Data Structure"?. It will be better if you can provide some more detail examples
Comment: I want to implement ML algorithm to automatically learn what  job skills are & extract them from both job posting and resumes. First we create skills dict with some known skills. This skill dict is updated iteratively using training set of job description. Now suppose one of the sentence in job description is ['Must have good knowledge of Data Structure']. After some cleaning operation I have tokens ['knowledge','Data Structure']. Now I want to validate this tokens from dbpedia whether they are skills or not. How I can do this so that after validation I will add Data Structure in skills dict.


How to find exact value of integral $\int_{0}^{\infty} \frac{1}{\left(x^{4}-x^{2}+1\right)^{n}}dx$?

Question: When I first encountered the integral $\displaystyle \int_{0}^{\infty} \frac{1}{x^{4}-x^{2}+1} d x$, I am very reluctant to solve it by partial fractions and search for any easier methods.  Then I learnt a very useful trick to evaluate the integral.
Noting that
$$I(1):= \int_{0}^{\infty} \frac{d x}{x^{4}-x^{2}+1} \stackrel{x \mapsto \frac{1}{x}}{=} \int_{0}^{\infty} \frac{x^{2}}{x^{4}-x^{2}+1}
$$
Combining them yields
\begin{aligned}
I(1)&=\frac{1}{2} \int_{0}^{\infty} \frac{x^{2}+1}{x^{4}-x^{2}+1} d x\\&= \frac{1}{2}\int_{0}^{\infty} \frac{1+\frac{1}{x^{2}}}{x^{2}+\frac{1}{x^{2}}-1} d x \\
&= \frac{1}{2}\int_{0}^{\infty} \frac{d\left(x-\frac{1}{x}\right)}{\left(x-\frac{1}{x}\right)^{2}+1} \\
&= \frac{1}{2}\tan ^{-1}\left(x-\frac{1}{x}\right)_{0}^{\infty} \\
&= \frac{\pi}{2}
\end{aligned}
Later, I started to investigate the integrands with higher powers.
Similarly,
$$
I(2):= \int_{0}^{\infty} \frac{d x}{\left(x^{4}-x^{2}+1\right)^{2}} \stackrel{x \mapsto \frac{1}{x}}{=}\int_{0}^{\infty} \frac{x^{6}}{\left(x^{4}-x^{2}+1\right)^{2}} d x
$$
By division, we decomposed $x^6$ and obtain $$
\frac{x^{6}}{\left(x^{4}-x^{2}+1\right)^{2}}=\frac{x^{2}+1}{x^{4}-x^{2}+1}-\frac{1}{\left(x^{4}-x^{2}+1\right)^{2}}
$$$$
I(2)=\int_{0}^{\infty} \frac{x^{2}+1}{x^{4}-x^{2}+1} d x-\int_{0}^{\infty} \frac{1}{\left(x^{4}-x^{2}+1\right)^{2}}dx
$$
We can now conclude that $$I(2)=I(1)=\frac{\pi}{2} $$
My Question:
How about the integral $$\displaystyle I_{n}=\int_{0}^{\infty} \frac{d x}{\left(x^{4}-x^{2}+1\right)^{n}}$$ for any integer $n\geq 3$?
Comment: One approach is to use [contour integration](https://en.wikipedia.org/wiki/Contour_integration), see examples 1 and 2 under "direct methods".
Comment: Thank you.  Looking forward to seeing your answer.
Comment: Let
$$J_n = 2^{1 - 2 n} \pi \sum_{k = 0}^{n - 1}
 \binom {2 k} k \binom {2 n - 2 - k} {n - 1}, \\
R[y_n] =
12 n (n + 1) y_{n + 2} - 14 n (2 n + 1) y_{n + 1} + (16 n^2 - 1) y_n, \\
P(x) = x^4 - x^2 + 1,$$
then $R[J_n] = 0$ and
$$R[P^{-n}(x)] =
\frac d {dx} \left(
 -x ((4 n + 1) x^4 - (6 n + 1) x^2 + 2 n + 1) P^{-n - 1}(x) \right),$$
therefore the integral of $R[P^{-n}(x)]$ is zero and $I_n$ is also a solution of $R[y_n] = 0$. Since $I_1 = J_1$ and $I_2 = J_2$, it follows that $I_n = J_n$.
Comment: Thank you for your suggestion.
Comment: Writing a (fairly) long answer, request you to wait.
Comment: In the edit, I added  $\int_0^\infty\frac{dx}{(x^m+1)^n}$
Answer: Too long for a comment
You could be interested by
$$\displaystyle I_{n}=\int_{0}^{t} \frac{d x}{\left(x^{4}-x^{2}+1\right)^{n}}=t \, F_1\left(\frac{1}{2};n,n;\frac{3}{2};e^{+\frac{i \pi }{3}} t^2,e^{-\frac{i \pi
   }{3}} t^2\right)$$ where appears the Appell hypergeometric function of two variables and the roots of the quadratic in $x^2$.
I did not find any interesting reduction formula or any asymptotics for $t \to \infty$.
Nevertheless,
$$\displaystyle J_{n}=\int_{0}^{\infty} \frac{d x}{\left(x^{4}-x^{2}+1\right)^{n}}=\pi \,\frac {a_n}{2^{b_n}}$$ where the $a_n$ correspond to the sequence
$$\{1,1,9,21,25,483,2359,2907,115533,288915,363363,3674619,37326471,\cdots\}$$ and the $b_n$ the sequence
$$\{1,1,4,5,5,9,11,11,16,17,17,20,23,\cdots\}$$ None of these has been found in $OEIS$.
Edit
For
$$I_{m,n}=\int_0^\infty\frac{dx}{(x^m+1)^n}=\frac{\Gamma \left(1+\frac{1}{m}\right) \Gamma \left(n-\frac{1}{m}\right)}{\Gamma(n)} \qquad \text{if} \qquad \Re(m n)>1\land \Re(m)>0$$
gives the simple
$$I_{m,n+1}=\left(1-\frac{1}{m n}\right)I_{m,n}$$
Comment: So fast! Thank you.
Answer: Note
$$
\int_0^\infty \frac1{(x^4-x^2+1)^{n+1}}dx=\frac{(-1)^{n}}{n!} \frac{d^{n} J(a)}{da^{n}}\bigg|_{a=1}
$$
where
$$J(a)=\int_0^\infty \frac{dx}{x^4-x^2+a}=\frac1{2\sqrt a}
\int_0^\infty \frac{d(x-\frac{\sqrt a}x)}{(x-\frac{\sqrt a}x)^2+2\sqrt a-1}
= \frac\pi{2\sqrt{a(2\sqrt a-1)} }
$$
Then
\begin{align}
& \int_0^\infty \frac1{x^4-x^2+1}dx= J(1)=\frac\pi2\\
&\int_0^\infty \frac1{(x^4-x^2+1)^2}dx= -\frac{dJ(a)}{da}\bigg|_{a=1}=\frac\pi2\\
 &\int_0^\infty \frac1{(x^4-x^2+1)^3}dx=\frac12\frac{d^2J(a)}{da^2}\bigg|_{a=1}=\frac{9\pi}{16}\\
&\int_0^\infty \frac1{(x^4-x^2+1)^4}dx=-\frac16\frac{d^3 J(a)}{da^3}\bigg|_{a=1}=\frac{21\pi}{32}\\
&\int_0^\infty \frac1{(x^4-x^2+1)^5}dx=\frac1{24} \frac{d^4 J(a)}{da^4}\bigg|_{a=1}=\frac{25\pi}{32}\\
&\int_0^\infty \frac1{(x^4-x^2+1)^6}dx=-\frac1{120} \frac{d^5 J(a)}{da^5}\bigg|_{a=1}=\frac{483\pi}{512}\\
&\hspace{5mm}\cdots\hspace{2mm}\cdots
\end{align}
Comment: Thank you for your nice solution.  We have the same starting point $J(a)$. But I gave up as I can't handle the nth derivative of $J(a)$.
Comment: @Lai The derivative is here: https://www.wolframalpha.com/input/?i=nth+derivative+of+1%2F%28sqrt%28%28a%282+sqrt%28a%29+-+1%29%29%29 This should give you an explicit form of your integral. Cheers and have a nice weekend!
Comment: @1010011010 WA is incorrect here, just check the case $n=1$ by hand.
Answer: There are many approaches to solving this integral that I found in papers. We first generalize the integral to $$
N_{0,4}(a ; m) = \int_0^\infty \frac{dx}{(x^4+2ax^2+1)^{m+1}}
$$
The formula for this general expression is $$
N_{0,4}(a ; m) = \frac{\pi}{2} \frac{P_m(a)}{[2(a+1)]^{m+\frac 12}}
$$
where $$
P_m(a) = \sum_{l=0}^m \left[2^{-2m} \sum_{k=l}^m 2^k \binom{2m-2k}{m-k}\binom{m+k}{m}\binom{k}{l}\right]a^l
$$
I will be providing brief details on these computations , and not much more than that , in order to highlight merely the key computations. Some sections overlap with each other, but each one of them is, in their own right, capable of solving and generating further discussion.

1
The first approach is to set $x = \tan \theta$. This gives $$
\int_{0}^{\frac \pi 2} \frac{d\theta}{\cos^2 \theta}\left(\frac{\cos^4 \theta}{\sin^4 \theta + 2a \sin^2 \theta \cos^2 \theta + \cos^4 \theta}\right)^{m+1}
$$
Observe that $$
\sin^4 \theta + 2a \sin^2 \theta \cos^2 \theta + \cos^4 \theta = (1+a)+(1-a)\cos^2 (2 \theta)
$$
We set $u = 2 \theta$ now: $$
2^{-(m+1)} \int_0^\pi \left(\frac{(1+\cos u)^2}{(1+a) + (1-a)\cos^2 u}\right)^{m+1} \frac{du}{1+\cos u}
$$
which simplifies to $$
2^{-(m+1)} \int_0^{\pi} \left(\frac{(1+\cos u)^{2m+1}}{[(1+a) + (1-a)\cos^2 u]^{m+1}}\right) du
$$
Now we expand $(1+\cos u)^{2m+1}$ using the binomial theorem. Since this is a linear combination of powers of $\cos u$, we'll merely show how to tackle the more general $$
\int_0^{\pi} [(1+a) + (1-a)\cos^2 u]^{-(m+1)} \cos^j u \ du
$$
The first observation is that for $j$ odd, the integrand is an odd function around $\frac \pi 2$. Therefore, the corresponding integral is zero. For $j$ odd, one applies the double angle substitution again since we have a polynomial in $\cos^2$ as the integrand, and notes that the resulting function following substitution is even, so a factor of $2$ comes out and the integral limits change. The end of this should lead to $$
N_{0,4}(a ; m) = \sum_{j=0}^m 2^{-j} \binom{2m+1}{2j} \int_0^{\pi} [(3+a)+(1-a)\cos v]^{-(m+1)} (1+\cos v)^{j} dv
$$
Finally, we can simplify this using the typical $\tan(v/2)$ substitution, and the result is already specified above.

2
We can find a recursion as follows. Let $V(x) = x^4+2ax^2+1$. The idea is to recognize that we can generate the recursion by integrating a very simple polynomial identity. We start by noticing that $V,V'$ are co-prime, therefore we can find polynomials $B,C$ such that $CV+BV' = \frac{-1}{m}$. A quick use of the inverse Euclid algorithm will tell you $$
B(x) = \frac{ax^3-x(1-2a^2)}{4(a^2-1)m} \quad ; \quad C(x) = \frac{\frac{ax^2}{1-a^2} - 1}{m}
$$
Once we divide both sides of the equation by $V^{m+1}$ we get $$
CV^{-m} + BV'V^{-(m+1)} = \frac{-V^{-(m+1)}}{m}
$$
and integrating this from $0$ to $\infty$ gives $$
\int_0^\infty CV^{-m} dx + \int_0^\infty BV'V^{-(m+1)} dx = \frac{-1}{m} \int_0^\infty V^{-(m+1)} dx
$$
Which leads to $$
-\int_0^\infty CmV^{-m} dx - \int_0^\infty BmV'V^{-(m+1)} dx =  N_{0,4}(a ; m)
$$
In the first term, one can use the definition of $C$ to write the integral as a sum of two integrals, one involving $x^2V^{-m}$ and the other involving just $V^{-m}$. For the other, one calculates $BmV'$ ,performs the polynomial division $\frac{BmV'}{V}$ into quotient and remainder and then splits the integral based on that calculation, leading once again to a sum of two integrals : one involving $x^2V^{-m}$ and the other involving $V^{-m}$. Once these calculations are performed, we are eventually led to $$
N_{0,4}(a ; m) = \left(1+\frac{1-2a^2}{4m(a^2-1)}\right) N_{0,4}(a ; m-1) + \frac{(4m-3)a}{4m(a^2-1)} \int_{0}^\infty x^2V^{-m} dx
$$
However, we now make the observation that $$
\int_{0}^\infty x^2V^{-m} dx = \frac{1}{2(m-1)}\frac{d}{da} \int_0^\infty V^{-(m-1)} dx
$$
Since the derivative and the integral can be interchanged. This leads to the following recursion $$
N_{0,4}(a ; m) = \left(1+\frac{1-2a^2}{4m(a^2-1)}\right) N_{0,4}(a ; m-1) -\frac{(4m-3)a}{8m(m-1)(a^2-1)}\frac{d}{da} N_{0,4}(a ; m-2)
$$
Now, one can check that the polynomial given as an answer, satisfies these conditions and the initial conditions, completing the proof. Having said that, the intuition behind why such a polynomial should come into play is hard to explain without knowing hypergeometric functions. Extremely roughly speaking , however : provided we latch on a multiplicative term involving $a$, we can find a cousin of the solution to the recurrence above, that satisfies a second-order recurrence in $m$, which is also of the orthogonal type. That leads us to the Jacobi polynomials and the resulting expansion.

3
We are now going to use reduction formulas that express the given integrand in terms of simpler, easier to integrate functions. The theory applies to the integration of even rational polynomials with positive coefficients, whose denominator has symmetric coefficients i.e. reads the same from  (Like $(x^4+2ax^2+1)^m$)

Theorem : Define the "general symmetric polynomial" $$
D_p(d_1,\ldots,d_p ; z)=\sum_{k=0}^p d_{p+1-k}(z^{2k}+z^{4p-2k})
$$
Define the auxiliary polynomials
$$
E_p(d_1,\ldots,d_p;z) = \left(\sum_{j=1}^{p} d_j\right) z^{2p} + \sum_{i=1}^p 2^{2i-1} z^{2(p-i)}\sum_{k=1}^{p-i+1}\frac{j+i-1}{i}\binom{j+2i-2}{j-1}d_{j+i}
$$
For $d_i \in \mathbb R^+$. We have the following integral identity $$
\int_0^{\infty} \frac{z^{2n}dz}{D_p^{m+1}} = 2^{-m}\sum_{j=0}^{(m+1)p-n-1} 4^j\binom{(m+1)p-n-1+j}{2j}\int_0^{\infty} \frac{z^{2[(m+1)p-1-j]}dz}{E_p^{m+1}}
$$

In fact, the proof isn't really very difficult at all! It's actually just a repetition of what was done in section $1$ : a couple of double-angle substitutions topped off by a $\tan(v/2)$ type substitution. Nevertheless, it is important to see that the generalization occurs in the first place.
Using this theorem on $D_1 = z^4+2d_1z^2+1$ and the computed $E_1 = (1+d_1)z^2+2$ gives the following identity with $n=0$ : $$
\int_0^{\infty} \frac{dz}{(z^4+2d_1z^2+1)^{m+1}} = 2^{-m}\sum_{j=0}^m 4^j\binom{m+j}{2j} \int_0^\infty \frac{z^{2(m-j)}dz}{((1+d_1)z^2+2)^{m+1}}
$$
A change of variable involving $z^2$ on the latter integral will tell you that you only need to be able to evaluate $\displaystyle\int_0^\infty \frac{u^{r-\frac 12}du}{(1+u)^s}$. This can be done in a few ways, perhaps the best being to let $t = (1+u)^{-s}$, then recognizing a Beta integral which simplifies to a ratio of Gamma functions, followed by using Euler's reflection formula for the $\Gamma$ function. All in all, it's a simpler integrand to take care of.

4
We now introduce yet another transform. This transform is called the Landen transform, and it's origin in this situation is observed when one uses a substitution relating to $\cot \theta$. You can try , first, to prove the following identity

Theorem : Let $f$ be a rational function which is integrable over $\mathbb R$. Then $$
\int_{-\infty}^{\infty} f(x)dx = \int_{-\infty}^{\infty} \left[f(y+\sqrt{y^2+1}) + f(y - \sqrt{y^2+1})\right]\left(1+\frac{y}{\sqrt{y^2+1}}\right)dy
$$

If $f$ is even, then the above integral limits can also be $0,+\infty$. However, the most important observation is that this transform retains rationality : on the RHS, you still end up getting a rational function to integrate. The hope, of course, is that it will be simple enough to integrate.
In our case, if $Q(x) = \frac 1{(x^4+2ax^2+1)^{m+1}}$ then we use the result once to get the integrand on the right hand side $$
Q_1 = \left[Q(y+\sqrt{y^2+1}) + Q(y - \sqrt{y^2+1})\right]\left(1+\frac{y}{\sqrt{y^2+1}}\right)
$$
Remarkably enough, due to the nature of the $Q$ present here, we can simplify this and get the following expression $$
Q_1 = \sum_{k=0}^m \binom{m+k}{m-k} \frac{(2y)^{2k}}{2^m(1+a+2y^2)^{m+1}}
$$
Without going too much into that particular proof, the idea is that if $\phi = y + \sqrt {y^2+1}$ then $-\phi^{-1} = y - \sqrt{y^2+1}$. One can find a relation between $Q_1$ and the polynomial $\frac{\phi^{2m+1}+\phi^{-(2m+1)}}{\phi+\phi^{-1}}$. The latter polynomial is reminiscent of polynomials involving roots of quadratic equations : it is seen to satisfy a typical three-term recurrence. This three-term recurrence, interestingly enough, is once again of the "orthogonal form" as mentioned before, and the RHS comes in as a solution of the recurrence.
However, once $Q_1$ is identified, it's clear that the integral of $Q_1$ again reduces to the integration of $\frac{y^mdy}{(1+y)^n}$, and we are done.

5
We use Ramanujan's master theorem now, to provide yet another way of evaluating the integral. However, this one is more surprising, because it yields the answer quite straightforwardly and without too much fuss. It is also capable of harbouring better intuition. While the theorem itself is more difficult to state, it is the following version that is of use, and easier to state.

Theorem : Let $f(x) = \sum_{k=0}^\infty \frac{\lambda(k)(-x)^k}{k!}$ be expandable in a series. Then $$
\int_0^\infty x^{s-1} f(x)dx = \Gamma(s)\lambda(-s)
$$

That is, the ability to write $f$ as a power series in $-x$ allows you to then find certain integrals relating to $f$ (These are called the Mellin transforms). We want to use this to get our result. How do we do that?
The idea is to find a function , whose $\lambda$ are the $N_{0,4}(a;m)$. However, the integrands of $N_{0,4}(a ; m)$ form a geometric progression. It is then natural to expect that $f$ is likely to be of the type $\frac 1{1-\ldots}$ or something i.e. a sum, whose expansion is a geometric progression of coefficients.
With this in mind, we observe the following identity by solving the base case $$
\frac 1{\pi \sqrt 2}  \int_0^\infty \frac{dx}{x^4+2ax^2+1+c} = \frac{d}{dc}\sqrt{a+\sqrt{1+c}}
$$
Successive differentiations with respect to $c$ lead to an important geometric pattern being established. The result of such an operation is that we obtain the Taylor expansion $$
\sqrt{a+\sqrt{1+c}} = \sqrt{a+1} + \frac{1}{\pi \sqrt 2} \sum_{k=1}^\infty \frac{(-1)^{k-1}}{k} N_{0,4}(a ; k-1)c^k
$$
and we are in the territory of the theorem. Applying that, tells us $$
\Gamma(s) \lambda(-s) = \int_0^\infty c^{s-1}\sqrt{a+\sqrt{1+c}} dc
$$
However, did you notice that $\lambda(-s) = -\frac{(-s-1)!}{\pi \sqrt 2} N_{0,4}(a ; -s-1)$ seems to be some negative indexed analogue of $N_{0,4}$? This might be somewhat disconcerting. However, we are in the realm of complex analysis , where analytic continuation allows us to make meaning of such terms. One may notice the following derivative identity to achieve this $$
\lambda(m+1) = \left(\frac{-1}{2} \frac{d}{da}\right)^{2m+1} \lambda(-m)
$$
Following the differentiation and some routine substitutions, we arrive at $$
N_{0,4}(a ; m) = \frac{m \pi \sqrt 2}{2^{6m+1}}\binom{4m}{2m}\binom{2m}{m}\int_1^\infty u(u^2-1)^{m-1}(a+u)^{-(2m+1/2)}du
$$
The latter may be integrated by-parts : indeed, we take $u(u^2-1)^m$ to be the differentiated term, and integrate the other term repeatedly. The derivatives of this function eventually run out to $0$ . Furthermore, we can find the values of its derivatives at the point $1$ until they run out, hence we can derive every boundary term occurring in the expansion. Performing these routine calculations then lead to the proof.

6
This is just Gradshteyn-Ryzhik and their formula for this case, using the hypergeometric function. Formula 3.252.11 of GS reads
$$
\int_0^\infty \frac{x^{\nu-1}dx}{(x^2+2ax+1)^{\mu + 1/2}} = \frac{2^\mu \Gamma(1+\mu)B(-\nu+2\mu+1,\nu) P^{-\mu}_{\mu - \nu}(a)}{(1-a^2)^{\mu/2}}
$$
where $\Gamma,B$ are the Gamma and Beta functions respectively, and $$
P^{\beta}_{\alpha}(x) = \frac 1{\Gamma(1-\beta)} \left(\frac{a+1}{a-1}\right)^{\beta/2} {}_2F_1(-\alpha,\alpha+1 ; 1-\beta ; \frac{1-a}{2})
$$
is the Legendre function with parameters $\alpha,\beta$ expressed in parametric form. It is possible to use this representation to connect it to Jacobi polynomials, which leads to the formula in the starting.
I do not know how to derive this identity or how the hypergeometric functions link up with the Jacobi functions, however.

References

Gradshteyn, Ryzhik : Table of integrals, series and products

Boros, George; Moll, Victor H., An integral hidden in Gradshteyn and Ryzhik, J. Comput. Appl. Math. 106, No. 2, 361-368 (1999). ZBL0939.33007

Boros, George; Moll, Victor H., The double square root, Jacobi polynomials and Ramanujan's master theorem, J. Comput. Appl. Math. 130, No. 1-2, 337-344 (2001). ZBL1011.33005

Amdeberhan, Tewodros; Espinosa, Olivier; Gonzalez, Ivan; Harrison, Marshall; Moll, Victor H.; Straub, Armin, Ramanujan's master theorem, Ramanujan J. 29, No. 1-3, 103-120 (2012). ZBL1258.33001

Amdeberhan, Tewodros; Moll, Victor H., A formula for a quartic integral: a survey of old proofs and some new ones, Ramanujan J. 18, No. 1, 91-102 (2009). ZBL1178.33002

Boros, George; Moll, Victor H., Landen transformations and the integration of rational functions, Math. Comput. 71, No. 238, 649-668 (2002). ZBL0988.33009
Comment: $a^2 - 1$ in section 6 should be $1 - a^2$, otherwise $a = -1/2$ would give a complex factor. Also, the relation between the Legendre function and the hypergeometric function should be as given [here](https://en.wikipedia.org/wiki/Legendre_function). Apparently the simplest closed form is $\pi C_{-1/2}^{(n)}(-1/2)/2$.
Comment: @Maxim Thanks for pointing this out, I'll edit it.
Answer: In order to tackle the general integral, I define a more general integral
$$
I_{n}(a):=\int_{0}^{\infty} \frac{1}{\left(x^{4}-a x^{2}+1\right)^{n}} d x.
$$
where $a<2.$
I am attempting to create a "Reduction Formula" for $I_{n}(a)$.
Differentiating $I_{n}(a)$ twice w.r.t. $a$ yields
$$
\int_{0}^{\infty} \frac{x^{4}}{\left(x^{4}-a x^{2}+1\right)^{n+2}} d x=\frac{1}{n(n+1)} I_{n}^{\prime \prime}(a) \tag*{(1)}
$$
Differentiating $I_{n+1}(a)$ w.r.t. $a$ yields
$$
\int_{0}^{\infty} \frac{x^{2}}{\left(x^{4}-a x^{2}+1\right)^{n+2}} d x=\frac{1}{n+1} I_{n+1}^{\prime}(a) \tag*{(2)}
$$
(1)-$a \times $(2) yields
$$
\begin{aligned} \\
\int_{0}^{\infty} \frac{x^{4}-a x^{2}+1-1}{\left(x^{4}-a x^{2}+1\right)^{n+2}} d x=\frac{I_{n}^{\prime \prime}(a)}{n(n+1)}-\frac{a I_{n+1}^{\prime}(a)}{n+1} \\
I_{n+1}(a)-I_{n+2}(a)=\frac{I_{n}^{\prime \prime}(a)}{n(n+1)}-\frac{a I_{n+1}^{\prime}(a)}{n+1} \\
\boxed{I_{n+2}(a)=I_{n+1}(a)-\frac{I_{n}^{\prime \prime}(a)}{n(n+1)}+\frac{a I_{n+1}^{\prime}(a)}{n+1}}, \\
\end{aligned}
$$
which is the "Reduction Formula" for $I_n(a).$
Now we need two "initial" integrals, $I_1(a)$ and $I_2(a)$ which can be found in my answer in Quora,
$\displaystyle  \boxed{I_{1}(a)=\frac{\pi}{2 \sqrt{2-a}} \text { and } I_{1}^{\prime}(a)=\frac{\pi}{4(2-a)^{\frac{3}{2}}}} \tag*{} $
$\boxed{ \displaystyle I_{2}(a)=\frac{\pi(3-a)}{4(2-a)^{\frac{3}{2}}} \text { and } I_{2}^{\prime}(a)=\frac{\pi(5-a)}{8(2-a)^{\frac{5}{2}}}} \tag*{} $
Now we can apply the formula.
$$
\begin{aligned}
I_{3}(a) &=I_{2}(a)-\frac{I_{1}^{\prime \prime}(a)}{2}+\frac{a I_{2}^{\prime}(a)}{2} \\
&=\frac{\pi(3-a)}{4(2-a)^{\frac{3}{2}}}-\frac{3 \pi}{16(2-a)^{\frac{5}{2}}}+\frac{a \pi(5-a)}{16(2-a)^{\frac{5}{2}}}\\&= \frac{3 \pi\left(a^{2}-5 a+7\right)}{16(2-a)^{\frac{5}{2}}}
\end{aligned}
$$
$$\boxed{\int_{0}^{\infty} \frac{1}{\left(x^{4}-a x^{2}+1\right)^{3}} d x= \frac{3 \pi\left(a^{2}-5 a+7\right)}{16(2-a)^{\frac{5}{2}}}}\tag*{}$$
In particular, when $a=1$,
$$
\boxed{I_{n+2}(1)=I_{n+1}(1)-\frac{I_{n}^{\prime \prime}(1)}{n(n+1)}+\frac{I_{m+1}^{\prime}(1)}{n+1}}
$$
$$
\int_{0}^{\infty} \frac{d x}{\left(x^{4}-x^{2}+1\right)^{3}}=\frac{9 \pi}{16},
$$
$$
\begin{aligned}
\int_{0}^{\infty} \frac{d x}{\left(x^{4}-x^{2}+1\right)^{4}} &=I_{3}(1)-\frac{I_{2}^{\prime \prime}(1)}{6}+\frac{I_{3}^{\prime}(1)}{3} =\frac{9 \pi}{16}-\frac{9 \pi}{48}+\frac{9 \pi}{32} =\frac{21 \pi}{32}
\end{aligned}
$$
By the way, I had also found 8 other integrals.
$ \begin{aligned}&\int_{0}^{\infty} \frac{d x}{x^{4}+x^{2}+1}=I_{1}(-1)=\frac{\pi}{2 \sqrt{3}} \\&\int_{0}^{\infty} \frac{d x}{x^{4}-x^{2}+1}=I_{1}(1)=\frac{\pi}{2} \\&\int_{0}^{\infty} \frac{d x}{\left(x^{4}+x^{2}+1\right)^{2}}=I_{2}(-1)=\frac{\pi}{3 \sqrt{3}} \\&\int_{0}^{\infty} \frac{d x}{\left(x^{4}-x^{2}+1\right)^{2}}=I_{2}(1)=\frac{\pi}{2} \\&\int_{0}^{\infty} \frac{d x}{\left(x^{4}+x^{2}+1\right)^{3}}=I_{3}(-1)=\frac{13}{48 \sqrt{3}} \\&\int_{0}^{\infty} \frac{d x}{x^{4}+1}=I_{1}(0)=\frac{\pi}{2 \sqrt{2}} \\&\int_{0}^{\infty} \frac{d x}{\left(x^{4}+1\right)^{2}}=I_{2}(0)=\frac{3 \pi}{8 \sqrt{2}} \\&\int_{0}^{\infty} \frac{d x}{\left(x^{4}+1\right)^{3}}=I_{3}(0)=\frac{21\pi}{64 \sqrt{2}}\end{aligned} \tag*{} $
Theoretically, I can find the exact values of the integrals one by one. But is there any hope to find the closed forms of
$I(a)$ using the formula?  Your help is highly appreciated.
Answer: Glad to see there are several nice answers in various perspectives.  I am now going to give one more by inverse substitution followed by integration by parts.
Using $x \mapsto \frac{1}{x}$ yields
$$
I(m, n, r):=\int_{0}^{\infty} \frac{x^{r} d x}{\left(x^{m}+1\right)^{n}} \stackrel{x \mapsto \frac{1}{x}}{=} \int_{0}^{\infty} \frac{\frac{1}{x^{r}}}{\left(\frac{1}{x^{m}}+1\right)^{n}}\left(\frac{d x}{x^{2}}\right)
$$
Simplifying and then  performing integration by parts,
$$
\begin{aligned}
I(m, n, r) &=\int_{0}^{\infty} \frac{x^{m n-r-2}}{\left(1+x^{m}\right)^{n}} d x \\
&=-\frac{1}{m(n-1)} \int_{0}^{\infty} x^{(n-1)m-r-1} d\left(\frac{1}{\left(1+x^{m}\right)^{n-1}}\right) \\
&=\frac{m(n-1)-r-1}{m(n-1)} \int_{0}^{\infty} \frac{x^{m(n-1)-r-2}}{\left(1+x^{m}\right)^{n-1}} d x \\
&=\left(1-\frac{r+1}{m(n-1)}\right) I(m, n-1, r) \\
&\qquad\qquad  \vdots\\ &=\left(1-\frac{r+1}{m(n-1)}\right)\left(1-\frac{r+1}{m(n-2)}\right) \cdots\left(1-\frac{r+1}{m}\right) I\left(m,1,r\right) \\
&=\prod_{j=1}^{n-1}\left(1-\frac{r+1}{j m}\right)\int_{0}^{\infty} \frac{x^{r}}{x^{m}+1} d x
\end{aligned}
$$
Using the formula proved in my post
$$
\int_{0}^{\infty} \frac{x^{r}}{x^{m}+1} d x=\frac{\pi}{m} \csc \frac{(r+1) \pi}{m},
$$
by putting $r=2k$ and $m=6$, we can conclude
$$
\begin{aligned}
\int_{0}^{\infty} \frac{1}{\left(x^{4}-x^{2}+1\right)^{n}} d x
=& \int_{0}^{\infty}\left(\frac{x^{2}+1}{x^{6}+1}\right)^{n} d x \\
=& \sum_{k=0}^{n}\left(\begin{array}{c}
n \\
k
\end{array}\right) \int_{0}^{\infty} \frac{x^{2 k}}{\left(1+x^{6}\right)^{n}} d x \\=& \boxed{\sum_{k=0}^{n}\left[\left(\begin{array}{c}
n \\
k
\end{array}\right) \frac{\pi}{6} \csc \frac{(2 k+1) \pi}{6} \prod_{j=1}^{n-1}\left(1-\frac{2 k+1}{6 j}\right)\right]}
\end{aligned}
$$
Comment: Note that $$\int_{0}^{\infty} \frac{x^{2k}}{x^{6}+1} d x$$ in recursion may diverge for $0\le k \le n$.
Answer: Differentiation sometimes is easier than integration!
Inverse substitution rewrites the integral
$\displaystyle \int_{0}^{\infty} \frac{x^{r}}{x^{m}+a} d x \stackrel{x\mapsto\frac{1}{\sqrt[m]{a}}}{=}\frac{1}{a^{1-\frac{r+1}{m}}} \int_{0}^{\infty} \frac{x^{r}}{x^{m}+1} d x \tag*{} $
where $0<a<2.$
Using the formula proved in my post
$ \displaystyle \int_{0}^{\infty} \frac{x^{r}}{x^{m}+1} d x=\frac{\pi}{m } \csc \frac{(r+1) \pi}{m},\tag*{} $
we get
$ \displaystyle \int_{0}^{\infty} \frac{x^r}{x^{m}+a} d x=a^{-\left(1-\frac{r+1}{m}\right)} \frac{\pi}{m} \csc \frac{(r+1) \pi}{m}\tag*{} $
Differentiating the integral w.r.t. $ a$ by$n-1 $ times yields
$ \displaystyle \int_{0}^{\infty} \frac{(-1)^{r-1}(n-1) ! x^{r}}{\left(x^{m}+a\right)^{n}}=\frac{\pi}{m} \csc \frac{(r+1) \pi}{m}(-1)^{n-1}\left(1-\frac{r+1}{m}\right)\left(2-\frac{r+1}{m}\right)\cdots\left(n-1-\frac{r+1}{m}\right)a^{-\left(n-\frac{r+1}{m}\right)} \tag*{}$
Now we can conclude that
$$\boxed{ \displaystyle \int_{0}^{\infty} \frac{x^{r} d x}{\left(x^{m}+a\right)^{n}}=\frac{\pi}{m(n-1) !} \csc \frac{(r+1) \pi}{m} \prod_{j=1}^{n-1}\left(j-\frac{r+1}{m}\right) a^{-\left(n-\frac{r+1}{m}\right)}}$$
Come back to our integral and use Binomial Theorem.
\begin{aligned}\int_{0}^{\infty} \frac{1}{\left(x^{4}-x^{2}+1\right)^{n}} d x =& \int_{0}^{\infty}\left(\frac{x^{2}+1}{x^{6}+1}\right)^{n} d x =\sum_{k=0}^{n}\left(\begin{array}{l}n \\k\end{array}\right) \int_{0}^{\infty} \frac{x^{2 k}}{\left(x^{6}+1\right)^{n}} d x\end{aligned}
Putting $ m=6, r=2k $ and $ a=1 $ yields
$\displaystyle \boxed{\begin{aligned}\int_{0}^{\infty} \frac{1}{\left(x^{4}-x^{2}+1\right)^{n}} d x &=\sum_{k=0}^{n}\left(\begin{array}{c}n \\k\end{array}\right) \frac{\pi}{6(n-1) !} \csc \frac{(2k+1) \pi}{6} \prod_{j=1}^{n-1}\left(j-\frac{2k+1}{6}\right)\\&=\sum_{k=0}^{n}\left[\left(\begin{array}{l}n \\k\end{array}\right) \frac{\pi}{6} \csc \frac{(2 k+1) \pi}{6} \prod_{j=1}^{n-1}\left(1-\frac{2 k+1}{6 j}\right)\right] \end{aligned} }\tag*{} $
Answer: With CAS and help of <code>MellinTransfrom</code>:
$$\int_0^{\infty } \frac{1}{\left(x^4-x^2+1\right)^n} \, dx=\\\mathcal{M}_s^{-1}\left[\int_0^{\infty } \mathcal{M}_a\left[\frac{1}{\left(x^4-a x^2+1\right)^n}\right](s) \,
   dx\right](1)=\\\mathcal{M}_s^{-1}\left[\int_0^{\infty } \frac{(-1)^{-s} x^{-2 s} \left(1+x^4\right)^{-n+s} \Gamma (n-s) \Gamma (s)}{\Gamma (n)} \,
   dx\right](1)=\\\mathcal{M}_s^{-1}\left[\frac{(-1)^{-s} \Gamma \left(\frac{1}{4}-\frac{s}{2}\right) \Gamma \left(-\frac{1}{4}+n-\frac{s}{2}\right) \Gamma (s)}{4 \Gamma
   (n)}\right](1)=\\\frac{\Gamma \left(\frac{1}{4}\right) \Gamma \left(-\frac{1}{4}+n\right) \, _2F_1\left(\frac{1}{4},-\frac{1}{4}+n;\frac{1}{2};\frac{1}{4}\right)}{4 \Gamma
   (n)}+\frac{\Gamma \left(\frac{3}{4}\right) \Gamma \left(\frac{1}{4}+n\right) \, _2F_1\left(\frac{3}{4},\frac{1}{4}+n;\frac{3}{2};\frac{1}{4}\right)}{4 \Gamma (n)}$$


Funcao codeigniter com sql

Question: Tenho uma função chamada pneus na model do codeigniter
E na mesma model tenho outra função que eu preciso chamar o cod da função pneus
Alguém pode me dizer como faço isso aqui um exemplo do que quero fazer...
<code>$this->db->where('xcod1 = ', $this->pneus->cod);</code>
Comment: Está a aceder à tabela? Não terá de especificar a tabela da BD
Comment: Não ficou mto claro qual é o problema, poderia explicar melhor e colocar as partes importantes do model?
Comment: Digamos a sql é essa : $this->db->where('xcod1 = ', Aqui eu quero pegar um cod); E esse cod vem de uma outra função ai quero saber como posso pegar fiz usando $this->nomeDaFuncao->cod;
Comment: Faça a função retornar o valor, depois passe ele para frente.
Comment: E como passo ela ?
Answer: O model do CI ele serve apenas para comunicação com DB, quem gerenciar e chama as funções são os controller
Pois bem nessa sua função:
<code>$this->db->where('xcod1 = ', $this->pneus->cod);
</code>
o correto seria, sem o sinal de "=" ficando assim:
<code>$this->db->where('xcod1', $this->pneus->cod);
</code>
mas de onde vem o objeto pneus, acredito q esteja ai!

Funcao codeigniter com sql


$\mu(A\backslash B) = \mu(A)-\mu(B)$...when does this hold?

Question: I have looked seemingly everywhere on this site yet couldn't find an answer to this question: when is it the case that the difference between two sets has a measure equal to the difference in measures (i.e., what conditions will allow $\mu(A\backslash B) = \mu(A)-\mu(B)$ to hold true)?
I don't anticipate a list of all possible situations...however, some cases alongside maybe examples would be extremely helpful. As far as context is concerned, this is simply for the sake of curiosity; not necessarily for any specific proof. I am currently studying Gerald Folland's Real Analysis text.
Comment: If $B\subset A$ and $\mu(A)<\infty$
Comment: Yes, you are right. If $B\subset A$, and $\mu(B)<\infty$, then we are OK. This condition is of course more general than $\mu(A)<\infty$
Comment: @AndrewZhang $\mu(B) < \infty$. $A$ can have infinite measure, we just can't subtract $\infty$ naively.
Comment: @JAG131 As an aside, when $B$ isn't a subset of $A$ in a given argument, it's a common trick to write $B = (A \cap B) \cup (B \setminus A)$ so you can then cut out the piece of $B$ that actually lies in $A$.
Comment: It's not necessary that $B\subseteq A,$ i.e. $B\setminus A=\emptyset.$ One can have $B\setminus A\neq\emptyset$ as long as $\mu(B\setminus A)=0.$
Comment: It holds true if $B$ is measurable and a subset of $A$.
Comment: That's it? Lot less complicated than I was expecting. Thanks all!
Answer: First assume that $\mu(A)<\infty$ and $\mu(B)<\infty$ so that the right hand side is defined.
Then, since $A = (A\setminus B)\cup(A\cap B),$ where $A\setminus B$ and $A\cap B$ are disjoint, we have
$
\mu(A) = \mu(A\setminus B)+\mu(A\cap B),
$
i.e.
$$
\mu(A\setminus B)=\mu(A)-\mu(A\cap B).
$$
But we want the second term on the right hand side to be $\mu(B),$ so when is $\mu(A\cap B)=\mu(B)$? Just as above we also have
$$
\mu(B\setminus A) = \mu(B) - \mu(A\cap B)
.
$$
Thus $\mu(A\cap B)=\mu(B)$ exactly when $\mu(B\setminus A)=0.$
We conclude that for sets $A$ and $B$ of finite measure we have $\mu(A\setminus B) = \mu(A)-\mu(B)$ exactly when $\mu(B\setminus A)=0,$ i.e. when $B$ is almost included in $A$.


How to Zoom and Pan SWF file in Flex

Question: I need to pan and zoom swf file . I have work with adobe's zoom component. But it work only with images.
My requirement is zoom the specified area of swf and set centrally when I drag and drop a
rectangle to the swf file.
Have any open source api available for doing this. or please give any useful information.
Thanks.
Answer: U can use native Gesture-events. Catch them from the Stage or any other instance of InteractiveObject class.
e.g.:
anyYourInteractiveObject.addEventListener(GestureEvent.GESTURE_TWO_FINGER_TAP, twoTapHandler);

or
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, zoomGestureHandler);

How to Zoom and Pan SWF file in Flex


Is there a name referring to this result?

Question: For any real $m \times n$ matrix $A$, it seems that
$$\det(I_n + A^{T}A) = \det(I_m + AA^{T}) $$
always holds, where $I_n$ is the identity matrix of size $n$.
Though I have not tried to prove this yet, I'm sure it is a part of well-known results in linear algebra. So my question is, what is the name referring to this fact, and where can I find a reference to it?
Comment: See [this question](http://math.stackexchange.com/questions/17831/sylvesters-determinant-identity) for proofs of Sylvester's determinant identity.
Comment: @MTurgeon: My question came from preliminary differential geometry, when considering the Riemannian volume form $\sqrt{g}$ of the metric on a graph of a multivariable function.
Comment: I thought at first that there was no reason for it to have a name. But then I noticed it was familiar, thus my answer below. So I was wrong.
Answer: It does: it is a special case of Sylvester's determinant theorem.
Comment: Surely this is what I've been looking for! Thanks so much!


What is the best way to address users storing and streaming music within your company?

Question: We have a number of users who have MP3s in their home directories which are stored on our centralized file server. This has a negative affect on how long our backups take, how much drives space we need to have, etc. I thought about sending e-mails out for people to remove it with a notice that it would be deleted by a certain day but I don't feel that this is the right way to go about this. Many of these employees have music because it helps them work more efficiently and they don't have quantities that are excessive but the amount in sum across all the employees is still significant.
I have come up with a couple of ideas but each have their own problems:

Idea: Allow Users to stream music instead of storing it
Problem: Takes up too much bandwidth
Idea: Move all the music to the users' local machines
Problem: This would take significant effort on my department's part and we would then be responsible for doing things like redirecting the default directories for iTunes on people's computers so that data is stored locally
Idea: Encourage people to purchase their own portable MP3 players by leveraging our corporate discount to offer employees discounted players
Problem: Some of our users listen to podcasts, something that I have found extremely beneficial in my job, and may not have a computer at home to synchronize with

What are some good ways to handle respecting our users and getting the productivity and morale benefits that music affords without having to store users' music on our file server?
Comment: Companies can be sued for pirated music on their network, especially if it's on servers and not desktops. The company is going to have a tough time proving it owns the CDs that the MP3 was ripped from.
Comment: Problems like this require a management solution, not system administration.
Comment: To clarify on the "owns the CDs that the MP3 was ripped from";  owning the CD actually does not confer you any additional rights in this case; and even if it did, the CDs almost certainly belong to the employees, NOT the company, so this is a very cut-and-dry case of illegal file sharing (between the employee and the company server).
Comment: What are the good ways of respecting your users? Well for me that would be reminding them that music players are cheap these days and then telling them that they've got a week before the global delete takes care of their MP3 files.
Comment: I almost cried...
Comment: If you're a Microsoft house why not ask for a bunch of free Zunes? It not like there's a shortage of them :)
Comment: As soon as i read that you are backing up MP3s, I cringed.
Comment: @GWLlosa "owning the CD actually does not confer you any additional rights in this case" maybe not on your country. YMMV...
Answer: I'd be tempted to ask senior management just to send out a "remove and don't do it again" email - then you can do a monthly scan and give the management a list of those still doing it.
It's not a technical issue so don't make it one.
Comment: Whoa. Way to ruin the work environment. And how does prescribing MP3 players or desk radio (hark, anachronism) address this? Having music *on the PC* is so much more practical. Just give the users some storage space that isn't backed up. Don't swing the banhammer. About the "hard costs" – doesn't every piece of equipment for the employees and every can of milk in the fridge incur costs? Aren't milk-saving companies the epitome of the evil company nobody likes to work for?
Comment: Stolen milk too, mmmm...delicious stolen milk hmmm
Comment: I cannot upvote this enough.  There is a fine line between personal use and legitimate business needs.  If it crosses into a realm where it either costs the company actual monies (in the form of backups) or IT time...it's no longer "personal use".
Comment: I completely agree. If a user needs music to be productive, an MP3 player or desk radio of some sort should be the only option. Saving music on the servers or streaming music are both hard costs that can and should be avoided.
Comment: It would cost you less in the long run to just purchase an iPod for each user...
Comment: @Konrad - YES swing the banhammer, if that is what it takes? Why should an employer be expected provide storage space for their employees to use this way? Potentially incur legal risk? Have to deal with the support issues that arise? I don't see an employer as "evil" because they refuse to expose themselves to that problem. And I'm sorry but where's the inconvenience to asking people to use their own MP3 player to listen to their own music?
Comment: I'd like to install a cracked Street Figher IV con my computer so I can enjoy better my lunchtime.
Comment: Ok, keep it on the local disk then, no need for them on the network.
Comment: "not a technical issue" Fair point! When you've moved the files to the desktops and it still hit's the fan you're gonna get it. Best approach if you're gonna take one is an absolute approach.
Comment: Likewise I can't upvote this enough.  Include HR in the notification to the senior management.  If you don't have a computer use policy, now would be an excellent time to put one in place, effective immediately (many examples on the net).  Have HR add the policy notification to their onboarding process, and ensure that it states that employment and usage of company resources constitutes agreement with the policy.
Comment: As others have said, I can't upvote this enough - chasing technical solutions for non-technical management issues is an enormous waste of IT resources.
Comment: +1 File within the same AUP that deals with users browsing Facebook/YouTube/whatever-sites-management-dislikes-today.
Comment: Agreed - Have management make it a company policy NOT to store mp3s, etc and have employees sign off on it.  If it is a policy and people are still doing it, you have all the authority you need to enforce it.  This goes beyond employees' "productivity" (which is never a quantitative figure anyway and is not your position to judge - it is the employee's manager)
Comment: @Konrad:  If you have employees ordering THOUSANDS OF GALLONS of milk, then that's an accurate comparison.
Answer: Whatever you do, you are going to need management support for it.  IT can rarely set its own policies without this support (especially if your policy affects management - like if they are also storing mp3s on the server...)  Users generally get upset when things stop working the way they always have as well so you are going to need to communicate with them BEFORE you make any changes too.  Company storage of mp3s is not a good idea even if you don't have any SLA on the data and it could disappear at any time since it could lead to legal issues (can you be certain that NONE of the mp3s are copyrighted?).  Again, this is a small chance, but it is still there.
Depending on your file server, you may be able to exclude certain file types from being stored at all, and you can usually exclude certain file types from backups as well depending on the backup software.  Windows 2003 has File Server Resource Manager that allows you to set quotas, file screens, etc...
Comment: Thank you for the additional heads up about being able to filter file types right on the file server. I didn't realize that was possible.
Comment: +1, +1, +1. It is always a losing proposition trying to find a technical solution to a personal problem.
Answer: Exclude music and video directories from your backups entirely, and let your coworkers know that those directories are provided as-is, not backed up and they shouldn't put important stuff there.
If legal/copyright issues are a concern, have employees sign a waiver that says anything they put in those directories is solely their own responsibility.
I have seen a lot of companies where the IT department is a total pain-in-the-ass, making their coworkers miserable day after day. Please work hard towards not being one of those. Keep in mind that you are there to help your coworkers make the best of their working day :)
Comment: @Cypher that is a *completely* different use-case! The question refers to users saving their music on their work computers so that they can listen to it (and that causes backups to bloat), and **not** users piggybacking on company backups for their personal usage.
Comment: I agree that it is a good answer. But it seems we understand the question differently: the way I read the first sentence of the question, the mp3s ending up in backups is just a side-effect of the user's actions - and not the aim of the users when they put the files there.
Comment: Users are clever.  They will just stick their music in other directories that *are* backed up.
Comment: @ANeves Actually, that's not correct.  See the first sentence of the question.  :-)  I'll clarify that this *is* a good answer and will indeed help with backup bloat, there may be a need to do a bit more than just exclude directories (circumstances depending, of course).
Answer: I'm afraid that there isn't an answer that either you or your users are going to like.  This type of issue plagues many IT departments.  I'm lucky because I work for a government agency, where it's strictly forbidden to rip MP3s to the network (for that matter, they're strictly prohibited from connecting ANY personal device to the network).  We have specific policies in place prohibiting it.
We encourage people to bring portable radios or MP3 players instead.  That's the easiest route.
Edited to add:  The minute you lay your hands (IT) on this issue will be the minute that your users expect numerous things to happen.  One, that you'll help them restore all the MP3s they deleted.  Two, you'll help them rip CDs they brought.  Three, make it easier for them to share music with other employees...and the list goes on and on.
This is a Pandora's box that you don't want to open my friend, because it will only end in frustration from an IT standpoint.  DO NOT ALLOW THIS.
Comment: [Godwin's Law](http://en.wikipedia.org/wiki/Godwin's_law)? Seriously? Here?
Comment: In the limited experience I have, people already expect these things just because your in IT - the network storage aspect doesn't change much in this regard. In either case you can just refuse to support it.
Comment: Is that comment worth flagging, or preserving for the sheer numbskullery?
Comment: @mfinni:  I say leave it.  I'll attribute it to the younger crowd on SF.
Comment: It's been my experience that expectations can be managed really well with IT policies and procedures.
Comment: And it got an upboat?
Answer: I had the same issue at my company, what I ended up doing in the end was creating a separate network share dedicated to music. Backups are limited to a single weekly sync. We call the share 'play', and its reserved for non-essential data, anything that ends up there might disappear forever :)
Bonus edit: just checked the share size:
<code>[ben@kentro play]# du -h
  ...
712G    .
</code>
Yikes!
Comment: My inner BOFH recommends RAID 0 storage made up exclusively from old laptop hard drives...
Comment: Much better to allow a pressure valve for this impulse than to divert IT and management time onto trying to squash it.   But it does depend a bit on the company culture.
Comment: I should add, we've got a pretty rad culture :)
Comment: We use a 24 disk raid 1 setup, good enough :)
Answer: I'm not an employer nor a sysadmin so I can only offer an employee's perspective:
A company that bans me from storing music on my work PC sucks.
Of course finding a solution will cost resources (and effectively money). But so do all other investments for the employees, from the second monitor to a fridge full of milk and all the other stuff.
I was under the impression that abolishing fresh milk to cut costs is universally seen as a douchey move. In fact, Joel even uses this as a hook in a promo movie for Fog Creek, to offset himself from those big, unfriendly corporations.
If music makes programmers productive, giving them second-best solutions isn't a smart move, in my opinion.
Instead of mandating portable MP3 players or blaring radios, can't the company reserve a remote folder for storage that isn't backed up?
Comment: @Zoot: well at least they're making an effort but I for one prefer having a decent software to play my music instead of an inherently user-unfriendly MP3 player. Even a sucky software like iTunes beats the best MP3 player hands down.
Comment: Is this policy universally bad, or is there any way for the company to turn this into a positive?  For example, a company that prevents me from listening to music sucks, but a company that gives me $100 to buy an MP3 player is awesome, right?
Comment: Not storing music on work PCs isn't that bad ... yes, it means I can't share out my collection of odd xmas music ... but it's nowhere near as obnoxious as the 'no plugging personal devices into government computers' rule which meant I had to get extra cables so I wasn't crawling under my desk each day to keep my ipod charged.
Answer: Hardware is cheap, employees are expensive. If adding $100 in hardware/infrastructure and $50/mo in support costs PER USER allows your users to be even 5% more effective, then it is a good business decision. Buy more hard drives and a faster network for your backup system, or a faster network to allow streaming. Happy employees are productive employees.
Comment: Or, buy them a new iPod touch/MP3 player of choice and offer them a new one every two years that they remain employees.
Answer: One possibility is that you could create an MP3 share for every user on some USB drives hooked up to your system (or some sort of other cheaper storage) depending on the size of your company. The only downside is that you or your company might get in trouble if these are copyrighted mp3s -- that seems a bit paranoid to me for a small/medium company though.
You could then not worry about backing up these shares. Also, it wouldn't help the file storage issues but you could always exclude *.mp3 from backups. But then you might loose actual needed mp3 content.
My vote would be just to go and delete them periodically for anything outside of iTunes which you could control with the GPO. I think saying "No Music" would really hurt Moral, but I never got much kickback when trying to tell them that these files had to be local -- users were understanding. You can make a help document that explains how to move it and send automated warnings. You could even say it has to be legal data as well in that document.
Comment: Also, I really like your idea of the iPod (or whatever) discount. Might generate good will while solving a problem :-)
Comment: I like the idea but it would still put a burden on our IT department both in terms of labor and legal requirements to support and maintain something like this. Most of our users are not technically savvy enough to be able to manage their music files themselves aside from what something like iTunes does for them by default. If I could control iTunes through GPO that would be moving in the right direction but I still don't like taking on the legal responsibility for storing files that may have been downloaded illegally.
Comment: +1 for Morale consideration.
Comment: Not necessarily on USB drives, just on a network drive. Also, one could put a "Music" link in everyone's home directory pointing to the share. That would make it near-painless for unsophisticated users.  Of course, that share isn't backed up.  Your Chairman's mp3 board meeting recording would be in the normal user space, so it *would* be backed up.
Answer: To start I'd enforce quotas for the home directories and exclude *.mp3, *.mp4, *.ogg, *.wma *.whatever-other-stuff you don't want backed up.
Comment: I thought about this too but I imagine the day when the CEO or one of the other executives or mangers walks into my office and says that they need me to recover the recording of an executive meeting that they accidentally deleted from their home directory, which just so happened to be in MP3 format.
Comment: Probably better to exclude a standardized music directory name than to exclude by extension.
Comment: Hey I really like this solution. Tbh though, I don't think excluding MP3 format is such a problem. The CEO etc should not be storing recordings of offical meetings, adhoc meetings even, should not be stored on the home drive. They should be stored in the correct location on the companies network share for that team/department.
Comment: As described by the OP, that means that they can't store it at all, which means that they will stream it, using bandwidth. Now if you put that restriction into the backup software instead, that solves the problem - less bandwidth, and shorter backup times.
Answer: I'd suggest promoting the personal music player policy.  It encourages users to continue listening to the music that helps their productivity, but limits your liability.  Set a policy for storage of personal data and usage of streaming services on work computers/networks.
Some employees have purchased smartphones for the purpose of streaming music during work hours without using company bandwidth.  The guy across the aisle from me does that.
You could also search for .mp3 files and email the users reminders about responsible computer use, but this risks straying into the "Mordac the Preventer" territory of system administration.
Answer: No one seems to be mentioning the legal side of things here.  There are huge copyright infringement issues surrounding storing MP3s on corporate servers.  Any CIO worth his/her salt will ban MP3 storage on corporate PCs or servers.
I LMAO when I read "A company that bans me from storing music on my work PC sucks.", above.
Comment: @Simon: *is* there a copyright issue with this? I don't think so. As long as the company servers aren't used for *sharing* (which, to be honest, is common practice at many workplaces), I don't see any problems. There is no automatic copyright infringement just because something is stored on company-owned computers. If that were the case, every single-license software ever acquired by anyone at a company would infringe copyright.
Comment: Actually, in this case, there is a pretty clear-cut copyright issue.  Someone buys a CD.  That gives them the CD, and the right to play the music on the CD.  That is the extent of the 'rights' that they have from owning the CD.  The servers, presumably, belong to the company.  So the person has made an illegal copy of a CD (the .mp3) and illegally distributed it (to the company share) and every time it is backed up, ANOTHER ILLEGAL COPY IS MADE.
Comment: @GWL and the others here: I remain unconvinced. Nobody has addressed my software license point which should be completely analogous, but is common practice (nb: assume here that *I* bought the license, not the company … but even then, the same issues would exist regarding storage and copies). – Then there's the backup issue; of course, this will depend on the country in question but at least in Germany, creating a backup is not, and was never, a copyright infringement. Distribution on a share is another matter entirely, and I have explicitly *excluded* that from my consideration above.
Comment: Legal side of things wasn't part of the question. It was a technical question about how to solve an issue where a key assumption is that the users have taken the time to responsibly acquire MP3 music.
Comment: Add to that, if the company makes a policy decision to support/encourage the infringing behavior (the proposed IT policies would all apply), they are even more culpable.
Comment: @GWLlosa When I purchase a CD, I also have the Fair Use right to format and time shift the contents of that CD for personal use [margin too small for citation]. WHERE I format-shift it to has never been an issue tested in court, but I can't imagine it mattering.
I concede the backups point. Easy solution, don't backup mp3 files.
Comment: @Konrad - There are at least two legal issues with this. Firstly - the sharing point; there may be many who respect that this isn't legal but the company only needs to have one or two foolish employees on staff who don't respect this and it has a problem. Secondly - a sane company wouldn't want to expose itself to *potential* liability for the above scenario, for things like performance rights charges for the music, for unlicensed music on its servers, etc. Regardless of "right" or "wrong", the employer has better things to do with its profits than paying the legal costs of being a test case.
Answer: Enforce quotas for backed-up directories, and leave some larger storage available for non-critical data.
Answer: If you're in europe, Spotify solves your problem. Or redirect "My Music" to their local harddrive if you're on the windows platform.
Answer: I don't even know why this is an issue tbh.
We don't allow people to store personal music/video files on company machines.  We don't do it because of storage implications as that's a relative non-issue - we do it because we don't know, and don't have the resource to find out if we did want to know, the copyright situation of those files.
Some people seem to view music files differently to the way they would if, say, a user wanted to store a bunch of ripped video games on a company owned machine.
An 8gb USB stick costs next to nothing, if people want to play their music on a company PC they're welcome, just don't store it on one.
Answer: Assuming that your client computers have plenty of drive space, use Group Policy to redirect the My Music profile folder to a local path (such as its default location, or something like "<code>C:\Local\Music</code>". Once this setting is in effect, users won't have to do anything special to get Windows Media Player or iTunes to rip to that local directory.
For whatever my 2 cents is worth, I definitely get both of the arguments being made here.  I've tried to split the difference in my own environment -- I redirect their My Music folders to a local share, and I make it clear that while users are more than welcome to listen to (and store) music on their workstations, this is an activity that we ALLOW, not SUPPORT. Helpdesk tickets regarding music will be openly mocked.
Answer: Pragmatism rules !!

Make a drive with one (or two) top level folders - music and video.
hide the drive so it is not discoverable - tell some users it exists.
forget about it - the users will self regulate.

Why hide it - so a simple audit will not find it. Tell no one. move on...
Your IT dept cannot afford to manage it - your company cannot afford to moderate/police it - even acknowledging its existence is dodgy.
Comment: Even if I hide it there is still one person who operates with such  transparency that they would make sure everyone is aware of the drives existance and would monitor it to make sure that it was healthy and functioning properly, never letting it be forgotten about, me. Given that I can't (and wouldn't) hide this from myself then what I would refer to as the  sweeping it under a rug option, isn't an option.
Answer: When last I had to address this, I took an old PC, some old 250GB HDDs that weren't being used any longer, got the company to spring four hundred quid for a cheap RAID card, and built a terabyte server for "content".  I could have done it with software RAID if i wanted to spend absolutely no money at all.
IT management knew about it in a "plausibly deniable" way, that is, I told them in such a way that noone could prove I told them.
Then I let the users know that it was there.  They were almost all developers, and developers work better when they have their music and cached radio and stupid games and whatever available to hand, nd easily shareable with their friends (not as in "copy this", but as in "listen to this, it's on the media box").  I told them the server wasn't being backed up, but it was RAIDed, so the content probably wouldn't just vanish.  I told them that if I found their streamed content taking up space on the production file servers, I'd summarily delete it and kill them with a stick.
It worked very well, for a time; I got about a third of my main file server back, they got music and video as they pleased, and everyone was happy.  Eventually, senior management found out about it and got quietly pissed because of the liability issues some have raised above, and it was turned off.  Of course, the developers got wind of this (when I told them), and as I had predicted, we ran out of space on the main file server within a week.
There have been notes above regarding the legality of ripping one's own CDs.  I'm no lawyer, but I think there are grounds to suspect as FUD the "oh gods oh gods the server is made of company bits on company property we're all going to die and the riaa will eat our babies eek eek" position that some senior managers take.  There is somewhat less doubt about whether developers will have and share this content at work, so it always seemed to me that a pragmatic accord was better.
Answer: Where did the music come from?  If they're downloading it on their company PC, you have some bigger issues.  If they're plugging in their portable MP3 players, that has to stop: there's no reason why they need to setup iTunes or whatever and have their personal library on their own machines.
Regardless, you'll need to get buy-in/support from senior management, but I've had no issues implementing the following policy on my customer's offices:

For communal areas, reception, etc., 9 times out of 10 they're happy with a radio: they can't listen to anything NSFW, so your local "easy rock" suffices.  We just bought a couple of combo docking station/radios for < $100 at a big box electronics store.
For everyone else, plug in your earphones into your mp3 device: trying to find a room or cubicle that can all agree on music isn't something you can solve with technology.
Setup file screening on your servers: Windows 2003 R2 and 2008 support file screening where you can setup a policy to forbid certain file types from being stored on your file servers.  You could push out a scheduled task on each workstation that deletes audio files but you have to be careful not to blow away legitimate files (like audio dictation, or any sound alerts that may be required for an application).


Test on the properties of two betas?

Question: I have a set of observations. When I do an OLS I get a $\beta$. After I remove some values I also get a $\beta$. Now I want to test if the properties of two betas are the same? Please give me a hint how to do that?
Comment: I think [this](http://stats.stackexchange.com/questions/55501/test-a-significant-difference-between-two-slope-values) is gonna help you. An maybe [this](http://stats.stackexchange.com/questions/59327/how-to-compare-two-regression-slopes-for-one-predictor-on-two-different-outcomes/59331#59331) too.
Answer: What exactly are you trying to find out? One way to approach this would be to look at the problem differently: Simply add a predictor (0 for regular observations, 1 for observations you would remove) and estimate/test the interaction between this new predictor and the other term of interest.

Test on the properties of two betas?


Is $\pi=\sqrt[(p-1)]{p}$ is an uniformizer of $\mathbb{Z}_p[\zeta_p]$?

Question: Let $\mathbb{Q}_p(\zeta_p)$ be the cyclotomic extension of the $p$-adic field $\mathbb{Q}_p$.
Then $\pi=\zeta_p-1$ is an uniformizer of the ring of integer $\mathbb{Z}_p[\zeta_p]$ as $v_p(\zeta_p-1)=\frac{1}{p-1}$.
We also have $\pi=\sqrt[(p-1)]{-p}$ is also an uniformizer which has valuation $\frac{1}{p-1}$.
In fact, any two uniformizer are conjugate to each other. That means, if $pi$ and $\pi'$ be two uniformizer then there is a unit $u \in \mathbb{Z}_p[\zeta_p]^{*}$ such that $$\pi'=u \pi.$$
Thus if $\pi=\sqrt[(p-1)]{-p}$  is an uniformizer, then $\pi=\sqrt[(p-1)]{p}$ should be an uniformizer.
Am I right saying that $\pi=\sqrt[(p-1)]{p}$ is also an uniformizer of $\mathbb{Z}_p[\zeta_p]$ ?
Now suppose $p=2$,
Is at least $\sqrt{-1} \in \mathbb{Q}_2(\zeta_2)$ so that $\pi=\sqrt{2}$ will be an uniformizer of $\mathbb{Z}_2[\zeta_2]$ ?
Is there any modification of $\pi=\sqrt[(p-1)]{-p}$,  so that it becomes uniformizer of $\mathbb{Z}_2[\zeta_2]$ ?
Answer: This will work as long as $\sqrt[p-1]{-1}\in K=\Bbb Q_p(\zeta_p)$. The trouble is, it isn't. The roots of unity of order coprime to $p$
in $K$ are the same as those in $\Bbb Q_p$
and all satisfy $X^{p-1}=1$ (as long as $p$ is odd). So there are no solutions
of $X^{p-1}=-1$ in $K$.