Skip to content

Instantly share code, notes, and snippets.

View Higgcz's full-sized avatar
:octocat:

Vojtech Micka Higgcz

:octocat:
  • NNAISENSE
  • Lugano
View GitHub Profile
@Higgcz
Higgcz / gist:3810770
Created October 1, 2012 10:26
Given a specified total t and a list of integers, find all distinct sums using numbers from the list that add up to t. Use findSum(t, given_numbers, new LinkedList<Integer>())
public static LinkedList<LinkedList<Integer>> findSum(int t, LinkedList<Integer> input, LinkedList<Integer> used) {
LinkedList<LinkedList<Integer>> inner, out = new LinkedList<LinkedList<Integer>>();
Integer sum = 0, temp;
LinkedList<Integer> usedBk, inputBk = (LinkedList<Integer>) input.clone();
while ( !inputBk.isEmpty() ) {
temp = inputBk.poll();
if ( temp == sum ) {
@Higgcz
Higgcz / coinChange.cpp
Created October 5, 2012 18:34
Number of combination for coins changing
#include <iostream>
long change(const int sum, const int coins[], const int size) {
if ( sum == 0 ) return 0;
if ( coins == NULL || size == 0 ) return 0;
long * out = new long[sum + 1];
out[0] = 1;
@Higgcz
Higgcz / gist:3875195
Created October 11, 2012 20:14
Getting classification tresholds.
function [treshold, direction] = classificationTreshold(D1, D2)
meA=D1.Mean;
siA=D1.Sigma;
meC=D2.Mean;
siC=D2.Sigma;
hlavni = (siC^2-siA^2);
funA = [
hlavni
@Higgcz
Higgcz / gist:3989390
Created October 31, 2012 19:52
Parzen function which computes for a given x an estimation of probability p(x).
function y = my_parzen(x, X, sigma, method)
if ( ~exist('method', 'var') ),
method = 'method';
end;
n = length(X);
y = zeros(length(x), 1);
switch method
@Higgcz
Higgcz / gist:3995814
Created November 1, 2012 19:17
Log likelihood function (normal distribution)
covGen = (0.5:0.001:2.5) * 10e2;
for s=1:size(covGen,2),
L(s) = sum(log(normpdf(measurmentX1, Model.Mean, covGen(s))));
end;
@Higgcz
Higgcz / perceptron.m
Created November 7, 2012 18:07
Simple Perceptron algorithm which divide the input space with a linear decision boundary.
function [ model ] = perceptron( data, options )
%PERCEPTRON
%
% INPUT:
% data : struct [ 1xn ] data for training the classifier
% .X
% .y
% limit : int [ 1x1 ] maximum number of iteration
% options : struc [ --- ]
% .limit : int [ 1x1 ] maximum number of iteration
@Higgcz
Higgcz / UIColor+HashParser.h
Created November 20, 2012 00:15
I made a category on UIColor which allows to create color from hex code (eg.: #498ea8). I have tried to use different methods to get number from hex string, but all of them was to slow, something about 0.022 - 0.040 ms. This is the fastest way I've found
//
// UIColor+HashParser.h
//
// Created by Vojtech Micka on 11/19/12.
// Copyright (c) 2012 All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIColor (HexParser)
@Higgcz
Higgcz / montage.m
Created December 6, 2012 19:07
Montage functiong for displaying multiple images as grid
function montage(images, varargin)
%MONTAGE Display multiple images as grid
%
% Synopsis:
% MYMONTAGE(images)
% MYMONTAGE(...,PARAM1,VAL1,PARAM2,VAL2,...) displays the image, specifying
% parameters and corresponding values that control various aspects of the
% image display. Parameter names can be abbreviated, and case does not matter.
%
% Parameters include:
@Higgcz
Higgcz / DifferentElements.c++
Last active December 31, 2015 04:39
Count number of different letters in word in array.
inline unsigned calcStates () {
unsigned numStates = (unsigned) substrings[0].size() + 1;
Word str1, str2;
for ( vector<Word>::iterator str = substrings.begin(); (str+1) != substrings.end(); ) {
str1 = *str;
str2 = *(++str);
unsigned i = 0;
while (str1[i] == str2[i] && i < str1.size()) i++;
%% -------------------------------------------------------------------------
% ( 9 ) Inference & missing values
% -------------------------------------------------------------------------
% Create inference engine
engine = jtree_inf_engine ( bnet );
% Sort brokenData to right order
brokenDataSorted = brokenData ( bnet.ordering, : )';