Another implementation using velocity vector:
//- random position expression by Pavel Pehlivanov -
//- ------------------2011-02-03--------------------
//---- to setup scene for this add custom attrs ----
//---- "randX" "randY" "randZ" to target object ----
//--------------------------------------------------
$myObj = "pCube1"; //target object name
$xMin = -10; //x min var
$xMax = 10; //x max var
$yMin = -10; //y min var
$yMax = 10; //y max var
$zMin = -10; //z min var
$zMax = 10; //z max var
$spd = .5; //speed
//get object pos
float $crX = getAttr ($myObj+".tx");
float $rnX = getAttr ($myObj+".randX");
float $crY = getAttr ($myObj+".ty");
float $rnY = getAttr ($myObj+".randY");
float $crZ = getAttr ($myObj+".tz");
float $rnZ = getAttr ($myObj+".randZ");
vector $currPos = <<$crX,$crY,$crZ>>;
vector $targetPos = <<$rnX,$rnY,$rnZ>>;
//compute velocity
vector $targetVelocity = $targetPos-$currPos;
vector $targetUnitVelocity = unit($targetVelocity);
float $targetDist = mag($targetVelocity);
//if current velocity distance is less than speed calculate new pos
if($targetDist<$spd){
//move object to desired pos
setAttr ($myObj+".tx") ($rnX);
setAttr ($myObj+".ty") ($rnY);
setAttr ($myObj+".tz") ($rnZ);
//create new target pos
setAttr ($myObj+".randX") (rand($xMin,$xMax));
setAttr ($myObj+".randY") (rand($yMin,$yMax));
setAttr ($myObj+".randZ") (rand($zMin,$zMax));
}else{
//else move object using vector mult by speed
setAttr ($myObj+".tx") ($crX+($spd*$targetUnitVelocity.x));
setAttr ($myObj+".ty") ($crY+($spd*$targetUnitVelocity.y));
setAttr ($myObj+".tz") ($crZ+($spd*$targetUnitVelocity.z));
}