Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Julia Cookbook

You're reading from   Julia Cookbook Over 40 recipes to get you up and running with programming using Julia

Arrow left icon
Product type Paperback
Published in Sep 2016
Publisher
ISBN-13 9781785882012
Length 172 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Raj R Jalem Raj R Jalem
Author Profile Icon Raj R Jalem
Raj R Jalem
Jalem Raj Rohit Jalem Raj Rohit
Author Profile Icon Jalem Raj Rohit
Jalem Raj Rohit
Arrow right icon
View More author details
Toc

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 the following:

    How to do it...

  2. The countne() function does exactly the opposite of the counteq() function in the preceding step. It returns the number of elements that are not equal in both the vectors:
    countne(a,b)
    

    The output...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime