Here comes the contrast! Can Julia beat Python and R to win?

mob604756fb8908 2021-07-20 05:02:57
comes contrast julia beat python


# Scan the QR code to sign up for the source creation #

original text :Julia vs R vs Python: simple optimization

author :ZJ, Data scientist , Full stack engineer , Head of the credit risk model team .

compile : Open source in China (oschina2013)

If you need to reprint, please indicate the above information in the text

In this article , The author optimizes by a simple likelihood function (Maximum Likelihood Optimization) Let's make a comparison Julia,R and Python. This is a relatively small optimization problem , The performance difference may not be obvious , But the process of solving problems can well reflect the advantages and disadvantages of the three .

At the time of writing this article , The familiarity with these three languages is as follows :

Julia evangelist ChrisRackauckas Once said :

If you use Julia Deal with one 10 The question of seconds , Its advantages don't show up . And once the problem gets complicated , It takes a long time , At this time Julia The advantages of the company will gradually manifest itself .

Someone uses it Python and Julia Did a comparative experiment . With 10⁵ Calculate for the boundary point , When the value ratio 10⁵ Less time Python Than Julia fast . But the value is greater than 10⁵ after ,Julia It's faster than Python Much faster .

optimization problem

Watch the sequence Q1,Q2,…,Qn, We need to find the parameters that optimize the likelihood function μ and σ:

Usually we try to optimize log likelihood :

Statistically , This is the maximum likelihood estimation of the truncated normal distribution (MLE).

Julia The test situation of

Here's how the author uses Julia The situation of testing . Use Julia Medium Optim.jl, You can use special symbols directly (symbols) As variable name , According to the usage habit , Here the author uses the Greek alphabet μσ.Julia One more JuMP.jl Packages are used to optimize problems . but JuMP.jl More suitable for more advanced optimization problems , It's a bit of a fuss to use here .

Julia First optimization

Julia In performing the first optimization, we used 7 second , Than R and Python All slow . Regarding this ,ChrisRackauckas Pointed out that :

If you need to solve 100 individual 10 Second optimization problem , The first execution costs 17 second , The next optimization doesn't require compilation , It's about 10 second . therefore , The total running time is 1007 second . therefore , When used Julia Deal with one 10⁵ The second question is , this 7 Seconds can be ignored ; But if use Julia Handle 5 Seconds or less , this 7 The difference in seconds is particularly obvious .

The author hardcoded below in MLE Used in the estimate Q_t Value :

The output effect is as follows , The layout looks very comfortable , It also supports math public display :

From that ** Julia The advantages of :**

**
Julia Deficiency :**

R The test situation of

R There is one truncnorm Used to deal with truncated normality

The result will output :

R The advantages of :

R Deficiency :

Python The test situation of

The author makes use of the existing Python Learn from experience and come up with the following plan , Enter the code :

Output results :

Python The advantages of :

Python Deficiency :

in summary , A comprehensive comparison of the three languages is as follows :

版权声明
本文为[mob604756fb8908]所创,转载请带上原文链接,感谢
https://pythonmana.com/2021/05/20210530193104985h.html

  1. python —pandas库常用函数
  2. Python应用matplotlib绘图简介
  3. Python matplotlib高级绘图详解
  4. 入门训练 Fibonacci数列-python实现
  5. Python -二维数组定义
  6. python二进制相加
  7. Python文本处理:解析json格式的数据
  8. 查看python安装路径
  9. Python编程之计算生态
  10. Python-turtle标准库知识小结(python绘图工具)
  11. Python-time标准库知识小结
  12. Python-random标准库知识小结
  13. python安装第三方库的三种方法
  14. python程序的控制结构
  15. Python程序的函数和代码复用
  16. python之组合数据类型
  17. python【力扣LeetCode算法题库】300 最长上升子序列(动态规划)
  18. python【力扣LeetCode算法题库】695- 岛屿的最大面积(深搜)
  19. python【力扣LeetCode算法题库】面试题 01.06-字符串压缩
  20. python【力扣LeetCode算法题库】1160-拼写单词
  21. python【力扣LeetCode算法题库】836- 矩形重叠
  22. python【力扣LeetCode算法题库】409-最长回文串(数学 计数器)
  23. python【力扣LeetCode算法题库】面试题40- 最小的k个数
  24. python【力扣LeetCode算法题库】945- 使数组唯一的最小增量
  25. python【力扣LeetCode算法题库】365- 水壶问题(裴蜀等式)
  26. python【力扣LeetCode算法题库】876- 链表的中间结点
  27. python【力扣LeetCode算法题库】面试题 17.16- 按摩师(DP)
  28. python【力扣LeetCode算法题库】892-三维形体的表面积
  29. python【力扣LeetCode算法题库】999-车的可用捕获量(DFS)
  30. python【力扣LeetCode算法题库】914. 卡牌分组(reduce & collections.Counter)
  31. python【力扣LeetCode算法题库】820- 单词的压缩编码
  32. python【力扣LeetCode算法题库】1162- 地图分析(BFS)
  33. python【力扣LeetCode算法题库】面试题62- 圆圈中最后剩下的数字(约瑟夫环)
  34. python【力扣LeetCode算法题库】912- 排序数组
  35. python【力扣LeetCode算法题库】1111- 有效括号的嵌套深度
  36. python【力扣LeetCode算法题库】289- 生命游戏
  37. python【力扣LeetCode算法题库】12- 整数转罗马数字(打表 模拟)
  38. python【数据结构与算法】内置函数enumerate(枚举) 函数(看不懂你来打我)
  39. python【力扣LeetCode算法题库】13- 罗马数字转整数
  40. python【数据结构与算法】内置函数 zip() 函数(看不懂你来打我)
  41. python【力扣LeetCode算法题库】14-最长公共前缀(列表解压)
  42. python【蓝桥杯vip练习题库】ADV-281特等奖学金
  43. python【蓝桥杯vip练习题库】ADV-69质因数(数论)
  44. python爬不同图片分别保存在不同文件夹中
  45. python打印a-z
  46. python以16进制打印输出
  47. 每天好心情——Python画一棵樱花树
  48. 在终端输入命令打开mac自带的python工具IDLE
  49. Python3的安装(Windows)
  50. Python第一个爬虫项目
  51. Python模拟日志生成
  52. 【邵奈一】Python爬虫专栏(一)之Python爬虫热身
  53. 用 Python 画一棵圣诞树
  54. 你一定想不到,实现一个Python+Selenium的自动化测试框架就这么简单!
  55. 一文快速教你搭建Python+Selenium环境
  56. 一看就会:Python+Appium实现自动化测试
  57. 【邵奈一】Python爬虫专栏(三)之自动登录
  58. Python core developer: the retirement of the father of Python has no impact
  59. Python3 or Python2? Examples explain the differences between the two
  60. Analysis of Linux DHCP server IP allocation Python script