CodePlexProject Hosting for Open Source Software

Suppose each measurment in your sample consists of values for two variables, and you want to know how the variables are related. You might measure the sex and income of a large number of people, or the concentration of a chemical and
the population of fish in different ponds. These are called bivariate samples, and they can be analyzed using the BivariateSample class.

Here is an example that creates and adds some values to a BivariateSample class:

To get information about each variable considered seperately, you can use the X and Y properties to get a read-only Sample of each variable.

To measure the covariance between the two variables, just use the covariance property:

### Tests of Association

To test for an association between X and Y, you can use any one of the standard statistical tests of association: Pearson R, Spearman rho, or Kendall tau. Here is code to perform a Pearson R test. The test statistic is the linear correlation coefficient.

Here is an example that creates and adds some values to a BivariateSample class:

```
BivaraiteSample sample = new BivariateSample();
sample.Add(2.0, 324);
sample.Add(1.5, 550);
sample.Add(3.3, 111);
sample.Add(2.2, 285);
```

To get information about each variable considered seperately, you can use the X and Y properties to get a read-only Sample of each variable.

UncertainValue xMean = sample.X.PopulationMean; UncertainValue xVariance = sample.X.PopulationVariance;

To measure the covariance between the two variables, just use the covariance property:

UncertainValue cov = sample.PopulationCovariance;

TestResult pearson = sample.PersonRTest(); double r = pearson.Statistic; double Q = pearson.RightProbability;

Last edited May 1, 2011 at 11:34 PM by ichbin, version 1