|
What algorithm can I solve this pensions problem?
A Company's Net Income(NI) is to be distributes to members based on their monthly contributions(MC) and a common rate(R)and a variant power(P) where P is n/12 and n is the month.
The equation is
I=((((1+R/100)^P)-1)*MC) where I is interest for a particular month.
Hence NI=i1+I2+I3+.....In
How can I find the unknown which is the Rate R?
I really need your help
Thanks
|
|
|
|
|
Surely the rate (R) needs to be set in advance by the fund's trustees. Or am I totally misunderstanding the issue?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I agree with you, this thing might be impossible.
This is the scenario, the client has Net Income that it wants to distribute to members based on an unknown Rate such that the sum of all the Interest earned on month contributions will sum up to this Net Income.
Thank You
|
|
|
|
|
It's some years since I did formulae like this so I am afraid the best I can suggest is to take a look here[^] for some possible suggestions.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
when there isn't a closed formula yielding the variable you want, all you can do is create an iterative approach. Basically come up with an initial guess R1, calculate how wrong the outcome is, say F1 = NI1 - NItarget, then use a new guess R2, calculcate F2, etc. until it is sufficiently accurate. An appropriate iteration scheme is offered by the Newton-Raphson algorithm (Google it).
|
|
|
|
|
Solve for December to get rid of P? Or sum the year? Or do I grossly misunderstand?
Tadeusz Westawic
Sum quid sum.
|
|
|
|
|
Anyone know of an efficient algorithm for calculating contours / isolines from either regular or irregular elevation data? Preferably one that results in a definition of points per contour (i.e., a polyline representing a contour line).
Cheers!
|
|
|
|
|
I've got a simple and fast one for colouring in a contour line on a bitmap, but that may not suit your needs. Essentially it goes
for x = 0 to xmax
for y = 0 to ymax
if (CI(x,y) > CI(x-1,y) || CI(x,y) > CI(x+1,y) || CI(x,y) > CI(x,y-1) || CI(x,y) > CI(x,y+1))
set_line_colour(x,y);
where
int CI(int x, int y)
{
return (int)(altitude[x,y] / contour_interval);
}
If this is any good to you, it's yours. You'll need to clean up edge effects.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
|
Hi
I am looking for C# code for Present Value, Future Value and Interest Rate of Return calulation similar to what is offered in Excel. I have found some basic examples but i am looking for a library that has handled most of the senarios. Can anyone point me in the right direction?
Life is what happens while we are making other plans
|
|
|
|
|
The formulas for PV, FV, IRR are well documented, and can be implemented in the language of your choice. If you want a library, then you are not interested in formulas and algorithms, and hence you asked in the wrong forum. Anyway, I don't know a ready-made solution, when I need something like that, I write some code.
|
|
|
|
|
Hi Luc
Sorry if this is the wrong forum. Incase it is here are the 2 formulas i am working with, need to check which one is correct. As you can see I calculate pv differently in both
1. double rate = 6.00;
int nper = 20;
double pmt = 2456.53;
double v; // discount factor
double pv;
rate = rate / 100;
v = Math.Pow((1 + rate), -nper);
pv = pmt * ((1 - v) / rate);
return pv;
2. double rate = 6.00;
int nper = 20;
double pmt = 2456.53;
double v;
double pv;
rate = rate / 100;
v = Math.Pow((1 + rate), -nper);
pv = pmt * v;
return pv;
Thanks, David
Life is what happens while we are making other plans
|
|
|
|
|
as the two results are dramatically different, it should be obvious that at least one is completely wrong for your purposes. Whether the other one fits, depends on the problem at hand. You have chosen not to explain anything, I can't help any further.
|
|
|
|
|
I'm writing an in-house system that goes a bit further than this, and have been patterning much of my model from
QuantLib[^]...
It's in C++ and a real headache to compile, but I've been taking the pieces I need and porting them to C# (Sorry, can't release my ported code)... Works pretty well, but might be overkill for your purposes, depending on what you're trying to accomplish.
|
|
|
|
|
I've probably been staring at this far too long but I can't find an algorithm that will return the correct results for the code below. Anyone have some fresh ideas?
private void Test()
{
Logic(false, false, false, false, false, false, false);
Logic(false, false, false, false, true, true, true);
Logic(false, false, false, false, true, false, false);
Logic(false, false, true, false, true, true, false);
Logic(false, false, true, true, true, true, true);
}
private void Logic(bool f, bool fl, bool d, bool dl, bool r, bool rl, bool expected)
{
bool result = [What algorithm goes here];
System.Diagnostics.Debug.Assert(result == expected, "Does not match expected results");
}
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: bool result = [What algorithm goes here];
I can not possibly tell you what the name is of what you want. What do you want? What fits there is a logic expression, probably one involving the object's state (no "static") and/or the input parameters.
BTW: it looks like a function, but doesn't return anything. A more natural set-up would be:
private void TestAll()
{
Test(false, false, false, false, false, false, false);
Test(false, false, false, false, true, true, true);
Test(false, false, false, false, true, false, false);
Test(false, false, true, false, true, true, false);
Test(false, false, true, true, true, true, true);
}
private bool Test(bool f, bool fl, bool d, bool dl, bool r, bool rl, bool expected)
{
bool result=Logic(bool f, bool fl, bool d, bool dl, bool r, bool rl);
bool OK=result==expected;
System.Diagnostics.Debug.Assert(OK, "Test failed: "+f+f1+d+d1+r+r1+result+expected);
return OK;
}
private bool Logic(bool f, bool fl, bool d, bool dl, bool r, bool rl, bool expected)
{
bool result = ???;
return result;
}
Assuming you meant a static function, one possible expression fitting the test vectors is:
bool mf = f==f1;
bool md = d==d1;
bool mr = r==r1;
bool result=mf && md && mr && (f||d||r);
but there are many more. In fact, your Logic function seems to have 64 different input combinations, each leading to some result, and only 5 test vectors have been defined, so 59 cases are undefined. If no (easy) expression is available, you can always implement a table look-up.
|
|
|
|
|
I know I didn't supply all of the possible cases (too much typing and I'm a lazy developer )
It turned out to be a little simpler after I realized the variables are paired. For instance, if f == false then fl must also be false, same for d and dl, and r and rl.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I'll need a complete truth table, unless all other entries are "don't care" (which I'll assume for now)
How about r && rl && (dl == d) ? I know it may seem lame, but it fits your specifications..
edit: lameness fixed. I just woke up..
|
|
|
|
|
Thanks, works perfectly. As I said I was starting at problem too long. Can't see the forest for the trees.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You're welcome
|
|
|
|
|
Try:
bool result = expected;
|
|
|
|
|
Hi Mark,
there's this Karnaugh logic maps, which are actually the normal way you'll solve such problems
cheerz
nas
|
|
|
|
|
Really? And to think I spent hours wasting my time doing it with a stone and chisel
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
IMO Karnaugh maps aren't very useful. They can't cope with medium or large problems (how many times have you drawn Karnaugh maps with 6 input variables?) and they aren't very useful at solving small problems, as you just don't need them. The one thing they do well is visualize how minterms can be formed, but once you saw the principle, you don't need a graphics tool any more.
|
|
|
|
|
Luc Pattyn wrote: Karnaugh maps aren't very useful
That's why you have Quine–McCluskey algorithm. You can easily implement it in any language and it always works regardless of number of inputs.
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|