plateform
stringclasses
1 value
repo_name
stringlengths
13
113
name
stringlengths
3
74
ext
stringclasses
1 value
path
stringlengths
12
229
size
int64
23
843k
source_encoding
stringclasses
9 values
md5
stringlengths
32
32
text
stringlengths
23
843k
github
facundoq/courses-master
ComputeMarginal.m
.m
courses-master/pgm/p7/ComputeMarginal.m
973
utf_8
b17f8235ad67cf5b95fb291d1d46eed1
%ComputeMarginal Computes the marginal over a set of given variables % M = ComputeMarginal(V, F, E) computes the marginal over variables V % in the distribution induced by the set of factors F, given evidence E % % M is a factor containing the marginal over variables V % V is a vector containing the variables i...
github
facundoq/courses-master
AssignmentToIndex.m
.m
courses-master/pgm/p7/AssignmentToIndex.m
609
utf_8
3c17a18df90fc3a49aeebcb3e418e23f
% AssignmentToIndex Convert assignment to index. % % I = AssignmentToIndex(A, D) converts an assignment, A, over variables % with cardinality D to an index into the .val vector for a factor. % If A is a matrix then the function converts each row of A to an index. % % See also IndexToAssignment.m % % Copyright ...
github
facundoq/courses-master
CreateCliqueTree.m
.m
courses-master/pgm/p7/CreateCliqueTree.m
2,121
utf_8
a936108baf3997c53510b2efc9259f7b
%CREATECLIQUETREE Takes in a list of factors F, Evidence and returns a %clique tree after calling ComputeInitialPotentials at the end. % % C = CREATECLIQUETREE(F) Takes a list of factors and creates a clique % tree . The value of the cliques should be initialized to % the initial potential. % It returns a cl...
github
facundoq/courses-master
submitWeb.m
.m
courses-master/pgm/p7/submitWeb.m
580
utf_8
5f4510147426716d140b1e22e95d36d7
% submitWeb Creates files from your code and output for web submission. % % If the submit function does not work for you, use the web-submission mechanism. % Call this function to produce a file for the part you wish to submit. Then, % submit the file to the class servers using the "Web Submission" button on ...
github
facundoq/courses-master
ComputeJointDistribution.m
.m
courses-master/pgm/p7/ComputeJointDistribution.m
906
utf_8
9a44d68defaa54e26172513735c2f85d
%ComputeJointDistribution Computes the joint distribution defined by a set % of given factors % % Joint = ComputeJointDistribution(F) computes the joint distribution % defined by a set of given factors % % Joint is a factor that encapsulates the joint distribution given by F % F is a vector of factors (s...
github
facundoq/courses-master
PrintFactor.m
.m
courses-master/pgm/p7/PrintFactor.m
526
utf_8
7ab925539a614f01ebbef8c4c001d3c2
% Copyright (C) Daphne Koller, Stanford University, 2012 function [] = PrintFactor(F) % Pretty print the factor F. % The first row lists the variables and subsequent rows are % the joint assignment and their associated factor value in % the last column. for i=1:length(F.var) fprintf(1, '%d\t', F.var(i...
github
facundoq/courses-master
InstanceNegLogLikelihood.m
.m
courses-master/pgm/p7/InstanceNegLogLikelihood.m
5,486
utf_8
1480ccb0976ff59c1d9df08e2dc5ffac
% function [nll, grad] = InstanceNegLogLikelihood(X, y, theta, modelParams) % returns the negative log-likelihood and its gradient, given a CRF with parameters theta, % on data (X, y). % % Inputs: % X Data. (numCharacters x numImageFeatures matrix) % X(:,1) is all ones...
github
facundoq/courses-master
ObserveEvidence.m
.m
courses-master/pgm/p7/ObserveEvidence.m
1,905
utf_8
be2baaabecfb90454113523ffef414c2
% ObserveEvidence Modify a vector of factors given some evidence. % F = ObserveEvidence(F, E) sets all entries in the vector of factors, F, % that are not consistent with the evidence, E, to zero. F is a vector of % factors, each a data structure with the following fields: % .var Vector of variables in the...
github
facundoq/courses-master
SetValueOfAssignment.m
.m
courses-master/pgm/p7/SetValueOfAssignment.m
856
utf_8
b9b9de205d3d14c0abd0cc805bae2fc8
%SETVALUEOFASSIGNMENT Sets the value of a variable assignment in a factor. % % F = SETVALUEOFASSIGNMENT(F, A, v) sets the value of a variable assignment, % A, in factor F to v. The order of the variables in A are assumed to be the % same as the order in F.var. % % F = SETVALUEOFASSIGNMENT(F, A, v, VO) set...
github
facundoq/courses-master
IndexToAssignment.m
.m
courses-master/pgm/p2/IndexToAssignment.m
598
utf_8
91464eb3a4bee675ea43f291e36754f6
% IndexToAssignment Convert index to variable assignment. % % A = IndexToAssignment(I, D) converts an index, I, into the .val vector % into an assignment over variables with cardinality D. If I is a vector, % then the function produces a matrix of assignments, one assignment % per row. % % See also A...
github
facundoq/courses-master
submit.m
.m
courses-master/pgm/p2/submit.m
26,858
utf_8
3d05a059f947090116edcf9659a11f24
function submit(partId, webSubmit) %SUBMIT Submit your code and output to the pgm-class servers % SUBMIT() will connect to the pgm-class server and submit your solution % There is no penalty for submitting, so go ahead and try this! % % If this function does not work for you, use the web-submission mechanism. % ...
github
facundoq/courses-master
GetValueOfAssignment.m
.m
courses-master/pgm/p2/GetValueOfAssignment.m
805
utf_8
0cdb098df0b0778650c51563f7710e12
% GetValueOfAssignment Gets the value of a variable assignment in a factor. % % v = GetValueOfAssignment(F, A) returns the value of a variable assignment, % A, in factor F. The order of the variables in A are assumed to be the % same as the order in F.var. % % v = GetValueOfAssignment(F, A, VO) gets the v...
github
facundoq/courses-master
AssignmentToIndex.m
.m
courses-master/pgm/p2/AssignmentToIndex.m
600
utf_8
429d0a6516a1cc5724d602ccf3df86e0
% AssignmentToIndex Convert assignment to index. % % I = AssignmentToIndex(A, D) converts an assignment, A, over variables % with cardinality D to an index into the .val vector for a factor. % If A is a matrix then the function converts each row of A to an index. % % See also IndexToAssignment.m and Samp...
github
facundoq/courses-master
submitWeb.m
.m
courses-master/pgm/p2/submitWeb.m
523
utf_8
6bbecf7bb45a5031ca74002e71845d3e
% submitWeb Creates files from your code and output for web submission. % % If the submit function does not work for you, use the web-submission mechanism. % Call this function to produce a file for the part you wish to submit. Then, % submit the file to the class servers using the "Web Submission" button on ...
github
facundoq/courses-master
SetValueOfAssignment.m
.m
courses-master/pgm/p2/SetValueOfAssignment.m
1,154
utf_8
33321dcc114579d30b93c1fc99b35e17
% SetValueOfAssignment Sets the value of a variable assignment in a factor. % % F = SetValueOfAssignment(F, A, v) sets the value of a variable assignment, % A, in factor F to v. The order of the variables in A are assumed to be the % same as the order in F.var. % % F = SetValueOfAssignment(F, A, v, VO) se...
github
facundoq/courses-master
RunInference.m
.m
courses-master/pgm/p3/RunInference.m
1,864
utf_8
949c039d2cf8422123f6642e76b152a8
function pred = RunInference (factors) % This function performs inference for a Markov network specified as a list % of factors. % % Input: % factors: An array of struct factors, each containing 'var', 'card', and % 'val' fields. % % Output: % pred: An array of predictions for every variable. In particular, % ...
github
facundoq/courses-master
IndexToAssignment.m
.m
courses-master/pgm/p3/IndexToAssignment.m
585
utf_8
5b59626ed9c81a59a158ac9e48e2c257
% IndexToAssignment Convert index to variable assignment. % % A = IndexToAssignment(I, D) converts an index, I, into the .val vector % into an assignment over variables with cardinality D. If I is a vector, % then the function produces a matrix of assignments, one assignment % per row. % % See also A...
github
facundoq/courses-master
submit.m
.m
courses-master/pgm/p3/submit.m
21,118
utf_8
b49fc354ceeadf746a58dfc4abae826f
function submit(partId, webSubmit) %SUBMIT Submit your code and output to the pgm-class servers % SUBMIT() will connect to the pgm-class server and submit your solution % There is no penalty for submitting, so go ahead and try this! % % If this function does not work for you, use the web-submission mechanism. % ...
github
facundoq/courses-master
GetValueOfAssignment.m
.m
courses-master/pgm/p3/GetValueOfAssignment.m
835
utf_8
e0d34fcad4369e061ca88650da3397c9
%GETVALUEOFASSIGNMENT Gets the value of a variable assignment in a factor. % % v = GETVALUEOFASSIGNMENT(F, A) returns the value of a variable assignment, % A, in factor F. The order of the variables in A are assumed to be the % same as the order in F.var. % % v = GETVALUEOFASSIGNMENT(F, A, VO) gets the va...
github
facundoq/courses-master
AssignmentToIndex.m
.m
courses-master/pgm/p3/AssignmentToIndex.m
652
utf_8
98d4cfb7615e1a71bb4c77d5982ddabf
% AssignmentToIndex Convert assignment to index. % % I = AssignmentToIndex(A, D) converts an assignment, A, over variables % with cardinality D to an index into the .val vector for a factor. % If A is a matrix then the function converts each row of A to an index. % % See also IndexToAssignment.m and Samp...
github
facundoq/courses-master
submitWeb.m
.m
courses-master/pgm/p3/submitWeb.m
581
utf_8
40868cac2a1f7de8fbdc5855c255d44d
% submitWeb Creates files from your code and output for web submission. % % If the submit function does not work for you, use the web-submission mechanism. % Call this function to produce a file for the part you wish to submit. Then, % submit the file to the class servers using the "Web Submission" button on ...
github
facundoq/courses-master
eq_factors.m
.m
courses-master/pgm/p3/eq_factors.m
372
utf_8
0425650440c2e53ea5fb0979fb30200d
function eq=eq_factors(F1,F2) assert(length(F1)==length(F2),'Both factor lists must have the same number of elements'); eq=true; for i=1:length(F1) if ~eq_factor(F1(i),F2(i)) eq=false; break; end end end function eq=eq_factor(f1,f2) eq= eq_eps(f1.var,f2.var) && e...
github
facundoq/courses-master
comparedata.m
.m
courses-master/pgm/p3/comparedata.m
12,980
utf_8
a7242d9a91fcd2959131f5fce367f085
function retval=comparedata(data1, data2, context, Params) % function retval=comparedata(data1, data2, context, Params) % compares to see if data1 and data2 are roughly recursively equal. "Rough" here is defined by % the Params. Note that matlabs ISEQUAL function is a test for exact equality. comparedata % ...
github
facundoq/courses-master
SetValueOfAssignment.m
.m
courses-master/pgm/p3/SetValueOfAssignment.m
856
utf_8
2165785a0cb20136c69297b48edfd77e
%SETVALUEOFASSIGNMENT Sets the value of a variable assignment in a factor. % % F = SETVALUEOFASSIGNMENT(F, A, v) sets the value of a variable assignment, % A, in factor F to v. The order of the variables in A are assumed to be the % same as the order in F.var. % % F = SETVALUEOFASSIGNMENT(F, A, v, VO) set...
github
facundoq/courses-master
ComputeExactMarginalsBP.m
.m
courses-master/pgm/old/p4/ComputeExactMarginalsBP.m
1,027
utf_8
7463656744c4aa90967fe0e0ac4c6c0f
%COMPUTEEXACTMARGINALSBP Runs exact inference and returns the marginals %over all the variables (if isMax == 0) or the max-marginals (if isMax == 1). % % M = COMPUTEEXACTMARGINALSBP(F, E, isMax) takes a list of factors F, % evidence E, and a flag isMax, runs exact inference and returns the % final marginals for ...
github
facundoq/courses-master
EliminateVar.m
.m
courses-master/pgm/old/p4/EliminateVar.m
1,346
utf_8
d107c19a06837def63e9460f88420c58
% Function used in production of clique trees % % Copyright (C) Daphne Koller, Stanford University, 2012 function [newF C E] = EliminateVar(F, C, E, Z) useFactors = []; scope = []; for i=1:length(F) if any(F(i).var == Z) useFactors = [useFactors i]; scope = union(scope, F(i).var); end end % ...
github
facundoq/courses-master
IndexToAssignment.m
.m
courses-master/pgm/old/p4/IndexToAssignment.m
641
utf_8
4500d5b7500f21f11c89b80922de3c42
% IndexToAssignment Convert index to variable assignment. % % A = IndexToAssignment(I, D) converts an index, I, into the .val vector % into an assignment over variables with cardinality D. If I is a vector, % then the function produces a matrix of assignments, one assignment % per row. % % See also Assignme...
github
facundoq/courses-master
CliqueTreeCalibrate.m
.m
courses-master/pgm/old/p4/CliqueTreeCalibrate.m
1,848
utf_8
41802a206ec191940f3cf20f266c6290
%CLIQUETREECALIBRATE Performs sum-product or max-product algorithm for %clique tree calibration. % P = CLIQUETREECALIBRATE(P, isMax) calibrates a given clique tree, P % according to the value of isMax flag. If isMax is 1, it uses max-sum % message passing, otherwise uses sum-product. This function % returns...
github
facundoq/courses-master
FactorMarginalization.m
.m
courses-master/pgm/old/p4/FactorMarginalization.m
1,691
utf_8
1a6c278432109b94853fa27ff43fe933
% FactorMarginalization Sums given variables out of a factor. % B = FactorMarginalization(A,V) computes the factor with the variables % in V summed out. The factor data structure has the following fields: % .var Vector of variables in the factor, e.g. [1 2 3] % .card Vector of cardinalities corresp...
github
facundoq/courses-master
DecodedMarginalsToChars.m
.m
courses-master/pgm/old/p4/DecodedMarginalsToChars.m
218
utf_8
02261a4f2b86ec598a6e1c7e98525853
% Copyright (C) Daphne Koller, Stanford University, 2012 function DecodedMarginalsToChars(decodedMarginals) chars = 'abcdefghijklmnopqrstuvwxyz'; fprintf('%c', chars(decodedMarginals)); fprintf('\n'); end
github
facundoq/courses-master
MaxDecoding.m
.m
courses-master/pgm/old/p4/MaxDecoding.m
825
utf_8
77521fc67bc3fda7b4022e983878fcda
%MAXDECODING Finds the best assignment for each variable from the marginals M %passed in. Returns A such that A(i) returns the index of the best %instantiation for variable i. % % For instance: Let's say we have two variables 1 and 2. % Marginals for 1 = [0.1, 0.3, 0.6] % Marginals for 2 = [0.92, 0.08] % A(1) ...
github
facundoq/courses-master
FactorProduct.m
.m
courses-master/pgm/old/p4/FactorProduct.m
2,357
utf_8
06035e60b1296257aaf43c3e4e8aa15c
% FactorProduct Computes the product of two factors. % C = FactorProduct(A,B) computes the product between two factors, A and B, % where each factor is defined over a set of variables with given dimension. % The factor data structure has the following fields: % .var Vector of variables in the factor, e.g...
github
facundoq/courses-master
PA4_Run_Tests.m
.m
courses-master/pgm/old/p4/PA4_Run_Tests.m
2,900
utf_8
9d8a8cc98992d397df6f86722b773415
% A simple test suite for PA 4 % % copy the comparedata.m file from last week's test suite or from % http://www.mathworks.com/matlabcentral/fileexchange/1459-comparedata % into the directory for this weeks assignment and save this file % as PA4_Run_Tests.m % % If you call PA4_RUn_Tests, it will always run all tests in ...
github
facundoq/courses-master
submit.m
.m
courses-master/pgm/old/p4/submit.m
28,922
utf_8
b8b1d235d74470e02883bb719fbc8e8c
function submit(partId, webSubmit) %SUBMIT Submit your code and output to the pgm-class servers % SUBMIT() will connect to the pgm-class server and submit your solution % There is no penalty for submitting, so go ahead and try this! % % If this function does not work for you, use the web-submission mechanism. % ...
github
facundoq/courses-master
StandardizeFactors.m
.m
courses-master/pgm/old/p4/StandardizeFactors.m
621
utf_8
f622aaecac8d0b7e4493aacd074eda6c
% Function that sorts the variables in F and returns an equivalent % factor G. Used only to standardize output for grading purposes. function G = StandardizeFactors(F) G = struct('var', [], 'card', [], 'val', []); for i = 1:length(F) G(i) = StandardizeFactor(F(i)); end function G = StandardizeFactor(F); G = stru...
github
facundoq/courses-master
ComputeInitialPotentials.m
.m
courses-master/pgm/old/p4/ComputeInitialPotentials.m
2,659
utf_8
b5526520826bacd5fc24dba1351ed2c5
%COMPUTEINITIALPOTENTIALS Sets up the cliques in the clique tree that is %passed in as a parameter. % % P = COMPUTEINITIALPOTENTIALS(C) Takes the clique tree skeleton C which is a % struct with three fields: % - nodes: cell array representing the cliques in the tree. % - edges: represents the adjacency matrix o...
github
facundoq/courses-master
GetValueOfAssignment.m
.m
courses-master/pgm/old/p4/GetValueOfAssignment.m
838
utf_8
44eefd1a7a3ae4efe72c80711a4ac67d
% GetValueOfAssignment Gets the value of a variable assignment in a factor. % % v = GetValueOfAssignment(F, A) returns the value of a variable assignment, % A, in factor F. The order of the variables in A are assumed to be the % same as the order in F.var. % % v = GetValueOfAssignment(F, A, VO) gets the value o...
github
facundoq/courses-master
GetNextCliques.m
.m
courses-master/pgm/old/p4/GetNextCliques.m
1,380
utf_8
a4369fa83d781d4e7b3a9aeca267298a
%GETNEXTCLIQUES Find a pair of cliques ready for message passing % [i, j] = GETNEXTCLIQUES(P, messages) finds ready cliques in a given % clique tree, P, and a matrix of current messages. Returns indices i and j % such that clique i is ready to transmit a message to clique j. % % We are doing clique tree message...
github
facundoq/courses-master
FactorMaxMarginalization.m
.m
courses-master/pgm/old/p4/FactorMaxMarginalization.m
1,731
utf_8
a40575c5f3f866ca4b304cfa3f370a6f
% FactorMaxMarginalization Max-marginalizes a factor % by taking the max over a given set variables. % % B = FactorMaxMarginalization(A,V) computes the factor with the variables % in V maxed out. The factor data structure has the following fields: % .var Vector of variables in the factor, e.g. [1 2 3] % ...
github
facundoq/courses-master
ComputeMarginal.m
.m
courses-master/pgm/old/p4/ComputeMarginal.m
1,227
utf_8
67b61710048f402adfa7ea23875b4872
%ComputeMarginal Computes the marginal over a set of given variables % M = ComputeMarginal(V, F, E) computes the marginal over variables V % in the distribution induced by the set of factors F, given evidence E % % M is a factor containing the marginal over variables V % V is a vector containing the variables i...
github
facundoq/courses-master
AssignmentToIndex.m
.m
courses-master/pgm/old/p4/AssignmentToIndex.m
622
utf_8
3da521179d034588af2bfe11ed13f8f7
% AssignmentToIndex Convert assignment to index. % % I = AssignmentToIndex(A, D) converts an assignment, A, over variables % with cardinality D to an index into the .val vector for a factor. % If A is a matrix then the function converts each row of A to an index. % % See also IndexToAssignment.m % % Copyright ...
github
facundoq/courses-master
CreateCliqueTree.m
.m
courses-master/pgm/old/p4/CreateCliqueTree.m
2,238
utf_8
0b309fb32a6aee40615f6221d60a710e
%CREATECLIQUETREE Takes in a list of factors F, Evidence and returns a %clique tree after calling ComputeInitialPotentials at the end. % % P = CREATECLIQUETREE(F, Evidence) Takes a list of factors and creates a clique % tree. The value of the cliques should be initialized to % the initial potential. % It ret...
github
facundoq/courses-master
submitWeb.m
.m
courses-master/pgm/old/p4/submitWeb.m
581
utf_8
40868cac2a1f7de8fbdc5855c255d44d
% submitWeb Creates files from your code and output for web submission. % % If the submit function does not work for you, use the web-submission mechanism. % Call this function to produce a file for the part you wish to submit. Then, % submit the file to the class servers using the "Web Submission" button on ...
github
facundoq/courses-master
ComputeJointDistribution.m
.m
courses-master/pgm/old/p4/ComputeJointDistribution.m
1,270
utf_8
f5233de99da1f71ac79340c59698670d
%ComputeJointDistribution Computes the joint distribution defined by a set % of given factors % % Joint = ComputeJointDistribution(F) computes the joint distribution % defined by a set of given factors % % Joint is a factor that encapsulates the joint distribution given by F % F is a vector of factors (s...
github
facundoq/courses-master
comparedata.m
.m
courses-master/pgm/old/p4/comparedata.m
12,980
utf_8
a7242d9a91fcd2959131f5fce367f085
function retval=comparedata(data1, data2, context, Params) % function retval=comparedata(data1, data2, context, Params) % compares to see if data1 and data2 are roughly recursively equal. "Rough" here is defined by % the Params. Note that matlabs ISEQUAL function is a test for exact equality. comparedata % ...
github
facundoq/courses-master
ObserveEvidence.m
.m
courses-master/pgm/old/p4/ObserveEvidence.m
2,193
utf_8
4af4a267a25aaff99190410099accb86
% ObserveEvidence Modify a vector of factors given some evidence. % F = ObserveEvidence(F, E) sets all entries in the vector of factors, F, % that are not consistent with the evidence, E, to zero. F is a vector of % factors, each a data structure with the following fields: % .var Vector of variables in the...
github
facundoq/courses-master
SetValueOfAssignment.m
.m
courses-master/pgm/old/p4/SetValueOfAssignment.m
1,181
utf_8
6a83e76d1be90e51b6e7eba649f9f209
% SetValueOfAssignment Sets the value of a variable assignment in a factor. % % F = SetValueOfAssignment(F, A, v) sets the value of a variable assignment, % A, in factor F to v. The order of the variables in A are assumed to be the % same as the order in F.var. % % F = SetValueOfAssignment(F, A, v, VO) sets the...
github
facundoq/courses-master
IndexToAssignment.m
.m
courses-master/pgm/old/p2/IndexToAssignment.m
598
utf_8
91464eb3a4bee675ea43f291e36754f6
% IndexToAssignment Convert index to variable assignment. % % A = IndexToAssignment(I, D) converts an index, I, into the .val vector % into an assignment over variables with cardinality D. If I is a vector, % then the function produces a matrix of assignments, one assignment % per row. % % See also A...
github
facundoq/courses-master
submit.m
.m
courses-master/pgm/old/p2/submit.m
26,858
utf_8
3d05a059f947090116edcf9659a11f24
function submit(partId, webSubmit) %SUBMIT Submit your code and output to the pgm-class servers % SUBMIT() will connect to the pgm-class server and submit your solution % There is no penalty for submitting, so go ahead and try this! % % If this function does not work for you, use the web-submission mechanism. % ...
github
facundoq/courses-master
GetValueOfAssignment.m
.m
courses-master/pgm/old/p2/GetValueOfAssignment.m
805
utf_8
0cdb098df0b0778650c51563f7710e12
% GetValueOfAssignment Gets the value of a variable assignment in a factor. % % v = GetValueOfAssignment(F, A) returns the value of a variable assignment, % A, in factor F. The order of the variables in A are assumed to be the % same as the order in F.var. % % v = GetValueOfAssignment(F, A, VO) gets the v...
github
facundoq/courses-master
AssignmentToIndex.m
.m
courses-master/pgm/old/p2/AssignmentToIndex.m
600
utf_8
429d0a6516a1cc5724d602ccf3df86e0
% AssignmentToIndex Convert assignment to index. % % I = AssignmentToIndex(A, D) converts an assignment, A, over variables % with cardinality D to an index into the .val vector for a factor. % If A is a matrix then the function converts each row of A to an index. % % See also IndexToAssignment.m and Samp...
github
facundoq/courses-master
submitWeb.m
.m
courses-master/pgm/old/p2/submitWeb.m
523
utf_8
6bbecf7bb45a5031ca74002e71845d3e
% submitWeb Creates files from your code and output for web submission. % % If the submit function does not work for you, use the web-submission mechanism. % Call this function to produce a file for the part you wish to submit. Then, % submit the file to the class servers using the "Web Submission" button on ...
github
facundoq/courses-master
SetValueOfAssignment.m
.m
courses-master/pgm/old/p2/SetValueOfAssignment.m
1,154
utf_8
33321dcc114579d30b93c1fc99b35e17
% SetValueOfAssignment Sets the value of a variable assignment in a factor. % % F = SetValueOfAssignment(F, A, v) sets the value of a variable assignment, % A, in factor F to v. The order of the variables in A are assumed to be the % same as the order in F.var. % % F = SetValueOfAssignment(F, A, v, VO) se...
github
facundoq/courses-master
PS2_RunTests.m
.m
courses-master/pgm/old/p2/PS2_RunTests/PS2_RunTests.m
5,637
utf_8
6b7a92686737a22e5e43bf7da194732b
function PS2_RunTests() clear; constTOL = 1e-6; load('PA2_TestInput'); load('PA2_TestOutput'); partNames = validParts(); partId = promptPart(); len = length(partNames); partNamesAlligned = char( partNames ); resultAll = 1; for i = 1:len ...
github
facundoq/courses-master
comparedata.m
.m
courses-master/pgm/old/p2/PS2_RunTests/comparedata.m
12,980
utf_8
a7242d9a91fcd2959131f5fce367f085
function retval=comparedata(data1, data2, context, Params) % function retval=comparedata(data1, data2, context, Params) % compares to see if data1 and data2 are roughly recursively equal. "Rough" here is defined by % the Params. Note that matlabs ISEQUAL function is a test for exact equality. comparedata % ...
github
facundoq/courses-master
RunInference.m
.m
courses-master/pgm/old/p3/RunInference.m
1,769
utf_8
1ba1656e4edc7d51078478fedd09878a
function pred = RunInference (factors) % This function performs inference for a Markov network specified as a list % of factors. % % Input: % factors: An array of struct factors, each containing 'var', 'card', and % 'val' fields. % % Output: % pred: An array of predictions for every variable. In particular, % ...
github
facundoq/courses-master
IndexToAssignment.m
.m
courses-master/pgm/old/p3/IndexToAssignment.m
585
utf_8
5b59626ed9c81a59a158ac9e48e2c257
% IndexToAssignment Convert index to variable assignment. % % A = IndexToAssignment(I, D) converts an index, I, into the .val vector % into an assignment over variables with cardinality D. If I is a vector, % then the function produces a matrix of assignments, one assignment % per row. % % See also A...
github
facundoq/courses-master
PA3Test.m
.m
courses-master/pgm/old/p3/PA3Test.m
3,670
utf_8
5b202bcf62d9afa7d2d59c42b1484ab3
% A simple test suite for PA 3 % % copy the comparedata.m file from last week's test suite or from % http://www.mathworks.com/matlabcentral/fileexchange/1459-comparedata % into the directory for this weeks assignment and save this file % as PA3Test.m % % A test can have three different results: % - If the test suite s...
github
facundoq/courses-master
submit.m
.m
courses-master/pgm/old/p3/submit.m
21,118
utf_8
b49fc354ceeadf746a58dfc4abae826f
function submit(partId, webSubmit) %SUBMIT Submit your code and output to the pgm-class servers % SUBMIT() will connect to the pgm-class server and submit your solution % There is no penalty for submitting, so go ahead and try this! % % If this function does not work for you, use the web-submission mechanism. % ...
github
facundoq/courses-master
GetValueOfAssignment.m
.m
courses-master/pgm/old/p3/GetValueOfAssignment.m
835
utf_8
e0d34fcad4369e061ca88650da3397c9
%GETVALUEOFASSIGNMENT Gets the value of a variable assignment in a factor. % % v = GETVALUEOFASSIGNMENT(F, A) returns the value of a variable assignment, % A, in factor F. The order of the variables in A are assumed to be the % same as the order in F.var. % % v = GETVALUEOFASSIGNMENT(F, A, VO) gets the va...
github
facundoq/courses-master
AssignmentToIndex.m
.m
courses-master/pgm/old/p3/AssignmentToIndex.m
652
utf_8
98d4cfb7615e1a71bb4c77d5982ddabf
% AssignmentToIndex Convert assignment to index. % % I = AssignmentToIndex(A, D) converts an assignment, A, over variables % with cardinality D to an index into the .val vector for a factor. % If A is a matrix then the function converts each row of A to an index. % % See also IndexToAssignment.m and Samp...
github
facundoq/courses-master
submitWeb.m
.m
courses-master/pgm/old/p3/submitWeb.m
581
utf_8
40868cac2a1f7de8fbdc5855c255d44d
% submitWeb Creates files from your code and output for web submission. % % If the submit function does not work for you, use the web-submission mechanism. % Call this function to produce a file for the part you wish to submit. Then, % submit the file to the class servers using the "Web Submission" button on ...
github
facundoq/courses-master
comparedata.m
.m
courses-master/pgm/old/p3/comparedata.m
12,980
utf_8
a7242d9a91fcd2959131f5fce367f085
function retval=comparedata(data1, data2, context, Params) % function retval=comparedata(data1, data2, context, Params) % compares to see if data1 and data2 are roughly recursively equal. "Rough" here is defined by % the Params. Note that matlabs ISEQUAL function is a test for exact equality. comparedata % ...
github
facundoq/courses-master
SetValueOfAssignment.m
.m
courses-master/pgm/old/p3/SetValueOfAssignment.m
856
utf_8
2165785a0cb20136c69297b48edfd77e
%SETVALUEOFASSIGNMENT Sets the value of a variable assignment in a factor. % % F = SETVALUEOFASSIGNMENT(F, A, v) sets the value of a variable assignment, % A, in factor F to v. The order of the variables in A are assumed to be the % same as the order in F.var. % % F = SETVALUEOFASSIGNMENT(F, A, v, VO) set...
github
facundoq/courses-master
IndexToAssignment.m
.m
courses-master/pgm/old/p1/IndexToAssignment.m
599
utf_8
ae992bdc926d3d43576329d3737682a2
% IndexToAssignment Convert index to variable assignment. % % A = IndexToAssignment(I, D) converts an index, I, into the .val vector % into an assignment over variables with cardinality D. If I is a vector, % then the function produces a matrix of assignments, one assignment % per row. % % See also A...
github
facundoq/courses-master
FactorMarginalization.m
.m
courses-master/pgm/old/p1/FactorMarginalization.m
1,670
utf_8
33b5e1d1854ef38351d0e2f83985c6c7
% FactorMarginalization Sums given variables out of a factor. % B = FactorMarginalization(A,V) computes the factor with the variables % in V summed out. The factor data structure has the following fields: % .var Vector of variables in the factor, e.g. [1 2 3] % .card Vector of cardinalities cor...
github
facundoq/courses-master
FactorProduct.m
.m
courses-master/pgm/old/p1/FactorProduct.m
2,447
utf_8
171395bdd14a08975b7bb77172cefcd5
% FactorProduct Computes the product of two factors. % C = FactorProduct(A,B) computes the product between two factors, A and B, % where each factor is defined over a set of variables with given dimension. % The factor data structure has the following fields: % .var Vector of variables in the factor,...
github
facundoq/courses-master
submit.m
.m
courses-master/pgm/old/p1/submit.m
22,940
utf_8
a27c89f0871722dbca10d1936da76cae
function submit(partId, webSubmit) %SUBMIT Submit your code and output to the pgm-class servers % SUBMIT() will connect to the pgm-class server and submit your solution % There is no penalty for submitting, so go ahead and try this! % Call this function without arguments (i.e. submit). Make sure your working % ...
github
facundoq/courses-master
StandardizeFactors.m
.m
courses-master/pgm/old/p1/StandardizeFactors.m
581
utf_8
372bcf4422698c44d7cbbec1b0135d85
% Function that sorts the variables in F and returns an equivalent % factor G. Used only to standardize output for grading purposes. function G = StandardizeFactors(F) G = struct('var', [], 'card', [], 'val', []); for i = 1:length(F) G(i) = StandardizeFactor(F(i)); end function G = StandardizeFactor(F); G = stru...
github
facundoq/courses-master
GetValueOfAssignment.m
.m
courses-master/pgm/old/p1/GetValueOfAssignment.m
806
utf_8
a63908225b529b3a7d605707c809a0a2
% GetValueOfAssignment Gets the value of a variable assignment in a factor. % % v = GetValueOfAssignment(F, A) returns the value of a variable assignment, % A, in factor F. The order of the variables in A are assumed to be the % same as the order in F.var. % % v = GetValueOfAssignment(F, A, VO) gets the v...
github
facundoq/courses-master
ComputeMarginal.m
.m
courses-master/pgm/old/p1/ComputeMarginal.m
1,409
utf_8
aa24323bce17b3c2026804439ecf64d1
%ComputeMarginal Computes the marginal over a set of given variables % M = ComputeMarginal(V, F, E) computes the marginal over variables V % in the distribution induced by the set of factors F, given evidence E % % M is a factor containing the marginal over variables V % V is a vector containing the variab...
github
facundoq/courses-master
AssignmentToIndex.m
.m
courses-master/pgm/old/p1/AssignmentToIndex.m
601
utf_8
2c6715c575574bb93ebc1dd4a52002ac
% AssignmentToIndex Convert assignment to index. % % I = AssignmentToIndex(A, D) converts an assignment, A, over variables % with cardinality D to an index into the .val vector for a factor. % If A is a matrix then the function converts each row of A to an index. % % See also IndexToAssignment.m and Fact...
github
facundoq/courses-master
submitWeb.m
.m
courses-master/pgm/old/p1/submitWeb.m
829
utf_8
f9a016a2c73dbb464925709b4f7c2f51
% submitWeb Creates files from your code and output for web submission. % % If the submit function does not work for you, use the web-submission mechanism. % Call this function to produce a file for the part you wish to submit. Then, % submit the file to the class servers using the "Web Submission" button on ...
github
facundoq/courses-master
ComputeJointDistribution.m
.m
courses-master/pgm/old/p1/ComputeJointDistribution.m
1,193
utf_8
fcd1712d5a333fbdaf4194dfc5c6bf35
%ComputeJointDistribution Computes the joint distribution defined by a set % of given factors % % Joint = ComputeJointDistribution(F) computes the joint distribution % defined by a set of given factors % % Joint is a factor that encapsulates the joint distribution given by F % F is a vector of factors (s...
github
facundoq/courses-master
ObserveEvidence.m
.m
courses-master/pgm/old/p1/ObserveEvidence.m
2,205
utf_8
739504ed5aebf8614c3449db44e59e07
% ObserveEvidence Modify a vector of factors given some evidence. % F = ObserveEvidence(F, E) sets all entries in the vector of factors, F, % that are not consistent with the evidence, E, to zero. F is a vector of % factors, each a data structure with the following fields: % .var Vector of variables in...
github
facundoq/courses-master
SetValueOfAssignment.m
.m
courses-master/pgm/old/p1/SetValueOfAssignment.m
1,155
utf_8
8c432b1246dea3f405d525c595d2a82f
% SetValueOfAssignment Sets the value of a variable assignment in a factor. % % F = SetValueOfAssignment(F, A, v) sets the value of a variable assignment, % A, in factor F to v. The order of the variables in A are assumed to be the % same as the order in F.var. % % F = SetValueOfAssignment(F, A, v, VO) se...
github
facundoq/courses-master
FactorSum.m
.m
courses-master/pgm/p6/FactorSum.m
2,340
utf_8
d2e83cf81bd5e92fe61deaa53e6f4643
% FactorSum Computes the sum of two factors. % C = FactorProduct(A,B) computes the sum between two factors, A and B, % where each factor is defined over a set of variables with given dimension. % The factor data structure has the following fields: % .var Vector of variables in the factor, e.g. [1 2 3] % ...
github
facundoq/courses-master
EliminateVar.m
.m
courses-master/pgm/p6/EliminateVar.m
1,446
utf_8
63d8d8f317c1282c1feff173a9c8caef
% Function used in production of clique trees % F = list of factors % E = adjacency matrix for variables % Z = variable to eliminate % % Copyright (C) Daphne Koller, Stanford University, 2012 function [newF E] = EliminateVar(F, E, Z) % Index of factors to multiply (b/c they contain Z) useFactors = []; % Union ...
github
facundoq/courses-master
IndexToAssignment.m
.m
courses-master/pgm/p6/IndexToAssignment.m
641
utf_8
4500d5b7500f21f11c89b80922de3c42
% IndexToAssignment Convert index to variable assignment. % % A = IndexToAssignment(I, D) converts an index, I, into the .val vector % into an assignment over variables with cardinality D. If I is a vector, % then the function produces a matrix of assignments, one assignment % per row. % % See also Assignme...
github
facundoq/courses-master
OptimizeMEU.m
.m
courses-master/pgm/p6/OptimizeMEU.m
2,343
utf_8
e693eb879b674aea24c37cf401a27b2b
% Copyright (C) Daphne Koller, Stanford University, 2012 function [MEU OptimalDecisionRule] = OptimizeMEU( I,euf ) % Inputs: An influence diagram I with a single decision node and a single utility node. % I.RandomFactors = list of factors for each random variable. These are CPDs, with % th...
github
facundoq/courses-master
SimpleCalcExpectedUtility.m
.m
courses-master/pgm/p6/SimpleCalcExpectedUtility.m
1,451
utf_8
70b3e3d62760d8ea01aa659bef8d5310
% Copyright (C) Daphne Koller, Stanford University, 2012 function EU = SimpleCalcExpectedUtility(I) % Inputs: An influence diagram, I (as described in the writeup). % I.RandomFactors = list of factors for each random variable. These are CPDs, with % the child variable = D.var(1) % ...
github
facundoq/courses-master
CPDFromFactor.m
.m
courses-master/pgm/p6/CPDFromFactor.m
780
utf_8
376ed3dcc66b1fb5b12b7816829e56cd
% Copyright (C) Daphne Koller, Stanford University, 2012 function [CPD] = CPDFromFactor(F, Y) nvars = length(F.var); % Reorder the var, card and val fields of Fnew so that the first var is the % child variable. Fnew = F; YIndexInF = find(F.var == Y); this.card = F.card( YIndexInF ); % Parents is a d...
github
facundoq/courses-master
FactorMarginalization.m
.m
courses-master/pgm/p6/FactorMarginalization.m
1,750
utf_8
c5e05c8d4059cb32dcd028428a787bb2
% FactorMarginalization Sums given variables out of a factor. % B = FactorMarginalization(A,V) computes the factor with the variables % in V summed out. The factor data structure has the following fields: % .var Vector of variables in the factor, e.g. [1 2 3] % .card Vector of cardinalities corresp...
github
facundoq/courses-master
NormalizeFactorValues.m
.m
courses-master/pgm/p6/NormalizeFactorValues.m
234
utf_8
8f1abae0e673dcb23d8168c1cff3aae2
% Copyright (C) Daphne Koller, Stanford University, 2012 function F = NormalizeFactorValues( F ) for i=1:length(F) ThisFactor = F(i); ThisFactor.val = ThisFactor.val / sum(ThisFactor.val); F(i) = ThisFactor; end
github
facundoq/courses-master
OptimizeWithJointUtility.m
.m
courses-master/pgm/p6/OptimizeWithJointUtility.m
1,162
utf_8
07ac72d15add3aea32d608afbc98ab93
% Copyright (C) Daphne Koller, Stanford University, 2012 function [meu, odr] = OptimizeWithJointUtility( I ) % Inputs: An influence diagram I with a single decision node and one or more utility nodes. % I.RandomFactors = list of factors for each random variable. These are CPDs, with % the c...
github
facundoq/courses-master
FactorProduct.m
.m
courses-master/pgm/p6/FactorProduct.m
2,357
utf_8
06035e60b1296257aaf43c3e4e8aa15c
% FactorProduct Computes the product of two factors. % C = FactorProduct(A,B) computes the product between two factors, A and B, % where each factor is defined over a set of variables with given dimension. % The factor data structure has the following fields: % .var Vector of variables in the factor, e.g...
github
facundoq/courses-master
CalculateExpectedUtilityFactor.m
.m
courses-master/pgm/p6/CalculateExpectedUtilityFactor.m
1,453
utf_8
2596595287f074dfe245294f7f49262b
% Copyright (C) Daphne Koller, Stanford University, 2012 function EUF = CalculateExpectedUtilityFactor( I ) % Inputs: An influence diagram I with a single decision node and a single utility node. % I.RandomFactors = list of factors for each random variable. These are CPDs, with % the child...
github
facundoq/courses-master
submit.m
.m
courses-master/pgm/p6/submit.m
29,000
utf_8
9740d8a11ffbe15f4d78728c9ce198ea
function submit(partId, webSubmit) %SUBMIT Submit your code and output to the pgm-class servers % SUBMIT() will connect to the pgm-class server and submit your solution % There is no penalty for submitting, so go ahead and try this! % % If this function does not work for you, use the web-submission mechanism. % ...
github
facundoq/courses-master
NormalizeCPDFactors.m
.m
courses-master/pgm/p6/NormalizeCPDFactors.m
845
utf_8
eea30946b1d108ecb184666d4a5980b3
% Copyright (C) Daphne Koller, Stanford University, 2012 function [F] = NormalizeCPDFactors(F) NumFactors = length(F); for i=1:NumFactors f = F(i); dummy.var = f.var(2:end); dummy.card = f.card(2:end); dummy.val = zeros(1,prod(dummy.card)); % Now for each joint assignment to parents, r...
github
facundoq/courses-master
GetValueOfAssignment.m
.m
courses-master/pgm/p6/GetValueOfAssignment.m
838
utf_8
44eefd1a7a3ae4efe72c80711a4ac67d
% GetValueOfAssignment Gets the value of a variable assignment in a factor. % % v = GetValueOfAssignment(F, A) returns the value of a variable assignment, % A, in factor F. The order of the variables in A are assumed to be the % same as the order in F.var. % % v = GetValueOfAssignment(F, A, VO) gets the value o...
github
facundoq/courses-master
test.m
.m
courses-master/pgm/p6/test.m
5,425
utf_8
bf9d0e1af9af6ba2d656f27fe1ebc618
% A simple test suite for PA 6 % % Based on the code by Mihaly Barasz posted on the forum. % % copy the CompareData.m file from last weeks test suite % into the directory for this weeks assignment and save this file % as PA6_RunTests.m % function result = test(anyway) if ~exist('CompareData', 'file') fprintf('please...
github
facundoq/courses-master
AssignmentToIndex.m
.m
courses-master/pgm/p6/AssignmentToIndex.m
621
utf_8
8595f64ecc3b8cd1684ddd5753e83de3
% AssignmentToIndex Convert assignment to index. % % I = AssignmentToIndex(A, D) converts an assignment, A, over variables % with cardinality D to an index into the .val vector for a factor. % If A is a matrix then the function converts each row of A to an index. % % See also IndexToAssignment.m % % Copyright ...
github
facundoq/courses-master
submitWeb.m
.m
courses-master/pgm/p6/submitWeb.m
581
utf_8
40868cac2a1f7de8fbdc5855c255d44d
% submitWeb Creates files from your code and output for web submission. % % If the submit function does not work for you, use the web-submission mechanism. % Call this function to produce a file for the part you wish to submit. Then, % submit the file to the class servers using the "Web Submission" button on ...
github
facundoq/courses-master
PrintFactor.m
.m
courses-master/pgm/p6/PrintFactor.m
526
utf_8
7ab925539a614f01ebbef8c4c001d3c2
% Copyright (C) Daphne Koller, Stanford University, 2012 function [] = PrintFactor(F) % Pretty print the factor F. % The first row lists the variables and subsequent rows are % the joint assignment and their associated factor value in % the last column. for i=1:length(F.var) fprintf(1, '%d\t', F.var(i...
github
facundoq/courses-master
VariableElimination.m
.m
courses-master/pgm/p6/VariableElimination.m
1,379
utf_8
fbe2c579afa50401ca8cf8aea00e68fa
% VariableElimination takes in a list of factors F and a list of variables to eliminate % and returns the resulting factors after running sum-product to eliminate % the given variables. Note that it may return more than one % factor. % % Fnew = VariableElimination(F, Z) % F = list of factors % Z = list of var...
github
facundoq/courses-master
exchange_variable_order.m
.m
courses-master/pgm/p6/exchange_variable_order.m
727
utf_8
a4a3750de5d5379914f27955c1866cba
function f=exchange_variable_order(f,v1,v2) if (v1~=v2) v1_index=find(f.var==v1); v2_index=find(f.var==v2); f=exchange_variable_order_indices(f,v1_index,v2_index); end end function g=exchange_variable_order_indices(f,v1_index,v2_index) %[sortedVars, order] = sort(F.var); %G.var = sorte...
github
facundoq/courses-master
CompareData.m
.m
courses-master/pgm/p6/CompareData.m
13,243
utf_8
902e19647aeaa160c7022598ee7216c1
function retval = CompareData(data1, data2, context, Params) % function retval = comparedata(data1, data2, context, Params) % compares to see if data1 and data2 are roughly recursively equal. "Rough" here is defined by % the Params. Note that matlabs ISEQUAL function is a test for exact equality. comparedata % ...
github
facundoq/courses-master
OptimizeLinearExpectations.m
.m
courses-master/pgm/p6/OptimizeLinearExpectations.m
1,773
utf_8
7702e69bf798c297ff7c82db5052eaf3
% Copyright (C) Daphne Koller, Stanford University, 2012 function [meu, odr] = OptimizeLinearExpectations( I ) % Inputs: An influence diagram I with a single decision node and one or more utility nodes. % I.RandomFactors = list of factors for each random variable. These are CPDs, with % the...
github
facundoq/courses-master
ObserveEvidence.m
.m
courses-master/pgm/p6/ObserveEvidence.m
2,321
utf_8
7ccbe679d2443d219a227f6f29d5785b
% ObserveEvidence Modify a vector of factors given some evidence. % F = ObserveEvidence(F, E) sets all entries in the vector of factors, F, % that are not consistent with the evidence, E, to zero. F is a vector of % factors, each a data structure with the following fields: % .var Vector of variables in the...
github
facundoq/courses-master
SetValueOfAssignment.m
.m
courses-master/pgm/p6/SetValueOfAssignment.m
1,180
utf_8
6fbb116264c5e21b678618dbe6f44a9d
% SetValueOfAssignment Sets the value of a variable assignment in a factor. % % F = SetValueOfAssignment(F, A, v) sets the value of a variable assignment, % A, in factor F to v. The order of the variables in A are assumed to be the % same as the order in F.var. % % F = SetValueOfAssignment(F, A, v, VO) sets the...