English 中文(简体)
设定功能的数值清单
原标题:Get function given a list of values
  • 时间:2011-10-01 19:34:00
  •  标签:
  • python

是否有办法,我可以提出诸如[1、3、4.5、1]等价值清单,并获得与这些价值相关的职能? 类似:

I don t want to plot it or anything, I just want to substitute values in that function and see what the result would be.

编辑:有没有办法计算数据的相关性? 就像我给它一份包含数千个价值观的清单一样,它使我恢复根据这些价值观调整的职能。

最佳回答

根据您对

我想知道这些价值观之间的关系是什么,我有成千上万的价值观储存在一份清单中,我想知道,是否真的可以告诉我这些价值观是如何相关的。

似乎像你一样试图做一个regression analysis(可能是一条线性回归)并符合价值观。

您可使用NumPy,用于在沙尔进行线性回归分析。 http://web.archive.org/web/20130407175357/http://www.scipy.org:80/Cookbook/LinearRegression”rel=“nofollow noreferer”>。

问题回答

Yes, the function is called map().

def y(x):
    return 3*x+4

map(y, [1,3,4.5,1])

<>代码>(>功能适用于每个项目,并填写结果清单。

根据你修订后的问题,我会走下去,并补充一个答案。 没有这种职能。 我认为,你不大可能找到一种在任何<>>><>><>>方案拟定语言中结束的职能。 你的定义不够严格,但任何事情都是合理的。 如果我们仅举两点投入,就能够有各种关系:

[10, 1]

possible relationships:

def x(y):
  return y ** 0

def x(y):
  return y / 10

def x(y)
  return y % 10 + 1

...... ......重复。 诚然,其中一些是任意的,但它们是你所穿阵列的第一和第二个价值观之间的有效关系。 当你要求建立10、15或35人之间的关系时,“解决方案”的可能性就变得更加荒唐。

I assume you want to find out if the sequences [1, 2, 3, 4] and [ 1, 3, 4.5, 1] (or else the pairs [(1, 1), (2, 3), (3, 4.5), (4, 1)] are related with a (linear) function or not.

Try to plot these and see if they form somethign that looks like a (straight) line or not.

你们还可以寻找相关技术。 http://www.statsoft.com

“entergraph

What you re looking for is called "statistical regression". There are many methods by which you might do this; here s a site that might help: Least Squares Regression but ultimately, this is a field to which many books have been devoted. There s polynomial regressions, trig regressions, logarithmic...you ll have to know something about your data before you decide which model you apply; if you don t have any knowledge of what the dataset will look like before you process it, I d suggest comparing the residuals of whatever you get and choosing the one with the lowest sum.

简短回答: 无。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...