Most voted "variance" questions
6 questions
Sort by count of
-
40
votes3
answers2698
viewsWhat are covariance and countervariance?
I saw something like in this question and I know that this relates in some way to object orientation. What are they? How do they affect my code, and how can I use them to encode better?…
-
14
votes2
answers341
viewsFirst-class functions: Why should input types be counter-variants?
To demonstrate the problem I will use Scala code (although this is a rule formalized by Luca Cardelli). trait Function1[-A, +R] { def apply(x: A): R } In Scala this means that a function with an…
-
13
votes1
answer333
viewsWhy are arrays covariant and generic are invariant?
Arrays in Java are covariant, that is, it’s perfectly cool to do something like: Number[] meuArray = new Integer[10]; Generic types are invariant. The line below does not compile: List<Number>…
-
11
votes2
answers355
viewsNegative variance in R? Floating point error propagation
Suppose the following formula to calculate the variance: variancia <- function(x) { n <- length(x) (1/(n^2-n))*(n*(sum(x^2))-(sum(x)^2)) } Note that it is equivalent to the function var in…
-
3
votes1
answer48
viewsUnable to initialize a generic object with inheritance
I’m having a hard time accepting an inherited class as a generic class type. public class Teste { private void Testando() { var dog = new Cachorro(); dog.Nome = "Toy"; dog.Patas = 4;…
-
2
votes2
answers44
viewshow to implement the jaccknife method if two terms are removed (in R)
I created the following code to calculate the variance using the jackknife method. However, instead of taking one term at a time, I now need to take it out two by two. I know it’s something basic,…