Search Results

Search found 1309 results on 53 pages for 'solving'.

Page 1/53 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to improve Algorithmic Programming Solving skill? [closed]

    - by gaurav
    Possible Duplicate: How can I improve my problem-solving ability? How do you improve your problem solving skills? Should I learn design patterns or algorithms to improve my logical thinking skills? What to do when you're faced with a problem that you can't solve quickly? Are there non-programming related activities akin to solving programming problems? I am a computer engineering graduate. I have studied programming since three years. I am good in coding and programming. I have been trying to compete in algorithmic competitions on sites such as topcoder,spoj since one and a half year, but I am still unable to solve problems other than too easy problems. I have learned from people that it takes practice to solve such problems. I try to solve those problems but sometimes I am unable to understand and even if I do understand I am unable to think of a good algorithm for solving it. Even if I solve I get Wrong answer and I am unable to figure out what is the problem with my code as it works on samples given on the sites but fails on test cases which they do not provide. I really want to solve those problems and become good in algorithms. I have read books for learning algorithms like Introduction to algorithms by CLRS,practicing programming questions. I have gone through some questions but they don't answer this question. I have seen the questions which are said duplicates but those questions focus on overall programming, but I am asking for algorithm related programming, basically for competing in programming which involve solving a problem statement then online judge will automatically evaluate it, such type of programming is quite different from the type of programming these questions discuss.

    Read the article

  • Great Debugging skills weak problem solving

    - by Mahmoud
    For the 5 years I worked for various companies, I worked in large software like computer vision kits, embedded, games. I found myself very good at debuggins skills, I've even found and fixed bugs in frameworks and I solved them. The problem is that I'm very weak at problem solving. I got interview with Qualcomm, and they said you're fine at software, but you have a limited problem solving, I also had the same results with Google. I'm very bad at solving puzzles and brain teasers. During the interviews I solve all of the software related problems on the blackboard, but when I went to the GM and face math problems and probabilities, I struggle. How can I improve my problem solving skills? Edit Some of the problems: A cake that is cut from anywhere and needs just one cut to halved in equal. I told him cut it horizontally, he said No, consider it as a 2D Problem!. Consider a concenteric 3 circles, each one can get a color, but not matched with the other circle, how many blobs you can make out of those circles ? this was with the GM ( Augmented Reality SDK) Consider a train, an infinite one, and you looked at the window, and there are two cars, one big, and one small, what is the probability of having only a big car, I said 50%, he said, what if that two cars you dont know their length, and you want to get the probability of getting the biggest one, I struggled, didn't solve it... I was really exahusted after long day of interviews prob of having a number divisible by 5 in numbers from 1 to 100.. struggled!! All coding questions I solved them like reverse a string, detect a cycle in a linked list,..etc.

    Read the article

  • How does one improve one's problem-solving ability?

    - by gcc
    How can one improve one's problem-solving ability? Everyone says same thing: "a real programmer knows how to handle real problem." But they forget how they learn this ability, or where (I know in school, no one gives us any ability, of course in my opinion). If you have any idea except above ones, feel free when you give your advice solve more problems do more exercises, write code, search google then write more ... For me, my question is like "use complex/known library instead of using your own." In other words, I want your personal experience, book recommendation, webpage on problem solving. Moreover, look your problem-solving method and give us your personal ability as if it is an algorithm

    Read the article

  • How do I improve my problem-solving ability

    - by gcc
    How can I improve my problem-solving ability? Every one says same thing "a real programmer knows how to handle real problem", but they forget how they learn this ability, or where (I know in school, no one gives us any ability, of course in my opinion). If you have any idea except above ones, feel free when you give your advice solve more problems do more exercises, write code, search google then write more ... For me, my question is like "Use complex/known library instead of using your own." In other words, I want your experience, book recommendation, web page on problem solving

    Read the article

  • Flowchart for solving programming problems

    - by nurne
    I noticed that every developer implements a somewhat different flowchart for solving programming problems. By flowchart I mean a defined system of techniques that the developer goes through in a certain sequence, trying to solve the problem at hand. Some examples for techniques: Google "how to..." or "... tutorial". Search the java/msdn/apple/etc API doc for the specific class or method. Search in stack overflow the exact problem with some tags like [iphone]/[java] etc. Take a nap and let the subconscious work. Debug. Draw the algorithm or system. Google the logged error message. Ask a colleague or manager. Ask a new question in stack overflow. From your experience, what is the best flowchart for solving a programming problem?

    Read the article

  • looking for a good programming problem solving tool

    - by ctilley79
    Years ago when I was in school my computer science department used a website that had many different problem solving questions typically used in computer programming. They were ordered in difficulty and you were presented the solution after you attempted the problem. The site was used in competitions and was very useful for training purposes. Since I am trying to brush up on my algorithm skills, a good tool like this would be very useful. Does anyone know of a site similar to this in "modern" times?

    Read the article

  • Solving a probabilistic problem

    - by ????????????
    So I am interested in Computational Investing and came across this problem on a wiki page: Write a program to discover the answer to this puzzle:"Let's say men and women are paid equally (from the same uniform distribution). If women date randomly and marry the first man with a higher salary, what fraction of the population will get married?" I don't have much knowledge in probability theory, so I'm not really sure how to implement this in code. My thinking: Populate two arrays(female,male) with random salary values from a uniform distribution. Randomly pair one female and one male array element and see if condition of higher salary is met. If it is, increment a counter. Divide counter by population and get percentage. Is this the correct logic? Do woman continually date until there is no males left with higher salaries than women?

    Read the article

  • How do one improve him/her problem-solving ability ?

    - by gcc
    How can one improve him/her problem-solving ability? Every one says same thing "a real programmer knows how to handle real problem", but they forget how they learn this ability, or where (I know in school, no one gives us any ability, of course in my opinion). If you have any idea except above ones, feel free when you give your advice solve more problems do more exercises, write code, search google then write more ... For me, my question is like "Use complex/known library instead of using your own." In other words,t I want your presonal experience, book recommendation, web page on problem solving. Moreover, look your problem-solving method and give us your personal ability as if it is an algorithm

    Read the article

  • Are there non-programming related activities akin to solving programming problems ?

    - by julien
    I'm talking about particular activities, for which you can draw parallels with the specific kind of reasonning needed when solving programming problems. Counter examples are activities that would help in almost any situation, like : take a shower or any other, somewhat passive activities, which are only helpful in triggering this sort of asynchronous problem solving our brain does exercise, because you brain simply works better when you're fit EDIT : It seems this question was quite misunderstood. I wasn't asking about what you can do when stuck on a problem but rather, what kind of activities you have in you spare time that you think help you, more or less directly, solving programing problems.

    Read the article

  • What is your unique programming problem-solving style? [closed]

    - by gcc
    Everyone has their own styles and technique for approaching and solving real world problems. These distinguish us from other people or other programmers. (Actually, I think it make us more desirable as programmers and improves computer science) To improve, we read a lot of books; for example, programming style, how to solve problems, how to approach problems, software and algorithms, et al. Can I learn your technique? In other words, if someone gives you a problem, at first step, what are you doing to solve it? I want learn the style in which you approach, analyze, and solve a problem. EDIT: every programmer is a unique instance; each of us approach problems and converge on solutions in our own... idiomatic manner. This manner is sometimes a quirk of training, a bias of tools, but often it is an insightful nugget, a little golden hammer that cracks nuts just slightly faster then others. When answering, give your general approaches but also take a moment to identify how you look at things in ways that your peers do not. Let's call this your Unique Solving Perspective, or USP.

    Read the article

  • How to improve problem solving skills/programming skills

    - by kaibuki
    Hi All, I am new to programming, and have been given many interviews for jobs, but what I lag is the concepts and skills of general problem solving not respect to any particular programming language. are there any books or material available which can help me upgrade my programming skills. looking forward for you guys to share your views. Thanks a millions.. Kai

    Read the article

  • Can someone recommend a resource/site/book to improve problem solving skills

    - by kjm
    I am a reasonably experienced developer (.NET, c#, asp.NET etc) but I'd like to hone my problem solving skills. I find that when I come up against a complex problem I sometimes implement a solution that I feel could have been better had I analyzed the problem in a different way. Ideally what I am looking for is a resource of some type that has 'practice problems and solutions' as I think my skills will only get better by practicing this more and adopting better practices. I hope my question is not to vague and I wont get upset with people answering with opinions etc.. thanks

    Read the article

  • Solving a math problem/expression, which is a string, in PHP

    - by Koning WWWWWWWWWWWWWWWWWWWWWWW
    The user can enter a math problem (expression) like 5 + 654, 6 ^ 24, 2!, sqrt(543), log(54), sin 5, sin(50). After some reformatting (e.g. change sin 5 into sin(5)), and doing an eval, PHP gives me the right result: $problem = "5 + 5324"; eval("$result = " . $problem); echo $problem . " = " . $result; However, this is quite unsafe: /* If you read this, please, plz don't be stupid and DO NOT EXECUTE this code!!!!! */ $problem = "shell_exec('rm -rf /')"; eval("$result = " . $problem); /* Nukes system */ echo $problem . " = " . $result; Can anyone point me in the right direction parsing and solving a math question like the examples above, which is safe? Thanks.

    Read the article

  • Abstraction: The War between solving the problem and a general solution.

    - by Bryan Harrington
    As a programmer, I find myself in the dilemma where I want make my program as abstract and as general as possible. Doing so usually would allow me to reuse my code and have a more general solution for a problem that might (or might not) come up again. Then this voice in my head says, just solve the problem dummy its that easy! Why spend more time than you have to? We all have indeed faced this question where Abstraction is on your right shoulder and Solve-it-stupid sits on the left. Which to listen to and how often? What is your strategy for this? Should you abstract everything?

    Read the article

  • Hard problem - need help for solving

    - by dada
    I don't want you to solve this problem for me, i just want to ask for some ideas. This is the input below, and it represents a map. The 'x' represents land, and the dots - water. So with the 'x' you can represent 'islands' on the map. xxx.x...xxxxx xxxx....x...x ........x.x.x ..xxxxx.x...x ..x...x.xxx.x ..x.x.x...x.. ..x...x...xxx ...xxxxxx.... x............ As you can see, there are some islands which are closed, i.e. if some boat is inside its territory, it won't be able to get out, for ex: ..xxxxx. ..x...x. ..x.x.x. ..x...x. ..xxxxx. And there are some open islands which is possible to get out of them, ex: .xxxxx .x...x .x.x.x .xxx.x The problem is this: For a given NxM map like those above, calculate howm any of the islands are open, and how many are closed. I repeat: I don't want you to solve it, just need some sugestions, ideas for solving. thanks

    Read the article

  • problem solving [closed]

    - by Suresh S
    Problem Statement The Sports Associations in India (SAI) wants to choose 2 teams of 4 people each to send to Asian games. There are 13 people who want to be members of the teams. The SAI tries grouping them in various ways to see which athletes perform well together. Each grouping gets one test run on the test track and their time is recorded. Your task is to help the SAI choose two disjoint teams of 4 such that the sum of their practice times is minimal. Input There will be several input instances. The first line of each instance gives the total number of practice runs. This will be followed by n lines. Each of those lines will contain 5 numbers: p1 p2 p3 p4 t t is the time taken (in milliseconds) by the team consisting of p1, p2, p3 and p4. The time taken will not be more than 2 minutes. The end of the input will be indicated by a line with n=0. Output Output the best total and the two teams that you choose. If it is impossible to choose two disjoint teams from the test runs given, output -1. Sample Input 6 1 2 3 4 30000 10 11 12 13 15000 5 6 7 8 37800 1 5 10 12 20000 5 6 9 11 43000 1 9 12 13 11000 3 1 4 7 9 10000 3 5 7 11 17890 6 7 12 13 20000 0 Sample Output 45000 -1 Input to the problem 40 2 8 11 9 15532 1 13 11 9 57629 10 12 1 5 43406 6 10 1 2 43904 8 3 4 11 12473 6 12 5 11 19826 3 9 10 11 48347 6 12 13 1 45854 5 4 9 7 34452 9 8 12 2 5596 4 10 2 7 6778 3 6 8 5 32858 13 12 8 6 42457 12 9 2 5 49530 6 8 10 7 51453 1 3 11 9 18620 6 2 5 11 5153 4 1 9 8 37336 10 5 1 12 59524 4 5 3 2 1318 2 13 6 8 7839 12 4 9 5 30697 4 10 13 1 25249 4 2 9 13 52359 8 11 1 9 36437 7 5 11 6 58522 9 1 12 6 58837 7 6 8 5 37826 13 1 11 3 1841 11 3 5 13 50000 2 8 7 12 10137 1 4 12 5 32558 8 5 6 7 39021 1 7 10 13 5979 9 2 11 6 29661 13 12 9 7 7219 12 1 11 9 37354 5 1 10 9 47948 8 1 2 10 11071 2 11 1 8 3074 80 3 5 8 10 37873 1 2 3 5 27633 10 13 3 11 8645 13 1 9 6 2167 5 11 13 8 30862 8 7 9 6 47591 3 11 13 8 33823 2 13 7 5 36668 12 3 11 6 53711 6 13 3 7 52412 3 6 7 5 3850 1 5 11 12 35483 1 7 6 10 50943 11 3 6 8 40191 12 8 13 7 4529 4 10 5 1 43280 4 12 10 5 35142 12 4 5 10 37242 9 7 13 2 2661 3 9 2 10 453 3 8 12 9 12479 3 10 11 5 30047 9 1 11 2 40883 6 5 1 2 8774 11 7 9 1 37701 8 3 4 6 32970 4 12 7 10 55109 8 11 13 12 44713 2 10 8 5 37763 13 10 12 2 53628 7 2 5 10 53197 3 2 1 11 14916 1 2 3 10 50756 3 13 5 6 6959 10 6 1 4 2948 4 7 13 9 14146 8 13 10 2 16784 3 2 6 5 30337 1 6 7 8 14239 2 6 11 5 13749 12 1 10 5 30827 4 6 11 8 18780 9 10 8 5 6336 7 9 1 3 3101 10 3 4 13 56678 7 6 3 8 8258 11 7 12 6 19046 13 6 9 8 46356 9 5 11 13 56570 9 1 10 5 6193 8 6 9 11 16854 3 7 4 9 53573 8 12 10 1 28135 10 3 8 4 31411 11 1 3 12 34534 8 6 4 13 3527 1 6 10 9 52307 11 7 1 12 2886 12 11 1 6 17659 13 5 6 8 48834 11 2 1 10 52951 3 9 13 7 21054 1 5 11 9 14507 11 5 12 4 42040 1 6 12 7 46414 5 12 3 10 26239 6 10 7 8 40762 8 11 6 10 38538 13 1 10 7 31140 9 10 13 4 34164 13 6 7 12 49696 6 13 3 5 36003 8 9 13 6 58409 3 10 7 9 20693 2 1 11 12 22653 5 8 4 7 49888 5 3 2 11 29911 8 12 6 9 30964 8 3 13 6 23597 4 1 6 7 31657 4 6 8 7 13 33639 13 8 10 3 27863 5 2 1 12 1408 4 11 1 12 59010 63 10 11 9 8 23611 10 8 6 11 12410 4 6 7 9 44390 8 4 1 6 16543 1 2 8 10 37452 11 12 6 13 28968 11 12 2 8 59617 1 9 11 2 28631 11 6 5 1 27251 2 7 10 4 42503 7 8 10 3 13673 9 13 11 7 30308 6 1 12 9 4888 13 1 9 8 19475 8 7 3 5 34187 8 1 12 3 46266 6 10 12 5 32855 3 7 13 1 38427 2 5 13 3 59487 6 11 1 13 2098 1 4 13 6 22239 13 7 12 3 28703 12 3 7 4 32 9 8 2 13 35271 10 13 6 12 36422 12 6 9 8 44303 1 9 13 11 22962 11 13 6 12 39518 5 6 13 11 47909 4 13 1 8 10654 11 8 12 4 31956 7 12 9 13 35923 4 9 3 2 34736 13 2 10 1 22945 7 10 8 13 36947 1 4 12 13 19432 7 12 13 4 48718 9 5 13 11 18827 11 2 1 12 45444 8 12 6 13 33175 4 2 11 13 56186 2 9 3 11 33218 12 13 8 1 50727 13 1 8 2 48138 7 1 5 3 1926 6 4 10 1 40997 11 3 1 4 26033 6 10 13 1 40988 11 12 5 4 25199 4 3 1 10 23498 3 6 12 7 24306 13 10 12 3 53255 3 13 4 12 14517 7 10 9 3 29925 9 11 12 13 28333 3 5 13 6 13602 13 12 9 6 10394 8 4 12 6 57471 9 3 4 7 34723 11 9 5 3 38480 12 9 10 11 48048 4 3 6 7 31884 2 10 4 5 57654 86 1 6 5 13 56577 6 8 2 5 20429 11 13 9 3 2243 3 1 10 12 55231 9 5 7 8 29964 5 11 8 1 29624 6 9 3 1 43055 12 13 10 8 52132 10 8 4 1 5729 7 3 6 8 53097 11 12 7 1 18711 12 7 6 13 44397 10 12 5 7 53574 5 3 4 13 27078 11 2 5 10 43623 3 7 1 8 57350 10 12 4 9 19752 5 13 9 3 59380 4 7 13 6 32575 7 5 6 11 13593 13 7 12 6 38282 13 7 6 2 45430 6 2 5 10 38082 2 11 13 7 53557 10 6 7 13 40461 6 11 7 1 22007 4 7 2 3 22386 9 7 11 10 35337 2 6 11 7 4129 6 13 5 3 31813 1 11 6 9 11749 5 11 8 13 21858 5 12 9 11 2470 13 10 6 11 14503 8 4 1 3 10783 1 10 12 7 47116 11 1 8 10 25034 8 1 4 9 23350 3 10 1 9 56717 13 2 8 12 5825 12 3 13 7 35628 10 6 1 12 26901 2 13 3 5 2775 1 8 9 7 1294 7 13 12 2 48170 11 9 13 1 34311 9 6 3 13 30663 8 3 10 6 5853 1 10 2 4 19880 9 2 3 12 48990 3 7 11 4 51558 8 13 2 4 9698 9 4 5 1 6834 3 4 12 2 20941 11 3 9 7 40108 13 11 2 4 2594 8 9 10 13 12242 1 8 10 5 42413 7 1 11 3 17779 1 5 8 3 6934 4 9 8 11 10235 8 11 10 2 18879 11 4 8 2 12691 9 7 5 2 44947 3 2 5 4 30042 2 7 12 4 27185 6 5 10 1 28695 12 9 1 5 53813 8 12 9 3 24719 6 1 4 11 22716 1 13 10 8 39981 12 11 5 2 22412 6 11 2 4 14457 4 11 5 3 39658 10 11 2 1 33056 1 3 6 9 16958 6 11 12 7 50779 8 10 6 13 24824 7 10 1 13 35692 13 4 8 9 32885 7 6 4 3 10948 4 5 7 1 36875 5 10 6 7 58746 10 7 8 12 39453 8 4 12 1 46674 11 3 1 8 48103 0

    Read the article

  • Solving programming problems or contributing code?

    - by nischayn22
    What are the best skills to develop for a college graduate?? Should one spend hours/days trying to solve problems on codechef or topcoder or contribute code to open source organizations? My personal experience says solving problems teaches you how to make optimal code and learn new programming techniques (which someone else has researched and made available) to solve problems, whereas contributing to open source teaches you how to organize code (so others can work on it), use coding conventions and make "real" use of what you have learnt so far, blah blah!! Also another thing to note is that many companies are hiring today based on one's problem solving skills (Is this something I should worry about?) P.S. I have done little of online problem solving and little of code contribution (via GSoC), but left confused what I should continue doing (as doing both simultaneously isn't easy).

    Read the article

  • Is problem solving of puzzles/logic tests a skill that can be developed with practise or only someth

    - by dotnetdev
    Programming is essentially problem solving/using a lot of logic. With solving puzzles (like the ones recruiters like MS etc ask), is this a skill that can be developed with practise or is it a skill that only someone who is gifted has (I assume the former as many people can pass these tests)? Even so, I keep thinking it is a special skill for someone gifted, not for someone with a lot of practise. I guess that with practise you are perhaps more open-minded and start to think out of the box more (solving technical problems in development may also foster this mindset perhaps). Thanks

    Read the article

  • Problem solving/ Algorithm Skill is a knack or can be developed with practice?

    - by KaluSingh Gabbar
    Every time I start a hard problem and if can not figure out the exact solution or can not get started, I get into this never ending discussion with myself, as below: That problem solving/mathematics/algorithms skills are gifted (not that you can learn by practicing, by practice, you only master the kind of problems that you already have solved before) only those who went to good schools can do it, as they learned it early. What are your thoughts, can one achieve awesomeness in problem solving/algorithms just by hard work or you need to have that extra-gene in you?

    Read the article

  • How I improve my problem-solving ability

    - by gcc
    How we can improve our problem-solving ability ? Every one says same thing "real programmer knows how to handle real problem.", but they forget something how they take this ability, or where ( I know in school, no one gives us any ability, of course in my opinion. ) If you have any idea except above ones, feel free when you give an advice solve more problem do more exercise, write code, search google then write more ... For me, my question is like "Use complex/known library instead of using your own." In other words, I want your experience, book recommendation, web page

    Read the article

  • Fast language for problem solving? [closed]

    - by Friend of Kim
    I learned PHP to make websites. After some years I've started using programming for solving what is difficult tasks for my level. Now I want to make a program that solves equations. (I want to write it myself, not use an API. Because I'm doing this for the sake of the challenge, not for the result..) Because of this, I'm going to learn a new and faster/better language. It's going to be C++, Java, Python or C#. What are the benefits of each language, and which language is best for speed compared to speed of writing and readability? Using C would be lightning fast, but the lack of OO is making for more complex code and reduces the readability, for example..

    Read the article

  • Solving Big Problems with Oracle R Enterprise, Part I

    - by dbayard
    Abstract: This blog post will show how we used Oracle R Enterprise to tackle a customer’s big calculation problem across a big data set. Overview: Databases are great for managing large amounts of data in a central place with rigorous enterprise-level controls.  R is great for doing advanced computations.  Sometimes you need to do advanced computations on large amounts of data, subject to rigorous enterprise-level concerns.  This blog post shows how Oracle R Enterprise enables R plus the Oracle Database enabled us to do some pretty sophisticated calculations across 1 million accounts (each with many detailed records) in minutes. The problem: A financial services customer of mine has a need to calculate the historical internal rate of return (IRR) for its customers’ portfolios.  This information is needed for customer statements and the online web application.  In the past, they had solved this with a home-grown application that pulled trade and account data out of their data warehouse and ran the calculations.  But this home-grown application was not able to do this fast enough, plus it was a challenge for them to write and maintain the code that did the IRR calculation. IRR – a problem that R is good at solving: Internal Rate of Return is an interesting calculation in that in most real-world scenarios it is impractical to calculate exactly.  Rather, IRR is a calculation where approximation techniques need to be used.  In this blog post, we will discuss calculating the “money weighted rate of return” but in the actual customer proof of concept we used R to calculate both money weighted rate of returns and time weighted rate of returns.  You can learn more about the money weighted rate of returns here: http://www.wikinvest.com/wiki/Money-weighted_return First Steps- Calculating IRR in R We will start with calculating the IRR in standalone/desktop R.  In our second post, we will show how to take this desktop R function, deploy it to an Oracle Database, and make it work at real-world scale.  The first step we did was to get some sample data.  For a historical IRR calculation, you have a balances and cash flows.  In our case, the customer provided us with several accounts worth of sample data in Microsoft Excel.      The above figure shows part of the spreadsheet of sample data.  The data provides balances and cash flows for a sample account (BMV=beginning market value. FLOW=cash flow in/out of account. EMV=ending market value). Once we had the sample spreadsheet, the next step we did was to read the Excel data into R.  This is something that R does well.  R offers multiple ways to work with spreadsheet data.  For instance, one could save the spreadsheet as a .csv file.  In our case, the customer provided a spreadsheet file containing multiple sheets where each sheet provided data for a different sample account.  To handle this easily, we took advantage of the RODBC package which allowed us to read the Excel data sheet-by-sheet without having to create individual .csv files.  We wrote ourselves a little helper function called getsheet() around the RODBC package.  Then we loaded all of the sample accounts into a data.frame called SimpleMWRRData. Writing the IRR function At this point, it was time to write the money weighted rate of return (MWRR) function itself.  The definition of MWRR is easily found on the internet or if you are old school you can look in an investment performance text book.  In the customer proof, we based our calculations off the ones defined in the The Handbook of Investment Performance: A User’s Guide by David Spaulding since this is the reference book used by the customer.  (One of the nice things we found during the course of this proof-of-concept is that by using R to write our IRR functions we could easily incorporate the specific variations and business rules of the customer into the calculation.) The key thing with calculating IRR is the need to solve a complex equation with a numerical approximation technique.  For IRR, you need to find the value of the rate of return (r) that sets the Net Present Value of all the flows in and out of the account to zero.  With R, we solve this by defining our NPV function: where bmv is the beginning market value, cf is a vector of cash flows, t is a vector of time (relative to the beginning), emv is the ending market value, and tend is the ending time. Since solving for r is a one-dimensional optimization problem, we decided to take advantage of R’s optimize method (http://stat.ethz.ch/R-manual/R-patched/library/stats/html/optimize.html). The optimize method can be used to find a minimum or maximum; to find the value of r where our npv function is closest to zero, we wrapped our npv function inside the abs function and asked optimize to find the minimum.  Here is an example of using optimize: where low and high are scalars that indicate the range to search for an answer.   To test this out, we need to set values for bmv, cf, t, emv, tend, low, and high.  We will set low and high to some reasonable defaults. For example, this account had a negative 2.2% money weighted rate of return. Enhancing and Packaging the IRR function With numerical approximation methods like optimize, sometimes you will not be able to find an answer with your initial set of inputs.  To account for this, our approach was to first try to find an answer for r within a narrow range, then if we did not find an answer, try calling optimize() again with a broader range.  See the R help page on optimize()  for more details about the search range and its algorithm. At this point, we can now write a simplified version of our MWRR function.  (Our real-world version is  more sophisticated in that it calculates rate of returns for 5 different time periods [since inception, last quarter, year-to-date, last year, year before last year] in a single invocation.  In our actual customer proof, we also defined time-weighted rate of return calculations.  The beauty of R is that it was very easy to add these enhancements and additional calculations to our IRR package.)To simplify code deployment, we then created a new package of our IRR functions and sample data.  For this blog post, we only need to include our SimpleMWRR function and our SimpleMWRRData sample data.  We created the shell of the package by calling: To turn this package skeleton into something usable, at a minimum you need to edit the SimpleMWRR.Rd and SimpleMWRRData.Rd files in the \man subdirectory.  In those files, you need to at least provide a value for the “title” section. Once that is done, you can change directory to the IRR directory and type at the command-line: The myIRR package for this blog post (which has both SimpleMWRR source and SimpleMWRRData sample data) is downloadable from here: myIRR package Testing the myIRR package Here is an example of testing our IRR function once it was converted to an installable package: Calculating IRR for All the Accounts So far, we have shown how to calculate IRR for a single account.  The real-world issue is how do you calculate IRR for all of the accounts?This is the kind of situation where we can leverage the “Split-Apply-Combine” approach (see http://www.cscs.umich.edu/~crshalizi/weblog/815.html).  Given that our sample data can fit in memory, one easy approach is to use R’s “by” function.  (Other approaches to Split-Apply-Combine such as plyr can also be used.  See http://4dpiecharts.com/2011/12/16/a-quick-primer-on-split-apply-combine-problems/). Here is an example showing the use of “by” to calculate the money weighted rate of return for each account in our sample data set.  Recap and Next Steps At this point, you’ve seen the power of R being used to calculate IRR.  There were several good things: R could easily work with the spreadsheets of sample data we were given R’s optimize() function provided a nice way to solve for IRR- it was both fast and allowed us to avoid having to code our own iterative approximation algorithm R was a convenient language to express the customer-specific variations, business-rules, and exceptions that often occur in real-world calculations- these could be easily added to our IRR functions The Split-Apply-Combine technique can be used to perform calculations of IRR for multiple accounts at once. However, there are several challenges yet to be conquered at this point in our story: The actual data that needs to be used lives in a database, not in a spreadsheet The actual data is much, much bigger- too big to fit into the normal R memory space and too big to want to move across the network The overall process needs to run fast- much faster than a single processor The actual data needs to be kept secured- another reason to not want to move it from the database and across the network And the process of calculating the IRR needs to be integrated together with other database ETL activities, so that IRR’s can be calculated as part of the data warehouse refresh processes In our next blog post in this series, we will show you how Oracle R Enterprise solved these challenges.

    Read the article

  • Does one's native spoken language affect quality of code?

    - by Xepoch
    There is a school of thought in linguistics that problem solving is very much tied to the syntax, semantics, grammar, and flexibility of one's own native spoken language. Working with various international development teams, I can clearly see a mental culture (if you will) in the codebase. Programming language aside, the German coding is quite different from my colleagues in India. As well, code is distinctly different in Middle America as it is in Coastal America (actually, IBM noticed this years ago). Do you notice with your international colleagues (from ANY country) that coding style and problem solving are in-line with native tongues?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >