按字母顺序排列集合(Sorting a collection in alphabetical order)
有没有什么方法可以用来按字母顺序排列集合(使用C#2.0?)。
谢谢
Is there any way, out of the box, to sort a collection in alphabetical order (using C# 2.0 ?).
Thanks
原文:https://stackoverflow.com/questions/3494941
最满意答案
包含您实际运行的代码,得到的结果以及您的预期结果总是一个好主意。
在这里,主要的问题是你有一个语法错误。 其次,你应该使用numpy数组,而不是列表。 第三,正如文档所示(请参阅https://lmfit.github.io/lmfit-py/model.html#lmfit.model.ModelResult.eval )
result.eval()
将params
作为第一个参数,而不是自变量。 总之,你想用你的最后两行代替x1 = np.array([1, 2, 3]) # input for prediction a = result.eval(x=x1) # prediction
应该按预期工作。
而且:当然,你不需要
lmfit
做线性回归。 )。It is always a good idea to include the code you actually ran, the result you got, and the result you expected.
Here, the main problem is that you have a syntax error. Second, you should use numpy arrays, not lists. And third, as the docs show (see https://lmfit.github.io/lmfit-py/model.html#lmfit.model.ModelResult.eval)
result.eval()
would takeparams
as the first argument, not the independent variable. In short, you want to replace your last two lines withx1 = np.array([1, 2, 3]) # input for prediction a = result.eval(x=x1) # prediction
that should work as expected.
And: of course, you don't need
lmfit
to do a linear regression. ;).
相关问答
更多-
为什么没有绘制预测?(Why is prediction not plotted?)[2022-12-25]
绘图方法是为X轴采用数组,为Y轴采用数组,并根据这些数组绘制一条线 。 你试图用线条的方法绘制一个点 ... 为了使您的代码能够工作(我已经测试过并且工作正常),请切换此行: plt.plot(X[0],obj.predict(7),color='black',linewidth=3) 用这一行: plt.scatter(7,obj.predict(7),color='black',linewidth=3) 散射方法将采用给定的点(7,7)并将其放入图中,就像您想要的那样。 我希望这有帮助:) The ... -
Python lmfit:模型对象试图使用“self”作为自由变量(Python lmfit: Model object trys to use “self” as free variable)[2023-08-10]
由于fit_func不使用self,因此将其fit_func静态方法: @staticmethod def fit_func(x, a, b): return a * x + b 这样你就不必担心self 。 Since fit_func is not using self, make it a static method: @staticmethod def fit_func(x, a, b): return a * x + b This way you don't have to w ... -
您的脚本可能要短得多,以说明问题。 但是,最终的参数保存在result_150.params ,依此类推。 传递给minimize()的参数在拟合中不会改变。 那么,对于lmfit版本0.9.0及更高版本来说也是如此。 也许你的同事在lmfit上有一个旧版本。 Your script could be a lot shorter to illustrate the question. But, the final Parameters are held in result_150.params and so ...
-
我认为前一行中有一个括号问题。 这会导致返回包含在公式中。 我认为最后有一个缺失。 I think there is a parenthesis problem in the previous line. This causes the return to be included in the formula. I think there's a ) missing at the end.
-
lmfit没有达到预期的效果(lmfit not performing as expected)[2023-08-09]
嗯,应该是 out = mod1.fit(spectra_beBG[:,1], pars, x=spectra_beBG[:,0]) 也就是说,你想要拟合“y”,并传入“pars”和“x”数组来帮助计算具有这些参数和自变量的模型。 Hm, should that be out = mod1.fit(spectra_beBG[:,1], pars, x=spectra_beBG[:,0]) That is, you want to fit "y", and pass in the "pars" and ... -
包含您实际运行的代码,得到的结果以及您的预期结果总是一个好主意。 在这里,主要的问题是你有一个语法错误。 其次,你应该使用numpy数组,而不是列表。 第三,正如文档所示(请参阅https://lmfit.github.io/lmfit-py/model.html#lmfit.model.ModelResult.eval ) result.eval()将params作为第一个参数,而不是自变量。 总之,你想用你的最后两行代替 x1 = np.array([1, 2, 3]) # input for pred ...
-
将标记附加到表示感兴趣的子集/类别的救护车数据上(例如,“忙碌”与“非忙碌”)。 对于非正式或非参数分析,请使用relrisk工具,或者在使用split.ppp分离不同类型的点后使用split.ppp 。 对于正式分析(考虑样本大小等),您应该将几个候选模型拟合到相同的数据,一个模型具有繁忙/非繁忙效果,另一个模型没有这样的效果,然后使用anova.ppm正式测试是否有一个忙/不忙的效果。 参见上述书的第14章。 Attach marks to the ambulance data representing ...
-
在python中使用lmfit模块,如何调用模型中的参数?(With using lmfit module in python, how to call the parameters in the model?)[2023-02-01]
您可能尝试在函数外部打印该数据。 amp , shift , omega和decay变量在fc2min的局部范围内,因此只能在函数内部访问。 您的数据分析技能似乎远远超过您的Python专有技术,因此我在此代码中添加了一些有用的提示: import numpy as np import matplotlib.pyplot as plt from lmfit import minimize, Parameters, Parameter, report_fit # create data to be fitt ... -
您需要两个以上的数据点才能将双参数指数模型拟合为数据。 Lmfit模型旨在进行数据拟合。 像这样的东西可以工作: import numpy as np import lmfit xdat = np.linspace(0, 2.0, 11) ydat = 2.1 * np.exp(-xdat /0.88) + np.random.normal(size=len(xdat), scale=0.06) mod = lmfit.models.ExponentialModel() pars = mod.guess ...
-
这只是一个绘图问题,您只需更改两行就可以看到结果相同: yValTest = VoigtConv(absPlot[:,0], result.best_values.get('A'), result.best_values.get('x0'), result.best_values.get('sigma'), result.best_values.get('gamma'),) 到(注意改变切片) yValTest = VoigtConv(absPlot[50:170, 0], result.best_va ...