variance

Cannot display measure variance in Excel pivot table

I'm trying to display the difference in a measure from one day to the next in Excel (2007) by setting the value field setting to 'Difference From' with Base field = day and Base item = previous. If my underlying data is a SSAS cube, the value that displays for each cell is #N/A. If my underlying data is a set of records on another worksh...

Excel Determine Range

I am creating a spreadsheet which has a column of data, and I would like to calculate the varaince of x number of rows based on x inputed. Any advice? ...

C# : Is Variance (Covariance / Contravariance) another word for Polymorphism ?

I am trying to figure out the exact meaning of the words Covariance and Contravariance from several articles online and questions on StackOverflow, and from what I can understand, it's only another word for polymorphism. Am I correct with the above statement? Or have I got it wrong ? ...

Help using variance in C# 4.0

Here's the problem. I would like to create a class which will contain configuration data. This data consists of key/value pairs. Some examples: "hostName"="localhost", "timeout"=1000, etc.. My initial idea was to store all these in a generic dictionary: private Dictionary<string, ConfigurationItem<object>> Configuration = new Dicti...

Calculating variance with large numbers

I haven't really used variance calculation that much, and I don't know quite what to expect. Actually I'm not too good with math at all. I have a an array of 1000000 random numeric values in the range 0-10000. The array could grow even larger, so I use 64 bit int for sum. I have tried to find code on how to calc variance, but I don't ...

Conditional typing in generic method

Consider the following (heavily simplified) code: public T Function<T>() { if (typeof(T) == typeof(string)) { return (T) (object) "hello"; } ... } It's kind of absurd to first cast to object, then to T. But the compiler has no way of knowing that the previous test assured T is of type string. What is the most eleg...

Finding the spread of each cluster from Kmeans

Hello, I'm trying to detect how well an input vector fits a given cluster centre. I can find the best match quite easily (the centre with the minimum euclidean distance to the input vector is the best), however, I now need to work how good a match that is. To do this I need to find the spread (standard deviation?) of the vectors which ...

Using sim() with lmer()

I have run two multilevel logistic regressions using the same predictors but on two different responses: fruitMLM <- lmer(InsuffFruit ~ Income + HDI + Income:HDI + (1 + Income | Country),family=binomial(link="logit")) fuelMLM <- lmer(Pollution ~ Income + HDI + Income:HDI + (1 + Income | Country),family=binomial(link="logit")) Income...

When is @uncheckedVariance needed in Scala, and why is it used in GenericTraversableTemplate?

@uncheckedVariance can be used to bridge the gap between Scala's declaration site variance annotations and Java's invariant generics. scala> import java.util.Comparator import java.util.Comparator scala> trait Foo[T] extends Comparator[T] defined trait Foo scala> trait Foo[-T] extends Comparator[T] <console>:5: error: contrav...

Is this a covariance bug in C# 4 ?

In the following piece of code I expected to be able to implicitly cast from elements to baseElements because TBase is implicitly convertible to IBase. public interface IBase { } public interface IDerived : IBase { } public class VarianceBug { public void Foo<TBase>() where TBase : IBase { IEnumerable<TBase> elements = n...

Can I have a type that's both, covariant and contravariant, i.e. fully fungible/changeable with sub and super types?

Just a stupid question. I could try it out in 2 minutes, really. It's just that I have 1 GB RAM and have already got 2 instances of VS 2010 open on my desktop, with an instance of VS 2005, too. Opening another instance of VS 2010 would be an over kill. Can I have a type (for now forgetting its semantics) that can be covariant as well as...

Detect variance on generic type parameters of interfaces

Is there a way to reflect on an interface to detect variance on its generic type parameters and return types? In other words, can I use reflection to differentiate between the two interfaces: interface IVariant<out R, in A> { R DoSomething(A arg); } interface IInvariant<R, A> { R DoSomething(A arg); } The IL for both looks the...

ref and out parameters in C# and cannot be marked as variant.

What does the statement mean? From here ref and out parameters in C# and cannot be marked as variant. 1) Does it mean that the following can not be done. public class SomeClass<R, A>: IVariant<R, A> { public virtual R DoSomething( ref A args ) { return null; } } 2) Or does it mean I cannot have the followi...

Homoscedascity test for Two-Way ANOVA

I've been using var.test and bartlett.test to check basic ANOVA assumptions, among others, homoscedascity (homogeniety, equality of variances). Procedure is quite simple for One-Way ANOVA: bartlett.test(x ~ g) # where x is numeric, and g is a factor var.test(x ~ g) But, for 2x2 tables, i.e. Two-Way ANOVA's, I want to do something lik...

Why is there no parameter contra-variance for overriding?

C++ and Java support return-type covariance when overriding methods. Neither, however, support contra-variance in parameter types - instead, it translates to overloading (Java) or hiding (C++). Why is that? It seems to me that there is no harm in allowing that. I can find one reason for it in Java - since it has the "choose-the-most-sp...

Can I "pimp my library" with an analogue of TraversableLike.map that has nicely variant types?

Suppose I want to add functionality like map to a Scala List, something along the lines of list mapmap f, which applies the function f to each element of list twice. (A more serious example might be implementing a parallel or distributed map, but I don't want to get distracted by details in that direction.) My first approach would be o...

My variance function in C# does not return accurate value

The source data : static double[] felix = new double[] { 0.003027523, 0.002012256, -0.001369238, -0.001737660, -0.001647287, 0.000275154, 0.002017238, 0.001372621, 0.000274148, -0.000913576, 0.001920263, 0.001186456, -0.000364631, 0.000638337, 0.000182266, -0.001275626, -0.000821093, 0.001186998, -0.000455996, -0.0...

When using covariance notations or generic bounds in Scala

Hi, In Scala variance can be defined with variance operators like + and - on the generic type argument. For example the List type is covariant in the standard library. class List[+A] So a function with a covariant list can be defined like this: def foo[A](list : List[A]) Also variance can be emulated with generic bounds. So we can...

Generic parameter delegate?

I'm a bit fuzzy on the new Action/Func/Variance/CoVariance stuff, which is probably what I need. What I want is to be able to pass a delegate as a parameter to a method, that takes a string and returns a bool. The problem is that I can't use a typed delegate or interface since it will be used in different libraries which doesn't share l...