Hi, welcome to Just Answer.
There's a common problem with these engine's computer not being able to identify the correct cylinder missfiring, you need a scan tool to monitor the engine cylinders and issolate the one with the most missfires which will be the culprit. Commonly it is an ignition coil failure. But can be a fuel injector or another cause as well. You really need to take the car to the dealer where the cylinder can be issolated, but if you want you can buy one ignition coil and install it on a cylidner. Drive the car and see if the rough performance has gone, if not, move that coil to another cylinder, and continue to do this until the missifre is gone or you've swapped that coil to all the cylidners.
Below is the Mazda bullitn that was put out for the technicians, concerning these missfires and how to issolate them.
ALL MODELS EXCEPT B-SERIES TRUCK & TRIBUTE - ENGINE MISFIRE DIAGNOSTIC PROCEDURES - SERVICE TIP
2005-2006 MPV 2003-2006 Mazda6 (2.3L), 2005-2006 Mazda6 (3.0L), 2004-2006 Mazda3, 2006 Mazda5, 2004-2006 RX-8, 2006 MX-5, 2006 MAZDASPEED6
Some vehicles may experience rough idle, hesitation, and/or misfire. The concern may occur with the Malfunction Indicator Light (MIL) illuminated and a Diagnostic Trouble Code (DTC) P0300 stored in PCM memory. In other cases, there may be no MIL illumination or DTC stored. Customers having this concern should have their vehicle repaired using the following repair procedure.
- Before attempting repairs, be sure the concern can be duplicated at the time of diagnosis.
1. Verify customer concern.
2. Record Freeze Frame Data (FFD).
3. Install WDS to vehicle and I.D. the vehicle.
4. Select the TOOLBOX icon at the top of the screen.
5. Select "POWERTRAIN".
6. Select "OBD TEST MODES".
7. Select "MODE6 ON-BOARD TEST RESULTS", then press the Tick mark.
Mode06 shows OBD system monitor completion and monitor results. Nearly all OBD monitors work after every drive cycle. However, the results of monitoring stored in memory is only the last / current driving cycle. For misfire monitors, the last ten (10) drive cycles are stored.
- Be sure the PCM has learned the vehicles crank profile before proceeding. A vehicle equipped with misfire monitor needs to learn the crank shaft profile. If Keep Alive Memory is erased, both Mode06 and crank shaft profile data are erased also. In this case, the vehicle must be driven again.
8. Move the scroll bar on the right side of the screen about 3/4 toward the bottom until you see "MISFIRE CYLINDER DATA" for each cylinder.
9. In the "VALUE" column, if a misfire occurred, there will be a number greater than zero (0) shown for that cylinder. The cylinder with a number greater than zero (0) would then be the misfiring cylinder.
EWMA Exponential Weighted Moving Average. This is an indicator of the average of misfire counts from the last ten (10) driving cycles.
10. If there are all zeroes (0) in the value column for each cylinder, then a misfire did NOT occur in the last 10 drive cycles.
11. Verify repair.
The location of the ignition coil is below, and I have to make a correction, your model only has the one coil "pack" versus the coil for each cylinder i was describing earnlier. So you only need to purchase one coil "pack" and if the missfire remains, you should have it issolated through a factory level scan tool to the cylinder causing it.
Coil Pack location:
PS. Thanks for the ACCPET :)