O'Reilly logo

Julia Cookbook by Jalem Raj Rohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deviation metrics

Metrics that help calculate the distance or similarity between two vectors are called deviation metrics. These metrics help us understand the relationship between the different vectors and the data in them.

Getting ready

You have to have the StatsBase package ready. This can be done by running using StatsBase in the REPL.

How to do it...

  1. For getting the number of elements in a vector that are exactly equal to a set of elements in a vector, we can use the counteq() function.

    For example, consider the two vectors: a = [1, 2, 3, 4, 5, 6] and b = [4, 2, 3, 5, 6, 7].

    The elements at the second and third indexes are equal to each other, so they will be returned as a result of the counteq() function:

    counteq(a,b)
    

    The output would look like ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required