Home loan calculation formula (algorithm)? - algorithm

How a bank calculate home loan's payments?
For example,
$1,000,000 at 5.00% over a 25 year period.
Monthly payment: $5,845.90
Current Payment To Date
Payment -------------------------- ----------------------------------------------
Number Interest Principal Interest Paid Principal Paid Balance
1 $4,166.67 $1,679.23 $4,166.67 $1,679.23 $998,320.77
2 $4,159.67 $1,686.23 $8,326.34 $3,365.46 $996,634.54
3 $4,152.64 $1,693.26 $12,478.98 $5,058.72 $994,941.28
4 $4,145.59 $1,700.31 $16,624.57 $6,759.03 $993,240.97
5 $4,138.50 $1,707.40 $20,763.07 $8,466.43 $991,533.57
6 $4,131.39 $1,714.51 $24,894.46 $10,180.94 $989,819.06
7 $4,124.25 $1,721.65 $29,018.71 $11,902.59 $988,097.41
8 $4,117.07 $1,728.83 $33,135.78 $13,631.42 $986,368.58
9 $4,109.87 $1,736.03 $37,245.65 $15,367.45 $984,632.55
10 $4,102.64 $1,743.26 $41,348.29 $17,110.71 $982,889.29
I'm trying to do same calculations in Excel, but I get another numbers...

The algorithms are well shown and discussed here (in Javascript) -- implement exactly the same algorithms in Excel's VBA, Javascript, Ruby, whatever, and you'll get pretty much the same results!-)

the magic words are amortization schedule.

The difference you see in Excel is probably to do with the way the compound interest is calculated. Most banks add compound interest daily (gets them more money).
The wikipedia article has a nice example of the equation used by US banks. You can code that up.

Related

Is Visual Studio Subscription (earlier MSDN suscription) per user?

I have just going through https://visualstudio.microsoft.com/vs/pricing/ and found the prices to be 45 $/ month or 1199 $/year for Professional subscription. Is this cost per user? if so, do I need to purchase 100 subscriptions (4500 $ / per month!) for 100 developers in my company?
It's per user. It's better described on the following page:
https://visualstudio.microsoft.com/vs/pricing-details/
I'm just looking for the same and you can be glad to have a price tag of $1199 - to me as single user located in Germany this turns into 1540€ on check-out, that would be $1813. VAT is only a small share of that difference.
Btw, the fee is for the first year, renewal will be relatively cheaper.
With your larger number of seats, you should also investigate the SKU 77D-00092 and 77D-00095 respectively. As I see them advertised in various places these still come with two years of MSDN subscription rather than the one year offered on the MS web site, also at a lower price. Maybe they are missing bundled Azure credits? Those SKUs appear to require an "Open License" plan with at least 5 seats - that's as far as I got.

From monthly to yearly data in TraMineR

I am using TraMineR for a while now and I have a question regarding changing the time granularity of my sequences. At the moment I have my sequences aligned on months, but for several reasons I would like to change this to years. I would like to use the longest spell in each year as the state for that particular year. In other words, if somebody was cohabiting for 4 months and then got married and stayed married for the other 8 months in the year 2000, I would like to code that person as being married in 2000. I was wondering if there is an easy way to do this with TraMineR.
Thanks in advance,
Tom
The seqgranularity function from the TraMineRextras package aggregates each successive subsequence of length tspan into a single state. In its stable version on the CRAN two aggregation methods are proposed: "first" or "last" that replace the sequence over the period with respectively the first and last state in the period.
The option you are looking for, i.e., replace the period with the most frequent state, is currently in test in the development version of TraMineRextras available from R-Forge. The argument is method="mostfreq"
Here is an example where we aggregate monthly data into yearly data:
library(TraMineRextras)
data(mvad)
mvad.seq <- seqdef(mvad, 17:86)
mvad.seq2 <- seqgranularity(mvad.seq, tspan=12, method="mostfreq")
par(mfrow=c(2,1))
seqiplot(mvad.seq, withlegend=F)
seqiplot(mvad.seq2, withlegend=F)

Xpath text extraction between 2 keywords

Is there an xpath expression that return the text available between 2 keywords?
For example we have a span like the following:
<b>Specialty: </b>PO<br/><b>Job Function: </b>RN<br/><br/><b>Qualifications/Duties</b><br/>Texas Health Presbyterian Allen is currently in search of a Registered Nurse to help meet the growing needs of our Day Surgery Department to work PRN in Day Surgery and also float to PACU.<br/><br/><b>Basic Qualifications:</b><br/><br/>*Graduate of an accredited school of nursing<br/>*Valid RN license in the state of Texas<br/>*BLS<br/>*ACLS<br/>*PALS within 6 months of hire<br/>*Minimum of 1 - 3 years experience as RN in Day Surgery, PACU, Outpatient Surgery, or ICU<br/>*Strong organizational skills and ability to function in a fast paced work environment<br/>*Ability to accept responsibility and show initiative to work without direct supervision<br/>*A high degree of confidentiality, positive interpersonal skills and ability to function in a fast-paced environment<br/><br/><b>Preferred Qualifications:</b><br/><br/>*Three years RN experience in Outpatient Surgery along with some ICU experience.<br/>*PALS<br/>*PACU , Endoscopy or Ambulatory setting<br/>*IV Conscious Sedation<br/><br/><b>Hours/Schedule:</b><br/><br/>*Variable<br/><br/>J2WPeriop<br/><br/><b>Entity Information</b><br/>Texas Health Presbyterian Hospital Allen is a 73-bed, acute-care hospital serving the northern Collin County area since 2000. Hospital services include women’s care, a Level II neonatal intensive care unit, orthopedics, pediatrics, wound care and sleep medicine. Texas Health Allen, a Pathway to Excellence® designated hospital by the American Nurses Credentialing Center, has more than 500 physicians on its medical staff practicing in more than 25 specialties. Texas Health Allen is a World Health Organization-designated "Baby-Friendly Hospital" and was the first hospital in Texas to receive the distinction. The hospital is a Level IV trauma center and an Accredited Chest Pain Center by the Society of Chest Pain Centers, which makes our facility intensely qualified to serve our community and your professional aspirations.<br/>
I would like to know if we can define an xpath to return all the text that is available between 2 keywords say "Qualifications/Duties" and "Entity Information"
Yes, but don't expect a nicely formatted output, the markup is messy and the expression might need some slight tweaks for whether you also want the nodes with "Basic Qualifications:" or not (this version skips them, it only takes "naked" text nodes).
//text()[preceding-sibling::*[text()='Qualifications/Duties'] and following-sibling::*[text()='Entity Information']]
And it means:
//text()
SELECT EVERY TEXT NODE
[
THAT
preceding-sibling::*[text()='Qualifications/Duties']
IS PRECEDED BY A NODE WITH TEXT = "Qualifications/Duties"
and following-sibling::*[text()='Entity Information'
AND FOLLOWED BY A NODE WITH TEXT = "Entity Information"
]
the output for your example:
Texas Health Presbyterian Allen is currently in search of a Registered Nurse to help meet the growing needs of our Day Surgery Department to work PRN in Day Surgery and also float to PACU.
*Graduate of an accredited school of nursing
*Valid RN license in the state of Texas
*BLS
*ACLS
*PALS within 6 months of hire
*Minimum of 1 - 3 years experience as RN in Day Surgery, PACU, Outpatient Surgery, or ICU
*Strong organizational skills and ability to function in a fast paced work environment
*Ability to accept responsibility and show initiative to work without direct supervision
*A high degree of confidentiality, positive interpersonal skills and ability to function in a fast-paced environment
*Three years RN experience in Outpatient Surgery along with some ICU experience.
*PALS
*PACU , Endoscopy or Ambulatory setting
*IV Conscious Sedation
*Variable
J2WPeriop

how to read file in cucumber

I'm a newbie to cucumber. I've the following scenario that I want to code in cucumber:
Feature: Withdraw Fixed Amount
The "Withdraw Cash" menu contains several fixed amounts to
speed up transactions for users.
Scenario Outline: Withdraw fixed amount
Given I have <Balance> in my account
When I choose to withdraw the fixed amount of <Withdrawal>
Then I should receive <Received> cash
And the balance of my account should be <Remaining>
Examples:
| Balance | Withdrawal | Received | Remaining |
| $500 | $50 | $50 | $450 |
| $500 | $100 | $100 | $400 |
I 'd like to read the data (Examples:)from a file like this:
$500;$50;;$50;$450
$500;$100;$100;$400
I'm not sure if I can read data from cucumber's feature file or in the step definitions. Could someone please shed some lights on this? Many thanks!
No it's not possible to 'generate' scenarios in Cucumber. Each row in your example table runs as an individual scenario, and Cucumber must know up-front which scenarios are to be run.
That said, there are 2 possibilities, I'd consider both to be quite unattractive:
Write the entire scenario in code in a single step def e.g.:
Scenario: Withdraw fixed amount
Given withdrawing should work correctly
#steps.rb
Given /^withdrawing should work correctly$/ do
# Read values from file
# For each row in the file, do everything the scenario would do
end
This works but will have the serious drawback of revealing nothing about the behaviour of the system through the Gherkin feature.
Code gen the feature file. Use a templating language such as ERB to transform a feature file, inserting whatever example rows are necessary, as a task which occurs before running Cucumber. Effective, but at the cost of a LOT of complexity.
In both situations you're removing the numbers from the feature file, which immediately negates its function as a central source of documentation, readers would have to refer back to the 'numbers' file in order to figure out the actual behaviour of the system.
What you requested is overkill. Examples are here to help you identify possible cases in clear format, but not for mass data handling.
Each row in Examples should be meaningful otherwise you are wasting resources.
For example. With $100 balance, withdrawal of $20 should leave $80. But $20 may be a hardcoded number, so you need one more case to verify that, say withdrawing $30.
The ATM system may have a daily withdrawal limitation of $1000. So, if you ask for $1200, the system should only give you $1000. You need another row to test that.
Every case above is meaningful. And I don't think there are so much cases that you need a CSV file to handle it. Manual typing is good enough.

Barcode Encryption of Personal Identifiers (or alternatives suggested by you)

I am trying to create a health application of a rather sensitive nature which will require some form of cryptography/obfuscation. There is a health study in which once a year, known individuals with permanent and recognisable identifier numbers (eg KIG0005001 as an individuals identifier) walk into the clinic, are identified, have their blood tested as part of a study. Next year, the same happens again, as this is a longitudinal study. Now the results of the blood test should NOT be able to be traceable to an actual individual (HIV status, etc are highly sensitive bits of information that should not be linkable with actual individuals due to their right to privacy), but it is IMPERATIVE that we can identify year on year which blood samples belong to one unique individual (without knowing WHO the individual actually is, the emphasis is on the blood samples being traceable to one individual, not the individual).
My idea (and here is where am asking for your expertise in cryptography and obfuscation) is that when the individual visits the clinic they come with an identifying card with their regular id number KIG0005001 . This number is entered into a system where via an algorithm/encryption it spits out a barcode (based on the original id KIG0005001 , therefore any future visits should produce the SAME barcode for a particular individual) which can be printed out as stickers. These barcode stickers are the ones to be used to identify the samples (stick em on the samples). The stickers should have the following information in them: unique identifier (via barcode?), the round number that the sample was taken (samples will be taken once a year, so year 1= round 1) and date sample taken.
Is this possible? What are the alternatives? How/What should I do in terms of transforming KIG0005001 into an encrypted barcode which is repeatable year on year (so blood sample can always be traced back to the same source). Am programming in Java.
Thanks in advance,
Tumaini
To answer this question, I don't think it needs to be in the barcode section.
First of all, there is no way to keep everything 100% secure... but you can make it more complicated to be understood by a human.
It's the same thing as the passport controversy... A biometric passport must be secure: it's not possible to read the information without knowing the "private key". But let's say you read and record everybody's passport that enters your store and save it to a database. You will be able to trace who is coming back and even what they previously bought since you have their passport's ID...
To make the life harder for your employees, you need to generate an ID that will match the real person's ID. So if the employee is testing the blood of KIG0005001, they will receive a different unique ID for that day; the computer will know how to link them up. So that your employee has no idea who is this number at that moment...
Cryptography is probably useless here since you work with IDs. Even a gibberish data repeated multiple time is still an ID.

Resources