Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I have this function with R.
immediate.amput.EV <- function(Dead.prob=.010,Dead.cost=40000,Alive.prob=.0990,Alive.cost=50000,high=100,p.payoff=1) {
return((Dead.prob * Dead.cost) + (Alive.prob * Alive.cost))
}
immediate.amput.EV()
It's supposed to output : (0.010 * 40000) + (0.990 * 50000) = 400 + 49500 = 49900
Instead it gives me: 5350
Could you please tell me why?
Thanks..
As Brian Hannays says: Change the definition of Alive.prob to 1-Dead.prob. A good programming habit is to try to avoid redundant (and then possibly conflicting) definitions...
function(Dead.prob=.010,Dead.cost=40000,Alive.prob=1-Dead.prob,Alive.cost=50000,high=100,p.payoff=1) {
return((Dead.prob * Dead.cost) + (Alive.prob * Alive.cost))
}
your math is wrong. In your comments, you added an extra 0
400 + 4950 NOT 49500
.01 *40000 =400 and .099*50000= 4950 and 400+4950 =5350
accept the answer or delete your question.
Related
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 days ago.
Improve this question
I'm new to solving big -O and analysis questions and I'm slightly confused on this problem. excuse me if my math is wrong but f(n) <= Cg(n) in this case n(2^n) = f(n) and 2^2n = g(n)
boiling it down I get n/2^n <= C after working it out.
im lost on how to find n0 and C, I assume n0 is 1 as it is usually the case, but im uncertain of C, i assume its 2 but im not sure how to show so.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 3 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I'm getting this compile warning:
this expression will fail with ArithmeticError
from this code:
#seconds 300
#to_millis 1000
#seconds * #to_millis
I tried adding:
#seconds 300
#to_millis 1000
if is_integer(#seconds) and is_integer(#to_millis) do
#seconds * #to_millis
end
is the problem that it could overflow? What is the correct way of handling this?
* EDIT *
In my actual code, these variables are coming from config files - something with the config is wrong and they are coming back nil so that is the problem. I think this can be closed since it's not an elixir problem
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I have found this formula for computing Pi value:
But I need to compute only(for example - 1000th) number of Pi value. How I can do it with provided formula?
Thanks.
What you want is called a "spigot algorithm". Take a look at [1] in the section "BBP digit-extraction algorithm for pi". Good luck and have fun.
[1] http://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I need to find limit sqrt((3x-1)/(x+2)) when x->infinity
Can anyone help me please?
The answer is sqrt(3):
As x gets very very big, the degree 0 terms (-1x^0 and 2x^0) grow insignificant thus leaving:
sqrt(3x/x)
As you can see this reduces to:
sqrt(3)
And this is no longer affected by x and is, then, the answer.
Note
Math questions are best suited on Stack Exchange's Math page.
mjgpy3 deserves credit for his correct and elegant explanation.
But I'll offer you Wolfram Alpha as a way to answer these for yourself without having to ask here:
http://www.wolframalpha.com/input/?i=limit%20%20sqrt((3x-1)%2F(x%2B2))%20%20as%20x-%3Einfinity
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
in model casio fx-82ms i must do some scientific calculations with logaritm functions but the calculator calculates all problem base of ten(10) but i need base of two.
anyone can help me?
Always remember, you may use the natural logarithm to solve for any base: i.e., for any arbitrary base b, the logarithm of x to the base b is: ln(x)/ln(b)
/Try it!
Convert between bases:
http://www.equationsheet.com/eqninfo/Equation-0043.html
You can convert a log of x in base a to log of x in base b, divide by the log of a in base b.
This could be better answered on the math site, but is easy enough to just answer here.