-1

I want to make a quantization of a complex signal in Python - need to have this signal as a set of discrete nonuniform levels. For example, a part of this signal can be represented as:

x = [0, 0.015, 0.03, 0.04, 0.08, 0.1, 0.11, 0.12, 0.14, 0.17, 0.2, 0.225, 0.24, 0.27, 0.31, 0.32, 0.33, 0.35, 0.36, 0.37, 0.39, 0.4, 0.42, 0.44, 0.45, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.55, 0.57, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.75, 0.77, 0.79, 0.82, 0.88] 

y = [0, 0.5, 1, 1.5, 2, 2.5, 2.75, 2.93, 2.93, 2.8, 2.5, 2, 1.5, 1.15, 1, 0.95, 1, 1.08, 1.10, 1.07, 1.02, 0.9, 0.7, 0.3, 0.1, -0.4, -0.6, -0.65, -0.6, -0.3, 0, 0.35, 0.5, 0.9, 1.2, 1.25, 1.2, 1.1, 0.95, 0.7, 0.5, 0.3, 0, -0.15]

plot(x, y,"r"); grid(True); show()

Could you kindly recommend me how I can make it in Python?

This plot shows what I want to have:

Nayuki
  • 17,911
  • 6
  • 53
  • 80
  • You may want to try [np.digitize](https://numpy.org/doc/stable/reference/generated/numpy.digitize.html). – MaxPowers Dec 23 '20 at 10:15

1 Answers1

-1

Using matplotlib and the marker parameter this is plotted and may meet your requirements.

import matplotlib.pyplot as plt

# x, y data provided

plt.plot(x,y,marker="_")
etch_45
  • 792
  • 1
  • 6
  • 21
  • Thanks for your answer, but it can make just a visualization of the provided set. My question is mostly about quantization of the data set - how to reduce a number of points in data set via replacement to levels (i.e. for similar values that are close define one average value, for example, using "moving average" method). – Alina Belova Dec 17 '20 at 03:56