Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #Random selection of the initial guess values
  2. def RandomSearch(Iterations):
  3.  
  4. nIt=Iterations
  5. GuessContainer=[]
  6. ErrorContainer=[]
  7. for k in range(nIt):
  8. lGuess=[np.random.uniform(low=0,high=1) for val in range(4)]
  9. lerror=SquaredError(lGuess)
  10. GuessContainer.append(lGuess) #Contains the list of random initial values
  11. ErrorContainer.append(lerror) #List of the errors
  12. minError=np.min(ErrorContainer) #Min error value
  13. minLocation=[j for j in range(nIt) if ErrorContainer[j]==minError] #Returns the location of the min value in the list
  14. bestGuess=GuessContainer[minLocation[0]] #Best initial value guess
  15.  
  16. return ErrorContainer,bestGuess
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement