|
It may be slightly different, but in essence it is the same issue.
|
|
|
|
|
No Richard..The earlier question was for "curve"... And this one is for "surface". which is pretty complex than Curve.
|
|
|
|
|
|
Not really, a surface is composed of two curves, so it is the same question. If you don't understand curves, you won't understand surfaces. Simple as that.
|
|
|
|
|
Can any one suggest how to create C2 continuous piece wise Bezier spline curve with vector method?
Thanks in advance.
~SSETH
|
|
|
|
|
What do you mean by create?
|
|
|
|
|
|
Does it make any sense to test decision tree on dataset generated randomly? example: (the output "true"/"false" is not conditioned on parameters 1-10)
for (int i = 0; i < l; i++)
{
string[] new_ex = new string[11];
new_ex[0] = ThreadSafeRandom.ThisThreadsRandom.Next(60)%5 == 1 ? "true" : "false";
for (int r = 1; r < 5; r++)
new_ex[r] = (ThreadSafeRandom.ThisThreadsRandom.Next(60)%3).ToString();
for (int r = 5; r < 7; r++)
new_ex[r] = (ThreadSafeRandom.ThisThreadsRandom.Next(60)%3).ToString();
for (int r = 7; r < 9; r++)
new_ex[r] = (ThreadSafeRandom.ThisThreadsRandom.Next(20)%5).ToString();
for (int r = 9; r < 11; r++)
new_ex[r] = (ThreadSafeRandom.ThisThreadsRandom.Next(4)).ToString();
dataset.Add(new_ex);
}
|
|
|
|
|
If your goal was obfuscation, you've accomplished that.
(Consider a generic string LIST and .Add method in the main body).
|
|
|
|
|
coding issues are not relevant, its more like theoretical question but thanks for hints
|
|
|
|
|
I've used random number generation to simulate queues / arrival rates; so yes, decision trees based on random data has it's place.
|
|
|
|
|
Let's assume that ‘k’ is an integer that indicate and reveals exactly the length of subset that sum to 0. Thus length of subset to pick is determined by ‘k’. If I would like to pick only ‘k’ distinct set of integers from any given set of integers in polynomial time without having needed to check through every possible length other than the chosen length. What will be the time complexity and the size of subset for every given subset sum problem?
For example:
Given a set of integers {-3, 17, 30, 12, -8 -15, 7, 45, 16, 9} is there a non-empty subset whose sum is zero? Yes, because k = 5. Output {-3, 17, -8, -15, 9 = 0}
Given a set of integers {12, 5, -6, 7, -22} is there a non-empty subset whose sum is zero? No, because k = null. Output none
Given a set of integers {8, 20, 3, 35, -2, 3, 40, 7, 16, -9, 25} is there a non-empty subset whose sum is zero? Yes, because k = 5. Output {8, 3, -2, -9 = 0}
Given a set of integers {-2, 10, 15, 20, 3, 12, 45, -6, 17, 1, 18, 5} is there a non-empty subset whose sum is zero? Yes because k = 9. Output {-2, 15, 3, 12, -45, -6, 17, 1, 5 = 0}
etc..
modified 5-Feb-16 13:17pm.
|
|
|
|
|
|
Thanks for the response but what I’m trying to say is that will I always find solution in polynomial time if ‘k’ is always right for every given subset sum problem?
|
|
|
|
|
See my April 2014 Tip/Trick: Subset - Sum Problem with Numeric Collections [^]
which includes a very efficient way to generate all possible combinations of n items.
Optimizing to make it more efficient for combinations of n choose k should not be too difficult.
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
Thanks for the response but what I’m trying to say is that will I always find solution in polynomial time if ‘k’ is always right for every given subset sum?
|
|
|
|
|
Hello,
I have a class Tree
public class Tree{
private int tree_height;
private int tree_width;
private int nodes_count;
private List<Node> tree_nodes;}
and class node
public class Node{
private object state;
private int ordering;
private int height;
private int parent;}
I would like to create a method to add a branch to a tree
here is my code:
public void AddBranch(Tree branch, int node_num)
{
if (nodes_count >= node_num && node_num > 0)
{
int last_el_ordering = nodes_count,
first_parent_height = tree_nodes[node_num - 1].Height,
first_parent_ordering = tree_nodes[node_num - 1].Ordering;
tree_nodes.Add(new Node(branch.Tree_nodes.First().State, last_el_ordering + 1, first_parent_ordering, first_parent_height + 1));
foreach (Node el in branch.Tree_nodes.Skip(1))
tree_nodes.Add(new Node(el.State, el.Ordering + last_el_ordering, el.Parent + last_el_ordering, el.Height + first_parent_height));
tree_nodes = tree_nodes.OrderBy(match => match.Height).ToList();
int i = 1;
foreach (Node el in tree_nodes)
{
List<Node> temp = tree_nodes.ToList().FindAll(match => match.Parent == el.Ordering).ToList();
el.Ordering = i++;
if (temp.Count() > 0)
foreach (Node el2 in temp)
el2.Parent = el.Ordering;
}
}
}
I have a little problem when I add new node after connecting two trees eg: to tree
first
a b c
false false false
i want to add a branch
d
false
to the first node
The label "false" which is child of "d" is getting misplaced and I cannot figure out why. Please help.
the input
Tree testing_tree1 = new Tree(new Node("start"));
List<string> temp = new List<string> { "a", "b", "c" };
foreach(string el in temp)
testing_tree1.AddBranch(new Tree(new Node(el)),1);
for (int i = 0; i < 3; i++)
testing_tree1.AddBranch(new Tree(new Node("false")), i+2);
Tree testing_tree2 = new Tree(new Node("d"));
testing_tree2.AddBranch(new Tree(new Node("false")), 1);
testing_tree1.AddBranch(testing_tree2, 1);
testing_tree1.DisplayTree();
Console.Read();
the output
tree depth: 3 tree width: 4 nodes count: 9
Node number:1, Node parent:-1, Node height:1, Node value:start
Node number:2, Node parent:1, Node height:2, Node value:a
Node number:3, Node parent:1, Node height:2, Node value:b
Node number:4, Node parent:1, Node height:2, Node value:c
Node number:5, Node parent:1, Node height:2, Node value
Node number:6, Node parent:2, Node height:3, Node value:false
Node number:7, Node parent:3, Node height:3, Node value:false
Node number:8, Node parent:4, Node height:3, Node value:false
Node number:9, Node parent:8, Node height:3, Node value:false
|
|
|
|
|
Use the debugger and see what your code is really doing.
The debugger permit you to execute your code line by line and inspect variables during execution.
You should see that somewhere, your code is not doing as expected.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Good morning sirs,
please I need your help on a project I am working on, I am new to this discussion forum on algorithm(but not to CodeProject) and new to algorithm itself, someone directed me here.
I started a project on algorithm for plotting SkewT-lnP chart, I have written all other algorithms to do all needed calculations including that of the grids but am stock on how to write the main algorithm for plotting the SkewT chart and the type of graphics library to use. am using c# language and vs2010 IDE.
thanks
|
|
|
|
|
Don't try to write your own graphics routines.
There are a number of open source and commercial libraries available. For the commercial ones, use their trial version.
Create a wrapper for your library calls so you can try different options (VisiBlox; SciChart; etc.).
If your product becomes commercially viable, then get a license if necessary.
|
|
|
|
|
OK, to summarise your problem, you have more than 3 dimensions to plot on a graph.
When plotting 3 dimensions on a graph, we use a projection to map these to 2 dimensions. This is based on the orientation of the axes. You need to create a similar projection from you multidimensional coordinates to a 2 dimensional plane.
Check out 4D Visualization: Projections (1)[^] as a starting point.
|
|
|
|
|
Hello,
Warning: my tree class does not contain links between nodes. To connect two nodes I use leafs. Parent -> Node(linking) -> Node(desired). That way I get "Parameter1" -> "0" -> "false".
Description: examples is list of string[] such that string[0] is "false" or "true" and the rest is "0" - "10" strings as attributes values. AttributesVector has Names - List<string> of attributes and Possible_values List<int> with max value of attributes (10 for all). My output is showing all possible parameters values (0, 1, 2, 3,..., 10) with response 'true' or 'false' and it should consider only the values that make any sense (attribute 1 never get value 0). I don't know why. I also get too many nodes in the tree. I have datasets that I can provide along with csv reader.
private Tree DecisionTreeLearning(List<string[]> examples, AttributesVector attributes_vector, Tree default_tree)
{
if (examples.Count() == 0)
return default_tree;
if (AllExamplesSameClassification(examples))
return new Tree(new Node(examples.First()[0]));
if (attributes_vector.Vector_length == 0)
return MajorityValue(examples);
string chosen_attribute = ChooseAttribute(examples, attributes_vector);
Tree current_tree = new Tree(new Node(chosen_attribute));
Tree current_majority_value = MajorityValue(examples);
int chosen_attr_index = attributes_vector.Names.FindIndex(match => match == chosen_attribute);
int temp2 = 2;
for (int i = 0; i < attributes_vector.Possible_values[chosen_attr_index] + 1; i++)
{
List<string[]> matching_examples = examples.FindAll(match => match[chosen_attr_index] == i.ToString());
List<string> new_attributes_names = new List<string> { };
foreach (string el in attributes_vector.Names)
{
string temp = string.Copy(el);
new_attributes_names.Add(temp);
}
new_attributes_names.RemoveAt(chosen_attr_index);
List<int> new_list_of_possible_values = new List<int> { };
foreach (int el in attributes_vector.Possible_values)
{
int temp = el;
new_list_of_possible_values.Add(temp);
}
new_list_of_possible_values.RemoveAt(chosen_attr_index);
AttributesVector new_attributes_vector = new AttributesVector(new_attributes_names, new_list_of_possible_values);
Tree subtree = new Tree();
subtree = DecisionTreeLearning(matching_examples, new_attributes_vector, current_majority_value);
current_tree.AddBranch(new Tree(new Node(i.ToString())), 1);
current_tree.AddBranch(subtree, temp2++);
}
return current_tree;
}
modified 29-Jan-16 5:17am.
|
|
|
|
|
|
I have 7500 points with me. when I plot in excel it will draw a sine wave with a glitch. I want to know the exact start and end position of the glitch. Is there any algorithm which I can use to find this. i am developing the application in C#. Below are 7500
|
|
|
|
|
i don't know if this is optimal, but it's easy:
if you have a nice big smooth sine wave, you can simply go through each pair of points in order, calculating the slope between each pair. the glitch will start at the spot where the slope changes by more than some threshold. to find the end of the glitch, do the same in reverse.
|
|
|
|
|