Distance algorithm

Jonathan Caceres, Sep 30, 01:20
Shuffling Cards by Repeated Sampling

Jonathan Caceres, Sep 19, 23:40
The following algorithm shuffles a deck of cards in-place and is thereby very memory efficient. initially, deck[i]= 1,2,3,...,52.
CardShuffle():
1. for i = 1 to 51 do:
2. j = number drawn uniformly at random between i and 52 inclusive
3. card = deck[j]
4. deck[j] = deck[i]
5. deck[i] = card
Assuming that a random (or pseudorandom) bit generator is available, step (2) above can be implemented using Neumann's method.
When
i = 1 a 6-bit number
r is generated. If the number is between 0 and 51 inclusive, then we set
j = r +1. Otherwise, we generate another 6 bits and repeat. From Lemma 3 it follows that j will be drawn from the correct probability distribution.
Bubble Sort

Jonathan Caceres, Aug 25, 13:49
On each pass adjacent items are compared.
If pair is out of order they are swapped.
At the end of the first pass the largest
element will have bubbled to the last
position in the array.
Bubble Sort Algorithm
var Initialise limit variables to array size
Set right = 50
Set loop 1 = right
Set Swapped = true
dowhile(swapped = true AND loop1 >= 2)
Set loop2 = 1
Set swapped to false
dowhile(loop2 < = loop1 - 1)
if array(loop2)> array(loop2 + 1) the
swap array(loop2) with array(loop2 + 1)
Set swapped = true
end if
Set loop2 = loop2 + 1
end do
Set loop1 = loop1 -1
end do
Uniform Sampling Algorithm

Jonathan Caceres, Mar 29, 00:40
Input: Integer N >= 1
Output: R chosen uniformly at random from [0,N,-1]
Choose 1 to N Randomly (N)
1. Let T be the smallest power of 2 such that T >= N
2. compute R = RGB(log2(T))
3. if R < N then output R and halt
4. goto step(2)
Algorithm or Modeling of cell to cell transmission HIV-1

Jonathan Caceres, Mar 19, 03:49
MODELING CELL-TO-CELL TRANSMISSION FOR HIV-1
Modes of Viral Transmission and Modeling Viral Dynamics
The well-known standard model of viral dynamics (reviewed in 27, 36)
represents the dominant and standard approach to analyze and quantify
the spread of a viral infection within a host. The model follows the
concentrations of target cells (T), infected cells (I), and virions (V).
Their interactions, depicted in Figure 1a, are mathematically
described by the following system of ordinary differential equations:
1.equation 1
Target cells, T, which are cells susceptible to infection, are produced
at a constant rate λ and have an average lifetime of 1/dT. Infected
cells, I, die with rate δ per cell and produce new virions at rate ρ
that are cleared from the system at rate c per virion. In the formulation
given in Equation 1, infection of target cells is mediated (a) by
cell-free virions at a rate dependent on the viral concentration, V, and
a transmission rate constant β and (b) by infected cells with a cell-to-cell
transmission rate constant ω. When cell-to-cell transmission is included
in the model, virus spread and target cell depletion are accelerated (Figure 1b).
Viewed on https://www.annualreviews.org/doi/full/10.1146/annurev-virology-110615-042249#_i24 19 March 2020
Log in vs Login

Jonathan Caceres, Feb 29, 10:05
Log in and login have only seen heavy use since personal
computers became ubiquitous in the 1980s, but they are
now so common that misusing them in your writing can cost
you credibility. Log in (two words) should only be used
as a verb. Login (one word) can be a noun or an adjective.
SORTING

Jonathan Caceres, Jun 27, 11:41
Selection Sort
Writing Sorting Algorithm
Sorting it is the major part of computer routines with huge datasets
and loads of information to process these days, it is a good a idea
to understand of how of how works sort algorithms
Assuming we have an array of numbers like this:
Unsorted Array my_Numbers = [20,5,16,19,9,15,2,18,17,8,12,1,3,7,10,8,6,11,4,13,14]
Sorted Array my_Numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
We will look at the following sorting algorithms
>> Selection sort
>> Bubble sort
>> Insertion sort
>> Shell sort
>>> Selection Sort my_Numbers = [20,5,16,19,9,15,2,18,17,8,12,1,3,7,10,8,6,11,4,13,14]
ALGORITHM
- var my_Numbers = [20,5,16,19,9,15,2,18,17,8,12,1,3,7,10,8,6,11,4,13,14];
- var temp;
- for(var i=0; i=my_Number.length; i++){
- for(var j=0; j=i+1; j++){
- if(my_Numbers[i] > my_Numbers[j]){
- temp = my_Numbers[j];
- my_Number[j] = temp;
- }
- }
- }
Karatsuba multiplication algorithm

Jonathan Caceres, Oct 11, 05:16
The Karatsuba multiplication algorithm
The Karatsuba algorithm is an efficient algorithm for multiplying two large numbers together.
It has a complexity of O(n^2) where n is the size in bits of the numbers being multiplied.
1. Karatsuba(x,y)
2. if |x| <= 16 then return (x*y)
3. m =|x|/2
4. compute a and b such that x = a2^m+b
5. compute c and d such that y = c2^m+d
6. t = Karatsuba (a,c)
7. u = Karatsuba (a+b,c+d)
8. v = Karatsuba (a,d)
9. output (tv2^2m +(u-t-v)2^m +v) and halt
The reason that Karatsuba is faster than the classical approach is that it divides a problem
into three problems of half the size.
Biological or Artificial Neural Networks

Jonathan Caceres, Oct 08, 06:54
The ability to learn and to react to changes in our environment requires some
sort of energy or activity in this case our brain, with billion of network
connections that interact each other in a glorious speed.
But is machine learning or artificial intelligence (AI) getting our jobs? at the
moment humans has replicated the mathematical model of network for communication
still the proper algorithm and the hardware that can connect billion of connection
sort, learn, react, in a blink of an eye.
In the diagram you can see both the biological and the artificial neural networks.
The New Big Wave in Technology Machine Learning

Jonathan Caceres, Oct 08, 06:58
Machine learning systems automatically learn programs from
data. This is often a very attractive alternative to manually
constructing them, and in the last decade the use of machine
learning has spread rapidly throughout computer science
and beyond.
Machine learning is used in Web search, spam
filters, recommender systems, ad placement, credit scoring,
fraud detection, stock trading, drug design, and many other
applications.
LEARNING = REPRESENTATION + EVALUATION + OPTIMIZATION
- Algorithm 1 LearnDT(TrainSet)
- if all examples in TrainSet have the same class y∗ then
- return MakeLeaf(y∗)
- if no feature xj has InfoGain(xj ,y) > 0 then
- y∗ ← Most frequent class in TrainSet
- return MakeLeaf(y∗)
- x∗ ← argmaxxj
- InfoGain(xj ,y)
- TS0 ← Examples in TrainSet with x∗ = 0
- TS1 ← Examples in TrainSet with x∗ = 1
- return MakeNode(x∗, LearnDT(TS0), LearnDT(TS1))
Reference 2019/1/18 viewed url:https://homes.cs.washington.edu/~pedrod/papers/cacm12.pdf
The Stable Marriage Algorithm

Jonathan Caceres, Oct 08, 06:59
David Gale was born in Manhattan. During the years in which he was growing up
and attending school, his home was sometimes in New York City, sometimes in the surrounding
district. He studied at Swarthmore College, Swarthmore, Pennsylvania, and was awarded a B.A.
in mathematics in 1943. He then went to the University of Michigan to study for a Master's Degree
which he was awarded in 1947. For his doctoral research he went to Princeton where he undertook
research in game theory with Albert W Tucker as his thesis advisor. He was a Procter Fellow
during 1948 and received a Ph.D. in 1949 for his thesis Solutions of Finite Two-Person Games.
Stable Marriage Algorithm
- function stable Matching {
- Initialize all m ∈ M and w ∈ W to free
- while ∃ free man m who still has a woman w to propose to {
- w = first woman on m’s list to whom m has not yet proposed
- if w is free
- (m, w) become engaged
- else some pair (m', w) already exists
- if w prefers m to m'
- m' becomes free
- (m, w) become engaged
- else
- (m', w) remain engaged
- }
- }
Node.JS

Jonathan Caceres, Oct 08, 07:04
Node.JS is a great platform to store internet radio shows as its asynchronous
nature allows us to handle multiple streams at the same time without ever having to worry
about different processes interfering with one another. This means we can store different
shows, from different streams, to different locations at the same time.
JSON
{"name" : "Newsjack",
"radioStation" : "BBC Radio 4 Extra",
"playlistURL" : "http://www.bbc.co.uk/radio/listen/live/r4x_aacla.pls",
"startTime" : "22:30",
"duration" : "25",
"recurs" : {
"every" : ["thursday"]
}
You can see the JSON file has a description of the radio station as well the days
of the week that the show is on.
Reading our JSON file
Now that we have a JSON file describing our radio show, let's put it to use.
Create an app.js file and require the following Node.JS modules
var http: required('http'),
fs = required('fs'),
spaw = required('child_process).spawn;
getShowList invoke that function to load in the JSON file.
The readFile function is an asynchronous method, so all data read will be passed
through to a callback.
This and more at LinuxUser magazine thank you.