Positive forecasts with hts and combinef in R I am doing forecasts for a lot of time series. These consist of forecasts for specific items in specific regions, where all regions belong to a country. So this is a hierarchial series.    Product 1 - Country 1   product 1 - country 1 - region 1-1 product 1 - country 1 - region 1-2   Product 1 - Country 2    Product 1 - Country 2 - region 2-1  ........  ........   And then there is of course also the "Total" of all.   My matrix cmat contains all bottom level data, i.e. for all products and regions. Every column is a time series. The name of a column is for example: 000214ABCab. The numbers are the product ID, the next 3 letters are the country, and the next two letters are the region. I want forecasts on this level, but also on the product-country level.   First I was struggling with the performance, as I have a lot of data. In the example below I only use a subset of 1000 time series.   subs = cmat[,1:1000] hh = hts(subs, characters = c(maxlength+3,2)) ally = aggts(hh)  #make list of data tables with time series  subs2 = as.data.table(t(ally)) subs2$CODE = unlist(hh$labels) datlist = subs2[, list(list(.SD)),by=CODE]$V1  setattr(datlist, 'names', subs2$CODE) #code is the identifier of products/country/region  s1 = Sys.time() fcast = NULL for(i in 1:nrow(subs2)){     if(i%%1000==0){         print(i)     }     fc = data.table(pmax(forecast(stlf(ts(matrix(datlist[[i]]),frequency=12)),h=12)$mean,0) )     names(fc) = names(datlist)[i]      fcast = rbind(fcast, t(fc)) } s2 = Sys.time()  fcasts = t(fcast) y.f = combinef(fcasts, get_nodes(hh),keep="all")  s3 = Sys.time()   I am also surprised by how fast combinef is. However, I only want positive or zero forecasts. Preferably also integer forecasts. I already do pmax(forecast, 0) in the loop. But by using combinef, I lose this again.   If I do now again pmax then I will also lose the functionality of the combinef, right? So how can I make the forecasts positive? Also, for me it is not necessary to have a "total forecast" at all, but I don't know if I can omit this?
Combinef in R HTS package- constrain to keep forecasts positive? When using the combinef function from Rob Hyndman's very useful  for forecasting hierarchical and grouped time series, there does not seem to be a way to constrain the optimally combined forecasts to be positive- the starting forecasts can be positive, but can go negative through the reconciliation process.  The forecast.gts and forecast.hts functions have an argument to keep forecasts positive, but this does not seem to be an option when using combinef by itself with forecasts obtained by other methods.  Am I correct in this understanding, and if so is there a decent workaround?
Cyclic orbit animation I'm trying to make one object orbit another. But I want it to repeat, rather than stop at 100 frames. It seems there is no option for this. Is there a way to make this happen? So, I'm trying to figure out how to run the scene from the beginning of Lost Mine of Phandelver (5e starter set) where the party is ambushed by goblins and I'm really confused as to how Passive Wisdom (Perception) works.  The included rulebook mentions on page 6 :     When you hide, there’s a chance someone will notice you even if they aren’t searching. To determine whether such a creature notices you, the DM compares your Dexterity (Stealth) check with that creature’s passive Wisdom (Perception) score, which equals 10 + the creature’s Wisdom modifier, as well as any other bonuses or penalties. If the creature has advantage, add 5. For disadvantage, subtract 5. For example, if a 1st-level character (with a proficiency bonus of +2) has a Wisdom of 15 (a +2 modifier) and proficiency in Perception, he or she has a passive Wisdom (Perception) of 14.   So the party is being ambushed by goblins and at that point the DM guide mentions on page 7 :     Check to see who, if anyone, is surprised. [...] Make a Dexterity (Stealth) check for the goblins, rolling once for all of them. Roll a d20, add the goblins' Stealth skill modifier (+6) to the roll and compare the result to the characters' Passive Wisdom (Perception) scores.   So to me this reads like I should roll 1d20+6 for the goblins and compare that to the static Passive Wisdom (Perception) score on the character sheet of a PC. The PCs don't get to roll anything as they're not actively looking for enemies, even though they are investigating the dead horses.  I would also think that if the characters were supposed to roll, the DM guide would clearly instruct so, given that this is the starter set.  However, watching  at around 8:01 I notice that the DM is explicitly asking his party for a perception roll. And the same thing happens on a couple of other videos where people are running the Lost Mine adventure. The DM always requests a roll.  So what gives? Shall I take it that the DMs ask for the roll because they consider the party to be actively seeking for hidden foes? Or am I just misreading the rulebook and the DM guide? Show if a user is online, idle, or offline on their account page? I want to display the status of the user on the account page. I added the following code in the theme I am using. It works, but users are never displayed offline. Why? What is wrong in the code? user.html.twig &lt;div class=&quot;bs-field-status&quot;&gt;   {% if status == 'Online' %}     &lt;i class=&quot;user-online fa fa-circle fa-lg&quot;&gt;&lt;/i&gt; Online   {% elseif status == 'Absent' %}     &lt;i class=&quot;user-absent fa fa-circle fa-lg&quot;&gt;&lt;/i&gt; Absent   {% else %}     &lt;i class=&quot;user-offline fa fa-circle fa-lg&quot;&gt;&lt;/i&gt; Offline   {% endif %} &lt;/div&gt;  bootstrap_subtheme_front_office.theme &lt;?php /**  * @file  * Bootstrap sub-theme.  *  * Place your custom PHP code in this file.  */  use Drupal\Core\Database\Database;  /**  * Implements hook_entity_presave().  */ function bootstrap_subtheme_front_office_preprocess_user(&amp;$variables) {   // get user object   $user = $variables['elements']['#user'];   //- The user has logged in at least once   if ($user-&gt;getLastLoginTime()) {     if (account_is_logged_in_less_then_thirty_minutes($user-&gt;id())) {       $status = 'Online';     }     else {       $status = 'Absent';     }   }   else {     $status = 'Offline';   }   $variables['status'] = $status; }  /**  * @param $uid  *  * @return bool  */ function account_is_logged_in_less_then_thirty_minutes($uid) {   $connection = Database::getConnection();   $query = $connection-&gt;select('sessions', 'sessions')     -&gt;fields('sessions', ['sid', 'uid', 'timestamp'])     -&gt;condition('sessions.uid', $uid, '=')     //- chef if the user was online in 30 minutes (60 * 30)     -&gt;condition('sessions.timestamp', \Drupal::time()         -&gt;getRequestTime() - (60 * 30), '&gt;')     -&gt;execute();   //- Get result.   $results = $query-&gt;fetchAll(\PDO::FETCH_OBJ);   return (count($results) &gt; 0) ? TRUE : FALSE; } Is the function Riemann integrable? If yes, obtain the value of $\int_0^1f(x) \ dx$      $f(x) = \begin{cases} \frac {1}{n},  &amp; \frac{1}{n+1}&lt;x\le\frac{1}{n}\\ 0, &amp; x=0 \end{cases}$   My attempt  $f$ is bounded and monotonically increasing on $[0,1]$. Also, $f$ has infinite discontinuities but only one limit point. Therefore $f$ is Riemann integrable. Now, to calculate the integration  $\int_0^1f(x) \ dx=\int_{1/2}^{1}1 \ dx + \int_{1/3}^{1/2}\frac{1}{2} \ dx + \int_{1/4}^{1/3}\frac{1}{3} \ dx+...$  $=\sum_{n=1}^\infty \frac{1}{n^2}-\frac{1}{n}+\frac{1}{n+1}$  How do I proceed from here? How do I calculate these summations? I know $\sum \frac{1}{n}$ is $\log 2$, but not the other two summations. Recurrence Inequality Define sequence ${a_n}$ as follows: $a_1 = \frac {1}{2}, 2ka_k = (2k-3)a_{k-1}.$  Show that for any natural number $n, \sum_{k=1}^{n} a_k &lt;1$ (No calculus is allowed).  I'm really just stuck on the right way to approach this. It is sufficient to show that $\sum_{k=1}^{\infty} a_k &lt;1,$ but this isn't a series I am familiar with. I tried defining a partial sum series $b_n$ such that $b_n = \sum_{k=n}^{\infty} a_k,$ but that didn't help to find a non-trivial relationship. So I was playing around on Area 51 hoping for further news on the private beta for ebooks, and noticed that my avatar (a hand) was missing. Also the Area 51 has the old toolbar. So I looked at the flair page. The network flair has my hand, the Area 51 flair has a quilt. OK, so time to upload a new image, and WordPress -- WordPress -- I don't want to login to WordPress. Any idea what's up with that?  The following questions did not help, and have different causes and symptoms: Recursive feature elimination and one-hot & dummy encoding? When using RFE in linear regression and logistic regression, do we one-hot encode the features (K levels and K dummy features) or dummy-encode the features (K levels and K-1 dummy features leaving one out).   As per a comment by @Matthew Drury in an answer (URL below), one hot encoding is applied for a regularized linear model and for unregularized linear model dummy encoding. My doubt is what type of encoding when using RFE without any L1/L2 penalties.    My understanding is since in RFE some features gets eliminated so if for a categorical variable with say 4 levels we do dummy encoding and have 3 features/levels in model &amp; RFE eliminated 1, we will only have 2 features/levels left and the interpretation of its coefficient would not make sense in absence of the one level which was left out as reference.  Whereas if we have done one-hot encoding and RFE considers 2 features as important and eliminates other 2 then we can very well judge/interpret the coefficients or importance of 2 features RFE keeps.  So question which type of encoding is needed to be done when using RFE with linear and logistic regression? Change hanging indent in description list I'm trying to get a description's list hanging indent to lie flush with the first line of text.  I have a description list such as the following:  \begin{description}  \item[Label the first] Lorem ipsum dolor sit amet, consectetur adipisicing                         elit, sed do eiusmod tempor incididunt ut labore et                         dolore magna aliqua.  \item[The longest label] Ut enim ad minim veniam, quis nostrud exercitation                           ullamco laboris nisi ut aliquip ex ea commodo                           consequat.  \item[Shrtlbl] Duis aute irure dolor in reprehenderit in voluptate velit esse                 cillum dolore eu fugiat nulla pariatur. \end{description}   This produces the following output:    I would like to have each paragraph indented so that the following lines are flush with the first letter of the list item's text, the way it's laid out in my TeX.  For instance, the "s" of "sectetur" should be right under the "L" of "Lorem".  I've tried looking through the documentation of , but I can't seem to find a good option.  I tried specifying [leftmargin=3cm, style=sameline], but this results in the following:    This isn't quite right: I'm trying to get each item lined up differently, so that the "L" of "Lorem" is not necessarily flush with the "U" of "Ut" or the "D" of "Duis".  Does anybody know a good way to do this? On a series involving harmonic numbers In the digital age of photography, we can see a range of digital camera sensors sizes in use, from 1/3.2" in small phones, up to Medium format sensors that are 53.4 x 40.0mm in size or more!  Why has no company endevoured to produce a sensor that can be considered to be large format (50mm X 80mm or larger)? Do such camera sensors exist in non-consumer products? There are several spells that require the target to be "humanoid" such as , , etc.  However, if the target is Polymorphed after that spell has been successful, then what happens?  Does the change in form to Beast end the spell effects? Does it suppress the spell until the correct form returns? Does it do something else? How to identify if a webpage is being loaded inside an iframe or directly into the browser window? I am writing an iframe based facebook app. Now I want to use the same html page to render the normal website as well as the canvas page within facebook. I want to know if I can determine whether the page has been loaded inside the iframe or directly in the browser? Is there a rule for pronouncing “th” at the beginning of a word? Consider the th in thistle versus the th in this: the former is unvoiced, while the latter is voiced.  Is there a rule or reason for the differences? Render looks "brighter" than in viewport preview Somehow my viewport preview shows darker result than what comes out in render (check out in corner of the pic)  World strength is at zero and ambient occlusion is also disabled.  Floor is using bump and roughness from picture. Wall has adaptive subdivision surface  modifier.  All lit using planes with emission shaders.  I wanted to play around with render layers and maybe I screw some setting there, hope this helps. Are there any   editors for ? Perhaps something similar to    but for PGF/TikZ?   If there is no WYSIWYG editor for this tandem, is there one perhaps that allows the user to easily generate PGF/TikZ templates?  Alternatively, how can I most easily generate PFG/TikZ code from a visual conception? Do people mostly code their PGF/TikZ graphics from scratch? How can I programmatically delete a line from a Word document using c#? One post with multiple questions or multiple posts? I want to ask several questions about the same problem domain but each question is independent from the others. Should I put all the questions in a single post or should I split them and send multiple posts? Which metric to use to evaluate highly imbalance classification model performance My professor proved that the kernel is a normal subgroup under a homomorphism f by saying. Let $h\in H$  by applying f to it  $f(ghg^{-1})=f(g)f(h)f(g)^{-1}=e $  My question is how is this a proof that the kernel is normal. What is the reason we apply f to it ? By applying f dont we just prove that $f(ghg^{-1})$ is normal ? What are the meaning and possible origin of "word!" and "word up"? Several times, I have had conversations, all over instant messenger, finish with "word" or "Word up G".  As it ends a conversation, I am guessing it is like "goodbye".  My question is what is the meaning of "word" and "word up g"? Also, what is the origin?  I am more interested in the meaning as that will help with understanding its usage.