if (NON_EMPTY_SELECTION)
{
	data_rows  	 = Columns 	(SELECTED_CHART_ROWS);

	if (data_rows % 2 == 0)
	{
		temp = -1;
		data_columns = -1;
		
		for (count = 0; count<data_rows; count = count+1)
		{
			temp2 = SELECTED_CHART_COLS[count];
			if (temp<0)
			{
				temp = temp2;
			}
			else
			{
				if (temp!=temp2)
				{
					if (data_columns<0)
					{
						data_columns = temp2;
					}
					else
					{
						if (temp2!=data_columns)
						{
							break;
						}
					}
				}
			}
		}
		
		if ((count == data_rows)&&(data_columns>=0)&&(temp>=0))
		{
			for (count = 0; count < data_rows; count = count+2)
			{
				if (SELECTED_CHART_ROWS[count]!=SELECTED_CHART_ROWS[count+1])
				{
					break;
				}
			}
		
			if (count==data_rows)
			{
				SELECTED_CHART_ROWS = {2,data_rows/2};
				for (count = 0; count < data_rows; count = count+2)
				{
					SELECTED_CHART_ROWS[0][count/2]=SELECTED_CHART_DATA[count];
					SELECTED_CHART_ROWS[1][count/2]=SELECTED_CHART_DATA[count+1];
				}
				SELECTED_CHART_DATA = SELECTED_CHART_ROWS;
				data_rows = data_rows/2;
				
				/* decide what the weight column is: weights or cum. distr */
				data_mean = 0;
				for (count = 0; count < data_rows; count = count + 1)
				{
					data_var = SELECTED_CHART_DATA[1][count];
					if ((data_var<0)||(data_var>1))
					{
						fprintf (stdout, "Interval probabilities column must contain numbers between 0 and 1.\n");
						return;
					}
					data_mean = data_mean + SELECTED_CHART_DATA[1][count];
				}
				chi2statistic = 0;
				
				for (count = 0; count < data_rows; count = count + 1)
				{
					temp = data_rows*SELECTED_CHART_DATA[1][count];
					chi2statistic = chi2statistic+(SELECTED_CHART_DATA[0][count]*data_rows-temp)^2/temp;
				}
				
				fprintf (stdout, "\nGoodness of fit statisitc: ", chi2statistic, 
								 "\np-value: ", 1-CChi2(chi2statistic,data_rows-1), "\n");
				return 0;
			}
		}
	}

	fprintf (stdout, "Please select two columns with interval proportions (1st column) and hypothesized distribution weights (2nd columns).\n");
}
else
{
	NON_EMPTY_SELECTION = -1;
}

