protected static Ptg calcAveDev( Ptg[] operands )
	{
		if( operands.length < 1 )
		{
			return new PtgErr( PtgErr.ERROR_VALUE );
		}
		// Get the average for the mean		
		PtgNumber av = (PtgNumber) StatisticalCalculator.calcAverage( operands );
		double average = -0.001;
		try
		{
			Double dd = new Double( String.valueOf( av.getValue() ) );
			average = dd;
		}
		catch( NumberFormatException e )
		{
		}
		;
		if( average == -0.001 )
		{
			return PtgCalculator.getError();
		}

		// work out the total deviation
		double total = 0;
		int count = 0;
		Double d;
		Ptg[] alloperands = PtgCalculator.getAllComponents( operands );
		for( Ptg resPtg : alloperands )
		{
			try
			{  // some fields may be text, so handle gracefully
				if( resPtg.getValue() != null )
				{
					d = new Double( String.valueOf( resPtg.getValue() ) );
					double dub = d;
					dub = average - dub;
					dub = Math.abs( dub );
					total += dub;
					count++;
				}
			}
			catch( NumberFormatException e )
			{
			}
			;
		}
		// work out the mean deviation
		double mean = total / count;
		PtgNumber pnum = new PtgNumber( mean );
		return pnum;
	}