Giter Site home page Giter Site logo

parametric_modeling's Introduction

parametric_modeling

Parametric modelling functions that can be found in MATLAB... now in Python! (AR, ARMA, frequency response modeling) The idea is to have all the functions listed at: http://www.mathworks.es/es/help/signal/parametric-modeling.html

Note about license: All the code I wrote is BSD as stated in the LICENSE file. Any commented/inspired by MATLAB code is of their own property. Given this was a project for university I won't dig further into this issue. If you want to re-use this code, you should research under what conditions you can based on that.

Right now we have:

Also I needed to implement:

  • convmtx Convolution matrix
    • Working thanks to... me!

===================

Developed using Python 2.7, Eclipse + PyDev, MATLAB R2013a 64 bits

  • Using numpy 1.6.1 (from ubuntu debs, using Ubuntu 12.04 64 bit)
sudo apt-get install numpy
  • Using scipy 0.13.1 (upgraded it from Ubuntu debs as I needed newer functions and some bugfixes)
sudo pip install scipy
sudo pip install spectrum 

I wanted to use/integrate in: python_control, using a checkout of the most updated branch, can be found at: https://github.com/awesomebytes/python-control-code

But I don't have time for now.

  • For testing purposes using matlabpipe from python-mlabwrap

This great library lets you execute MATLAB code from Python (easily! check the tests xxxxx_matlab_vs_python.py).

https://github.com/awesomebytes/python-mlabwrap

This is a fork from the work of Filipe Fernandes which he forked from http://code.google.com/p/danapeerlab/

git clone https://github.com/awesomebytes/python-mlabwrap
cd python-mlwrap
sudo python setup.py install

Thanks to this tool I can test the behaviour of my functions versus the MATLAB functions and also give the same input data without needing to implement lots of other functions.

A MATLAB to Python code translator which doesn't do all the job but helps

I've rehosted it now in Github https://github.com/awesomebytes/libermate to give it more visibility and add it's README to it and my advice on how to use it if you ever want to translate a MATLAB script to Python.

Guide on How to translate a MATLAB file to Python

Note: I haven't tried it, but you may want to try: https://github.com/victorlei/smop for the automatic MATLAB->Python translation

  1. Use libermate for making a quick automatic translation

python libermate.py ~/my_path_to/my_matlab_script.m

If you have problems check my file: https://github.com/awesomebytes/libermate/blob/master/notes_on_using_libermate.txt

  1. Correct other errors (many mentioned in notes_on_using_libermate.txt), use http://wiki.scipy.org/NumPy_for_Matlab_Users for helping yourself

  2. Check little pieces of code executing in MATLAB the same line using https://github.com/awesomebytes/python-mlabwrap Use any of my test files as an example on how to execute code and recover variables (structs and cells have some problems).

  3. Keep a iPython open to check little doubts (numpy arrays don't behave the same as MATLAB matrices)

  4. Use some IDE on Python to ease your life looking at how to use functions and correcting coding errors, I recomend Eclipse + PyDev

Eclipse (Standard 4.3.1 as of writing) http://www.eclipse.org/downloads/

PyDev plugin (Instructions on how to install) http://pydev.org/manual_101_install.html

You may need to update Java, here you have a nice tutorial on that: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html

parametric_modeling's People

Contributors

awesomebytes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parametric_modeling's Issues

Noise simulation with Yuler & Burg ?

Hi
I want to simulate a sensor's noise after eliminating high frequency noise using wavelt.
I used for this purpose Yuler and Burg. But the problem is that the series diverge. Now, I don't know if the problem is function, in my code, or it's normal when the series diverge.
My code :

import numpy as np
import matplotlib.pyplot as plt
import pywt
from scipy import signal
from spectrum import *
from pylab import *

def simulat_noise_yuler (self,x,ordre):#x = data series
    var=np.var(x)
    noise = np.random.normal(0, var**0.5, len(x))
    ar, variance, coeff_reflection = aryule(x, ordre)

    last_elements=np.array(ar)
    i=0
    while i<len(ar)/2:
        tmp=ar[i]
        ar[i]=ar[len(ar)-1-i]
        ar[len(ar)-1-i]=tmp
        i+=1
    tmp_coef=[]
    i=0
    while i<len(coeff_reflection):
        tmp_coef.append([coeff_reflection[i]])
        i+=1
    coef=np.array(tmp_coef)

    result=[]
    i=0
    new_element=0
    while i<len(x): 
        new_element= last_elements.dot(coef)+ noise[i]
        result.append(float(new_element))
        j=1
        while j<len(last_elements):
            last_elements[j]=last_elements[j-1]
            j+=1
        last_elements[0]=new_element
        i+=1
    return result
import numpy as np
import matplotlib.pyplot as plt
import pywt
from scipy import signal
from spectrum import *
from pylab import *

    def simulation_bruit_burg(self,x,ordre):
        var=numpy.var(x)
        noise = np.random.normal(0, var**0.5, len(x))
        ar, variance, coeff_reflection = arburg(x, ordre)
        i=0
        tmp_ar=[]
        tmp_coef=[]
        while i<len(ar):
            tmp_ar.append(ar[len(ar)-1-i].real)
            tmp_coef.append(coeff_reflection[i].real)
            i+=1

        last_elements=np.array(tmp_ar)
        coeff_reflection=np.array(tmp_coef)

        result=[]
        i=0
        new_element=0
        while i<len(x): 
            new_element= last_elements.dot(coeff_reflection)+ noise[i]
            result.append(float(new_element))
            j=1
            while j<len(last_elements):
                last_elements[j-1]=last_elements[j]
                j+=1
            last_elements[len(last_elements)-1]=new_element
            i+=1
        return result

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.