human
Probability of obtaining pairs from two arrays such that element from the first array is smaller than that of the second array | Function to find probability such that x < y and X belongs to arr1 [ ] and Y belongs to arr2 [ ].
Stores the length of arr1.
Stores the length of arr2.
Stores the result.
Traverse the arr1 [ ].
Stores the count of elements in arr2 that are greater than arr [ i ].
Traverse the arr2 [ ].
If arr2 [ j ] is greater than arr1 [ i ].
Increment res by y.
Update the value of res.
Return resultant probability.
Driver Code"
How can the above be solved in Python?
 ... Write me a code to probability of obtaining pairs from two arrays such that element from the first array is smaller than that of the second array and the other steps required?
assistant
#Here is code to probability of obtaining pairs from two arrays such that element from the first array is smaller than that of the second array and the other steps required.
 def probability ( arr1 , arr2 ) :
	N = len ( arr1 )
	M = len ( arr2 )
	res = 0
	for i in range ( N ) :
		y = 0
		for j in range ( M ) :
			if ( arr2 [ j ] > arr1 [ i ] ) :
				y += 1
		res += y
	res = res / ( N * M )
	return res
if __name__ == " _ _ main _ _ " :
	arr1 = [ 5 , 2 , 6 , 1 ]
	arr2 = [ 1 , 6 , 10 , 1 ]
	print ( probability ( arr1 , arr2 ) )