首页 \ 问答 \ Excel公式:根据另一行中的对应值计算一行中的唯一值(Excel Formula: Count Unique Values in a Row Based on Corresponding Value in Another Row)

Excel公式:根据另一行中的对应值计算一行中的唯一值(Excel Formula: Count Unique Values in a Row Based on Corresponding Value in Another Row)

我已经尝试了很长一段时间,我已经尝试了一些不同的方法,无法得到我正在寻找的任何结果。 我在Excel中有一个类似于下面的数据集(为格式化道歉,我还不能发布图像):

          Manager 1     Manager 1       Manager 2        Manager 2
Issuer 1          0           0               0                  0  
Issuer 2        100         100               0                100
Issuer 3        100           0             100                  0
Issuer 4          0           0               0                  0

我正在尝试计算与每个Manager相关联的唯一发行者的数量(“关联”被定义为具有> 0的值)。 每个Issuer都是唯一的(仅在列表中显示一次),但每个Manager可以多次显示。 我想为每个经理人拿一个号码。 那么,结果如下:

经理1:2(不是3,因为发行人2为经理1出现两次,我正在寻找唯一的值,所以它只计算一次)

经理2:2

我可以编写一个公式来计算每个Manager的大于零结果的总数,但不能计算唯一大于零结果的总数。 我尝试过SUMPRODUCT和DCOUNT的变种,但我没有得到正确的结果。 我也可以为我想要实现的目标编写一个宏,但我更喜欢一个公式(部分是为了看看它是如何完成的挑战)。 任何帮助是极大的赞赏!


I've been trying to get this one for quite a while and I've tried a few different approaches and can't get the result I'm looking for with any of them. I have a dataset similar to the below in Excel (apologize for the formatting, I can't yet post images):

          Manager 1     Manager 1       Manager 2        Manager 2
Issuer 1          0           0               0                  0  
Issuer 2        100         100               0                100
Issuer 3        100           0             100                  0
Issuer 4          0           0               0                  0

I'm trying to count the number of unique Issuers associated with each Manager ("associated" being defined as having a value > 0). Each Issuer is unique (only shows up once in the list) but each Manager can show up multiple times. I'm trying to get one number for each Manager. So, the results would be as follows:

Manager 1: 2 (not 3, because Issuer 2 shows up twice for Manager 1, and I'm looking for unique values so it would only be counted once)

Manager 2: 2

I can write a formula to count the total number of greater-than-zero results for each Manager, but not the total number of unique greater-than-zero results. I've tried variations of SUMPRODUCT and DCOUNT but I'm not getting the correct result. I could also write a macro for what I'm trying to achieve but I'd prefer a formula (partly for the challenge in seeing how it can be done). Any help is greatly appreciated!


原文:https://stackoverflow.com/questions/20753066
更新时间:2022-04-16 08:04

最满意答案

谷歌快速搜索“Gurobi目标函数”表明,Gurobi 有一个API来设置一个接受线性二次表达式的目标函数 。 这是非常期待的,因为根据定义 ,二次规划是二次函数的优化,其中数学背后是专门为此类设计的方法(比如,直接使用Q系数矩阵和c矢量而不是原始函数) 。

我没有过多地研究细节,但我可以看出, Pearson积矩相关系数似乎不是二次方而是一个有理函数。 所以,如果你的具体情况不能简化为那个,没有。

我不能说其他解决方案,因为每个解决方案都是一个独立的产品,必须单独考虑。

由于您的函数看似是分段连续且无限可微,因此您可能对通用梯度方法感兴趣。


A quick Google search for "Gurobi objective function" shows that Gurobi has an API to set an objective function that accepts a linear or quadratic expression. That is quite expected because quadratic programming is, by definition, an optimization of a quadratic function, with the math behind the methods specifically designed for this class (like, working directly with the Q coefficient matrix and the c vector rather than the raw function).

I didn't look into details too much, but I can see that Pearson product-moment correlation coefficient appears to be not a quadratic but a rational function. So, if your specific case can't be simplified to that, no.

I cannot say anything about other solvers because each one is an independent product and has to be considered separately.

Since your function appears to be piecewise continuous and infinitely differentiable, you're probably interested in general-purpose gradient methods instead.

相关问答

更多
  • 你在条件“for”中有一点错误,var“i”永远不会超过commonKeys.length function rec(object1, object2) { var sum1 = 0; var sum2 = 0; var squareSum1 = 0; var squareSum2 = 0; var productsSum = 0; var i; var commonKeys = commonProperties(object1, object2); for (i = 0; ...
  • 您可以使用svyvar来估计方差 - 协方差矩阵,然后将其缩放到相关性: library(survey) data(api) dstrat <- svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc) v <- svyvar(~api00+api99, dstrat) as.matrix(v) cov2cor(as.matrix(v)) 这适用于任何数量的关联和任何设计。 You can use svyvar to es ...
  • 你的算法在数学上看起来正确但数值不稳定。 明确找出正方形的总和是灾难的秘诀。 如果你有像array(10000000001, 10000000002, 10000000003)怎么办? 用于计算方差的数字稳定的单程算法可以在维基百科上找到 ,同样的原理可以应用于计算协方差。 更简单一点,如果你不关心速度,你可以使用两遍。 在第一遍中找到平均值,然后在第二遍中使用教科书公式计算方差和协方差。 Your algorithm looks mathematically correct but numerically ...
  • 我没有完全检查你的数学,但有一件事给我的是$TF1^2和$obj1[$x]['count']^2 。 他们正在使用按位异或运算符 。 我相信你想pow($TF1, 2)和pow($obj1[$x]['count'], 2) 或者: $TF1 * $TF1和$obj1[$x]['count'] * $obj1[$x]['count'] 这是一个常见的错误。 同时请注意文章中的免责声明: 上面的公式提供了一种用于计算样本相关性的简便单通道算法,但根据所涉及的数量,它有时可能在数值上不稳定 。 I haven’t ...
  • 相同序列的相关性必须为1 似乎你在例程的最后有问题; 代替 double numerator = productSum - ((pSum * qSum) / (double)Height); double denominator = Math.Sqrt((pSumSq - (pSum * pSum) / (double)Height) * (qSumSq - (qSum * qSum) / (double)Height)); 你应该把 double n = ((double) Width) * He ...
  • 只有当两种股票以相同货币报价时,您的实施才有效,因为它们都是通过相同的外汇汇率时间序列(代码中的buf3)进行转换的。 由于外汇汇率不是固定的,它们都是以其本国货币进行关联的时间可以不同于它们都转换为另一种货币时的关联。 例如,如果两种股票都以欧元计价,并且您以美元计算其相关性,那么您计算的是美元投资者在将美元转换为欧元后再购买股票的相关性。 时间序列波动的部分原因是欧元兑美元汇率波动,而不仅仅是股票价格。 相比之下,这两只资产的欧元投资者只会经历股票价格的相关性,并且不会承受外汇价格。 这真的取决于你在这 ...
  • 居中余弦相似性与Pearson相关性相同。 在theano它可以计算如下: a = T.vector(dtype=theano.config.floatX) b = T.vector(dtype=theano.config.floatX) a_centered, b_centered = a - a.mean(), b - b.mean() r_num = T.dot(a_centered, b_centered) r_den = T.sqrt(T.dot(a_centered, a_centered) ...
  • 根据keras文档 ,您应该将平方相关系数作为函数而不是字符串'mean_squared_error' 。 该函数需要接收2个张量(y_true, y_pred) 。 你可以看看keras 源代码的灵感。 在tf.contrib.metrics.streaming_pearson_correlation上还有一个函数tf.contrib.metrics.streaming_pearson_correlation。 只要注意参数的顺序,它应该是这样的: 更新1:根据这个问题初始化局部变量 import ten ...
  • 谷歌快速搜索“Gurobi目标函数”表明,Gurobi 有一个API来设置一个接受线性或二次表达式的目标函数 。 这是非常期待的,因为根据定义 ,二次规划是二次函数的优化,其中数学背后是专门为此类设计的方法(比如,直接使用Q系数矩阵和c矢量而不是原始函数) 。 我没有过多地研究细节,但我可以看出, Pearson积矩相关系数似乎不是二次方而是一个有理函数。 所以,如果你的具体情况不能简化为那个,没有。 我不能说其他解决方案,因为每个解决方案都是一个独立的产品,必须单独考虑。 由于您的函数看似是分段连续且无限 ...
  • 计算Pearson相关系数; 你需要首先计算Mean然后standard daviation然后correlation coefficient ,如下所述 1.计算平均值 insert into tab2 (tab1_id, mean) select ID, sum([counts]) / (select count(*) from tab1) as mean from tab1 group by ID; 2.计算标准偏差 update tab2 set stddev = ( select sqrt( ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。