DataScience Classroomnotes 02/Jul/2022

Numpy Contd…

  • The method searchsorted() performs binary search in the array and returns the index where the specified value would be inserted to maintain search order
  • The searchsorted() method is assumed to be used on sorted arrays
  • Sorting Arrays
  • Filtering arrays

Randoms Numbers with Numpy

  • Generating random numbers

Random Distribution

  • This is set of random numbers that follow a certain probai=bility density function
  • Generate a 1-D array containing 50 values where each value has to 0,1,2,3 or 4
    • probability for the value to be 0 is 0.1
    • probabilty for the value to 1 is 0.3
    • probabilty for the value to 2 is 0.2
    • probaility for the value to be 3 is 0.2
    • probaility for the value to be 4 is 0.2
  • Generate a 2-D array with values from the above pdf with size 4*5

  • Shuffling arrays

Universal Functions (ufuncs)

  • ufuncs are Numpy functions that operates on ndarray object
  • They are used to implement vectoriazation in Numpy which is faster than iterating over elements
  • ufuncs take additional args
    • where
    • dtype
    • out
  • Sample
  • Next Steps:
    • Write our own ufuncs
  • Refer Here for the jupyter notebook

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner