Feedforward control is essential in highperformance motion control. The aim of this paper is to develop a unified framework for automatic feedforward optimization from both batch-wise data sets as well as real-time data. A statistical analysis is employed to analyze the effect of noise, i.e., an iteration varying disturbance, on feedforward controller performance. This provides new insights, both potential advantages as well as possible hazards of real-time estimation are considered. Finally, a case study confirms and illustrates the results. * The research leading to these results has received funding from the European Union H2020 program under grant agreement n. 637095 (Four-ByThree) and ECSEL-2016-1 under grant agreement n. 737453 (I-MECH).