I added the diagram to C.Zach Martin's answer. I didn't edit his answer as it's disconcerting when the whole sense of an answer is changed by an edit.
My understanding of the original post referred to is that they intended the signal to connect to the top of the circuit and for ground to connect to the bottom
Which is not what CZR has recommended his answer suggests a series connection - sensor signal in at top, output to eg Arduino at bottom.
And I suggest that both are not optimum.
What you want is a "low pass filter" that removes the high frequency variation and noise. Like this - the capacitor is charged and discharged via the resistor. Slower varying signals do this more effectively, faster varying signals have less effect on the capacitor's voltage.
Note that how well this will work depends very very very greatly on the input source and the load. If you provide a sensor part number, or better still a link to a data sheet as well, and specific Arduino connection information (or whatever the load / output is) then we can provide a better answer.
Having R as 1k ohm and C as 100 uF will give a time constant of 1 millisecond. That may not be good enough. Larger capacitors will produce a lower frequency filter. Bigger or much bigger resistor values (10k, 100k) may be usable - but may not, depending on the sensor and load. Help us help you!.
Datasheet - analog sensor GP2Y0A21YK
Datasheet - digital sensor GP2Y0D21YK
Analog & digital in one datasheet
This sensor was referenced by Endolith and may (or may not) be what you are using. If it is then R in the circuit I showed above can't be much more than 1K if the output is (as it appears to be) "open collector". Just adding a capacitor from output to ground would have some effect but the assymetrically driven output could give problems. SO tell us what you are really wanting to use - sensor and load, and we can refine the answer.
Your sensor MAY be one of these. Yes?