C# Nmath 到 Python SciPy
我需要将一些函数从 C# 移植到 Python,但我无法正确实现下一个代码:
[SqlFunction(IsDeterministic = true, DataAccess = DataAccessKind.None)]
public static SqlDouble LogNormDist(double probability, double mean, double stddev)
{
LognormalDistribution lnd = new LognormalDistribution(mean,stddev);
return (SqlDouble)lnd.CDF(probability);
}
此代码使用 CenterSpace Nmath 库。
任何人都可以帮我在 python 中编写一个与此代码类似的正确函数吗?
对不起我的英语不好。
UPD 实际上,我不明白哪些 scipy.stats.lognorm.cdf attrs 与 C# 概率相似,意思是 stddev
如果只是将现有订单复制到 python,就像下面的答案一样,我会得到错误的数字。
I need to port some functions from C# to Python, but i can't implement next code right:
[SqlFunction(IsDeterministic = true, DataAccess = DataAccessKind.None)]
public static SqlDouble LogNormDist(double probability, double mean, double stddev)
{
LognormalDistribution lnd = new LognormalDistribution(mean,stddev);
return (SqlDouble)lnd.CDF(probability);
}
This code uses CenterSpace Nmath library.
Anyone can help me to write a right function in python, which will be similar to this code?
Sorry for my English.
UPD Actually, i don't understand which scipy.stats.lognorm.cdf attrs are simillar to C# probability, mean, stddev
If just copy existing order to python, like in answer below, i get wrong number.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Scipy 在 scipy.stats 包中定义了一堆发行版
更新
好吧,看起来 Scipy 的统计定义有点不标准。 这是 scipy.stats.lognormal 文档字符串的结尾
所以也许可以尝试一下,
如果这仍然不起作用,请尝试获取一些样本点,我会看看是否可以找到工作关系。
Udpate 2
哎呀,我没有意识到比例参数是一个关键字。 这个现在应该可以工作了:
干杯,祝你的项目好运!
Scipy has a bunch of distributions defined in the scipy.stats package
Update
Okay, it looks like Scipy's stat definitions are a little nonstandard. Here's the end of the docstring for
scipy.stats.lognormal
So maybe try
If that still doesn't work, try getting a few sample points and I'll see if I can find a working relationship.
Udpate 2
Oops, I didn't realize that the scale param is a keyword. This one should now work:
Cheers and good luck with your project!
Python 文档描述了一种方法 random.lognormvariate(mu, sigma):
http://docs.python .org/library/random.html
也许这就是您想要的。
The Python docs describe a method random.lognormvariate(mu, sigma):
http://docs.python.org/library/random.html
Maybe that's what you want.
也许您可以使用 Python.NET(这不是 IronPython),它允许访问 .NET 组件和服务:
http://pythonnet.sourceforge.net/
Maybe you can use Python.NET (this is NOT IronPython), it allows to access .NET components and services:
http://pythonnet.sourceforge.net/
Ivan,
我们没有兴趣让人们局限于 NMath。 这就是我们在 NMath 中所做的事情。
那
应该有帮助......
Ivan,
We've got no interest in keeping people locked into NMath. Here's what we're doing in NMath.
where
That should help...