AuthorIo. D

The problem of “Beautiful Arrays” with C Source code

An array is called beautiful if for every pair of numbers , , (), there exists an  such that . Note that can be equal to or too. Input First line of the input contains an integer T denoting the number of test cases. T test cases follow. First line of each test case contains an integer n denoting number of elements in a. Next line contains n space separated integers denoting the array a. Output...

Upgrading CNC 3020 to support USB connection

The 3020 CNC router is a popular Chinese machine for a good reason. For around 500EUR, you can have a simple CNC with a rigid all-aluminum frame, three decent stepper motors, and pretty good resolution. However, a major disadvantage of this CNC is the out-of-date electronic parts. The motor controller is using a parallel port which is not available in any new computer(PC). For that reason, it is...

K-nearest neighbours algorithm in C

In a previous post we saw the differences between K-means and K-NN. Here is step by step on how to compute K-nearest neighbors KNN algorithm. Determine parameter K = number of nearest neighbors Calculate the distance between the query-instance and all the training samples Sort the distance and determine nearest neighbors based on the K-th minimum distance Gather the category of the nearest...

Difference between K-means and K-nearest neighbor algorithm

In short, the algorithms are trying to accomplish different goals. K-nearest neighbor is a subset of supervised learning classification (or regression) algorithms (it takes a bunch of labeled points and uses them to learn how to label other points). It is supervised because you are trying to classify a point based on the known classification of other points. In contrast, K-means is a subset of...

An overview of Independent Component Analysis

1. What is ICA ? Independent Component Analysis is a technique of separating signals from their linear mixes. We could assume two signals and that are a linear combination of two signals source and , the relationships of and are shown in the following system of linear equations where , , and are the parameters determining the mixing of the signals. These parameters( ) are not known, so the...

Perceptron Neural Network using Matlab

Perceptron is one of the simplest forms of a neural network model. The following code snippet is a simple version of such a neural network using Matlab. Before using it please read some background information at wikipedia :  clc; clear all; close all; % Data inputs=[1 0 0; 1 0 1;1 1 0;1 1 1]; % Desired Output desiredOutput=[1 1 1 0]; % Learning Rate learningRate=0.1; % HardLimit threshold...

Separation of Image Mixture using FastICA

Image separation of mixed and overlapped images is a frequent problem in computer vision (image processing). The following Matlab source code is a demonstration of image separation using FastICA algorithm based on kurtosis. clc;clear all;close all; original_image1=imread ('input1.jpg'); original_image2=imread ('input2.jpg'); figure() subplot(3,3,1),imshow(original_image1),title('Original Source...

Find the Elapsed Time using Monotonic Clocks in Linux

When a linux program requires measuring elapsed time, you need an individual timer to perform this task. This timer should be independent even if the user changes the time on the system clock. In Linux there are several different implementations for different cases (): CLOCK_REALTIMESystem-wide realtime clock. Setting this clock requires appropriate privileges.CLOCK_MONOTONICClock that cannot be...

Edge detection with a given direction using Matlab

The aim of this article is to detect the edges with a given direction in an image. To that end create a function [ E ] = oriented_edges( I, thr, a, da ) that takes as input a double grayscale image Ι, a threshold value thr, a direction a, and an angle da. The output of the function is a binary image Ε where the pixels that meet the following requirements should have the value 1: The pixel...

Principal Component Analysis using Matlab

PCA is a way of identifying patterns in data, and expressing the data in such a way as to highlight their similarities and differences. Below are the steps of the algorithm: close all; % clear all; clc; % data = load('Data/eeg.mat'); % data = data.data{1,2}; Step 1 – Initialize the dataset, 6 vectors of 32 sample data % % Step 1 - Initialize the dataset, 6 vectors of 32 sample data % X =...

Disclaimer: The present content may not be used for training artificial intelligence or machine learning algorithms. All other uses, including search, entertainment, and commercial use, are permitted.

Categories

Tags