想要找到大偏差的大区域 [英] Want to find large areas of high deviation

查看:63
本文介绍了想要找到大偏差的大区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想测试新钣金成型工艺的效率。在形成之后,我们测量与预期厚度的偏差。



原始数据可视化为方形网格,测量范围从0(正确厚度)到5(高偏离正确的厚度)。



我们希望找到与正确厚度偏差较大的大面积区域。为此,我们计算网格中每个位置的分数。分数是通过将位置自身的偏差,

添加到其周围的偏差来确定的。



例如,在网格中:

We want to test the efficiency of new sheet metal forming process. After forming we measure the deviation from the intended thickness.

The raw data can be visualised as a square grid of measurements ranging from 0 (correct thickness) to 5 (high deviation from correct thickness).

We want to find large areas of high deviation from the correct thickness. To do so, We calculate a score for each location in the grid. The score is determined by adding the location's own deviation,
to its surrounding deviations.

For Example, in a grid:

4 | 2 | 3 | 2
0 | 1 | 2 | 2
1 | 3 | 0 | 2
2 | 0 | 1 | 5

位置(1,1)的得分如下:



得分(1,1)= 4 + 2 + 3 + 0 + 1 + 2 + 1 + 3 + 0 = 16



处理网格边缘附近的位置时得分

应忽略网格外的值。例如,

位置`(0,0)`的分数如下:

The score for location `(1,1)` is follows:

score(1,1) = 4 + 2 + 3 + 0 + 1 + 2 + 1 + 3 + 0 = 16

When dealing with locations around the edge of the grid the score
should ignore values outside the grid. For instance the score of
location `(0, 0)` is as follows:

4 | 2 | 3 | 2
0 | 1 | 2 | 2
1 | 3 | 0 | 2
2 | 0 | 1 | 5

得分(0,0)= 4 + 2 + 0 + 1 = 7



写一个函数:

class解决方案{public string solution(int T,int N,int [] V); } $ / $
,给定一个整数`T`,一个整数'N`和一个零索引数组`V`

由'N * N`整数组成,返回一个'T`最高分的清单和

他们的位置。



每个位置和分数都应格式化:

(x,y,得分)



其中`(x,y)`是网格左上角的零索引向量。 br />


该列表应作为字符串返回:

(x1,y1,score1)(x2,y2,score2)(x3,y3) ,得分3)



如果有多个位置具有相同的分数,则选择左上角的位置

,例如`(1,0,20)(2,0,20)(1,1,20)`



要求网格中top1测量的输入:

score(0,0) = 4 + 2 + 0 + 1 = 7

Write a function:
class Solution { public string solution (int T, int N, int[ ] V); }
that, given an integer `T`, an integer `N` and a zero-indexed array `V`
consisting of `N*N` integers, return a list of the `T` highest scores and
their locations.

Each location and score should be formatted:
(x, y, score)

Where `(x,y)` is the zero-indexed vector from the top-left of the grid.

The list should be returned as a string:
(x1, y1, score1) (x2, y2, score2) (x3, y3, score3)

If there are multiple locations with the same score, prefer locations
to the top-left e.g. `(1, 0 ,20)(2, 0, 20)(1, 1 ,20)`

The inputs asking for the top1 measurement in the grid:

4 | 2 | 3 | 2
0 | 1 | 2 | 2
1 | 3 | 0 | 2
2 | 0 | 1 | 5

将是:



T = 1

N = 4

V = [4,2,3,2,0,1,2,2,1,3,0,2,2,0,1,5]



我尝试了什么:



我不明白输出到底是什么。我不擅长统计。任何人都可以帮我找到解决方案吗?谢谢

Would be:

T = 1
N = 4
V = [4, 2, 3, 2, 0, 1, 2, 2, 1, 3, 0, 2, 2, 0, 1, 5]

What I have tried:

I didn't understand properly what exactly the output is. I am not good at statistics. Can anyone help me to find the solution? Thanks

推荐答案

首先,这不是统计数据。这只是一个分数评估,然后对分数进行排序,这就是你应该解决问题的方法。因为这看起来非常像家庭作业问题而你没有问过关于代码的问题我不会给出任何代码。那是你要做的。



首先,给自己写一个接受输入并将其处理成值网格的方法。矢量向量是存储网格的一种选择。



然后你需要一种方法来计算给定网格,其大小和网格中的位置的分数(X,Y)。它可以将分数作为整数返回。事情变得有点棘手。您需要保存分数以及位置以及可能与左上角的距离,以便您可以轻松地对分数进行排序。我可能会使用一个结构,每个值都作为成员 - 得分,x,y和距离。您可以将结构保存在矢量中。



接下来,对分数矢量进行排序以使它们按顺序排列。您需要具有排序的次要标准,即分数匹配时左上角的距离以及分数和距离匹配时的第三个条件。例如,坐标(1,2)和(2,1)距离左上角是相同的距离,哪一个先来?第三级条件将决定。



最后,给定分数的分类向量,将最高T分数写入指定格式的字符串。



我会将问题分成这四个部分并一次处理一个。
First of all, this is not statistics. It is just a score evaluation and then sorting of the scores and that is the way you should approach the problem. Since this seems remarkably like a homework problem and you didn't ask a question about code I will not give any code. That is for you to do.

First, write yourself a method that accepts the input and process it into a grid of values. A vector of vectors is one option to store the grid.

Then you need a method that computes a score given the grid, its size, and a location in the grid (x,y). It could return the score as an integer. Here's where things get a little tricky. You need to save the scores along with the location and possibly the distance from the top left so you can sort the scores easily. I would probably use a structure with each of these values as the members - score, x, y, and distance. You can save the structures in a vector.

Next, sort the vector of scores to get them in order. You will need to have a secondary criterion for the sort which is the distance from the top left corner for when the scores match and a tertiary condition for when the scores and distances match. For example, the coordinates (1,2) and (2,1) are the same distance from the top left so which one comes first? The tertiary condition will decide that.

Lastly, given the sorted vector of scores, write the top T scores into a string in the specified format.

I would separate the problem into these four components and deal with them one at a time.


这篇关于想要找到大偏差的大区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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