How to display complex pricing for mentorship platform

Question: I have an issue with my UI. I run a mentorship platform that charges $19.99/month and then users can book calls with mentors. Some mentors do not charge an additional fee so the cost is $0/call. However, when the user goes to the landing page, they see $0/call and thing it's fake or not aware of the membership fee. How can I fix my UI so that the membership fee is clearer to users? I don't want to deceive them. Here's the page - https://www.mentordial.com/
Comment: Why don't you write "Free for members" in this case? ux.stackexchange is a question site about user experience and does not deal with technical implementation. So if you have a problems with that, you might have more success at stackoverflow.
Comment: There's something wrong with how this model works. Users don't like added or hidden fees to subscriptions. Why not have tiers? Like Regular member subscription starting at $19.99/month for $0 mentors, Pro member subscription starting at $24.99 for the more expensive mentors.
Answer: One possible solution could be to clearly display the membership fee on the landing page, either in the main call-to-action for the platform or in a prominent location nearby. Saying something like "$19.99/month + applicable per-call fees (from $0)". This could help to ensure that users are aware of the $19.99/month fee and the potential of paying nothing per call, before they begin interacting with the platform and booking calls with mentors.
Another approach could be to include information about the membership fee and the cost of individual calls in the booking flow, before the user is asked to confirm their booking or using difference sections in the landing-page flow. Something like: $19.99/month as the main price, then individual sections for free calls and calls that cost an additional fee. This would allow you to provide more detailed information about the fees and charges associated with using the platform, and give users the opportunity to review and understand the costs before committing to a booking.
Additionally, you could consider adding a disclaimer or notice on the landing page that clarifies the membership fee and the cost of individual calls. This could help to prevent users from misunderstanding the pricing and avoid any potential issues with deceptive advertising. A sub-header under your pricing section would be a good implementation.
Overall, the key is to be clear and transparent.


Are Android geofences surviving a reboot?

Question: is the system persisting them or do I have to add them again them after reboot? I have not found anything about that in the documentation at https://developer.android.com/training/location/geofencing.html
Comment: Please see [my answer to a similar question](https://stackoverflow.com/a/50869301/766755) for a complete run down of all of the situations in which you need to re-register geofences.
Answer: Geofences will not persist on reboot.
You have to listen for BOOT_COMPLETED action and add geofences again.
Note: If your app installed on external storage(SD card), you will never receive Boot Complete action. So you have to specify android:installLocation="internalOnly" in the manifest tag.
This is because, android device will broadcast BOOT_COMPLETED action before setting up the external storage.
Comment: When ever you get triggered from Geofence, you'll get id of that particular geofence. But in real time we have lots of information instead of just an id. SharedPreferences is just like storage to save ousr geofences information like id, messages, lat,lng,and few more values associated with it.
Comment: Hi, in this http://developer.android.com/training/location/geofencing.html tutorial i really don't understand the usage of `SharedPreferences` because they are never used in term of accessing data. Do you know why Presistent Storage is used.
Comment: Thanks Sundeep that's sound logical. I'm already storing Geofence data in the database. I was just confused and assuming that may be GeoFence  Api use the data that have been saved in the `SharedPreferences`.
Comment: The default is android:installLocation="internalOnly" so it doesn't need to be explicitly declared in your manifest, but it's not a bad idea to do so.
Answer: I haven't found any documentation confirming this, but my own experiments have shown that they are not persisted across reboots.
My setup was as follows:

Run application
Application sets up various geofences on first launch only as NEVER_EXPIRE
Exit application
Use phone in regions marked by fences
Confirm fences trigger pending intents which are sent to IntentService
Leave region
Reboot phone
Re-enter region
Pending intent does not get sent to IntentService

If anyone has more information on this from someone at Google please comment!
Comment: You have to add the geofences again on reboot. As the documentation says that geofences are removed on reboot.
Answer: Which data do you want to persist? Is it the geofence region in your device or the geofence region stored by Google Play Service Location API ?
I believe the device need to register a region (defined by its latitude, longitude and radius) to Google Play Service (via LocationClient). You also need to provide expiration time, transition type you want to be notified, and the Intent from which you will be notified.
This region will be stored (remotely) not in your App. When it pass its expiration time, Google Play Service will automatically remove it. You can also set it as NEVER_EXPIRE.
If the region is not expired yet, Google Play Service will notify your App (via intent that you send when calling addGeofences).
The source of the region (lat, long, radius) is up to your implementation.
Comment: The question asks whether the system (I assume he means Google Play Services) persists Geofences after a reboot, regardless of expiration time, but you don't answer this.
Comment: Look at these documentations:  http://developer.android.com/reference/com/google/android/gms/location/Geofence.Builder.html and [http://developer.android.com/reference/com/google/android/gms/location/LocationClient.html#addGeofences(java.util.List, android.app.PendingIntent, com.google.android.gms.location.LocationClient.OnAddGeofencesResultListener)]
Comment: I just took another look at the GeofencingDetection sample app.
Comment: I just took another look at the GeofencingDetection sample app. It does not need INTERNET permission, only ACCESS_FINE_LOCATION. So the geofencing region most likely stored locally. But, i did not get notified for any transitions when Wifi and 3G are disabled. I am assuming with GPS is the most accurate one, i should get notified for transitions.


Are any pairs of these four structural models nested in another?

Question:
Are any pairs of these four structural models nested in another?  I think the second-order single factor model is nested in the second-order two factor model (second order single factor model is when covariance between the two second order factors in second-order two factor model is 1) but I can't determine whether other pairs are nested or not.
Comment: Is this a question from a course or textbook? If so, please add the `[self-study]`
tag & read its [wiki](http://stats.stackexchange.com/tags/self-study/info).
Comment: It is not from a course or textbook.  It is from my own research project.
Answer: a) is the saturated model. All models are nested within the saturated model. That's the basis of the chi-square test. You're testing against the saturated model, which has 0 df and 0 chi-square.
c) and d) are equivalent models. d) isn't identified without a constraint on the loadings, so there is only one parameter to estimate.
All that we are left with is the relationship between b), and c)/d). These are nested, but not (quite) in the usual way. Constraing the correlation to 1 in model b) gives you nested models, but you can't test these nested models using the chi-square test, because the parameter is on the boundary of the permitted space. In a sense it's a one-tailed test - when you relax the correlation in model c) we know that the parameter will change, but it must get smaller, not larger. The nested model chi-square test assumes that the parameter can change in any direction. It's surprisingly tricky. Here's a paper: http://psycnet.apa.org/?&fa=main.doiLanding&doi=10.1037/1082-989X.13.2.150
Comment: Thank you for your feedback!  What I am particularly interested is whether or not I can do a chi-square test between a and each of b, c, d.  If a is the saturated model and all three other models are nested within a, I can do  chi-square tests between a & b, a & c, and a & d, correct?

I would greatly appreciate your feedback on this. Thank you very much!
Comment: Yes, you can do those tests.
Answer: I have taken the liberty of editing the figure to add labels a)-d) and re-uploading it within the question.
Three definitions of nesting, in SEM are:

"whenever one model has all the same free parameters as does a second model but also has other free parameters not shared by the other model. In other words, the two models are equivalent except for a subset of free parameters in one model that are fixed or constrained in the other (Maruyama, 1998, p. 235). ).
Loehlin (1992) defines nested as being when "the model with the smaller number of free variables can be obtained from the model with the larger number of free variables by fixing one or more of the latter" (p. 67).
Kline (2011) defines nested as "if one is a proper subset of the other. For example, if a free parameter is dropped from model A ... to form B ... model B is nested in model A" (p. 214).

You are correct that model b) is nested in model c). The one-factor model is a restricted version of the two-factor model. To see this, consider what happens if we fix the correlation between the two factors in model c) to 1. In this case the 2 factors will be identical which is the same as replacing them both with a single factor.
By similar reasoning, we can also see that d) is nested in c) if we fixed both paths from Fatique in model d) to 1.
Loehlin, J.C., (1992), Latent Variable Models: An introduction to factor, path and structural analysis, 2nd Ed, Hillsdale, New Jersey
Kline, R.B. (2011), Principles and Practice of Structural Equation Modeling, 3rd Ed, Guildford Press
Maruyama, G. (1998), Basics of Structural Equation Modeling. Thousand Oaks CA: Sage.


Comparing multiple regression coefficients

Question: Qualifier: I am not a statistician.
I have 4 data sets and want to determine whether the 4 regression coefficients obtained are statistically significantly different. I compared each pair of coefficients separately (6 hypotheses) with t-tests and found no significant difference (t values ~1 for 6 d.f.). Does this support my null hypothesis (there is no significant difference in the coefficients) or do I need to make a correction because I am comparing multiple hypotheses. That is, if I made a correction would it only make the level of significance even lower?
Comment: If the form of the regression is the same for all 4 data sets, you could have more power to detect differences in regression coefficients among data sets by analyzing all your data together in a single regression, including an indicator variable for the data set, and seeing if there is a significant interaction between the data-set variable and the variable(s) whose regression coefficient(s) you are examining. Editing your question to provide more details about your study might help.
Comment: Another advantage of the suggestion made by @EdM is that you get a single, more powerful test.
Answer: Answering briefly on this.
Using a P-value in Null Hypothesis Significance Testing (NHST) does not allow you to draw conclusions about your null hypothesis, just that you cannot reject it at the observed data. This is a common misconception. See e.g. Nickerson, R. S. (2000). Null hypothesis significance testing: A review of an old and continuing controversy. Psychological Methods, 5, 241-301.
Instead, you could calculate confidence intervals to get an idea about the population estimate, see for example Abserson 2002 - or use Bayesian statistics, but that is another chapter.
You are right that your P-values will be even higher when correction for multiple comparisons is performed.
Comment: I think you mean a high P-value.  If the P-value is sufficiently low common practice is to to reject the null hypothesis.
Comment: Thanks for the addition, I was looking for a better way to say this. Incorporated an edit!


Does a countable set generate a countable group?

Question: Let $G$ be a group and let $A\subseteq G$ be infinite. Do $A$ and $\left<  A\right> $ have the same cardinality?
Answer: Yes. Any element of $\langle A\rangle$ is a "word" in the alphabet $A\cup\{a^{-1}\mid a\in A\}$, which is again a set of size $|A|$. Any word is a finite string of symbols from this alphabet (but of course, different words may give the same element of $\langle A\rangle$), so $\langle A\rangle$ has size at most $|A|^{<\omega}$, which again is $|A|$. This gives $|A|$ as an upper bound. Of course, every element of $A$ is in this group, so it has size at least $|A|$, and equality follows.
This uses (some amount of) the axiom of choice, though. Without it, we cannot prove for an arbitrary infinite set $A$ that $|A|^{<\omega}=|A|$. Choice is not needed to prove this equality in concrete cases, such as if $|A|=|\mathbb N|$ or $|A|=|\mathbb R|$. There is however another, somewhat subtler, use of choice in the proof: Many different words may be equal, which is why a priori the number of words is just an upper bound, because this shows that $\langle A\rangle$ is a quotient of the set of words, under some equivalence relation. Without choice, a quotient of a set may even be larger than the set. I point this out here. (In that answer I link to a nice talk you may enjoy on this issue, by Mike Oliver.)
Comment: This is a very nice answer.
Answer: Let me give a proof of the statement in the title which has a different flavour from the other proofs. It use more group theory than the other answers (most notable, it uses the fact that subgroups of free groups are free). It also uses choice, which is required to get that (non-finitely generated) subgroups of free groups are free.

Let $G$ be a countably-generated group, $G=\langle A\rangle$. We want to show that $G$ is countable. (I shall use "countable" to mean "infinite and countable", but it is difficult not to see how this result implies that finitely generated groups are countable also.)
To prove that $G$ is countable it suffices to prove that the free group on the generators $A$ is countable (can you see why this is?). This is a well-known result, and I shall give a relatively full proof. For more details, the book Combinatorial group theory by Magnus Karrass and Solitar will provide better detail/background. (There also exist topological proofs, but I do not know any good the references. Perhaps John Meier's book, or Pierre de la Harpe's?).
Write $F_{\infty}$ then for the free group on countably many generators.
Let $\langle a, b\rangle$ generate the free group on two generators.
Proposition: $H:=\langle a^{-i}ba^i, i\in\mathbb{Z}\rangle$ is free and infinitely generated, $H\cong F_{\infty}$.
This clearly proves the theorem.
Proof: As subgroups of free groups are free, $H$ is free. It therefore suffices to prove that the set $\{a^{-i}ba^i\}$ is a minimal generating set.
It is an important fact about free groups that if $\langle S\rangle=F$ and $F$ is $n$-generated then there exists an $n$-element subset of $S$ which generates $F$. Thus, if we can show that every element of $\{a^{-i}ba^i\}$ is needed to generate $H$ then we are done.
We shall write $W(x, y)$ to mean a word in $x$ and $y$. For example, if $W(x, y)=x^2y^2$ then $W(a^{-1}ba, a^{-2}ba^2)=(a^{-1}ba)^2(a^{-2}ba^2)^2=(a^{-1}b^2a)(a^{-2}b^2a^2)=a^{-1}b^2a^{-1}b^2a^2$.
The trick is to count the number of $b$-terms. Define the $b$-length of a word over $\{a^{-i}ba^i\}$ to be the number of $b$-terms in the word. For example, $b^2a^{-1}b^{-1}a$ has $b$-length $3$. You can think of it as taking the sum of the absolute values of the $b$-exponents: $|2|+|-1|=2+1=3$.
To see that every element of $\{a^{-i}ba^i\}$ is needed, suppose $g:=a^{-j}ba^j$ is not needed. However, $g$ is in $H$, so $g\in\langle a^{-i}ba^i; i\in\mathbb{N}\setminus\{j\} \rangle$=H. Note that the $b$-length of $g$ is one, while in general the $b$-length of $W(\{a^{-i}ba^i\})$ is simply the length of the word $W$. Thus, as $g$ has $b$-length one it is not in $\langle a^{-i}ba^i; i\in\mathbb{N}\setminus\{j\} \rangle$, a contradiction.
Comment: Note that this does use choice! It's required for the statement that subgroups of free groups are free.
Comment: @tolUene Thanks for pointing this out! I've corrected it now.
Answer: I rarely can be sure that my proofs are correct. However I can't say this trial is not correct:
Let
$$C=A\cup A^{-1}\cup\{1\}$$
then
$$\left< A\right>=\bigcup_{n\in \Bbb N}C^n$$
$$\Rightarrow|\left<A\right>|\le|\Bbb N||C|=|\Bbb N||A|=|A|$$
$$\Rightarrow |\left<A\right>|=|A|$$
Comment: I am not sure what you mean by $|\mathbb N||C^n|$ in the previous to last line, since this depends on $n$ now while nothing else does. Maybe you meant $|\mathbb N|\sup_n|C^n|$, from which the argument can proceed now as written.
Comment: thanks. $n$ is not needed. because $C$ is infinite, $C\times C\times C\times...\times C$ has the same size as $C$ (as $A$). So $C^n=CC...C$ has size $|C|$ too. now $sup_n |C^n|=sup_n |C|=|C|$. I think at most a countable version of Axiom of Choice is used.


what does RESTORE_TRANSACTIONS request in android in app billing return?

Question: Hi I just want to know whether the RESTORE_TRANSACTIONS request for android in app billing returns all the purchased items for all the apps the user has bought or just the ones from that specific application?
Answer: Just the purchases for that specific app.  It raises a PURCHASE_STATE_CHANGED event just as if the user had made a new in-app purchase in your app.  If the user makes a purchase in another app, your app won't be notified either.  Same logic.


Black box test plan to see whether a value is hard coded

Question: I need to make a manual test plan (black box testing) to see whether a value is hard coded in a drop down list (its' the acceptance criteria).
Can anybody give me any suggestions on that?
Thanks in advance
Saj
Answer: Until you will describe your application a bit more is hard to say something.
If you can using adming priviliges add/remove values on the dropdown then test is simple.
However if not, if any functionality do not allow you to change values on the DDL why test it then?
The requirment should be descoped as part of Test Report abrevation from Test Plan with given resonable why it is not tested, why it cannot be tested in black box methodology and approved by Product Owner or bussines users.
Answer: if the data of the drop down list is taken from data base u can change the data from the data base and check the hard code issue or else
As per the unique id the data is populated in the drop down u can change that unique id and identify is there any hard cord.
Answer: There at at least three options:

If you have possibility to change values in that list by making something in the application just try it
If not - perhaps you have possibility to add something to the list
If not - maybe you have to the database and can change the data
If not - ask someone - maybe administrator can make some changes in database for a short time - just to make some test.

Take into account that changing in application and in database may not look the same - when you change in application everything should work, changing in database may require some other actions (triggers, procedures) or time (some things may be refreshed during night or in other schedule).


How can I check the PID of a X-server in another virtual terminal?

Question: I am trying to open a program in a naked X-server on a different virtual terminal.
I am using ubuntu 9.10.
The command I'm using is this.
openvt -f -s -- `X :2 & '/path/to/program' -display :2`;

Now, when the program shuts down I want the X-server to be killed as well.
So my question is this: How can I save the PID of the new X-server (X :2) to then later kill it?
It is going to be used in a normal shell script.
Answer: In bash, $! is the  process ID of the most recently executed back-ground (asynchronous) command.
Sombrero:Documents polleyj$ xterm &
[1] 41316
Sombrero:Documents polleyj$ KILLPID=$!
Sombrero:Documents polleyj$ echo $KILLPID
41316
Sombrero:Documents polleyj$ kill $KILLPID
Sombrero:Documents polleyj$
[1]+  Killed                  xterm
Sombrero:Documents polleyj$

Answer: Instead of using openvt, you could use Xephyr to open a nested X sesssion. That would make it easier to manage it afterwards.
Use sudo apt-get install xserver-xephyr to install it.
Couple that with using $! to grab the process ID as James suggested.
Answer: What I did was to store pgrep -f 'X :2' in a variable mypid.
Then I simply killed $mypid..


Can a stray kitten eat eggs?

Question: I have many stray cats around, and there's this stray kitten I am feeding whenever I can. Is it safe to feed her boiled eggs a few times a week?
Answer: Yes you can feed eggs to cats but try to limit the amount to two eggs per week.
link https://www.catster.com/lifestyle/cat-health-can-cats-eat-eggs-ask-a-vet-food-tips
If you feed eggs you need to be sure they are boiled to kill the bacteria comonly found in eggs.
Raw eggs contain a substanse that will stop b-vitamins beeing absorbed by cats and dogs so they might get a lack of b-vitamins if you feed a lot of raw eggs(the risk for this is low)if the eggs are boiled this is not a problem.
Only use egg as a suplement you need to feed the kitten other types of food too.
There is a risk the kitten might get an upset stomach when you feed eggs atleast in the beginning so start slow.
Answer: I would advice against feeding the kitten, not because it might not tolerate the food very well, but because you teach it to beg or wait to be fed instead of seeking it's own food. You take over the responsibility for this cat as if you had adopted it.

What happens to the cat if you cannot feed it anymore, maybe because you moved away or for medical reasons? The cat will suffer from hunger because it never had to hunt for all it's food before.
Other cats might notice the food. Before you know it, you're feeding a second cat, then a third and so forth. If you don't feed all of them, they might start fighting over the food.
A well-fed cat will have babies. These babies will be strays, just like their mother. If you feed them, they will have more babies... You actually want to help a stray cat, but in the end you let more stray cats be born who will suffer.

You see, it's actually best not to give stray cats any food at all. If you want to, you can give the kitten some small treats, but not enough food to feed it for a day.
The best solution of all would be to donate money to an animal welfare organization that spayes and neuters stray cats so they cannot give birth anymore.
Comment: While I somewhat agree with your point about taking over responsibility, that kinda deviates from the original question. OP wasn't asking whether it's moral to feed stray cats. It was whether a kitten who's in the wild can eat eggs and not get sick.
Comment: I live in middle-east and in my neighborhood the green bin are taken out every morning, strays find food there whenever. Idk hunting, I saw stray cat family eating roaches, so not much facility. They beg for food when they are hungry, the ones in my building is cat family she never meows alot for food, the kittens also quiet, they appreciate the handouts when I'm around. Neighbors sometime leave food out too but it's not cat-friendly, like pancakes or something, they don't eat. In very hot climate a little food and some water go along way for the stray city cats. Thank you for sincere advice

Can a stray kitten eat eggs?


VAR for Non-Stationary Data?

Question: I have property return variables and economic variables  in natural log form, which are non-stationary in level and stationary in first differences, but are not cointegrated. To my understanding, this rules out the use of the VECM, and so should I estimate the VAR in levels, first differences or something else? Thanks!
Answer: Your choice should be VAR in first differences.
If you do VAR in levels, you will have left-hand-side variables diverging from right-hand-side variables, which is bad (coefficient estimates will be ill-behaved and not really meaningful). You cannot do VECM since there is no stationary linear combination of variables in levels to put in the model. VAR in first differences is just like VECM but without the stationary combination of variables in levels. Since differenced variables are stationary, you can put them in a VAR and expect well-behaved coefficient estimators.
Comment: Thanks Richard, what about if the variables are in fact non-stationary in levels, stationary in first differences but also cointegrated? After adding more variables, my data is now cointegrated. I believe this would prompt the use of the VECM, however would it still be appropriate to use the VAR in first differences? VAR in first differences gives me better results in the Impulse Response Functions
Comment: @James, If they are I(1) and cointegrated, you would use VECM. It would not be appropriate to use VAR in first differences because it would be misspecified, namely, affected by omitted variable bias (missing the stationary combination of variables in levels, i.e. the error-correction term). This has been discussed in some previous posts on cointegration, VECM and VAR.

VAR for Non-Stationary Data?


Turning off desktop integration in firefox

Question: I used to be able to turn off the desktop integration in firefox by going to the general settings and unclicking the box that says "Prompt integration options." But I just reinstalled 14.04 on a new laptop (T420) and the firefox settings have changed. That option no longer appears anywhere, so I'm constantly getting these prompts asking if I want to install this or that website.
How can I shut this off?
Answer: Cancel that, I was able to turn it off using the Unity Tweak tool.


Can a GFCI combo and a switch be independently connected to a light and a fan using 14/3 wire?

Question: The box on the left in the diagram is a dimmer switch and the box on the right is a GFCI combo switch. The ground wiring is absent from the diagram. How can this wiring be completed to connect the fan and light independently?
Comment: Do you want GFCI protection for the light and fan?  Why are there three terminals on the dimmer?  If the dimmer is a 3-way, which terminal is common (black)?
Answer: With GFCI Protection of Devices
If you want to provide GFCI protection of the fixture, you'd feed the switches from the LOAD side of the GFCI device.

Without GFCI Protection of Devices
If you don't want to provide GFCI protection to the devices, you'd feed the switches from the incoming feeder.

NOTE: I've labeled one of the dimmer terminals as "C" (common), as it looks like you might have a 3-way dimmer. In this case the "C" terminal will be an odd color (likely black), while the other two will be the same color (brass). Unless of course the third terminal in your diagram is green (ground), in which case you should ignore this note and connect the grounding conductor to the green terminal.


Decrypting 3-DES with DES

Question: I have a ciphertext, that is encrypted using 3-DES.
I wondered, why is it possible to decrypt it using 1-DES.
1-DES key is shorter than 3-DES that is used. How does it work like that?
Comment: Your question is very unclear. 3DES is a composition of 3 DES operations. why would it not be possible to decrypt by performing those operations separately?
Comment: Could you have a look at the given answer and indicate if it answers your question? You can indicate this by accepting the answer, or by leaving a comment if your question has not been answered by it.
Answer: Triple DES (Wikipedia) is simply DES used three times, usually ciphertext = E(k3,D(k2,E(k1,plaintext))), although I have seen other arrangements such as E(k1,E(k2,E(K3,plaintext).  So just split the 3-DES key into three (sometimes two) parts k1, k2, and k3, and run 1-DES three times, using the appropriate key each time.
So, for example, if my 3-DES key is aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbcccccccccccccccc (hex), then the 1-DES keys would typically be aaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbb, and cccccccccccccccc, with the system documentation letting us know which one is k1, k2, and k3.  So assuming we encrypted using ciphertext = E(k3,D(k2,E(k1,plaintext))), then we can decrypt using 1-DES as follows:

temp1 = D(k3,ciphertext)
temp2 = E(k2,temp1)
plaintext = D(k1,temp2)

And of course if we are using something like Cipher Block Chaining, the whole sequence above would be considered one block cipher decryption.
Edit:
1. If only two keys are used (the ABA mentioned in the comments), the general approach is the same, except instead of having a separate k3, we just set k3=k1 and do the same as before.

Just to be clear, E(k,p) is enciphering the plaintext p using the key k, and D(k,c) is decrypting the ciphertext c using the key k.  For this example, we are using plain DES for both E() and D().

Decrypting 3-DES with DES


Which is better self-destruct or upgradable smart contract?

Question: I have a smart contract which I might want to modify in future. Should I use self-destruct to destruct that contract and then deploy a new one?
Or, should I make that contract upgradable to make changes in future?
Which one is most feasible solution in terms of cost and other factors?
Comment: Self-destruct will remove the contract and you have to deploy a new contract and your users have to know the new address. You can write an upgradable smart contract that will route calls to the new contract without creating any problems to users. It all up to what exactly your requirement. Implementing self-destruct is much easier as compared to writing upgradable smart contracts.
Answer: The cost is theoretically the same. It's really up to your own preference if you want the old contract to continue existing or not.
One benefit to using an upgrade-able contract is that it can store a reference to the new contract which could make it easier for someone to find the newer contract.
One downside to using an upgrade-able contract is that people may continue trying to use the old contract (which you may or may not have disabled functionality for) and that could be quite frustrating as a user.
Comment: You can keep the old contract running and delegate the calls to the new contract
Answer: This is how the contract updation would work if you used selfdestruct:

Deploy a new version of the contract.
Manually migrate all state from the old one contract to the new one (which can be very expensive in terms of gas fees!)
Update all contracts that interacted with the old contract to use the address of the new one
Reach out to all your users and convince them to start using the new deployment (and handle both contracts being used simultaneously, as users are slow to migrate)
selfdestruct the old contract.

But if you use upgradable contracts, you can upgrade your contracts, keeping(preserving) the contract state (storage & balance) while keeping the
same contract address.
So, in this sense, I think using selfdestruct approach WILL COST YOU MUCH MORE than using upgradable contracts.
In case you would like to know how upgradable contracts work, and how you can wtite one easily, you can check out this post on smart contract versioning.
Answer: selfdestruct will remove all storage from the state, which isn't ideal if you might ever need it in future.
Upgradeable contracts can be established with a version flag and a pointer to the address of any new contracts after they are deprecated - you could also include a 'pause' function in your contract (with an onlyOwner modifier to make sure nobody else pauses it) so once it has been deprecated the functions within the original contract no longer work.
We use a contract register on our private chain to keep an eye on the latest version of each contract - when updates are made the original contract is paused, its latestVersion bool is set to false and successorAddress is added to their register mapping entry to point towards the correct new version. Our contract register is also upgradeable, for additional resilience :)
There is plenty of in-depth coverage on this topic in this question
Answer: if you selfdestruct your contract, its bytecode will be deleted and you no longer can interact with the contract.
In upgradable proxy, you have proxy contract and implementation contracts.
 user => Proxy => ImplementationContract

in this design, the state is stored inside the Proxy contract. If in the future you deploy the next version of your contract, this new contract can still access the previous state. that is why upgradable contracts are designed for: you can change the logic and yet still access to the previous transactions or any other state variables.


about H$_\alpha$ and H$_\beta$ lines in astronomical objects' spectra

Question: Generally there may be some line ratio between the two lines.
If  H$\alpha$ is strong, it is quite possible we can see H$_\beta$ too.
Is it possible we can see H$_\beta$, but can not see H$_\alpha$? In what kind of environments can it happen?
Answer: In a normal stellar atmosphere, where the temperature decreases with height, I think this is not possible.
H-alpha absorption arises from the $n=2$ to $n=3$ transition; H-beta from the $n=2$ to $n=4$ transition. Thus both transitions are governed by the number of atoms in the $n=2$ lower level.
The absorption coefficient for a transition can be written in proportionality terms by (in local thermodynamic equilibrium)
$$ \alpha_\nu \propto  \nu B_{lu} n_l ( 1 - \exp[-h\nu/kT]),$$
where $B_{ul}$ is the Einstein absorption coefficient, $n_l$ is the population of the lower energy level and $\nu$ is the photon frequency corresponding to the transition.
Using the well-known relationship between the Einstein emission and absorption coefficients and values for the emission coefficients found here, we can estimate a ratio of absorption coefficients for a given temperature.
$$ \frac{\alpha_{H\beta}}{\alpha_{H\alpha}} = \frac{g_{n=4}}{g_{n=3}} \frac{A_{H\beta}}{A_{H\alpha}} \left(\frac{\nu_{\alpha}}{\nu_{\beta}}\right)^2 \left(\frac{1 - \exp(-h\nu_{\beta}/kT)}{1-\exp(-h\nu_{\alpha}/kT}\right),$$
where $A_X$ are the Einstein emission coefficients and the statistical weights $g_n$ are given by $2n^2$.
Thus if we take $\nu_\alpha = 4.57\times10^{14}$ Hs, $\nu_{\beta}=6.17\times10^{14}$ Hz, $A_{H\alpha} \simeq 10^{8}$ s$^{-1}$, $A_{H\beta} \simeq 3\times 10^{7}$ s$^{-1}$, then
$$\frac{\alpha_{H\beta}}{\alpha_{H\alpha}} = 0.29 \left( \frac{1 - \exp(-29642/T)}{1 - \exp(-21956/T)}\right)$$
So when $T$ (in Kelvin) is small, the ratio is about 0.3. When $T$ becomes large then the ratio increases, but above $T \sim 12,000$ K, all the Hydrogen is ionised.
Thus in thermodynamic equilibrium is it very difficult to manufacture a circumstance where the optical depth in the H$\beta$ line is larger than that in the H$\alpha$ line.
[I'd be grateful if someone can tell me whether the ratio I calculated above is correct, since I could not find it in any reference and need to work it out from scratch].
Comment: scratch? That is awesome job!
Comment: I revised the title. It is not necessarily a stellar spectrum.
Answer: As a small addendum to Rob Jeffries' excellent answer, I'll note that you probably can't get a scenario of "H-beta, but no H-alpha" for emission lines, either. The emission lines are the reverse of the absorption lines, so to have H-beta emission without H-alpha, you'd have to have $n = 4$ to $n = 2$ transitions without also having $n = 3$ to $n = 2$ transitions. But even if you could somehow magically arrange to have all your H atoms in the $n = 4$ level, some of them would transition to $n = 3$, and then to $n = 2$, so you really can't avoid H-alpha emission.
Furthermore, dust extinction is worse at shorter wavelengths, so dust extinction could in principle give you the appearance of H-alpha emission without H-beta emission, but not the reverse.


How to upgrade ubuntu 12.4 to 14.4

Question: I bought a new Dell 3542 laptop with Ubuntu 12.04. I want to upgrade it to 14.04. My update manager is showing there are no updates to install. Please tell me step by step how to upgrade. Thank you.
Comment: have the checkmark checked for checking for new releases?
Comment: Hello, and welcome to AskUbuntu! Unfortunately, Ubuntu 12.04 is long out-dated, and has reached its EOL (End of Life), so we no longer support questions about it. What you can do is download Ubuntu from an outside source, and re-install to your PC.
Comment: @DavidCole-GrammarPolice 12.04 will go end of life April 2017
Comment: Ok, can you tell me how, I mean should I buy a DVD or download it from ubuntu website. If you suggest to download from website then please tell me how to install. Thank you
Comment: This is not a very good idea to upgrade. You will face a lot of SOLVABLE problems with wifi, touchpad, graphics, etc. So think twice before you do it. This is specific to this kind of Dell comps with preinstalled 12.04
Answer: Open a terminal window and
sudo do-release-upgrade

If you are doing the upgrade over SSH it will spawn a new SSH daemon and warn you that you may lose connectivity during the upgrade and tell you how to reconnect.
It's always best to do it locally if you can, but I've done many over SSH connections :)
Answer: Install the update-manager-core package:
 apt-get install update-manager-core

Open the release-upgrades file for editing by entering the following command:
 nano /etc/update-manager/release-upgrades

Verify that the following line is present in the file, and that Prompt is set to lts:
Prompt=lts

Exit nano and upgrade your Linode to Ubuntu 14.04 LTS by entering the following command:
do-release-upgrade -d

Follow the on-screen instructions to complete the installation process. You will be prompted as to whether you wish to continue; as you are on LISH, it is safe to continue via SSH.
You may see a message type y and hit enter
Verify that it's running Ubuntu 14.04 LTS by entering the following command:
cat /etc/lsb-release

Comment: It works. My system updated.
Answer: You can do this following
To upgrade on a desktop system:
Press Ctrl +Alt+T(to open a terminal) and type in sudo update-manager
Update Manager should open up and tell you: New distribution release '14.04 LTS' is available.
I can show a windows in my case(i am already on 14.04 LTS so it will be different for you)

Click Upgrade and follow the on-screen instructions.
For more info, visit here
Answer: I would comment Ashu's answer, but I don't have the reputation for that, so I post another answer.
Open update-manager and click Settings.

As Rinzwind commented at your question, remember to enable long-term support versions at software-sources settings.

Then follow Ashu's instructions.
Have in your mind that some of us (Pilot6 also) prefere not to upgrade distributions this way, but doing a clean install. You can do it better if you prepare a boot-USB before possibly mess-up your 12.04 system upgrading it to 14.04, using start-up disk creator and a proper for your laptop 14.04 ISO, downloaded from http://releases.ubuntu.com/14.04/.

How to upgrade ubuntu 12.4 to 14.4


Meaning of proper prior

Question: I am trying to learn the basics of Bayesian decision and I came across the phrase "proper prior" but I don't really understand what it means. Does anyone know?
Comment: By default "prior" commonly means "proper prior", so this is a case where looking for the [antonym](https://en.wikipedia.org/wiki/Prior_probability#Improper_priors) may be more useful. (If this does not help, you can clarify, but consider adding the [tag:self-study] tag.)
Comment: I searched for the meaning of improper prior and I found that it means the prior does not integrate to one and can even be infinite (it is not a proper probability distribution so to speak...) Do you agree@GeoMatt22?
Also, what about the self-sudy tag?
Comment: You are right, an improper prior is a prior that does not integrate to one and may even be infinite like e.g. a ''uniform prior'' over $[0,+\infty[$.
Comment: @MedNait that is correct. A proper prior is literally a prior that is a PDF, so has unit integral. I mentioned self-study as your short question came across as similar to thse types of (homework/textbook) questions we see a lot, with little sense that the poster tried to solve on their own. But I realize that "proper prior" may be hard to Google, as noted in my original comment.
Answer: A prior distribution that integrates to 1 is a proper prior, by contrast with an improper prior which doesn't.
For example, consider estimation of the mean, $\mu$ in a normal distribution. the following two prior distributions:
$\qquad f(\mu) = N(\mu_0,\tau^2)\,,\: -\infty<\mu<\infty$
$\qquad f(\mu) \propto c\,,\qquad\qquad -\infty<\mu<\infty.$
The first is a proper density. The second is not - no choice of $c$ can yield a density that integrates to $1$. Nevertheless, both lead to proper posterior distributions.
See the following posts which throw additional light on the use of improper priors issue and some closely related issues:
Flat, conjugate, and hyper- priors. What are they?
What is an "uninformative prior"? Can we ever have one with truly no information?
Comment: By: "An improper prior can still be understood in some sense" you mean as a weighting of the likelihood function, where the possibly high values of the improper prior can be corrected by the normalization factor $p(x)$?
Comment: Just to complete my understanding, is a prior that integrates to 1 and is not always positive proper?
Comment: That won't be any use at all, since it won't leave you with a proper posterior.
Comment: So basically, we can get a proper posterior even with an improper prior $p(\theta)$ because of the multiplication by the likelihood ($p(x|\theta)$: distribution of data given $\theta$ that cannot be improper!) that guaranties this. On the other hand, if the prior is negative valued nothing can correct for this. Is this correct?
Comment: The product of a prior density that goes below with a likelihood will produce a posterior that goes below zero (unless the likelihood happens to be 0 there). But the prior going negative would also have no interpretation. An improper prior can generally still be understood in some (more or less vague) sense.
Comment: Something like that.

Meaning of proper prior


Is there a per turn gold cost to allying with a city-state?

Question: Obviously there can be a cost involved with getting a city-state to ally with you, in the sense that you gift them gold to get reputation.  But I noticed in my game the other night that allying with a city-state to get their resources appeared to cause my gold per turn to fall precipitously.  Am I now paying maintenance on the roads that are in their territory?  Are there other possible explanations?
Comment: Two thoughts: 1) What kind of city state? I wonder if you got more food and that changed how your cities wanted to work, or they grew and couldn't work as many $ hexes. 2) I'm soon (when I have time to cite pictures) going to dispute roads not costing $ each turn outside your borders, I think its only inside someone else's borders that you don't have to pay.
Answer: Simple answer: No, not directly.
I played around with my save game, and the difference appears to be that as a result of going into "We love the king" mode, my gold from cities went down dramatically.  I would guess that this is because the civilians were assigned to food instead of money to take advantage of the growth benefit.  I guess this means you have to keep a close eye on how your civilians are assigned, especially later in the game when maintenance is high and money is a lot more important than a little population growth.
Comment: Don't forget to add the answer to your question: No, it shouldn't.
Answer: My experience shows that it is not only "We love the king" mode. Also if you change from unhappy to happy cities change production to focus more on food and this results in a drop of gold/science production.


How to store variables in an interpreted language?

Question: Say I'm making an interpreted language. What's the best way for me to store variable name/value pairs (or type/name/value triplets in the case of languages with typing)?
Comment: Isn't it obviously some kind of `name->value` map data structure? What have you tried?
Answer: Many dynamic languages have function scope, i.e. a variable is in scope within the whole of the function body that it is declared in, or if it is not declared within a function then it is global. In this case, each stack frame needs just one mapping from names to values, which could be a hashtable or any other dictionary data structure. To look up a name:

First check the current stack frame,
Otherwise if the current stack frame represents a closure, recursively check the closed-over stack frame,
Otherwise, check the globals.

For languages with block scope, there are generally more scopes than there are stack frames, and local variables in a block may be allowed to shadow local variables declared in an outer block in the same function. In this case, each stack frame can have a stack of dictionaries, where each dictionary in the stack represents a block.
To check a name, iterate through the stack from top to bottom, trying each dictionary in order; to declare a variable, add it to the top-most dictionary in the stack; and to interpret a block statement, push a new dictionary to the stack before interpreting the child statements, and then pop it from the stack (so that the variables in that dictionary go "out of scope").
It may be convenient to use a dictionary type which encapsulates this behaviour; for example, Python's collections library has the class ChainMap which implements a stack of dictionaries like this. You can implement your own "chain map" data structure by writing a class which holds a dictionary and an optional reference to a parent, which would be another "chain map".

The use of dictionaries assumes that variable names are represented as strings in the AST. If you are interpreting a bytecode language, then local variable names may already have been replaced with numeric indices; for example, Java bytecode has instructions for loading or storing to the first, second, third, fourth or nth local variable.
In this case, you should know in advance how many local variables each function has; then, variables' values can be stored in an array, and accessed by index. Alternatively, if your interpreter is implemented in a low-level language with direct access to the call stack, then local variables can be stored on the stack directly, and then accessed by computed stack offsets. However, if you take this approach then you will need some other strategy for handling closures, which may capture the local variables of an outer function call beyond its lifetime on the stack.
Comment: TIL `ChainMap` exists in python. Never knew it was a thing.
Answer: Adding to @kaya3's answer regarding the stack-of-dictionaries, you'll still need something that the variable-name key points to. Eg., the user's identifier "x" must refer to some previously declared/instantiated "x":
x = 1

def foo():
    return x + 2  # what is x?

If your identifier resolution can be run at compile time, then you can store a pointer to the declared "x" in the AST node for your use of "x". That implies that the dictionary maps from the identifier's name to the AST node where the identifier was declared.


Temperature of an object placed half way between sun and earth

Question: I'm looking for a qualitative understanding. Suppose I put an object which was at $0$K half way between earth and sun. Initially the object sucks up more photons and emits fewer photons. After some time it reaches equilibrium. Now would the temperature of this object stay at $2.7$K ?
Answer: No. That is the temperature it would reach if it was exposed only to the cosmic microwave background. In other words, if it was far away from any stars or other sources of light.
The sun is very hot, and the light released from it reflects that. Your object will get rather a lot hotter than $2.7~\rm K$, as it reaches equilibrium with the sun's light, not with the cosmic microwave background.
The actual temperature it reaches depends on a lot of factors, like how much light it reflects and how much of its surface area is illuminated. If it is a perfect blackbody, with half of its surface area illuminated normally (in other words, it's a flat disk), and the whole object reaches thermal equilibrium (i.e. there are no temperature gradients in it), then the temperature it reaches is given by:
$$ T_{\rm eq}=T_{\rm sun}\left({r^2\over2R^2}\right)^{1\over4}\approx470~\rm K$$
where $R$ is the distance from the sun, and $r$ is the radius of the sun.
If you change the assumptions I've made (for instance, assume that there is a large temperature gradient, so the sunward side is much hotter), this can change quite a bit. Specifically, that assumption changes the temperature to about $560~\rm K$, as it gets rid of the factor of $2$ in the denominator.
Different assumptions on shape and thermal conductivity can change that factor anywhere from $0$ (imagine a long, thin cylinder, with just the end illuminated) to $1$ (a perfect insulator will only heat up where it is illuminated, and so won't lose any energy to radiation from non-illuminated parts).
Comment: @pentane It comes from a straightforward application of the Stefan-Boltzmann law. I was assuming a flat disk so the cross-sectional area is half the surface area, while that link is assuming a spherical object, where the ratio is $4$ instead. The $2$ in the denominator can vary anywhere between zero (imagine a long, thin cylinder with just the end illuminated) to one (any shape, if the object is a good insulator, so only the illuminated side gets hot).
Comment: Oh I see ty!  Is 2.7K  the temperature when there are no hot objects near by ? Does that mean temperature decreases gradually as we move away from the sun and reaches 2.7K as we reach pluto maybe ?
Comment: Pluto is around $40~\rm K$ at its coldest, so even that's not far enough. But yes, generally that's the idea.
Comment: Gotcha! So when astronomers say 'space' most of the time they don't really mean 400km away from earth. They mean much far away, the vast space between stars. Thanks again :)
Comment: what temperature would the object get if it was placed half way between the sun and earth tho?
Comment: @pentane Added.
Comment: where's the source of that equation?
Comment: http://www.astro.uvic.ca/~venn/A201/maths.7.planet_temperature.pdf this has a slightly different equation
Comment: $\large T_{eq} = T_{sun} \left( \frac{r^2}{4R^2} \right) ^{\frac{1}{4}} $ or the equivalent $\large T_{eq} = T_{sun} \left( \frac{r}{2R} \right) ^{\frac{1}{2}} $ which brings it down to 394 K if my math is correct
Comment: Oh awesome! Could you add that it's a disc to the post?
Comment: @pentane It is done.
Answer: Earth's upper atmosphere has a temperature of about 260 kelvin, which is in equilibrium with the amount of radiation it receives from the Sun. The Earth radiates as much as it absorbs.
An object at half the distance would receive four times as much sunlight. In equilibrium, its thermal radiation would be four times as large. According to Stefan-Boltzmann's law, thermal radiation is proportional to the fourth power of absolute temperature, $T^4$. So the object would have temperature $\sqrt[4]{4}= \sqrt{2}$ as high, about $1.41 \times 260 \approx 370$ kelvin.
(This is what happened to Icaros the son of Daidalos. He flew halfway to the Sun, but then the wax on the wings started to melt.)
Comment: @rsadhvika The moon has a huge difference between the day side and the night side because rotation is slow and there is no atmosphere to average things out. Some craters at the pole are permanently in the shadow. Temperature of the rock there can be as low as 30 kelvin.
Comment: Clever! 370K.. that's just 97C. Since moon has no atmosphere, would the temperature on moon be around 260K too ?
Comment: Google says 100C on moon during day time. May be it is not reaching equilibrium..
Comment: The moon is closer to a perfect blackbody than the earth, and the hottest parts are relatively close to thermal equilibrium with the sun's light. So you'd probably get closer to the right answer using the moon's temperature, rather than the earth's upper atmosphere.
Answer: One can also approach this quantitatively. Let us assume the object to be a sphere of radius $r$ with emissivity $\epsilon$ and fast heat conduction. It will receive energy from the sun and the CMB, and radiate away heat depending on its temperature. Its internal temperature will change so that energy is conserved, and this will tell us how it will heat up.
The solar input is equal to the sunlight that hits the object. The total amount of sunlight will be the light crossing the area $\pi r^2$ (while the lit surface is half of the surface, near the terminator line it gets spread thinly). If the sun has luminosity $L$ and the object is at a distance $R$ the total power is $$P_{sun}=\epsilon\frac{L}{4\pi R^2}\pi r^2$$
Here the emissivity plays a role: if the object is shiny it will reflect some of the energy.
The CMB input comes from all directions (we ignore the shading of the sun, it is not large in the sky) and is blackbody radiation of temperature $T_{CMB}=2.7$ K. We get power $$P_{CMB}=4\pi r^2 \epsilon \sigma T^4_{CMB}$$
The object radiates heat back into space with the full surface, $$P_{rad}=4\pi r^2 \epsilon \sigma T^4$$ depending on its temperature.
Putting all this together, the amount of energy gained (or lost) per unit of time is $$P_{sun}+P_{CMB}-P_{rad} = \epsilon \pi r^2 \left (\frac{L}{4\pi R^2} + 4\sigma(T^4_{CMB}-T^4)\right )$$
This already tells us a lot of things. Emissivity determines how much the object participates in the energy exchange. A shiny object will change in temperature more slowly than a black one. The rate of energy exchange depends on the area. Calculating the size of the terms in the parenthesis will show that the first one is large (hundreds of Watt per square meter), the CMB one small (0.000003 W/m$^2$) and that the temperature will hence have an equilibrium when the solar term is equal and opposite to the object thermal term, or $L/4\pi R^2 = 4\sigma T^4$, which gives $$T_{balance}=\left [\frac{L}{16 \pi \sigma R^2}\right ]^{1/4}.$$ Temperatures will decline as ${(R^{-2})}^{1/4}=1/\sqrt{R}$ as we go outwards. The equilibrium temperature is also independent of object size $r$.
Just to complete the model, how does $T$ change if the object is not in thermal equilibrium? Let us assume it has specific heat capacity $C_V$ and mass $4\pi \rho r^3/3$, where $\rho$ is density. Then the internal heat store will be $4\pi \rho r^3 C_V T/3$, and plugging this all together as a differential equation:
$$\frac{d}{dt}\left [ 4\pi \rho r^3 C_V T/3 \right ] = \epsilon \pi r^2 \left (\frac{L}{4\pi R^2} + 4\sigma(T^4_{CMB}-T^4)\right ).$$ Since the object is assumed to not change size or heat capacity (the last one is only approximately true, and I am very interested in the complications that happen at very low temperatures), we can simplify to:
$$\frac{dT}{dt} = \left [\frac{3\epsilon}{4 \rho r C_V} \right]  \left (\frac{L}{4\pi R^2} + 4\sigma(T^4_{CMB}-T^4)\right ).$$
The bracket term is basically the thermal inertia, factors that determine how fast things cool down or heat up. It is inversely proportional to radius: big things react slowly. Similarly, dense things and things with high heat capacity respond slowly.
Solving the differential equation is a bit overkill (it is basically $T'=a-bT^4$, and one can get the implicit solution for time $t = C+\int \frac{dT}{a-bT^4}$ - the integral is unfortunately messy but in principle analytically tractable). If the object also conducts heat slowly we would have to model internal heat diffusion - doable with the heat equation in spherical coordinates, but requiring a numerical solution.


Intraclass correlation with count data

Question: I want to calculate the ICC between 3 different measurements where the dependent variable is a count. As far as I understood, if the data were normally distributed, I would use a repeated measures ANOVA for this. But for count data, the normality assumption doesn't hold true. Do you have any hints how to get the ICC without using rmANOVA? I know that generalized linear models are somehow crucial for that, but I don't know how to exactly use them for this purpose.
Comment: Welcome to the site. This is a good question. I have edited it for clarity; please ensure it still says what you want it to. Eg, I changed the 'independent variable is a count' to the *dependent* variable. Note that the distribution of your IV is irrelevant, so I suspect you meant DV. If that's wrong please let us know.
Answer: You need to work with a Generalized Linear Mixed-effects Model (GLMM).  The repeated measures ANOVA is actually a special case of the Linear Mixed-effects Model (LMM), so GLMM:LMM as GLM:LM.  From there, just recognize that the ICC is a descriptive statistic that assesses how distinctive the units are relative to the total spread of the data.  The standard formula is:
$$
ICC = \frac{\sigma_{\bar{x_i}}^2}{\sigma_{\bar{x_i}}^2+\sigma_\varepsilon^2}
$$
In the context of a mixed-effects model, the distinctiveness of the individuals is the variance of the random effects.  Since variances add, the total is the variance of the random effects plus the residual variance.
To illustrate, here is a simple example, coded in R:
library(lme4)   # we'll use this package to fit the GLMM
set.seed(1189)  # this makes the example exactly reproducible

N          = 20                                     # there are 20 people in your study
reps       = 3                                      # w/ 3 observation each
id         = rep(1:N, each=reps)                    # this is the ID indicator
sub.lambda = rnorm(N, mean=1.6, sd=.3)              # here we generate each unit's mean
sub.lambda = rep(sub.lambda, each=reps)             #  & copy them for each observation
y          = rpois(reps*N, lambda=exp(sub.lambda))  # here we generate the counts

mod = glmer(y~(1|id), family=poisson)               # this fits the Poisson GLMM
summary(mod)                                        # here is the output:
# Generalized linear mixed model fit by maximum likelihood
#   (Laplace Approximation) [glmerMod]
#  Family: poisson  ( log )
# ...
#
# Random effects:
#   Groups Name        Variance Std.Dev.
#   id     (Intercept) 0.1066   0.3265
# Number of obs: 60, groups:  id, 20
#
# Fixed effects:
#             Estimate Std. Error z value Pr(>|z|)
# (Intercept)  1.45853    0.09745   14.97   <2e-16 ***

  ## now we get the variance of the random effects, the residuals, & calculate the ICC:
v.RE  = summary(mod)$varcor$id[1];  v.RE   # 0.1066211
v.res = var(resid(mod));            v.res  # 1.141968
ICC   = v.RE/(v.RE+v.res);          ICC    # 0.08539324

Comment: Thanks a lot for your answer. I recently also read that a Friedman's test could be used for this purpose. What do you think of it? And does this GLMM also work for incomplete data, means NAs in the dataset or unequal number of observations per measurement?
Comment: @soschnei, I would not use Friedman't test to determine the ICC here, but you could use it for a test of a treatment effect. If your dataset is naturally unbalanced (you simply took measures at different times), there is no problem. If you have missing data (you *should* have had data there) a GLMM is fine as long as the data are missing at random (MAR).
Comment: Thanks again. I have some more questions: Why didn't you use the number of repetitions as a fixed effect? I found quite some models in which days of repetitions or comparable units were used as a fixed effect. This gives me very different results. And if I would have an additional factor, e.g. I measures counts for left and right leg, how would you include it in the model? Also using a random effect? And if I use the mean counts instead of raw count data, I would still have to use glme, wouldn't I? The data is not integer anymore but is also not allowed to be negative.

Intraclass correlation with count data


Son created an account using a junk email

Question: When my son originally created his POkemon Go account he asked for my email address which I refused. He forgot his, so he created a junk email account. Now that the app was upgraded, my son can't play because all updates are being done through an gmail account he can't access it because he does not remember the password.  I tried to create the email address but someone is already using it.  Is there a way to transfer his Pokemon Go to a new gmail account or is he out of luck.
Comment: You can't just create a Pokemon Go account with only an email address. You would have to be logged in which would require a password.
Comment: What do you mean with fictional account? Either he created a new Gmail account or not. If he created a new Gmail account he should also have created the password for it.
Comment: I don't think he created a gmail account, I think he just typed in a random one or one that did not exist (at least under his name)
Answer: If you are able to sign into the app, you can go into settings and logout of that account to log into another one. You will lose your account data doing this. If you cannot log into the app, and get stuck at the loading screen (with the Gyrados) there is a chance for it to have a "Sign Out" button right in the center. That will allow you to get out and sign in with an email address/account you control.
The problem is that your son effectively created his account under someone else's name, and now that account is theirs and he will not be able to get it back. You'll need to create a new account, tied to an email you already have. Either your son will need to remember his email account or create a new one before signing into it in the game. Unfortunately he has no other options.


Why don't they use short wave radios in The Walking Dead?

Question: Charging  the batteries using solar powered chargers  could work right?
Comment: Because that would make sense.
Comment: Most rechargeable batteries go bad over time in one way or another.  It is certainly possible to charge batteries via solar power though.  I have an emergency AM/FM radio that includes a solar panel to power the radio or charge the NiMH batteries, which in my radio are replaceable.  I haven't seen the show though, so I have no idea why they wouldn't use these.
Comment: What would zombies want with short wave radios?
Answer: Nothing stops them from doing so. Should they be fortunate enough to come across one in working condition and also have the means to power it, a shortwave would be a decent addition to their equipment.
Nothing stops them from using a shortwave radio but the availability of having one. Yes, it would be possible to recharge one using a portable recharger and such technology would have existed in the period the Walking Dead is set in (presumably it is close to our current time frame).

Since the series started, Rick and Co. have rarely come to a section of town that hasn't already been cleared out of survivalist-type equipment. They might have been able to scrounge one from the CDC or from the military outside of the site, but they have found themselves constantly on the run.

Since they left the governor's group in poor graces, if there was one there, they either didn't see it or didn't think to take it with them. There might have also been one in Terminus but they left there in a bit of a hurry and didn't get a chance to look around.

Their best chance of finding one they could use would likely be in a major city but the population of walkers in those conditions make the risk not worth the reward.
Comment: Why does this question get downvoted? What have I done wrong now?
Comment: Why is someone giving him -1 for a (imho) good answer?
Comment: "Their best chance of finding one they could use would likely be in a major city"    but not a rural police station or farm? really?
Comment: Anything likely to be found in rural areas has likely been scavenged by survivors or taken by the people living in the area when the event happened. If they were to find any such radios now, if their batteries were left in the units, it is possible they have corroded or corrupted the device, leaving it unusable. Shortwaves in stores would not have the batteries in the device, so they still have a better chance finding a working unit in a city, in a place that sold them, should they feel bold enough to try.
Comment: Trucks have them. The entire story has happened within a year, not long enough for batteries to corrode. Why would anyone take the battery out? Also, they are the people living in the area where the event happened are they not? Don't forget Rick managed to get into the police station and get weapons and you're saying that the batteries there would have been corroded? Not a good answer I'm afraid.
Comment: Yes, trucks can have them. Don't remember seeing any trucks so far in the series. These would most likely be the first radios to be scavenged assuming they can be removed from the truck. And people would take the batteries out of their devices if they didn't want battery leakage and corrosion to potentially damage the radio. The only batteries not known to leakage are lithium batteries. Any alkali battery left in a device can leak and corrode.
Answer: TL;DR:  We can assume that the survivors would consider using some form of radio communications technology if the opportunity presented itself.
This is now clear, because in the comics, Eugene recently traded beer for an old CB radio, and has since repaired it and begun using it.

On the show:
There is no explicitly mentioned reason for them not to do so, now that they are in a permanent settlement with access to solar power. It hasn't come up yet on the show.
Before Rick's group found Alexandria, it wasn't feasible:
Prior to the group's arrival at Alexandria, however, they were wandering around aimlessly, fighting for survival, and didn't know where their next meal or drink of water would come from.  They certainly couldn't lug around a solar charger at that point.  They were dying of starvation and dehydration. Communication was the least of their problems.
Now that they are in Alexandria, it isn't a priority:
Even now, they have been at Alexandria for some time, and have a decent supply of electricity, but they simply have more important things to worry about than talking to strangers who are almost certainly in the same position they are, if not worse.  There is too much going on and not enough time - or incentive - to think about anything beyond mere survival.
In the short time that Rick's group has been in Alexandria, they have been careening from one crisis to the next.  First, no one trusted them.  Then the Pete and Jessie issue happened.  Then the Wolves attacked.  Then the zombies from the quarry escaped and had to be dealt with.  Then they had to rebuild the community and repair the damage done by the Wolves and the herd.  Then they met Jesus and discovered the Hilltop.  Then they went to war against Negan and the Saviors.  And all this time, they've been struggling just to feed themselves.  At no point since their arrival in Alexandria have they had a decent chance to even think about communicating with the outside world.
Even if they get things under control, it might not be a very good idea:
After Rick's group sorts out the Saviors and achieves some sense of normalcy, there will still be another issue to consider:  As has been made quite obvious already, zombies are really a secondary concern at this point.  The real threat is other human beings.  Rick said, at the end of the season 5 finale, that people will come and try to take Alexandria for themselves, and Rick will teach the Alexandrians how to fight back.  But in this world, the best defense is not really a good offense:  the best defense is not letting your enemies know that you exist.
Using radios would jeopardize the group's anonymity and relative invisibility.  If someone overheard a radio communication, they would instantly realize that a community of people was out there somewhere, and would begin to look for it.  That would be incredibly dangerous for the Alexandrians.
So they didn't have the means until they got to Alexandria.  Then they didn't have the time to make it happen.  And once those two issues are no longer a factor, it still might not be advisable.

In the comics:
In recent issues, Eugene obtained an old Citizens' Band radio and began to use it.  Over the last three issues (#151-#153), he has been talking to a fellow survivor at an unknown location.

Issue #151

Issue #151

Issue #151

Issue #152

Issue #152
As you can see, there is still the question of whether Eugene can trust his new acquaintance, and the acquaintance is still reluctant to trust Eugene.  By this point, everyone who was foolish enough to immediately assume the best about new people is dead, and everyone who is left knows that new people are best treated as enemies until they have proven otherwise.
Answer: Short wave frequencies (i.e., HF) are used for very long distance communications.  They would not be using the short waves for intra-group communications, but to communicate with other parts of the world.
They would use VHF and UHF frequencies (e.g., CB, handheld radios) for local, and regional communications.
Answer: They probably could scrounge around and find a shortwave radio and power it using a DC inverter and plugging it into a car for power.
I think the real question is to ask whether or not they would want to contact other groups. They have been burned by their recent interactions with the others, so I'm not sure if they would be willing to trust anyone else new, at least for a while.
Rick didn't even trust Gabriel, and he wouldn't hurt a fly.
Comment: I was thinking more along the lines of communicating within the group
Answer: Virtually all HF/VHF/UHF radios can run on DC in varying amounts of voltage.  Many HF (shortwave) transceivers run on 12V DC, so they can be hooked up directly to a car battery.  Some CB radios run on 12VDC.  Others, such as handhelds for VHF, UHF, etc. run on lower amounts of DC, but those are easy to convert.  Inverters switch AC to DC and vice versa.  Converters, such as step-down converters will take 12VDC, for example, and step it down to 6VDC or lower.
Hope this clears it up a bit.


Police and doctors

Question: If you live in one state and have a doctor in another (because they don't offer the treatment to you, unless you're a pregnant female), can the police in your town call your doctor and tell them not to prescribe people from your town - when you did nothing wrong at all.
Comment: This would be easier to understand if it was fleshed out more. Are you getting at efforts by a resident of one state to circumvent abortion restrictions in another perhaps?
Answer: Only the courts have legal authority to order a licensed medical practitioner to refrain from writing a legal prescription, or to order a licensed pharmacist to not fill one. I assume that is what you mean by "tell him not prescribe people from our town". Additionally, the courts of one state only have jurisdiction over actions in that state, so an Idaho judge cannot restrain a doctor's practice in Washington. The fact that a customer is an Idaho resident does not change that.
Police can give orders in furtherance of their official duties. Generally, that relates to immediate situations, such as an order to sit on the ground (during an arrest), step aside (when executing a search warrant), and the like. It depends on the state, but many states have "emergency powers" laws that allow the governor to give orders (such as evacuation) as are felt to be required in an emergency, and that authority may be transmitted to local police. If the governor (of that state) issued such an order, then police of the other state could enforce it (but that hasn't happened).
If an officer felt that the people from one town were selling oxycodone, he might feel that as a citizen, he should try to persuade the local doctor to stop writing those prescriptions. Persuasion is always legal; going beyond persuasion (acting under color of law) requires legal authority, which would be lacking in the situation you describe.
Comment: "Persuasion" may not be legal if the fact that the person holds an official position is influential even if they do not expressly act in an official capacity
Comment: Not my point - speaking freely as a private citizen is fine - saying the same thing while wearing a police uniform and giving the impression that you are speaking with the authority of the office (even if only implied) - not so much
Comment: And, equally, we have no evidence they weren't. The OP has posited if it is ok for a police officer to restrict a doctor - the question is irrelevant if the doctor doesn't know the other person is a police officer.
Comment: I'm assuming US jurisdiction, following the OP's tag, where the right to speak freely is constitutionally protected. Holding a government position does not terminate your ordinary rights as a citizen.
Comment: We have no evidence anyone was wearing a uniform.

Police and doctors


Why is mixed factorial ANOVA more powerful than between-groups ANOVA

Question: Why is a two-way mixed factorial ANOVA involving six conditions more powerful than a between-groups ANOVA with involving three conditions? I understand that between-groups analyses are less powerful as subject variance is not removed (Greenwald, 1976). But why is a mixed factorial ANOVA more powerful (i.e., requires lower N to detect significant main effects and interactions) when it still involves between-group comparisons? Grateful for anyone who can shed some light on this for me.
Comment: My calculation of power was done using G*Power, F tests, "ANOVA: repeated measures, within-between interaction"
Comment: Actually, I think the power analysis should have been done as "repeated measures, between factors". This computes a more realistic calculation for the required sample size (similar N to to between-subjects ANOVA, but not lower). Yes, power was set at 80%.
Answer: Since you used G*power, I'm wondering if you saw that by adding a repeated measures (within subjects) factor to a one factor between subjects design, thus ending up with two (mixed), you saw that you did not need to increase the number of participants necessary to detect the effects at (say) 80% power?
Power is specific to a single hypothesis test, it is the probability that you will reject the null hypothesis if indeed there is a "real" effect to detect. So going from one factor to two increases the number of hypothesis tests you perform, but does not inflate the Type I error rate (the probability of falsely rejecting the null). The mixed design means you also don't need any more participants than you already have because you can vary the repeated measures factor across different time points in the same sample of participants. Thus, power seems to be increased, but it is really that you get more bang for your buck with the design.


Can the Command spell force someone to answer a question in a Zone of Truth?

Question: If you have an enemy in a Zone of Truth who failed their save, they can still choose to not answer. If a player casts Command on them with the word being "answer" would that force the creature to answer the question posed? Similarly, what if you cast the command "lie" on a creature in a Zone of Truth?
Comment: At least related: [Can I use the Suggestion spell to force a creature to tell the truth?](https://rpg.stackexchange.com/q/70695), [What spells or magic items are available to detect lies?](https://rpg.stackexchange.com/q/172630)
Answer: The command spell is almost entirely left to the GM
The command spell states:

[...] Some typical commands and their effects follow. You might issue a command other than one described here. If you do so, the GM determines how the target behaves. If the target can't follow your command, the spell ends. [...]

Notably, "Answer" is not in the given list of commands and so anything that happens from this command is going to be up to the GM.
But even if it does force somebody to answer a question, and they are required to tell the truth, they can still choose the talk around the question or give an answer that is unclear. In fact, a GM could even argue "Dog" is an acceptable answer to a yes or no question because it is some kind of answer, just not a particularly helpful one.
Comment: Is "Confess" a valid command?
Comment: Side note: This also covers the command "lie" mentioned in the question's text. The target currently can't lie, so the command ends immediately.
Comment: @Egor Alternatively, the lie is not deliberate, so *zone of truth* doesn't actually stop it. Alternatively alternatively, they just speak a lie they did not even know was a lie, and thus it also wasn't deliberately lying because they had assumed it was the truth but the spell just *knew* it wasn't, somehow
Comment: @Verdan I am now imagining Jim Carrey in The Mask, confessing to a host of things that don't matter and making a mockery of your first level spell.


How to ignore iPad auto correct recommendation?

Question: iPad's typing auto correct sometimes can be useful, yet sometimes it provides the wrong recommendation. it's often inconvenient to break my hands from the typing position to tap the "x". I wonder aside from tapping the "x" next to the recommended word to ignore recommendation, what can I do on the keyboard to ignore it?
Answer: This is a bit of a workaround, but what I always do is just delete the last letter and type it again. iOS recognizes this as an assertion that that's how you wanted to type the word, and won't give the suggestion again.
Also, if you type a word and it gets corrected, the erase it and type it again, it won't correct you twice.
Finally, it seems that if you type a word that isn't in the dictionary and ignore or erase the correction, it won't offer that correction again in that text field. You can try this by just typing the same "wrong" word a few times and it will stop correcting you.
It's not exactly what you're asking for, but I find the autocorrect to be sufficiently intuitive for me. (As a matter if fact, I typed this on my iPhone with absolutely no regard for errors.)
Answer: Sorry. There isn't really another way.
However, you can manually add words or phrases into the dictionary

Go to the Settings app, choose General, Keyboard. Scroll to the bottom and you will see Shortcuts. At the very bottom you will see the ability to create a new shortcut.

When adding a word, you can add just the phrase and leave the shortcut blank if you just want to add it to the dictionary.
Answer: I just learned that you don't have to be too accurate in hitting that x mark. Tap anywhere in the grey suggestion word box and it goes away.


404 - Not Found error while trying to access my new facebook app

Question:
404 - Not Found The page you are trying to access does not exist. If
  this error persists, please contact the website webmaster.

The above message appears when I attempt to access my new facebook app. Now please understand that I am new to web site and app development.
I purchased a Joomla template, uploaded those files to my web site and have NO probem viewing the template within the /site/ folder at my web site. I have followed all instructions from facebook and Joomla including watching tutorial videos typing in the file names exactly as instructed. On Firefox i first get the above 404 message. On IE i get the following message;

Content was blocked because it was not signed by a valid security
  certificate.

My site does not have a security certificate and I wasn't told I needed one, but is this the reason that my new facebook app won't display the template it's linked to on my web site?
Answer: Starting just recently you will need to have an SSL cert to property host a facebook app.  The 404 might just be some latency with DNS settings needing to propagate thru the interwebs.


Enforcing Vista parental controls while allowing some admin rights

Question: I'd like to set up parental controls for a non-admin Vista user but still allow them to perform installations without requiring an admin password. How can I do this?
Answer: You cannot do this easily, applications need administrative rights to install usually, as they need to modify the file system.
If your application users an MSI installer to install (which most do), you can force the installer to always install with admin privilages. To do so you need to make a change in group policy, if the machine is on a domain, or the local security policy if it is not, to enabel the 'Always install with elevated privileges' option in both the machine and the user configurations.


Why we measure bandwith at -3dB?

Question: To characterize a signal it's a common use to determine bandwidth at -3dB from the peak (half power). Also, filter's cutoff frequency is pointed at -3dB. Why we use this rule?
Answer: It is a common value because at $-3 \ \mathrm{dB}$ the power of the signal is reduced to half its value. I'll show a brief example to make it clearer.
Suppose that you have a signal whose amplitude is $1 \ \mathrm{V}$. If we reduce its amplitude by $-3 \ \mathrm{dB}$, the new amplitude would be close to $ 0.707 \ \mathrm{V} $.
The power of a signal is proportional to the square of its amplitude. For simplicity, let's assume a resistance of $1 \ \Omega$ on which we are going to calculate the dissipated power. Therefore, originally we would have had a power of $$(1 \ \mathrm{V})^2\cdot\frac{1}{1 \ \Omega}=1 \ \mathrm{W}$$
But after the reduction, we have a power of
$$(0.707 \ \mathrm{V})^2\cdot\frac{1}{1 \ \Omega}=0.5 \ \mathrm{W}$$
The power has decreased to half its original value. That is why the $-3 \ \mathrm{dB}$ point is commonly used to characterize frequency-related properties.
Comment: Is half-power some sort of minimum guarantee for signal pass through the passband (in case of filter)?

There are other choices but half-power is widely used? Why the design at half-power?
Comment: @jomegaA It actually depends on what your requirements for your filter are. There has to be some criteria to inform what the bandwidth is, and half-power seems an easy-to-remember choice. There is no actual reason behind it, it's just a convention. IMHO, it is a good choice for manufacturers because 1) it makes their products seem "better" (the bandwidth would be reduced if we chose, for instance, -1 dB as cutoff point) and 2) it would be unacceptable (to me) to say that a frequency such that the power is less than half its original value is inside the bandwidth.
Answer: As an addition to Tendero's answer, it is mathematically simpler to define the bandedges as the -3.01 dB or "half-power" frequencies.  The simplest example is a first-order low-pass filter:
$$ H(s) = \frac{1}{1 + \frac{s}{\omega_0}} $$
The frequency response is obtained by substituting: $s \leftarrow j \omega$ .  Then
$$ H(j \omega) = \frac{1}{1 + j \frac{\omega}{\omega_0}} $$
Then the power spectrum of the frequency response is the magnitude-square of the frequency response:
$$\begin{align}
 \Big| H(j \omega) \Big|^2 &= \left| \frac{1}{1 + j \frac{\omega}{\omega_0}} \right|^2 \\
\\
  &= \frac{1}{1 +  \left(\frac{\omega}{\omega_0} \right)^2} \\
\end{align}$$
You can see that when $\omega = 0$ (or DC), the power gain is $\big| H(j 0) \big|^2 = 1$ which is the peak gain.
And when $\omega = \omega_0$, the power gain is $\big| H(j \omega_0) \big|^2 = \frac12$ which is half the peak power gain.  When $s$ is normalized by $\omega_0$ in the first-order low-pass filter, then $\omega_0$ is the half-power frequency.
Answer: Another source of the 3(dB) rule-of-thumb is that is how far two targets/signals/sources must be separated in order for the human eye to distinguish between the two. For example, if you have two rectangle functions, the edge of one must be past the -3(dB) edge of the other for them not to look like one single rectangle function.

Why we measure bandwith at -3dB?


Where can I find a good CAML tutorial?

Question: I am just starting to get my feet wet with SP Foundation 2010, and need to customize some web parts. I am looking for some CAML tutorials that go beyond what's on the MSDN site, and also include the SP configuration considerations to run various queries. I'm particularly interested in learning more about integrating JavaScript with CAML...I've heard that it can be done, but don't know to what extent, and have not seen any relevant samples. Suggestions?
Comment: A broad question like this must be made community wiki (if allowed)
Comment: @Anders Have the moderators made community-wiki available to OPs? According to meta, authors can't make something community wiki.
Answer: Have a look at this tutorial. Hope this will help you in learning the CAML query basics.
CAML Query tutorial for SharePoint
Answer: On MSDN you find a nice intro here:
http://msdn.microsoft.com/en-us/library/ms426449.aspx
Answer: This one was helpful  - Writing CAML Queries For Retrieving List Items from a SharePoint List and is fairly comprehensive.
Comment: It's been a few years - try this link:
http://mossknowledge.blogspot.com/2012/07/writing-caml-queries-for-retrieving.html
Comment: broken link... the link will not work!
Answer: You can also use the U2U CAML Builder.
Comment: We  require relevant answers and disclosure of any affiliation with  products or websites. Please see [May I promote products or websites I  am affiliated with here?](http://sharepoint.stackexchange.com/faq#promotion) for guidelines. Better still, just link to the original source rather than via your blog.

Where can I find a good CAML tutorial?


Group policy lock screen is not updating when the picture changes

Question: I have a group policy that looks in C:\background\defaultBackground.jpg for the lock screen.  When I set the policy and did a gpupdate, restarted, logged in, and then logged back out the picture was there.  However, when I changed the picture it is not updating.  Does anybody have some insight as to why?
Answer: Is this Windows 10 Pro?  And is this Windows 10 v1607 or later (the Anniversary Update)?
The lock screen policy now only works in Enterprise or Education SKUs.
https://technet.microsoft.com/en-us/itpro/windows/manage/group-policies-for-enterprise-and-education-editions
Answer: My guess is because this is a computer setting and isn't applied at logon/logoff of the user but at computer startup or at the GP refresh interval. My guess is that you changed the image and then logged off and on and expected the image to change.


New Hosting - Blank Page in Wordpress

Question: The organisation that hosts our Wordpress site (a Church Diocese) is migrating all their sites to a new host by moving the full cPanel configuration across. Our Wordpress site seems to have migrated OK with the exception of CiviCRM. When I access the CiviCRM menu in the Wordpress backend all I get now is a blank page.
Any ideas as to where I should look to resolve this problem?
Thanks for any help/hints.
Answer: Blank page normally suggests a PHP error, so your error logs are a good place to start.

New Hosting - Blank Page in Wordpress