Skip to content
Advertisement

How to repeat the steps

In my program I have total of 3 steps.

  1. To find the mean
  2. Split the given list using the mean value
  3. If the threshold value > epsilon then update mean value and repeat the step 2 again with updated mean value, else finished.

I have achieved above two steps anyhow. Third step I have achieved only half and struggling in how to repeat the step 2 till the threshold value will be less than epsilon.

My code is below:

JavaScript

My output of above is:

JavaScript

In this case I have to repeat the step 2 again considering new mean. I am new to Python.

Advertisement

Answer

I’m not able to numpy but i can imagine that all you need is a recursive runner function, i don’t want to break the structure of your code, therefore i did not try to optimize the code. You can try the following code, i tried, it works:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement