office官网找到IRR的介绍

https://support.office.com/zh-cn/article/irr-%E5%87%BD%E6%95%B0-64925eaa-9988-495b-b290-3ad0c163c1bc

https://docs.microsoft.com/zh-cn/office/vba/language/reference/user-interface-help/irr-function?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev11.query%3FappId%3DDev11IDEF1%26l%3Dzh-CN%26k%3Dk(vblr6.chm1009282)%3Bk(TargetFrameworkMoniker-Office.Version%3Dv15)%26rd%3Dtrue

1.找js的实现

function IRR(cashFlows, estimatedResult) {  var result = "isNAN";  if (cashFlows != null && cashFlows.length > 0) {  // check if business startup costs is not zero:  if (cashFlows[0] != 0) {  var noOfCashFlows = cashFlows.length;  var sumCashFlows = 0;  // check if at least 1 positive and 1 negative cash flow exists:  var noOfNegativeCashFlows = 0;  var noOfPositiveCashFlows = 0;  for (var i = 0; i < noOfCashFlows; i++) {  sumCashFlows += cashFlows[i];  if (cashFlows[i] > 0) {  noOfPositiveCashFlows++;  } else {  if (cashFlows[i] < 0) {  noOfNegativeCashFlows++;  }  }  }  // at least 1 negative and 1 positive cash flow available?  if (noOfNegativeCashFlows > 0 && noOfPositiveCashFlows > 0) {  // set estimated result:  var irrGuess = 0.1; // default: 10%  if (!isNaN(estimatedResult)) {  irrGuess = estimatedResult;  if (irrGuess <= 0) {  irrGuess = 0.5;  }  }  // initialize first IRR with estimated result:  var irr = 0;  if (sumCashFlows < 0) { // sum of cash flows negative?  irr = -irrGuess;  } else { // sum of cash flows not negative  irr = irrGuess;  }  // iteration:  // the smaller the distance, the smaller the interpolation  // error  var minDistance = 1e-15;  // business startup costs  var cashFlowStart = cashFlows[0];  var maxIteration = 100;  var wasHi = false;  var cashValue = 0;  for (var i = 0; i <= maxIteration; i++) {  // calculate cash value with current irr:  cashValue = cashFlowStart; // init with startup costs  // for each cash flow  for (var j = 1; j < noOfCashFlows; j++) {  cashValue += cashFlows[j] / Math.pow(1 + irr, j);  }  // cash value is nearly zero  if (Math.abs(cashValue) < 0.01) {  result = irr;  break;  }  // adjust irr for next iteration:  // cash value > 0 => next irr > current irr  if (cashValue > 0) {  if (wasHi) {  irrGuess /= 2;
                      }  irr += irrGuess;  if (wasHi) {  irrGuess -= minDistance;  wasHi = false;  }  } else {// cash value < 0 => next irr < current irr  irrGuess /= 2;  irr -= irrGuess;  wasHi = true;  }  // estimated result too small to continue => end  // calculation  if (irrGuess <= minDistance) {  result = irr;  break;  }  }  }  }  }  return result;
}  

2. var一个 [] 来验证找到的函数 是否可用

3.调用IRR,estimatedResult设置为0.1,保持与excel默认值一致

转载于:https://www.cnblogs.com/ww01/p/11005373.html

excel的IRR函数相关推荐

  1. R语言dataframe计算满足筛选条件的行的个数(筛选满足条件的数据行并计数):类似于excel的countif函数

    R语言dataframe计算满足筛选条件的行的个数(筛选满足条件的数据行并计数):类似于excel的countif函数 目录

  2. R语言dataframe分组数据汇总(aggregate and sum):类似于excel的sumif函数

    R语言dataframe分组数据汇总统计(aggregate and sum):类似于excel的sumif函数 目录 R语言dataframe分组数据汇总统计(aggregate and sum): ...

  3. excel的if函数中android,excel中if函数嵌套式使用教程

    exce表格数据统计函数的示例 函数统计数据步骤1:每个函数均有三个参数:database.field 和 criteria.这些参数指向函数所使用的工作表区域. 函数统计数据步骤2:除了GETPIV ...

  4. EXCEL中SUMIF函数介绍

    在EXCEL中SUMIF函数是一个常用的汇总函数,下面来介绍一下EXCEL中的SUMIF函数的使用方法. 下图是介绍该函数的简单数据数据: 此函数可以进行判定,当某数据项满足特定的条件时,将特定的数据 ...

  5. 【图文】Excel中vlookup函数的使用方法

    今天统计数据,用到了Excel中vlookup函数,第一次使用当然少不了百度,经过反复研究后,算是解决了问题,现整理成文档. 一.实现效果 Sheet1   Sheet2       注:上图中she ...

  6. Excel中Sumproduct函数的使用方法

    1.sumproduct函数的含义 1 1.Sumproduct函数的适用范围,在给定的几组数组中,然后把数组间对应的元素相乘,最后返回乘积之和. 从字面上可以看出,sumproduct有两个英文单词 ...

  7. Excel公式与函数案例速查手册/电脑技巧从入门到精通丛书

    出版社: 机械工业出版社; 第1版 (2013年12月1日) 丛书名: 电脑技巧从入门到精通丛书 平装: 770页 语种: 简体中文 开本: 32 条形码: 9787111448761 商品尺寸: 1 ...

  8. Excel中vlookup函数的使用方法

    http://candy36.blog.163.com/blog/static/13089096200872933710998/ 想当年,Excel只学了个基本,现在才发现,其实其功能非常强大,只是还 ...

  9. Excel 2016新增函数之TEXTJOIN

    Excel 2016新增函数之TEXTJOIN 在2016年1月功能更新中,EXCEL 2016新增几个常用重要函数,主要有:ifs,switch,maxifs,minifs,concat,textj ...

  10. 计算机中函数counta表示,excel中counta函数的使用方法

    你还在为Excel中counta函数的使用方法而苦恼吗,今天小编教你Excel中counta函数的使用方法,今天,学习啦小编就教大家在counta函数的使用方法. Excel的counta函数的使用方 ...

最新文章

  1. illegalstateexception是什么异常_异常源码分析—告诉你学习“源码”究竟有什么用!...
  2. Npm 5 package locks
  3. ​CSRankings年度更新,清华北大包揽AI领域前两名​ | AI日报
  4. 针对B2B平台的接口自动化测试系统
  5. npm : 无法加载文件 D:\Program Files\nodejs\node_global\npm.ps1,因为在此系统上禁止运行脚本。
  6. ue4光追降噪_【魔改UE4】后记_焦散效果总结
  7. Python 正则模块的应用
  8. Android 系统(158)---Android O、N 减少占用ROM空间或者加快安装速度
  9. hun暑期实训 最大报销额(01背包) 关于动态内存分配的new与delete
  10. Linux基本命令 帮助命令
  11. openwrt路由器更换了Flash之后需要修改的源码
  12. system_Class类说明文档
  13. 【PMP】pmp练习题及解析
  14. linux 软键盘输入密码,Linux系统中使用屏幕键盘的方法
  15. 【Cocos2d-x】物理引擎使用入门
  16. 【高数复盘】2.1导数概念
  17. kanziopengl杂谈
  18. We‘re sorry but XXX doesn‘t work properly without JavaScript enabled. Please enable it to contin
  19. Python使用asyncio+aiohttp异步爬取猫眼电影专业版
  20. 将数字、字母、汉字分开的方法

热门文章

  1. DPDK ip分片与重组的设计实现
  2. 求一段看不懂的乱码_这些真的不是乱码,是汉字!竟然一个都不认识
  3. Excel 有哪些可能需要熟练掌握而很多人不会的技能
  4. 上市一再受阻,“微医”再融资4亿美元就能敲开“港股”大门?
  5. LabVIEW心率监测装置
  6. 怎样在html中加入计数器?(2),html如何实现计数器以及时钟的功能代码
  7. Nginx(九):Nginx网页压缩技术
  8. 如何使用手机打开CAJ文件?
  9. orgChart实现多重树状图结构
  10. Caused by: org.apache.spark.SparkException: This RDD lacks a SparkContext. It could happen in the