Artificial Intelligence Lab 1 : Python Introduction

$24.99 $18.99

import numpy as np Q1) [20 Marks] Random Number Generation Using commands np.random.randint and np.random.rand, generate: 100 random integers in the interval −10 to 10. uniform random numbers in the interval [0, 1]. Q2) [40 Marks] Operations with Vectors [20 Marks]: Write a function which accepts integer n as input and outputs a data set…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:

Description

5/5 – (2 votes)

import numpy as np

Q1) [20 Marks] Random Number Generation

Using commands np.random.randint and np.random.rand, generate:

  1. 100 random integers in the interval −10 to 10.

  1. uniform random numbers in the interval [0, 1]. Q2) [40 Marks] Operations with Vectors

    1. [20 Marks]: Write a function which accepts integer n as input and outputs a data set of n points of form (xi, yi)ni=1 in the 2-dimensional plane (chosen at random) in the interval [−1, 1) [−1, 1). Here (x, y) means points are in 2-dimensions, and the subscript i in (xi, yi) means it is the ith data point.

    2. [10 Marks]: Given a point (xnew, ynew) find k = 5, 10, 15 nearest point in the data

set generated in part a). Distance between point in data set and the new point is given by p

(xi − xnew)2 + (yi − ynew)2. Can you find a better command in numpy to do this? (Hint:

Search in np.linalg).

  1. [10 Marks]: Given a point (xnew, ynew) find k = 5, 10, 15 points in the data set generated in part

  1. that make a positive angle with the new point. Implement this as a separate function.

Q3) Plotting [30 Marks]

  1. [10 Marks] Plot the data set in blue and the k points obtained in Q2 a) and Q2 b) in red.

  1. [10 Marks] Generate n = 100 random integers and plot their histogram.

Q4)[10 Marks] Generate n = 100 random points in the interval [−0.5, 0.5]. Plot the sample mean given by

Artificial Intelligence Lab 1 : Python Introduction
$24.99 $18.99