[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
I have two signals, each one of them is a sum of random cosine
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /sci/ - Science & Math

Thread replies: 11
Thread images: 1
File: 1424966132517.jpg (164 KB, 620x849) Image search: [Google]
1424966132517.jpg
164 KB, 620x849
I have two signals, each one of them is a sum of random cosine & sine waves.
I need to classify them using a clustering algorithm.
How do I go about that using python?
>>
classify what exactly?
>>
>>8143761
I don't know this question is driving me crazy.
That's all what the exercise says.
My best guess is classify them according to the frequencies maybe?
>>
Don't know what the clustering algorithm part of the question is talking about. I would use an FFT in Python using NumPy so you can get a graph with frequency on the X axis. There you will be able to see the frequency spectrum and understand what sine and cosine waves went into making your signal. You'll get awesome graphs if you make sure the frequency resolution is 1 Hz or smaller, but I don't know what you mean by "classify".
>>
Just do FFT and then some clustering algorithm from scikit-learn. ezpz
>>
>>8143835
>>8143842
A previous question asked about the FFT and this question specifically asked to use the clustering algorithms
>>
>>8143789
find some k means algorithm for python

draw the fft of your signal
I might be wrong, but I suggest that as your features, you use frequencies AND phases, you might get something interesting. If phases are irrelevant, you will notice anyway.

each component of the signal corresponds to a point in a 2D space (frequency,phase).

try to visually see how many groups you can form (you can use better methods, but this is just a first test)

use your k-means on the set of obtained points, with the number of groups you want to get

don't know what your signal looks like so you might need more steps, but that's a way to start.
>>
>>8143846
these are my two random signals. It's my first time with python I'm sure it's messy.

N = 10001 # Number of samples
Nf = np.sum(n) # number of Frequencies
t = np.arange(N, dtype= float)
Ts = np.random.rand(Nf)*2000+10
fs = 1/Ts #random frequencies
print(fs)
#random amplitudes
amp= np.random.rand(Nf)*200+10
#First signal
for num in range(0, int(n[0])):
signal1 = np.array(signal1 + np.array(amp[num]* np.cos(fs[num]*2*np.pi*t)))
for num in range(0, int(n[1])):
signal1 = np.array(signal1 + np.array(amp[num+int(n[0])]* np.sin(fs[num+int(n[0])]*2*np.pi*t)))
#Second signal
for num in range(0, int(n[2])):
signal2 = np.array(signal2 + np.array(amp[num+int(n[0])]* np.cos(fs[num+int(n[0])]*2*np.pi*t)))
for num in range(0, int(n[3])):
signal2 = np.array(signal2 + np.array(amp[num+int(n[0])]* np.sin(fs[num+int(n[0])]*2*np.pi*t)))
>>
>>8143854
sorry this is the second signal

#Second signal
for num in range(0, int(n[2])):
signal2 = np.array(signal2 + np.array(amp[num+int(sum(n[0:2]))]* np.cos(fs[num+int(sum(n[0:2]))]*2*np.pi*t)))
for num in range(0, int(n[3])):
signal2 = np.array(signal2 + np.array(amp[num+int(sum(n[0:3]))]* np.sin(fs[num+int(sum(n[0:3]))]*2*np.pi*t)))
>>
>>8143854
I forgot something: you can also consider amplitude as a feature. And here it looks like there is no phase so you can remove that.

and instead of k-means, I suggest a gaussian mixture model because of the rand.
>>
>>8143904
I'm really new to all of this. any help concerning the Gaussian mixture ?
Thread replies: 11
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.