locked
Square root factor RRS feed

  • Question

  • Is it theoretically possible to write a Variable.SquareRoot factor (VMP)? Basically the idea is to have a probabilistic version of the vector 2-norm, e.g.

    public static Variable<double> L2Norm(VariableArray<double> array)
    {
        var copy = Variable.Copy(array);
        var vec = Variable.Vector(copy);
        var normSquared = Variable.InnerProduct(array, vec);
        return Variable.SquareRoot(normSquared);
    }


    • Edited by AndyMiles Friday, January 27, 2017 11:49 PM syntax error
    Friday, January 27, 2017 11:49 PM

Answers

  • Yes, it is possible, but you should write a factor for the entire 2-norm, because taking the InnerProduct of an array with itself will not work correctly. This is why the compiler gives an error if you try to write InnerProduct(array, array). Your code works around the error message but doesn't fix the underlying problem with such InnerProducts.
    • Marked as answer by AndyMiles Sunday, January 29, 2017 4:41 PM
    Saturday, January 28, 2017 7:06 PM
    Owner

All replies

  • Yes, it is possible, but you should write a factor for the entire 2-norm, because taking the InnerProduct of an array with itself will not work correctly. This is why the compiler gives an error if you try to write InnerProduct(array, array). Your code works around the error message but doesn't fix the underlying problem with such InnerProducts.
    • Marked as answer by AndyMiles Sunday, January 29, 2017 4:41 PM
    Saturday, January 28, 2017 7:06 PM
    Owner
  • Hi Andy,

    Did you ever write the squareRoot/norm factor? I also need this functionality.

    Friday, July 14, 2017 12:09 PM