Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Random selection of the initial guess values
- def RandomSearch(Iterations):
- nIt=Iterations
- GuessContainer=[]
- ErrorContainer=[]
- for k in range(nIt):
- lGuess=[np.random.uniform(low=0,high=1) for val in range(4)]
- lerror=SquaredError(lGuess)
- GuessContainer.append(lGuess) #Contains the list of random initial values
- ErrorContainer.append(lerror) #List of the errors
- minError=np.min(ErrorContainer) #Min error value
- minLocation=[j for j in range(nIt) if ErrorContainer[j]==minError] #Returns the location of the min value in the list
- bestGuess=GuessContainer[minLocation[0]] #Best initial value guess
- return ErrorContainer,bestGuess
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement