1

In order to increase the computational speed, i need to resize the 1-D numpy array . The caveat here is that the numpy array is to be used as a shape descriptive curve which will further be utilized as a tool to classify the different class.

enter image description here

currently the array has 853 elements. The plot of the array is,

enter image description here

Is there any effective way to reduce the array size but i don't want the plot signature i.e charecteristics to degrade. Note: i want to reduce 853 to 64 samples effectively without losing the content signature.

I used res=np.resize(srd,(64,)), to resize the 853 element srd array to 64 elements but the plot of the resized element is completely different. The plot of the array after resizing,

enter image description here

DrBwts
  • 3,470
  • 6
  • 38
  • 62
  • Please post the actual code (not images). Minimum example will be useful. – rpoleski May 25 '20 at 12:37
  • res = np.resize(srd,(64,)), i used this code but the plot of the res array is completely different then the original srd array plot – Saibala Sundram May 25 '20 at 12:50
  • Please post [minimal working example](https://stackoverflow.com/help/minimal-reproducible-example). I also recommend [how to ask](https://stackoverflow.com/help/how-to-ask). – rpoleski May 25 '20 at 13:02
  • With `np.resize` you are just keeping the first 64 elementes. You can see that in the plots. – darcamo May 25 '20 at 13:17
  • Do you require the samples to be equispaced or do you want something more adaptive? – norok2 May 25 '20 at 13:46
  • Does this answer your question? [Resample a numpy array](https://stackoverflow.com/questions/29085268/resample-a-numpy-array) – norok2 May 25 '20 at 13:50

1 Answers1

1

1) Simplest solution would be taking every n-th sample of your signal (reduce the shape by a factor of n). Example:

resampled_signal = signal[::2]

2) More advanced solutions involve using resample or intep1d from scipy library

S. Iakovlev
  • 126
  • 1
  • 8