protected static Ptg calcFrequency( Ptg[] operands ) throws CalculationException
	{
		Ptg[] firstArr = PtgCalculator.getAllComponents( operands[0] );
		Ptg[] secondArr = PtgCalculator.getAllComponents( operands[1] );
		CompatibleVector t = new CompatibleVector();
		for( Ptg p : secondArr )
		{
			try
			{
				Double d = new Double( String.valueOf( p.getValue() ) );
				t.addOrderedDouble( d );
			}
			catch( NumberFormatException e )
			{
			}
			;
		}
		Double[] binsArr = new Double[t.size()];
		double[] dataArr;
		dataArr = PtgCalculator.getDoubleValueArray( firstArr );
		if( dataArr == null )
		{
			return new PtgErr( PtgErr.ERROR_NA );//20090130 KSC: propagate error
		}
		t.toArray( binsArr );
		int[] retvals = new int[secondArr.length + 1];
		for( double aDataArr : dataArr )
		{
			for( int x = 0; x < binsArr.length; x++ )
			{
				if( aDataArr <= binsArr[x] )
				{
					retvals[x]++;
					x = binsArr.length;
				}
				else if( aDataArr > binsArr[binsArr.length - 1] )
				{
					retvals[binsArr.length]++;
					x = binsArr.length;
				}
			}
		}
		// keep the original locations, so we can put the end result array in the correct order.
		// not used!	double[] originalLocs = PtgCalculator.getDoubleValueArray(secondArr);
		String ret = "{";
		for( int retval : retvals )
		{
			ret += retval + ",";
		}
		ret = ret.substring( 0, ret.length() - 1 ); // get rid of final comma
		ret += "}";

		PtgArray returnArr = new PtgArray();
		returnArr.setVal( ret );
		return returnArr;
	}