确定一组数字的模式 [英] Determine a pattern in numbers in a group

查看:148
本文介绍了确定一组数字的模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我按照特定模式有一组50个数字.我输入了30个数字,必须确定第31个数字.我可以吗?

我正在使用c.就像铁路时标一样,输入数据.

If I have a set of 50 numbers following a specific pattern. I entered 30 numbers and have to determine the 31st number. Can I?

I''m using c. Like railway timings type data.

推荐答案

如果您知道这种模式,那么编写代码来填写丢失/跟随的数字将是一件简单的事情.如果您的模式具有实际名称,则可能可以在Internet上的某个地方找到它的公式.例如,此处描述了斐波那契模式:

http://en.wikipedia.org/wiki/Fibonacci_number [
If you know the pattern, it would be a simple matter to write code to fill in missing/following numbers. If your pattern has an actual name, you can probably find a formula for it on the internet somewhere. For instance, the Fibonacci pattern is described here:

http://en.wikipedia.org/wiki/Fibonacci_number[^]


如果是严格模式,则类似于1 4 9 16 25 36(每个递增数字的平方),然后您可以对可以确定下一个数字的函数进行硬编码.

如果您的数据有些模糊(不精确),例如火车在到达前一站的时间之前到达下一站的时间,那么
模糊逻辑 [ ^ ]是解决之道.

模糊逻辑的基本思想是获得一系列输入(也许来自相同的变量,也许来自不同的变量),然后应用一些模糊逻辑来预测将来的下一个值或某些值.

如果您有或可以得到matlab的副本,我会强烈建议阅读有关Fuzzy Inference Systems的matlab帮助手册,并通过其示例进行研究.
实现的代码会稍有不同,但确实可以帮助您理解.

我将对它们的原理做一个粗略的解释.
我不会解释模糊化和反模糊化等技术的详细信息,如果您没有在matlab中阅读它们,那只会使您感到困惑.

以您的火车为例:
火车从A站到B再到C

从A到B的火车的基本时间是25分钟,从B到C的火车的基本时间是35分钟.
然后有一些因素会影响它.
在繁忙时间,火车在每个车站的停留时间更长.
下雨时,火车无法以最快的速度行驶.

现在我们将它们转换为输入:
1.出发站
2.整理站
2.一天中的时间(这是因为它有多忙.您也可以将星期几作为输入)
3.多湿

这些输入中的每一个都采用指定域和范围内的值,通常为0.0-1.0
接下来,我们生成一个函数,该函数会将每个输入映射到其范围内的权重.

对于它有多湿",我将范围设置为0.0(干燥)到1.0(倾盆大雨或冰雹),范围0.0(没有延迟)到1.0(延迟很多)

如果需要,可以跳过此步骤,这更便于最终用户使用.
接下来,我们创建语言变量 [
If it is a strict pattern, something like 1 4 9 16 25 36 (the square of each incrementing number) then you could hard code a function that would determine exactly the next number.

If your data is somewhat fuzzy (not exact) such as what time the train will reach the next station given the time it reached the previous station then Fuzzy Logic[^] would be the way to go.

The basic idea of fuzzy logic is that you get a series of inputs (perhaps from the same variable, and perhaps from different variables) and you apply some fuzzy logic to predict the next value or some value in the future.

If you have or can get a copy of matlab i would strongly recommend reading the matlab help manual about Fuzzy Inference Systems and work through its examples.
The implementation will be slightly different in code, but it will really help your understanding.

I will give a rough explanation of what they are tho.
I will not explain the details of techniques such as fuzzification and defuzzification, if you don''t read about them in matlab then it will just confuse you.

In the case of your train example:
The train travels from station A to B then to C

The base time for the train to get from A to B is 25min and to get from B to C is 35min.
Then there are some factors that affect it.
During busy times the train spends longer at each station.
When it is raining the train cannot travel as fast.

Now we convert these into the inputs:
1. Starting station
2. Finishing station
2. Time of day (this is for how busy it is. You may include day of week as an input as well)
3. How wet it is

Each of these inputs takes a value in a specified domain and range, generally 0.0-1.0
Next we generate a function that will map each input to a weight over its range.

For "How wet it is", I would make the domain 0.0 (dry) to 1.0 (pouring rain or hail) and the range 0.0 (no delay) to 1.0 (delayed a lot)

This step can be skipped if you want, this is more for ease of use by end users.
next we create linguistic variables[^] for each input.
This is basically a word or phrase that represents a value of a specific variable. I have already done this subconsciously in the previous step to help the explanation.

In the case of "How wet it is" again, we might define:
dry      = 0.0
drizzle  = 0.1
mist     = 0.2
moderate = 0.4
heavy    = 0.8
hail     = 1.0



这样用户就可以选择其中一个单词作为变量多湿"的输入,其他变量也是如此.

现在我们有了变量的域(输入),我们需要获取范围(输出),该范围定义了将输入与输出相关联的函数.
对于有多湿"的情况,您需要倾斜的东西,例如linearexponentiallogarithmic.但这可以是您想要的任何东西.
我想说在这种特殊情况下,指数是一个不错的选择.

最后,您需要结合评估所有输入功能的结果以得出最终答案.
您可能需要根据对输入的影响程度,分别对每个输入进行加权.

开始/结束"站点输入将以站点名称作为语言输入,该输入将变为整数并输出从路线起点到该站点的时间,包括每个站点的停靠点.这样,您只需执行完成站"-开始站"即可获得任意两个站之间的基准时间.

电台语言变量:
A = 1
B = 2
C = 3

这样,您可以将工作站名称用作数组或switch语句中的索引.

一天中的时间"输入的域为0-23(小时),并且在其图形中将有2个峰来表示高峰时间(例如,上午7点至上午9点和下午3点至下午6点)

计算完基准时间后,您只需要添加每个输入的加权时间

时间=终点站"-起点站" +一天中的时间" * 2分钟+多湿" * 5分钟

这种解释严格来说不是模糊推理系统,但是您可以更轻松地进行编码和理解.



So that the user would select 1 of those words as the input to the variable "How wet it is", and the same would go for the other variables.

Now that we have the domain (input) of the variable we need to get the range (output) which defines a function that relates the input to the output.
For the case of "How wet it is" you want something with an incline, like linear, exponential or logarithmic. But it can be anything you want.
I would say that exponential would be a good choice in this particular case.

Finally, you need to combine the result from evaluating the function of all your inputs to produce a final answer.
You will likely need to weight each input individually based on how much it will effect the time of arrival.

The Start/Finish station inputs will take the station name as a linguistic input which would turn to an integer and output the time from the start of the route to that station, including stops at each station. This way, you can simply do "Finish Station" - "Start Station" to get the base time that it will take between any 2 stations.

Station linguistic variables:
A = 1
B = 2
C = 3

This way you can use the station name as an index into an array or in a switch statement.

The Time of day input would have a domain of 0-23 (hours) and would have 2 peaks in its graph to represent peak times (7am-9am & 3pm-6pm for example)

Once you have calculated the base time it would take, then you simply need to add on the weighted times from each of the inputs

Time = "Finish Station" - "Start Station" + "Time of day" * 2min + "How wet it is" * 5min

This explanation is not strictly a Fuzzy Inference System, but it will be much easier for you to code and understand.


在一般情况下,我可以在数学上证明从理论上讲这是不可能的. br/> 如果预先知道该模式,则该任务很简单-您不需要前30个数字.
如果模式未知,则理论上是不可能的.

这是证明.

假设您有一种算法 A 定义了整数的模式:对于任何整数 I (有序号),它返回序列的整数值:(I)=> A(I).
现在,问题的表述是:序列的第一个 N 个值是已知的.如何找出 A(N + 1) A 是未知的? (如果 A 是已知的,则任何 I 的答案都是已知的,而无需知道任何值.)
让我们建议解决方案是可能的,并且 A(N + 1)= H .现在证明存在另一种算法B,因此对于任何 I {0..N} B(I)!= A(I)("":不等于),表示 I = N +1 .
由于问题的表述表明 A 是未知的,任何满足上述要求的 B 都将证明该问题无法解决.因此,对于任何给定的 A N ,任何 B 都可以作为证明.
让我们定义 B(I)= A(I)+ I-(I%N),其中""是除以模.可以检查出 I:{0..N} 而不是 B(I)== A(I) b> B(N + 1)== A(I)+ I> A(I)=> 证明.

现在,您可能会纳闷:有很多类似的问题,这些都是IQ测试中常见的问题!答案很简单:它们全都不正确.这种问题的唯一影响纯粹是社会和心理上的(或者更确切地说,属于认知能力):一般人通常遵循相同的模式识别,这通常被认为是正确的答案.如果您没有达到平均水平(尤其是远远高于平均水平!),您将无法通过智商测试!
一个实际的结果是:一个人在同意参加测验的那一刻未通过智商测验.参加或提供智商测试是智力缺陷的明显指示!

—SA
I can prove mathematically, in general case, that this is theoretically impossible.
If the pattern in known in advance, the task is trivial — you don''t need first 30 numbers.
If the pattern is unknown, this is theoretically impossible.

Here is the proof.

Let''s assume you have the algorithm A which defined the pattern of integer numbers: for any integer I (ordering number), it returns integer value of the sequence: (I) => A(I).
Now, the formulation of the problem is: first N values of the sequence are known. How to find out A(N+1) is A is unknown? (If A is known, the answer is known for any I without knowledge of any values.)
Let''s suggest that the solution is possible and A(N+1) = H. Let''s now proof there is another algorithm B, so for any B(I)==A(I) for any I {0..N} and B(I) != A(I) ("!": not equal) for I = N + 1.
As A is stated to be unknown by the formulation of the problem any B satisfying the above requirement will proof that the problem is not solvable. So, for any given A and N, any B will make the proof.
Let''s define B(I) = A(I) + I - (I % N), where "%" is the division by modulo. One can check up that this B(I) == A(I) for I:{0..N}, but for B(N+1) == A(I) + I > A(I) => The proof.

Now, one can wonder: there are many problems like that, typical for IQ tests, etc.! The answer is simple: they all are incorrect. The only effect of such question is purely social and psychological (or rather, belongs to cognitive abilities): average people usually follows the same pattern recognition which is usually considered as a correct answer. If you''re not average (especially well above average!) you would fail IQ test!
One practical consequence is: a person fails IQ test at the moment when she or he agree to take the test. Taking or offering IQ tests is a clear indication of intellectual deficiency!

—SA


这篇关于确定一组数字的模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆