The crankshaft and camshaft position sensors may be failing or the oder of the pins into the coil. The temperature time switch could be bad, as well as the distributor itself.
These are some things to check before diagnosing the Motronic Control System.
Double check all wire connections for a tight fit and corrosion.
There is a special part number BMW has to test the Motronic System and I do not have access to parts list, but I have test instructions, which have the part number, and the diagrams you will need to test the unit.