I'm not sure how floating point are represented in C, and how much of a precision someone could get. In a c source file, I have the macro:  #define NUMBER 123.367   In the main function there are these 2 instructions:  float x = NUMBER; printf("x is %f\n", x);   When I run it, I get:      x is 123.366997   Which is quite close to 123.367, but it kinda messes the purpose of the program. Is there any way to round up x to the desired value? Or is this a flaw of floating point arithmetic-representation that can't be fixed?
Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
derivative of cost function for Logistic Regression I am going over the lectures on Machine Learning at Coursera.   I am struggling with the following. How can the partial derivative of   $$J(\theta)=-\frac{1}{m}\sum_{i=1}^{m}y^{i}\log(h_\theta(x^{i}))+(1-y^{i})\log(1-h_\theta(x^{i}))$$  where $h_{\theta}(x)$ is defined as follows  $$h_{\theta}(x)=g(\theta^{T}x)$$ $$g(z)=\frac{1}{1+e^{-z}}$$  be $$ \frac{\partial}{\partial\theta_{j}}J(\theta) =\sum_{i=1}^{m}(h_\theta(x^{i})-y^i)x_j^i$$  In other words, how would we go about calculating the partial derivative with respect to $\theta$ of the cost function (the logs are natural logarithms):  $$J(\theta)=-\frac{1}{m}\sum_{i=1}^{m}y^{i}\log(h_\theta(x^{i}))+(1-y^{i})\log(1-h_\theta(x^{i}))$$ Does the Lunatic Cultist spawn on iPad? I was searching for more answers on the internet. I kept searching, and I found one thing that help me a little. I went back to Terraria and tried it out, but the Lunatic Cultist didn’t spawn.  Does the Lunatic Cultist spawn on an iPad? Storing the original document class page layout with geometry Is it possible, using the geometry package, to store (and restore) the original layout specified by the document class (in my case, the class is report)?    Here is some context.  I have been editing a long document in the default page layout for the report document class.  Now I found out that I need a title page.  There is a particular title page layout, and in fact, it works perfectly if I just load the geometry package with its default and change just two settings.  But then I want the rest of the document back in the original page layout!  I can't do something like \restoregeometry, since I think geometry just overrides the class options... i.e. there doesn't seem to be anything to restore.  Similarly, it seems I can't use \savegeometry or \loadgeometry.  So how can I get back to my original layout for the rest of the document without painstakingly hard-coding in all of the specific page layout variables?    Here is a minimum working example:   \documentclass[a4paper,10pt]{report}  \RequirePackage[a4paper,dvips]{geometry} % g1 \geometry{top=2.5cm,bottom=2.3cm}        % g2  \begin{document}  \input{the_title_page}  \SomeGeometryCommandsHere  % g3  \input{the_rest}  \end{document}   If I run the above code with the lines labeled "g" commented out, then the title page does not have the correct page layout, but the rest of the document is formatted perfectly.    If I leave lines g1 and g2 uncommented, then the title page has exactly the correct layout, but no matter what I put for g3 (e.g. \loadgeometry, \restoregeometry, etc.) I can't recover the original layout that I had when g1 and g2 were commented.  Of course, I could completely specify the original layout exhaustively in line g3, and this should in principle work.  However, I spent almost one hour on this last night and when I still couldn't get it formated correctly I decided I really needed a smarter solution. $\newcommand{\P}{\mathbb{P}}$Is it valid to interpret $\P(B|A)$ as "infinite probability" when $\P(A) = 0$? Using modulo operation to draw graph I currently have a Yongnuo YN560-TX trigger and a Yongnuo YN-560 Mark III. I would like to get a iTTL flash that also works with remote triggering.  How compatible are are different flash brands (Neewer, Yongnuo, etc.) when it comes to things like setting zoom, etc. ? I followed  to create a soccer ball.  Now I want to texture it in a way that every pentagon has an image inside itself and the exagons are white, but I also want everything to be a little glossy. I managed to successfully UV Map the ball and paint the texture in photoshop but now I am having big problems in applying the texture material to the mesh.    I've created a new material in Blender Render mode with Diffuse and the texture applied to it. I also set the Texture mapping to UV. I've gone in edit mode, selected all the mesh and applied the material. Unfortunately in Texture View Mode I see just a white ball and while rendering I see everything's black.      If I try to do this in Cycles Render and use a Mix Shader with the FAC set to the texture image I get what I want in the Texture View Mode but while rendering I just see everything black and white of my colored images.        I hope I've been clear enough and that someone will help me in this easy/difficult task! Thank you in advance How to use resistors? I have a power supply of 5 volts @ 1A. I want to reduce the current from 1A to 250mA. Which resistor should be use?   I tried this equation(Ohm's Law):  R = V / I  = 5/(0.75)  = 6.66 Ohms.  I tried the 6.66 Ohm resistor but it only reduce few mili Amps. "No, I didn't see him" vs "Yes, I didn't see him" Bob didn't come to office today.  I was asked "Didn't you see Bob today?"  Should I say "Yes, I didn't see him today" or "No, I didn't see him today"? Finding integer solutions for $6x+15y+20z=1$ Problem: Find integers $x$, $y$, and $z$ that satisfy the equation $6x+15y+20z=1$.  I noticed that $\gcd(6,15)=3$, $\gcd(15,20)=5$, and that $\gcd(6,20)=2$. And of course $\gcd(6,15,2)=1$.   Of course I know to set one of the variables (x, y, or z) to be zero. But I want to know how to get the more trivial answers. But where do I go from here to find the solutions? Can cited works hold grammatical positions in sentences? Though I read this style quite often, I was recently told unambiguously by a reviewer that I was NOT supposed to use citations "as if they are objects in a sentence."  The following sentence is an example of what the reviewer considered unacceptable:       We analyzed the data using the Wilmerding method, guided by [12].   The references section might include the following:      [12] Smith, D., Marshawn, J., &amp; Devenshaw, A. 2011. Techniques and   Procedures for Applying the Wilmerding Method.  Prince Publications,   Inc, New York, NY.   The Wilmerding method1 is not a step-by-step algorithm that can be precisely followed as if by a machine, and thus [12] does not provide a step-by-step algorithmic description but rather guidance for using  the method. [12] is a relatively slim but authoritative textbook about how to use the Wilmerding method.  Within this question, for the purpose of discussion, I have intentionally put [12] in grammatical positions where it's an important element of the sentence and the sentence would make less sense without the reference.  Sometimes that seems to be the most efficient way to communicate the intended message.  Is using a reference as a grammatical sentence element like this OK?   Why might this not be considered acceptable?   Should I be rewording those sentences?  Is it enough of a violation to be worth passing the note on to authors of papers I review?   I considered posting this on  but it seems more specific to academia than general English usage, and the comment came from a content reviewer rather than a copy editor.   is related but it seems to be more about when to put authors names' in vs. outside of the parentheses in an APA-like style.   The numbered citation style (as opposed to following APA, for example) is required by the venue.  1: Fictionalized for the purpose of this discussion What is $\Delta t$ in the time-energy uncertainty principle? In non-relativistic QM, the $\Delta E$ in the time-energy uncertainty principle is the limiting standard deviation of the set of energy measurements of $n$ identically prepared systems as $n$ goes to infinity. What does the $\Delta t$ mean, since $t$ is not even an observable? What am I doing wrong? Joint Density of sum of random variables! So, I have this question:    And, what I have tried so far is I let $z_1 = \frac{X + Y}{2}$ and let $z_2 = \frac{X - Y}{2}$ to use change of variables for this question. However, when I work this out and plug it into my joint distribution of $X$ and $Y$ above, I end up with the $z_2$ disappearing and only having $z_1$ left in my joint distribution of $z_1$ and $z_2$. So, then when I go to find the marginal for just $z_1$ (which is $\frac{X + Y}{2}$ &lt;- what I am looking for), there is no $z_2$ therefore, integrating wrt to $z_2$, I get $z_2$ just come up (integral of 1). This is an issue because the bounds are from 0 to $\inf$. Obviously, I can't have infinite in my marginal density so what am I doing wrong?   Also, for question 5, I work it out similarly except I let $z_2 = X$ but I just end up with the exact same density as $f_{x,y}$ as seen in question 4 - is that normal? Please help, I been doing this question for a long time trying various dummy transformations.  Also, for question 4, I found the marginals of $x$ and $y$ and realized that the independence consequence (of the product being equal to the joint) is satisfied but using convolution, I get the same issue of my integral coming out to infinite! Thank you for all the help!   EDIT: Am I doing my bounds wrong? the bound for z_2 is from 0 to inf or 0 to z_1? diff a ruby string or array How do I do a diff of two strings or arrays in Ruby? How to combine bold and "code sample" in Markdown? How can I make a word in a code sample bold? I only see asterisks around the expected bold text.  sample **sample** sample Why do I see different versions of node and nodejs I ran the following commands to install the stable version of node  sudo npm cache clean -f sudo npm install -g n sudo npm install -g n   Now, when I run node -v, I see v10.0.0, whereas nodejs -v returns v4.2.6. As far as I'm aware, node and nodejs are the same thing. Why am I seeing this? Thanks. High-end compact camera with swivel screen and running on AA batteries I'm looking for a new compact camera that:   has a  is small enough to be mountable on a  and, runs on AA batteries. good flexibility   Requirement (3) stems from the fact that I may be hiking in the wild for weeks on an end, with no opportunity to change a Lithium-Ion battery. If another solution permits me to take thousands rather than hundreds photographs on full charge, I may consider that as well.  Additionally, it would be nice (but not essential) to have:   the ability to handle high dynamic range a viewfinder physical buttons — I live in a cold climate, and don't like to use touch-screens   The upper price range for compact models is still good for me, and I don't mind a pricerange of €400–€800 (but I don't mind cheaper either, if still of good quality).  I've been the happy user of several models in the , but now my PowerShot A650 IS has died. Starting from , it seems requirement (3) kills of many cameras: the , (might also fail (2)), the , the , the ... Although enough models meet requirements (1), (2), and (4), as well as the (non-essential) additional features I listed, it seems in the past 5 years, cameras have moved away from using AA batteries. What camera models still exist that meet my requirements?    Last photograph taken with my Canon PowerShot A650 IS, taking on Christmas Day 2012 in the Caldera de Taburiente, La Palma, Canary Islands, Spain. Assume that given three predicates are presented below: $H(x)$: $x$ is a horse $A(x)$: $x$ is an animal $T(x,y)$: $x$ is a tail of $y$ Then, translate the following inference into an inference using predicate logic expressions and prove whether inference is valid or not (for instance, using natural deduction): Horses are animals.  Horses' tails are tails of animals. My thoughts: I am quite good at translating predicate logic expressions, but here I struggled to come up with formula for Horses' tails. My initial idea was to consider similar sentence such as &quot;w is a tail of a horse&quot; to form required inference, but it was not successful. Would be welcomed to hear your ideas about this task. Weather Resistant Outlets vs Weather Proof Box Every time I open a folder from the desktop, a prompt is shown that the said folder is opened. How do I stop that?