-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Ben Vincent
committed
May 20, 2017
1 parent
be1b858
commit 48cb8f2
Showing
3 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
ddToolbox/models/parametric_models/bens_new_model/SubjectiveTimePowerFunction.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
classdef SubjectiveTimePowerFunction < DeterministicFunction | ||
%SubjectiveTimePowerFunction | ||
|
||
methods (Access = public) | ||
|
||
function obj = SubjectiveTimePowerFunction(varargin) | ||
obj = obj@DeterministicFunction(varargin{:}); | ||
end | ||
|
||
function plot(obj, pointEstimateType) | ||
|
||
%% PLOT N SAMPLES | ||
x = [0:1:365]; | ||
try | ||
plot(x, obj.eval(x, 'nExamples', 100), '-', 'Color',[0.5 0.5 0.5 0.1]) | ||
catch | ||
% backward compatability | ||
plot(x, obj.eval(x, 'nExamples', 100), '-', 'Color',[0.5 0.5 0.5]) | ||
end | ||
|
||
hold on | ||
%% Plot point estimate | ||
y = obj.eval(x, 'pointEstimateType', pointEstimateType); | ||
plot(x, y, '-',... | ||
'Color', 'k',... | ||
'LineWidth', 2) | ||
|
||
%% Formatting | ||
xlabel('objective time', 'interpreter','latex') | ||
ylabel('subjective time', 'interpreter','latex') | ||
box off | ||
axis square | ||
axis tight | ||
end | ||
|
||
end | ||
|
||
|
||
methods (Static, Access = protected) | ||
|
||
function y = function_evaluation(x, theta) | ||
if verLessThan('matlab','9.1') | ||
y = bsxfun(@times, ... | ||
bsxfun(@power, x, theta.tau),... | ||
theta.k); | ||
else | ||
% use new array broadcasting in 2016b | ||
y = theta.k * (x ^ theta.tau); | ||
end | ||
end | ||
|
||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters