covariance

Autofac: Resolving variant types with both in and out type arguments

隐身守侯 提交于 2019-12-08 16:10:22
问题 This question is a follow up of my previous question: Autofac: Hiding multiple contravariant implementations behind one composite. I'm trying to find the boundries of what we can do with Autofac's covariance and contravariance support. I noticed that Autofac's ContravariantRegistrationSource only supports generic interfaces with a single generic parameter that is marked with the in keyword. This seems to limit the usefulness of this feature, and I'm wondering if Autofac has other ways in

covariance matrix by group

妖精的绣舞 提交于 2019-12-08 09:37:31
问题 I have been able to calculate covariance for my large data set with: cov(MyMatrix, use="pairwise.complete.obs",method="pearson") This provided the covariance table I was looking for, as well as dealing with the NA issues that are throughout my data. For a deeper analysis, however, I want to create covariance matrices that deal separately with the 800+ groups I have in my data set (some have 40+ observations, others only 1). I tried (from http://www.mail-archive.com/r-help@r-project.org

Calculating Mahalanobis distance with C#

烂漫一生 提交于 2019-12-08 06:32:16
问题 I'm trying to calculate the mahalanobis distance with c#. I can't find any real good examples online and I'm new to C#. I am especially having trouble getting the covariance matrix to run right. Any help would be appreciated. Thanks! using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MathNet.Numerics.LinearAlgebra.Double; namespace MahalanobisDistance { class Program { static void Main(string[] args) { Program p = new

numpy.cov() returns unexpected output

 ̄綄美尐妖づ 提交于 2019-12-08 03:50:46
问题 I have a X dataset which has 9 features and 683 rows (683x9). I want to take covariance matrix of this X dataset and another dataset which has same shape with X. I use np.cov(originalData, generatedData, rowvar=False) code to get it but it returns a covariance matrix of shape 18x18. I expected to get 9x9 covariance matrix. Can you please help me to fix it. 回答1: The method cov calculates the covariances for all pairs of variables that you give it. You have 9 variables in one array, and 9 more

calcCovarMatrix in multichannel image and unresolved assertion error

∥☆過路亽.° 提交于 2019-12-08 02:52:11
问题 i'm try to get covariance matrix from an image stored in cv::Mat. i need it for calculate mahalanobis distance and attempt to some color segmentation. this is my code: Mat covar, selection, meanBGR; selection = src(roi); calcCovarMatrix(selection, covar, meanBGR, CV_COVAR_NORMAL|CV_COVAR_ROWS); the Mat src is from webcam and standard BGR opencv format, so CV_32FC3. pixels are stored (i think) in row vector order (blue, green, red).. so i think my code is correct. but i recive this runtime

Why does MATLAB native function cov (covariance matrix computation) use a different divisor than I expect?

社会主义新天地 提交于 2019-12-08 02:47:38
问题 Given a data matrix data of M dimensions and N samples, say, data = randn(N, M); I could compute the covariance matrix with data_mu = data - ones(N, 1)*mean(data); cov_matrix = (data_mu'*data_mu)./N If I use the native MATLAB function cov_matrix2 = cov(data) this will always be equal to cov_matrix = (data_mu'*data_mu)./(N-1) That is, the denominator is (N - 1) is one less. Why?? Can you reproduce it? Is this a bug?? I use MATLAB version 7.6.0.324 (2008). 回答1: That is, the denominator is (N -

numpy.polyfit has no keyword 'cov'

你说的曾经没有我的故事 提交于 2019-12-08 02:02:09
问题 I'm trying to use polyfit to find the best fitting straight line to a set of data, but I also need to know the uncertainty on the parameters, so I want the covariance matrix too. The online documentation suggests I write: polyfit(x, y, 2, cov=True) but this gives the error: TypeError: polyfit() got an unexpected keyword argument 'cov' And sure enough help(polyfit) shows no keyword argument 'cov'. So does the online documentation refer to a previous release of numpy? (I have 1.6.1, the newest

Why A->B doesn't make List<A>->List<B>? Wouldn't that remove need for wildcards?

痞子三分冷 提交于 2019-12-08 01:36:13
问题 Disclaimer: I'm not a professional developer, and I'm not intending to become one. Reading book about Java, as I wanted to try Android programming, no previous Java experience whatsoever. I'm reading this book - and I rather like it. I've read part of chapter about generic classes, got to the point where they mention wildcards, and got confused. If B extends A: List<B> is not a subtype of List<A> (as I understand it they're exactly the same) List<? extends B> is a subtype of List<? extends A>

How to Convert IList<SomeObject> to IList<ISomeInterface> where SomeObject implements ISomeInterface using covariance in C# 4.0

假如想象 提交于 2019-12-07 18:54:52
问题 How to Convert IList to IList where SomeObject implements ISomeInterface using covariance in C# 4.0 I have something similar to following IList<Items> GetItems; IList<IItems> items = GetItems() as IList<IItems>; but items is null; the answer here was for pre 4.0: Converting an array of type T to an array of type I where T implements I in C# 回答1: why not simply use IList<Items> GetItems; IList<IItems> items = GetItems().Cast<IItems>().ToList(); 回答2: For this to work as you are thinking then I

Covariance & Contravariance with List vs IEnumerable

房东的猫 提交于 2019-12-07 15:18:47
问题 So, let's say I have: Public Interface ISomeInterface End Interface Public Class SomeClass Implements ISomeInterface End Class If I have MyList as List(Of SomeClass) , I cannot directly set a List(Of ISomeInterface) = MyList . However, I can Set an IEnumerable(Of ISomeInterface) = MyList . With my understanding of Covariance I thought that it should work list to list since List(Of T) implements IEnumerable(Of T) . Clearly, I am missing something. Why does it work that way? Specifically why