任何人都可以帮助我将其转换为C#.这实际上伤害了我的大脑.
http://www.evanmiller.org/how-not-to-sort-by-average-rating.html

require 'statistics2'
def ci_lower_bound(pos, n, power)
if n == 0
return 0
end
z = Statistics2.pnormaldist(1-power/2)
phat = 1.0*pos/n
(phat + z*z/(2*n) - z * Math.sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)
end
Run Code Online (Sandbox Code Playgroud)
这是什么意思?
Statistics2.pnormaldist(1-power/2)
Run Code Online (Sandbox Code Playgroud) 我有一个非常不必要的困境.我懒洋洋地寻找一个将lamda表达式转换为字符串的函数.我每次都在输入这个缓存密钥让我感到困扰,但我真的不想花时间去创建它.
我想用它来创建我创建的缓存函数:
如果我想在没有每次调用函数的情况下为某个人获取名称的话.
public static string GetPersonName(int id)
{
return Repository.PersonProvider.Cached(x => x.GetById(id)).Name;
}
Run Code Online (Sandbox Code Playgroud)
GetExpressionDescription将返回"PersonProvider.GetById(int 10)"
我认为这是可能的,但我想知道是否有人已经建立了这个或已经在某处看到它.
public static R Cached<T, R>(this T obj, Expression<Func<T, R>> function, double hours = 24)
{
var expressionDescription = GetExpressionDescription(function);
return Cached(function, expressionDescription, hours);
}
public static R Cached<T, R>(this T obj, Expression<Func<T, R>> function, string cacheName, double hours = 24)
{
var context = HttpContext.Current;
if (context == null)
return function.Compile().Invoke(obj);
R results = default(R);
try { results = (R)context.Cache[cacheName]; }
catch { …Run Code Online (Sandbox Code Playgroud) User x = null;
object o = x;
// determine type with only reference to o
Run Code Online (Sandbox Code Playgroud)
并且泛型不起作用