A prosthetic joint system comprising: a prosthetic joint, including: a state controller connected to a solenoid in an actuator; a sensor configured to detect prosthetic joint movement data; and a memory; and an optimization unit with a setup mode configured to: generate a plurality of data files containing prosthetic joint movement data from a movement of a prosthetic joint capable of being in one or more states; and iteratively analyze the prosthetic joint movement data for each of the plurality of data files to determine prosthetic joint movement decision values to ensure a state of the prosthetic joint matches with a corresponding movement of the prosthetic joint and/or optimizes performance of said prosthetic joint, characterized in that: the state controller is configured to use the prosthetic joint movement decision values to determine when the state of the prosthetic joint enters a stumble recovery state wherein the prosthetic joint is set to be stiff, in response to an abnormal gait condition and in that the optimization unit is configured to iteratively adjust the prosthetic joint movement decision values corresponding to a transition into the stumble recovery state; wherein the abnormal gait condition for entry into the stumble recovery state comprises: bending the prosthetic joint beyond a bent knee angle decision value; exceeding a maximum leg swing time; exceeding a maximum knee angle rate; not exceeding the bent knee decision value before a swing bend time value; or exceeding the sum of a minimum swing moment boundary. a prosthetic joint, including: a state controller connected to a solenoid in an actuator; a sensor configured to detect prosthetic joint movement data; and a memory; and a state controller connected to a solenoid in an actuator; a sensor configured to detect prosthetic joint movement data; and a memory; and an optimization unit with a setup mode configured to: generate a plurality of data files containing prosthetic joint movement data from a movement of a prosthetic joint capable of being in one or more states; and iteratively analyze the prosthetic joint movement data for each of the plurality of data files to determine prosthetic joint movement decision values to ensure a state of the prosthetic joint matches with a corresponding movement of the prosthetic joint and/or optimizes performance of said prosthetic joint, characterized in that: the state controller is configured to use the prosthetic joint movement decision values to determine when the state of the prosthetic joint enters a stumble recovery state wherein the prosthetic joint is set to be stiff, in response to an abnormal gait condition and in that the optimization unit is configured to iteratively adjust the prosthetic joint movement decision values corresponding to a transition into the stumble recovery state; wherein the abnormal gait condition for entry into the stumble recovery state comprises: bending the prosthetic joint beyond a bent knee angle decision value; exceeding a maximum leg swing time; exceeding a maximum knee angle rate; not exceeding the bent knee decision value before a swing bend time value; or exceeding the sum of a minimum swing moment boundary. generate a plurality of data files containing prosthetic joint movement data from a movement of a prosthetic joint capable of being in one or more states; and iteratively analyze the prosthetic joint movement data for each of the plurality of data files to determine prosthetic joint movement decision values to ensure a state of the prosthetic joint matches with a corresponding movement of the prosthetic joint and/or optimizes performance of said prosthetic joint, characterized in that: the state controller is configured to use the prosthetic joint movement decision values to determine when the state of the prosthetic joint enters a stumble recovery state wherein the prosthetic joint is set to be stiff, in response to an abnormal gait condition and in that the optimization unit is configured to iteratively adjust the prosthetic joint movement decision values corresponding to a transition into the stumble recovery state; wherein the abnormal gait condition for entry into the stumble recovery state comprises: bending the prosthetic joint beyond a bent knee angle decision value; exceeding a maximum leg swing time; exceeding a maximum knee angle rate; not exceeding the bent knee decision value before a swing bend time value; or exceeding the sum of a minimum swing moment boundary. the state controller is configured to use the prosthetic joint movement decision values to determine when the state of the prosthetic joint enters a stumble recovery state wherein the prosthetic joint is set to be stiff, in response to an abnormal gait condition and in that the optimization unit is configured to iteratively adjust the prosthetic joint movement decision values corresponding to a transition into the stumble recovery state; wherein the abnormal gait condition for entry into the stumble recovery state comprises: bending the prosthetic joint beyond a bent knee angle decision value; exceeding a maximum leg swing time; exceeding a maximum knee angle rate; not exceeding the bent knee decision value before a swing bend time value; or exceeding the sum of a minimum swing moment boundary. bending the prosthetic joint beyond a bent knee angle decision value; exceeding a maximum leg swing time; exceeding a maximum knee angle rate; not exceeding the bent knee decision value before a swing bend time value; or exceeding the sum of a minimum swing moment boundary.